diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..d383bdf --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,59 @@ +name: Checks + +on: + push: + branches: [main] + pull_request: + +jobs: + checks: + runs-on: ubuntu-latest + steps: + # Side by side, because the view depends on the design package by + # relative path. Checked out anywhere else that path resolves to nothing. + - uses: actions/checkout@v4 + with: + path: agent + + - uses: actions/checkout@v4 + with: + repository: sourceant/design + path: design + + - uses: actions/setup-go@v5 + with: + go-version-file: agent/go.mod + cache-dependency-path: agent/go.sum + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + # The design preset imports a peer dependency, and node resolves that + # from where the preset lives. Installed as a package it would find the + # consumer's copy by walking up; linked by relative path it looks in a + # directory with nothing in it. This goes when that dependency is a + # version rather than a path. + - name: Peer dependencies the design preset resolves from its own folder + working-directory: design + run: npm install --no-audit --no-fund --no-save @tailwindcss/typography + + - name: Formatting + working-directory: agent + run: make fmt-check + + - name: Vet + working-directory: agent + run: make vet + + - name: Tests + working-directory: agent + run: make test-race + + # The view is built before the binary, because the binary embeds it. A + # build against stale assets proves nothing about the change. + - name: Build + working-directory: agent + run: | + make ui-deps + make build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c9de7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +sourceant-agent +coverage.out +coverage.html +ui/node_modules/ +ui/dist/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..28077fa --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +.PHONY: help deps ui ui-deps ui-dev build build-go test test-race test-coverage fmt fmt-check vet lint lint-install clean qa + +BINARY_NAME=sourceant-agent +VERSION?=$(shell cat VERSION 2>/dev/null || echo "dev") +BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S') +GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") +LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT)" + +help: + @echo "SourceAnt agent - build commands" + @echo "" + @echo "make deps - Download dependencies, Go and npm" + @echo "make ui - Build the local view into what the binary embeds" + @echo "make ui-dev - Run the view against a running agent" + @echo "make build - Build the view, then the agent binary" + @echo "make build-go - Build the binary with whatever view is embedded" + @echo "make test - Run unit tests" + @echo "make test-race - Run unit tests under the race detector" + @echo "make test-coverage - Run tests with a coverage report" + @echo "make fmt - Format code with gofmt" + @echo "make fmt-check - Check gofmt formatting" + @echo "make vet - Run go vet" + @echo "make lint - Run golangci-lint" + @echo "make qa - Run fmt-check, vet, lint, and tests" + @echo "make clean - Clean build artifacts" + +deps: ui-deps + go mod download + go mod tidy + +ui-deps: + cd ui && npm install --no-audit --no-fund + +# Vite writes into internal/ui/assets, which is what the binary embeds, so a +# build and the sources it came from cannot disagree. +ui: + cd ui && npm run build + +ui-dev: + cd ui && npm run dev + +build: ui build-go + +build-go: + go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/agent + +test: + go test ./... + +test-race: + go test -race ./... + +test-coverage: + go test -coverprofile=coverage.out ./... + go tool cover -html=coverage.out -o coverage.html + @echo "Coverage report generated: coverage.html" + +fmt: + go fmt ./... + +fmt-check: + @test -z "$$(gofmt -l .)" || (echo "Run gofmt on:" && gofmt -l . && exit 1) + +vet: + go vet ./... + +lint: + @command -v golangci-lint > /dev/null 2>&1 && golangci-lint run ./... || \ + (test -x "$$(go env GOPATH)/bin/golangci-lint" && "$$(go env GOPATH)/bin/golangci-lint" run ./... || \ + (echo "golangci-lint not found. Run 'make lint-install' first." && exit 1)) + +lint-install: + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest + +qa: fmt-check vet lint test + +clean: + rm -f $(BINARY_NAME) + rm -f coverage.out coverage.html + go clean diff --git a/README.md b/README.md new file mode 100644 index 0000000..df34309 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# SourceAnt agent + +The process that stays up on a developer's machine. It supervises the SourceAnt indexer, keeps the local code graph current, and serves it to the CLI and the local UI. + +It never parses code. The grammars and the graph shape live in the Python core, so that one index serves every client. + +## What it does + +Starts the core on a free port and waits for it to answer. Restarts it when it dies, backing off as failures repeat. Serves its own HTTP surface on `127.0.0.1:8930`, where `/health` reports whether the core is up and how many times it has been started, and `/api/repositories` and `/api/graph` read the index. + +It also serves the local view at `/`: Overview, Knowledge, Graphs, Repositories, Settings. The assets are embedded in the binary, so the view works with no network and cannot drift from the agent serving it. + +The view is Vue, built by Vite from `ui/`: Tailwind for the design tokens, lucide for icons, force-graph in 2D and 3d-force-graph for Tree, Radial, Layered and Force. + +There are no reviews here. A review reads a pull request, and nothing on a machine produces one. + +Loopback is the default because the agent reads a working tree. The machine it runs on is the only audience it has. + +## Running it + +Building needs Go and npm: `make build` builds the view, then the binary that embeds it. `make build-go` skips the view when nothing about it changed, and `make ui-dev` runs it against an agent already running. + +```bash +make build +./sourceant-agent +``` + +It starts whatever `sourceant install` put on this machine, reading `~/.sourceant/config.json`: a container, or the core as a program. A container binds every interface inside and is published to loopback outside, because one binding the container's own loopback could be reached by nothing. + +With nothing installed it looks for `sourceant` on `PATH`, which is what somebody working on the core itself already has. See [sourceant/cli](https://github.com/sourceant/cli) to install one, and [sourceant/sourceant](https://github.com/sourceant/sourceant) for the core. + +| Variable | Default | Meaning | +|---|---|---| +| `SOURCEANT_AGENT_LISTEN` | `127.0.0.1:8930` | Where the agent answers | +| `SOURCEANT_CORE` | what was installed | A core to supervise instead, overriding the install | +| `SOURCEANT_CORE_PORT` | chosen at start | The port to start the core on | + +## Building + +```bash +make qa # fmt-check, vet, lint, test +make build +``` + +## Licence + +MIT. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/cmd/agent/main.go b/cmd/agent/main.go new file mode 100644 index 0000000..083d962 --- /dev/null +++ b/cmd/agent/main.go @@ -0,0 +1,113 @@ +// Command sourceant-agent keeps the local index running and serves it. +package main + +import ( + "context" + "fmt" + "os" + "os/signal" + "strconv" + "syscall" + "time" + + "github.com/sourceant/agent/internal/api" + "github.com/sourceant/agent/internal/config" + "github.com/sourceant/agent/internal/core" + "github.com/sourceant/agent/internal/runtime" + "github.com/sourceant/agent/internal/supervise" +) + +// Set at build time. See the Makefile. +var ( + Version = "dev" + BuildTime = "unknown" + GitCommit = "unknown" +) + +func main() { + if len(os.Args) > 1 && (os.Args[1] == "version" || os.Args[1] == "--version") { + fmt.Printf("sourceant-agent %s (%s, built %s)\n", Version, GitCommit, BuildTime) + return + } + if err := run(); err != nil { + fmt.Fprintln(os.Stderr, "sourceant-agent:", err) + os.Exit(1) + } +} + +func run() error { + cfg, err := config.FromEnvironment() + if err != nil { + return err + } + + port := cfg.CorePort + if port == 0 { + if port, err = supervise.FreePort(); err != nil { + return fmt.Errorf("finding a port for the core: %w", err) + } + } + coreURL := "http://127.0.0.1:" + strconv.Itoa(port) + client := core.New(coreURL, 30*time.Second) + + installed := resolveCore(cfg) + // So a review asked for over MCP answers with a link somebody can click + // rather than a path they have to assemble. The agent serves the screen, so + // it is the only thing that knows this. + installed.UIURL = "http://" + cfg.Listen + name, args, err := installed.Serve(port) + if err != nil { + return err + } + + supervisor := supervise.New(supervise.Options{ + Name: name, + Args: args, + Ready: client.Healthy, + ReadyWithin: 60 * time.Second, + Output: os.Stderr, + }) + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + supervised := make(chan error, 1) + go func() { supervised <- supervisor.Run(ctx) }() + + served := make(chan error, 1) + server := api.New(client, supervisor, Version, coreURL) + go func() { served <- server.Serve(ctx, cfg.Listen) }() + + // A repository read once answers about last month, so it is read again on + // whatever schedule somebody set. This is the process that is always up, + // which is what makes it the one to do it. + go server.Keep(ctx) + + fmt.Fprintf(os.Stderr, "sourceant-agent %s listening on %s, core on %s (%s)\n", + Version, cfg.Listen, coreURL, installed.Describe()) + + // Whichever half stops first ends the agent: an agent serving without a + // core answers nothing, and a core nobody serves is not reachable. + select { + case err := <-supervised: + return err + case err := <-served: + return err + } +} + +// resolveCore decides which core to start, most specific first. +// +// An explicit command wins, because somebody naming one means it. Then what +// the installer wrote. Then the core on PATH, which is what a person working +// on the core itself already has and what makes the agent runnable before +// anything has been installed at all. +func resolveCore(cfg config.Config) runtime.Core { + if cfg.CoreWasChosen { + return runtime.Core{Runtime: runtime.Python, Command: cfg.Core} + } + if installed, err := runtime.Load(runtime.ConfigPath()); err == nil { + return installed.Core + } + return runtime.Core{Runtime: runtime.Python, Command: cfg.Core} +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..39a3490 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/sourceant/agent + +go 1.26.1 diff --git a/internal/api/mcp.go b/internal/api/mcp.go new file mode 100644 index 0000000..4153c13 --- /dev/null +++ b/internal/api/mcp.go @@ -0,0 +1,45 @@ +package api + +import ( + "net/http" + "net/http/httputil" + "net/url" + "strings" +) + +// mcp proxies the MCP endpoint through to the core. +// +// The agent is the address a client is given: it is always up, and it knows +// which port the core landed on this time. A client pointed straight at the +// core would have to be reconfigured every restart. +// +// FlushInterval is -1 because a streamable HTTP response is written as it is +// produced. Buffered, the client waits for a response the server considers +// already sent, and the call hangs. +func (s *Server) mcp() http.Handler { + target, err := url.Parse(s.coreURL) + if err != nil { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Error(w, "the core address is not a URL", http.StatusBadGateway) + }) + } + + proxy := httputil.NewSingleHostReverseProxy(target) + proxy.FlushInterval = -1 + proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) { + http.Error(w, "the core is not answering", http.StatusBadGateway) + } + + forward := proxy.Director + proxy.Director = func(r *http.Request) { + forward(r) + // Rewritten so the core sees its own address rather than the agent's. + // The core refuses a Host it does not recognise, which is what keeps an + // unauthenticated endpoint off anything but loopback. + r.Host = target.Host + if !strings.HasPrefix(r.URL.Path, "/mcp") { + r.URL.Path = "/mcp" + r.URL.Path + } + } + return proxy +} diff --git a/internal/api/review_test.go b/internal/api/review_test.go new file mode 100644 index 0000000..31843b3 --- /dev/null +++ b/internal/api/review_test.go @@ -0,0 +1,154 @@ +package api + +import ( + "encoding/json" + "net/http" + "testing" + + "github.com/sourceant/agent/internal/core" +) + +func TestSkillsOnHandAreListed(t *testing.T) { + reader := &stubReader{skills: core.SkillPage{ + Skills: []core.Skill{{ID: "migrations", Name: "migrations", Origin: "repository"}}, + Total: 1, + }} + server := New(reader, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/skills?repository=acme/billing") + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.askedFor != "acme/billing" { + t.Errorf("asked for %q, want the repository named", reader.askedFor) + } +} + +func TestAMachineWithNoSkillsAnswersAnEmptyList(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/skills") + + var page struct { + Skills []core.Skill `json:"skills"` + } + if err := json.Unmarshal(response.Body.Bytes(), &page); err != nil { + t.Fatalf("could not read the answer: %v", err) + } + if page.Skills == nil { + t.Error("answered null, want an empty list a screen can draw") + } +} + +func TestOneSkillComesBackInFull(t *testing.T) { + reader := &stubReader{oneSkill: core.Skill{ID: "migrations", Body: "Never edit one."}} + server := New(reader, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/skills/migrations") + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.forgot != "migrations" { + t.Errorf("asked for %q, want the skill named", reader.forgot) + } +} + +// The agent does not hold a review. It asks the core, which keeps it, so a +// link to one still opens after this process has restarted. +func TestAskingForAReviewAnswersWithWhereToFindIt(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/reviews", + `{"repository":"acme/billing","against":"dev","title":"Edit the migration","use_model":true}`) + + if response.Code != http.StatusAccepted { + t.Fatalf("got %d, want 202", response.Code) + } + var started core.Reading + if err := json.Unmarshal(response.Body.Bytes(), &started); err != nil { + t.Fatalf("could not read the answer: %v", err) + } + if started.ID == "" { + t.Error("answered without a name, so nobody could come back for it") + } + if reader.asked.Against != "dev" || !reader.asked.UseModel { + t.Errorf("asked %+v, want what was sent", reader.asked) + } +} + +func TestOneReviewComesBackByName(t *testing.T) { + reader := &stubReader{reviewed: core.Review{ + Ready: false, + Verdicts: []core.Verdict{{Skill: "migrations", Passed: false}}, + }} + server := New(reader, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/reviews/abc123") + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + var found core.Reading + if err := json.Unmarshal(response.Body.Bytes(), &found); err != nil { + t.Fatalf("could not read the answer: %v", err) + } + if reader.forgot != "abc123" { + t.Errorf("asked for %q, want the review named", reader.forgot) + } + if len(found.Review.Verdicts) != 1 { + t.Errorf("got %d verdicts, want the one it made", len(found.Review.Verdicts)) + } +} + +func TestTheLastFewComeBackAsAList(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/reviews") + + var found []core.Reading + if err := json.Unmarshal(response.Body.Bytes(), &found); err != nil { + t.Fatalf("could not read the answer: %v", err) + } + if found == nil { + t.Error("answered null, want an empty list a screen can draw") + } +} + +func TestReviewingNowhereIsRefused(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/reviews", `{}`) + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestAReviewWithNothingToSayStillDrawsAsLists(t *testing.T) { + server := New(&stubReader{reviewed: core.Review{Ready: true}}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/reviews/abc123") + + var found core.Reading + if err := json.Unmarshal(response.Body.Bytes(), &found); err != nil { + t.Fatalf("could not read the answer: %v", err) + } + if found.Review.Changed == nil || found.Review.Skills == nil || found.Review.Verdicts == nil { + t.Error("answered null somewhere, want empty lists a screen can draw") + } +} + +func TestAskingAModelToInitializeIsCarriedThrough(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + body(t, server, http.MethodPost, "/api/knowledge/initialize", + `{"repository":"acme/billing","use_model":true}`) + + if !reader.askedUseModel { + t.Error("did not carry the ask to use a model, so nothing would be proposed") + } +} diff --git a/internal/api/reviews.go b/internal/api/reviews.go new file mode 100644 index 0000000..455ecb6 --- /dev/null +++ b/internal/api/reviews.go @@ -0,0 +1,75 @@ +package api + +import ( + "net/http" + + "github.com/sourceant/agent/internal/core" +) + +// A review is kept by the core, not held here. +// +// The thing that asks for one is often not the thing that reads it: an agent +// runs one over MCP while somebody is in the middle of something else and +// hands them a link. A link into this process's memory stops working when this +// process restarts, which is not a property a link should have. + +func (s *Server) review(w http.ResponseWriter, r *http.Request) { + var ask core.Ask + if !readBody(w, r, &ask) { + return + } + if ask.Repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + started, err := s.reader.Review(r.Context(), ask) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusAccepted, started) +} + +func (s *Server) reviewed(w http.ResponseWriter, r *http.Request) { + found, err := s.reader.Reviewed(r.Context(), r.PathValue("id")) + if err != nil { + fail(w, err) + return + } + found.Review = drawable(found.Review) + write(w, http.StatusOK, found) +} + +func (s *Server) listReviews(w http.ResponseWriter, r *http.Request) { + found, err := s.reader.Reviews(r.Context(), r.URL.Query().Get("repository")) + if err != nil { + fail(w, err) + return + } + // None yet is an empty list, never a null, so a screen can draw it. + if found == nil { + found = []core.Reading{} + } + write(w, http.StatusOK, found) +} + +// drawable fills in the empty lists, so a screen can draw an answer without +// special-casing every absent one. +func drawable(reviewed core.Review) core.Review { + if reviewed.Changed == nil { + reviewed.Changed = []core.ChangedFile{} + } + if reviewed.Skills == nil { + reviewed.Skills = []core.Skill{} + } + if reviewed.Knowledge == nil { + reviewed.Knowledge = []core.Recorded{} + } + if reviewed.Verdicts == nil { + reviewed.Verdicts = []core.Verdict{} + } + if reviewed.Read.Suggestions == nil { + reviewed.Read.Suggestions = []core.Suggestion{} + } + return reviewed +} diff --git a/internal/api/schedule.go b/internal/api/schedule.go new file mode 100644 index 0000000..a6106a2 --- /dev/null +++ b/internal/api/schedule.go @@ -0,0 +1,138 @@ +package api + +import ( + "context" + "log" + "time" + + "github.com/sourceant/agent/internal/core" +) + +// A repository read once is a repository that answers about last month. The +// agent is the process that is always up, so it is the one that reads them +// again. +// +// How often is the core's to declare and a person's to set, and it is read +// every time rather than at startup: somebody changing it in Settings should +// not have to restart anything to see it take. + +const ( + // How often the settings are consulted. Short enough that a change in + // Settings takes hold while somebody is still looking at the screen. + asking = time.Minute + + // Nothing is read again sooner than this, whatever a setting says, because + // a person who typed 1 by accident should not have their laptop reading + // every repository they own once a minute. + sooner = 5 * time.Minute +) + +type schedule struct { + reader Reader + // When each thing last ran, so a restart does not re-read everything and + // a long interval is not lost. + indexed time.Time + learned time.Time +} + +// Keep runs the reading somebody asked for, until ctx is cancelled. +func (s *Server) Keep(ctx context.Context) { + keeper := &schedule{reader: s.reader} + ticker := time.NewTicker(asking) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + keeper.tick(ctx) + } + } +} + +func (k *schedule) tick(ctx context.Context) { + settings, err := k.reader.Settings(ctx) + if err != nil { + // A core that is still starting is not a problem worth logging every + // minute. The next tick asks again. + return + } + + if due(minutes(settings, "index.every"), k.indexed) { + k.indexed = time.Now() + k.read(ctx) + } + if due(minutes(settings, "knowledge.every"), k.learned) { + k.learned = time.Now() + k.learn(ctx, configured(settings)) + } +} + +// due reports whether something set to run every so often is owed a run. +// Zero minutes means somebody turned it off. +func due(every time.Duration, last time.Time) bool { + if every <= 0 { + return false + } + if every < sooner { + every = sooner + } + return time.Since(last) >= every +} + +func minutes(settings []core.Setting, key string) time.Duration { + for _, setting := range settings { + if setting.Key != key { + continue + } + switch value := setting.Value.(type) { + case float64: + return time.Duration(value) * time.Minute + case int: + return time.Duration(value) * time.Minute + } + return 0 + } + return 0 +} + +func (k *schedule) read(ctx context.Context) { + // Only what changed is read, so this costs close to nothing on a + // repository nobody has touched. + if _, err := k.reader.Index(ctx, "", false, true); err != nil { + log.Printf("reading repositories again: %v", err) + } +} + +// configured reports whether there is a model to ask. Asking core to use one +// it does not have is refused, and a scheduler that did it anyway would put a +// failure in the log every hour for a setting nobody turned on. +func configured(settings []core.Setting) bool { + named, keyed := false, false + for _, setting := range settings { + switch setting.Key { + case "model.name": + text, ok := setting.Value.(string) + named = ok && text != "" + case "model.api_key": + keyed = setting.IsSet != nil && *setting.IsSet + } + } + return named && keyed +} + +func (k *schedule) learn(ctx context.Context, ask bool) { + repositories, err := k.reader.Repositories(ctx) + if err != nil { + log.Printf("looking for new knowledge: %v", err) + return + } + for _, repository := range repositories { + // Reading what a repository states costs nothing. Asking a model costs + // money every time, so it happens only where somebody has said which + // model to ask. + if _, err := k.reader.Initialize(ctx, repository.Name, false, ask); err != nil { + log.Printf("looking for new knowledge in %s: %v", repository.Name, err) + } + } +} diff --git a/internal/api/schedule_test.go b/internal/api/schedule_test.go new file mode 100644 index 0000000..3170cb6 --- /dev/null +++ b/internal/api/schedule_test.go @@ -0,0 +1,75 @@ +package api + +import ( + "testing" + "time" + + "github.com/sourceant/agent/internal/core" +) + +func setting(key string, value any) core.Setting { + return core.Setting{Key: key, Value: value} +} + +func TestSomethingTurnedOffNeverRuns(t *testing.T) { + if due(0, time.Time{}) { + t.Error("ran something set to every zero minutes") + } +} + +func TestSomethingNeverRunIsOwedARun(t *testing.T) { + if !due(time.Hour, time.Time{}) { + t.Error("waited an hour before the first run") + } +} + +func TestSomethingJustRunIsNotOwedAnother(t *testing.T) { + if due(time.Hour, time.Now()) { + t.Error("ran again immediately") + } +} + +// Somebody typing 1 by accident should not have their laptop reading every +// repository they own once a minute. +func TestNothingRunsSoonerThanIsSensible(t *testing.T) { + if due(time.Minute, time.Now().Add(-2*time.Minute)) { + t.Error("honoured an interval shorter than anything is worth") + } + if !due(time.Minute, time.Now().Add(-10*time.Minute)) { + t.Error("never ran at all") + } +} + +func TestHowOftenIsReadFromWhatTheCoreDeclares(t *testing.T) { + settings := []core.Setting{setting("index.every", float64(30))} + + if minutes(settings, "index.every") != 30*time.Minute { + t.Errorf("got %s, want 30m", minutes(settings, "index.every")) + } + if minutes(settings, "nothing.declared") != 0 { + t.Error("invented a schedule for a setting nobody declared") + } +} + +func TestAModelIsOnlyAskedWhereThereIsOne(t *testing.T) { + yes, no := true, false + + named := []core.Setting{ + setting("model.name", "gemini/gemini-2.5-flash"), + {Key: "model.api_key", IsSet: &yes}, + } + unkeyed := []core.Setting{ + setting("model.name", "gemini/gemini-2.5-flash"), + {Key: "model.api_key", IsSet: &no}, + } + + if !configured(named) { + t.Error("would not ask a model that is configured") + } + if configured(unkeyed) { + t.Error("would ask a model with no key, which is refused every time") + } + if configured(nil) { + t.Error("would ask a model nobody chose") + } +} diff --git a/internal/api/server.go b/internal/api/server.go new file mode 100644 index 0000000..9a21c5b --- /dev/null +++ b/internal/api/server.go @@ -0,0 +1,479 @@ +// Package api is the agent's own HTTP surface. +// +// Everything else talks to the agent rather than to the Python core: the agent +// is the process that is always up, it knows which port the core landed on, and +// it is where a view across every registered repository will be assembled. A +// client that reached past it would have to learn all three. +package api + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "strconv" + "time" + + "github.com/sourceant/agent/internal/browse" + "github.com/sourceant/agent/internal/core" + "github.com/sourceant/agent/internal/ui" +) + +// Reader is the part of the core client this server needs. +type Reader interface { + Healthy(ctx context.Context) bool + Repositories(ctx context.Context) ([]core.Repository, error) + Graph(ctx context.Context, repository string, opts core.GraphOptions) (core.Graph, error) + Attention(ctx context.Context, repository string) (core.Attention, error) + Register(ctx context.Context, path, name string) (core.Repository, error) + Forget(ctx context.Context, path string) error + Index(ctx context.Context, repository string, everything, update bool) ([]core.Indexed, error) + Knowledge(ctx context.Context, repository string, limit, offset int) (core.KnowledgePage, error) + RecordKnowledge(ctx context.Context, repository string, item core.Knowledge) (core.Knowledge, error) + ForgetKnowledge(ctx context.Context, repository, id string) error + Initialize(ctx context.Context, repository string, dryRun, useModel bool) (core.Seeded, error) + Skills(ctx context.Context, repository string) (core.SkillPage, error) + Skill(ctx context.Context, id, repository string) (core.Skill, error) + RecordSkill(ctx context.Context, stated core.Stated) (core.Skill, error) + ForgetSkill(ctx context.Context, repository, scope, id string) error + Review(ctx context.Context, ask core.Ask) (core.Reading, error) + Reviewed(ctx context.Context, id string) (core.Reading, error) + Reviews(ctx context.Context, repository string) ([]core.Reading, error) + Settings(ctx context.Context) ([]core.Setting, error) + SetSetting(ctx context.Context, key string, value any) (core.Setting, error) + ResetSetting(ctx context.Context, key string) (core.Setting, error) +} + +// Supervision is the part of the supervisor this server reports on. +type Supervision interface { + Starts() int + LastExit() error +} + +// Status is what the agent says about itself. +type Status struct { + Version string `json:"version"` + // CoreURL is where the agent's core is listening. + CoreURL string `json:"core_url"` + // CoreUp is whether it answered just now. + CoreUp bool `json:"core_up"` + // CoreStarts counts launches, so a number that keeps climbing is a + // core that keeps dying. + CoreStarts int `json:"core_starts"` + LastExit string `json:"last_exit,omitempty"` +} + +// Server answers for the agent. +type Server struct { + reader Reader + supervisor Supervision + version string + coreURL string +} + +// New builds the agent's HTTP surface. +func New(reader Reader, supervisor Supervision, version, coreURL string) *Server { + return &Server{ + reader: reader, + supervisor: supervisor, + version: version, + coreURL: coreURL, + } +} + +// Handler is the agent's routes. +func (s *Server) Handler() http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("GET /health", s.health) + mux.HandleFunc("GET /api/repositories", s.repositories) + mux.HandleFunc("POST /api/repositories", s.addRepository) + mux.HandleFunc("DELETE /api/repositories", s.dropRepository) + mux.HandleFunc("POST /api/index", s.index) + mux.HandleFunc("GET /api/graph", s.graph) + mux.HandleFunc("GET /api/attention", s.attention) + mux.HandleFunc("GET /api/knowledge", s.knowledge) + mux.HandleFunc("PUT /api/knowledge", s.recordKnowledge) + mux.HandleFunc("DELETE /api/knowledge", s.forgetKnowledge) + mux.HandleFunc("POST /api/knowledge/initialize", s.initialize) + mux.HandleFunc("GET /api/settings", s.settings) + mux.HandleFunc("PUT /api/settings", s.setSetting) + mux.HandleFunc("DELETE /api/settings", s.resetSetting) + mux.HandleFunc("GET /api/skills", s.skills) + mux.HandleFunc("GET /api/skills/{id...}", s.skill) + mux.HandleFunc("PUT /api/skills", s.recordSkill) + mux.HandleFunc("DELETE /api/skills", s.forgetSkill) + mux.HandleFunc("POST /api/reviews", s.review) + mux.HandleFunc("GET /api/reviews", s.listReviews) + mux.HandleFunc("GET /api/reviews/{id}", s.reviewed) + mux.HandleFunc("GET /api/browse", s.browse) + mux.Handle("/mcp", s.mcp()) + mux.Handle("/mcp/", s.mcp()) + // Not method-scoped: Go refuses a "GET /" that is more general than a + // method-agnostic "/mcp/" registered beside it. + mux.Handle("/", ui.Handler()) + return mux +} + +func (s *Server) health(w http.ResponseWriter, r *http.Request) { + status := Status{Version: s.version, CoreURL: s.coreURL} + if s.reader != nil { + status.CoreUp = s.reader.Healthy(r.Context()) + } + if s.supervisor != nil { + status.CoreStarts = s.supervisor.Starts() + if exit := s.supervisor.LastExit(); exit != nil { + status.LastExit = exit.Error() + } + } + write(w, http.StatusOK, status) +} + +func (s *Server) repositories(w http.ResponseWriter, r *http.Request) { + repositories, err := s.reader.Repositories(r.Context()) + if err != nil { + fail(w, err) + return + } + // An empty registry is an empty list, never a null, so a client can draw + // "nothing indexed yet" without special-casing the absent case. + if repositories == nil { + repositories = []core.Repository{} + } + write(w, http.StatusOK, repositories) +} + +func (s *Server) graph(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + if repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + limit, err := strconv.Atoi(r.URL.Query().Get("node_limit")) + if err != nil { + limit = 0 + } + graph, err := s.reader.Graph(r.Context(), repository, core.GraphOptions{ + PathPrefix: r.URL.Query().Get("path_prefix"), + IncludeTests: r.URL.Query().Get("include_tests") == "true", + NodeLimit: limit, + }) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, graph) +} + +func (s *Server) attention(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + if repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + found, err := s.reader.Attention(r.Context(), repository) + if err != nil { + fail(w, err) + return + } + // A repository with no recent history is an empty list, never a null, so a + // screen can say "nothing yet" without special-casing the absent case. + if found.Files == nil { + found.Files = []core.Worth{} + } + write(w, http.StatusOK, found) +} + +func (s *Server) addRepository(w http.ResponseWriter, r *http.Request) { + var body struct { + Path string `json:"path"` + Name string `json:"name"` + } + if !readBody(w, r, &body) { + return + } + if body.Path == "" { + write(w, http.StatusBadRequest, problem{Error: "name a directory"}) + return + } + added, err := s.reader.Register(r.Context(), body.Path, body.Name) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, added) +} + +func (s *Server) dropRepository(w http.ResponseWriter, r *http.Request) { + path := r.URL.Query().Get("path") + if path == "" { + write(w, http.StatusBadRequest, problem{Error: "name a directory"}) + return + } + if err := s.reader.Forget(r.Context(), path); err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, map[string]string{"path": path}) +} + +func (s *Server) index(w http.ResponseWriter, r *http.Request) { + var body struct { + Repository string `json:"repository"` + Everything bool `json:"everything"` + // Update reads only what changed. Asking for none of it means read it + // again, which is what somebody pressing a button for it means. + Update bool `json:"update"` + } + if !readBody(w, r, &body) { + return + } + done, err := s.reader.Index(r.Context(), body.Repository, body.Everything, body.Update) + if err != nil { + fail(w, err) + return + } + if done == nil { + done = []core.Indexed{} + } + write(w, http.StatusOK, done) +} + +// knowledge is what is recorded, about one repository or about every one. +// +// Naming none is not a mistake here, unlike writing: a decision is remembered +// by what it decided rather than by which checkout it was filed against. +func (s *Server) knowledge(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + limit, _ := strconv.Atoi(r.URL.Query().Get("limit")) + offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) + page, err := s.reader.Knowledge(r.Context(), repository, limit, offset) + if err != nil { + fail(w, err) + return + } + if page.Items == nil { + page.Items = []core.Knowledge{} + } + write(w, http.StatusOK, page) +} + +func (s *Server) recordKnowledge(w http.ResponseWriter, r *http.Request) { + var body struct { + Repository string `json:"repository"` + core.Knowledge + } + if !readBody(w, r, &body) { + return + } + if body.Repository == "" || body.ID == "" || body.Summary == "" { + write(w, http.StatusBadRequest, problem{Error: "a repository, an id and a summary are needed"}) + return + } + recorded, err := s.reader.RecordKnowledge(r.Context(), body.Repository, body.Knowledge) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, recorded) +} + +func (s *Server) forgetKnowledge(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + id := r.URL.Query().Get("id") + if repository == "" || id == "" { + write(w, http.StatusBadRequest, problem{Error: "a repository and an id are needed"}) + return + } + if err := s.reader.ForgetKnowledge(r.Context(), repository, id); err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, map[string]string{"id": id}) +} + +func (s *Server) initialize(w http.ResponseWriter, r *http.Request) { + var body struct { + Repository string `json:"repository"` + DryRun bool `json:"dry_run"` + UseModel bool `json:"use_model"` + } + if !readBody(w, r, &body) { + return + } + if body.Repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + seeded, err := s.reader.Initialize(r.Context(), body.Repository, body.DryRun, body.UseModel) + if err != nil { + fail(w, err) + return + } + if seeded.Found == nil { + seeded.Found = []core.Seed{} + } + write(w, http.StatusOK, seeded) +} + +func (s *Server) skills(w http.ResponseWriter, r *http.Request) { + page, err := s.reader.Skills(r.Context(), r.URL.Query().Get("repository")) + if err != nil { + fail(w, err) + return + } + // A machine with no skills folder is an empty list, never a null, so a + // screen can say "nothing yet" without special-casing the absent case. + if page.Skills == nil { + page.Skills = []core.Skill{} + } + write(w, http.StatusOK, page) +} + +func (s *Server) skill(w http.ResponseWriter, r *http.Request) { + id := r.PathValue("id") + if id == "" { + write(w, http.StatusBadRequest, problem{Error: "name a skill"}) + return + } + found, err := s.reader.Skill(r.Context(), id, r.URL.Query().Get("repository")) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, found) +} + +func (s *Server) recordSkill(w http.ResponseWriter, r *http.Request) { + var stated core.Stated + if !readBody(w, r, &stated) { + return + } + if stated.ID == "" { + write(w, http.StatusBadRequest, problem{Error: "name a skill"}) + return + } + written, err := s.reader.RecordSkill(r.Context(), stated) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, written) +} + +func (s *Server) forgetSkill(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + scope := r.URL.Query().Get("scope") + id := r.URL.Query().Get("id") + if id == "" { + write(w, http.StatusBadRequest, problem{Error: "name a skill"}) + return + } + if err := s.reader.ForgetSkill(r.Context(), repository, scope, id); err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, map[string]string{"id": id}) +} + +func (s *Server) settings(w http.ResponseWriter, r *http.Request) { + settings, err := s.reader.Settings(r.Context()) + if err != nil { + fail(w, err) + return + } + if settings == nil { + settings = []core.Setting{} + } + write(w, http.StatusOK, settings) +} + +func (s *Server) setSetting(w http.ResponseWriter, r *http.Request) { + var body struct { + Key string `json:"key"` + Value any `json:"value"` + } + if !readBody(w, r, &body) { + return + } + if body.Key == "" { + write(w, http.StatusBadRequest, problem{Error: "name a setting"}) + return + } + setting, err := s.reader.SetSetting(r.Context(), body.Key, body.Value) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, setting) +} + +func (s *Server) resetSetting(w http.ResponseWriter, r *http.Request) { + key := r.URL.Query().Get("key") + if key == "" { + write(w, http.StatusBadRequest, problem{Error: "name a setting"}) + return + } + setting, err := s.reader.ResetSetting(r.Context(), key) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, setting) +} + +func (s *Server) browse(w http.ResponseWriter, r *http.Request) { + listing, err := browse.At(r.URL.Query().Get("path")) + if err != nil { + write(w, http.StatusNotFound, problem{Error: err.Error()}) + return + } + write(w, http.StatusOK, listing) +} + +func readBody(w http.ResponseWriter, r *http.Request, into any) bool { + if err := json.NewDecoder(r.Body).Decode(into); err != nil { + write(w, http.StatusBadRequest, problem{Error: "the body is not readable as JSON"}) + return false + } + return true +} + +type problem struct { + Error string `json:"error"` +} + +// fail answers with the core's own status where it gave one, so a repository +// nobody registered reads as 404 here too rather than as the agent breaking. +func fail(w http.ResponseWriter, err error) { + var coreError *core.Error + if errors.As(err, &coreError) { + write(w, coreError.StatusCode, problem{Error: coreError.Detail}) + return + } + write(w, http.StatusBadGateway, problem{Error: err.Error()}) +} + +func write(w http.ResponseWriter, status int, body any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(body) +} + +// Serve runs the agent's HTTP surface until ctx is cancelled. +func (s *Server) Serve(ctx context.Context, address string) error { + server := &http.Server{ + Addr: address, + Handler: s.Handler(), + ReadHeaderTimeout: 10 * time.Second, + } + go func() { + <-ctx.Done() + shutdown, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) + defer cancel() + _ = server.Shutdown(shutdown) + }() + if err := server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { + return err + } + return nil +} diff --git a/internal/api/server_test.go b/internal/api/server_test.go new file mode 100644 index 0000000..f99bcc5 --- /dev/null +++ b/internal/api/server_test.go @@ -0,0 +1,267 @@ +package api + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "testing" + + "github.com/sourceant/agent/internal/core" +) + +type stubReader struct { + up bool + repositories []core.Repository + graph core.Graph + attention core.Attention + indexed []core.Indexed + knowledge core.KnowledgePage + err error + askedFor string + askedOptions core.GraphOptions + askedEverything bool + askedUpdate bool + askedDryRun bool + askedUseModel bool + seeded core.Seeded + skills core.SkillPage + oneSkill core.Skill + reviewed core.Review + readings []core.Reading + asked core.Ask + stated core.Stated + settings []core.Setting + setKey string + setValue any + registered core.Repository + recorded core.Knowledge + forgot string +} + +func (s *stubReader) Healthy(context.Context) bool { return s.up } + +func (s *stubReader) Repositories(context.Context) ([]core.Repository, error) { + return s.repositories, s.err +} + +func (s *stubReader) Graph(_ context.Context, repository string, opts core.GraphOptions) (core.Graph, error) { + s.askedFor = repository + s.askedOptions = opts + return s.graph, s.err +} + +func (s *stubReader) Attention(_ context.Context, repository string) (core.Attention, error) { + s.askedFor = repository + return s.attention, s.err +} + +func (s *stubReader) Register(_ context.Context, path, name string) (core.Repository, error) { + s.registered = core.Repository{Name: name, Path: path} + return s.registered, s.err +} + +func (s *stubReader) Forget(_ context.Context, path string) error { + s.forgot = path + return s.err +} + +func (s *stubReader) Index(_ context.Context, repository string, everything, update bool) ([]core.Indexed, error) { + s.askedFor = repository + s.askedEverything = everything + s.askedUpdate = update + return s.indexed, s.err +} + +func (s *stubReader) Knowledge(_ context.Context, repository string, limit, offset int) (core.KnowledgePage, error) { + s.askedFor = repository + return s.knowledge, s.err +} + +func (s *stubReader) RecordKnowledge(_ context.Context, repository string, item core.Knowledge) (core.Knowledge, error) { + s.askedFor = repository + s.recorded = item + return item, s.err +} + +func (s *stubReader) ForgetKnowledge(_ context.Context, repository, id string) error { + s.askedFor = repository + s.forgot = id + return s.err +} + +func (s *stubReader) Initialize(_ context.Context, repository string, dryRun, useModel bool) (core.Seeded, error) { + s.askedFor = repository + s.askedDryRun = dryRun + s.askedUseModel = useModel + return s.seeded, s.err +} + +func (s *stubReader) Skills(_ context.Context, repository string) (core.SkillPage, error) { + s.askedFor = repository + return s.skills, s.err +} + +func (s *stubReader) Skill(_ context.Context, id, repository string) (core.Skill, error) { + s.askedFor = repository + s.forgot = id + return s.oneSkill, s.err +} + +func (s *stubReader) ResetSetting(_ context.Context, key string) (core.Setting, error) { + s.setKey = key + return core.Setting{Key: key}, s.err +} + +func (s *stubReader) RecordSkill(_ context.Context, stated core.Stated) (core.Skill, error) { + s.stated = stated + return core.Skill{ID: stated.ID, Name: stated.Name}, s.err +} + +func (s *stubReader) ForgetSkill(_ context.Context, repository, scope, id string) error { + s.askedFor = repository + s.forgot = id + return s.err +} + +func (s *stubReader) Review(_ context.Context, ask core.Ask) (core.Reading, error) { + s.asked = ask + s.askedFor = ask.Repository + return core.Reading{ID: "one", Repository: ask.Repository, Status: "running"}, s.err +} + +func (s *stubReader) Reviewed(_ context.Context, id string) (core.Reading, error) { + s.forgot = id + return core.Reading{ID: id, Status: "done", Review: s.reviewed}, s.err +} + +func (s *stubReader) Reviews(_ context.Context, repository string) ([]core.Reading, error) { + s.askedFor = repository + return s.readings, s.err +} + +func (s *stubReader) Settings(context.Context) ([]core.Setting, error) { + return s.settings, s.err +} + +func (s *stubReader) SetSetting(_ context.Context, key string, value any) (core.Setting, error) { + s.setKey, s.setValue = key, value + return core.Setting{Key: key}, s.err +} + +type stubSupervisor struct { + starts int + exit error +} + +func (s stubSupervisor) Starts() int { return s.starts } +func (s stubSupervisor) LastExit() error { return s.exit } + +func call(t *testing.T, server *Server, target string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + server.Handler().ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, target, nil)) + return recorder +} + +func TestHealthReportsWhetherTheCoreIsAnswering(t *testing.T) { + server := New(&stubReader{up: true}, stubSupervisor{starts: 2}, "1.2.3", "http://127.0.0.1:8931") + + response := call(t, server, "/health") + + var status Status + decode(t, response, &status) + if !status.CoreUp { + t.Error("reported a core that answered as down") + } + if status.CoreStarts != 2 { + t.Errorf("got %d starts, want 2", status.CoreStarts) + } + if status.Version != "1.2.3" || status.CoreURL != "http://127.0.0.1:8931" { + t.Errorf("got version %q at %q, want what the agent was built with", status.Version, status.CoreURL) + } +} + +func TestHealthCarriesWhyTheCoreLastDied(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{starts: 9, exit: errors.New("exit status 1")}, "dev", "") + + response := call(t, server, "/health") + + var status Status + decode(t, response, &status) + if status.LastExit != "exit status 1" { + t.Errorf("got last exit %q, want what the process said", status.LastExit) + } +} + +func TestAnEmptyRegistryIsAnEmptyListRatherThanNull(t *testing.T) { + server := New(&stubReader{repositories: nil}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/repositories") + + if got := response.Body.String(); got != "[]\n" { + t.Errorf("got %q, want an empty list", got) + } +} + +func TestGraphPassesOnWhatNarrowsADrawing(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + call(t, server, "/api/graph?repository=acme/billing&path_prefix=app/&include_tests=true&node_limit=200") + + if reader.askedFor != "acme/billing" { + t.Errorf("asked for %q, want acme/billing", reader.askedFor) + } + want := core.GraphOptions{PathPrefix: "app/", IncludeTests: true, NodeLimit: 200} + if reader.askedOptions != want { + t.Errorf("asked with %+v, want %+v", reader.askedOptions, want) + } +} + +func TestGraphRefusesToGuessWhichRepositoryIsMeant(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/graph") + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestAnUnregisteredRepositoryStaysA404(t *testing.T) { + reader := &stubReader{err: &core.Error{ + StatusCode: http.StatusNotFound, + Detail: "acme/nope is not registered on this machine", + }} + server := New(reader, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/graph?repository=acme/nope") + + if response.Code != http.StatusNotFound { + t.Errorf("got %d, want the core's own 404", response.Code) + } + var body problem + decode(t, response, &body) + if body.Error != "acme/nope is not registered on this machine" { + t.Errorf("got %q, want the reason the core gave", body.Error) + } +} + +func TestACoreThatCannotBeReachedIsNotTheAgentBreaking(t *testing.T) { + server := New(&stubReader{err: errors.New("connection refused")}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/repositories") + + if response.Code != http.StatusBadGateway { + t.Errorf("got %d, want 502", response.Code) + } +} + +func decode(t *testing.T, response *httptest.ResponseRecorder, into any) { + t.Helper() + if err := json.Unmarshal(response.Body.Bytes(), into); err != nil { + t.Fatalf("decoding %q: %v", response.Body.String(), err) + } +} diff --git a/internal/api/writes_test.go b/internal/api/writes_test.go new file mode 100644 index 0000000..5bbd6a2 --- /dev/null +++ b/internal/api/writes_test.go @@ -0,0 +1,145 @@ +package api + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/sourceant/agent/internal/core" +) + +func body(t *testing.T, server *Server, method, target, payload string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + request := httptest.NewRequest(method, target, strings.NewReader(payload)) + server.Handler().ServeHTTP(recorder, request) + return recorder +} + +func TestADirectoryCanBeCovered(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/repositories", + `{"path":"/home/me/billing","name":"acme/billing"}`) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.registered.Path != "/home/me/billing" || reader.registered.Name != "acme/billing" { + t.Errorf("registered %+v, want what was asked for", reader.registered) + } +} + +func TestCoveringNowhereIsRefused(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/repositories", `{}`) + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestADirectoryCanBeDropped(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodDelete, "/api/repositories?path=/home/me/billing", "") + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.forgot != "/home/me/billing" { + t.Errorf("forgot %q, want the directory named", reader.forgot) + } +} + +func TestIndexingReportsWhatWasRead(t *testing.T) { + reader := &stubReader{indexed: []core.Indexed{{Repository: "acme/billing", Files: 12}}} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/index", `{"repository":"acme/billing"}`) + + var done []core.Indexed + decode(t, response, &done) + if len(done) != 1 || done[0].Files != 12 { + t.Errorf("got %+v, want what the core read", done) + } + if reader.askedFor != "acme/billing" { + t.Errorf("indexed %q, want acme/billing", reader.askedFor) + } +} + +func TestIndexingEverythingSaysSo(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + body(t, server, http.MethodPost, "/api/index", `{"everything":true}`) + + if !reader.askedEverything { + t.Error("asked for one repository, want all of them") + } +} + +func TestKnowledgeIsRecordedAgainstARepository(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPut, "/api/knowledge", + `{"repository":"acme/billing","id":"retry","kind":"decision","summary":"Retry three times."}`) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.askedFor != "acme/billing" || reader.recorded.ID != "retry" { + t.Errorf("recorded %+v against %q", reader.recorded, reader.askedFor) + } +} + +func TestKnowledgeWithNothingToSayIsRefused(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPut, "/api/knowledge", + `{"repository":"acme/billing","id":"retry","kind":"decision"}`) + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestNothingRecordedIsAnEmptyListRatherThanNull(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/knowledge?repository=acme/billing") + + if !strings.Contains(response.Body.String(), `"items":[]`) { + t.Errorf("got %q, want an empty list", response.Body.String()) + } +} + +// A browser will not tell a page the absolute path of a folder somebody picked, +// so the agent lists the machine and the page navigates what it lists. +func TestBrowsingListsDirectoriesToPickFrom(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/browse?path="+t.TempDir()) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if !strings.Contains(response.Body.String(), `"entries"`) { + t.Errorf("got %q, want a listing", response.Body.String()) + } +} + +func TestBrowsingNowhereSaysSo(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/browse?path=/definitely/not/here") + + if response.Code != http.StatusNotFound { + t.Errorf("got %d, want 404", response.Code) + } +} diff --git a/internal/browse/browse.go b/internal/browse/browse.go new file mode 100644 index 0000000..d12bd12 --- /dev/null +++ b/internal/browse/browse.go @@ -0,0 +1,82 @@ +// Package browse lists directories, so a person can pick one to index. +// +// A browser cannot give a page the absolute path of a folder somebody chose: +// its file picker deliberately withholds it. The agent is already on the +// machine, so it walks it and the page navigates what it lists. +package browse + +import ( + "os" + "path/filepath" + "sort" + "strings" +) + +// Entry is one directory that can be opened or picked. +type Entry struct { + Name string `json:"name"` + Path string `json:"path"` + // Repository says the directory is a git working tree, which is what + // somebody is nearly always looking for. + Repository bool `json:"repository"` +} + +// Listing is one directory and what is under it. +type Listing struct { + Path string `json:"path"` + Parent string `json:"parent"` + Entries []Entry `json:"entries"` +} + +// Home is where browsing starts when nowhere was named. +func Home() string { + home, err := os.UserHomeDir() + if err != nil { + return string(filepath.Separator) + } + return home +} + +// At lists the directories inside path. +// +// Only directories, and only their names: this exists to choose somewhere to +// index, and reading file contents is the indexer's job, not the picker's. +func At(path string) (Listing, error) { + if path == "" { + path = Home() + } + resolved, err := filepath.Abs(filepath.Clean(path)) + if err != nil { + return Listing{}, err + } + + items, err := os.ReadDir(resolved) + if err != nil { + return Listing{}, err + } + + entries := make([]Entry, 0, len(items)) + for _, item := range items { + if !item.IsDir() || strings.HasPrefix(item.Name(), ".") { + continue + } + full := filepath.Join(resolved, item.Name()) + entries = append(entries, Entry{ + Name: item.Name(), + Path: full, + Repository: isRepository(full), + }) + } + sort.Slice(entries, func(i, j int) bool { return entries[i].Name < entries[j].Name }) + + parent := filepath.Dir(resolved) + if parent == resolved { + parent = "" + } + return Listing{Path: resolved, Parent: parent, Entries: entries}, nil +} + +func isRepository(path string) bool { + info, err := os.Stat(filepath.Join(path, ".git")) + return err == nil && (info.IsDir() || info.Mode().IsRegular()) +} diff --git a/internal/browse/browse_test.go b/internal/browse/browse_test.go new file mode 100644 index 0000000..ab26c12 --- /dev/null +++ b/internal/browse/browse_test.go @@ -0,0 +1,103 @@ +package browse + +import ( + "os" + "path/filepath" + "testing" +) + +func tree(t *testing.T) string { + t.Helper() + root := t.TempDir() + for _, dir := range []string{"work", "work/billing", "work/billing/.git", "work/notes", ".hidden"} { + if err := os.MkdirAll(filepath.Join(root, dir), 0o755); err != nil { + t.Fatalf("building the tree: %v", err) + } + } + if err := os.WriteFile(filepath.Join(root, "work", "a-file"), []byte("x"), 0o644); err != nil { + t.Fatalf("writing a file: %v", err) + } + return root +} + +func TestItListsDirectoriesAndNotFiles(t *testing.T) { + root := tree(t) + + listing, err := At(filepath.Join(root, "work")) + if err != nil { + t.Fatalf("listing: %v", err) + } + + names := make([]string, 0, len(listing.Entries)) + for _, entry := range listing.Entries { + names = append(names, entry.Name) + } + if len(names) != 2 || names[0] != "billing" || names[1] != "notes" { + t.Errorf("got %v, want the two directories in order", names) + } +} + +func TestItMarksAWorkingTree(t *testing.T) { + root := tree(t) + + listing, _ := At(filepath.Join(root, "work")) + + for _, entry := range listing.Entries { + if entry.Name == "billing" && !entry.Repository { + t.Error("a directory with .git in it was not marked as a repository") + } + if entry.Name == "notes" && entry.Repository { + t.Error("a directory with no .git was marked as a repository") + } + } +} + +func TestHiddenDirectoriesAreLeftOut(t *testing.T) { + root := tree(t) + + listing, _ := At(root) + + for _, entry := range listing.Entries { + if entry.Name == ".hidden" { + t.Error("listed a hidden directory") + } + } +} + +func TestItSaysWhereUpIs(t *testing.T) { + root := tree(t) + + listing, _ := At(filepath.Join(root, "work")) + + if listing.Parent != root { + t.Errorf("got parent %q, want %q", listing.Parent, root) + } +} + +func TestTheTopOfTheTreeHasNoParent(t *testing.T) { + listing, err := At(string(filepath.Separator)) + if err != nil { + t.Fatalf("listing the root: %v", err) + } + + if listing.Parent != "" { + t.Errorf("got parent %q at the top of the tree, want none", listing.Parent) + } +} + +func TestNowhereNamedStartsAtHome(t *testing.T) { + listing, err := At("") + if err != nil { + t.Fatalf("listing: %v", err) + } + + if listing.Path != Home() { + t.Errorf("got %q, want %q", listing.Path, Home()) + } +} + +func TestADirectoryThatIsNotThereIsAnError(t *testing.T) { + if _, err := At(filepath.Join(t.TempDir(), "nowhere")); err == nil { + t.Fatal("listed a directory that does not exist") + } +} diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..d3b4998 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,59 @@ +// Package config reads what the agent needs to know before it starts anything. +package config + +import ( + "fmt" + "os" + "strconv" +) + +const ( + EnvListen = "SOURCEANT_AGENT_LISTEN" + EnvCore = "SOURCEANT_CORE" + EnvPort = "SOURCEANT_CORE_PORT" +) + +// DefaultListen is loopback on purpose. The agent reads a person's working +// tree; the machine it runs on is the only audience it has. +const DefaultListen = "127.0.0.1:8930" + +// DefaultCore is the Python entry point, found on PATH. +const DefaultCore = "sourceant" + +// Config is everything the agent takes from its environment. +type Config struct { + // Listen is where the agent answers. + Listen string + // Core is the Python executable to supervise. + Core string + // CoreWasChosen says somebody named that executable, rather than it being + // the fallback. An explicit choice outranks whatever was installed. + CoreWasChosen bool + // CorePort is the port to start it on, zero to pick a free one. + CorePort int +} + +// FromEnvironment reads the configuration, filling in what was not set. +func FromEnvironment() (Config, error) { + chosen := os.Getenv(EnvCore) + cfg := Config{ + Listen: valueOr(EnvListen, DefaultListen), + Core: valueOr(EnvCore, DefaultCore), + CoreWasChosen: chosen != "", + } + if raw := os.Getenv(EnvPort); raw != "" { + port, err := strconv.Atoi(raw) + if err != nil || port < 1 || port > 65535 { + return cfg, fmt.Errorf("%s is %q, which is not a port", EnvPort, raw) + } + cfg.CorePort = port + } + return cfg, nil +} + +func valueOr(name, fallback string) string { + if value := os.Getenv(name); value != "" { + return value + } + return fallback +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 0000000..38234e8 --- /dev/null +++ b/internal/config/config_test.go @@ -0,0 +1,55 @@ +package config + +import "testing" + +func TestItRunsWithNothingSet(t *testing.T) { + t.Setenv(EnvListen, "") + t.Setenv(EnvCore, "") + t.Setenv(EnvPort, "") + + cfg, err := FromEnvironment() + if err != nil { + t.Fatalf("reading configuration: %v", err) + } + + if cfg.Listen != DefaultListen { + t.Errorf("got %q, want %q", cfg.Listen, DefaultListen) + } + if cfg.Core != DefaultCore { + t.Errorf("got %q, want %q", cfg.Core, DefaultCore) + } + if cfg.CorePort != 0 { + t.Errorf("got port %d, want one chosen at start", cfg.CorePort) + } +} + +func TestItTakesWhatWasSet(t *testing.T) { + t.Setenv(EnvListen, "127.0.0.1:9999") + t.Setenv(EnvCore, "/opt/sourceant/bin/sourceant") + t.Setenv(EnvPort, "8123") + + cfg, err := FromEnvironment() + if err != nil { + t.Fatalf("reading configuration: %v", err) + } + + if cfg.Listen != "127.0.0.1:9999" || cfg.Core != "/opt/sourceant/bin/sourceant" || cfg.CorePort != 8123 { + t.Errorf("got %+v, want what the environment said", cfg) + } +} + +func TestAPortThatIsNotAPortIsRefusedAtStart(t *testing.T) { + t.Setenv(EnvPort, "eighty") + + if _, err := FromEnvironment(); err == nil { + t.Fatal("accepted a port that is not a number") + } +} + +func TestAPortOutsideTheRangeIsRefusedAtStart(t *testing.T) { + t.Setenv(EnvPort, "70000") + + if _, err := FromEnvironment(); err == nil { + t.Fatal("accepted a port no socket can bind") + } +} diff --git a/internal/core/client.go b/internal/core/client.go new file mode 100644 index 0000000..1888db3 --- /dev/null +++ b/internal/core/client.go @@ -0,0 +1,706 @@ +// Package core reads the Python indexer's HTTP surface. +// +// The agent never parses code. Everything it knows about a repository it got +// from here, so that one set of grammars and one graph shape serve every +// client. +package core + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// Envelope is the shape every core route answers in. +type envelope[T any] struct { + Status string `json:"status"` + Message string `json:"message"` + Data T `json:"data"` +} + +// Repository is one repository registered on this machine. +type Repository struct { + Name string `json:"name"` + Path string `json:"path"` +} + +// Node is one file, import or symbol in a repository's graph. +// +// Kind says what the thing is and never what it is written in: a file is a file +// whatever its language. Degree is how many lines meet here, which is what +// sizes it, and Community is which part of the repository it belongs to, which +// is what colours it. +type Node struct { + ID string `json:"id"` + Name string `json:"name"` + Kind string `json:"kind"` + Language string `json:"language,omitempty"` + Path string `json:"path"` + Labels []string `json:"labels"` + Degree int `json:"degree"` + Community *int `json:"community"` +} + +// Community is one part of a code graph: symbols more connected to each other +// than to the rest, named after where they live or what they are built around. +type Community struct { + ID int `json:"id"` + Name string `json:"name"` + Size int `json:"size"` +} + +// Link is a typed edge between two nodes. +type Link struct { + Source string `json:"source"` + Target string `json:"target"` + Type string `json:"type"` +} + +// Graph is a whole scope, as the index drew it. +// +// Truncated says the scope was larger than the cap asked for, so what came back +// is a part of the repository and not the repository. +type Graph struct { + Nodes []Node `json:"nodes"` + Links []Link `json:"links"` + Communities []Community `json:"communities"` + Truncated bool `json:"truncated"` + // Focus is the node it was walked out from, empty if it drew everything. + Focus string `json:"focus,omitempty"` +} + +// Error is a non-2xx answer from the core, carrying what it said. +type Error struct { + StatusCode int + Detail string +} + +func (e *Error) Error() string { + if e.Detail == "" { + return fmt.Sprintf("sourceant core returned %d", e.StatusCode) + } + return fmt.Sprintf("sourceant core returned %d: %s", e.StatusCode, e.Detail) +} + +// NotFound reports whether the core had no such repository registered. +func (e *Error) NotFound() bool { return e.StatusCode == http.StatusNotFound } + +// Patience is how long an ordinary call may take. Reads and writes against a +// local index answer in milliseconds; anything near this is a core in trouble. +const Patience = 30 * time.Second + +// Working is how long a call that does real work may take. Reading a repository +// of ten thousand files, or asking a model about five rules one at a time, is +// minutes rather than seconds, and cutting it off at the ordinary deadline +// throws away work that was going to succeed. +const Working = 15 * time.Minute + +// Client talks to one core instance. +type Client struct { + baseURL string + http *http.Client + patience time.Duration +} + +// New builds a client for the core serving at baseURL. +// +// The deadline is per call rather than on the client itself, because a client +// deadline caps every call at the shortest one any call needs. +func New(baseURL string, timeout time.Duration) *Client { + if timeout <= 0 { + timeout = Patience + } + return &Client{ + baseURL: strings.TrimRight(baseURL, "/"), + http: &http.Client{}, + patience: timeout, + } +} + +// waiting gives a call a deadline, unless it already has one. +// +// A deadline already on the context was set by whoever knows what this call is +// doing, so it wins: applying the ordinary one on top would cut a fifteen +// minute review off after thirty seconds. +func waiting(ctx context.Context, limit time.Duration) (context.Context, context.CancelFunc) { + if _, ok := ctx.Deadline(); ok { + return ctx, func() {} + } + return context.WithTimeout(ctx, limit) +} + +// BaseURL is the core this client talks to. +func (c *Client) BaseURL() string { return c.baseURL } + +// Healthy reports whether the core is up and answering. +func (c *Client) Healthy(ctx context.Context) bool { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/health", nil) + if err != nil { + return false + } + resp, err := c.http.Do(req) + if err != nil { + return false + } + defer func() { _ = resp.Body.Close() }() + _, _ = io.Copy(io.Discard, resp.Body) + return resp.StatusCode >= 200 && resp.StatusCode < 300 +} + +// Repositories lists what has been registered on this machine. +func (c *Client) Repositories(ctx context.Context) ([]Repository, error) { + return get[[]Repository](ctx, c, "/api/code/repositories", nil) +} + +// GraphOptions narrows what a drawing covers. +type GraphOptions struct { + PathPrefix string + IncludeTests bool + NodeLimit int +} + +// Graph reads one repository's whole scope. +func (c *Client) Graph(ctx context.Context, repository string, opts GraphOptions) (Graph, error) { + query := url.Values{"repository": {repository}} + if opts.PathPrefix != "" { + query.Set("path_prefix", opts.PathPrefix) + } + if opts.IncludeTests { + query.Set("include_tests", "true") + } + if opts.NodeLimit > 0 { + query.Set("node_limit", strconv.Itoa(opts.NodeLimit)) + } + return get[Graph](ctx, c, "/api/code/graph", query) +} + +// Worth is one file where recent change has landed on something the rest of +// the code leans on. +type Worth struct { + Path string `json:"path"` + Dependants int `json:"dependants"` + Changes int `json:"changes"` +} + +// Attention is where a person's time goes furthest in a repository. +type Attention struct { + Files []Worth `json:"files"` + // The window the change counts cover, so a screen need not invent one. + Since string `json:"since"` +} + +// Attention is the files where recent change meets a central position. +// +// Either fact alone says little: something half the codebase imports and +// nobody has touched is settled, and something nothing imports that changes +// daily is a scratch pad. It is the overlap that is worth somebody's time. +func (c *Client) Attention(ctx context.Context, repository string) (Attention, error) { + return get[Attention](ctx, c, "/api/code/attention", url.Values{ + "repository": {repository}, + }) +} + +// Register covers one more directory, so the next index run reads it too. +func (c *Client) Register(ctx context.Context, path, name string) (Repository, error) { + return send[Repository](ctx, c, http.MethodPost, "/api/code/repositories", nil, map[string]string{ + "path": path, + "name": name, + }) +} + +// Forget stops covering a directory. What was already indexed is left alone. +func (c *Client) Forget(ctx context.Context, path string) error { + _, err := send[map[string]any](ctx, c, http.MethodDelete, "/api/code/repositories", + url.Values{"path": {path}}, nil) + return err +} + +// Indexed is what one repository's index run read. +type Indexed struct { + Repository string `json:"repository"` + Files int `json:"indexed"` + Unchanged int `json:"unchanged"` + Removed int `json:"removed"` + Skipped int `json:"skipped"` +} + +// Index reads repositories into the graph, one or all of them. +// +// Update reads only what changed since last time, which is what a watcher +// wants. Somebody who asked for this in as many words usually means read it +// again: how a file is read changes with the indexer, and an update pass sees +// an unchanged file and skips it. +// +// The core answers when the reading is done, so this takes as long as the +// repository is large. The caller's context is what bounds it. +func (c *Client) Index(ctx context.Context, repository string, everything, update bool) ([]Indexed, error) { + ctx, done := waiting(ctx, Working) + defer done() + return send[[]Indexed](ctx, c, http.MethodPost, "/api/code/index", nil, map[string]any{ + "repository": repository, + "everything": everything, + "update": update, + }) +} + +// Knowledge is one thing recorded about a repository. +type Knowledge struct { + ID string `json:"id"` + Kind string `json:"kind"` + Status string `json:"status"` + // Which repository it was recorded against. Only answered when the search + // was not narrowed to one, where it is the thing a reader cannot infer. + Repository string `json:"repository,omitempty"` + Summary string `json:"summary"` + Properties map[string]any `json:"properties"` +} + +// KnowledgePage is what a search answered. +type KnowledgePage struct { + Items []Knowledge `json:"items"` + Total int `json:"total"` + HasMore bool `json:"has_more"` +} + +// Knowledge reads what is recorded about one repository. +func (c *Client) Knowledge(ctx context.Context, repository string, limit, offset int) (KnowledgePage, error) { + query := url.Values{"repository": {repository}} + if limit > 0 { + query.Set("limit", strconv.Itoa(limit)) + } + if offset > 0 { + query.Set("offset", strconv.Itoa(offset)) + } + return get[KnowledgePage](ctx, c, "/api/knowledge", query) +} + +// RecordKnowledge writes something down about a repository. +func (c *Client) RecordKnowledge(ctx context.Context, repository string, item Knowledge) (Knowledge, error) { + return send[Knowledge](ctx, c, http.MethodPut, "/api/knowledge", nil, map[string]any{ + "repository": repository, + "id": item.ID, + "kind": item.Kind, + "status": item.Status, + "summary": item.Summary, + "properties": item.Properties, + }) +} + +// Seed is one thing a repository states, read off a file rather than judged. +type Seed struct { + Knowledge + Source string `json:"source"` +} + +// Seeded is what reading a repository's own words found. +type Seeded struct { + Found []Seed `json:"found"` + Recorded int `json:"recorded"` +} + +// Initialize records what a repository already states about itself. +// +// Asking without recording is the safe half, so a person can see what would be +// written before any of it is. Asking a model as well finds what nobody wrote +// down, and costs whatever the machine's own model costs. +func (c *Client) Initialize(ctx context.Context, repository string, dryRun, useModel bool) (Seeded, error) { + if useModel { + var done context.CancelFunc + ctx, done = waiting(ctx, Working) + defer done() + } + return send[Seeded](ctx, c, http.MethodPost, "/api/knowledge/initialize", nil, map[string]any{ + "repository": repository, + "dry_run": dryRun, + "use_model": useModel, + }) +} + +// Skill is one thing a team wrote down about how work here is done. +// +// Paths, Reviews and Automatic are what the author stated in the skill's own +// frontmatter: which files it is about, whether it belongs in a review, and +// whether anything but a person may start it. Reviews is null where nobody +// said, which is most of them and is not the same as saying no. +type Skill struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Origin string `json:"origin"` + Path string `json:"path"` + Paths []string `json:"paths"` + Reviews *bool `json:"reviews"` + Automatic bool `json:"automatic"` + Body string `json:"body,omitempty"` +} + +// SkillPage is the skills on hand. +type SkillPage struct { + Skills []Skill `json:"skills"` + Total int `json:"total"` +} + +// Skills is everything this machine and this repository hold. +// +// All of them: a person with a folder per coding agent easily has a hundred, +// and a screen that silently showed the first fifty would be lying about what +// a review had to choose from. +func (c *Client) Skills(ctx context.Context, repository string) (SkillPage, error) { + return get[SkillPage](ctx, c, "/api/skills", url.Values{ + "repository": {repository}, + "limit": {"500"}, + }) +} + +// Skill is one rule in full, so a person can read what a check was made against. +func (c *Client) Skill(ctx context.Context, id, repository string) (Skill, error) { + return get[Skill](ctx, c, "/api/skills/"+id, url.Values{"repository": {repository}}) +} + +// Stated is a skill somebody is writing down, and where it belongs. +// +// Scope is "repository" for something about one project, which the team then +// gets by pulling, or "machine" for something somebody wants everywhere. +type Stated struct { + ID string `json:"id"` + Repository string `json:"repository"` + Scope string `json:"scope"` + Name string `json:"name"` + Description string `json:"description"` + Body string `json:"body"` + Paths []string `json:"paths"` + Reviews *bool `json:"reviews"` +} + +// RecordSkill writes a skill down, in a repository or on this machine. +// +// Only the places this product owns are written. What somebody keeps in the +// folders named after a coding agent is that agent's, and core refuses to +// write there. +func (c *Client) RecordSkill(ctx context.Context, stated Stated) (Skill, error) { + if stated.Scope == "" { + stated.Scope = "repository" + } + if stated.Paths == nil { + stated.Paths = []string{} + } + return send[Skill](ctx, c, http.MethodPut, "/api/skills", nil, stated) +} + +// ForgetSkill removes a skill written here. +func (c *Client) ForgetSkill(ctx context.Context, repository, scope, id string) error { + if scope == "" { + scope = "repository" + } + _, err := send[map[string]any](ctx, c, http.MethodDelete, "/api/skills", + url.Values{"repository": {repository}, "scope": {scope}, "id": {id}}, nil) + return err +} + +// Finding is one thing a rule says is wrong with a change. +type Finding struct { + Detail string `json:"detail"` + Severity string `json:"severity"` + Path string `json:"path"` + Line *int `json:"line"` +} + +// Verdict is what one rule made of a change. +type Verdict struct { + Skill string `json:"skill"` + Passed bool `json:"passed"` + Note string `json:"note"` + Findings []Finding `json:"findings"` +} + +// ChangedFile is one file a checkout's work touches, and what changed in it. +// +// The patch travels with the file rather than as one diff for the whole +// change: a page shows somebody the file they are looking at, and a list of +// names is not a review. +type ChangedFile struct { + Path string `json:"path"` + Change string `json:"change"` + Patch string `json:"patch"` +} + +// Recorded is one thing known about the repository being reviewed. +type Recorded struct { + ID string `json:"id"` + Kind string `json:"kind"` + Summary string `json:"summary"` +} + +// Where is the checkout a review read, and what it was compared against. +// +// A person with a worktree open somewhere else is otherwise left wondering +// whose work they are looking at. +type Where struct { + Path string `json:"path"` + Branch string `json:"branch"` + Against string `json:"against"` + Base string `json:"base"` + Commits int `json:"commits"` +} + +// Suggestion is one thing to change, and the code to put there. +type Suggestion struct { + Path string `json:"path"` + StartLine int `json:"start_line"` + EndLine int `json:"end_line"` + Side string `json:"side"` + Comment string `json:"comment"` + Category string `json:"category"` + // Both sides. Without what it replaces, a suggestion draws as an addition + // out of nowhere. + ExistingCode string `json:"existing_code"` + SuggestedCode string `json:"suggested_code"` +} + +// Summary is the review in the order a person reads it. +type Summary struct { + Overview string `json:"overview"` + KeyImprovements []string `json:"key_improvements"` + MinorSuggestions []string `json:"minor_suggestions"` + CriticalIssues []string `json:"critical_issues"` +} + +// Read is the review proper: the same one the hosted path gives a pull +// request, from the same generator. +type Read struct { + Verdict string `json:"verdict"` + Summary Summary `json:"summary"` + Suggestions []Suggestion `json:"suggestions"` + Notes map[string]string `json:"notes"` +} + +// Commit is one commit the branch has that the branch it left does not. +type Commit struct { + SHA string `json:"sha"` + Author string `json:"author"` + At string `json:"at"` + Subject string `json:"subject"` + Body string `json:"body"` +} + +// Review is whether a checkout's work is ready to be proposed to anyone. +// +// Every field the core answers with has to be named here. This is decoded into +// and re-encoded on the way out, so anything missing is dropped in silence. +type Review struct { + Ready bool `json:"ready"` + Note string `json:"note"` + Base string `json:"base"` + Where Where `json:"where"` + Changed []ChangedFile `json:"changed"` + Commits []Commit `json:"commits"` + Skills []Skill `json:"skills"` + Knowledge []Recorded `json:"knowledge"` + Verdicts []Verdict `json:"verdicts"` + // The review itself, as opposed to what the skills made of it. + Read Read `json:"review"` +} + +// Ask is what to review and how. +type Ask struct { + Repository string `json:"repository"` + Against string `json:"against"` + Title string `json:"title"` + Description string `json:"description"` + Skills []string `json:"skills"` + UseModel bool `json:"use_model"` +} + +// Reading is one review, whether it has finished or not. +// +// Kept by the core rather than held here, because the thing that asks for a +// review is often not the thing that reads it: an agent runs one over MCP and +// hands somebody a link, and the link has to still work later. +type Reading struct { + ID string `json:"id"` + Repository string `json:"repository"` + Status string `json:"status"` + Title string `json:"title"` + Error string `json:"error"` + Started string `json:"started"` + Finished string `json:"finished"` + Review Review `json:"review"` + // Where to send somebody who was handed this by an agent. + Path string `json:"path"` +} + +// Review asks for a review and answers with where to find it. +// +// Nothing here reaches a forge: the work being judged has not been proposed to +// anyone yet, which is the point of judging it now. +func (c *Client) Review(ctx context.Context, ask Ask) (Reading, error) { + if ask.Skills == nil { + ask.Skills = []string{} + } + return send[Reading](ctx, c, http.MethodPost, "/api/local/reviews", nil, ask) +} + +// Reviewed is one review by name, however long ago it ran. +func (c *Client) Reviewed(ctx context.Context, id string) (Reading, error) { + return get[Reading](ctx, c, "/api/local/reviews/"+url.PathEscape(id), nil) +} + +// Reviews is the last few, newest first, without their findings. +func (c *Client) Reviews(ctx context.Context, repository string) ([]Reading, error) { + return get[[]Reading](ctx, c, "/api/local/reviews", url.Values{ + "repository": {repository}, + }) +} + +// Setting is one thing configurable on this machine. +// +// A credential answers whether it is set rather than what it is: a screen needs +// the first and nothing needs the second. +type Setting struct { + Key string `json:"key"` + Label string `json:"label"` + Description string `json:"description"` + Type string `json:"type"` + Value any `json:"value"` + Default any `json:"default"` + Choices []string `json:"choices"` + Group string `json:"group"` + Secret bool `json:"secret"` + // Listed is several of something rather than one thing, kept one to a + // line, so a screen draws it as a list rather than as a box of text. + Listed bool `json:"listed"` + IsSet *bool `json:"is_set"` +} + +// Settings is everything configurable on this machine. +func (c *Client) Settings(ctx context.Context) ([]Setting, error) { + return get[[]Setting](ctx, c, "/api/local/settings", nil) +} + +// SetSetting gives one setting a value on this machine. +func (c *Client) SetSetting(ctx context.Context, key string, value any) (Setting, error) { + return send[Setting](ctx, c, http.MethodPut, "/api/local/settings/"+url.PathEscape(key), + nil, map[string]any{"value": value}) +} + +// ResetSetting puts one setting back to what it would be if nobody had touched it. +func (c *Client) ResetSetting(ctx context.Context, key string) (Setting, error) { + return send[Setting](ctx, c, http.MethodDelete, + "/api/local/settings/"+url.PathEscape(key), nil, nil) +} + +// ForgetKnowledge removes something recorded. +func (c *Client) ForgetKnowledge(ctx context.Context, repository, id string) error { + _, err := send[map[string]any](ctx, c, http.MethodDelete, "/api/knowledge", + url.Values{"repository": {repository}, "id": {id}}, nil) + return err +} + +func send[T any](ctx context.Context, c *Client, method, path string, query url.Values, payload any) (T, error) { + var zero T + target := c.baseURL + path + if len(query) > 0 { + target += "?" + query.Encode() + } + + var body io.Reader + if payload != nil { + encoded, err := json.Marshal(payload) + if err != nil { + return zero, err + } + body = bytes.NewReader(encoded) + } + + ctx, done := waiting(ctx, c.patience) + defer done() + + req, err := http.NewRequestWithContext(ctx, method, target, body) + if err != nil { + return zero, err + } + req.Header.Set("Accept", "application/json") + if payload != nil { + req.Header.Set("Content-Type", "application/json") + } + + resp, err := c.http.Do(req) + if err != nil { + return zero, err + } + defer func() { _ = resp.Body.Close() }() + + answered, err := io.ReadAll(resp.Body) + if err != nil { + return zero, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return zero, &Error{StatusCode: resp.StatusCode, Detail: detail(answered)} + } + + var parsed envelope[T] + if err := json.Unmarshal(answered, &parsed); err != nil { + return zero, fmt.Errorf("sourceant core answered %s with something other than JSON: %w", path, err) + } + return parsed.Data, nil +} + +func get[T any](ctx context.Context, c *Client, path string, query url.Values) (T, error) { + var zero T + target := c.baseURL + path + if len(query) > 0 { + target += "?" + query.Encode() + } + ctx, done := waiting(ctx, c.patience) + defer done() + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, target, nil) + if err != nil { + return zero, err + } + req.Header.Set("Accept", "application/json") + + resp, err := c.http.Do(req) + if err != nil { + return zero, err + } + defer func() { _ = resp.Body.Close() }() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return zero, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return zero, &Error{StatusCode: resp.StatusCode, Detail: detail(body)} + } + + var parsed envelope[T] + if err := json.Unmarshal(body, &parsed); err != nil { + return zero, fmt.Errorf("sourceant core answered %s with something other than JSON: %w", path, err) + } + return parsed.Data, nil +} + +// detail pulls the reason out of an error body, falling back to the body itself. +func detail(body []byte) string { + var parsed struct { + Detail string `json:"detail"` + Error string `json:"error"` + } + if err := json.Unmarshal(body, &parsed); err == nil { + if parsed.Detail != "" { + return parsed.Detail + } + if parsed.Error != "" { + return parsed.Error + } + } + return strings.TrimSpace(string(body)) +} diff --git a/internal/core/client_test.go b/internal/core/client_test.go new file mode 100644 index 0000000..d5204d4 --- /dev/null +++ b/internal/core/client_test.go @@ -0,0 +1,247 @@ +package core + +import ( + "context" + "errors" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "slices" + "strings" + "testing" + "time" +) + +// The fixtures are answers captured from a running core, not written here, so a +// change to what it serves fails these rather than passing against our guess. +func fixture(t *testing.T, name string) []byte { + t.Helper() + data, err := os.ReadFile(filepath.Join("testdata", name)) + if err != nil { + t.Fatalf("reading fixture: %v", err) + } + return data +} + +func serving(t *testing.T, routes map[string]func(http.ResponseWriter, *http.Request)) *Client { + t.Helper() + mux := http.NewServeMux() + for pattern, handler := range routes { + mux.HandleFunc(pattern, handler) + } + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + return New(server.URL, 5*time.Second) +} + +func TestRepositoriesReadsWhatTheCoreRegistered(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/repositories": func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write(fixture(t, "repositories.json")) + }, + }) + + repositories, err := client.Repositories(context.Background()) + if err != nil { + t.Fatalf("listing repositories: %v", err) + } + + if len(repositories) != 1 { + t.Fatalf("got %d repositories, want 1", len(repositories)) + } + if repositories[0].Name != "local/sourceant" { + t.Errorf("got name %q, want local/sourceant", repositories[0].Name) + } + if repositories[0].Path == "" { + t.Error("got an empty path, want the directory the core registered") + } +} + +func TestGraphKeepsWhatTellsAFileFromAFunction(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write(fixture(t, "graph.json")) + }, + }) + + graph, err := client.Graph(context.Background(), "local/sourceant", GraphOptions{}) + if err != nil { + t.Fatalf("reading graph: %v", err) + } + + if len(graph.Nodes) == 0 || len(graph.Links) == 0 { + t.Fatalf("got %d nodes and %d links, want both", len(graph.Nodes), len(graph.Links)) + } + if graph.Truncated { + t.Error("got a truncated graph, want the whole captured scope") + } + + var file, symbol *Node + for i := range graph.Nodes { + switch { + case file == nil && slices.Contains(graph.Nodes[i].Labels, "File"): + file = &graph.Nodes[i] + case symbol == nil && graph.Nodes[i].Kind == "function": + symbol = &graph.Nodes[i] + } + } + if file == nil || symbol == nil { + t.Fatal("the captured graph holds no file and function to tell apart") + } + // A file is a file whatever it is written in. Colouring Python files apart + // from Go ones would be colouring the wrong question, so the language sits + // beside the kind rather than standing in for it. + if file.Kind != "file" || file.Language != "python" { + t.Errorf("got kind %q language %q, want file and python", file.Kind, file.Language) + } + if file.Path == "" || symbol.Path == "" { + t.Error("got a node with no path, want where the code sits") + } +} + +// A drawing sizes a node by how busy it is and colours it by which part of the +// repository it belongs to, so neither may be missing from what is read. +func TestGraphKeepsWhatSizesAndColoursANode(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write(fixture(t, "graph.json")) + }, + }) + + graph, err := client.Graph(context.Background(), "local/sourceant", GraphOptions{}) + if err != nil { + t.Fatalf("reading graph: %v", err) + } + + if len(graph.Communities) == 0 { + t.Fatal("the captured graph found no parts to colour") + } + for _, part := range graph.Communities { + if part.Name == "" || part.Size == 0 { + t.Errorf("got part %+v, want one saying what it is and how big", part) + } + } + + busiest, coloured := 0, 0 + for _, node := range graph.Nodes { + if node.Degree > busiest { + busiest = node.Degree + } + if node.Community != nil { + coloured++ + } + } + if busiest == 0 { + t.Error("no node says how many lines meet at it") + } + if coloured == 0 { + t.Error("no node says which part it belongs to") + } +} + +func TestGraphPassesOnWhatNarrowsADrawing(t *testing.T) { + var asked string + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, r *http.Request) { + asked = r.URL.RawQuery + _, _ = w.Write(fixture(t, "graph.json")) + }, + }) + + _, err := client.Graph(context.Background(), "local/sourceant", GraphOptions{ + PathPrefix: "src/config/", + IncludeTests: true, + NodeLimit: 120, + }) + if err != nil { + t.Fatalf("reading graph: %v", err) + } + + for _, want := range []string{ + "repository=local%2Fsourceant", + "path_prefix=src%2Fconfig%2F", + "include_tests=true", + "node_limit=120", + } { + if !strings.Contains(asked, want) { + t.Errorf("query %q is missing %q", asked, want) + } + } +} + +func TestAnUnregisteredRepositoryIsReportedAsSuch(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write(fixture(t, "unknown_repository.json")) + }, + }) + + _, err := client.Graph(context.Background(), "acme/nope", GraphOptions{}) + + var coreError *Error + if !errors.As(err, &coreError) { + t.Fatalf("got %v, want a core error", err) + } + if !coreError.NotFound() { + t.Errorf("got status %d, want 404", coreError.StatusCode) + } + if !strings.Contains(coreError.Error(), "not registered on this machine") { + t.Errorf("got %q, want the reason the core gave", coreError.Error()) + } +} + +func TestHealthyIsFalseWhenTheCoreIsNotThere(t *testing.T) { + client := New("http://127.0.0.1:1", 200*time.Millisecond) + + if client.Healthy(context.Background()) { + t.Error("reported a core that is not listening as healthy") + } +} + +// Everything the core says about a review has to survive the trip through +// here. This is decoded into a struct and encoded again on the way out, so a +// field nobody named is dropped without a word: the commits a branch is ahead +// by went missing that way, and the page that drew them looked simply empty. +func TestNothingTheCoreSaysAboutAReviewIsDroppedInTransit(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/local/reviews/abc": func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`{"data":{ + "id":"abc","repository":"acme/billing","status":"done", + "review":{ + "where":{"branch":"work","against":"main","commits":18}, + "commits":[{"sha":"1111111","author":"Nobody","at":"2026-08-29T00:00:00Z","subject":"First","body":"why"}], + "changed":[{"path":"a.py","change":"modified","patch":"@@"}], + "review":{"verdict":"COMMENT","suggestions":[ + {"path":"a.py","start_line":2,"comment":"c","category":"BUG", + "existing_code":"was","suggested_code":"is"} + ]} + } + }}`)) + }, + }) + + read, err := client.Reviewed(context.Background(), "abc") + if err != nil { + t.Fatalf("reading a review: %v", err) + } + + if got := len(read.Review.Commits); got != 1 { + t.Fatalf("got %d commits, want 1", got) + } + if got := read.Review.Commits[0].Subject; got != "First" { + t.Fatalf("got subject %q, want First", got) + } + if got := read.Review.Where.Commits; got != 18 { + t.Fatalf("got %d commits ahead, want 18", got) + } + + suggestions := read.Review.Read.Suggestions + if len(suggestions) != 1 { + t.Fatalf("got %d suggestions, want 1", len(suggestions)) + } + if got := suggestions[0].ExistingCode; got != "was" { + t.Fatalf("got existing code %q, want was", got) + } +} diff --git a/internal/core/patience_test.go b/internal/core/patience_test.go new file mode 100644 index 0000000..9a7905c --- /dev/null +++ b/internal/core/patience_test.go @@ -0,0 +1,47 @@ +package core + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + "time" +) + +func slow(delay time.Duration, body any) *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + select { + case <-time.After(delay): + case <-r.Context().Done(): + return + } + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(map[string]any{"data": body}) + })) +} + +func TestAnOrdinaryCallGivesUpOnTheOrdinaryDeadline(t *testing.T) { + server := slow(300*time.Millisecond, []Repository{}) + defer server.Close() + client := New(server.URL, 50*time.Millisecond) + + if _, err := client.Repositories(context.Background()); err == nil { + t.Error("waited past the ordinary deadline") + } +} + +// Whoever asked owns the deadline. A caller who says fifty milliseconds gets +// fifty milliseconds, whatever the call would otherwise have waited. +func TestADeadlineAlreadySetIsNotReplaced(t *testing.T) { + server := slow(300*time.Millisecond, []Repository{}) + defer server.Close() + client := New(server.URL, Working) + + ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) + defer cancel() + + if _, err := client.Repositories(ctx); err == nil { + t.Error("waited past the deadline it was given") + } +} diff --git a/internal/core/testdata/graph.json b/internal/core/testdata/graph.json new file mode 100644 index 0000000..14eaecf --- /dev/null +++ b/internal/core/testdata/graph.json @@ -0,0 +1 @@ +{"status":"success","message":"Request was successful","data":{"nodes":[{"id":"file:src/config/__init__.py","name":"__init__.py","kind":"file","path":"src/config/__init__.py","labels":["File"],"language":"python","degree":0,"community":3},{"id":"file:src/config/db.py","name":"db.py","kind":"file","path":"src/config/db.py","labels":["File"],"language":"python","degree":5,"community":1},{"id":"file:src/config/paths.py","name":"paths.py","kind":"file","path":"src/config/paths.py","labels":["File"],"language":"python","degree":7,"community":0},{"id":"file:src/config/settings.py","name":"settings.py","kind":"file","path":"src/config/settings.py","labels":["File"],"language":"python","degree":3,"community":2},{"id":"import:src/config/db.py:0","name":"from sqlmodel import create_engine, Session","kind":"import","path":"src/config/db.py","labels":["Import"],"degree":1,"community":1},{"id":"import:src/config/db.py:1","name":"from src.utils.logger import logger","kind":"import","path":"src/config/db.py","labels":["Import"],"degree":1,"community":1},{"id":"import:src/config/db.py:2","name":"from src.config.settings import DATABASE_URL, STATELESS_MODE, DEBUG_MODE","kind":"import","path":"src/config/db.py","labels":["Import"],"degree":1,"community":1},{"id":"import:src/config/paths.py:0","name":"import os","kind":"import","path":"src/config/paths.py","labels":["Import"],"degree":1,"community":0},{"id":"import:src/config/paths.py:1","name":"import secrets","kind":"import","path":"src/config/paths.py","labels":["Import"],"degree":1,"community":0},{"id":"import:src/config/paths.py:2","name":"from pathlib import Path","kind":"import","path":"src/config/paths.py","labels":["Import"],"degree":1,"community":0},{"id":"import:src/config/settings.py:0","name":"import os","kind":"import","path":"src/config/settings.py","labels":["Import"],"degree":1,"community":2},{"id":"import:src/config/settings.py:1","name":"from dotenv import load_dotenv","kind":"import","path":"src/config/settings.py","labels":["Import"],"degree":1,"community":2},{"id":"import:src/config/settings.py:2","name":"from src.config.paths import default_database_url","kind":"import","path":"src/config/settings.py","labels":["Import"],"degree":1,"community":2},{"id":"symbol:src/config/db.py:get_engine:7:0","name":"get_engine","kind":"function","path":"src/config/db.py","labels":["Function"],"degree":1,"community":1},{"id":"symbol:src/config/db.py:get_session:30:1","name":"get_session","kind":"function","path":"src/config/db.py","labels":["Function"],"degree":1,"community":1},{"id":"symbol:src/config/paths.py:data_dir:10:0","name":"data_dir","kind":"function","path":"src/config/paths.py","labels":["Function"],"degree":1,"community":0},{"id":"symbol:src/config/paths.py:default_database_url:26:2","name":"default_database_url","kind":"function","path":"src/config/paths.py","labels":["Function"],"degree":1,"community":0},{"id":"symbol:src/config/paths.py:ensure_data_dir:20:1","name":"ensure_data_dir","kind":"function","path":"src/config/paths.py","labels":["Function"],"degree":1,"community":0},{"id":"symbol:src/config/paths.py:local_jwt_secret:30:3","name":"local_jwt_secret","kind":"function","path":"src/config/paths.py","labels":["Function"],"degree":1,"community":0}],"links":[{"source":"file:src/config/db.py","target":"symbol:src/config/db.py:get_engine:7:0","type":"defines"},{"source":"file:src/config/db.py","target":"symbol:src/config/db.py:get_session:30:1","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:data_dir:10:0","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:default_database_url:26:2","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:ensure_data_dir:20:1","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:local_jwt_secret:30:3","type":"defines"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:0","type":"imports"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:1","type":"imports"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:2","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:0","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:1","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:2","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:0","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:1","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:2","type":"imports"}],"communities":[{"id":0,"name":"src/config","size":8},{"id":1,"name":"src/config/db.py","size":6},{"id":2,"name":"src/config/settings.py","size":4},{"id":3,"name":"src/config/__init__.py","size":1}],"truncated":false,"focus":null}} \ No newline at end of file diff --git a/internal/core/testdata/repositories.json b/internal/core/testdata/repositories.json new file mode 100644 index 0000000..7d6fa53 --- /dev/null +++ b/internal/core/testdata/repositories.json @@ -0,0 +1 @@ +{"status":"success","message":"Request was successful","data":[{"name":"local/sourceant","path":"/app"}]} \ No newline at end of file diff --git a/internal/core/testdata/unknown_repository.json b/internal/core/testdata/unknown_repository.json new file mode 100644 index 0000000..5304dee --- /dev/null +++ b/internal/core/testdata/unknown_repository.json @@ -0,0 +1 @@ +{"detail":"acme/nope is not registered on this machine"} \ No newline at end of file diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go new file mode 100644 index 0000000..9dd0b86 --- /dev/null +++ b/internal/runtime/runtime.go @@ -0,0 +1,211 @@ +// Package runtime says how to start the Python core on this machine. +// +// There are two ways to have it, and which one a person chose is a fact about +// their machine rather than about either binary: the installer writes it down +// and the agent reads it. Without that file the agent looks for the core on +// PATH, which is what a developer working on the core itself already has. +package runtime + +import ( + "encoding/json" + "errors" + "fmt" + "net/url" + "os" + "path/filepath" + "strconv" +) + +// Kind is how the core is installed. +type Kind string + +const ( + // Python is the core as a program on this machine. + Python Kind = "python" + // Docker is the core as a container image. + Docker Kind = "docker" +) + +// DefaultImage is the published core. A tag is pinned at install time; this is +// only the fallback for a config that names none. +const DefaultImage = "ghcr.io/sourceant/sourceant:latest" + +// Core is everything needed to start the indexer. +type Core struct { + Runtime Kind `json:"runtime"` + // Command is the executable, for the python runtime. + Command string `json:"command,omitempty"` + // Image is the container, for the docker runtime. + Image string `json:"image,omitempty"` + // DataDir is where the index lives. Both runtimes must agree on it, or + // indexing and reading would address two different databases. + DataDir string `json:"data_dir,omitempty"` + // Mount is a host directory the container can see, for the docker runtime. + // + // The indexer reads the repository's files, so a container that cannot see + // them indexes nothing. It is mounted at the same path it has on the host, + // which is what lets one registry of absolute paths mean the same thing to + // both runtimes. A repository outside it is not readable this way. + Mount string `json:"mount,omitempty"` + // UIURL is where the agent serves the screen, so the core can hand out a + // link to a review rather than a path. + UIURL string `json:"-"` + // User is the uid:gid a container runs as, for the docker runtime. + // + // The image has a user of its own, and where that user's id differs from + // the person's, everything the container writes into the mounted index + // belongs to somebody who does not exist on this machine. The installer + // records who is installing so the container writes as them. + User string `json:"user,omitempty"` +} + +// Config is what the installer wrote. +type Config struct { + Core Core `json:"core"` +} + +// Home is where SourceAnt keeps what it installed. +func Home() string { + if override := os.Getenv("SOURCEANT_INSTALL_HOME"); override != "" { + return override + } + home, err := os.UserHomeDir() + if err != nil { + return ".sourceant" + } + return filepath.Join(home, ".sourceant") +} + +// ConfigPath is the file the installer writes and the agent reads. +func ConfigPath() string { return filepath.Join(Home(), "config.json") } + +// ErrNotInstalled says nothing has been installed here yet. +var ErrNotInstalled = errors.New("no runtime is installed") + +// Load reads the installed runtime. +func Load(path string) (Config, error) { + data, err := os.ReadFile(path) + if errors.Is(err, os.ErrNotExist) { + return Config{}, ErrNotInstalled + } + if err != nil { + return Config{}, err + } + var config Config + if err := json.Unmarshal(data, &config); err != nil { + return Config{}, fmt.Errorf("%s is not readable as a runtime: %w", path, err) + } + if config.Core.Runtime != Python && config.Core.Runtime != Docker { + return Config{}, fmt.Errorf("%s names runtime %q, which is neither python nor docker", path, config.Core.Runtime) + } + return config, nil +} + +// Save writes the runtime for the agent to read. +func Save(path string, config Config) error { + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + return err + } + data, err := json.MarshalIndent(config, "", " ") + if err != nil { + return err + } + return os.WriteFile(path, append(data, '\n'), 0o644) +} + +// Serve is the command that starts the core listening on port. +// +// The two runtimes need different addresses for the same thing. A program on +// this machine binds loopback and is reached there. A container binding +// loopback would bind the container's own, reachable by nothing, so it binds +// every interface inside and is published to loopback outside. +func (c Core) Serve(port int) (string, []string, error) { + number := strconv.Itoa(port) + switch c.Runtime { + case Python: + if c.Command == "" { + return "", nil, errors.New("the python runtime names no command") + } + return c.Command, []string{"serve", "--host", "127.0.0.1", "--port", number}, nil + case Docker: + image := c.Image + if image == "" { + image = DefaultImage + } + args := []string{ + "run", "--rm", + "--name", "sourceant-core-" + number, + "-p", "127.0.0.1:" + number + ":" + number, + } + if c.DataDir != "" { + args = append(args, "-v", c.DataDir+":/data", "-e", "SOURCEANT_HOME=/data") + } + if c.UIURL != "" { + // So a review asked for over MCP can answer with a link somebody + // can click, rather than a path they have to assemble. + args = append(args, "-e", "SOURCEANT_UI_URL="+c.UIURL) + // And a second address for reaching back. The clickable one is + // loopback, which inside a container is the container, so handing + // work to the agent needs the host's address instead. + args = append(args, + "--add-host", "host.docker.internal:host-gateway", + "-e", "SOURCEANT_AGENT_URL="+throughTheHost(c.UIURL), + ) + } + if c.Mount != "" { + args = append(args, "-v", c.Mount+":"+c.Mount) + // The image has a home of its own, and nothing a person taught + // their coding agent is in it. What the person keeps in theirs is + // only readable if the container is told where theirs is. + args = append(args, "-e", "SOURCEANT_MACHINE_HOME="+c.Mount) + } + if c.User != "" { + args = append(args, "--user", c.User) + } + // The image starts a production server by default, so the entry point + // is replaced with the command line the agent actually wants. + args = append(args, "--entrypoint", "./sourceant", image, + "serve", "--host", "0.0.0.0", "--port", number) + return "docker", args, nil + default: + return "", nil, fmt.Errorf("runtime %q is neither python nor docker", c.Runtime) + } +} + +// Describe is one line naming what will be started. +func (c Core) Describe() string { + switch c.Runtime { + case Python: + return "python · " + c.Command + case Docker: + image := c.Image + if image == "" { + image = DefaultImage + } + return "docker · " + image + default: + return string(c.Runtime) + } +} + +// throughTheHost rewrites a loopback address into one a container can reach. +// +// The agent listens on loopback, which is right: nothing else should reach it. +// A container's loopback is its own, so the same URL means two different +// machines depending on who reads it. +func throughTheHost(address string) string { + parsed, err := url.Parse(address) + if err != nil { + return address + } + host := parsed.Hostname() + if host != "127.0.0.1" && host != "localhost" && host != "::1" { + return address + } + if port := parsed.Port(); port != "" { + parsed.Host = "host.docker.internal:" + port + } else { + parsed.Host = "host.docker.internal" + } + return parsed.String() +} diff --git a/internal/runtime/runtime_test.go b/internal/runtime/runtime_test.go new file mode 100644 index 0000000..ac1d009 --- /dev/null +++ b/internal/runtime/runtime_test.go @@ -0,0 +1,135 @@ +package runtime + +import ( + "errors" + "path/filepath" + "slices" + "strings" + "testing" +) + +func TestNothingInstalledIsSaidPlainly(t *testing.T) { + _, err := Load(filepath.Join(t.TempDir(), "config.json")) + + if !errors.Is(err, ErrNotInstalled) { + t.Fatalf("got %v, want ErrNotInstalled", err) + } +} + +func TestWhatTheInstallerWroteIsWhatTheAgentReads(t *testing.T) { + path := filepath.Join(t.TempDir(), "config.json") + written := Config{Core: Core{ + Runtime: Docker, + Image: "ghcr.io/sourceant/sourceant:v1", + DataDir: "/home/someone/.local/share/sourceant", + }} + + if err := Save(path, written); err != nil { + t.Fatalf("saving: %v", err) + } + read, err := Load(path) + if err != nil { + t.Fatalf("loading: %v", err) + } + + if read != written { + t.Errorf("got %+v, want %+v", read, written) + } +} + +func TestARuntimeThatIsNeitherIsRefusedWhenItIsRead(t *testing.T) { + path := filepath.Join(t.TempDir(), "config.json") + if err := Save(path, Config{Core: Core{Runtime: "podman"}}); err != nil { + t.Fatalf("saving: %v", err) + } + + if _, err := Load(path); err == nil { + t.Fatal("accepted a runtime that is neither python nor docker") + } +} + +func TestThePythonRuntimeBindsLoopbackDirectly(t *testing.T) { + core := Core{Runtime: Python, Command: "/opt/sourceant/bin/sourceant"} + + name, args, err := core.Serve(8931) + if err != nil { + t.Fatalf("building the command: %v", err) + } + + if name != "/opt/sourceant/bin/sourceant" { + t.Errorf("got %q, want the installed command", name) + } + want := []string{"serve", "--host", "127.0.0.1", "--port", "8931"} + if !slices.Equal(args, want) { + t.Errorf("got %v, want %v", args, want) + } +} + +// A container binding loopback binds its own, which nothing can reach, so it +// has to bind every interface inside and be published to loopback outside. +func TestTheDockerRuntimeBindsInsideAndPublishesOutside(t *testing.T) { + core := Core{ + Runtime: Docker, + Image: "ghcr.io/sourceant/sourceant:v1", + DataDir: "/data/here", + Mount: "/home/someone", + User: "501:20", + } + + name, args, err := core.Serve(8931) + if err != nil { + t.Fatalf("building the command: %v", err) + } + + if name != "docker" { + t.Errorf("got %q, want docker", name) + } + line := strings.Join(args, " ") + for _, want := range []string{ + "-p 127.0.0.1:8931:8931", + "--host 0.0.0.0 --port 8931", + "-v /data/here:/data", + "-e SOURCEANT_HOME=/data", + // At the same path on both sides, so one registry of absolute paths + // means the same thing whichever runtime reads it. + "-v /home/someone:/home/someone", + // The image has a home of its own, and nothing the person taught their + // coding agent is in it. + "-e SOURCEANT_MACHINE_HOME=/home/someone", + "--user 501:20", + "--entrypoint ./sourceant", + "ghcr.io/sourceant/sourceant:v1 serve", + } { + if !strings.Contains(line, want) { + t.Errorf("%q is missing from: docker %s", want, line) + } + } +} + +// Every docker flag has to come before the image, or docker reads it as an +// argument to the core instead of to itself. +func TestEveryDockerFlagComesBeforeTheImage(t *testing.T) { + core := Core{Runtime: Docker, Image: "ghcr.io/sourceant/sourceant:v1", DataDir: "/data/here", User: "501:20"} + + _, args, _ := core.Serve(8931) + + image := slices.Index(args, "ghcr.io/sourceant/sourceant:v1") + if image == -1 { + t.Fatal("the image is not in the command") + } + for _, flag := range []string{"--rm", "--name", "-p", "-v", "-e", "--user", "--entrypoint"} { + if at := slices.Index(args, flag); at > image { + t.Errorf("%s comes after the image, so docker would pass it to the core", flag) + } + } +} + +func TestADataDirNobodyChoseIsNotMounted(t *testing.T) { + core := Core{Runtime: Docker, Image: "img"} + + _, args, _ := core.Serve(8931) + + if slices.Contains(args, "-v") { + t.Errorf("mounted something without being told where: %v", args) + } +} diff --git a/internal/supervise/process_other.go b/internal/supervise/process_other.go new file mode 100644 index 0000000..9bcc377 --- /dev/null +++ b/internal/supervise/process_other.go @@ -0,0 +1,13 @@ +//go:build !unix + +package supervise + +import "os/exec" + +// Process groups are a Unix idea. Elsewhere the supervisor reaches the process +// it started and no further, which is what the standard library offers. +func isolate(*exec.Cmd) {} + +func askToStop(command *exec.Cmd) error { return command.Process.Kill() } + +func forceStop(command *exec.Cmd) error { return command.Process.Kill() } diff --git a/internal/supervise/process_unix.go b/internal/supervise/process_unix.go new file mode 100644 index 0000000..cc1b121 --- /dev/null +++ b/internal/supervise/process_unix.go @@ -0,0 +1,30 @@ +//go:build unix + +package supervise + +import ( + "os/exec" + "syscall" +) + +// isolate puts the process in a group of its own. +// +// Without it, stopping the core reaches only the process we started. Anything +// it started stays running, holding the port the next start wants. +func isolate(command *exec.Cmd) { + command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} +} + +// signal sends sig to the whole group, falling back to the process alone when +// there is no group to address. +func signal(command *exec.Cmd, sig syscall.Signal) error { + pid := command.Process.Pid + if group, err := syscall.Getpgid(pid); err == nil { + return syscall.Kill(-group, sig) + } + return syscall.Kill(pid, sig) +} + +func askToStop(command *exec.Cmd) error { return signal(command, syscall.SIGTERM) } + +func forceStop(command *exec.Cmd) error { return signal(command, syscall.SIGKILL) } diff --git a/internal/supervise/supervisor.go b/internal/supervise/supervisor.go new file mode 100644 index 0000000..6543ced --- /dev/null +++ b/internal/supervise/supervisor.go @@ -0,0 +1,266 @@ +// Package supervise keeps the Python core running. +// +// The core is a separate process because the grammars and the graph live there. +// The agent's job is to make that process something a person never has to think +// about: start it, notice when it dies, start it again. +package supervise + +import ( + "context" + "errors" + "fmt" + "io" + "net" + "os/exec" + "sync" + "time" +) + +// Backoff is how long to wait before restarting, and how far that grows. +type Backoff struct { + First time.Duration + Max time.Duration +} + +func (b Backoff) after(previous time.Duration) time.Duration { + if previous == 0 { + return b.First + } + doubled := previous * 2 + if doubled > b.Max { + return b.Max + } + return doubled +} + +// Options describe the process to keep alive. +type Options struct { + // Name and Args are the command. Name is looked up on PATH. + Name string + Args []string + // Dir is where it runs, empty for the agent's own directory. + Dir string + // Env is the whole environment, empty to inherit the agent's. + Env []string + // Ready reports whether the process is up and answering. It is polled + // after each start until it says yes or ReadyWithin passes. + Ready func(context.Context) bool + // ReadyWithin bounds that wait, and PollEvery is how often it is asked. + ReadyWithin time.Duration + PollEvery time.Duration + // StopWithin is how long a process gets to stop when asked, before it is + // killed. + StopWithin time.Duration + // Backoff paces restarts. + Backoff Backoff + // Output receives the process's stdout and stderr, nil to discard. + Output io.Writer +} + +func (o Options) withDefaults() Options { + if o.ReadyWithin == 0 { + o.ReadyWithin = 30 * time.Second + } + if o.PollEvery == 0 { + o.PollEvery = 100 * time.Millisecond + } + if o.StopWithin == 0 { + o.StopWithin = 5 * time.Second + } + if o.Backoff.First == 0 { + o.Backoff.First = 250 * time.Millisecond + } + if o.Backoff.Max == 0 { + o.Backoff.Max = 30 * time.Second + } + return o +} + +// ErrNotReady says the process started but never began answering. +var ErrNotReady = errors.New("the process started but never became ready") + +// process is one launch, and the single place its exit is waited for. +// +// exec.Cmd is not safe to Wait on from one goroutine while another reads +// ProcessState, so exactly one goroutine calls Wait and everybody else learns +// what happened by waiting on done. +type process struct { + cmd *exec.Cmd + err error + done chan struct{} +} + +// wait is the only caller of Wait. Writing err before closing done is what lets +// exit read it without a lock. +func (p *process) wait() { + p.err = p.cmd.Wait() + close(p.done) +} + +// exit blocks until the process has gone, and says why. +func (p *process) exit() error { + <-p.done + return p.err +} + +// Supervisor runs one process and restarts it for as long as it is asked to. +type Supervisor struct { + options Options + + mu sync.Mutex + starts int + lastExit error +} + +// New builds a supervisor for the process described by options. +func New(options Options) *Supervisor { + return &Supervisor{options: options.withDefaults()} +} + +// Starts is how many times the process has been launched, restarts included. +func (s *Supervisor) Starts() int { + s.mu.Lock() + defer s.mu.Unlock() + return s.starts +} + +// LastExit is why the process last stopped, nil if it never has. +func (s *Supervisor) LastExit() error { + s.mu.Lock() + defer s.mu.Unlock() + return s.lastExit +} + +// Run starts the process and keeps it running until ctx is cancelled. +// +// It returns once the process is stopped and no further restart is wanted, so a +// caller runs it in its own goroutine. A cancelled context is not an error: it +// is how a caller says stop. +func (s *Supervisor) Run(ctx context.Context) error { + var wait time.Duration + for { + if ctx.Err() != nil { + return nil + } + + started, err := s.start(ctx) + if err != nil { + return err + } + + if s.options.Ready != nil && !s.waitReady(ctx, started) { + s.terminate(started) + s.record(started.exit()) + if ctx.Err() != nil { + return nil + } + return fmt.Errorf("%w within %s", ErrNotReady, s.options.ReadyWithin) + } + + s.record(started.exit()) + if ctx.Err() != nil { + return nil + } + + wait = s.options.Backoff.after(wait) + select { + case <-ctx.Done(): + return nil + case <-time.After(wait): + } + } +} + +func (s *Supervisor) start(ctx context.Context) (*process, error) { + command := exec.Command(s.options.Name, s.options.Args...) + command.Dir = s.options.Dir + command.Env = s.options.Env + command.Stdout = s.options.Output + command.Stderr = s.options.Output + isolate(command) + + if err := command.Start(); err != nil { + return nil, fmt.Errorf("starting %s: %w", s.options.Name, err) + } + + started := &process{cmd: command, done: make(chan struct{})} + go started.wait() + + s.mu.Lock() + s.starts++ + s.mu.Unlock() + + // Stopping the process when the context ends is what makes the wait + // return, so a cancelled Run does not leave the core running behind it. + go func() { + select { + case <-ctx.Done(): + s.terminate(started) + case <-started.done: + } + }() + + return started, nil +} + +// waitReady polls until the process answers, it exits, or the deadline passes. +func (s *Supervisor) waitReady(ctx context.Context, started *process) bool { + deadline := time.Now().Add(s.options.ReadyWithin) + ticker := time.NewTicker(s.options.PollEvery) + defer ticker.Stop() + + for { + if s.options.Ready(ctx) { + return true + } + if time.Now().After(deadline) { + return false + } + select { + case <-started.done: + return false + case <-ctx.Done(): + return false + case <-ticker.C: + } + } +} + +// terminate asks the process to stop, then insists. +// +// A core killed outright loses whatever it was writing, so it is asked first +// and only killed if it does not go. Both signals address the process group, +// because a core that started a worker leaves it holding the port otherwise. +func (s *Supervisor) terminate(started *process) { + if started == nil || started.cmd.Process == nil { + return + } + if err := askToStop(started.cmd); err != nil { + return + } + select { + case <-started.done: + case <-time.After(s.options.StopWithin): + _ = forceStop(started.cmd) + } +} + +func (s *Supervisor) record(exit error) { + s.mu.Lock() + s.lastExit = exit + s.mu.Unlock() +} + +// FreePort asks the operating system for a port nobody is using. +// +// It is racy by nature: the port is free when asked and could be taken before +// it is bound. Nothing better exists without binding it here and handing the +// listener over, which a child process cannot accept. +func FreePort() (int, error) { + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return 0, err + } + defer func() { _ = listener.Close() }() + return listener.Addr().(*net.TCPAddr).Port, nil +} diff --git a/internal/supervise/supervisor_test.go b/internal/supervise/supervisor_test.go new file mode 100644 index 0000000..e46618a --- /dev/null +++ b/internal/supervise/supervisor_test.go @@ -0,0 +1,166 @@ +package supervise + +import ( + "context" + "errors" + "os" + "path/filepath" + "sync/atomic" + "testing" + "time" +) + +// script writes an executable shell script and returns the command to run it. +func script(t *testing.T, body string) (string, []string) { + t.Helper() + path := filepath.Join(t.TempDir(), "process.sh") + if err := os.WriteFile(path, []byte("#!/bin/sh\n"+body), 0o755); err != nil { + t.Fatalf("writing script: %v", err) + } + return "/bin/sh", []string{path} +} + +func TestItRestartsAProcessThatDies(t *testing.T) { + name, args := script(t, "exit 1\n") + supervisor := New(Options{ + Name: name, + Args: args, + Backoff: Backoff{First: time.Millisecond, Max: 2 * time.Millisecond}, + }) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { return supervisor.Starts() >= 3 }) + cancel() + + if err := <-done; err != nil { + t.Fatalf("running: %v", err) + } + if supervisor.LastExit() == nil { + t.Error("a process that exited 1 was recorded as exiting cleanly") + } +} + +func TestItLeavesNothingRunningWhenItIsToldToStop(t *testing.T) { + marker := filepath.Join(t.TempDir(), "alive") + name, args := script(t, "touch "+marker+"\nwhile true; do sleep 0.05; done\n") + supervisor := New(Options{Name: name, Args: args}) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { + _, err := os.Stat(marker) + return err == nil + }) + cancel() + + select { + case err := <-done: + if err != nil { + t.Fatalf("running: %v", err) + } + case <-time.After(5 * time.Second): + t.Fatal("cancelling left the process running") + } +} + +// A core that started a worker leaves it holding the port unless the whole +// group is stopped, so this drives a process that starts a child of its own. +func TestItLeavesNoGrandchildRunningEither(t *testing.T) { + dir := t.TempDir() + marker := filepath.Join(dir, "child-alive") + child := filepath.Join(dir, "child.sh") + if err := os.WriteFile(child, []byte( + "#!/bin/sh\nwhile true; do touch "+marker+"; sleep 0.02; done\n"), 0o755); err != nil { + t.Fatalf("writing child script: %v", err) + } + name, args := script(t, child+" &\nwhile true; do sleep 0.05; done\n") + supervisor := New(Options{Name: name, Args: args, StopWithin: 200 * time.Millisecond}) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { + _, err := os.Stat(marker) + return err == nil + }) + cancel() + <-done + + // The child touches the marker every 20ms while it lives. Remove it, and if + // it comes back the child outlived the process that started it. + if err := os.Remove(marker); err != nil { + t.Fatalf("removing marker: %v", err) + } + time.Sleep(300 * time.Millisecond) + if _, err := os.Stat(marker); err == nil { + t.Error("a grandchild was still running after the supervisor stopped") + } +} + +func TestItWaitsForTheProcessToAnswerBeforeCallingItStarted(t *testing.T) { + name, args := script(t, "while true; do sleep 0.05; done\n") + var polls atomic.Int32 + supervisor := New(Options{ + Name: name, + Args: args, + Ready: func(context.Context) bool { + return polls.Add(1) >= 3 + }, + PollEvery: time.Millisecond, + ReadyWithin: 5 * time.Second, + }) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go func() { _ = supervisor.Run(ctx) }() + + waitFor(t, func() bool { return polls.Load() >= 3 }) + if supervisor.Starts() != 1 { + t.Errorf("started %d times while waiting to be ready, want 1", supervisor.Starts()) + } +} + +func TestAProcessThatNeverAnswersIsReportedRatherThanRestartedForever(t *testing.T) { + name, args := script(t, "while true; do sleep 0.05; done\n") + supervisor := New(Options{ + Name: name, + Args: args, + Ready: func(context.Context) bool { return false }, + PollEvery: time.Millisecond, + ReadyWithin: 50 * time.Millisecond, + }) + + err := supervisor.Run(context.Background()) + + if !errors.Is(err, ErrNotReady) { + t.Fatalf("got %v, want ErrNotReady", err) + } +} + +func TestFreePortGivesAPortNobodyIsUsing(t *testing.T) { + port, err := FreePort() + if err != nil { + t.Fatalf("asking for a port: %v", err) + } + if port <= 0 || port > 65535 { + t.Errorf("got port %d, want a usable one", port) + } +} + +func waitFor(t *testing.T, condition func() bool) { + t.Helper() + deadline := time.Now().Add(5 * time.Second) + for time.Now().Before(deadline) { + if condition() { + return + } + time.Sleep(2 * time.Millisecond) + } + t.Fatal("condition never held") +} diff --git a/internal/ui/assets/assets/3d-force-graph-B8lgMx4q.js b/internal/ui/assets/assets/3d-force-graph-B8lgMx4q.js new file mode 100644 index 0000000..25c7f7e --- /dev/null +++ b/internal/ui/assets/assets/3d-force-graph-B8lgMx4q.js @@ -0,0 +1,1151 @@ +import{C as Ua,R as tp,M as tt,T as kr,V as ce,P as wc,a as V,b as At,B as Hi,c as sr,S as Rc,d as Kt,e as rp,f as ea,L as Ky,G as sp,g as np,h as ip,i as Yy,Q as Qy,j as op,k as Zy,l as Jy,w as z,H as ht,m as Ec,N as Ds,n as ap,o as Ac,F as eb,p as tb,y as up,q as Be,r as O,s as We,t as ps,u as yt,v as er,x as He,z as ft,A as Ls,D as Gr,E as Ni,W as fa,I as br,J as js,K as rb,O as lp,U as sb,X as Cc,Y as cp,Z as nb,_ as ib,$ as ob,a0 as ab,a1 as ub,a2 as lb,a3 as cb,a4 as db,a5 as Tn,a6 as St,a7 as vn,a8 as Fs,a9 as Ze,aa as Ge,ab as dt,ac as dp,ad as qi,ae as Xi,af as Vr,ag as $r,ah as tr,ai as Ki,aj as Yi,ak as Mc,al as hp,am as fp,an as zr,ao as Bc,ap as Pc,aq as Oa,ar as pp,as as xr,at as Li,au as hb,av as fb,aw as ss,ax as Sn,ay as Dr,az as rs,aA as Mn,aB as pb,aC as Dc,aD as Fc,aE as pa,aF as Ia,aG as oe,aH as Qi,aI as Lc,aJ as Rd,aK as ka,aL as Ui,aM as gb,aN as ga,aO as Ga,aP as Oi,aQ as Va,aR as ls,aS as yl,aT as Bn,aU as gp,aV as Lt,aW as mp,aX as ma,aY as Pn,aZ as yp,a_ as Zi,a$ as Uc,b0 as bp,b1 as _p,b2 as Ed,b3 as Dn,b4 as mb,b5 as xp,b6 as Tp,b7 as vp,b8 as Sp,b9 as Np,ba as wp,bb as Rp,bc as Ep,bd as Ap,be as Cp,bf as Mp,bg as Bp,bh as yb,bi as bb,bj as _b,bk as Pp,bl as Wr,bm as mn,bn as yn,bo as bn,bp as Fr,bq as Dp,br as Fp,bs as Lp,bt as Up,bu as Op,bv as Ip,bw as kp,bx as Gp,by as Oc,bz as ta,bA as ra,bB as sa,bC as na,bD as Ad,bE as Cd,bF as Md,bG as Bd,bH as bl,bI as _l,bJ as xl,bK as Tl,bL as vl,bM as ya,bN as Sl,bO as Nl,bP as wl,bQ as Rl,bR as El,bS as Al,bT as Cl,bU as Ml,bV as Bl,bW as Pl,bX as Dl,bY as Fl,bZ as Ll,b_ as Ul,b$ as Ol,c0 as Il,c1 as kl,c2 as Gl,c3 as Vl,c4 as $l,c5 as ba,c6 as zl,c7 as Vp,c8 as xb,c9 as Tb,ca as vb,cb as Sb,cc as Nb,cd as wb,ce as Rb,cf as Eb,cg as Ab,ch as Cb,ci as Mb,cj as $a,ck as Ic,cl as Bb,cm as Pb,cn as Db,co as _a,cp as Fb,cq as Lb,cr as Ub,cs as Ob,ct as Ib,cu as kb,cv as Gb,cw as Vb,cx as $b,cy as zb,cz as Wb,cA as jb,cB as Hb,cC as qb,cD as Xb,cE as Kb,cF as Yb,cG as Qb,cH as $p,cI as zp,cJ as Zb,cK as Jb,cL as e_,cM as xa,cN as t_,cO as r_,cP as Wp,cQ as jp,cR as Hp,cS as s_,cT as n_,cU as i_,cV as o_,cW as kc,cX as a_,cY as u_,cZ as l_,c_,c$ as Ta,d0 as va,d1 as nu,d2 as iu,d3 as d_,d4 as h_,d5 as f_,d6 as p_,d7 as Pd,d8 as g_,d9 as Dd,da as m_,db as y_,dc as qp,dd as b_,de as __}from"./three.module-D-PgY1-x.js";import{h as pe,o as x_,g as T_,f as Gc,k as v_,l as S_,t as Xp,j as N_,G as w_,T as Fd,E as Ld}from"./Paired-DNTqsPj0.js";import{f as R_,a as E_,b as A_,c as C_,e as M_}from"./radial-aO03NmL0.js";const Nn=new wc,Lr=new ce,Kp=new V,ou=new ce,ia=new ce,Sa=new V,Wl=new V,Yp=new At,Qp=new V,Zp=new V;let lt=null,fr=null;const Ur=[],cs={NONE:-1,PAN:0,ROTATE:1};class B_ extends Ua{constructor(e,t,r=null){super(t,r),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new tp,this.mouseButtons={LEFT:tt.PAN,MIDDLE:tt.PAN,RIGHT:tt.ROTATE},this.touches={ONE:kr.PAN},this._onPointerMove=P_.bind(this),this._onPointerDown=D_.bind(this),this._onPointerCancel=F_.bind(this),this._onContextMenu=L_.bind(this),r!==null&&this.connect(r)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();Lr.x=(e.clientX-t.left)/t.width*2-1,Lr.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case tt.PAN:case kr.PAN:this.state=cs.PAN;break;case tt.ROTATE:case kr.ROTATE:this.state=cs.ROTATE;break;default:this.state=cs.NONE}}}function P_(i){const e=this.object,t=this.domElement,r=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),r.setFromCamera(Lr,e),lt)this.state===cs.PAN?r.ray.intersectPlane(Nn,Sa)&&(lt.position.copy(Sa.sub(Kp).applyMatrix4(Yp)),this.dispatchEvent({type:"drag",object:lt})):this.state===cs.ROTATE&&(ou.subVectors(Lr,ia).multiplyScalar(this.rotateSpeed),lt.rotateOnWorldAxis(Qp,ou.x),lt.rotateOnWorldAxis(Zp.normalize(),-ou.y),this.dispatchEvent({type:"drag",object:lt})),ia.copy(Lr);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(Ur.length=0,r.setFromCamera(Lr,e),r.intersectObjects(this.objects,this.recursive,Ur),Ur.length>0){const s=Ur[0].object;Nn.setFromNormalAndCoplanarPoint(e.getWorldDirection(Nn.normal),Wl.setFromMatrixPosition(s.matrixWorld)),fr!==s&&fr!==null&&(this.dispatchEvent({type:"hoveroff",object:fr}),t.style.cursor="auto",fr=null),fr!==s&&(this.dispatchEvent({type:"hoveron",object:s}),t.style.cursor="pointer",fr=s)}else fr!==null&&(this.dispatchEvent({type:"hoveroff",object:fr}),t.style.cursor="auto",fr=null);ia.copy(Lr)}}function D_(i){const e=this.object,t=this.domElement,r=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),Ur.length=0,r.setFromCamera(Lr,e),r.intersectObjects(this.objects,this.recursive,Ur),Ur.length>0&&(this.transformGroup===!0?lt=Jp(Ur[0].object):lt=Ur[0].object,Nn.setFromNormalAndCoplanarPoint(e.getWorldDirection(Nn.normal),Wl.setFromMatrixPosition(lt.matrixWorld)),r.ray.intersectPlane(Nn,Sa)&&(this.state===cs.PAN?(Yp.copy(lt.parent.matrixWorld).invert(),Kp.copy(Sa).sub(Wl.setFromMatrixPosition(lt.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:lt})):this.state===cs.ROTATE&&(Qp.set(0,1,0).applyQuaternion(e.quaternion).normalize(),Zp.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:lt})))),ia.copy(Lr))}function F_(){this.enabled!==!1&&(lt&&(this.dispatchEvent({type:"dragend",object:lt}),lt=null),this.domElement.style.cursor=fr?"pointer":"auto",this.state=cs.NONE)}function L_(i){this.enabled!==!1&&i.preventDefault()}function Jp(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:Jp(i.parent,e)}function U_(i){I_(i);const e=O_(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function O_(i){let e=Object.create(null);return{on:function(t,r,s){if(typeof r!="function")throw new Error("callback is expected to be a function");let n=e[t];return n||(n=e[t]=[]),n.push({callback:r,ctx:s}),i},off:function(t,r){if(typeof t>"u")return e=Object.create(null),i;if(e[t])if(typeof r!="function")delete e[t];else{const o=e[t];for(let a=0;a1&&(s=Array.prototype.slice.call(arguments,1));for(let n=0;n0&&(d.fire("changed",o),o.length=0)}function le(G){if(typeof G!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+G);for(var j=e.values(),ne=j.next();!ne.done;){if(G(ne.value))return!0;ne=j.next()}}}function G_(i,e){this.id=i,this.links=null,this.data=e}function Ud(i,e){i.links?i.links.add(e):i.links=new Set([e])}function Od(i,e,t,r){this.fromId=i,this.toId=e,this.data=t,this.id=r}function oo(i,e){return i.toString()+"👉 "+e.toString()}function V_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ao={exports:{}},Zs={exports:{}},au,Id;function eg(){return Id||(Id=1,au=function(e){return e===0?"x":e===1?"y":e===2?"z":"c"+(e+1)}),au}var uu,kd;function Gn(){if(kd)return uu;kd=1;const i=eg();return uu=function(t){return r;function r(s,n){let o=n&&n.indent||0,a=n&&n.join!==void 0?n.join:` +`,u=Array(o+1).join(" "),l=[];for(let c=0;c {var}max) {var}max = pos.{var};",{indent:6})} + } + + // Makes the bounds square. + var maxSideLength = -Infinity; + ${c("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})} + + currentInCache = 0; + root = newNode(); + ${c("root.min_{var} = {var}min;",{indent:4})} + ${c("root.max_{var} = {var}min + maxSideLength;",{indent:4})} + + i = bodies.length - 1; + if (i >= 0) { + root.body = bodies[i]; + } + while (i--) { + insert(bodies[i], root); + } + } + + function insert(newBody) { + insertStack.reset(); + insertStack.push(root, newBody); + + while (!insertStack.isEmpty()) { + var stackItem = insertStack.pop(); + var node = stackItem.node; + var body = stackItem.body; + + if (!node.body) { + // This is internal node. Update the total mass of the node and center-of-mass. + ${c("var {var} = body.pos.{var};",{indent:8})} + node.mass += body.mass; + ${c("node.mass_{var} += body.mass * {var};",{indent:8})} + + // Recursively insert the body in the appropriate quadrant. + // But first find the appropriate quadrant. + var quadIdx = 0; // Assume we are in the 0's quad. + ${c("var min_{var} = node.min_{var};",{indent:8})} + ${c("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})} + +${f(8)} + + var child = getChild(node, quadIdx); + + if (!child) { + // The node is internal but this quadrant is not taken. Add + // subnode to it. + child = newNode(); + ${c("child.min_{var} = min_{var};",{indent:10})} + ${c("child.max_{var} = max_{var};",{indent:10})} + child.body = body; + + setChild(node, quadIdx, child); + } else { + // continue searching in this quadrant. + insertStack.push(child, body); + } + } else { + // We are trying to add to the leaf node. + // We have to convert current leaf into internal node + // and continue adding two nodes. + var oldBody = node.body; + node.body = null; // internal nodes do not cary bodies + + if (isSamePosition(oldBody.pos, body.pos)) { + // Prevent infinite subdivision by bumping one node + // anywhere in this quadrant + var retriesCount = 3; + do { + var offset = random.nextDouble(); + ${c("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})} + + ${c("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})} + retriesCount -= 1; + // Make sure we don't bump it out of the box. If we do, next iteration should fix it + } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos)); + + if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) { + // This is very bad, we ran out of precision. + // if we do not return from the method we'll get into + // infinite loop here. So we sacrifice correctness of layout, and keep the app running + // Next layout iteration should get larger bounding box in the first step and fix this + return; + } + } + // Next iteration should subdivide node further. + insertStack.push(node, oldBody); + insertStack.push(node, body); + } + } + } +} +return createQuadTree; + +`;function f(m){let y=[],x=Array(m+1).join(" ");for(let _=0;_ max_${e(_)}) {`),y.push(x+` quadIdx = quadIdx + ${Math.pow(2,_)};`),y.push(x+` min_${e(_)} = max_${e(_)};`),y.push(x+` max_${e(_)} = node.max_${e(_)};`),y.push(x+"}");return y.join(` +`)}function p(){let m=Array(11).join(" "),y=[];for(let x=0;x 0) { + return this.stack[--this.popIdx]; + } + }, + reset: function () { + this.popIdx = 0; + } +}; + +function InsertStackElement(node, body) { + this.node = node; // QuadTree node + this.body = body; // physical body which needs to be inserted to node +} +`}return Er.exports}var uo={exports:{}},$d;function W_(){if($d)return uo.exports;$d=1,uo.exports=e,uo.exports.generateFunctionBody=t;const i=Gn();function e(r){let s=t(r);return new Function("bodies","settings","random",s)}function t(r){let s=i(r);return` + var boundingBox = { + ${s("min_{var}: 0, max_{var}: 0,",{indent:4})} + }; + + return { + box: boundingBox, + + update: updateBoundingBox, + + reset: resetBoundingBox, + + getBestNewPosition: function (neighbors) { + var ${s("base_{var} = 0",{join:", "})}; + + if (neighbors.length) { + for (var i = 0; i < neighbors.length; ++i) { + let neighborPos = neighbors[i].pos; + ${s("base_{var} += neighborPos.{var};",{indent:10})} + } + + ${s("base_{var} /= neighbors.length;",{indent:8})} + } else { + ${s("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})} + } + + var springLength = settings.springLength; + return { + ${s("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})} + }; + } + }; + + function updateBoundingBox() { + var i = bodies.length; + if (i === 0) return; // No bodies - no borders. + + ${s("var max_{var} = -Infinity;",{indent:4})} + ${s("var min_{var} = Infinity;",{indent:4})} + + while(i--) { + // this is O(n), it could be done faster with quadtree, if we check the root node bounds + var bodyPos = bodies[i].pos; + ${s("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})} + ${s("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})} + } + + ${s("boundingBox.min_{var} = min_{var};",{indent:4})} + ${s("boundingBox.max_{var} = max_{var};",{indent:4})} + } + + function resetBoundingBox() { + ${s("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})} + } +`}return uo.exports}var lo={exports:{}},zd;function j_(){if(zd)return lo.exports;zd=1;const i=Gn();lo.exports=e,lo.exports.generateCreateDragForceFunctionBody=t;function e(r){let s=t(r);return new Function("options",s)}function t(r){return` + if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number'); + + return { + update: function(body) { + ${i(r)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})} + } + }; +`}return lo.exports}var co={exports:{}},Wd;function H_(){if(Wd)return co.exports;Wd=1;const i=Gn();co.exports=e,co.exports.generateCreateSpringForceFunctionBody=t;function e(r){let s=t(r);return new Function("options","random",s)}function t(r){let s=i(r);return` + if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number'); + if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number'); + + return { + /** + * Updates forces acting on a spring + */ + update: function (spring) { + var body1 = spring.from; + var body2 = spring.to; + var length = spring.length < 0 ? options.springLength : spring.length; + ${s("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})} + var r = Math.sqrt(${s("d{var} * d{var}",{join:" + "})}); + + if (r === 0) { + ${s("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})} + r = Math.sqrt(${s("d{var} * d{var}",{join:" + "})}); + } + + var d = r - length; + var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r; + + ${s("body1.force.{var} += coefficient * d{var}",{indent:6})}; + body1.springCount += 1; + body1.springLength += r; + + ${s("body2.force.{var} -= coefficient * d{var}",{indent:6})}; + body2.springCount += 1; + body2.springLength += r; + } + }; +`}return co.exports}var ho={exports:{}},jd;function q_(){if(jd)return ho.exports;jd=1;const i=Gn();ho.exports=e,ho.exports.generateIntegratorFunctionBody=t;function e(r){let s=t(r);return new Function("bodies","timeStep","adaptiveTimeStepWeight",s)}function t(r){let s=i(r);return` + var length = bodies.length; + if (length === 0) return 0; + + ${s("var d{var} = 0, t{var} = 0;",{indent:2})} + + for (var i = 0; i < length; ++i) { + var body = bodies[i]; + if (body.isPinned) continue; + + if (adaptiveTimeStepWeight && body.springCount) { + timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount); + } + + var coeff = timeStep / body.mass; + + ${s("body.velocity.{var} += coeff * body.force.{var};",{indent:4})} + ${s("var v{var} = body.velocity.{var};",{indent:4})} + var v = Math.sqrt(${s("v{var} * v{var}",{join:" + "})}); + + if (v > 1) { + // We normalize it so that we move within timeStep range. + // for the case when v <= 1 - we let velocity to fade out. + ${s("body.velocity.{var} = v{var} / v;",{indent:6})} + } + + ${s("d{var} = timeStep * body.velocity.{var};",{indent:4})} + + ${s("body.pos.{var} += d{var};",{indent:4})} + + ${s("t{var} += Math.abs(d{var});",{indent:4})} + } + + return (${s("t{var} * t{var}",{join:" + "})})/length; +`}return ho.exports}var lu,Hd;function X_(){if(Hd)return lu;Hd=1,lu=i;function i(e,t,r,s){this.from=e,this.to=t,this.length=r,this.coefficient=s}return lu}var cu,qd;function K_(){if(qd)return cu;qd=1,cu=i;function i(e,t){var r;if(e||(e={}),t){for(r in t)if(t.hasOwnProperty(r)){var s=e.hasOwnProperty(r),n=typeof t[r],o=!s||typeof e[r]!==n;o?e[r]=t[r]:n==="object"&&(e[r]=i(e[r],t[r]))}}return e}return cu}var du,Xd;function tg(){if(Xd)return du;Xd=1;function i(r){t(r);const s=e(r);return r.on=s.on,r.off=s.off,r.fire=s.fire,r}function e(r){let s=Object.create(null);return{on:function(n,o,a){if(typeof o!="function")throw new Error("callback is expected to be a function");let u=s[n];return u||(u=s[n]=[]),u.push({callback:o,ctx:a}),r},off:function(n,o){if(typeof n>"u")return s=Object.create(null),r;if(s[n])if(typeof o!="function")delete s[n];else{const a=s[n];for(let u=0;u1&&(a=Array.prototype.slice.call(arguments,1));for(let u=0;u=1||u===0);return l*Math.sqrt(-2*Math.log(u)/u)}e.prototype.levy=r;function r(){var u=1.5,l=Math.pow(s(1+u)*Math.sin(Math.PI*u/2)/(s((1+u)/2)*u*Math.pow(2,(u-1)/2)),1/u);return this.gaussian()*l/Math.pow(Math.abs(this.gaussian()),1/u)}function s(u){return Math.sqrt(2*Math.PI/u)*Math.pow(1/Math.E*(u+1/(12*u-1/(10*u))),u)}function n(){var u=this.seed;return u=u+2127912214+(u<<12)&4294967295,u=(u^3345072700^u>>>19)&4294967295,u=u+374761393+(u<<5)&4294967295,u=(u+3550635116^u<<9)&4294967295,u=u+4251993797+(u<<3)&4294967295,u=(u^3042594569^u>>>16)&4294967295,this.seed=u,(u&268435455)/268435456}function o(u){return Math.floor(this.nextDouble()*u)}function a(u,l){var c=l||i();if(typeof c.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:h,shuffle:d};function d(){var f,p,g;for(f=u.length-1;f>0;--f)p=c.next(f+1),g=u[p],u[p]=u[f],u[f]=g;return u}function h(f){var p,g,m;for(p=u.length-1;p>0;--p)g=c.next(p+1),m=u[g],u[g]=u[p],u[p]=m,f(m);u.length&&f(u[0])}}return Jn.exports}var hu,Yd;function Qd(){if(Yd)return hu;Yd=1,hu=a;var i=$_(),e=z_(),t=W_(),r=j_(),s=H_(),n=q_(),o={};function a(c){var d=X_(),h=K_(),f=tg();if(c){if(c.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(c.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}c=h(c,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var p=o[c.dimensions];if(!p){var g=c.dimensions;p={Body:i(g,c.debug),createQuadTree:e(g),createBounds:t(g),createDragForce:r(g),createSpringForce:s(g),integrate:n(g)},o[g]=p}var m=p.Body,y=p.createQuadTree,x=p.createBounds,_=p.createDragForce,N=p.createSpringForce,A=p.integrate,v=B=>new m(B),S=Y_().random(42),P=[],F=[],U=y(c,S),W=x(P,c,S),se=N(c,S),ie=_(c),he=0,X=[],ue=new Map,D=0;le("nbody",ne),le("spring",Ae);var I={bodies:P,quadTree:U,springs:F,settings:c,addForce:le,removeForce:G,getForces:j,step:function(){for(var B=0;B=0?_e:-1);return F.push(ke),ke},getTotalMovement:function(){return he},removeSpring:function(B){if(B){var L=F.indexOf(B);if(L>-1)return F.splice(L,1),!0}},getBestNewBodyPosition:function(B){return W.getBestNewPosition(B)},getBBox:Y,getBoundingBox:Y,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(B){return B!==void 0?(c.gravity=B,U.options({gravity:B}),this):c.gravity},theta:function(B){return B!==void 0?(c.theta=B,U.options({theta:B}),this):c.theta},random:S};return u(c,I),f(I),I;function Y(){return W.update(),W.box}function le(B,L){if(ue.has(B))throw new Error("Force "+B+" is already added");ue.set(B,L),X.push(L)}function G(B){var L=X.indexOf(ue.get(B));L<0||(X.splice(L,1),ue.delete(B))}function j(){return ue}function ne(){if(P.length!==0){U.insertBodies(P);for(var B=P.length;B--;){var L=P[B];L.isPinned||(L.reset(),U.updateBodyForce(L),ie.update(L))}}}function Ae(){for(var B=F.length;B--;)se.update(F[B])}}function u(c,d){for(var h in c)l(c,d,h)}function l(c,d,h){if(c.hasOwnProperty(h)&&typeof d[h]!="function"){var f=Number.isFinite(c[h]);f?d[h]=function(p){if(p!==void 0){if(!Number.isFinite(p))throw new Error("Value of "+h+" should be a valid number.");return c[h]=p,d}return c[h]}:d[h]=function(p){return p!==void 0?(c[h]=p,d):c[h]}}}return hu}var Zd;function Q_(){if(Zd)return ao.exports;Zd=1,ao.exports=e,ao.exports.simulator=Qd();var i=tg();function e(r,s){if(!r)throw new Error("Graph structure cannot be undefined");var n=s&&s.createSimulator||Qd(),o=n(s);if(Array.isArray(s))throw new Error("Physics settings is expected to be an object");var a=r.version>19?ue:X;s&&typeof s.nodeMass=="function"&&(a=s.nodeMass);var u=new Map,l={},c=0,d=o.settings.springTransform||t;v(),_();var h=!1,f={step:function(){if(c===0)return p(!0),!0;var D=o.step();f.lastMove=D,f.fire("step");var I=D/c,Y=I<=.01;return p(Y),Y},getNodePosition:function(D){return he(D).pos},setNodePosition:function(D){var I=he(D);I.setPosition.apply(I,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(D){var I=l[D];if(I)return{from:I.from.pos,to:I.to.pos}},getGraphRect:function(){return o.getBBox()},forEachBody:g,pinNode:function(D,I){var Y=he(D.id);Y.isPinned=!!I},isNodePinned:function(D){return he(D.id).isPinned},dispose:function(){r.off("changed",A),f.fire("disposed")},getBody:x,getSpring:y,getForceVectorLength:m,simulator:o,graph:r,lastMove:0};return i(f),f;function p(D){h!==D&&(h=D,N(D))}function g(D){u.forEach(D)}function m(){var D=0,I=0;return g(function(Y){D+=Math.abs(Y.force.x),I+=Math.abs(Y.force.y)}),Math.sqrt(D*D+I*I)}function y(D,I){var Y;if(I===void 0)typeof D!="object"?Y=D:Y=D.id;else{var le=r.hasLink(D,I);if(!le)return;Y=le.id}return l[Y]}function x(D){return u.get(D)}function _(){r.on("changed",A)}function N(D){f.fire("stable",D)}function A(D){for(var I=0;Ii.length)&&(e=i.length);for(var t=0,r=Array(e);ti.length)&&(e=i.length);for(var t=0,r=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},n=s.dataBindAttr,o=n===void 0?"__data":n,a=s.objBindAttr,u=a===void 0?"__threeObj":a;return og(this,e),r=ig(this,e),za(r,"scene",void 0),Jd(r,bu,void 0),Jd(r,po,void 0),r.scene=t,eh(bu,r,o),eh(po,r,u),r.onRemoveObj(function(){}),r}return lg(e,i),ug(e,[{key:"onCreateObj",value:function(r){var s=this;return yu(e,"onCreateObj",this)([function(n){var o=r(n);return n[mu(po,s)]=o,o[mu(bu,s)]=n,s.scene.add(o),o}]),this}},{key:"onRemoveObj",value:function(r){var s=this;return yu(e,"onRemoveObj",this)([function(n,o){var a=yu(e,"getData",s)([n]);r(n,o),s.scene.remove(n),$c(n),delete a[mu(po,s)]}]),this}}])})(px),ri=function(e){return isNaN(e)?parseInt(Xp(e).toHex(),16):e},_u=function(e){return isNaN(e)?Xp(e).getAlpha():1},Ax=x_(T_);function sh(i,e,t){!e||typeof t!="string"||i.filter(function(r){return!r[t]}).forEach(function(r){r[t]=Ax(e(r))})}function Cx(i,e){var t=i.nodes,r=i.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=s.nodeFilter,o=n===void 0?function(){return!0}:n,a=s.onLoopError,u=a===void 0?function(f){throw"Invalid DAG structure! Found cycle in node path: ".concat(f.join(" -> "),".")}:a,l={};t.forEach(function(f){return l[e(f)]={data:f,out:[],depth:-1,skip:!o(f)}}),r.forEach(function(f){var p=f.source,g=f.target,m=N(p),y=N(g);if(!l.hasOwnProperty(m))throw"Missing source node with id: ".concat(m);if(!l.hasOwnProperty(y))throw"Missing target node with id: ".concat(y);var x=l[m],_=l[y];x.out.push(_);function N(A){return Kl(A)==="object"?e(A):A}});var c=[];h(Object.values(l));var d=Object.assign.apply(Object,[{}].concat(Zt(Object.entries(l).filter(function(f){var p=wi(f,2),g=p[1];return!g.skip}).map(function(f){var p=wi(f,2),g=p[0],m=p[1];return za({},g,m.depth)}))));return d;function h(f){for(var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,m=function(){var N=f[y];if(p.indexOf(N)!==-1){var A=[].concat(Zt(p.slice(p.indexOf(N))),[N]).map(function(v){return e(v.data)});return c.some(function(v){return v.length===A.length&&v.every(function(S,P){return S===A[P]})})||(c.push(A),u(A)),1}g>N.depth&&(N.depth=g,h(N.out,[].concat(Zt(p),[N]),g+(N.skip?0:1)))},y=0,x=f.length;y2?-60:-30),e<3&&s(t.graphData.nodes,"z"),e<2&&s(t.graphData.nodes,"y");function s(n,o){n.forEach(function(a){delete a[o],delete a["v".concat(o)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(r){return r.fx=r.fy=r.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,r){return r===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,r),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&r(),s(),n(),this;function r(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()0){var v=g.x-p.x,S=g.y-p.y||0,P=new te.Vector3().subVectors(x,y),F=P.clone().multiplyScalar(m).cross(v!==0||S!==0?new te.Vector3(0,0,1):new te.Vector3(0,1,0)).applyAxisAngle(P.normalize(),A).add(new te.Vector3().addVectors(y,x).divideScalar(2));N=new te.QuadraticBezierCurve3(y,F,x)}else{var U=m*70,W=-A,se=W+Math.PI/2;N=new te.CubicBezierCurve3(y,new te.Vector3(U*Math.cos(se),U*Math.sin(se),0).add(y),new te.Vector3(U*Math.cos(W),U*Math.sin(W),0).add(y),x)}h.__curve=N}}}}function s(){var o=pe(e.linkDirectionalArrowRelPos),a=pe(e.linkDirectionalArrowLength),u=pe(e.nodeVal);e.arrowDataMapper.entries().forEach(function(l){var c=wi(l,2),d=c[0],h=c[1];if(h){var f=t?d:e.layout.getLinkPosition(e.layout.graph.getLink(d.source,d.target).id),p=f[t?"source":"from"],g=f[t?"target":"to"];if(!(!p||!g||!p.hasOwnProperty("x")||!g.hasOwnProperty("x"))){var m=Math.cbrt(Math.max(0,u(p)||1))*e.nodeRelSize,y=Math.cbrt(Math.max(0,u(g)||1))*e.nodeRelSize,x=a(d),_=o(d),N=d.__curve?function(U){return d.__curve.getPoint(U)}:function(U){var W=function(ie,he,X,ue){return he[ie]+(X[ie]-he[ie])*ue||0};return{x:W("x",p,g,U),y:W("y",p,g,U),z:W("z",p,g,U)}},A=d.__curve?d.__curve.getLength():Math.sqrt(["x","y","z"].map(function(U){return Math.pow((g[U]||0)-(p[U]||0),2)}).reduce(function(U,W){return U+W},0)),v=m+x+(A-m-y-x)*_,S=N(v/A),P=N((v-x)/A);["x","y","z"].forEach(function(U){return h.position[U]=P[U]});var F=ag(te.Vector3,Zt(["x","y","z"].map(function(U){return S[U]})));h.parent.localToWorld(F),h.lookAt(F)}}})}function n(){var o=pe(e.linkDirectionalParticleSpeed),a=pe(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(u){var l=e.particlesDataMapper.getObj(u),c=l&&l.children,d=u.__singleHopPhotonsObj&&u.__singleHopPhotonsObj.children;if(!((!d||!d.length)&&(!c||!c.length))){var h=t?u:e.layout.getLinkPosition(e.layout.graph.getLink(u.source,u.target).id),f=h[t?"source":"from"],p=h[t?"target":"to"];if(!(!f||!p||!f.hasOwnProperty("x")||!p.hasOwnProperty("x"))){var g=o(u),m=Math.abs(a(u)),y=u.__curve?function(_){return u.__curve.getPoint(_)}:function(_){var N=function(v,S,P,F){return S[v]+(P[v]-S[v])*F||0};return{x:N("x",f,p,_),y:N("y",f,p,_),z:N("z",f,p,_)}},x=[].concat(Zt(c||[]),Zt(d||[]));x.forEach(function(_,N){var A=_.parent.__linkThreeObjType==="singleHopPhotons";if(_.hasOwnProperty("__progressRatio")||(_.__progressRatio=A?g<0?1:0:(N+m)/c.length),_.__progressRatio+=g,_.__progressRatio>=1||_.__progressRatio<0)if(!A)_.__progressRatio=_.__progressRatio%1,_.__progressRatio<0&&_.__progressRatio++;else{_.parent.remove(_),rh(_);return}var v=_.__progressRatio,S=y(v);_.geometry.type!=="SphereGeometry"&&_.lookAt(S.x,S.y,S.z),["x","y","z"].forEach(function(P){return _.position[P]=S[P]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var r=new te.Group;r.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=r,e.graphScene.add(r)}var s=pe(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var n=pe(e.linkDirectionalParticleWidth),o=Math.ceil(n(t)*10)/10/2,a=e.linkDirectionalParticleResolution,u=new te.SphereGeometry(o,a,a),l=pe(e.linkColor),c=pe(e.linkDirectionalParticleColor),d=c(t)||l(t)||"#f0f0f0",h=new te.Color(ri(d)),f=e.linkOpacity*3,p=new te.MeshLambertMaterial({color:h,transparent:!0,opacity:f});s=new te.Mesh(u,p)}t.__singleHopPhotonsObj.add(s)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var r=(function s(n){var o=[];if(n.geometry){n.geometry.computeBoundingBox();var a=new te.Box3;a.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld),o.push(a)}return o.concat.apply(o,Zt((n.children||[]).filter(function(u){return!u.hasOwnProperty("__graphObjType")||u.__graphObjType==="node"&&t(u.__data)}).map(s)))})(e.graphScene);return r.length?Object.assign.apply(Object,Zt(["x","y","z"].map(function(s){return za({},s,[v_(r,function(n){return n.min[s]}),S_(r,function(n){return n.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:E_().force("link",A_()).force("charge",C_()).force("center",M_()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new ti(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new ti(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new ti(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new ti(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var r=function(L){return L.some(function(Q){return t.hasOwnProperty(Q)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&r(["nodeAutoColorBy","graphData","nodeColor"])&&sh(e.graphData.nodes,pe(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&r(["linkAutoColorBy","graphData","linkColor"])&&sh(e.graphData.links,pe(e.linkAutoColorBy),e.linkColor),e._flushObjects||r(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=pe(e.nodeThreeObject),n=pe(e.nodeThreeObjectExtend),o=pe(e.nodeVal),a=pe(e.nodeColor),u=pe(e.nodeVisibility),l={},c={};(e._flushObjects||r(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(B){var L=s(B),Q=n(B);L&&e.nodeThreeObject===L&&(L=L.clone());var _e;return L&&!Q?_e=L:(_e=new te.Mesh,_e.__graphDefaultObj=!0,L&&Q&&_e.add(L)),_e.__graphObjType="node",_e}).onUpdateObj(function(B,L){if(B.__graphDefaultObj){var Q=o(L)||1,_e=Math.cbrt(Q)*e.nodeRelSize,ke=e.nodeResolution;(!B.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||B.geometry.parameters.radius!==_e||B.geometry.parameters.widthSegments!==ke)&&(l.hasOwnProperty(Q)||(l[Q]=new te.SphereGeometry(_e,ke,ke)),B.geometry.dispose(),B.geometry=l[Q]);var Ve=a(L),$e=new te.Color(ri(Ve||"#ffffaa")),ir=e.nodeOpacity*_u(Ve);(B.material.type!=="MeshLambertMaterial"||!B.material.color.equals($e)||B.material.opacity!==ir)&&(c.hasOwnProperty(Ve)||(c[Ve]=new te.MeshLambertMaterial({color:$e,transparent:!0,opacity:ir})),B.material.dispose(),B.material=c[Ve])}}).digest(e.graphData.nodes.filter(u))}if(e._flushObjects||r(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var d=pe(e.linkThreeObject),h=pe(e.linkThreeObjectExtend),f=pe(e.linkMaterial),p=pe(e.linkVisibility),g=pe(e.linkColor),m=pe(e.linkWidth),y={},x={},_={},N=e.graphData.links.filter(p);if((e._flushObjects||r(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(B){var L=B.__data&&B.__data.__singleHopPhotonsObj;L&&(L.parent.remove(L),rh(L),delete B.__data.__singleHopPhotonsObj)}).onCreateObj(function(B){var L=d(B),Q=h(B);L&&e.linkThreeObject===L&&(L=L.clone());var _e;if(!L||Q){var ke=!!m(B);if(ke)_e=new te.Mesh;else{var Ve=new te.BufferGeometry;Ve[xu]("position",new te.BufferAttribute(new Float32Array(6),3)),_e=new te.Line(Ve)}}var $e;return L?Q?($e=new te.Group,$e.__graphDefaultObj=!0,$e.add(_e),$e.add(L)):$e=L:($e=_e,$e.__graphDefaultObj=!0),$e.renderOrder=10,$e.__graphObjType="link",$e}).onUpdateObj(function(B,L){if(B.__graphDefaultObj){var Q=B.children.length?B.children[0]:B,_e=Math.ceil(m(L)*10)/10,ke=!!_e;if(ke){var Ve=_e/2,$e=e.linkResolution;if(!Q.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Q.geometry.parameters.radiusTop!==Ve||Q.geometry.parameters.radialSegments!==$e){if(!y.hasOwnProperty(_e)){var ir=new te.CylinderGeometry(Ve,Ve,1,$e,1,!1);ir[go](new te.Matrix4().makeTranslation(0,1/2,0)),ir[go](new te.Matrix4().makeRotationX(Math.PI/2)),y[_e]=ir}Q.geometry.dispose(),Q.geometry=y[_e]}}var xs=f(L);if(xs)Q.material=xs;else{var qr=g(L),Qn=new te.Color(ri(qr||"#f0f0f0")),Qs=e.linkOpacity*_u(qr),Xr=ke?"MeshLambertMaterial":"LineBasicMaterial";if(Q.material.type!==Xr||!Q.material.color.equals(Qn)||Q.material.opacity!==Qs){var Zn=ke?x:_;Zn.hasOwnProperty(qr)||(Zn[qr]=new te[Xr]({color:Qn,transparent:Qs<1,opacity:Qs,depthWrite:Qs>=1})),Q.material.dispose(),Q.material=Zn[qr]}}}}).digest(N),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var A=pe(e.linkDirectionalArrowLength),v=pe(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var B=new te.Mesh(void 0,new te.MeshLambertMaterial({transparent:!0}));return B.__linkThreeObjType="arrow",B}).onUpdateObj(function(B,L){var Q=A(L),_e=e.linkDirectionalArrowResolution;if(!B.geometry.type.match(/^Cone(Buffer)?Geometry$/)||B.geometry.parameters.height!==Q||B.geometry.parameters.radialSegments!==_e){var ke=new te.ConeGeometry(Q*.25,Q,_e);ke.translate(0,Q/2,0),ke.rotateX(Math.PI/2),B.geometry.dispose(),B.geometry=ke}var Ve=v(L)||g(L)||"#f0f0f0";B.material.color=new te.Color(ri(Ve)),B.material.opacity=e.linkOpacity*3*_u(Ve)}).digest(N.filter(A))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var S=pe(e.linkDirectionalParticles),P=pe(e.linkDirectionalParticleWidth),F=pe(e.linkDirectionalParticleColor),U=pe(e.linkDirectionalParticleThreeObject),W={},se={};e.particlesDataMapper.onCreateObj(function(){var B=new te.Group;return B.__linkThreeObjType="photons",B.__photonDataMapper=new ti(B),B}).onUpdateObj(function(B,L){var Q=!!B.children.length&&B.children[0],_e=U(L),ke,Ve;if(_e)ke=_e.geometry,Ve=_e.material;else{var $e=Math.ceil(P(L)*10)/10/2,ir=e.linkDirectionalParticleResolution;Q&&Q.geometry.parameters.radius===$e&&Q.geometry.parameters.widthSegments===ir?ke=Q.geometry:(se.hasOwnProperty($e)||(se[$e]=new te.SphereGeometry($e,ir,ir)),ke=se[$e]);var xs=F(L)||g(L)||"#f0f0f0",qr=new te.Color(ri(xs)),Qn=e.linkOpacity*3;Q&&Q.material.color.equals(qr)&&Q.material.opacity===Qn?Ve=Q.material:(W.hasOwnProperty(xs)||(W[xs]=new te.MeshLambertMaterial({color:qr,transparent:!0,opacity:Qn})),Ve=W[xs])}Q&&(Q.geometry!==ke&&Q.geometry.dispose(),Q.material!==Ve&&Q.material.dispose());var Qs=Math.round(Math.abs(S(L)));B.__photonDataMapper.id(function(Xr){return Xr.idx}).onCreateObj(function(){return new te.Mesh(ke,Ve)}).onUpdateObj(function(Xr){Xr.geometry=ke,Xr.material=Ve}).digest(Zt(new Array(Qs)).map(function(Xr,Zn){return{idx:Zn}}))}).digest(N.filter(S))}}if(e._flushObjects=!1,r(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(B){B.source=B[e.linkSource],B.target=B[e.linkTarget]});var ie=e.forceEngine!=="ngraph",he;if(ie){(he=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var X=e.d3ForceLayout.force("link");X&&X.id(function(B){return B[e.nodeId]}).links(e.graphData.links);var ue=e.dagMode&&Cx(e.graphData,function(B){return B[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),D=Math.max.apply(Math,Zt(Object.values(ue||[]))),I=e.dagLevelDistance||e.graphData.nodes.length/(D||1)*Mx*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var Y=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(B){return delete B[Y]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var le=["rl","td","zout"].includes(e.dagMode),G=function(L){return(ue[L[e.nodeId]]-D/2)*I*(le?-1:1)},j=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(B){return B[j]=G(B)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?R_(function(B){var L=ue[B[e.nodeId]]||-1;return(e.dagMode==="radialin"?D-L:L)*I}).strength(function(B){return e.dagNodeFilter(B)?1:0}):null)}else{var ne=nh.graph();e.graphData.nodes.forEach(function(B){ne.addNode(B[e.nodeId])}),e.graphData.links.forEach(function(B){ne.addLink(B.source,B.target)}),he=nh.forcelayout(ne,Nx({dimensions:e.numDimensions},e.ngraphPhysics)),he.graph=ne}for(var Ae=0;Ae0&&e.d3ForceLayout.alpha()1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=(function(s){function n(){var o;og(this,n);for(var a=arguments.length,u=new Array(a),l=0;l0){const{width:a,height:u}=e.context;t.bufferWidth=a,t.bufferHeight=u}const{environmentIntensity:n,environmentRotation:o}=e.scene;t.environmentIntensity=n,t.environmentRotation=o.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.version:s.version}}return t}containsNode(e){const t=e.material;for(const r in t)if(t[r]&&t[r].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=ah.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},ah.set(e,t)),t}getMaterialData(e){let t=oh.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(const r of this.refreshUniforms){const s=e[r];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[r]={id:s.id,version:0}:t[r]=s.clone():t[r]=s)}oh.set(e,t)}return t}equals(e,t,r){const{object:s,material:n,geometry:o}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(s.matrixWorld)!==!0)return a.worldMatrix.copy(s.matrixWorld),!1;const u=this.getMaterialData(e.material);if(u._renderId!==r){u._renderId=r;for(const d in u){const h=u[d],f=n[d];if(d!=="_renderId"&&d!=="_equal"){if(h.equals!==void 0){if(h.equals(f)===!1)return h.copy(f),u._equal=!1,!1}else if(f.isTexture===!0){if(h.id!==f.id||h.version!==f.version)return h.id=f.id,h.version=f.version,u._equal=!1,!1}else if(h!==f)return u[d]=f,u._equal=!1,!1}}if(u.transmission>0){const{width:d,height:h}=e.context;if(a.bufferWidth!==d||a.bufferHeight!==h)return a.bufferWidth=d,a.bufferHeight=h,u._equal=!1,!1}u._equal=!0}else if(u._equal===!1)return!1;if(a.geometryId!==o.id)return a.geometryId=o.id,!1;const l=this.getGeometryData(e.geometry);if(l._renderId!==r){l._renderId=r;const d=o.attributes,h=l.attributes;let f=0,p=0;for(const N in d)f++;for(const N in h){p++;const A=h[N],v=d[N];if(v===void 0)return delete h[N],l._equal=!1,!1;const S=v.isInterleavedBufferAttribute?v.data.uuid:v.id,P=v.isInterleavedBufferAttribute?v.data.version:v.version;if(A.id!==S||A.version!==P)return A.id=S,A.version=P,l._equal=!1,!1}if(p!==f)return l.attributes=this.getAttributesData(d),l._equal=!1,!1;const g=o.index,m=l.indexId,y=l.indexVersion,x=g?g.id:null,_=g?g.version:null;if(m!==x||y!==_)return l.indexId=x,l.indexVersion=_,l._equal=!1,!1;if(l.drawRange.start!==o.drawRange.start||l.drawRange.count!==o.drawRange.count)return l.drawRange.start=o.drawRange.start,l.drawRange.count=o.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let d=!1;for(let h=0;h{const r=t.match(e);if(!r)return null;const s=r[1]||r[2]||"",n=r[3].split("?")[0],o=parseInt(r[4],10),a=parseInt(r[5],10),u=n.split("/").pop();return{fn:s,file:u,line:o,column:a}}).filter(t=>t&&!Ux.some(r=>r.test(t.file)))}class bt{constructor(e=null){this.isStackTrace=!0,this.stack=Ox(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;const t=this.stack.map(r=>{const s=`${r.file}:${r.line}:${r.column}`;return r.fn?` at ${r.fn} (${s})`:` at ${s}`}).join(` +`);return`${e} +${t}`}}function zc(i,e=0){let t=3735928559^e,r=1103547991^e;if(Array.isArray(i))for(let s=0,n;s>>16,2246822507),t^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&r)+(t>>>0)}const Vn=i=>zc(i),Ji=i=>zc(i),Ri=(...i)=>zc(i),Ix=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),uh=new WeakMap;function pg(i){return Ix.get(i)}function Na(i){if(i==null)return null;const e=typeof i;return i.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":i.isVector2===!0?"vec2":i.isVector3===!0?"vec3":i.isVector4===!0?"vec4":i.isMatrix2===!0?"mat2":i.isMatrix3===!0?"mat3":i.isMatrix4===!0?"mat4":i.isColor===!0?"color":i instanceof ArrayBuffer?"ArrayBuffer":null}function Wc(i,...e){const t=i?i.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),i==="color"?new Kt(...e):t==="vec2"?new ce(...e):t==="vec3"?new V(...e):t==="vec4"?new He(...e):t==="mat2"?new jp(...e):t==="mat3"?new Qi(...e):t==="mat4"?new At(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?Gx(e[0]):null}function gg(i){let e=uh.get(i);return e===void 0&&(e={},uh.set(i,e)),e}function kx(i){let e="";const t=new Uint8Array(i);for(let r=0;re.charCodeAt(0)).buffer}const si={VERTEX:"vertex"},re={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},zt={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Vx=["fragment","vertex"],Tu=["setup","analyze","generate"],vu=[...Vx,"compute"],$n=["x","y","z","w"],$x={analyze:"setup",generate:"analyze"};let zx=0;class J extends Oa{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=re.NONE,this.updateBeforeType=re.NONE,this.updateAfterType=re.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=zx++,this.stackTrace=null,J.captureStackTrace===!0&&(this.stackTrace=new bt)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=xa.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,re.FRAME)}onRenderUpdate(e){return this.onUpdate(e,re.RENDER)}onObjectUpdate(e){return this.onUpdate(e,re.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const s=this[r];if(!(r.startsWith("_")===!0||e.has(s))){if(Array.isArray(s)===!0)for(let n=0;n0&&(e.inputNodes=r)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const n of e.inputNodes[r])s.push(t[n]);this[r]=s}else if(typeof e.inputNodes[r]=="object"){const s={};for(const n in e.inputNodes[r]){const o=e.inputNodes[r][n];s[n]=t[o]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function o(a){const u=[];for(const l in a){const c=a[l];delete c.metadata,u.push(c)}return u}if(s){const a=o(e.textures),u=o(e.images),l=o(e.nodes);a.length>0&&(n.textures=a),u.length>0&&(n.images=u),l.length>0&&(n.nodes=l)}return n}}J.captureStackTrace=!1;class zn extends J{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),r=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${r}[ ${s} ]`}}class mg extends J{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))(r===null||e.getTypeLength(t)===e.getTypeLength(s))&&(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),n=r.build(e,s);return e.format(n,s,t)}}class Xe extends J{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const s=e.getVectorType(this.getNodeType(e,t)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,s),a=e.getVarFromNode(this,null,s),u=e.getPropertyName(a);return e.addLineFlowCode(`${u} = ${o}`,this),n.snippet=o,n.propertyName=u,e.format(n.propertyName,s,t)}}return super.build(e,t)}}class Wx extends Xe{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),n=this.nodes,o=e.getComponentType(r),a=[];let u=0;for(const c of n){if(u>=s){O(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let d=c.getNodeType(e),h=e.getTypeLength(d),f;if(u+h>s&&(O(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),h=s-u,d=e.getTypeFromLength(h)),u+=h,f=c.build(e,d),e.getComponentType(d)!==o){const g=e.getTypeFromLength(h,o);f=e.format(f,d,g)}a.push(f)}const l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}const jx=$n.join("");class Hx extends J{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max($n.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let n=null;if(s>1){let o=null;this.getVectorLength()>=s&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=r.build(e,o);this.components.length===s&&this.components===jx.slice(0,this.components.length)?n=e.format(u,o,t):n=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else n=r.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qx extends Xe{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,n=this.getNodeType(e),o=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,o),u=s.build(e,a),l=t.build(e,n),c=e.getTypeLength(n),d=[];for(let h=0;hi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),ch=i=>Yx(i).split("").sort().join("");J.prototype.assign=function(...i){if(this.isStackNode!==!0)return ks!==null?ks.assign(this,...i):O("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new bt),this;{const e=Yl.get("assign");return this.addToStack(e(...i))}};J.prototype.toVarIntent=function(){return this};J.prototype.get=function(i){return new Kx(this,i)};const Ei={};function mo(i,e,t){Ei[i]=Ei[e]=Ei[t]={get(){this._cache=this._cache||{};let o=this._cache[i];return o===void 0&&(o=new Hx(this,i),this._cache[i]=o),o},set(o){this[i].assign(H(o))}};const r=i.toUpperCase(),s=e.toUpperCase(),n=t.toUpperCase();J.prototype["set"+r]=J.prototype["set"+s]=J.prototype["set"+n]=function(o){const a=ch(i);return new qx(this,a,H(o))},J.prototype["flip"+r]=J.prototype["flip"+s]=J.prototype["flip"+n]=function(){const o=ch(i);return new Xx(this,o)}}const or=["x","y","z","w"],ar=["r","g","b","a"],ur=["s","t","p","q"];for(let i=0;i<4;i++){let e=or[i],t=ar[i],r=ur[i];mo(e,t,r);for(let s=0;s<4;s++){e=or[i]+or[s],t=ar[i]+ar[s],r=ur[i]+ur[s],mo(e,t,r);for(let n=0;n<4;n++){e=or[i]+or[s]+or[n],t=ar[i]+ar[s]+ar[n],r=ur[i]+ur[s]+ur[n],mo(e,t,r);for(let o=0;o<4;o++)e=or[i]+or[s]+or[n]+or[o],t=ar[i]+ar[s]+ar[n]+ar[o],r=ur[i]+ur[s]+ur[n]+ur[o],mo(e,t,r)}}}for(let i=0;i<32;i++)Ei[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new zn(this,new wr(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(H(e))}};Object.defineProperties(J.prototype,Ei);const Qx=function(i,e=null){const t=Na(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?H(Ql(i,e)):t==="shader"?i.isFn?i:R(i):i},Zx=function(i,e=null){for(const t in i)i[t]=H(i[t],e);return i},Jx=function(i,e=null){const t=i.length;for(let r=0;ru?(O(`TSL: "${d}" parameter length exceeds limit.`,new bt),c.slice(0,u)):c}return e===null?n=(...c)=>s(new i(...wn(l(c)))):t!==null?(t=H(t),n=(...c)=>s(new i(e,...wn(l(c)),t))):n=(...c)=>s(new i(e,...wn(l(c)))),n.setParameterLength=(...c)=>(c.length===1?a=u=c[0]:c.length===2&&([a,u]=c),n),n.setName=c=>(o=c,n),n},eT=function(i,...e){return new i(...wn(e))};class tT extends J{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,s=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",o=n||"default";if(s[o])return s[o];const a=e.subBuildFn,u=e.fnCall;e.subBuildFn=n,e.fnCall=this;let l=null;if(t.layout){if(r){const h=t.layout.inputs;if(bg(r)){const f=r;for(let p=0;p{let x;return Symbol.iterator===m?x=function*(){yield void 0}:x=Reflect.get(g,m,y),x}}),d=r?sT(r):null,h=Array.isArray(r)?r.length>0:r!==null,f=t.jsFunc,p=h||f.length>1?f(d,c):f(c);l=H(p)}return e.subBuildFn=a,e.fnCall=u,t.once&&(s[o]=l),l}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),n=e.getNodeProperties(this),o=e.getSubBuildOutput(this),a=this.getOutputNode(e),u=e.fnCall;if(e.fnCall=this,s==="setup"){const l=e.getSubBuildProperty("initialized",this);if(n[l]!==!0&&(n[l]=!0,n[o]=this.getOutputNode(e),n[o].build(e),this.shaderNode.subBuilds))for(const c of e.chaining){const d=e.getDataFromNode(c,"any");d.subBuilds=d.subBuilds||new Set;for(const h of this.shaderNode.subBuilds)d.subBuilds.add(h)}r=n[o]}else s==="analyze"?a.build(e,t):s==="generate"&&(r=a.build(e,t)||"");return e.fnCall=u,r}}function bg(i){return i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)}function rT(i){let e;return Kc(i),bg(i)?e=[...i]:e=i[0],e}function sT(i){let e=0;return Kc(i),new Proxy(i,{get:(t,r,s)=>{let n;if(r==="length")return n=i.length,n;if(Symbol.iterator===r)n=function*(){for(const o of i)yield H(o)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const o=i[0];o[r]===void 0?n=o[e++]:n=Reflect.get(o,r,s)}else i[0]instanceof J&&(i[r]===void 0?n=i[e++]:n=Reflect.get(i,r,s));else n=Reflect.get(t,r,s);n=H(n)}return n}})}class nT extends J{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new tT(this,e)}setup(){return this.call()}}const iT=[!1,!0],oT=[0,1,2,3],aT=[-1,-2],_g=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Hc=new Map;for(const i of iT)Hc.set(i,new wr(i));const qc=new Map;for(const i of oT)qc.set(i,new wr(i,"uint"));const Xc=new Map([...qc].map(i=>new wr(i.value,"int")));for(const i of aT)Xc.set(i,new wr(i,"int"));const Wa=new Map([...Xc].map(i=>new wr(i.value)));for(const i of _g)Wa.set(i,new wr(i));for(const i of _g)Wa.set(-i,new wr(-i));const ja={bool:Hc,uint:qc,ints:Xc,float:Wa},dh=new Map([...Hc,...Wa]),Ql=(i,e)=>dh.has(i)?dh.get(i):i.isNode===!0?i:new wr(i,e),Ke=function(i,e=null){return(...t)=>{for(const s of t)if(s===void 0)return O(`TSL: Invalid parameter for the type "${i}".`,new bt),new wr(0,i);if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(s=>{const n=typeof s;return n!=="object"&&n!=="function"}))&&(t=[Wc(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return yo(e.get(t[0]));if(t.length===1){const s=Ql(t[0],i);return s.nodeType===i?yo(s):yo(new mg(s,i))}const r=t.map(s=>Ql(s));return yo(new Wx(r,i))}};function Zl(i){return i&&i.isNode&&i.traverse(e=>{e.isConstNode&&(i=e.value)}),!!i}const uT=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function xi(i,e){return new nT(i,e)}const H=(i,e=null)=>Qx(i,e),yo=(i,e=null)=>H(i,e).toVarIntent(),Kc=(i,e=null)=>new Zx(i,e),wn=(i,e=null)=>new Jx(i,e),Pe=(i,e=null,t=null,r=null)=>new yg(i,e,t,r),k=(i,...e)=>new eT(i,...e),$=(i,e=null,t=null,r={})=>new yg(i,e,t,{...r,intent:!0});let lT=0;class cT extends J{constructor(e,t=null){super();let r=null;t!==null&&(typeof t=="object"?r=t.return:(typeof t=="string"?r=t:O("TSL: Invalid layout type.",new bt),t=null)),this.shaderNode=new xi(e,r),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const r={name:"fn"+lT++,type:t,inputs:[]};for(const s in e)s!=="return"&&r.inputs.push({name:s,type:e[s]});e=r}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return O('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function R(i,e=null){const t=new cT(i,e);return new Proxy(()=>{},{apply(r,s,n){return t.call(...n)},get(r,s,n){return Reflect.get(t,s,n)},set(r,s,n,o){return Reflect.set(t,s,n,o)}})}const wa=i=>{ks=i},xg=()=>ks,me=(...i)=>ks.If(...i);function Tg(i){return ks&&ks.addToStack(i),i}E("toStack",Tg);const dT=new Ke("color"),w=new Ke("float",ja.float),Ue=new Ke("int",ja.ints),de=new Ke("uint",ja.uint),Ha=new Ke("bool",ja.bool),ee=new Ke("vec2"),Nt=new Ke("ivec2"),vg=new Ke("uvec2"),hT=new Ke("bvec2"),C=new Ke("vec3"),Sg=new Ke("ivec3"),Ng=new Ke("uvec3"),fT=new Ke("bvec3"),q=new Ke("vec4"),wg=new Ke("ivec4"),Rg=new Ke("uvec4"),pT=new Ke("bvec4"),Yc=new Ke("mat2"),rt=new Ke("mat3"),Us=new Ke("mat4");E("toColor",dT);E("toFloat",w);E("toInt",Ue);E("toUint",de);E("toBool",Ha);E("toVec2",ee);E("toIVec2",Nt);E("toUVec2",vg);E("toBVec2",hT);E("toVec3",C);E("toIVec3",Sg);E("toUVec3",Ng);E("toBVec3",fT);E("toVec4",q);E("toIVec4",wg);E("toUVec4",Rg);E("toBVec4",pT);E("toMat2",Yc);E("toMat3",rt);E("toMat4",Us);const gT=Pe(zn).setParameterLength(2),mT=(i,e)=>new mg(H(i),e);E("element",gT);E("convert",mT);E("append",i=>(z("TSL: .append() has been renamed to .toStack().",new bt),Tg(i)));class be extends J{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1,s=null){super(e),this.name=t,this.varying=r,this.placeholderNode=H(s),this.isPropertyNode=!0,this.global=!0}getNodeType(e){const t=super.getNodeType(e);return t==="output"?e.getOutputType():t}customCacheKey(){return Vn(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){const r=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${r}`,this)}return e.getPropertyName(t)}}const gs=(i,e,t=null)=>new be(i,e,!1,t),Wn=(i,e,t=null)=>new be(i,e,!0,t),Se=k(be,"vec4","DiffuseColor"),gn=k(be,"vec3","DiffuseContribution"),hh=k(be,"vec3","EmissiveColor"),Or=k(be,"float","Roughness"),os=k(be,"float","Metalness"),Jl=k(be,"float","Clearcoat"),Ai=k(be,"float","ClearcoatRoughness"),Gt=k(be,"vec3","Sheen"),As=k(be,"float","SheenRoughness"),Qc=k(be,"float","Iridescence"),ec=k(be,"float","IridescenceIOR"),tc=k(be,"float","IridescenceThickness"),rc=k(be,"float","AlphaT"),ws=k(be,"float","Anisotropy"),oa=k(be,"vec3","AnisotropyT"),Rn=k(be,"vec3","AnisotropyB"),Gs=k(be,"color","SpecularColor"),_n=k(be,"color","SpecularColorBlended"),xn=k(be,"float","SpecularF90"),sc=k(be,"float","Shininess"),Ci=k(be,"output","Output"),En=k(be,"float","dashSize"),Ra=k(be,"float","gapSize"),aa=k(be,"float","IOR"),nc=k(be,"float","Transmission"),Eg=k(be,"float","Thickness"),Ag=k(be,"float","AttenuationDistance"),Cg=k(be,"color","AttenuationColor"),Mg=k(be,"float","Dispersion"),fh=k(be,"float","AmbientOcclusion",!1,1);class Bg extends J{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const yT=(i,e=1,t=null)=>new Bg(i,!1,e,t),Zc=(i,e=0,t=null)=>new Bg(i,!0,e,t);re.FRAME;const Z=Zc("render",0,re.RENDER),bT=yT("object",1,re.OBJECT);class eo extends jc{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=bT}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.',new bt),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(r=>{const s=e(r,this);s!==void 0&&(this.value=s)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let n=e.getNodeFromHash(s);n===void 0&&(e.setHashNode(this,s),n=this);const o=n.getInputType(e),a=e.getUniformFromNode(n,o,e.shaderStage,this.name||e.context.nodeName),u=e.getPropertyName(a);e.context.nodeName!==void 0&&delete e.context.nodeName;let l=u;if(r==="bool"){const c=e.getDataFromNode(this);let d=c.propertyName;if(d===void 0){const h=e.getVarFromNode(this,null,"bool");d=e.getPropertyName(h),c.propertyName=d,l=e.format(u,o,r),e.addLineFlowCode(`${d} = ${l}`,this)}l=d}return e.format(l,r,t)}}const K=(i,e)=>{const t=uT(e||i);if(t===i&&(i=Wc(t)),i&&i.isNode===!0){let r=i.value;i.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),i=r}return new eo(i,t)};class ph extends Xe{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const _T=(...i)=>{let e;if(i.length===1){const t=i[0];e=new ph(null,t.length,t)}else{const t=i[0],r=i[1];e=new ph(t,r)}return H(e)};E("toArray",(i,e)=>_T(Array(e).fill(i)));class xT extends Xe{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return $n.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=t.getScope(),n=e.getDataFromNode(s);n.assign=!0;const o=e.getNodeProperties(this);o.sourceNode=r,o.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),o=r.build(e),a=r.getNodeType(e),u=s.build(e,a),l=s.getNodeType(e),c=e.getDataFromNode(this);let d;if(c.initialized===!0)t!=="void"&&(d=o);else if(n){const h=e.getVarFromNode(this,null,a),f=e.getPropertyName(h);e.addLineFlowCode(`${f} = ${u}`,this);const p=r.node,m=p.node.context({assign:!0}).build(e);for(let y=0;y{const c=l.type,d=c==="pointer";let h;return d?h="&"+u.build(e):h=u.build(e,c),h};if(Array.isArray(n)){if(n.length>s.length)O("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=s.length;else if(n.length(e=e.length>1||e[0]&&e[0].isNode===!0?wn(e):Kc(e[0]),new vT(H(i),e));E("call",ST);const NT={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ie extends Xe{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let n=new Ie(e,t,r);for(let o=0;o>"||r==="<<")return e.getIntegerType(o);if(r==="&&"||r==="||"||r==="^^")return"bool";if(r==="!"){const u=e.getTypeLength(o);return u>1?`bvec${u}`:"bool"}else if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){const u=Math.max(e.getTypeLength(o),e.getTypeLength(a));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(o)){if(a==="float")return o;if(e.isVector(a))return e.getVectorFromMatrix(o);if(e.isMatrix(a))return o}else if(e.isMatrix(a)){if(o==="float")return a;if(e.isVector(o))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(o)?a:o}}generate(e,t){const r=this.op,{aNode:s,bNode:n}=this,o=this.getNodeType(e,t);let a=null,u=null;o!=="void"?(a=s.getNodeType(e),u=n?n.getNodeType(e):null,r==="<"||r===">"||r==="<="||r===">="||r==="=="||r==="!="?e.isVector(a)?u=a:e.isVector(u)?a=u:a!==u&&(a=u="float"):r===">>"||r==="<<"?(a=o,u=e.changeComponentType(u,"uint")):r==="%"?(a=o,u=e.isInteger(a)&&e.isInteger(u)?u:a):e.isMatrix(a)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(a):e.isMatrix(u)||(a=u=o):e.isMatrix(u)?a==="float"?a="float":e.isVector(a)?a=e.getVectorFromMatrix(u):a=u=o:a=u=o):a=u=o;const l=s.build(e,a),c=n?n.build(e,u):null,d=e.getFunctionOperator(r);if(t!=="void"){const h=e.renderer.coordinateSystem===fa;if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">=")return h?e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${c} )`,o,t):e.format(`( ${l} ${r} ${c} )`,o,t):e.format(`( ${l} ${r} ${c} )`,o,t);if(r==="%")return e.isInteger(u)?e.format(`( ${l} % ${c} )`,o,t):e.format(`${this.getOperatorMethod(e,o)}( ${l}, ${c} )`,o,t);if(r==="!")return h&&e.isVector(a)?e.format(`not( ${l} )`,t):e.format(`( ${r} ${l} )`,a,t);if(r==="~")return e.format(`( ${r} ${l} )`,a,t);if(d)return e.format(`${d}( ${l}, ${c} )`,o,t);if(e.isMatrix(a)&&u==="float")return e.format(`( ${c} ${r} ${l} )`,o,t);if(a==="float"&&e.isMatrix(u))return e.format(`${l} ${r} ${c}`,o,t);{let f=`( ${l} ${r} ${c} )`;return!h&&o==="bool"&&e.isVector(a)&&e.isVector(u)&&(f=`all${f}`),e.format(f,o,t)}}else if(a!=="void")return d?e.format(`${d}( ${l}, ${c} )`,o,t):e.isMatrix(a)&&u==="float"?e.format(`${c} ${r} ${l}`,o,t):e.format(`${l} ${r} ${c}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Rt=$(Ie,"+").setParameterLength(2,1/0).setName("add"),xt=$(Ie,"-").setParameterLength(2,1/0).setName("sub"),ae=$(Ie,"*").setParameterLength(2,1/0).setName("mul"),vr=$(Ie,"/").setParameterLength(2,1/0).setName("div"),Pg=$(Ie,"%").setParameterLength(2).setName("mod"),wT=$(Ie,"==").setParameterLength(2).setName("equal"),RT=$(Ie,"!=").setParameterLength(2).setName("notEqual"),ET=$(Ie,"<").setParameterLength(2).setName("lessThan"),AT=$(Ie,">").setParameterLength(2).setName("greaterThan"),CT=$(Ie,"<=").setParameterLength(2).setName("lessThanEqual"),MT=$(Ie,">=").setParameterLength(2).setName("greaterThanEqual"),BT=$(Ie,"&&").setParameterLength(2,1/0).setName("and"),PT=$(Ie,"||").setParameterLength(2,1/0).setName("or"),DT=$(Ie,"!").setParameterLength(1).setName("not"),FT=$(Ie,"^^").setParameterLength(2).setName("xor"),LT=$(Ie,"&").setParameterLength(2).setName("bitAnd"),UT=$(Ie,"~").setParameterLength(1).setName("bitNot"),OT=$(Ie,"|").setParameterLength(2).setName("bitOr"),IT=$(Ie,"^").setParameterLength(2).setName("bitXor"),kT=$(Ie,"<<").setParameterLength(2).setName("shiftLeft"),GT=$(Ie,">>").setParameterLength(2).setName("shiftRight"),VT=R(([i])=>(i.addAssign(1),i)),$T=R(([i])=>(i.subAssign(1),i)),zT=R(([i])=>{const e=Ue(i).toConst();return i.addAssign(1),e}),WT=R(([i])=>{const e=Ue(i).toConst();return i.subAssign(1),e});E("add",Rt);E("sub",xt);E("mul",ae);E("div",vr);E("mod",Pg);E("equal",wT);E("notEqual",RT);E("lessThan",ET);E("greaterThan",AT);E("lessThanEqual",CT);E("greaterThanEqual",MT);E("and",BT);E("or",PT);E("not",DT);E("xor",FT);E("bitAnd",LT);E("bitNot",UT);E("bitOr",OT);E("bitXor",IT);E("shiftLeft",kT);E("shiftRight",GT);E("incrementBefore",VT);E("decrementBefore",$T);E("increment",zT);E("decrement",WT);class T extends Xe{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===T.MAX||e===T.MIN)&&arguments.length>3){let n=new T(e,t,r);for(let o=3;oo&&n>a?t:o>a?r:a>n?s:t}generateNodeType(e){const t=this.method;return t===T.LENGTH||t===T.DISTANCE||t===T.DOT?"float":t===T.CROSS?"vec3":t===T.ALL||t===T.ANY?"bool":t===T.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let n=null;if(s===T.ONE_MINUS)n=xt(1,t);else if(s===T.RECIPROCAL)n=vr(1,t);else if(s===T.DIFFERENCE)n=Ft(xt(t,r));else if(s===T.TRANSFORM_DIRECTION){let o,a;e.isMatrix(t.getNodeType(e))?(o=t,a=r):(o=r,a=t),n=Ht(ae(o,q(C(a),0)).xyz)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let s=this.method;const n=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,u=this.bNode,l=this.cNode,c=e.renderer.coordinateSystem;if(s===T.NEGATE)return e.format("( - "+a.build(e,o)+" )",n,t);{const d=[];return s===T.CROSS?d.push(a.build(e,n),u.build(e,n)):c===fa&&s===T.STEP?d.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":o),u.build(e,o)):c===fa&&(s===T.MIN||s===T.MAX)?d.push(a.build(e,o),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":o)):s===T.REFRACT?d.push(a.build(e,o),u.build(e,o),l.build(e,"float")):s===T.MIX?d.push(a.build(e,o),u.build(e,o),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":o)):(c===Ui&&s===T.ATAN&&u!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===T.DFDX||s===T.DFDY)&&(z(`TSL: '${s}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),s="/*"+s+"*/"),d.push(a.build(e,o)),u!==null&&d.push(u.build(e,o)),l!==null&&d.push(l.build(e,o))),e.format(`${e.getMethod(s,n)}( ${d.join(", ")} )`,n,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}T.ALL="all";T.ANY="any";T.RADIANS="radians";T.DEGREES="degrees";T.EXP="exp";T.EXP2="exp2";T.LOG="log";T.LOG2="log2";T.SQRT="sqrt";T.INVERSE_SQRT="inversesqrt";T.FLOOR="floor";T.CEIL="ceil";T.NORMALIZE="normalize";T.FRACT="fract";T.SIN="sin";T.SINH="sinh";T.COS="cos";T.COSH="cosh";T.TAN="tan";T.TANH="tanh";T.ASIN="asin";T.ASINH="asinh";T.ACOS="acos";T.ACOSH="acosh";T.ATAN="atan";T.ATANH="atanh";T.ABS="abs";T.SIGN="sign";T.LENGTH="length";T.NEGATE="negate";T.ONE_MINUS="oneMinus";T.DFDX="dFdx";T.DFDY="dFdy";T.ROUND="round";T.RECIPROCAL="reciprocal";T.TRUNC="trunc";T.FWIDTH="fwidth";T.TRANSPOSE="transpose";T.DETERMINANT="determinant";T.INVERSE="inverse";T.EQUALS="equals";T.MIN="min";T.MAX="max";T.STEP="step";T.REFLECT="reflect";T.DISTANCE="distance";T.DIFFERENCE="difference";T.DOT="dot";T.CROSS="cross";T.POW="pow";T.TRANSFORM_DIRECTION="transformDirection";T.MIX="mix";T.CLAMP="clamp";T.REFRACT="refract";T.SMOOTHSTEP="smoothstep";T.FACEFORWARD="faceforward";const Jc=w(1e-6),jT=w(Math.PI),HT=$(T,T.ALL).setParameterLength(1),qT=$(T,T.ANY).setParameterLength(1),XT=$(T,T.RADIANS).setParameterLength(1),KT=$(T,T.DEGREES).setParameterLength(1),Dg=$(T,T.EXP).setParameterLength(1),Ii=$(T,T.EXP2).setParameterLength(1),Fg=$(T,T.LOG).setParameterLength(1),jr=$(T,T.LOG2).setParameterLength(1),ds=$(T,T.SQRT).setParameterLength(1),YT=$(T,T.INVERSE_SQRT).setParameterLength(1),Os=$(T,T.FLOOR).setParameterLength(1),ed=$(T,T.CEIL).setParameterLength(1),Ht=$(T,T.NORMALIZE).setParameterLength(1),Sr=$(T,T.FRACT).setParameterLength(1),Dt=$(T,T.SIN).setParameterLength(1),QT=$(T,T.SINH).setParameterLength(1),pr=$(T,T.COS).setParameterLength(1),ZT=$(T,T.COSH).setParameterLength(1),JT=$(T,T.TAN).setParameterLength(1),ev=$(T,T.TANH).setParameterLength(1),tv=$(T,T.ASIN).setParameterLength(1),rv=$(T,T.ASINH).setParameterLength(1),Lg=$(T,T.ACOS).setParameterLength(1),sv=$(T,T.ACOSH).setParameterLength(1),nv=$(T,T.ATAN).setParameterLength(1,2),iv=$(T,T.ATANH).setParameterLength(1),Ft=$(T,T.ABS).setParameterLength(1),Ug=$(T,T.SIGN).setParameterLength(1),Hr=$(T,T.LENGTH).setParameterLength(1),Og=$(T,T.NEGATE).setParameterLength(1),ov=$(T,T.ONE_MINUS).setParameterLength(1),Ig=$(T,T.DFDX).setParameterLength(1),kg=$(T,T.DFDY).setParameterLength(1),av=$(T,T.ROUND).setParameterLength(1),uv=$(T,T.RECIPROCAL).setParameterLength(1),lv=$(T,T.TRUNC).setParameterLength(1),Gg=$(T,T.FWIDTH).setParameterLength(1),cv=$(T,T.TRANSPOSE).setParameterLength(1),dv=$(T,T.DETERMINANT).setParameterLength(1),hv=$(T,T.INVERSE).setParameterLength(1),Ln=$(T,T.MIN).setParameterLength(2,1/0),st=$(T,T.MAX).setParameterLength(2,1/0),ki=$(T,T.STEP).setParameterLength(2),fv=$(T,T.REFLECT).setParameterLength(2),pv=$(T,T.DISTANCE).setParameterLength(2),gv=$(T,T.DIFFERENCE).setParameterLength(2),Vs=$(T,T.DOT).setParameterLength(2),$s=$(T,T.CROSS).setParameterLength(2),qa=$(T,T.POW).setParameterLength(2),Vg=i=>ae(i,i),mv=i=>ae(i,i,i),$g=i=>ae(i,i,i,i),yv=$(T,T.TRANSFORM_DIRECTION).setParameterLength(2),bv=(i,e)=>Ht(ae(e,q(C(i),0)).xyz),_v=(i,e)=>Ht(q(C(i),0).mul(e).xyz),xv=i=>ae(Ug(i),qa(Ft(i),1/3)),zg=i=>Vs(i,i),xe=$(T,T.MIX).setParameterLength(3),hs=(i,e=0,t=1)=>new T(T.CLAMP,H(i),H(e),H(t)),td=i=>hs(i),Wg=$(T,T.REFRACT).setParameterLength(3),nr=$(T,T.SMOOTHSTEP).setParameterLength(3),Tv=$(T,T.FACEFORWARD).setParameterLength(3),vv=R(([i])=>{const r=43758.5453,s=Vs(i.xy,ee(12.9898,78.233)),n=Pg(s,jT);return Sr(Dt(n).mul(r))}),Sv=(i,e,t)=>xe(e,t,i),Nv=(i,e,t)=>nr(e,t,i),wv=(i,e)=>ki(e,i);E("all",HT);E("any",qT);E("radians",XT);E("degrees",KT);E("exp",Dg);E("exp2",Ii);E("log",Fg);E("log2",jr);E("sqrt",ds);E("inverseSqrt",YT);E("floor",Os);E("ceil",ed);E("normalize",Ht);E("fract",Sr);E("sin",Dt);E("sinh",QT);E("cos",pr);E("cosh",ZT);E("tan",JT);E("tanh",ev);E("asin",tv);E("asinh",rv);E("acos",Lg);E("acosh",sv);E("atan",nv);E("atanh",iv);E("abs",Ft);E("sign",Ug);E("length",Hr);E("lengthSq",zg);E("negate",Og);E("oneMinus",ov);E("dFdx",Ig);E("dFdy",kg);E("round",av);E("reciprocal",uv);E("trunc",lv);E("fwidth",Gg);E("min",Ln);E("max",st);E("step",wv);E("reflect",fv);E("distance",pv);E("dot",Vs);E("cross",$s);E("pow",qa);E("pow2",Vg);E("pow3",mv);E("pow4",$g);E("transformDirection",yv);E("transformNormalByViewMatrix",bv);E("transformNormalByInverseViewMatrix",_v);E("mix",Sv);E("clamp",hs);E("refract",Wg);E("smoothstep",Nv);E("faceForward",Tv);E("difference",gv);E("saturate",td);E("cbrt",xv);E("transpose",cv);E("determinant",dv);E("inverse",hv);E("rand",vv);class Rv extends J{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(r!==null){const n=r.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(s))return n}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,n=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=n,s!==null&&(e.getDataFromNode(s).parentNodeBlock=n);const o=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=o?r:r.context({nodeBlock:r}),a.elseNode=s?o?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:n,ifNode:o,elseNode:a}=e.getNodeProperties(this),u=e.currentFunctionNode,l=t!=="void",c=l?gs(r).build(e):"";s.nodeProperty=c;const d=n.build(e,"bool");if(e.context.uniformFlow&&a!==null){const p=o.build(e,r),g=a.build(e,r),m=e.getTernary(d,p,g);return e.format(m,r,t)}e.addFlowCode(` +${e.tab}if ( ${d} ) { + +`).addFlowTab();let f=o.build(e,r);if(f&&(l?f=c+" = "+f+";":(f="return "+f+";",u===null&&(z("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),f="// "+f))),e.removeFlowTab().addFlowCode(e.tab+" "+f+` + +`+e.tab+"}"),a!==null){e.addFlowCode(` else { + +`).addFlowTab();let p=a.build(e,r);p&&(l?p=c+" = "+p+";":(p="return "+p+";",u===null&&(z("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(c,r,t)}}const Ut=Pe(Rv).setParameterLength(2,3);E("select",Ut);class rd extends J{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Hs=(i=null,e={})=>{let t=i;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new rd(t,e)},Ev=i=>Hs(i,{uniformFlow:!0}),jg=(i,e)=>Hs(i,{nodeName:e});function Av(i,e,t=null){return Hs(t,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(i):s})}function Cv(i,e=null){return Hs(e,{getAO:(t,{material:r})=>r.transparent===!0?t:t!==null?t.mul(i):i})}function Mv(i,e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.'),jg(i,e)}E("context",Hs);E("label",Mv);E("uniformFlow",Ev);E("setName",jg);E("builtinShadowContext",(i,e,t)=>Av(e,t,i));E("builtinAOContext",(i,e)=>Cv(e,i));class ua extends J{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0],r=this.getShared(t);if(this!==r)return r.build(...e);if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let s=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const a=t.getDataFromNode(this);a.forceDeclaration=!0,s=!0}const n=t.getBaseStack();s?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:n}=e,o=n.backend.isWebGPUBackend===!0;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=o?s:a);const l=this.getNodeType(e);if(l=="void")return this.isIntent(e)!==!0&&O('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const c=e.getVectorType(l),d=t.build(e,c),h=e.getVarFromNode(this,r,c,void 0,u),f=e.getPropertyName(h);let p=f;if(u)if(o)p=a?`const ${f}`:`let ${f}`;else{const g=t.getArrayCount(e);p=`const ${e.getVar(h.type,f,g)}`}return e.addLineFlowCode(`${p} = ${d}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const sd=Pe(ua),Bv=(i,e=null)=>sd(i,e).toStack(),Pv=(i,e=null)=>sd(i,e,!0).toStack(),Dv=i=>sd(i).setIntent(!0).toStack();E("toVar",Bv);E("toConst",Pv);E("toVarIntent",Dv);class Fv extends J{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const An=(i,e,t=null)=>new Fv(H(i),e,t);class Lv extends J{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=An(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(r===void 0){const s=this.name,n=this.getNodeType(e),o=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,n,o,a),t.node=An(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation=e.shaderStage==="fragment"),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(r[t]===void 0){const n=this.getNodeType(e),o=e.getPropertyName(s,si.VERTEX);if(e.shaderStage===si.VERTEX){const a=r.node.build(e,n);e.addLineFlowCode(`${o} = ${a}`,this)}else e.flowNodeFromShaderStage(si.VERTEX,r.node,n,o);r[t]=o}return e.getPropertyName(s)}}const qs=Pe(Lv).setParameterLength(1,2),Uv=i=>qs(i);E("toVarying",qs);E("toVertexStage",Uv);const Ov=R(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),r=i.lessThanEqual(.04045);return xe(e,t,r)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Iv=R(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),r=i.lessThanEqual(.0031308);return xe(e,t,r)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),nd="WorkingColorSpace",kv="OutputColorSpace";class Hg extends Xe{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===nd?We.workingColorSpace:t===kv?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let n=t;return We.enabled===!1||r===s||!r||!s||(We.getTransfer(r)===oe&&(n=q(Ov(n.rgb),n.a)),We.getPrimaries(r)!==We.getPrimaries(s)&&(n=q(rt(We._getMatrix(new Qi,r,s)).mul(n.rgb),n.a)),We.getTransfer(s)===oe&&(n=q(Iv(n.rgb),n.a))),n}}const Gv=(i,e)=>new Hg(H(i),nd,e),id=(i,e)=>new Hg(H(i),e,nd);E("workingToColorSpace",Gv);E("colorSpaceToWorking",id);let Vv=class extends zn{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class qg extends J{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=re.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Vv(this,H(e))}setNodeType(e){const t=K(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;snew qg(i,e,t);class zv extends qg{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(Z)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const Wv=(i,e,t=null)=>new zv(i,e,t);class jv extends Xe{static get type(){return"ToneMappingNode"}constructor(e,t=qv,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ri(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===Ds)return t;let s=null;const n=e.renderer.library.getToneMappingFunction(r);return n!==null?s=q(n(t.rgb,this.exposureNode),t.a):(O("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const Hv=(i,e,t)=>new jv(i,H(e),H(t)),qv=Wv("toneMappingExposure","float");E("toneMapping",(i,e,t)=>Hv(e,t,i));const gh=new WeakMap;function mh(i,e){let t=gh.get(i);return t===void 0&&(t=new c_(i,e),gh.set(i,t)),t}class Kr extends jc{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=kc,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,n=this.bufferStride||r,o=this.bufferOffset;let a;s.isInterleavedBuffer===!0?a=s:s.isBufferAttribute===!0?a=mh(s.array,n):a=mh(s,n);const u=new l_(a,r,o);a.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;r!==void 0&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),n=e.getPropertyName(s);let o=null;if(e.shaderStage==="vertex"||e.shaderStage==="compute")this.name=n,o=n;else{let a;r&&(a=r+"Varying"),o=qs(this,a).build(e,t)}return o}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function od(i,e=null,t=0,r=0,s=kc,n=!1){return e==="mat3"||e===null&&i.itemSize===9?rt(new Kr(i,"vec3",9,0).setUsage(s).setInstanced(n),new Kr(i,"vec3",9,3).setUsage(s).setInstanced(n),new Kr(i,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&i.itemSize===16?Us(new Kr(i,"vec4",16,0).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,4).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,8).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,12).setUsage(s).setInstanced(n)):new Kr(i,e,t,r).setUsage(s)}const Xg=(i,e=null,t=0,r=0)=>od(i,e,t,r),Kg=(i,e=null,t=0,r=0)=>od(i,e,t,r,kc,!0),Yg=(i,e=null,t=0,r=0)=>od(i,e,t,r,Ia,!0);E("toAttribute",i=>Xg(i.value));class Le extends J{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s;if(r===Le.VERTEX)s=e.getVertexIndex();else if(r===Le.INSTANCE)s=e.getInstanceIndex();else if(r===Le.DRAW)s=e.getDrawIndex();else if(r===Le.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Le.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(r===Le.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+r);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=s:n=qs(this).build(e,t),n}}Le.VERTEX="vertex";Le.INSTANCE="instance";Le.SUBGROUP="subgroup";Le.INVOCATION_LOCAL="invocationLocal";Le.INVOCATION_SUBGROUP="invocationSubgroup";Le.DRAW="draw";const Xv=k(Le,Le.VERTEX),Un=k(Le,Le.INSTANCE);Le.SUBGROUP;Le.INVOCATION_SUBGROUP;Le.INVOCATION_LOCAL;const Kv=k(Le,Le.DRAW);class Yv extends J{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=re.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.',new bt),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=K(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){const r=e.getNodeProperties(this);r.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if(r==="compute"){const s=this.computeNode.build(e,"void");if(s!==""&&e.addLineFlowCode(s,this),this.count!==null&&e.allowEarlyReturns===!0){const n=this.countNode.build(e,"uint"),o=Un.build(e,"uint");e.flow.code=`${e.tab}if ( ${o} >= ${n} ) { return; } + +${e.flow.code}`}}else{const n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}}const Qg=(i,e=[64])=>{(e.length===0||e.length>3)&&O("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new bt);for(let t=0;t{const r=Qg(i,t);return typeof e=="number"?r.count=e:r.dispatchSize=e,r};E("compute",Qv);E("computeKernel",Qg);class Zv extends J{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const n=this.node.build(e,...t);return e.setCache(r),n}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Mi=i=>new Zv(H(i));function Jv(i,e=!0){return z('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Mi(i).setParent(e)}E("cache",Jv);E("isolate",Mi);class e0 extends J{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const t0=Pe(e0).setParameterLength(2);E("bypass",t0);const Zg=R(([i,e,t,r=w(0),s=w(1),n=Ha(!1)])=>{let o=i.sub(e).div(t.sub(e));return Zl(n)&&(o=o.clamp()),o.mul(s.sub(r)).add(r)});function r0(i,e,t,r=w(0),s=w(1)){return Zg(i,e,t,r,s,!0)}E("remap",Zg);E("remapClamp",r0);class la extends J{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if(r==="void")e.addLineFlowCode(s,this);else return e.format(s,r,t)}}const gr=Pe(la).setParameterLength(1,2),s0=i=>(i?Ut(i,gr("discard")):gr("discard")).toStack();E("discard",s0);const Jg=R(([i])=>q(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),n0=R(([i])=>i.a.equal(0).select(q(0),q(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"});class i0 extends Xe{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=q(t.rgb,t.a.clamp(0,1)),t=n0(t);const r=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||Ds,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Dn;return r!==Ds&&(t=t.toneMapping(r)),s!==Dn&&s!==We.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Jg(t),t}}const em=(i,e=null,t=null)=>new i0(H(i),e,t);E("renderOutput",em);class o0 extends Xe{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(t!==null)t(e,r);else{const s="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(s.length);let o="";o+="// #"+s+`# +`,o+=e.flow.code.replace(/^\t/mg,"")+` +`,o+="/* ... */ "+r+` /* ... */ +`,o+="// #"+n+`# +`,p_(o)}return r}}const a0=(i,e=null)=>new o0(H(i),e).toStack();E("debug",a0);class tm extends Oa{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class u0 extends J{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=re.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==tm&&Be('TSL: ".toInspector()" is only available with WebGPU.'),t}}function l0(i,e="",t=null){return i=H(i),i.before(new u0(i,e,t))}E("toInspector",l0);class rm extends J{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const n=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(n),a=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(a.name,o,r):qs(this).build(e,r)}else return z(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Wt=(i,e=null)=>new rm(i,e),Xs=(i=0)=>Wt("uv"+(i>0?i:""),"vec2");class c0 extends J{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const Gi=Pe(c0).setParameterLength(1,2);class d0 extends eo{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=re.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&r.width!==void 0){const{width:s,height:n}=r;this.value=Math.log2(Math.max(s,n))}}}const h0=Pe(d0).setParameterLength(1);class f0 extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const sm=new Ic;class to extends eo{static get type(){return"TextureNode"}constructor(e=sm,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=re.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?"float":"vec4":this.value.type===Ge?"uvec4":this.value.type===Ze?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Xs(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=K(this.value.matrix)),this._matrixUniform.mul(C(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=K(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(Ue(Gi(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||r.isTexture!==!0)throw new f0("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=R(()=>{let u=this.uvNode;return(u===null||e.context.forceUVContext===!0)&&e.context.getUV&&(u=e.context.getUV(this,e)),u||(u=this.getDefaultUV()),this.updateMatrix===!0&&(u=this.getTransformedUV(u)),u=this.setupUV(e,u),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?re.OBJECT:re.NONE,u})();let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this));let o=null,a=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(js.TEXTURE_COMPARE))o=this.compareNode;else{const u=r.compareFunction;u===null||u===Uc||u===Zi||u===ma||u===Pn?a=this.compareNode:(o=this.compareNode,Be('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=o,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,n,o,a,u,l,c,d){const h=this.value;let f;return n?f=e.generateTextureBias(h,t,r,n,o,c):u?f=e.generateTextureGrad(h,t,r,u,o,c):l?a?f=e.generateTextureGatherCompare(h,t,r,a,o,c,d):f=e.generateTextureGather(h,t,r,l,o,c,d):a?f=e.generateTextureCompare(h,t,r,a,o,c):this.sampler===!1?f=e.generateTextureLoad(h,t,r,s,o,c):s?f=e.generateTextureLevel(h,t,r,s,o,c):f=e.generateTexture(h,t,r,o,c),f}generate(e,t){const r=this.value,s=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const o=e.getDataFromNode(this);let a=this.getNodeType(e),u=o.propertyName;if(u===void 0){const{uvNode:c,levelNode:d,biasNode:h,compareNode:f,compareStepNode:p,depthNode:g,gradNode:m,gatherNode:y,offsetNode:x}=s,_=this.generateUV(e,c),N=d?d.build(e,"float"):null,A=h?h.build(e,"float"):null,v=g?g.build(e,"int"):null,S=f?f.build(e,"float"):null,P=p?p.build(e,"float"):null,F=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,U=y?y.build(e,"int"):null,W=x?this.generateOffset(e,x):null,se=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;U&&(a="vec4");let ie=v;ie===null&&r.isArrayTexture&&this.isTexture3DNode!==!0&&(ie="0");const he=e.getVarFromNode(this);u=e.getPropertyName(he);let X=this.generateSnippet(e,n,_,N,A,ie,S,F,U,W,se);if(P!==null){const ue=r.compareFunction;ue===ma||ue===Pn?X=ki(gr(X,a),gr(P,"float")).build(e,a):X=ki(gr(P,"float"),gr(X,a)).build(e,a)}e.addLineFlowCode(`${u} = ${X}`,this),o.snippet=X,o.propertyName=u}let l=u;return e.needsToWorkingColorSpace(r)&&(l=id(gr(l,a),r.colorSpace).setup(e).build(e,a)),e.format(l,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=H(e),t.referenceNode=this.getBase(),H(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=H(e).mul(h0(t)),t.referenceNode=this.getBase();const r=t.value;return t.generateMipmaps===!1&&(r&&r.generateMipmaps===!1||r.minFilter===Lt||r.magFilter===Lt)&&(z("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),H(t)}level(e){const t=this.clone();return t.levelNode=H(e),t.referenceNode=this.getBase(),H(t)}size(e){return Gi(this,e)}bias(e){const t=this.clone();return t.biasNode=H(e),t.referenceNode=this.getBase(),H(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=H(e),t.referenceNode=this.getBase(),H(t)}grad(e,t){const r=this.clone();return r.gradNode=[H(e),H(t)],r.referenceNode=this.getBase(),H(r)}gather(e=0){const t=this.clone();return t.gatherNode=H(e),t.referenceNode=this.getBase(),H(t)}depth(e){const t=this.clone();return t.depthNode=H(e),t.referenceNode=this.getBase(),H(t)}offset(e){const t=this.clone();return t.offsetNode=H(e),t.referenceNode=this.getBase(),H(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const r=this._flipYUniform;r!==null&&(r.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const p0=Pe(to).setParameterLength(1,4).setName("texture"),Ne=(i=sm,e=null,t=null,r=null)=>{let s;return i&&i.isTextureNode===!0?(s=H(i.clone()),s.referenceNode=i.getBase(),e!==null&&(s.uvNode=H(e)),t!==null&&(s.levelNode=H(t)),r!==null&&(s.biasNode=H(r))):s=p0(i,e,t,r),s},Jt=(...i)=>Ne(...i).setSampler(!1);class ad extends eo{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const ud=(i,e,t)=>new ad(i,e,t);class g0 extends zn{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class m0 extends ad{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Na(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=re.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if(r==="float"||r==="int"||r==="uint")for(let s=0;snew m0(i,e);class y0 extends J{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Ks=Pe(y0).setParameterLength(1);let ni,ii;class Re extends J{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===Re.DPR?"float":this.scope===Re.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=re.NONE;return(this.scope===Re.SIZE||this.scope===Re.VIEWPORT||this.scope===Re.DPR)&&(e=re.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Re.VIEWPORT?t!==null?ii.copy(t.viewport):(e.getViewport(ii),ii.multiplyScalar(e.getPixelRatio())):this.scope===Re.DPR?this._output.value=e.getPixelRatio():t!==null?(ni.width=t.width,ni.height=t.height):e.getDrawingBufferSize(ni)}setup(){const e=this.scope;let t=null;return e===Re.SIZE?t=K(ni||(ni=new ce)):e===Re.VIEWPORT?t=K(ii||(ii=new He)):e===Re.DPR?t=K(1):t=ee(jn.div(ic)),this._output=t,t}generate(e){if(this.scope===Re.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(ic).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}Re.COORDINATE="coordinate";Re.VIEWPORT="viewport";Re.SIZE="size";Re.UV="uv";Re.DPR="dpr";const nm=k(Re,Re.DPR),as=k(Re,Re.UV),ic=k(Re,Re.SIZE),jn=k(Re,Re.COORDINATE),Bi=k(Re,Re.VIEWPORT),b0=Bi.zw;Bi.xy;let Su=null,bo=null,Nu=null,_o=null,wu=null,xo=null,Ru=null,To=null,Eu=null,vo=null;const ro=K(0,"uint").setName("u_cameraIndex").setGroup(Zc("cameraIndex")).toVarying("v_cameraIndex"),Cs=K("float").setName("cameraNear").setGroup(Z).onRenderUpdate(({camera:i})=>i.near),Ms=K("float").setName("cameraFar").setGroup(Z).onRenderUpdate(({camera:i})=>i.far),rr=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrix);bo===null?bo=Tt(t).setGroup(Z).setName("cameraProjectionMatrices"):bo.array=t,e=bo.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Su===null&&(Su=K(i.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=Su;return e}).once()(),_0=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrixInverse);_o===null?_o=Tt(t).setGroup(Z).setName("cameraProjectionMatricesInverse"):_o.array=t,e=_o.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Nu===null&&(Nu=K(i.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Z).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=Nu;return e}).once()(),Hn=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorldInverse);xo===null?xo=Tt(t).setGroup(Z).setName("cameraViewMatrices"):xo.array=t,e=xo.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else wu===null&&(wu=K(i.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=wu;return e}).once()(),ld=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorld);To===null?To=Tt(t).setGroup(Z).setName("cameraWorldMatrices"):To.array=t,e=To.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Ru===null&&(Ru=K(i.matrixWorld).setName("cameraWorldMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.matrixWorld)),e=Ru;return e}).once()(),x0=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let r=0,s=i.cameras.length;r{const n=r.cameras,o=s.array;for(let a=0,u=n.length;ar.value.setFromMatrixPosition(t.matrixWorld))),e=Eu;return e}).once()(),yh=new a_;class Ce extends J{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=re.OBJECT,this.uniformNode=new eo(null)}generateNodeType(){const e=this.scope;if(e===Ce.WORLD_MATRIX)return"mat4";if(e===Ce.POSITION||e===Ce.VIEW_POSITION||e===Ce.DIRECTION||e===Ce.SCALE)return"vec3";if(e===Ce.RADIUS)return"float"}update(e){const t=this.object3d,r=this.uniformNode,s=this.scope;if(s===Ce.WORLD_MATRIX)r.value=t.matrixWorld;else if(s===Ce.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(t.matrixWorld);else if(s===Ce.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(t.matrixWorld);else if(s===Ce.DIRECTION)r.value=r.value||new V,t.getWorldDirection(r.value);else if(s===Ce.VIEW_POSITION){const n=e.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(n.matrixWorldInverse)}else if(s===Ce.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),yh.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),r.value=yh.radius}}generate(e){const t=this.scope;return t===Ce.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Ce.POSITION||t===Ce.VIEW_POSITION||t===Ce.DIRECTION||t===Ce.SCALE?this.uniformNode.nodeType="vec3":t===Ce.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ce.WORLD_MATRIX="worldMatrix";Ce.POSITION="position";Ce.SCALE="scale";Ce.VIEW_POSITION="viewPosition";Ce.DIRECTION="direction";Ce.RADIUS="radius";class Xt extends Ce{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}Xt.DIRECTION;const zs=k(Xt,Xt.WORLD_MATRIX);Xt.POSITION;Xt.SCALE;Xt.VIEW_POSITION;Xt.RADIUS;const T0=K(new Qi).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),Ws=R(i=>i.context.modelViewMatrix||v0).once()().toVar("modelViewMatrix"),v0=Hn.mul(zs),bh=R(i=>(i.context.isHighPrecisionModelViewMatrix=!0,K("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),_h=R(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return K("mat3").onObjectUpdate(({object:t,camera:r})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),S0=R(i=>i.shaderStage!=="fragment"?(Be("TSL: `clipSpace` is only available in fragment stage."),q()):i.context.clipSpace.toVarying("v_clipSpace")).once()(),mt=Wt("position","vec3"),Qe=mt.toVarying("positionLocal"),Ea=mt.toVarying("positionPrevious"),On=R(i=>zs.mul(Qe).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),im=R(()=>Qe.transformDirection(zs).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),je=R(i=>{if(i.shaderStage==="fragment"&&i.material.vertexNode){const e=_0.mul(S0);return e.xyz.div(e.w).toVar("positionView")}return i.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),Ee=R(i=>{let e;return i.camera.isOrthographicCamera?e=C(0,0,1):e=je.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class N0 extends J{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===ft?"false":e.getFrontFacing()}}const w0=k(N0),om=w(w0).mul(2).sub(1),so=R(([i],{material:e})=>{const t=e.side;return t===ft?i=i.mul(-1):t===Gr&&(i=i.mul(om)),i}),am=Wt("normal","vec3"),Nr=R(i=>i.geometry.hasAttribute("normal")===!1?(z('TSL: Vertex attribute "normal" not found on geometry.'),C(0,1,0)):am,"vec3").once()().toVar("normalLocal"),R0=je.dFdx().cross(je.dFdy()).normalize().toVar("normalFlat"),Vi=R(i=>{let e;return i.isFlatShading()?e=R0:e=lm(Nr).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),E0=R(i=>{let e=Vi.transformNormalByInverseViewMatrix(Hn);return i.isFlatShading()!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),ge=R(i=>{let e;return i.subBuildFn==="NORMAL"||i.subBuildFn==="VERTEX"?(e=Vi,i.isFlatShading()!==!0&&(e=so(e))):e=i.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),qn=ge.transformNormalByInverseViewMatrix(Hn).toVar("normalWorld"),Bs=R(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=ge:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),um=R(([i,e=zs])=>rt(e).inverse().transpose().mul(i).normalize());E("transformNormal",um);const lm=R(([i],e)=>{const t=e.context.modelNormalViewMatrix;return t?i.transformNormalByViewMatrix(t):T0.mul(i).transformNormalByViewMatrix(Hn)});R(()=>(z('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ge)).once(["NORMAL","VERTEX"])();R(()=>(z('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),qn)).once(["NORMAL","VERTEX"])();R(()=>(z('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Bs)).once(["NORMAL","VERTEX"])();const Au=new At,A0=K(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),Cu=K(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),oc=K(new At).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const r=(e.environment!==null||e.environmentNode&&e.environmentNode.isNode)&&i.envMap===null?e.environmentRotation:i.envMapRotation;return r?Au.makeRotationFromEuler(r).transpose():Au.identity(),Au}),C0=Ee.negate().reflect(ge),M0=Ee.negate().refract(ge,A0),B0=C0.transformDirection(ld).toVar("reflectVector"),P0=M0.transformDirection(ld).toVar("refractVector"),D0=new $a;class F0 extends to{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Ta?B0:e.mapping===va?P0:(O('CubeTextureNode: Mapping "%s" not supported.',e.mapping),C(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return r.isDepthTexture===!0?e.renderer.coordinateSystem===Ui?C(t.x,t.y.negate(),t.z):t:(t=oc.mul(t),(e.renderer.coordinateSystem===Ui||!r.isRenderTargetTexture)&&(t=C(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const L0=Pe(F0).setParameterLength(1,4).setName("cubeTexture"),vt=(i=D0,e=null,t=null,r=null)=>{let s;return i&&i.isCubeTextureNode===!0?(s=H(i.clone()),s.referenceNode=i,e!==null&&(s.uvNode=H(e)),t!==null&&(s.levelNode=H(t)),r!==null&&(s.biasNode=H(r))):s=L0(i,e,t,r),s};class U0 extends zn{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class cd extends J{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=re.OBJECT}element(e){return new U0(this,H(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=ud(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=Tt(null,e),t.updateType=re.OBJECT):e==="texture"?t=Ne(null):e==="cubeTexture"?t=vt(null):t=K(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;snew cd(i,e,t),O0=(i,e,t,r)=>new cd(i,e,r,t);class I0 extends cd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const ns=(i,e,t=null)=>new I0(i,e,t),cm=Xs(),k0=je.dFdx(),G0=je.dFdy(),dm=cm.dFdx(),hm=cm.dFdy(),fm=ge,pm=G0.cross(fm),gm=fm.cross(k0),ac=pm.mul(dm.x).add(gm.mul(hm.x)),uc=pm.mul(dm.y).add(gm.mul(hm.y)),xh=ac.dot(ac).max(uc.dot(uc)),mm=xh.equal(0).select(0,xh.inverseSqrt()),V0=ac.mul(mm).toVar("tangentViewFrame"),$0=uc.mul(mm).toVar("bitangentViewFrame"),ym=Wt("tangent","vec4"),Aa=ym.xyz.toVar("tangentLocal"),bm=R(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=Ws.mul(q(Aa,0)).xyz.toVarying("v_tangentView").normalize():e=V0,i.isFlatShading()!==!0&&(e=so(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),z0=R(([i,e],t)=>{let r=i.mul(ym.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),W0=R(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=z0(ge.cross(bm),"v_bitangentView").normalize():e=$0,i.isFlatShading()!==!0&&(e=so(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Ti=rt(bm,W0,ge).toVar("TBNViewMatrix"),j0=R(()=>{let i=Rn.cross(Ee);return i=i.cross(Rn).normalize(),i=xe(i,ge,ws.mul(Or.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()(),H0=i=>H(i).mul(.5).add(.5),Th=i=>C(i,ds(td(w(1).sub(Vs(i,i)))));class q0 extends Xe{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=nu,this.unpackNormalMode=iu}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let n=this.node.mul(2).sub(1);if(t===nu?s===Wp?n=Th(n.xy):s===d_?n=Th(n.yw):s!==iu&&O(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==iu&&O(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),r!==null){let a=r;e.isFlatShading()===!0&&(a=so(a)),n=C(n.xy.mul(a),n.z)}let o=null;return t===h_?o=lm(n):t===nu?o=Ti.mul(n).normalize():(O(`NodeMaterial: Unsupported normal map type: ${t}`),o=ge),o}}const vh=Pe(q0).setParameterLength(1,2),X0=R(({textureNode:i,bumpScale:e})=>{const t=s=>i.isolate().context({getUV:n=>s(n.uvNode||Xs()),forceUVContext:!0}),r=w(t(s=>s));return ee(w(t(s=>s.add(s.dFdx()))).sub(r),w(t(s=>s.add(s.dFdy()))).sub(r)).mul(e)}),K0=R(i=>{const{surf_pos:e,surf_norm:t,dHdxy:r}=i,s=e.dFdx().normalize(),n=e.dFdy().normalize(),o=t,a=n.cross(o),u=o.cross(s),l=s.dot(a).mul(om),c=l.sign().mul(r.x.mul(a).add(r.y.mul(u)));return l.abs().mul(t).sub(c).normalize()});class Y0 extends Xe{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return ge;const t=this.scaleNode!==null?this.scaleNode:1,r=X0({textureNode:this.textureNode,bumpScale:t});return K0({surf_pos:je,surf_norm:ge,dHdxy:r})}}const Q0=Pe(Y0).setParameterLength(1,2),Sh=new Map;class M extends J{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Sh.get(e);return r===void 0&&(r=ns(e,t),Sh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===M.COLOR){const n=t.color!==void 0?this.getColor(r):C();t.map&&t.map.isTexture===!0?s=n.mul(this.getTexture("map")):s=n}else if(r===M.OPACITY){const n=this.getFloat(r);t.alphaMap&&t.alphaMap.isTexture===!0?s=n.mul(this.getTexture("alpha")):s=n}else if(r===M.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=w(1);else if(r===M.SPECULAR_INTENSITY){const n=this.getFloat(r);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?s=n.mul(this.getTexture(r).a):s=n}else if(r===M.SPECULAR_COLOR){const n=this.getColor(r);t.specularColorMap&&t.specularColorMap.isTexture===!0?s=n.mul(this.getTexture(r).rgb):s=n}else if(r===M.ROUGHNESS){const n=this.getFloat(r);t.roughnessMap&&t.roughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).g):s=n}else if(r===M.METALNESS){const n=this.getFloat(r);t.metalnessMap&&t.metalnessMap.isTexture===!0?s=n.mul(this.getTexture(r).b):s=n}else if(r===M.EMISSIVE){const n=this.getFloat("emissiveIntensity"),o=this.getColor(r).mul(n);t.emissiveMap&&t.emissiveMap.isTexture===!0?s=o.mul(this.getTexture(r)):s=o}else if(r===M.NORMAL)t.normalMap?(s=vh(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,(t.normalMap.format==tr||t.normalMap.format==ba||t.normalMap.format==ya)&&(s.unpackNormalMode=Wp)):t.bumpMap?s=Q0(this.getTexture("bump").r,this.getFloat("bumpScale")):s=ge;else if(r===M.CLEARCOAT){const n=this.getFloat(r);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.CLEARCOAT_ROUGHNESS){const n=this.getFloat(r);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.CLEARCOAT_NORMAL)t.clearcoatNormalMap?s=vh(this.getTexture(r),this.getCache(r+"Scale","vec2")):s=ge;else if(r===M.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?s=n.mul(this.getTexture("sheenColor").rgb):s=n}else if(r===M.SHEEN_ROUGHNESS){const n=this.getFloat(r);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).a):s=n,s=s.clamp(1e-4,1)}else if(r===M.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const n=this.getTexture(r);s=Yc(oi.x,oi.y,oi.y.negate(),oi.x).mul(n.rg.mul(2).sub(ee(1)).normalize().mul(n.b))}else s=oi;else if(r===M.IRIDESCENCE_THICKNESS){const n=Me("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=Me("0","float",t.iridescenceThicknessRange);s=n.sub(o).mul(this.getTexture(r).g).add(o)}else s=n}else if(r===M.TRANSMISSION){const n=this.getFloat(r);t.transmissionMap?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.THICKNESS){const n=this.getFloat(r);t.thicknessMap?s=n.mul(this.getTexture(r).g):s=n}else if(r===M.IOR)s=this.getFloat(r);else if(r===M.LIGHT_MAP)t.lightMap?s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):s=C(0);else if(r===M.AO)t.aoMap?s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):s=w(1);else if(r===M.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):w(0);else{const n=this.getNodeType(e);s=this.getCache(r,n)}return s}}M.ALPHA_TEST="alphaTest";M.COLOR="color";M.OPACITY="opacity";M.SHININESS="shininess";M.SPECULAR="specular";M.SPECULAR_STRENGTH="specularStrength";M.SPECULAR_INTENSITY="specularIntensity";M.SPECULAR_COLOR="specularColor";M.REFLECTIVITY="reflectivity";M.ROUGHNESS="roughness";M.METALNESS="metalness";M.NORMAL="normal";M.CLEARCOAT="clearcoat";M.CLEARCOAT_ROUGHNESS="clearcoatRoughness";M.CLEARCOAT_NORMAL="clearcoatNormal";M.EMISSIVE="emissive";M.ROTATION="rotation";M.SHEEN="sheen";M.SHEEN_ROUGHNESS="sheenRoughness";M.ANISOTROPY="anisotropy";M.IRIDESCENCE="iridescence";M.IRIDESCENCE_IOR="iridescenceIOR";M.IRIDESCENCE_THICKNESS="iridescenceThickness";M.IOR="ior";M.TRANSMISSION="transmission";M.THICKNESS="thickness";M.ATTENUATION_DISTANCE="attenuationDistance";M.ATTENUATION_COLOR="attenuationColor";M.LINE_SCALE="scale";M.LINE_DASH_SIZE="dashSize";M.LINE_GAP_SIZE="gapSize";M.LINE_WIDTH="linewidth";M.LINE_DASH_OFFSET="dashOffset";M.POINT_SIZE="size";M.DISPERSION="dispersion";M.LIGHT_MAP="light";M.AO="ao";const Z0=k(M,M.ALPHA_TEST),J0=k(M,M.COLOR),eS=k(M,M.SHININESS),tS=k(M,M.EMISSIVE),_m=k(M,M.OPACITY),rS=k(M,M.SPECULAR),Nh=k(M,M.SPECULAR_INTENSITY),sS=k(M,M.SPECULAR_COLOR),ca=k(M,M.SPECULAR_STRENGTH),Mu=k(M,M.REFLECTIVITY),nS=k(M,M.ROUGHNESS),iS=k(M,M.METALNESS),oS=k(M,M.NORMAL),aS=k(M,M.CLEARCOAT),uS=k(M,M.CLEARCOAT_ROUGHNESS),lS=k(M,M.CLEARCOAT_NORMAL),cS=k(M,M.ROTATION),dS=k(M,M.SHEEN),hS=k(M,M.SHEEN_ROUGHNESS),fS=k(M,M.ANISOTROPY),pS=k(M,M.IRIDESCENCE),gS=k(M,M.IRIDESCENCE_IOR),mS=k(M,M.IRIDESCENCE_THICKNESS),yS=k(M,M.TRANSMISSION),bS=k(M,M.THICKNESS),_S=k(M,M.IOR),xS=k(M,M.ATTENUATION_DISTANCE),TS=k(M,M.ATTENUATION_COLOR),xm=k(M,M.LINE_SCALE),Tm=k(M,M.LINE_DASH_SIZE),vm=k(M,M.LINE_GAP_SIZE),lc=k(M,M.LINE_WIDTH),Sm=k(M,M.LINE_DASH_OFFSET),vS=k(M,M.POINT_SIZE),SS=k(M,M.DISPERSION),Nm=k(M,M.LIGHT_MAP),NS=k(M,M.AO),oi=K(new ce).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),wS=R(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class ct extends J{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===ct.OBJECT?this.updateType=re.OBJECT:e===ct.MATERIAL?this.updateType=re.RENDER:e===ct.FRAME?this.updateType=re.FRAME:e===ct.BEFORE_OBJECT?this.updateBeforeType=re.OBJECT:e===ct.BEFORE_MATERIAL?this.updateBeforeType=re.RENDER:e===ct.BEFORE_FRAME&&(this.updateBeforeType=re.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}ct.OBJECT="object";ct.MATERIAL="material";ct.FRAME="frame";ct.BEFORE_OBJECT="beforeObject";ct.BEFORE_MATERIAL="beforeMaterial";ct.BEFORE_FRAME="beforeFrame";const wm=(i,e)=>new ct(i,e).toStack(),dd=i=>wm(ct.OBJECT,i),RS=i=>wm(ct.FRAME,i);class ES extends zn{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.isContextAssign();if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?r=e.generatePBO(this):r=this.node.build(e):r=super.generate(e),s!==!0){const n=this.getNodeType(e);r=e.format(r,n,t)}return r}}const AS=Pe(ES).setParameterLength(2);class CS extends ad{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,n=null;t&&t.isStructTypeNode?(s="struct",n=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=pg(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=zt.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return AS(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(zt.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Xg(this.value),this._varying=qs(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Rm=(i,e=null,t=0)=>new CS(i,e,t),cc=new WeakMap,wh=new WeakMap,dc=new WeakMap;function Em(i,e){let t;const r=Math.max(e.count,1);if(e.isStorageInstancedBufferAttribute===!0)t=Rm(e,"mat4",r).element(Un);else if(r*16*4<=i.getUniformBufferLimit())t=ud(e.array,"mat4",r).element(Un);else{let o=cc.get(e);o||(o=new o_(e.array,16,1),cc.set(e,o));const a=e.usage===Ia?Yg:Kg,u=[a(o,"vec4",16,0),a(o,"vec4",16,4),a(o,"vec4",16,8),a(o,"vec4",16,12)];t=Us(...u)}return t}function MS(i,e,t){let r=dc.get(i);if(r===void 0){const s=e.clone();r={previousInstanceMatrix:s,node:Em(t,s)},dc.set(i,r)}return r.node}const Am=Wn("vec3","vInstanceColor"),BS=R(([i,e=null],t)=>{const r=i.isStorageInstancedBufferAttribute===!0,s=e&&e.isStorageInstancedBufferAttribute===!0,n=Em(t,i);let o=null;r||Math.max(i.count,1)*16*4>t.getUniformBufferLimit()&&(o=cc.get(i));let a=null,u=null;if(e)if(s)a=Rm(e,"vec3",Math.max(e.count,1)).element(Un);else{let c=wh.get(e);c||(c=new r_(e.array,3),wh.set(e,c)),u=c;const d=e.usage===Ia?Yg:Kg;a=C(d(c,"vec3",3,0))}(o!==null||u!==null)&&RS(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...i.updateRanges),i.version!==o.version&&(o.version=i.version)),e&&u!==null&&(u.clearUpdateRanges(),u.updateRanges.push(...e.updateRanges),e.version!==u.version&&(u.version=e.version))});const l=n.mul(Qe).xyz;if(Qe.assign(l),t.needsPreviousData()){const c=t.object;dd(({object:h})=>{dc.get(h).previousInstanceMatrix.array.set(i.array)});const d=MS(c,i,t);Ea.assign(d.mul(Ea).xyz)}if(t.hasGeometryAttribute("normal")){const c=um(Nr,n);Nr.assign(c)}a!==null&&Am.assign(a)},"void"),PS=R(([i])=>{const{instanceMatrix:e,instanceColor:t}=i;BS(e,t)},"void"),DS=R(([i,e])=>{const t=Ue(Gi(Jt(i),0).x).toConst(),r=Ue(e),s=r.mod(t).toConst(),n=r.div(t).toConst();return Jt(i,Nt(s,n))}),FS=R(([i,e])=>{const t=Ue(Gi(Jt(i),0).x).toConst(),r=Ue(e).mod(t).toConst(),s=Ue(e).div(t).toConst();return Jt(i,Nt(r,s)).x}),Cm=Wn("vec4","vBatchColor"),LS=R(([i],e)=>{const t=e.getDrawIndex()===null?Un:Kv,r=FS(i._indirectTexture,Ue(t)),s=i._matricesTexture,n=Ue(Gi(Jt(s),0).x).toConst(),o=w(r).mul(4).toInt().toConst(),a=o.mod(n).toConst(),u=o.div(n).toConst(),l=Us(Jt(s,Nt(a,u)),Jt(s,Nt(a.add(1),u)),Jt(s,Nt(a.add(2),u)),Jt(s,Nt(a.add(3),u))),c=i._colorsTexture;if(c!==null){const p=DS(c,r);Cm.assign(p)}const d=rt(l);Qe.assign(l.mul(Qe));const h=Nr.div(C(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),f=d.mul(h).xyz;Nr.assign(f),e.hasGeometryAttribute("tangent")&&Aa.mulAssign(d)},"void"),Rh=new WeakMap,hc=new WeakMap;function Mm(i,e,t,r,s,n){const o=i.element(s.x),a=i.element(s.y),u=i.element(s.z),l=i.element(s.w),c=t.mul(e),d=Rt(o.mul(n.x).mul(c),a.mul(n.y).mul(c),u.mul(n.z).mul(c),l.mul(n.w).mul(c));return r.mul(d).xyz}function US(i,e,t,r,s,n,o){const a=i.element(n.x),u=i.element(n.y),l=i.element(n.z),c=i.element(n.w);let d=Rt(o.x.mul(a),o.y.mul(u),o.z.mul(l),o.w.mul(c));d=s.mul(d).mul(r);const h=d.transformDirection(e).xyz,f=d.transformDirection(t).xyz;return{skinNormal:h,skinTangent:f}}function OS(i,e,t,r,s){const n=i.skeleton;let o=hc.get(n);if(o===void 0){n.update();const a=new Float32Array(n.boneMatrices);o={previousBoneMatrices:a,node:ud(a,"mat4",n.bones.length)},hc.set(n,o)}return Mm(o.node,Ea,e,t,r,s)}const IS=R(([i],e)=>{const t=Wt("skinIndex","uvec4"),r=Wt("skinWeight","vec4"),s=Me("bindMatrix","mat4"),n=Me("bindMatrixInverse","mat4"),o=O0("skeleton.boneMatrices","mat4",i.skeleton.bones.length);if(dd(({object:u,frameId:l})=>{const c=u.skeleton;if(Rh.get(c)!==l){Rh.set(c,l);const d=hc.get(c);d!==void 0&&d.previousBoneMatrices.set(c.boneMatrices),c.update()}}),e.needsPreviousData()){const u=OS(i,s,n,t,r);Ea.assign(u)}const a=Mm(o,Qe,s,n,t,r);if(Qe.assign(a),e.hasGeometryAttribute("normal")){const{skinNormal:u,skinTangent:l}=US(o,Nr,Aa,s,n,t,r);Nr.assign(u),e.hasGeometryAttribute("tangent")&&Aa.assign(l)}},"void");class kS extends J{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const r={};for(let a=0,u=this.params.length-1;aNumber(d)?p=">=":p="<"));let m;if(l)m=`while ( ${d} )`;else{const y={start:c,end:d},x=y.start,_=y.end;let N;const A=()=>p.includes("<")?"+=":"-=";if(g!=null)switch(typeof g){case"function":N=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":N=h+" "+A()+" "+e.generateConst(f,g);break;case"string":N=h+" "+g;break;default:g.isNode?N=h+" "+A()+" "+g.build(e):(O("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),N="break /* invalid update */")}else f==="int"||f==="uint"?g=p.includes("<")?"++":"--":g=A()+" 1.",N=h+" "+g;const v=e.getVar(f,h)+" = "+x,S=h+" "+p+" "+_;m=`for ( ${v}; ${S}; ${N} )`}e.addFlowCode((o===0?` +`:"")+e.tab+m+` { + +`).addFlowTab()}const n=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(` +`+e.tab+n);for(let o=0,a=this.params.length-1;onew kS(wn(i,"int")).toStack(),GS=()=>gr("break").toStack(),Bu=new WeakMap,Ct=new He,Eh=new WeakMap,Ah=R(({bufferMap:i,influence:e,stride:t,width:r,depth:s,offset:n})=>{const o=Ue(Xv).mul(t).add(n),a=o.div(r),u=o.sub(a.mul(r));return Jt(i,Nt(u,a)).depth(s).xyz.mul(e)});function VS(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,r=i.morphAttributes.color!==void 0,s=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,n=s!==void 0?s.length:0;let o=Bu.get(i);if(o===void 0||o.count!==n){let y=function(){g.dispose(),Bu.delete(i),i.removeEventListener("dispose",y)};o!==void 0&&o.texture.dispose();const a=i.morphAttributes.position||[],u=i.morphAttributes.normal||[],l=i.morphAttributes.color||[];let c=0;e===!0&&(c=1),t===!0&&(c=2),r===!0&&(c=3);let d=i.attributes.position.count*c,h=1;const f=4096;d>f&&(h=Math.ceil(d/f),d=f);const p=new Float32Array(d*h*4*n),g=new t_(p,d,h,n);g.type=dt,g.needsUpdate=!0;const m=c*4;for(let x=0;x{const{geometry:e}=i,t=e.morphAttributes.position!==void 0,r=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=s!==void 0?s.length:0;if(n===0)return;let o=Eh.get(i);(o===void 0||o.count!==n)&&(o={base:K(1),influences:i.morphTargetInfluences?Tt(i.morphTargetInfluences,"float"):null,count:n},Eh.set(i,o));const{base:a,influences:u}=o,{texture:l,stride:c,size:d}=VS(e);t===!0&&Qe.mulAssign(a),r===!0&&Nr.mulAssign(a);const h=Ue(d.width);$t(n,({i:f})=>{const p=w(0).toVar();i.count>1&&i.morphTexture!==null&&i.morphTexture!==void 0?p.assign(Jt(i.morphTexture,Nt(Ue(f).add(1),Ue(Un))).r):p.assign(u.element(f).toVar()),me(p.notEqual(0),()=>{t===!0&&Qe.addAssign(Ah({bufferMap:l,influence:p,stride:c,width:h,depth:f,offset:Ue(0)})),r===!0&&Nr.addAssign(Ah({bufferMap:l,influence:p,stride:c,width:h,depth:f,offset:Ue(1)}))})}),dd(({object:f})=>{const{base:p,influences:g}=o;f.geometry.morphTargetsRelative?p.value=1:p.value=1-f.morphTargetInfluences.reduce((m,y)=>m+y,0),g&&(g.array=f.morphTargetInfluences,g.update())})},"void");class Xn extends J{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zS extends Xn{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class WS extends rd{static get type(){return"LightingContextNode"}constructor(e,t=null,r=[],s=null,n=null){super(e),this.lightingModel=t,this.materialLightings=r,this.backdropNode=s,this.backdropAlphaNode=n,this._value=null}getContext(){const{materialLightings:e,backdropNode:t,backdropAlphaNode:r}=this,s=C().toVar("directDiffuse"),n=C().toVar("directSpecular"),o=C().toVar("indirectDiffuse"),a=C().toVar("indirectSpecular"),u={directDiffuse:s,directSpecular:n,indirectDiffuse:o,indirectSpecular:a};return{radiance:C().toVar("radiance"),irradiance:C().toVar("irradiance"),iblIrradiance:C().toVar("iblIrradiance"),ambientOcclusion:w(1).toVar("ambientOcclusion"),reflectedLight:u,materialLightings:e,backdrop:t,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const jS=Pe(WS);class HS extends Xn{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const Ts=new ce;class Bm extends to{static get type(){return"ViewportTextureNode"}constructor(e=as,t=null,r=null){let s=null;r===null?(s=new pp,s.minFilter=ls,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=re.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),e===null)return t;if(r.has(e)===!1){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),n=r||s;return this.value=this.getTextureForReference(n),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),n=r||s;n===null?t.getDrawingBufferSize(Ts):n.getDrawingBufferSize?n.getDrawingBufferSize(Ts):Ts.set(n.width,n.height);const o=this.getTextureForReference(n);(o.image.width!==Ts.width||o.image.height!==Ts.height)&&(o.image.width=Ts.width,o.image.height=Ts.height,o.needsUpdate=!0);const a=o.generateMipmaps;o.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(o),o.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Pm=Pe(Bm,null,null,{generateMipmaps:!0}).setParameterLength(0,3),qS=Pm(),XS=(i=as,e=null)=>qS.sample(i,e);let Pu=null;class KS extends Bm{static get type(){return"ViewportDepthTextureNode"}constructor(e=as,t=null,r=null){r===null&&(Pu===null&&(Pu=new xr),r=Pu),super(e,t,r)}}const YS=Pe(KS).setParameterLength(0,3);class wt extends J{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===wt.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===wt.DEPTH_BASE)r!==null&&(s=Fm().assign(r));else if(t===wt.DEPTH)e.isPerspectiveCamera?s=Dm(je.z,Cs,Ms):s=Cn(je.z,Cs,Ms);else if(t===wt.LINEAR_DEPTH)if(r!==null)if(e.isPerspectiveCamera){const n=hd(r,Cs,Ms);s=Cn(n,Cs,Ms)}else s=r;else s=Cn(je.z,Cs,Ms);return s}}wt.DEPTH_BASE="depthBase";wt.DEPTH="depth";wt.LINEAR_DEPTH="linearDepth";const Cn=(i,e,t)=>i.add(e).div(e.sub(t)),QS=R(([i,e,t],r)=>r.renderer.reversedDepthBuffer===!0?t.sub(e).mul(i).sub(t):e.sub(t).mul(i).sub(e)),Dm=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),ZS=(i,e,t)=>e.mul(i.add(t)).div(i.mul(e.sub(t))),hd=R(([i,e,t],r)=>r.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(i).sub(e)):e.mul(t).div(t.sub(e).mul(i).sub(t))),fd=(i,e,t)=>{e=e.max(1e-6).toVar();const r=jr(i.negate().div(e)),s=jr(t.div(e));return r.div(s)},Fm=Pe(wt,wt.DEPTH_BASE),Lm=k(wt,wt.DEPTH),JS=Pe(wt,wt.LINEAR_DEPTH).setParameterLength(0,1);YS();Lm.assign=i=>Fm(i);class qt extends J{static get type(){return"ClippingNode"}constructor(e=qt.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.hardwareClipping,this.scope===qt.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===qt.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return R(()=>{const r=w().toVar("distanceToPlane"),s=w().toVar("distanceToGradient"),n=w(1).toVar("clipOpacity"),o=t.length;if(this.hardwareClipping===!1&&o>0){const u=Tt(t).setGroup(Z);$t(o,({i:l})=>{const c=u.element(l);r.assign(je.dot(c.xyz).negate().add(c.w)),s.assign(r.fwidth().div(2)),n.mulAssign(nr(s.negate(),s,r))})}const a=e.length;if(a>0){const u=Tt(e).setGroup(Z),l=w(1).toVar("intersectionClipOpacity");$t(a,({i:c})=>{const d=u.element(c);r.assign(je.dot(d.xyz).negate().add(d.w)),s.assign(r.fwidth().div(2)),l.mulAssign(nr(s.negate(),s,r).oneMinus())}),n.mulAssign(l.oneMinus())}Se.a.mulAssign(n),Se.a.equal(0).discard()})()}setupDefault(e,t){return R(()=>{const r=t.length;if(this.hardwareClipping===!1&&r>0){const n=Tt(t).setGroup(Z);$t(r,({i:o})=>{const a=n.element(o);je.dot(a.xyz).greaterThan(a.w).discard()})}const s=e.length;if(s>0){const n=Tt(e).setGroup(Z),o=Ha(!0).toVar("clipped");$t(s,({i:a})=>{const u=n.element(a);o.assign(je.dot(u.xyz).greaterThan(u.w).and(o))}),o.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),R(()=>{const s=Tt(e).setGroup(Z),n=Ks(t.getClipDistance());$t(r,({i:o})=>{const a=s.element(o),u=je.dot(a.xyz).sub(a.w).negate();n.element(o).assign(u)})})()}}qt.ALPHA_TO_COVERAGE="alphaToCoverage";qt.DEFAULT="default";qt.HARDWARE="hardware";const eN=()=>new qt,tN=()=>new qt(qt.ALPHA_TO_COVERAGE),rN=()=>new qt(qt.HARDWARE),sN=.05,Ch=R(([i])=>Sr(ae(1e4,Dt(ae(17,i.x).add(ae(.1,i.y)))).mul(Rt(.1,Ft(Dt(ae(13,i.y).add(i.x))))))),Mh=R(([i])=>Ch(ee(Ch(i.xy),i.z))),nN=R(([i])=>{const e=st(Hr(Ig(i.xyz)),Hr(kg(i.xyz))),t=w(1).div(w(sN).mul(e)).toVar("pixScale"),r=ee(Ii(Os(jr(t))),Ii(ed(jr(t)))),s=ee(Mh(Os(r.x.mul(i.xyz))),Mh(Os(r.y.mul(i.xyz)))),n=Sr(jr(t)),o=Rt(ae(n.oneMinus(),s.x),ae(n,s.y)),a=Ln(n,n.oneMinus()),u=C(o.mul(o).div(ae(2,a).mul(xt(1,a))),o.sub(ae(.5,a)).div(xt(1,a)),xt(1,xt(1,o).mul(xt(1,o)).div(ae(2,a).mul(xt(1,a))))),l=o.lessThan(a.oneMinus()).select(o.lessThan(a).select(u.x,u.y),u.z);return hs(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class iN extends rm{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),r=e.hasGeometryAttribute(t);let s;return r===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new He(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const oN=(i=0)=>new iN(i);class qe extends Rd{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const r=this[t];r&&r.isNode===!0&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Vn(t.slice(0,-4)),r.getCacheKey());return this.type+Ji(e)}build(e){this.setup(e)}setupObserver(e){return new Lx(e)}setup(e){e.context.setupNormal=()=>An(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),n=An(this.vertexNode||s,"VERTEX");e.context.clipSpace=n,e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let o;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(r!==null?r.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);const u=this.setupLighting(e);a!==null&&e.stack.addToStack(a);const l=q(u,Se.a).max(0);o=this.setupOutput(e,l),Ci.assign(o);const c=this.outputNode!==null;if(c&&(o=this.outputNode),e.context.getOutput&&(o=e.context.getOutput(o,e)),r!==null){const d=t.getMRT(),h=this.mrtNode;d!==null?(c&&Ci.assign(o),o=d,h!==null&&(o=d.merge(h))):h!==null&&(o=h)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=u.convert(e.getOutputType())),o=this.setupOutput(e,u)}e.stack.outputNode=o,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const n=e.renderer.currentSamples;this.alphaToCoverage&&n>1?s=tN():e.stack.addToStack(eN())}return s}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(rN()),e.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(s===null){const n=t.getMRT();n&&n.has("depth")?s=n.get("depth"):t.logarithmicDepthBuffer===!0&&(r.isPerspectiveCamera?s=fd(je.z,Cs,Ms):s=Cn(je.z,Cs,Ms))}s!==null&&Lm.assign(s).toStack()}setupPositionView(){return Ws.mul(Qe).xyz}setupModelViewProjection(){return rr.mul(je)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),wS}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&$S(t),t.isSkinnedMesh===!0&&IS(t),this.displacementMap){const s=ns("displacementMap","texture"),n=ns("displacementScale","float"),o=ns("displacementBias","float");Qe.addAssign(Nr.normalize().mul(s.x.mul(n).add(o)))}return t.isBatchedMesh&&LS(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&PS(t),this.positionNode!==null&&Qe.assign(An(this.positionNode,"POSITION","vec3")),Qe}setupDiffuseColor(e){const{object:t,geometry:r}=e;this.maskNode!==null&&Ha(this.maskNode).not().discard();let s=this.colorNode?q(this.colorNode):J0;this.vertexColors===!0&&r.hasAttribute("color")&&(s=s.mul(oN())),t.instanceColor&&(s=Am.mul(s)),t.isBatchedMesh&&t._colorsTexture&&(s=Cm.mul(s)),Se.assign(s);const n=this.opacityNode?w(this.opacityNode):_m;Se.a.assign(Se.a.mul(n));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?w(this.alphaTestNode):Z0,this.alphaToCoverage===!0?(Se.a=nr(o,o.add(Gg(Se.a)),Se.a),Se.a.lessThanEqual(0).discard()):Se.a.lessThanEqual(o).discard()),this.alphaHash===!0&&Se.a.lessThan(nN(Qe)).discard(),e.isOpaque()&&Se.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?C(0):Se.rgb}setupNormal(){return this.normalNode?C(this.normalNode):oS}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ns("envMap","cubeTexture"):ns("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new HS(Nm)),t}setupMaterialLightings(e){const t=[];if(e.renderer.lighting.enabled===!1)return t;const r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);return s&&s.isLightingNode&&t.push(s),e.context.ambientOcclusion&&t.push(new zS(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=NS),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(fh.assign(t),e.context.ambientOcclusion=fh)}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:n}=this,o=this.lights===!0||this.lightsNode!==null,a=this.lights===!0?this.setupMaterialLightings(e):[],u=o?this.lightsNode||e.lightsNode:null;let l=this.setupOutgoingLight(e);if(u&&(a.length>0||u.getScope().hasLights)){const c=this.setupLightingModel(e)||null;l=jS(u,c,a,r,s)}else r!==null&&(l=C(s!==null?xe(l,r,s):r));return(n&&n.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(hh.assign(C(n||tS)),l=l.add(hh)),l}setupFog(e,t){const r=e.fogNode;return r&&(Ci.assign(t),t=q(r.toVar())),t}setupPremultipliedAlpha(e,t){return Jg(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const r in e){const s=e[r];this[r]===void 0&&(this[r]=s,s&&s.clone&&(this[r]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const r in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,r)===void 0&&t[r].get!==void 0&&Object.defineProperty(this.constructor.prototype,r,t[r])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const r=Rd.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:n,childNode:o}of this._getNodeChildren())r.inputNodes[n]=o.toJSON(e).uuid;function s(n){const o=[];for(const a in n){const u=n[a];delete u.metadata,o.push(u)}return o}if(t){const n=s(e.textures),o=s(e.images),a=s(e.nodes);n.length>0&&(r.textures=n),o.length>0&&(r.images=o),a.length>0&&(r.nodes=a)}return r}copy(e){const t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(const r in t)if(t[r].set!==void 0&&e[r]!==void 0){const s=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(s):this[r]=s}for(const r in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(r)&&this[r]!==void 0&&e[r]!==void 0){const s=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(s):this[r]=s}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(r=>r.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}}const aN=new op;class uN extends qe{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(aN),this.setValues(e)}}const lN=new Rb;class cN extends qe{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(lN),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?w(this.offsetNode):Sm,t=this.dashScaleNode?w(this.dashScaleNode):xm,r=this.dashSizeNode?w(this.dashSizeNode):Tm,s=this.gapSizeNode?w(this.gapSizeNode):vm;En.assign(r),Ra.assign(s);const n=qs(Wt("lineDistance").mul(t));(e?n.add(e):n).mod(En.add(Ra)).greaterThan(En).discard()}}const da=Wn("vec3","worldStart"),fc=Wn("vec3","worldEnd"),Um=Wn("float","lineDistance"),Rs=Wn("vec4","worldPos"),Bh=R(({start:i,end:e})=>{const t=rr.element(2).element(2),r=rr.element(3).element(2);return t.greaterThan(0).select(r.negate().div(t.add(1)),r.mul(-.5).div(t)).sub(i.z).div(e.z.sub(i.z))},{start:"vec4",end:"vec4",return:"float"}),dN=R(({p1:i,p2:e,p3:t,p4:r})=>{const s=i.sub(t),n=r.sub(t),o=e.sub(i),a=s.dot(n),u=n.dot(o),l=s.dot(o),c=n.dot(n),h=o.dot(o).mul(c).sub(u.mul(u)),p=a.mul(u).sub(l.mul(c)).div(h).clamp(),g=a.add(u.mul(p)).div(c).clamp();return ee(p,g)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"});R(({material:i})=>{const e=i._useDash,t=i._useWorldUnits,r=Wt("instanceStart"),s=Wt("instanceEnd"),n=q(Ws.mul(q(r,1))).toVar("start"),o=q(Ws.mul(q(s,1))).toVar("end");let a,u;e&&(a=w(Wt("instanceDistanceStart")).toVar("distanceStart"),u=w(Wt("instanceDistanceEnd")).toVar("distanceEnd")),t&&(da.assign(n.xyz),fc.assign(o.xyz));const l=Bi.z.div(Bi.w),c=rr.element(2).element(3).equal(-1);if(me(c,()=>{me(n.z.lessThan(0).and(o.z.greaterThan(0)),()=>{const y=Bh({start:n,end:o});o.assign(q(xe(n.xyz,o.xyz,y),o.w)),e&&u.assign(xe(a,u,y))}).ElseIf(o.z.lessThan(0).and(n.z.greaterThanEqual(0)),()=>{const y=Bh({start:o,end:n});n.assign(q(xe(o.xyz,n.xyz,y),n.w)),e&&a.assign(xe(u,a,y))})}),e){const y=i.dashScaleNode?w(i.dashScaleNode):xm,x=i.offsetNode?w(i.offsetNode):Sm;let _=mt.y.lessThan(.5).select(y.mul(a),y.mul(u));_=_.add(x),Um.assign(_)}const d=rr.mul(n),h=rr.mul(o),f=d.xyz.div(d.w),p=h.xyz.div(h.w),g=p.xy.sub(f.xy).toVar();g.x.assign(g.x.mul(l)),g.assign(g.normalize());const m=q().toVar();if(t){const y=o.xyz.sub(n.xyz).normalize(),x=xe(n.xyz,o.xyz,.5).normalize(),_=y.cross(x).normalize(),N=y.cross(_);Rs.assign(mt.y.lessThan(.5).select(n,o));const A=lc.mul(.5);Rs.addAssign(q(mt.x.lessThan(0).select(_.mul(A),_.mul(A).negate()),0)),e||(Rs.addAssign(q(mt.y.lessThan(.5).select(y.mul(A).negate(),y.mul(A)),0)),Rs.addAssign(q(N.mul(A),0)),me(mt.y.greaterThan(1).or(mt.y.lessThan(0)),()=>{Rs.subAssign(q(N.mul(2).mul(A),0))})),m.assign(rr.mul(Rs));const v=C().toVar();v.assign(mt.y.lessThan(.5).select(f,p)),m.z.assign(v.z.mul(m.w))}else{const y=ee(g.y,g.x.negate()).toVar("offset");g.x.assign(g.x.div(l)),y.x.assign(y.x.div(l)),y.assign(mt.x.lessThan(0).select(y.negate(),y)),me(mt.y.lessThan(0),()=>{y.assign(y.sub(g))}).ElseIf(mt.y.greaterThan(1),()=>{y.assign(y.add(g))}),y.assign(y.mul(lc)),y.assign(y.div(Bi.w.div(nm))),m.assign(mt.y.lessThan(.5).select(d,h)),y.assign(y.mul(m.w)),m.assign(m.add(q(y,0,0)))}return m})();R(({material:i,renderer:e})=>{const t=i._useAlphaToCoverage,r=i._useDash,s=i._useWorldUnits,n=Xs();if(r){const a=i.dashSizeNode?w(i.dashSizeNode):Tm,u=i.gapSizeNode?w(i.gapSizeNode):vm;En.assign(a),Ra.assign(u),n.y.lessThan(-1).or(n.y.greaterThan(1)).discard(),Um.mod(En.add(Ra)).greaterThan(En).discard()}const o=w(1).toVar("alpha");if(s){const a=Rs.xyz.normalize().mul(1e5),u=fc.sub(da),l=dN({p1:da,p2:fc,p3:C(0,0,0),p4:a}),c=da.add(u.mul(l.x)),d=a.mul(l.y),p=c.sub(d).length().div(lc);if(!r)if(t&&e.currentSamples>0){const g=p.fwidth();o.assign(nr(g.negate().add(.5),g.add(.5),p).oneMinus())}else p.greaterThan(.5).discard()}else if(t&&e.currentSamples>0){const a=n.x,u=n.y.greaterThan(0).select(n.y.sub(1),n.y.add(1)),l=a.mul(a).add(u.mul(u)),c=w(l.fwidth()).toVar("dlen");me(n.y.abs().greaterThan(1),()=>{o.assign(nr(c.oneMinus(),c.add(1),l).oneMinus())})}else me(n.y.abs().greaterThan(1),()=>{const a=n.x,u=n.y.greaterThan(0).select(n.y.sub(1),n.y.add(1));a.mul(a).add(u.mul(u)).greaterThan(1).discard()});return o})();const hN=new Nb;class fN extends qe{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(hN),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?w(this.opacityNode):_m;Se.assign(id(q(H0(ge),e),Ec))}}const Om=R(([i=im])=>{const e=i.z.atan(i.x).mul(1/(Math.PI*2)).add(.5),t=i.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return ee(e,t)}),Ph=R(([i=Xs()])=>{const e=i.x.sub(.5).mul(Math.PI*2),t=i.y.sub(.5).mul(Math.PI),r=t.cos(),s=r.mul(e.cos()),n=t.sin(),o=r.mul(e.sin());return C(s,n,o)});class Im extends ps{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new $a(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new Hp(5,5,5),o=Om(im),a=new qe;a.colorNode=Ne(t,o,0),a.side=ft,a.blending=Wr;const u=new sr(n,a),l=new Ac;l.add(u),t.minFilter===ls&&(t.minFilter=yt);const c=new s_(1,10,this),d=e.getMRT();return e.setMRT(null),c.update(e,l),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,u.geometry.dispose(),u.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const n=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,s);e.setRenderTarget(n)}}const Pi=new WeakMap;class pN extends Xe{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=vt(null);const t=new $a;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=re.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const n=s.isTextureNode?s.value:r[s.property];if(n&&n.isTexture){const o=n.mapping;if(o===Dc||o===Fc){if(Pi.has(n)){const a=Pi.get(n);Dh(a,n.mapping),this._cubeTexture=a}else{const a=n.image;if(gN(a)){const u=new Im(a.height);u.fromEquirectangularTexture(t,n),Dh(u.texture,n.mapping),this._cubeTexture=u.texture,Pi.set(n,u.texture),n.addEventListener("dispose",km)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function gN(i){return i==null?!1:i.height>0}function km(i){const e=i.target;e.removeEventListener("dispose",km);const t=Pi.get(e);t!==void 0&&(Pi.delete(e),t.dispose())}function Dh(i,e){e===Dc?i.mapping=Ta:e===Fc&&(i.mapping=va)}const Gm=Pe(pN).setParameterLength(1);class pd extends Xn{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Gm(this.envNode)}}class mN extends Xn{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=w(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Xa{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Vm extends Xa{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(q(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(q(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Se.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,n=e.context.environment;if(n)switch(t.combine){case e_:s.rgb.assign(xe(s.rgb,s.rgb.mul(n.rgb),ca.mul(Mu)));break;case Jb:s.rgb.assign(xe(s.rgb,n.rgb,ca.mul(Mu)));break;case Zb:s.rgb.addAssign(n.rgb.mul(ca.mul(Mu)));break;default:z("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const yN=new ss;class bN extends qe{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(yN),this.setValues(e)}setupNormal(){return so(Vi)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new mN(Nm)),t}setupOutgoingLight(){return Se.rgb}setupLightingModel(){return new Vm}}const $i=R(({f0:i,f90:e,dotVH:t})=>{const r=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(r.oneMinus()).add(e.mul(r))}),In=R(i=>i.diffuseColor.mul(1/Math.PI)),_N=()=>w(.25),xN=R(({dotNH:i})=>sc.mul(w(.5)).add(1).mul(w(1/Math.PI)).mul(i.pow(sc))),TN=R(({lightDirection:i})=>{const e=i.add(Ee).normalize(),t=ge.dot(e).clamp(),r=Ee.dot(e).clamp(),s=$i({f0:Gs,f90:1,dotVH:r}),n=_N(),o=xN({dotNH:t});return s.mul(n).mul(o)});class $m extends Vm{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const n=ge.dot(e).clamp().mul(t);r.directDiffuse.addAssign(n.mul(In({diffuseColor:Se.rgb}))),this.specular===!0&&r.directSpecular.addAssign(n.mul(TN({lightDirection:e})).mul(ca))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(In({diffuseColor:Se}))),s.indirectDiffuse.mulAssign(t)}}const vN=new rp;class SN extends qe{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(vN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightingModel(){return new $m(!1)}}const NN=new xb;class wN extends qe{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(NN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightingModel(){return new $m}setupVariants(){const e=(this.shininessNode?w(this.shininessNode):eS).max(1e-4);sc.assign(e);const t=this.specularNode||rS;Gs.assign(t)}}const RN=R(i=>{if(i.geometry.hasAttribute("normal")===!1)return w(0);const e=Vi.dFdx().abs().max(Vi.dFdy().abs());return e.x.max(e.y).max(e.z)}),zm=R(i=>{const{roughness:e}=i,t=RN();let r=e.max(.0525);return r=r.add(t),r=r.min(1),r}),EN=R(({alpha:i,dotNL:e,dotNV:t})=>{const r=i.pow2(),s=e.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt()),n=t.mul(r.add(r.oneMinus().mul(e.pow2())).sqrt());return vr(.5,s.add(n).max(Jc))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),AN=R(({alphaT:i,alphaB:e,dotTV:t,dotBV:r,dotTL:s,dotBL:n,dotNV:o,dotNL:a})=>{const u=a.mul(C(i.mul(t),e.mul(r),o).length()),l=o.mul(C(i.mul(s),e.mul(n),a).length());return vr(.5,u.add(l).max(Jc))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),CN=R(({alpha:i,dotNH:e})=>{const t=i.pow2(),r=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),MN=w(1/Math.PI),BN=R(({alphaT:i,alphaB:e,dotNH:t,dotTH:r,dotBH:s})=>{const n=i.mul(e),o=C(e.mul(r),i.mul(s),n.mul(t)),a=o.dot(o),u=n.div(a);return MN.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Wm=R(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,normalView:n=ge,USE_IRIDESCENCE:o,USE_ANISOTROPY:a})=>{const u=r.pow2(),l=i.add(Ee).normalize(),c=n.dot(i).clamp(),d=n.dot(Ee).clamp(),h=n.dot(l).clamp(),f=Ee.dot(l).clamp();let p=$i({f0:e,f90:t,dotVH:f}),g,m;if(Zl(o)&&(p=Qc.mix(p,s)),Zl(a)){const y=oa.dot(i),x=oa.dot(Ee),_=oa.dot(l),N=Rn.dot(i),A=Rn.dot(Ee),v=Rn.dot(l);g=AN({alphaT:rc,alphaB:u,dotTV:x,dotBV:A,dotTL:y,dotBL:N,dotNV:d,dotNL:c}),m=BN({alphaT:rc,alphaB:u,dotNH:h,dotTH:_,dotBH:v})}else g=EN({alpha:u,dotNL:c,dotNV:d}),m=CN({alpha:u,dotNH:h});return p.mul(g).mul(m)}),PN=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let lr=null;const Ca=R(({roughness:i,dotNV:e})=>{lr===null&&(lr=new Vp(PN,16,16,tr,ht),lr.name="DFG_LUT",lr.minFilter=yt,lr.magFilter=yt,lr.wrapS=Oi,lr.wrapT=Oi,lr.generateMipmaps=!1,lr.needsUpdate=!0);const t=ee(i,e);return Ne(lr,t).rg}),DN=R(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:o})=>{const a=Wm({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:o}),u=ge.dot(i).clamp(),l=ge.dot(Ee).clamp(),c=Ca({roughness:r,dotNV:l}),d=Ca({roughness:r,dotNV:u}),h=e.mul(c.x).add(t.mul(c.y)),f=e.mul(d.x).add(t.mul(d.y)),p=c.x.add(c.y),g=d.x.add(d.y),m=w(1).sub(p),y=w(1).sub(g),x=e.add(e.oneMinus().mul(.047619)),_=h.mul(f).mul(x).div(w(1).sub(m.mul(y).mul(x).mul(x)).add(Jc)),N=m.mul(y),A=_.mul(N);return a.add(A)}),jm=R(i=>{const{dotNV:e,specularColor:t,specularF90:r,roughness:s}=i,n=Ca({dotNV:e,roughness:s});return t.mul(n.x).add(r.mul(n.y))}),Fh=R(({f:i,f90:e,dotVH:t})=>{const r=t.oneMinus().saturate(),s=r.mul(r),n=r.mul(s,s).clamp(0,.9999);return i.sub(C(e).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),FN=R(({roughness:i,dotNH:e})=>{const t=i.pow2(),r=w(1).div(t),n=e.pow2().oneMinus().max(.0078125);return w(2).add(r).mul(n.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),LN=R(({dotNV:i,dotNL:e})=>w(1).div(w(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),UN=R(({lightDirection:i})=>{const e=i.add(Ee).normalize(),t=ge.dot(i).clamp(),r=ge.dot(Ee).clamp(),s=ge.dot(e).clamp(),n=FN({roughness:As,dotNH:s}),o=LN({dotNV:r,dotNL:t});return Gt.mul(n).mul(o)}),Lh=R(({N:i,V:e,roughness:t})=>{const n=.0078125,o=i.dot(e).saturate(),a=ee(t,o.oneMinus().sqrt());return a.assign(a.mul(.984375).add(n)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),ON=R(({f:i})=>{const e=i.length();return st(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),So=R(({v1:i,v2:e})=>{const t=i.dot(e),r=t.abs().toVar(),s=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),n=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=s.div(n),a=t.greaterThan(0).select(o,st(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return i.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),Du=R(({N:i,V:e,P:t,mInv:r,p0:s,p1:n,p2:o,p3:a})=>{const u=n.sub(s).toVar(),l=a.sub(s).toVar(),c=u.cross(l),d=C().toVar();return me(c.dot(t.sub(s)).greaterThanEqual(0),()=>{const h=e.sub(i.mul(e.dot(i))).normalize(),f=i.cross(h).negate(),p=r.mul(rt(h,f,i).transpose()).toVar(),g=p.mul(s.sub(t)).normalize().toVar(),m=p.mul(n.sub(t)).normalize().toVar(),y=p.mul(o.sub(t)).normalize().toVar(),x=p.mul(a.sub(t)).normalize().toVar(),_=C(0).toVar();_.addAssign(So({v1:g,v2:m})),_.addAssign(So({v1:m,v2:y})),_.addAssign(So({v1:y,v2:x})),_.addAssign(So({v1:x,v2:g})),d.assign(C(ON({f:_})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Ka=1/6,Hm=i=>ae(Ka,ae(i,ae(i,i.negate().add(3)).sub(3)).add(1)),pc=i=>ae(Ka,ae(i,ae(i,ae(3,i).sub(6))).add(4)),qm=i=>ae(Ka,ae(i,ae(i,ae(-3,i).add(3)).add(3)).add(1)),gc=i=>ae(Ka,qa(i,3)),Uh=i=>Hm(i).add(pc(i)),Oh=i=>qm(i).add(gc(i)),Ih=i=>Rt(-1,pc(i).div(Hm(i).add(pc(i)))),kh=i=>Rt(1,gc(i).div(qm(i).add(gc(i)))),Gh=(i,e,t)=>{const r=i.uvNode,s=ae(r,e.zw).add(.5),n=Os(s),o=Sr(s),a=Uh(o.x),u=Oh(o.x),l=Ih(o.x),c=kh(o.x),d=Ih(o.y),h=kh(o.y),f=ee(n.x.add(l),n.y.add(d)).sub(.5).mul(e.xy),p=ee(n.x.add(c),n.y.add(d)).sub(.5).mul(e.xy),g=ee(n.x.add(l),n.y.add(h)).sub(.5).mul(e.xy),m=ee(n.x.add(c),n.y.add(h)).sub(.5).mul(e.xy),y=Uh(o.y).mul(Rt(a.mul(i.sample(f).level(t)),u.mul(i.sample(p).level(t)))),x=Oh(o.y).mul(Rt(a.mul(i.sample(g).level(t)),u.mul(i.sample(m).level(t))));return y.add(x)},IN=R(([i,e])=>{const t=ee(i.size(Ue(e))),r=ee(i.size(Ue(e.add(1)))),s=vr(1,t),n=vr(1,r),o=Gh(i,q(s,t),Os(e)),a=Gh(i,q(n,r),ed(e));return Sr(e).mix(o,a)}),Vh=R(([i,e,t,r,s])=>{const n=C(Wg(e.negate(),Ht(i),vr(1,r))),o=C(Hr(s[0].xyz),Hr(s[1].xyz),Hr(s[2].xyz));return Ht(n).mul(t.mul(o))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),kN=R(([i,e])=>i.mul(hs(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),GN=Pm(),VN=XS(),$h=R(([i,e,t],{material:r})=>{const n=(r.side===ft?GN:VN).sample(i),o=jr(ic.x).mul(kN(e,t));return IN(n,o)}),zh=R(([i,e,t])=>(me(t.notEqual(0),()=>{const r=Fg(e).negate().div(t);return Dg(r.negate().mul(i))}),C(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),$N=R(([i,e,t,r,s,n,o,a,u,l,c,d,h,f,p])=>{let g,m;if(p){g=q().toVar(),m=C().toVar();const A=c.sub(1).mul(p.mul(.025)),v=C(c.sub(A),c,c.add(A));$t({start:0,end:3},({i:S})=>{const P=v.element(S),F=Vh(i,e,d,P,a),U=o.add(F),W=l.mul(u.mul(q(U,1))),se=ee(W.xy.div(W.w)).toVar();se.addAssign(1),se.divAssign(2),se.assign(ee(se.x,se.y.oneMinus()));const ie=$h(se,t,P);g.element(S).assign(ie.element(S)),g.a.addAssign(ie.a),m.element(S).assign(r.element(S).mul(zh(Hr(F),h,f).element(S)))}),g.a.divAssign(3)}else{const A=Vh(i,e,d,c,a),v=o.add(A),S=l.mul(u.mul(q(v,1))),P=ee(S.xy.div(S.w)).toVar();P.addAssign(1),P.divAssign(2),P.assign(ee(P.x,P.y.oneMinus())),g=$h(P,t,c),m=r.mul(zh(Hr(A),h,f))}const y=m.rgb.mul(g.rgb),x=i.dot(e).clamp(),_=C(jm({dotNV:x,specularColor:s,specularF90:n,roughness:t})),N=m.r.add(m.g,m.b).div(3);return q(_.oneMinus().mul(y),g.a.oneMinus().mul(N).oneMinus())}),zN=rt(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),WN=i=>{const e=i.sqrt();return C(1).add(e).div(C(1).sub(e))},Wh=(i,e)=>i.sub(e).div(i.add(e)).pow2(),jN=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),r=C(54856e-17,44201e-17,52481e-17),s=C(1681e3,1795300,2208400),n=C(43278e5,93046e5,66121e5),o=w(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=r.mul(n.mul(2*Math.PI).sqrt()).mul(s.mul(t).add(e).cos()).mul(t.pow2().negate().mul(n).exp());return a=C(a.x.add(o),a.y,a.z).div(10685e-11),zN.mul(a)},jh=R(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:r,baseF0:s})=>{const n=xe(i,e,nr(0,.03,r)),a=i.div(n).pow2().mul(t.pow2().oneMinus()).oneMinus();me(a.lessThan(0),()=>C(1));const u=a.sqrt(),l=Wh(n,i),c=$i({f0:l,f90:1,dotVH:t}),d=c.oneMinus(),h=n.lessThan(i).select(Math.PI,0),f=w(Math.PI).sub(h),p=WN(s.clamp(0,.9999)),g=Wh(p,n.toVec3()),m=$i({f0:g,f90:1,dotVH:u}),y=C(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),x=n.mul(r,u,2),_=C(f).add(y),N=c.mul(m).clamp(1e-5,.9999),A=N.sqrt(),v=d.pow2().mul(m).div(C(1).sub(N)),P=c.add(v).toVar(),F=v.sub(d).toVar();return $t({start:1,end:2,condition:"<=",name:"m"},({m:U})=>{F.mulAssign(A);const W=jN(w(U).mul(x),w(U).mul(_)).mul(2);P.addAssign(F.mul(W))}),P.max(C(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),ai=R(({normal:i,viewDir:e,roughness:t})=>{const r=i.dot(e).saturate(),s=t.mul(t),n=t.add(.1).reciprocal(),o=w(-1.9362).add(t.mul(1.0678)).add(s.mul(.4573)).sub(n.mul(.8469)),a=w(-.6014).add(t.mul(.5538)).sub(s.mul(.467)).sub(n.mul(.1255));return o.mul(r).add(a).exp().saturate()}),ui=C(.04),No=w(1);class Xm extends Xa{constructor(e=!1,t=!1,r=!1,s=!1,n=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=n,this.dispersion=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=C().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=C().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=C().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=C().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=C().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=ge.dot(Ee).clamp(),r=jh({outsideIOR:w(1),eta2:ec,cosTheta1:t,thinFilmThickness:tc,baseF0:Gs}),s=jh({outsideIOR:w(1),eta2:ec,cosTheta1:t,thinFilmThickness:tc,baseF0:Se.rgb});this.iridescenceFresnel=xe(r,s,os),this.iridescenceF0Dielectric=Fh({f:r,f90:1,dotVH:t}),this.iridescenceF0Metallic=Fh({f:s,f90:1,dotVH:t}),this.iridescenceF0=xe(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,os)}if(this.transmission===!0){const t=On,r=x0.sub(On).normalize(),s=qn,n=e.context;n.backdrop=$N(s,r,Or,gn,_n,xn,t,zs,Hn,rr,aa,Eg,Cg,Ag,this.dispersion?Mg:null),n.backdropAlpha=nc,Se.a.mulAssign(xe(1,n.backdrop.a,nc))}super.start(e)}computeMultiscattering(e,t,r,s,n=null){const o=ge.dot(Ee).clamp(),a=Ca({roughness:Or,dotNV:o}),u=n?Qc.mix(s,n):s,l=u.mul(a.x).add(r.mul(a.y)),d=a.x.add(a.y).oneMinus(),h=u.add(u.oneMinus().mul(.047619)),f=l.mul(h).div(d.mul(h).oneMinus());e.addAssign(l),t.addAssign(f.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const n=ge.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(n.mul(UN({lightDirection:e})));const o=ai({normal:ge,viewDir:Ee,roughness:As}),a=ai({normal:ge,viewDir:e,roughness:As}),u=Gt.r.max(Gt.g).max(Gt.b).mul(o.max(a)).oneMinus();n.mulAssign(u)}if(this.clearcoat===!0){const a=Bs.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(Wm({lightDirection:e,f0:ui,f90:No,roughness:Ai,normalView:Bs})))}r.directDiffuse.addAssign(n.mul(In({diffuseColor:gn}))),r.directSpecular.addAssign(n.mul(DN({lightDirection:e,f0:_n,f90:1,roughness:Or,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:n,ltc_1:o,ltc_2:a}){const u=t.add(r).sub(s),l=t.sub(r).sub(s),c=t.sub(r).add(s),d=t.add(r).add(s),h=ge,f=Ee,p=je.toVar(),g=Lh({N:h,V:f,roughness:Or}),m=o.sample(g).toVar(),y=a.sample(g).toVar(),x=rt(C(m.x,0,m.y),C(0,1,0),C(m.z,0,m.w)).toVar(),_=_n.mul(y.x).add(xn.sub(_n).mul(y.y)).toVar();if(n.directSpecular.addAssign(e.mul(_).mul(Du({N:h,V:f,P:p,mInv:x,p0:u,p1:l,p2:c,p3:d}))),n.directDiffuse.addAssign(e.mul(gn).mul(Du({N:h,V:f,P:p,mInv:rt(1,0,0,0,1,0,0,0,1),p0:u,p1:l,p2:c,p3:d}))),this.clearcoat===!0){const N=Bs,A=Lh({N,V:f,roughness:Ai}),v=o.sample(A),S=a.sample(A),P=rt(C(v.x,0,v.y),C(0,1,0),C(v.z,0,v.w)),F=ui.mul(S.x).add(No.sub(ui).mul(S.y));this.clearcoatSpecularDirect.addAssign(e.mul(F).mul(Du({N,V:f,P:p,mInv:P,p0:u,p1:l,p2:c,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul(In({diffuseColor:gn})).toVar();if(this.sheen===!0){const n=ai({normal:ge,viewDir:Ee,roughness:As}),o=Gt.r.max(Gt.g).max(Gt.b).mul(n).oneMinus();s.mulAssign(o)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(r.mul(Gt,ai({normal:ge,viewDir:Ee,roughness:As}))),this.clearcoat===!0){const m=Bs.dot(Ee).clamp(),y=jm({dotNV:m,specularColor:ui,specularF90:No,roughness:Ai});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(y))}const n=C().toVar("singleScatteringDielectric"),o=C().toVar("multiScatteringDielectric"),a=C().toVar("singleScatteringMetallic"),u=C().toVar("multiScatteringMetallic");this.computeMultiscattering(n,o,xn,Gs,this.iridescenceF0Dielectric),this.computeMultiscattering(a,u,xn,Se.rgb,this.iridescenceF0Metallic);const l=xe(n,a,os),c=xe(o,u,os),d=n.add(o),h=gn.mul(d.oneMinus()),f=r.mul(1/Math.PI),p=t.mul(l).add(c.mul(f)).toVar(),g=h.mul(f).toVar();if(this.sheen===!0){const m=ai({normal:ge,viewDir:Ee,roughness:As}),y=Gt.r.max(Gt.g).max(Gt.b).mul(m).oneMinus();p.mulAssign(y),g.mulAssign(y)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,n=ge.dot(Ee).clamp().add(t),o=Or.mul(-16).oneMinus().negate().exp2(),a=t.sub(n.pow(o).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(a)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const r=Bs.dot(Ee).clamp(),s=$i({dotVH:r,f0:ui,f90:No}),n=t.mul(Jl.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Jl));t.assign(n)}if(this.sheen===!0){const r=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(r)}}}const Hh=w(1),mc=w(-2),wo=w(.8),Fu=w(-1),Ro=w(.4),Lu=w(2),Eo=w(.305),Uu=w(3),qh=w(.21),HN=w(4),Xh=w(4),qN=w(16),XN=R(([i])=>{const e=C(Ft(i)).toVar(),t=w(-1).toVar();return me(e.x.greaterThan(e.z),()=>{me(e.x.greaterThan(e.y),()=>{t.assign(Ut(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ut(i.y.greaterThan(0),1,4))})}).Else(()=>{me(e.z.greaterThan(e.y),()=>{t.assign(Ut(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ut(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),KN=R(([i,e])=>{const t=ee().toVar();return me(e.equal(0),()=>{t.assign(ee(i.z,i.y).div(Ft(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(ee(i.x.negate(),i.z.negate()).div(Ft(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(ee(i.x.negate(),i.y).div(Ft(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(ee(i.z.negate(),i.y).div(Ft(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(ee(i.x.negate(),i.z).div(Ft(i.y)))}).Else(()=>{t.assign(ee(i.x,i.y).div(Ft(i.z)))}),ae(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),YN=R(([i])=>{const e=w(0).toVar();return me(i.greaterThanEqual(wo),()=>{e.assign(Hh.sub(i).mul(Fu.sub(mc)).div(Hh.sub(wo)).add(mc))}).ElseIf(i.greaterThanEqual(Ro),()=>{e.assign(wo.sub(i).mul(Lu.sub(Fu)).div(wo.sub(Ro)).add(Fu))}).ElseIf(i.greaterThanEqual(Eo),()=>{e.assign(Ro.sub(i).mul(Uu.sub(Lu)).div(Ro.sub(Eo)).add(Lu))}).ElseIf(i.greaterThanEqual(qh),()=>{e.assign(Eo.sub(i).mul(HN.sub(Uu)).div(Eo.sub(qh)).add(Uu))}).Else(()=>{e.assign(w(-2).mul(jr(ae(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),QN=R(([i,e])=>{const t=i.toVar();t.assign(ae(2,t).sub(1));const r=C(t,1).toVar();return me(e.equal(0),()=>{r.assign(r.zyx)}).ElseIf(e.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZN=R(([i,e,t,r,s,n])=>{const o=w(t),a=C(e),u=hs(YN(o),mc,n),l=Sr(u),c=Os(u),d=C(zi(i,a,c,r,s,n)).toVar();return me(l.notEqual(0),()=>{const h=C(zi(i,a,c.add(1),r,s,n)).toVar();d.assign(xe(d,h,l))}),d}),zi=R(([i,e,t,r,s,n])=>{const o=w(t).toVar(),a=C(e),u=w(XN(a)).toVar(),l=w(st(Xh.sub(o),0)).toVar();o.assign(st(o,Xh));const c=w(Ii(o)).toVar(),d=ee(KN(a,u).mul(c.sub(2)).add(1)).toVar();return me(u.greaterThan(2),()=>{d.y.addAssign(c),u.subAssign(3)}),d.x.addAssign(u.mul(c)),d.x.addAssign(l.mul(ae(3,qN))),d.y.addAssign(ae(4,Ii(n).sub(c))),d.x.mulAssign(r),d.y.mulAssign(s),i.sample(d).grad(ee(),ee())}),Ou=R(({envMap:i,mipInt:e,outputDirection:t,theta:r,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const u=pr(r),l=t.mul(u).add(s.cross(t).mul(Dt(r))).add(s.mul(s.dot(t).mul(u.oneMinus())));return zi(i,l,e,n,o,a)}),JN=R(({n:i,latitudinal:e,poleAxis:t,outputDirection:r,weights:s,samples:n,dTheta:o,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d})=>{const h=C(Ut(e,t,$s(t,r))).toVar();me(h.equal(C(0)),()=>{h.assign(C(r.z,0,r.x.negate()))}),h.assign(Ht(h));const f=C().toVar();return f.addAssign(s.element(0).mul(Ou({theta:0,axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d}))),$t({start:Ue(1),end:i},({i:p})=>{me(p.greaterThanEqual(n),()=>{GS()});const g=w(o.mul(w(p))).toVar();f.addAssign(s.element(p).mul(Ou({theta:g.mul(-1),axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d}))),f.addAssign(s.element(p).mul(Ou({theta:g,axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d})))}),q(f,1)}),ew=R(([i])=>{const e=de(i).toVar();return e.assign(e.shiftLeft(de(16)).bitOr(e.shiftRight(de(16)))),e.assign(e.bitAnd(de(1431655765)).shiftLeft(de(1)).bitOr(e.bitAnd(de(2863311530)).shiftRight(de(1)))),e.assign(e.bitAnd(de(858993459)).shiftLeft(de(2)).bitOr(e.bitAnd(de(3435973836)).shiftRight(de(2)))),e.assign(e.bitAnd(de(252645135)).shiftLeft(de(4)).bitOr(e.bitAnd(de(4042322160)).shiftRight(de(4)))),e.assign(e.bitAnd(de(16711935)).shiftLeft(de(8)).bitOr(e.bitAnd(de(4278255360)).shiftRight(de(8)))),w(e).mul(23283064365386963e-26)}),tw=R(([i,e])=>ee(w(i).div(w(e)),ew(i))),rw=R(([i,e,t])=>{const r=t.mul(t).toConst(),s=C(1,0,0).toConst(),n=$s(e,s).toConst(),o=ds(i.x).toConst(),a=ae(2,3.14159265359).mul(i.y).toConst(),u=o.mul(pr(a)).toConst(),l=o.mul(Dt(a)).toVar(),c=ae(.5,e.z.add(1)).toConst();l.assign(c.oneMinus().mul(ds(u.mul(u).oneMinus())).add(c.mul(l)));const d=s.mul(u).add(n.mul(l)).add(e.mul(ds(st(0,u.mul(u).add(l.mul(l)).oneMinus()))));return Ht(C(r.mul(d.x),r.mul(d.y),st(0,d.z)))}),sw=R(({roughness:i,mipInt:e,envMap:t,N_immutable:r,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const u=C(r).toVar(),l=C(0).toVar(),c=w(0).toVar();return me(i.lessThan(.001),()=>{l.assign(zi(t,u,e,n,o,a))}).Else(()=>{const d=Ut(Ft(u.z).lessThan(.999),C(0,0,1),C(1,0,0)),h=Ht($s(d,u)).toVar(),f=$s(u,h).toVar();$t({start:de(0),end:s},({i:p})=>{const g=tw(p,s),m=rw(g,C(0,0,1),i),y=Ht(h.mul(m.x).add(f.mul(m.y)).add(u.mul(m.z))),x=Ht(y.mul(Vs(u,y).mul(2)).sub(u)),_=st(Vs(u,x),0);me(_.greaterThan(0),()=>{const N=zi(t,x,e,n,o,a);l.addAssign(N.mul(_)),c.addAssign(_)})}),me(c.greaterThan(0),()=>{l.assign(l.div(c))})}),q(l,1)}),us=4,Kh=[.125,.215,.35,.446,.526,.582],Ps=20,nw=512,li=new Lc(-1,1,1,-1,0,1),iw=new Li(90,1),Yh=new Kt;let Iu=null,ku=0,Gu=0;const ow=new V,Ma=new WeakMap,aw=[3,1,5,0,4,2],Vu=QN(Xs(),Wt("faceIndex")).normalize(),Ya=C(Vu.x,Vu.y,Vu.z);class uw{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,n={}){const{size:o=256,position:a=ow,renderTarget:u=null}=n;if(this._setSize(o),this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Iu=this._renderer.getRenderTarget(),ku=this._renderer.getActiveCubeFace(),Gu=this._renderer.getActiveMipmapLevel();const l=u||this._allocateTarget(!0);return this._init(l),this._sceneToCubeUV(e,r,s,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,r=.1,s=100,n={}){return Be('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,n)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Be('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Be('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zh(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Jh(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Ta||e.mapping===va?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?y:0,y,y),l.render(e,o)}l.autoClear=c,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===Ta||e.mapping===va;s?this._cubemapMaterial===null&&(this._cubemapMaterial=Zh(e)):this._equirectMaterial===null&&(this._equirectMaterial=Jh(e));const n=s?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=n;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(o,li)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let n=1;np-us?r-p+us:0),y=4*(this._cubeSize-g);e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.roughness.value=f,u.mipInt.value=p-t,this._setViewport(n,m,y,3*g,2*g),s.setRenderTarget(n),s.render(a,li),n.texture.frame=(n.texture.frame||0)+1,u.envMap.value=n.texture,u.roughness.value=0,u.mipInt.value=p-r,this._setViewport(e,m,y,3*g,2*g),s.setRenderTarget(e),s.render(a,li)}_blur(e,t,r,s,n){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,r,s,"latitudinal",n),this._halfBlur(o,e,r,r,s,"longitudinal",n)}_halfBlur(e,t,r,s,n,o,a){const u=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&O("blur direction must be either latitudinal or longitudinal!");const c=3,d=this._lodMeshes[s];d.material=l;const h=Ma.get(l),f=this._sizeLods[r]-1,p=isFinite(n)?Math.PI/(2*f):2*Math.PI/(2*Ps-1),g=n/p,m=isFinite(n)?1+Math.floor(c*g):Ps;m>Ps&&z(`sigmaRadians, ${n}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ps}`);const y=[];let x=0;for(let S=0;S_-us?s-_+us:0),v=4*(this._cubeSize-N);this._setViewport(t,A,v,3*N,2*N),u.setRenderTarget(t),u.render(d,li)}_setViewport(e,t,r,s,n){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-n-r,s,n),e.scissor.set(t,e.height-n-r,s,n)):(e.viewport.set(t,r,s,n),e.scissor.set(t,r,s,n))}}function lw(i){const e=[],t=[],r=[];let s=i;const n=i-us+1+Kh.length;for(let o=0;oi-us?u=Kh[o-i+us-1]:o===0&&(u=0),t.push(u);const l=1/(a-2),c=-l,d=1+l,h=[c,c,d,c,d,d,c,c,d,d,c,d],f=6,p=6,g=3,m=2,y=1,x=new Float32Array(g*p*f),_=new Float32Array(m*p*f),N=new Float32Array(y*p*f);for(let v=0;v2?0:-1,F=[S,P,0,S+2/3,P,0,S+2/3,P+1,0,S,P,0,S+2/3,P+1,0,S,P+1,0],U=aw[v];x.set(F,g*p*U),_.set(h,m*p*U);const W=[U,U,U,U,U,U];N.set(W,y*p*U)}const A=new Hi;A.setAttribute("position",new ea(x,g)),A.setAttribute("uv",new ea(_,m)),A.setAttribute("faceIndex",new ea(N,y)),r.push(new sr(A,null)),s>us&&s--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function Qh(i,e,t){const r={magFilter:yt,minFilter:yt,generateMipmaps:!1,type:ht,format:er,colorSpace:f_,depthBuffer:t},s=new ps(i,e,r);return s.texture.mapping=pa,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Qa(i){const e=new qe;return e.depthTest=!1,e.depthWrite=!1,e.blending=Wr,e.name=`PMREM_${i}`,e}function cw(i,e,t){const r=Tt(new Array(Ps).fill(0)),s=K(new V(0,1,0)),n=K(0),o=w(Ps),a=K(0),u=K(1),l=Ne(),c=K(0),d=w(1/e),h=w(1/t),f=w(i),p={n:o,latitudinal:a,weights:r,poleAxis:s,outputDirection:Ya,dTheta:n,samples:u,envMap:l,mipInt:c,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:f},g=Qa("blur");return g.fragmentNode=JN({...p,latitudinal:a.equal(1)}),Ma.set(g,p),g}function dw(i,e,t){const r=Ne(),s=K(0),n=K(0),o=w(1/e),a=w(1/t),u=w(i),l={envMap:r,roughness:s,mipInt:n,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:u},c=Qa("ggx");return c.fragmentNode=sw({...l,N_immutable:Ya,GGX_SAMPLES:de(nw)}),Ma.set(c,l),c}function Zh(i){const e=Qa("cubemap");return e.fragmentNode=vt(i,Ya),e}function Jh(i){const e=Qa("equirect");return e.fragmentNode=Ne(i,Om(Ya),0),e}const ef=new WeakMap;function hw(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function fw(i,e,t){const r=pw(e);let s=r.get(i);if((s!==void 0?s.pmremVersion:-1)!==i.pmremVersion){const o=i.image;if(i.isCubeTexture)if(mw(o))s=t.fromCubemap(i,s);else return null;else if(yw(o))s=t.fromEquirectangular(i,s);else return null;if(s.pmremVersion=i.pmremVersion,r.has(i)===!1){const a=()=>{i.removeEventListener("dispose",a);const u=r.get(i);u!==void 0&&(u.dispose(),r.delete(i))};i.addEventListener("dispose",a)}r.set(i,s)}return s.texture}function pw(i){let e=ef.get(i);return e===void 0&&(e=new WeakMap,ef.set(i,e)),e}class gw extends Xe{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new Ic;s.isRenderTargetTexture=!0,this._texture=Ne(s),this._width=K(0),this._height=K(0),this._maxMip=K(0),this.updateBeforeType=re.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=hw(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(s.isPMREMTexture===!0||s.mapping===pa?t=s:t=fw(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new uw(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?oc.mul(C(t.x,t.y.negate(),t.z)):oc.mul(t);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZN(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function mw(i){if(i==null)return!1;let e=0;const t=6;for(let r=0;r0}const Km=Pe(gw).setParameterLength(1,3),tf=new WeakMap;class bw extends Xn{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const d=r.isTextureNode?r.value:t[r.property],h=this._getPMREMNodeCache(e.renderer);let f=h.get(d);f===void 0&&(f=Km(d),h.set(d,f)),r=f}const n=t.useAnisotropy===!0||t.anisotropy>0?j0:ge,o=r.context(rf(Or,n)).mul(Cu),a=r.context(_w(qn)).mul(Math.PI).mul(Cu),u=Mi(o),l=Mi(a);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(l);const c=e.context.lightingModel.clearcoatRadiance;if(c){const d=r.context(rf(Ai,Bs)).mul(Cu),h=Mi(d);c.addAssign(h)}}_getPMREMNodeCache(e){let t=tf.get(e);return t===void 0&&(t=new WeakMap,tf.set(e,t)),t}}const rf=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Ee.negate().reflect(e),t=$g(i).mix(t,e).normalize(),t=t.transformDirection(ld)),t),getTextureLevel:()=>i}},_w=i=>({getUV:()=>i,getTextureLevel:()=>w(1)}),xw=new Tb;class Ym extends qe{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(xw),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new bw(t):null}setupLightingModel(){return new Xm}setupSpecular(){const e=xe(C(.04),Se.rgb,os);Gs.assign(C(.04)),_n.assign(e),xn.assign(1)}setupVariants(){const e=this.metalnessNode?w(this.metalnessNode):iS;os.assign(e);let t=this.roughnessNode?w(this.roughnessNode):nS;t=zm({roughness:t}),Or.assign(t),this.setupSpecular(),gn.assign(Se.rgb.mul(e.oneMinus()))}}const Tw=new vb;class vw extends Ym{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(Tw),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?w(this.iorNode):_S;aa.assign(e),Gs.assign(Ln(Vg(aa.sub(1).div(aa.add(1))).mul(sS),C(1)).mul(Nh)),_n.assign(xe(Gs,Se.rgb,os)),xn.assign(xe(Nh,1,os))}setupLightingModel(){return new Xm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?w(this.clearcoatNode):aS,r=this.clearcoatRoughnessNode?w(this.clearcoatRoughnessNode):uS;Jl.assign(t),Ai.assign(zm({roughness:r}))}if(this.useSheen){const t=this.sheenNode?C(this.sheenNode):dS,r=this.sheenRoughnessNode?w(this.sheenRoughnessNode):hS;Gt.assign(t),As.assign(r)}if(this.useIridescence){const t=this.iridescenceNode?w(this.iridescenceNode):pS,r=this.iridescenceIORNode?w(this.iridescenceIORNode):gS,s=this.iridescenceThicknessNode?w(this.iridescenceThicknessNode):mS;Qc.assign(t),ec.assign(r),tc.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?ee(this.anisotropyNode):fS).toVar();ws.assign(t.length()),me(ws.equal(0),()=>{t.assign(ee(1,0))}).Else(()=>{t.divAssign(ee(ws)),ws.assign(ws.saturate())}),rc.assign(ws.pow2().mix(Or.pow2(),1)),oa.assign(Ti[0].mul(t.x).add(Ti[1].mul(t.y))),Rn.assign(Ti[1].mul(t.x).sub(Ti[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?w(this.transmissionNode):yS,r=this.thicknessNode?w(this.thicknessNode):bS,s=this.attenuationDistanceNode?w(this.attenuationDistanceNode):xS,n=this.attenuationColorNode?C(this.attenuationColorNode):TS;if(nc.assign(t),Eg.assign(r),Ag.assign(s),Cg.assign(n),this.useDispersion){const o=this.dispersionNode?w(this.dispersionNode):SS;Mg.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?C(this.clearcoatNormalNode):lS}setup(e){e.context.setupClearcoatNormal=()=>An(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}}const Sw=R(({normal:i,lightDirection:e,builder:t})=>{const r=i.dot(e),s=ee(r.mul(.5).add(.5),0);if(t.material.gradientMap){const n=ns("gradientMap","texture").context({getUV:()=>s});return C(n.r)}else{const n=s.fwidth().mul(.5);return xe(C(.7),C(1),nr(w(.7).sub(n.x),w(.7).add(n.x),s.x))}});class Nw extends Xa{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const n=Sw({normal:am,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(n.mul(In({diffuseColor:Se.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(In({diffuseColor:Se}))),s.indirectDiffuse.mulAssign(t)}}const ww=new Sb;class Rw extends qe{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ww),this.setValues(e)}setupLightingModel(){return new Nw}}const Ew=R(()=>{const i=C(Ee.z,0,Ee.x.negate()).normalize(),e=Ee.cross(i);return ee(i.dot(ge),e.dot(ge)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Aw=new wb;class Cw extends qe{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Aw),this.setValues(e)}setupVariants(e){const t=Ew;let r;e.material.matcap?r=ns("matcap","texture").context({getUV:()=>t}):r=C(xe(.2,.8,t.y)),Se.rgb.mulAssign(r.rgb)}}class Mw extends Xe{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if(this.getNodeType(e)==="vec2"){const n=t.cos(),o=t.sin();return Yc(n,o,o.negate(),n).mul(r)}else{const n=t,o=Us(q(1,0,0,0),q(0,pr(n.x),Dt(n.x).negate(),0),q(0,Dt(n.x),pr(n.x),0),q(0,0,0,1)),a=Us(q(pr(n.y),0,Dt(n.y),0),q(0,1,0,0),q(Dt(n.y).negate(),0,pr(n.y),0),q(0,0,0,1)),u=Us(q(pr(n.z),Dt(n.z).negate(),0,0),q(Dt(n.z),pr(n.z),0,0),q(0,0,1,0),q(0,0,0,1));return o.mul(a).mul(u).mul(q(r,1)).xyz}}}const Qm=Pe(Mw).setParameterLength(2),Bw=new Ab;class Zm extends qe{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Bw),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:n,scaleNode:o,sizeAttenuation:a}=this,u=Ws.mul(C(s||0));let l=ee(zs[0].xyz.length(),zs[1].xyz.length());o!==null&&(l=l.mul(ee(o))),r.isPerspectiveCamera&&a===!1&&(l=l.mul(u.z.negate()));let c=mt.xy;if(t.center&&t.center.isVector2===!0){const f=$v("center","vec2",t);c=c.sub(f.sub(.5))}c=c.mul(l);const d=w(n||cS),h=Qm(c,d);return q(u.xy.add(h),u.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pw=new Eb,Dw=new ce;class Fw extends Zm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pw),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ws.mul(C(e||Qe)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:n,sizeNode:o,sizeAttenuation:a}=this;let u=super.setupVertex(e);if(t.isNodeMaterial!==!0)return u;let l=o!==null?ee(o):vS;l=l.mul(nm),r.isPerspectiveCamera&&a===!0&&(l=l.mul(Lw.div(je.z.negate()))),n&&n.isNode&&(l=l.mul(ee(n)));let c=mt.xy;if(s&&s.isNode){const d=w(s);c=Qm(c,d)}return c=c.mul(l),c=c.div(b0.div(2)),c=c.mul(u.w),u=u.add(q(c,0,0)),u}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const Lw=K(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(Dw);this.value=.5*e.y});class Uw extends Xa{constructor(){super(),this.shadowNode=w(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Se.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Se.rgb)}}const Ow=new Cb;class Iw extends qe{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Ow),this.setValues(e)}setupLightingModel(){return new Uw}}gs("vec3");gs("vec3");gs("vec3");class kw{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class fs{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return r===void 0&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,n={};for(const o of e){let a;if(o.node&&o.node.attribute?a=o.node.attribute:(a=t.getAttribute(o.name),a!==void 0&&(a.isInterleavedBufferAttribute?n[o.name]=a.data.uuid:n[o.name]=a.id)),a===void 0)continue;r.push(a);const u=a.isInterleavedBufferAttribute?a.data:a;s.add(u)}return this.attributes=r,this.attributesId=n,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:n}=this,o=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),u=a!==null;let l=1;if(r.isInstancedBufferGeometry===!0?l=r.instanceCount:e.count!==void 0&&(l=Math.max(0,e.count)),l===0)return null;if(o.instanceCount=l,e.isBatchedMesh===!0)return o;let c=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(c=2);let d=n.start*c,h=(n.start+n.count)*c;s!==null&&(d=Math.max(d,s.start*c),h=Math.min(h,(s.start+s.count)*c));const f=r.attributes.position;let p=1/0;u?p=a.count:f!=null&&(p=f.count),d=Math.max(d,0),h=Math.min(h,p);const g=h-d;return g<0||g===1/0?null:(o.vertexCount=g,o.firstVertex=d,o)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let n=0,o=s.length;n1)&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Vn(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(r===void 0)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ri(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ri(e,1)),e=Ri(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const cr=[];class zw{constructor(e,t,r,s,n,o){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=n,this.info=o,this.chainMaps={}}get(e,t,r,s,n,o,a,u){const l=this.getChainMap(u);cr[0]=e,cr[1]=t,cr[2]=o,cr[3]=n;let c=l.get(cr);return c===void 0?(c=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,n,o,a,u),l.set(cr,c)):(c.camera=s,c.updateClipping(a),c.needsGeometryUpdate&&c.setGeometry(e.geometry),(c.version!==t.version||c.needsUpdate)&&(c.initialCacheKey!==c.getCacheKey()?(c.dispose(),c=this.get(e,t,r,s,n,o,a,u)):c.version=t.version)),cr[0]=null,cr[1]=null,cr[2]=null,cr[3]=null,c}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new fs)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,n,o,a,u,l,c,d){const h=this.getChainMap(d),f=new $w(e,t,r,s,n,o,a,u,l,c);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),h.delete(f.getChainArray())},f}}class ms{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const jt={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},is=16,Ww=211,jw=212;class Hw extends ms{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(r.version===void 0)t===jt.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===jt.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===jt.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===jt.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(r.version=65535?Pb:Db)(e,1);return s.version=Jm(i),s.__id=ey(i),s}class qw extends ms{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,r=this.get(t);r.initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const n=t.index,o=e.getAttributes();n!==null&&this.attributes.delete(n);for(const u of o)this.attributes.delete(u);const a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",s),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",s),this._geometryDisposeListeners.set(t,s)}updateAttributes(e){const t=e.getAttributes();for(const n of t)n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute?this.updateAttribute(n,jt.STORAGE):this.updateAttribute(n,jt.VERTEX);const r=this.getIndex(e);r!==null&&this.updateAttribute(r,jt.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,jt.INDIRECT)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(r.wireframe===!0){const n=this.wireframes;let o=n.get(t);o===void 0?(o=nf(t),n.set(t,o)):(o.version!==Jm(t)||o.__id!==ey(t))&&(this.attributes.delete(o),o=nf(t),n.set(t,o)),s=o}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Xw{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):O("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Tn||e.type===St?t=1:e.type===vn||e.type===Fs||e.type===ht?t=2:(e.type===Ze||e.type===Ge||e.type===dt)&&(t=4);let r=4;e.format===dp||e.format===qi||e.format===Xi||e.format===Vr||e.format===$r?r=1:e.format===tr||e.format===Ki?r=2:(e.format===Yi||e.format===Mc)&&(r=3);let s=t*r;e.type===hp||e.type===fp?s=2:(e.type===zr||e.type===Bc||e.type===Pc)&&(s=4);const n=e.width||1,o=e.height||1,a=e.isCubeTexture?6:e.depth||1;let u=n*o*a*s;const l=e.mipmaps;if(l&&l.length>0){let c=0;for(let d=0;d>d),p=h.height||Math.max(1,o>>d);c+=f*p*a*s}}u+=c}else e.generateMipmaps&&(u=u*1.333);return Math.round(u)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class ty{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Kw extends ty{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Yw extends ty{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Qw=0;class $u{constructor(e,t,r,s=null,n=null){this.id=Qw++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=n,this.usedTimes=0}}class Zw extends ms{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const n=s.pipeline;n&&(n.usedTimes--,n.computeProgram.usedTimes--);const o=this.nodes.getForCompute(e);let a=this.programs.compute.get(o.computeShader);a===void 0&&(n&&n.computeProgram.usedTimes===0&&this._releaseProgram(n.computeProgram),a=new $u(o.computeShader,"compute",e.name,o.transforms,o.nodeAttributes),this.programs.compute.set(o.computeShader,a),r.createProgram(a),this.info.createProgram(a));const u=this._getComputeCacheKey(e,a);let l=this.caches.get(u);l===void 0&&(n&&n.usedTimes===0&&this._releasePipeline(n),l=this._getComputePipeline(e,a,u,t)),l.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=l}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const n=s.pipeline;n&&(n.usedTimes--,n.vertexProgram.usedTimes--,n.fragmentProgram.usedTimes--);const o=e.getNodeBuilderState(),a=e.material?e.material.name:"";let u=this.programs.vertex.get(o.vertexShader);u===void 0&&(n&&n.vertexProgram.usedTimes===0&&this._releaseProgram(n.vertexProgram),u=new $u(o.vertexShader,"vertex",a),this.programs.vertex.set(o.vertexShader,u),r.createProgram(u),this.info.createProgram(u));let l=this.programs.fragment.get(o.fragmentShader);l===void 0&&(n&&n.fragmentProgram.usedTimes===0&&this._releaseProgram(n.fragmentProgram),l=new $u(o.fragmentShader,"fragment",a),this.programs.fragment.set(o.fragmentShader,l),r.createProgram(l),this.info.createProgram(l));const c=this._getRenderCacheKey(e,u,l);let d=this.caches.get(c);d===void 0?(n&&n.usedTimes===0&&this._releasePipeline(n),d=this._getRenderPipeline(e,u,l,c,t)):e.pipeline=d,d.usedTimes++,u.usedTimes++,l.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const r=this.get(e).pipeline;if(r===void 0)return!1;const s=this.backend.get(r);return s.pipeline!==void 0&&s.pipeline!==null}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let n=this.caches.get(r);return n===void 0&&(n=new Yw(r,t),this.caches.set(r,n),this.backend.createComputePipeline(n,s)),n}_getRenderPipeline(e,t,r,s,n){s=s||this._getRenderCacheKey(e,t,r);let o=this.caches.get(s);return o===void 0&&(o=new Kw(s,t,r),this.caches.set(s,o),e.pipeline=o,this.backend.createRenderPipeline(e,n)),o}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Jw extends ms{constructor(e,t,r,s,n,o){super(),this.backend=e,this.textures=r,this.pipelines=n,this.attributes=s,this.nodes=t,this.info=o,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return r.initialized!==!0&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return(r.initialized!==!0||r.bindings!==t)&&(r.bindings!==void 0&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const r=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(r),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(r.bindGroup===void 0){for(const s of t.bindings)if(s.isUniformBuffer)this.backend.createUniformBuffer(s),this.info.createUniformBuffer(s);else if(s.isSampledTexture)this.textures.updateTexture(s.texture);else if(s.isSampler)this.textures.updateSampler(s);else if(s.isStorageBuffer){const n=s.attribute,o=n.isIndirectStorageBufferAttribute?jt.INDIRECT:jt.STORAGE;this.attributes.update(n,o)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const r=this.get(t);if(r.usedTimes--,r.usedTimes===0){for(const s of t.bindings)s.isUniformBuffer?(this.backend.destroyUniformBuffer(s),this.info.destroyUniformBuffer(s),s.release()):s.isSampler&&(s.isSampledTexture!==!0&&this.backend.destroySampler(s),s.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,n=!0,o=0,a=0;for(const u of e.bindings)if(this.nodes.updateGroup(u)!==!1){if(u.isStorageBuffer){const c=u.attribute,d=c.isIndirectStorageBufferAttribute?jt.INDIRECT:jt.STORAGE,h=r.get(u);this.attributes.update(c,d),h.attribute!==c&&(h.attribute=c,s=!0)}if(u.isUniformBuffer)u.update()&&r.updateBinding(u);else if(u.isSampledTexture){const c=u.update(),d=u.texture,h=this.textures.get(d);if(c&&(this.textures.updateTexture(d),u.generation!==h.generation&&(u.generation=h.generation,s=!0),h.bindGroups.add(e)),r.get(d).externalTexture!==void 0||h.isDefaultTexture?n=!1:(o=o*10+d.id,a+=d.version),d.isStorageTexture===!0&&d.mipmapsAutoUpdate===!0){const p=this.get(d);u.store===!0?p.needsMipmap=!0:this.textures.needsMipmaps(d)&&p.needsMipmap===!0&&(this.backend.generateMipmaps(d),p.needsMipmap=!1)}}else if(u.isSampler&&u.update()){const d=this.textures.updateSampler(u);u.samplerKey!==d&&(u.samplerKey=d,s=!0)}u.isBuffer&&u.updateRanges.length>0&&u.clearUpdateRanges()}s===!0&&this.backend.updateBindings(e,t,n?o:0,a)}}const eR=Object.freeze([]);function tR(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?i.z-e.z:i.id-e.id}function of(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function af(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===Gr&&i.forceSinglePass===!1}class rR{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,n,o,a){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:n,group:o,clippingContext:a},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=r,u.groupOrder=s,u.renderOrder=e.renderOrder,u.z=n,u.group=o,u.clippingContext=a),this.renderItemsIndex++,u}push(e,t,r,s,n,o,a){const u=this.getNextRenderItem(e,t,r,s,n,o,a);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(af(r)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,r,s,n,o,a){const u=this.getNextRenderItem(e,t,r,s,n,o,a);r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(af(r)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,r){this.opaque.length>1&&this.opaque.sort(e||tR),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||of),this.transparent.length>1&&this.transparent.sort(t||of),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:eR);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,l=a.height>>t;let c=e.depthTexture||n[t];const d=e.depthBuffer===!0||e.stencilBuffer===!0;let h=!1;const f=c!==void 0&&c.image!==void 0&&c.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||f);c===void 0&&d&&(c=new xr,c.format=e.stencilBuffer?$r:Vr,c.type=e.stencilBuffer?zr:Ge,c.image.width=u,c.image.height=l,c.image.depth=a.depth,c.renderTarget=e,n[t]=c),c&&(c.isArrayTexture=p),(r.width!==a.width||a.height!==r.height)&&(h=!0,c&&(c.needsUpdate=!0,c.image.width=u,c.image.height=l,c.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=o,r.depthTexture=c||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(h=!0,c&&(c.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(e.isXRRenderTarget!==!0){for(let m=0;m{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(r.initialized===!0&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,n=this.backend;if(s&&r.initialized===!0&&n.destroyTexture(e),e.isFramebufferTexture){const l=this.renderer.getRenderTarget();l?e.type=l.texture.type:e.type=St}if(e.isHTMLTexture&&e.image){const l=this.renderer.domElement;if("requestPaint"in l){if(l.hasAttribute("layoutsubtree")||l.setAttribute("layoutsubtree","true"),e.image.parentNode!==l&&l.appendChild(e.image),this._htmlTextures.size===0){const c=this._htmlTextures;l.onpaint=d=>{const h=d&&d.changedElements;for(const f of c)(!h||h.includes(f.image))&&(f.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:o,height:a,depth:u}=this.getSize(e);if(t.width=o,t.height=a,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,o,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||e.isStorageTexture===!0||e.isExternalTexture===!0)n.createTexture(e,t),r.generation=e.version;else if(e.version>0){const l=e.image;if(l===void 0)z("Renderer: Texture marked for update but image is undefined.");else if(l.complete===!1)z("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const d=[];for(const h of e.images)d.push(h);t.images=d}else t.image=l;(r.isDefaultTexture===void 0||r.isDefaultTexture===!0)&&(n.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),e.source.dataReady===!0&&n.updateTexture(e,t);const c=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!c&&n.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else n.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;r.initialized!==!0&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&We.enabled===!0&&We.getTransfer(e.colorSpace)!==oe&&z("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=aR){let r=e.images?e.images[0]:e.image;return r?(r.image!==void 0&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let n=0;n{s.isOverrideContextNode===!0&&e.push(s.value.overrideNodes)});const t=new Map(e.flatMap(s=>Array.from(s.entries()))),r=super.getFlowContextData();return r.overrideNodes=t,r}}function lR(i,e=null,t=null){if(e&&e.isNode){const r=e;e=()=>r}return new sy(new Map([[i,e]]),t)}E("overrideNode",(i,e,t)=>lR(e,t,i));function cR(i,e=null){const t=new Map;for(const[r,s]of i){const n=s!==null?typeof s=="function"?s:()=>s:null;t.set(r,n)}return new sy(t,e)}E("overrideNodes",(i,e)=>cR(e,i));class dR extends be{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const r=this.getNodeType(e),s=e.getStructTypeNode(r);let n;return s!==null?n=s.getMemberType(e,t):(O(`TSL: Member "${t}" not found in struct "${r}".`,new bt),n="float"),n}getHash(){return String(this.id)}generate(){return this.name}}class hR extends J{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(e.isNode!==!0)return O("TSL: Invalid node added to stack.",new bt),this;if(t===-1)if(this._currentNode){let r=this._nodeDataLibrary.get(this._currentNode);r===void 0&&(r={delta:0},this._nodeDataLibrary.set(this._currentNode,r)),r.delta++,t=this.nodes.indexOf(this._currentNode)+r.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const r=new xi(t);return this._currentCond=Ut(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){const r=new xi(t),s=Ut(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new xi(e),this}Switch(e){return this._expressionNode=H(e),this}Case(...e){const t=[];if(e.length>=2)for(let a=0;anew ny(i,"uint","float"),Ao={};class Is extends T{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){r==="int"?t.assign(fR(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return de;case"int":return Ue;case"uvec2":return vg;case"uvec3":return Ng;case"uvec4":return Rg;case"ivec2":return Nt;case"ivec3":return Sg;case"ivec4":return wg}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{const o=de(0);this._resolveElementType(n,o,t);const a=w(o.bitAnd(Og(o))),l=pR(a).shiftRight(23).sub(127);return r(l)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{me(n.equal(de(0)),()=>de(32));const o=de(0),a=de(0);return this._resolveElementType(n,o,t),me(o.shiftRight(16).equal(0),()=>{a.addAssign(16),o.shiftLeftAssign(16)}),me(o.shiftRight(24).equal(0),()=>{a.addAssign(8),o.shiftLeftAssign(8)}),me(o.shiftRight(28).equal(0),()=>{a.addAssign(4),o.shiftLeftAssign(4)}),me(o.shiftRight(30).equal(0),()=>{a.addAssign(2),o.shiftLeftAssign(2)}),me(o.shiftRight(31).equal(0),()=>{a.addAssign(1)}),r(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{const o=de(0);this._resolveElementType(n,o,t),o.assign(o.sub(o.shiftRight(de(1)).bitAnd(de(1431655765)))),o.assign(o.bitAnd(de(858993459)).add(o.shiftRight(de(2)).bitAnd(de(858993459))));const a=o.add(o.shiftRight(de(4))).bitAnd(de(252645135)).mul(de(16843009)).shiftRight(de(24));return r(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const n=this._returnDataNode(t);return R(([a])=>{if(r===1)return n(s(a));{const u=n(0),l=["x","y","z","w"];for(let c=0;cd(r))()}}Is.COUNT_TRAILING_ZEROS="countTrailingZeros";Is.COUNT_LEADING_ZEROS="countLeadingZeros";Is.COUNT_ONE_BITS="countOneBits";new At;const gR=new ps;as.flipX();gR.depthTexture=new xr(1,1);const Wu=new Lc(-1,1,1,-1,0,1);class mR extends Hi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new _a([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _a(t,2))}}const yR=new mR;class iy extends sr{constructor(e=null){super(yR,e),this.camera=Wu,this.isQuadMesh=!0}async renderAsync(e){Be('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,Wu)}render(e){e.render(this,Wu)}}const oy=R(([i])=>Sr(w(52.9829189).mul(Sr(Vs(i,ee(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),mr=R(([i,e,t])=>{const r=w(2.399963229728653),s=ds(w(i).add(.5).div(w(e))),n=w(i).mul(r).add(t);return ee(pr(n),Dt(n)).mul(s)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),ju=new At,bR=K(0).setGroup(Z).onRenderUpdate(({scene:i})=>i.backgroundBlurriness),uf=K(1).setGroup(Z).onRenderUpdate(({scene:i})=>i.backgroundIntensity),_R=K(new At).setGroup(Z).onRenderUpdate(({scene:i})=>{const e=i.background;return e!==null&&e.isTexture&&e.mapping!==Bb||i.backgroundNode&&i.backgroundNode.isNode?ju.makeRotationFromEuler(i.backgroundRotation).transpose():ju.identity(),ju});R(({texture:i,uv:e})=>{const r=C().toVar();return me(e.x.lessThan(1e-4),()=>{r.assign(C(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{r.assign(C(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{r.assign(C(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{r.assign(C(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{r.assign(C(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{r.assign(C(0,0,-1))}).Else(()=>{const n=i.sample(e.add(C(-.01,0,0))).r.sub(i.sample(e.add(C(.01,0,0))).r),o=i.sample(e.add(C(0,-.01,0))).r.sub(i.sample(e.add(C(0,.01,0))).r),a=i.sample(e.add(C(0,0,-.01))).r.sub(i.sample(e.add(C(0,0,.01))).r);r.assign(C(n,o,a))}),r.normalize()});R(([i,e])=>i.mul(e).floor().div(e));const Co=new ce;class xR extends to{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class lf extends xR{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class Wi extends Xe{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const n=new ps(this._width,this._height,{type:ht,...s});n.texture.name="output";let o=null;(this.scope===Wi.DEPTH||s.depthBuffer!==!1)&&(o=new xr,o.isRenderTargetTexture=!0,o.name="depth",n.depthTexture=o),this.renderTarget=n,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:n.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=K(0),this._cameraFar=K(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=re.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return z("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return z("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e==="depth")throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new lf(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new lf(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=hd(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=Cn(n,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),e.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=dt),this.scope===Wi.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const n=t.getOutputRenderTarget();n&&n.isXRRenderTarget===!0?(s=t.xr.getCamera(),t.xr.updateCamera(s),Co.set(n.width,n.height)):(s=this.camera,t.getDrawingBufferSize(Co)),this.setSize(Co.width,Co.height);const o=t.getRenderTarget(),a=t.getMRT(),u=t.autoClear,l=t.transparent,c=t.opaque,d=s.layers.mask,h=t.contextNode,f=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Hs({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=f,t.setRenderTarget(o),t.setMRT(a),t.autoClear=u,t.transparent=l,t.opaque=c,t.contextNode=h,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),this._scissor!==null?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new He),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,s))}setViewport(e,t,r,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new He),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,s))}dispose(){this.renderTarget.dispose()}}Wi.COLOR="color";Wi.DEPTH="depth";const TR=R(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),vR=R(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SR=R(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),r=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),NR=R(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),wR=R(([i,e])=>{const t=rt(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=rt(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=NR(i),i=r.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),RR=rt(C(1.6605,-.1246,-.0182),C(-.5876,1.1329,-.1006),C(-.0728,-.0083,1.1187)),ER=rt(C(.6274,.0691,.0164),C(.3293,.9195,.088),C(.0433,.0113,.8956)),AR=R(([i])=>{const e=C(i).toVar(),t=C(e.mul(e)).toVar(),r=C(t.mul(t)).toVar();return w(15.5).mul(r.mul(t)).sub(ae(40.14,r.mul(e))).add(ae(31.96,r).sub(ae(6.868,t.mul(e))).add(ae(.4298,t).add(ae(.1191,e).sub(.00232))))}),CR=R(([i,e])=>{const t=C(i).toVar(),r=rt(C(.856627153315983,.137318972929847,.11189821299995),C(.0951212405381588,.761241990602591,.0767994186031903),C(.0482516061458583,.101439036467562,.811302368396859)),s=rt(C(1.1271005818144368,-.1413297634984383,-.14132976349843826),C(-.11060664309660323,1.157823702216272,-.11060664309660294),C(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=w(-12.47393),o=w(4.026069);return t.mulAssign(e),t.assign(ER.mul(t)),t.assign(r.mul(t)),t.assign(st(t,1e-10)),t.assign(jr(t)),t.assign(t.sub(n).div(o.sub(n))),t.assign(hs(t,0,1)),t.assign(AR(t)),t.assign(s.mul(t)),t.assign(qa(st(C(0),t),C(2.2))),t.assign(RR.mul(t)),t.assign(hs(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MR=R(([i,e])=>{const t=w(.76),r=w(.15);i=i.mul(e);const s=Ln(i.r,Ln(i.g,i.b)),n=Ut(s.lessThan(.08),s.sub(ae(6.25,s.mul(s))),.04);i.subAssign(n);const o=st(i.r,st(i.g,i.b));me(o.lessThan(t),()=>i);const a=xt(1,t),u=xt(1,a.mul(a).div(o.add(a.sub(t))));i.mulAssign(u.div(o));const l=xt(1,vr(1,r.mul(o.sub(u)).add(1)));return xe(i,C(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Fe extends J{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}class BR extends Fe{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return r===void 0&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,n=r.type,o=e.getCodeFromNode(this,n);s!==""&&(o.name=s);const a=e.getPropertyName(o),u=this.getNodeFunction(e).getCode(a);return o.code=u+` +`,t==="property"?a:e.format(`${a}()`,n,t)}}function md(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||je.z).negate()}const PR=R(([i,e],t)=>{const r=md(t);return nr(i,e,r)}),DR=R(([i],e)=>{const t=md(e);return i.mul(i,t,t).negate().exp().oneMinus()});R(([i,e],t)=>{const r=md(t),n=e.sub(On.y).max(0).toConst().mul(r).toConst();return i.mul(i,n,n).negate().exp().oneMinus()});const cf=R(([i,e])=>q(e.toFloat().mix(Ci.rgb,i.toVec3()),Ci.a));class FR extends J{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;r.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}Pe(FR);class Rr extends J{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,n=this.getNodeType(e),o=this.getInputType(e),a=this.pointerNode,u=this.valueNode,l=[];l.push(`&${a.build(e,o)}`),u!==null&&l.push(u.build(e,o));const c=`${e.getMethod(s,n)}( ${l.join(", ")} )`;if(r?r.length===1&&r[0].isStackNode===!0:!1)e.addLineFlowCode(c,this);else return t.constNode===void 0&&(t.constNode=gr(c,n).toConst()),t.constNode.build(e)}}Rr.ATOMIC_LOAD="atomicLoad";Rr.ATOMIC_STORE="atomicStore";Rr.ATOMIC_ADD="atomicAdd";Rr.ATOMIC_SUB="atomicSub";Rr.ATOMIC_MAX="atomicMax";Rr.ATOMIC_MIN="atomicMin";Rr.ATOMIC_AND="atomicAnd";Rr.ATOMIC_OR="atomicOr";Rr.ATOMIC_XOR="atomicXor";Pe(Rr);class ye extends Xe{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(r)?0:e.getTypeLength(r);return s>n?t:r}generateNodeType(e){const t=this.method;return t===ye.SUBGROUP_ELECT?"bool":t===ye.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),n=this.getInputType(e),o=this.aNode,a=this.bNode,u=[];if(r===ye.SUBGROUP_BROADCAST||r===ye.SUBGROUP_SHUFFLE||r===ye.QUAD_BROADCAST){const c=a.getNodeType(e);u.push(o.build(e,s),a.build(e,c==="float"?"int":s))}else r===ye.SUBGROUP_SHUFFLE_XOR||r===ye.SUBGROUP_SHUFFLE_DOWN||r===ye.SUBGROUP_SHUFFLE_UP?u.push(o.build(e,s),a.build(e,"uint")):(o!==null&&u.push(o.build(e,n)),a!==null&&u.push(a.build(e,n)));const l=u.length===0?"()":`( ${u.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${l}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}ye.SUBGROUP_ELECT="subgroupElect";ye.SUBGROUP_BALLOT="subgroupBallot";ye.SUBGROUP_ADD="subgroupAdd";ye.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";ye.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";ye.SUBGROUP_MUL="subgroupMul";ye.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";ye.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";ye.SUBGROUP_AND="subgroupAnd";ye.SUBGROUP_OR="subgroupOr";ye.SUBGROUP_XOR="subgroupXor";ye.SUBGROUP_MIN="subgroupMin";ye.SUBGROUP_MAX="subgroupMax";ye.SUBGROUP_ALL="subgroupAll";ye.SUBGROUP_ANY="subgroupAny";ye.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";ye.QUAD_SWAP_X="quadSwapX";ye.QUAD_SWAP_Y="quadSwapY";ye.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";ye.SUBGROUP_BROADCAST="subgroupBroadcast";ye.SUBGROUP_SHUFFLE="subgroupShuffle";ye.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";ye.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";ye.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";ye.QUAD_BROADCAST="quadBroadcast";let Mo;function Za(i){Mo=Mo||new WeakMap;let e=Mo.get(i);return e===void 0&&Mo.set(i,e={}),e}function yd(i){const e=Za(i);return e.shadowMatrix||(e.shadowMatrix=K("mat4").setGroup(Z).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(i.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(i.shadow.camera.coordinateSystem=t.camera.coordinateSystem,i.shadow.camera.updateProjectionMatrix()),i.shadow.updateMatrices(i)),i.shadow.matrix)))}function LR(i,e=On){const t=yd(i).mul(e);return t.xyz.div(t.w)}function ay(i){const e=Za(i);return e.position||(e.position=K(new V).setGroup(Z).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.matrixWorld)))}function UR(i){const e=Za(i);return e.targetPosition||(e.targetPosition=K(new V).setGroup(Z).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.target.matrixWorld)))}function uy(i){const e=Za(i);return e.viewPosition||(e.viewPosition=K(new V).setGroup(Z).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new V,r.value.setFromMatrixPosition(i.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const ly=i=>Hn.transformDirection(ay(i).sub(UR(i))),OR=gs("vec3","totalDiffuse"),IR=gs("vec3","totalSpecular"),kR=gs("vec3","outgoingLight"),GR=i=>i.sort((e,t)=>e.id-t.id),VR=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},Hu=new WeakMap,ci=[];class cy extends J{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=OR,this.totalSpecularNode=IR,this.outgoingLightNode=kR,this._lights=[],this.global=!0}customCacheKey(){const e=this._lights;for(let r=0;r0}}class $R extends J{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=re.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){dy.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||On)}}const dy=gs("vec3","shadowPositionWorld");function zR(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new Kt),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function WR(i,e){return e=zR(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function jR(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function HR(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function qR(i,e){return e=HR(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function XR(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function KR(i,e,t){return t=WR(i,t),t=qR(e,t),t}function YR(i,e,t){jR(i,t),XR(e,t)}const Ba=new WeakMap,QR=R(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let r=Ne(i,e.xy).setName("t_basic");return i.isArrayTexture&&(r=r.depth(t)),r.compare(e.z)}),ZR=R(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=(c,d)=>{let h=Ne(i,c);return i.isArrayTexture&&(h=h.depth(r)),h.compare(d)},n=Me("mapSize","vec2",t).setGroup(Z),o=Me("radius","float",t).setGroup(Z),a=ee(1).div(n),u=o.mul(a.x),l=oy(jn.xy).mul(6.28318530718);return Rt(s(e.xy.add(mr(0,5,l).mul(u)),e.z),s(e.xy.add(mr(1,5,l).mul(u)),e.z),s(e.xy.add(mr(2,5,l).mul(u)),e.z),s(e.xy.add(mr(3,5,l).mul(u)),e.z),s(e.xy.add(mr(4,5,l).mul(u)),e.z)).mul(1/5)}),JR=R(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=Me("mapSize","vec2",t).setGroup(Z),n=ee(1).div(s),o=e.xy,a=Sr(o.mul(s).add(.5)).toConst();o.subAssign(a.sub(.5).mul(n));const u=f=>{let p=Ne(i,o).offset(f).gather();return i.isArrayTexture&&(p=p.depth(r)),p.compare(e.z)},l=u(Nt(-1,1)).toConst(),c=u(Nt(1,1)).toConst(),d=u(Nt(-1,-1)).toConst(),h=u(Nt(1,-1)).toConst();return Rt(xe(l.x,c.y,a.x).add(l.y).add(c.x).mul(a.y),xe(l.w,c.z,a.x).add(l.z).add(c.w),xe(d.x,h.y,a.x).add(d.y).add(h.x),xe(d.w,h.z,a.x).add(d.z).add(h.w).mul(a.y.oneMinus())).mul(1/9)}),eE=R(({depthTexture:i,shadowCoord:e,depthLayer:t},r)=>{let s=Ne(i).sample(e.xy);i.isArrayTexture&&(s=s.depth(t)),s=s.rg;const n=s.x,o=st(1e-7,s.y.mul(s.y)),a=r.renderer.reversedDepthBuffer?ki(n,e.z):ki(e.z,n),u=w(1).toVar();return me(a.notEqual(1),()=>{const l=e.z.sub(n);let c=o.div(o.add(l.mul(l)));c=hs(xt(c,.3).div(.65)),u.assign(st(a,c))}),u}),tE=i=>{let e=Ba.get(i);return e===void 0&&(e=new qe,e.colorNode=q(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=Wr,e.fog=!1,Ba.set(i,e)),e},rE=i=>{const e=Ba.get(i);e!==void 0&&(e.dispose(),Ba.delete(i))},df=new fs,sn=[],sE=(i,e,t,r)=>{sn[0]=i,sn[1]=e;let s=df.get(sn);return(s===void 0||s.shadowType!==t||s.useVelocity!==r)&&(s=(n,o,a,u,l,c,d,h,f)=>{(n.castShadow===!0||n.receiveShadow&&t===Ni)&&(r&&(gg(n).useVelocity=!0),n.onBeforeShadow(i,n,a,e.camera,u,o.overrideMaterial,c),i.renderObject(n,o,a,u,l,c,d,h,f),n.onAfterShadow(i,n,a,e.camera,u,o.overrideMaterial,c))},s.shadowType=t,s.useVelocity=r,df.set(sn,s)),sn[0]=null,sn[1]=null,s},nE=R(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const n=w(0).toVar("meanVertical"),o=w(0).toVar("squareMeanVertical"),a=i.lessThanEqual(w(1)).select(w(0),w(2).div(i.sub(1))),u=i.lessThanEqual(w(1)).select(w(0),w(-1));$t({start:Ue(0),end:Ue(i),type:"int",condition:"<"},({i:c})=>{const d=u.add(w(c).mul(a));let h=r.sample(Rt(jn.xy,ee(0,d).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(s)),h=h.x,n.addAssign(h),o.addAssign(h.mul(h))}),n.divAssign(i),o.divAssign(i);const l=ds(o.sub(n.mul(n)).max(0));return ee(n,l)}),iE=R(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const n=w(0).toVar("meanHorizontal"),o=w(0).toVar("squareMeanHorizontal"),a=i.lessThanEqual(w(1)).select(w(0),w(2).div(i.sub(1))),u=i.lessThanEqual(w(1)).select(w(0),w(-1));$t({start:Ue(0),end:Ue(i),type:"int",condition:"<"},({i:c})=>{const d=u.add(w(c).mul(a));let h=r.sample(Rt(jn.xy,ee(d,0).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(s)),n.addAssign(h.x),o.addAssign(Rt(h.y.mul(h.y),h.x.mul(h.x)))}),n.divAssign(i),o.divAssign(i);const l=ds(o.sub(n.mul(n)).max(0));return ee(n,l)}),oE=[QR,ZR,JR,eE];let qu;const Bo=new iy;class hy extends $R{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:n,depthLayer:o}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),u=t({depthTexture:r,shadowCoord:s,shadow:n,depthLayer:o});return a.select(u,w(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,n=r.biasNode||Me("bias","float",r).setGroup(Z);let o=t,a;if(r.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),a=o.z;else{const u=o.w;o=o.xy.div(u);const l=Me("near","float",r.camera).setGroup(Z),c=Me("far","float",r.camera).setGroup(Z);a=fd(u.negate(),l,c)}return o=C(o.x,o.y.oneMinus(),s.reversedDepthBuffer?a.sub(n):a.add(n)),o}getShadowFilterFn(e){return oE[e]}setupRenderTarget(e,t){const r=new xr(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Pn:Zi;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:n}=this,{depthTexture:o,shadowMap:a}=this.setupRenderTarget(n,e),u=t.shadowMap.type,l=t.hasCompatibility(js.TEXTURE_COMPARE);if((u===ap||u===u_)&&l?(o.minFilter=yt,o.magFilter=yt):(o.minFilter=Lt,o.magFilter=Lt),n.camera.coordinateSystem=r.coordinateSystem,n.camera.updateProjectionMatrix(),u===Ni&&n.isPointLightShadow!==!0){o.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depthBuffer:!1}));let v=Ne(o);o.isArrayTexture&&(v=v.depth(this.depthLayer));let S=Ne(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(S=S.depth(this.depthLayer));const P=Me("blurSamples","float",n).setGroup(Z),F=Me("radius","float",n).setGroup(Z),U=Me("mapSize","vec2",n).setGroup(Z);let W=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qe);W.fragmentNode=nE({samples:P,radius:F,size:U,shadowPass:v,depthLayer:this.depthLayer}).context(e.getSharedContext()),W.name="VSMVertical",W=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qe),W.fragmentNode=iE({samples:P,radius:F,size:U,shadowPass:S,depthLayer:this.depthLayer}).context(e.getSharedContext()),W.name="VSMHorizontal"}const c=Me("intensity","float",n).setGroup(Z),d=Me("normalBias","float",n).setGroup(Z),h=yd(s),f=qn.mul(d);let p;!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?p=h.mul(dy.add(f)):p=K("mat4").onObjectUpdate(({object:S},P)=>P.value.multiplyMatrices(h.value,S.matrixWorld)).mul(Qe).add(h.mul(q(f,0)));const g=this.setupShadowCoord(e,p),m=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const y=u===Ni&&n.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,x=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:y,shadowCoord:g,shadow:n,depthLayer:this.depthLayer});let _;t.shadowMap.transmitted===!0&&(a.texture.isCubeTexture?_=vt(a.texture,g.xyz):(_=Ne(a.texture,g),o.isArrayTexture&&(_=_.depth(this.depthLayer))));let N;_?N=xe(1,x.rgb.mix(_,1),c.mul(_.a)).toVar():N=xe(1,x,c).toVar(),this.shadowMap=a,this.shadow.map=a;const A=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return _&&N.toInspector(`${A} / Color`,()=>this.shadowMap.texture.isCubeTexture?vt(this.shadowMap.texture,Ph()):Ne(this.shadowMap.texture)),N.toInspector(`${A} / Depth`,()=>{const v=Me("near","float",this.shadow.camera),S=Me("far","float",this.shadow.camera);let P;this.shadowMap.texture.isCubeTexture?P=vt(this.shadowMap.depthTexture,Ph()).r:P=Ne(this.shadowMap.depthTexture).r;let F;return this.shadow.camera.isPerspectiveCamera?F=hd(P,v,S):F=QS(P,v,S),F=Cn(F,v,S),F.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return R(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:n,scene:o}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=o.name;o.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,n.render(o,t.camera),o.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:n,scene:o,camera:a}=e,u=n.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.camera.layers.mask;(s.camera.layers.mask&4294967294)===0&&(s.camera.layers.mask=a.layers.mask);const d=n.getRenderObjectFunction(),h=n.getMRT(),f=h?h.has("velocity"):!1;qu=KR(n,o,qu),o.overrideMaterial=tE(r),n.setRenderObjectFunction(sE(n,s,u,f)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(d),u===Ni&&s.isPointLightShadow!==!0&&this.vsmPass(n),s.camera.layers.mask=c,YR(n,o,qu)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Bo.material=this.vsmMaterialVertical,Bo.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Bo.material=this.vsmMaterialHorizontal,Bo.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,rE(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const aE=(i,e)=>new hy(i,e),uE=new Kt,hf=new At,di=new V,Xu=new V,lE=[new V(1,0,0),new V(-1,0,0),new V(0,-1,0),new V(0,1,0),new V(0,0,1),new V(0,0,-1)],cE=[new V(0,-1,0),new V(0,-1,0),new V(0,0,-1),new V(0,0,1),new V(0,-1,0),new V(0,-1,0)],dE=[new V(1,0,0),new V(-1,0,0),new V(0,1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1)],hE=[new V(0,-1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1),new V(0,-1,0),new V(0,-1,0)],fE=R(({depthTexture:i,bd3D:e,dp:t})=>vt(i,e).compare(t)),pE=R(({depthTexture:i,bd3D:e,dp:t,shadow:r})=>{const s=Me("radius","float",r).setGroup(Z),n=Me("mapSize","vec2",r).setGroup(Z),o=s.div(n.x),a=Ft(e),u=Ht($s(e,a.x.greaterThan(a.z).select(C(0,1,0),C(1,0,0)))),l=$s(e,u),c=oy(jn.xy).mul(6.28318530718),d=mr(0,5,c),h=mr(1,5,c),f=mr(2,5,c),p=mr(3,5,c),g=mr(4,5,c);return vt(i,e.add(u.mul(d.x).add(l.mul(d.y)).mul(o))).compare(t).add(vt(i,e.add(u.mul(h.x).add(l.mul(h.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(f.x).add(l.mul(f.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(p.x).add(l.mul(p.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(g.x).add(l.mul(g.y)).mul(o))).compare(t)).mul(1/5)}),gE=R(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:r},s)=>{const n=t.xyz.toConst(),o=n.abs().toConst(),a=o.x.max(o.y).max(o.z),u=K("float").setGroup(Z).onRenderUpdate(()=>r.camera.near),l=K("float").setGroup(Z).onRenderUpdate(()=>r.camera.far),c=Me("bias","float",r).setGroup(Z),d=w(1).toVar();return me(a.sub(l).lessThanEqual(0).and(a.sub(u).greaterThanEqual(0)),()=>{let h;s.renderer.reversedDepthBuffer?(h=ZS(a.negate(),u,l),h.subAssign(c)):s.renderer.logarithmicDepthBuffer?(h=fd(a.negate(),u,l),h.addAssign(c)):(h=Dm(a.negate(),u,l),h.addAssign(c));const f=n.normalize();d.assign(i({depthTexture:e,bd3D:f,dp:h,shadow:r}))}),d});class mE extends hy{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===n_?fE:pE}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:n}){return gE({filterFn:t,depthTexture:r,shadowCoord:s,shadow:n})}setupRenderTarget(e,t){const r=new i_(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Pn:Zi;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:n,scene:o}=e,a=t.camera,u=t.matrix,l=n.coordinateSystem===Ui,c=l?lE:dE,d=l?cE:hE;r.setSize(t.mapSize.width,t.mapSize.width);const h=n.autoClear,f=n.getClearColor(uE),p=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha);for(let g=0;g<6;g++){n.setRenderTarget(r,g),n.clear();const m=s.distance||a.far;m!==a.far&&(a.far=m,a.updateProjectionMatrix()),di.setFromMatrixPosition(s.matrixWorld),a.position.copy(di),Xu.copy(a.position),Xu.add(c[g]),a.up.copy(d[g]),a.lookAt(Xu),a.updateMatrixWorld(),u.makeTranslation(-di.x,-di.y,-di.z),hf.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(hf,a.coordinateSystem,a.reversedDepth);const y=o.name;o.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${g+1}`,n.render(o,a),o.name=y}n.autoClear=h,n.setClearColor(f,p)}}const yE=(i,e)=>new mE(i,e);class Ys extends Xn{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Kt,this.colorNode=e&&e.colorNode||K(this.color).setGroup(Z),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=re.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return uy(this.light).sub(e.context.positionView||je)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return aE(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){const s=this.light.shadow.shadowNode;let n;s!==void 0?n=H(s):n=this.setupShadowNode(),this.shadowNode=n,this.shadowColorNode=r=this.colorNode.mul(n),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const fy=R(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const r=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(r.mul(i.div(e).pow4().oneMinus().clamp().pow2()),r)}),bE=({color:i,lightVector:e,cutoffDistance:t,decayExponent:r})=>{const s=e.normalize(),n=e.length(),o=fy({lightDistance:n,cutoffDistance:t,decayExponent:r}),a=i.mul(o);return{lightDirection:s,lightColor:a}};class _E extends Ys{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=K(0).setGroup(Z),this.decayExponentNode=K(2).setGroup(Z)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yE(this.light)}setupDirect(e){return bE({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}R(([i=Xs()],{renderer:e,material:t})=>{const r=zg(i.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.currentSamples>0){const n=w(r.fwidth()).toVar();s=nr(n.oneMinus(),n.add(1),r).oneMinus()}else s=Ut(r.greaterThan(1),0,1);return s});const xE=R(([i,e])=>{const t=i.x,r=i.y,s=i.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(r)),n=n.add(e.element(2).mul(2*.511664).mul(s)),n=n.add(e.element(3).mul(2*.511664).mul(t)),n=n.add(e.element(4).mul(2*.429043).mul(t).mul(r)),n=n.add(e.element(5).mul(2*.429043).mul(r).mul(s)),n=n.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(t).mul(s)),n=n.add(e.element(8).mul(.429043).mul(ae(t,t).sub(ae(r,r)))),n}),Yt=new gd;class TE extends ms{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,n=this.nodes.getBackgroundNode(e)||e.background;let o=!1;if(n===null)s._clearColor.getRGB(Yt),Yt.a=s._clearColor.a;else if(n.isColor===!0)n.getRGB(Yt),Yt.a=1,o=!0;else if(n.isNode===!0){const u=this.get(e),l=n;Yt.copy(s._clearColor);let c=u.backgroundMesh;if(c===void 0){let _=function(){n.removeEventListener("dispose",_),c.material.dispose(),c.geometry.dispose()};const h=q(l).mul(uf).context({getUV:()=>_R.mul(E0),getTextureLevel:()=>bR}),f=rr.element(3).element(3).equal(1),p=vr(1,rr.element(1).element(1)).mul(3),g=f.select(Qe.mul(p),Qe),m=Ws.mul(q(g,0));let y=rr.mul(q(m.xyz,1));y=y.setZ(y.w);const x=new qe;x.name="Background.material",x.side=ft,x.depthTest=!1,x.depthWrite=!1,x.allowOverride=!1,x.fog=!1,x.lights=!1,x.vertexNode=y,x.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=c=new sr(new Rc(1,32,32),x),c.frustumCulled=!1,c.name="Background.mesh",n.addEventListener("dispose",_)}const d=l.getCacheKey();u.backgroundCacheKey!==d&&(u.backgroundMeshNode.node=q(l).mul(uf),u.backgroundMeshNode.needsUpdate=!0,c.material.needsUpdate=!0,u.backgroundCacheKey=d),t.unshift(c,c.geometry,c.material,0,0,null,null)}else O("Renderer: Unsupported background configuration.",n);const a=s.xr.getEnvironmentBlendMode();if(a==="additive"?Yt.set(0,0,0,1):a==="alpha-blend"&&Yt.set(0,0,0,0),s.autoClear===!0||o===!0){const u=r.clearColorValue;u.r=Yt.r,u.g=Yt.g,u.b=Yt.b,u.a=Yt.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=s.autoClearColor===!0,r.clearDepth=s.autoClearDepth===!0,r.clearStencil=s.autoClearStencil===!0}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let vE=0;class yc{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=vE++}}class SE{constructor(e,t,r,s,n,o,a,u,l,c,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=d,this.nodeAttributes=s,this.bindings=n,this.updateNodes=o,this.updateBeforeNodes=a,this.updateAfterNodes=u,this.observer=l,this.hardwareClipping=c,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const s=new yc(t.name,[]);e.push(s);for(const n of t.bindings)s.bindings.push(n.clone())}else e.push(t);return e}}class ff{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class NE{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class py{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wE extends py{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class RE{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let EE=0;class Ku{constructor(e=null){this.id=EE++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class AE{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class ys{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class CE extends ys{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class ME extends ys{constructor(e,t=new ce){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class BE extends ys{constructor(e,t=new V){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class PE extends ys{constructor(e,t=new He){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class DE extends ys{constructor(e,t=new Kt){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class FE extends ys{constructor(e,t=new jp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class LE extends ys{constructor(e,t=new Qi){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class UE extends ys{constructor(e,t=new At){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class OE extends CE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class IE extends ME{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kE extends BE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class GE extends PE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class VE extends DE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $E extends FE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zE extends LE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WE extends UE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let jE=0;const pf=new WeakMap,gf=new WeakMap,HE=new WeakMap,qE=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Po=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0")),gy=i=>{if(i.writeUsageCount>0)return!0;if(i.subBuildsCache!==void 0){for(const e in i.subBuildsCache)if(gy(i.subBuildsCache[e]))return!0}return!1};class my{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=zu(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Ku,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:jE++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===Fr&&e.alphaToCoverage===!1}createRenderTarget(e,t,r){return new ps(e,t,r)}createCubeRenderTarget(e,t){return new Im(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(r!==null){const s=r.textures[e].type,n=r.textures[e].format;let o="vec";s===Ze?o="ivec":s===Ge&&(o="uvec"),n===qi||n===Xi?s===Ze?t="int":s===Ge?t="uint":t="float":n===tr||n===Ki?t=`${o}2`:n===Yi||n===Mc?t=`${o}3`:t=`${o}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s=r.shared;if(s)for(let o=1;od.nodeUniform.node.id-h.nodeUniform.node.id);for(const d of c.uniforms)o+=d.nodeUniform.node.id}else o+=c.nodeUniform.id;const a=this.renderer._currentRenderContext||this.renderer;let u=pf.get(a);u===void 0&&(u=new Map,pf.set(a,u));const l=Vn(o);n=u.get(l),n===void 0&&(n=new yc(e,t),u.set(l,n))}else n=new yc(e,t);return n}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return s===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(e===null){const t={},r=this.bindings;for(const s of vu)for(const n in r[s]){const o=r[s][n],a=t[n]||(t[n]=[]);for(const u of o)a.includes(u)===!1&&a.push(u)}e=[];for(const s in t){const n=t[s],o=this._getBindGroup(s,n);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,r)=>t.bindings[0].groupNode.order-r.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Po(t.r)}, ${Po(t.g)}, ${Po(t.b)} )`;const r=this.getTypeLength(e),s=this.getComponentType(e),n=o=>this.generateConst(s,o);if(r===2)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)} )`;if(r===3)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)} )`;if(r===4&&e!=="mat2")return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)}, ${n(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(n).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw new Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const r=this.attributes;for(const n of r)if(n.name===e)return n;const s=new ff(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return e.isDepthTexture===!0?"float":t===Ze?"int":t===Ge?"uint":"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let r=pg(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return qE.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,n=e.normalized;let o;return!(e instanceof zp)&&n!==!0&&(o=this.getTypeFromArray(r)),this.getTypeFromLength(s,o)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return r!==null?Number(r[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("THREE.NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=zu(this.stack);const e=xg();return this.stacks.push(e),wa(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const r=this.getDataFromNode(t);r.stack=e}return this.stack=e.parent,wa(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){r=r===null?e.isGlobal(this)?this.globalCache:this.cache:r;let s=r.getData(e);s===void 0&&(s={},r.setData(e,s)),s[t]===void 0&&(s[t]={});let n=s[t];if(this.subBuildLayers.length===0)return n;const o=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(o);return a&&(n.subBuildsCache===void 0&&(n.subBuildsCache={}),n=n.subBuildsCache[a]||(n.subBuildsCache[a]={}),n.subBuilds=o),n}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let n=s.bufferAttribute;if(n===void 0){const o=this.uniforms.index++;r===null&&(r="nodeAttribute"+o),n=new ff(r,t,e),this.bufferAttributes.push(n),s.bufferAttribute=n}return n}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const n=this.getDataFromNode(e,s,this.globalCache);let o=n.structType;if(o===void 0){const a=this.structs.index++;r===null&&(r="StructType"+a),o=new AE(r,t),this.structs[s].push(o),this.types[s][r]=e,n.structType=o}return o}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const n=this.getDataFromNode(e,r,this.globalCache);let o=n.uniform;if(o===void 0){const a=this.uniforms.index++;o=new NE(s||"nodeUniform"+a,t,e),this.uniforms[r].push(o),this.registerDeclaration(o),n.uniform=o}return o}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,n=!1){const o=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",o.subBuilds);let u=o[a];if(u===void 0){const l=n?"_const":"_var",c=this.vars[s]||(this.vars[s]=[]),d=this.vars[l]||(this.vars[l]=0);t===null&&(t=(n?"nodeConst":"nodeVar")+d,this.vars[l]++),a!=="variable"&&(t=this.getSubBuildProperty(t,o.subBuilds));const h=e.getArrayCount(this);u=new py(t,r,n,h),n||c.push(u),this.registerDeclaration(u),o[a]=u}return u}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,n=null){const o=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",o.subBuilds);let u=o[a];if(u===void 0){const l=this.varyings,c=l.length;t===null&&(t="nodeVarying"+c),a!=="varying"&&(t=this.getSubBuildProperty(t,o.subBuilds)),u=new wE(t,r,s,n),l.push(u),this.registerDeclaration(u),o[a]=u}return u}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=e.name;let n=s,o=this.getPropertyName(e),a=1;for(;r[o]!==void 0;)n=s+"_"+a++,e.name=n,o=this.getPropertyName(e);n!==s&&z(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`),r[o]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let n=s.code;if(n===void 0){const o=this.codes[r]||(this.codes[r]=[]),a=o.length;n=new RE("nodeCode"+a,t),o.push(n),s.code=n}return n}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let n=!0,o=t;for(;o;){if(s.get(o)===!0){n=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(n)for(const a of r)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),n=s.flowCodes||(s.flowCodes=[]),o=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);n.push(t),o.set(r,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; +`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=gf.get(t);r===void 0&&(r=new WeakMap,gf.set(t,r));let s=r.get(e);if(s===void 0){s=new BR;const n=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=n,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let o=0;const a=Object.values(this);return{next:()=>({value:a[o],done:o++>=a.length})}}};for(const o of t.inputs)r[o.name]=new dR(o.type,o.name);e.layout=null;const s=e.call(r),n=this.flowStagesNode(s,t.type);return e.layout=t,n}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const n=e.build(this,r);return this.setBuildStage(s),n}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,n=this.declarations,o=this.cache,a=this.buildStage,u=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new Ku,this.stack=zu();for(const c of Tu)this.setBuildStage(c),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=n,this.cache=o,this.stack=u,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){z("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const n=this.tab,o=this.cache,a=this.shaderStage,u=this.context;this.setShaderStage(e);const l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=l;let c=null;if(this.buildStage==="generate"){const d=this.flowChildNode(t,r);s!==null&&(d.code+=`${this.tab+s} = ${d.result}; +`),this.flowCode[e]=this.flowCode[e]+d.code,c=d}else c=t.build(this);return this.setShaderStage(a),this.cache=o,this.tab=n,this.context=u,c}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){z("Abstract function.")}getVaryings(){z("Abstract function.")}getVar(e,t,r=null){return`${r!==null?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(s!==void 0)for(const n of s)r.push(`${this.getVar(n.type,n.name,n.count)};`);return r.join(t?` +`:` + `)}getUniforms(){z("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(t!==void 0)for(const s of t)r+=s.code+` +`;return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){z("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const r=this.subBuildLayers;for(let s=t.length-1;s>=0;s--){const n=t[s];if(r.includes(n))return n}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r;t!==null?r=this.getClosestSubBuild(t):r=this.subBuildFn;let s;return r?s=e?r+"_"+e:r:s=e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:O('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(r.contextNode.isContextNode===!0?this.context={...this.context,...r.contextNode.getFlowContextData()}:O('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),r!==null){let s=t.library.fromMaterial(r);s===null&&(O(`NodeBuilder: Material "${r.type}" is not compatible.`),s=new qe),s.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of Tu){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of vu){this.setShaderStage(t);const r=this.flowNodes[t];for(const s of r)e==="generate"?this.flowNode(s):s.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of Tu){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of vu){this.setShaderStage(t);const r=this.flowNodes[t];for(const s of r)e==="generate"?this.flowNode(s):s.build(this);await up()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=HE.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(s===void 0){if(t==="float"||t==="int"||t==="uint")s=new OE(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")s=new IE(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")s=new kE(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")s=new GE(e);else if(t==="color")s=new VE(e);else if(t==="mat2")s=new $E(e);else if(t==="mat3")s=new zE(e);else if(t==="mat4")s=new WE(e);else throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);r.cache=s}return s}format(e,t,r){if(t=this.getVectorType(t),r=this.getVectorType(r),t===r||r===null||this.isReference(r))return e;const s=this.getTypeLength(t),n=this.getTypeLength(r);return s===16&&n===9?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:s===9&&n===4?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||n>4||n===0?e:s===n?`${this.getType(r)}( ${e} )`:s>n?(e=r==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,n)}`,this.format(e,this.getTypeFromLength(n,this.getComponentType(t)),r)):n===4&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:s===2?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(s===1&&n>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${ka} - Node System +`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||gg(this.object).useVelocity===!0}}class mf{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return r===void 0&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateBeforeMap,r);if(s.frameId!==this.frameId){const n=s.frameId;s.frameId=this.frameId,e.updateBefore(this)===!1&&(s.frameId=n)}}else if(t===re.RENDER){const s=this._getMaps(this.updateBeforeMap,r);if(s.renderId!==this.renderId){const n=s.renderId;s.renderId=this.renderId,e.updateBefore(this)===!1&&(s.renderId=n)}}else t===re.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateAfterMap,r);s.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(s.frameId=this.frameId)}else if(t===re.RENDER){const s=this._getMaps(this.updateAfterMap,r);s.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(s.renderId=this.renderId)}else t===re.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateMap,r);s.frameId!==this.frameId&&e.update(this)!==!1&&(s.frameId=this.frameId)}else if(t===re.RENDER){const s=this._getMaps(this.updateMap,r);s.renderId!==this.renderId&&e.update(this)!==!1&&(s.renderId=this.renderId)}else t===re.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class bd{constructor(e,t,r=null,s="",n=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=n}}bd.isNodeFunctionInput=!0;class XE extends Ys{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class KE extends Ys{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:ly(this.light),lightColor:e}}}class YE extends Ys{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=ay(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=K(new Kt).setGroup(Z)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,o=qn.dot(s).mul(.5).add(.5),a=xe(r,t,o);e.context.irradiance.addAssign(a)}}class _d extends Ys{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=K(0).setGroup(Z),this.penumbraCosNode=K(0).setGroup(Z),this.cutoffDistanceNode=K(0).setGroup(Z),this.decayExponentNode=K(0).setGroup(Z),this.colorNode=K(this.color).setGroup(Z)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return nr(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return r===void 0&&(r=LR(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:n}=this,o=this.getLightVector(e),a=o.normalize(),u=a.dot(ly(n)),l=this.getSpotAttenuation(e,u),c=o.length(),d=fy({lightDistance:c,cutoffDistance:r,decayExponent:s});let h=t.mul(l).mul(d),f,p;return n.colorNode?(p=this.getLightCoord(e),f=n.colorNode(p)):n.map&&(p=this.getLightCoord(e),f=Ne(n.map,p.xy).onRenderUpdate(()=>n.map)),f&&(h=p.mul(2).sub(1).abs().lessThan(1).all().select(h.mul(f),h)),{lightColor:h,lightDirection:a}}}class QE extends _d{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&r.isTexture===!0){const n=t.acos().mul(1/Math.PI);this._iesTextureNode=Ne(r,ee(n,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class ZE extends Ys{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let r=0;r<9;r++)t.push(new V);this.lightProbe=Tt(t)}update(e){const{light:t}=this;super.update(e);for(let r=0;r<9;r++)this.lightProbe.array[r].copy(t.sh.coefficients[r]).multiplyScalar(t.intensity)}setup(e){const t=xE(qn,this.lightProbe);e.context.irradiance.addAssign(t)}}const JE=R(([i,e])=>{const t=i.abs().sub(e);return Hr(st(t,0)).add(Ln(st(t.x,t.y),0))});class eA extends _d{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let r=1;t.map!==null&&(r=t.map.width/t.map.height),t.shadow.aspect=r}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=w(0),r=this.penumbraCosNode,s=yd(this.light).mul(e.context.positionWorld||On);return me(s.w.greaterThan(0),()=>{const n=s.xyz.div(s.w),o=JE(n.xy.sub(ee(.5)),ee(.5)),a=vr(-1,xt(1,Lg(r)).sub(1));t.assign(td(o.mul(-2).mul(a)))}),t}}const Yu=new At,Do=new At;let hi=null;class tA extends Ys{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=K(new V).setGroup(Z),this.halfWidth=K(new V).setGroup(Z),this.updateType=re.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;Do.identity(),Yu.copy(t.matrixWorld),Yu.premultiply(r),Do.extractRotation(Yu),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Do),this.halfHeight.value.applyMatrix4(Do)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Ne(hi.LTC_FLOAT_1),r=Ne(hi.LTC_FLOAT_2)):(t=Ne(hi.LTC_HALF_1),r=Ne(hi.LTC_HALF_2));const{colorNode:s,light:n}=this,o=uy(n);return{lightColor:s,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){hi=e}}class yy{parseFunction(){z("Abstract function.")}}class xd{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){z("Abstract function.")}}xd.isNodeFunction=!0;const rA=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,sA=/[a-z_0-9]+/ig,yf="#pragma main",nA=i=>{i=i.trim();const e=i.indexOf(yf),t=e!==-1?i.slice(e+yf.length):i,r=t.match(rA);if(r!==null&&r.length===5){const s=r[4],n=[];let o=null;for(;(o=sA.exec(s))!==null;)n.push(o);const a=[];let u=0;for(;u{let u=this._createNodeBuilder(e,e.material);try{t?await u.buildAsync():u.build()}catch(l){u=this._createNodeBuilder(e,new qe),t?await u.buildAsync():u.build(),O("TSL: "+l)}return u};if(t)return a().then(u=>(s=this._createNodeBuilderState(u),n.set(o,s),s.usedTimes++,r.nodeBuilderState=s,s));{let u=this._createNodeBuilder(e,e.material);try{u.build()}catch(l){u=this._createNodeBuilder(e,new qe),u.build();let c=l.stackTrace;!c&&l.stack&&(c=new bt(l.stack)),O("TSL: "+l,c)}s=this._createNodeBuilderState(u),n.set(o,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return s!==void 0?(s.usedTimes++,t.nodeBuilderState=s,s):(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||this._buildQueue.length===0)return;this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(r===void 0||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new SE(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){It[0]=e,It[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(It)||{};if(s.callId!==r){if(Ar.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Ar.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){Ar.push(t.getCacheKey(!0)),Ar.push(this.renderer.shadowMap.enabled?1:0),Ar.push(this.renderer.shadowMap.type);const o=this.getEnvironmentNode(e);o&&Ar.push(o.getCacheKey())}const n=this.getFogNode(e);n&&Ar.push(n.getCacheKey()),s.callId=r,s.cacheKey=Ji(Ar),this.callHashCache.set(It,s),Ar.length=0}return It[0]=null,It[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==r||s){const n=this.getCacheNode("background",r,()=>{if(r.isCubeTexture===!0||r.mapping===Dc||r.mapping===Fc||r.mapping===pa){if(e.backgroundBlurriness>0||r.mapping===pa)return Km(r);{let o;return r.isCubeTexture===!0?o=vt(r):o=Ne(r),Gm(o)}}else{if(r.isTexture===!0)return Ne(r,as.flipY()).setUpdateMatrix(!0);r.isColor!==!0&&O("WebGPUNodes: Unsupported background configuration.",r)}},s);t.backgroundNode=n,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const n=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let o=n.get(t);return(o===void 0||s)&&(o=r(),n.set(t,o)),o}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const s=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const n=Me("color","color",r).setGroup(Z),o=Me("density","float",r).setGroup(Z);return cf(n,DR(o))}else if(r.isFog){const n=Me("color","color",r).setGroup(Z),o=Me("near","float",r).setGroup(Z),a=Me("far","float",r).setGroup(Z);return cf(n,PR(o,a))}else O("Renderer: Unsupported fog configuration.",r)});t.fogNode=s,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const s=this.getCacheNode("environment",r,()=>{if(r.isCubeTexture===!0)return vt(r);if(r.isTexture===!0)return Ne(r);O("Nodes: Unsupported environment configuration.",r)});t.environmentNode=s,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,n=null){const o=this.nodeFrame;return o.renderer=e,o.scene=t,o.object=r,o.camera=s,o.material=n,o}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return e.isArrayTexture?this.backend.isWebGLBackend?r=Ne(e,as).depth(Ks("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):r=Ne(e,as).depth(bf).renderOutput(t.toneMapping,t.currentColorSpace):r=Ne(e,as).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){bf.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const s of r.updateNodes)t.updateNode(s)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const s of r.updateNodes)t.updateNode(s)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new mf,this.nodeBuilderCache=new Map,this.cacheLib={}}}const Qu=new wc;class Pa{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new At,this.viewNormalMatrix=new Qi,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let n=0;n0&&(Be("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ps(r.textureWidth,r.textureHeight,{depth:2,minFilter:yt,magFilter:yt,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&Be("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;const r=e.backend,s=e._textures,n=r.get?r.get(t):null;n&&(n.descriptors=void 0);const o=a=>{a!=null&&(r.delete&&r.delete(a),s.delete&&s.delete(a))};for(let a=0;aem(d,r.toneMapping,r.outputColorSpace)}),vf.set(u,l))}else l=u;r.contextNode=l,r.setRenderTarget(a.renderTarget),a.rendercall(),r.contextNode=u}r.setRenderTarget(o),r._setXRLayerSize(n.x,n.y),this.isPresenting=s}getSession(){return this._session}async setSession(e){const t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,e!==null){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let s=null,n=null,o=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(o=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?$r:Vr,n=t.stencil?zr:Ge);const u={colorFormat:r.RGBA8,depthFormat:o,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(u.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const l=this._glBinding.createProjectionLayer(u),c=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);const d=this._useMultiview?2:1,h=new xr(l.textureWidth,l.textureHeight,n,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new vi(l.textureWidth,l.textureHeight,{format:er,type:St,colorSpace:t.outputColorSpace,depthTexture:h,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:l.ignoreDepthValues===!1,resolveStencilBuffer:l.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const f of this._layers)f.plane.material=new ss({color:16777215,side:f.type==="cylinder"?ft:Ls}),f.plane.material.blending=Sn,f.plane.material.blendEquation=Dr,f.plane.material.blendSrc=rs,f.plane.material.blendDst=rs,f.xrlayer=this._createXRLayer(f),c.unshift(f.xrlayer);e.updateRenderState({layers:c})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},n=new XRWebGLLayer(e,r,s);this._glBaseLayer=n,e.updateRenderState({baseLayer:n}),t.setPixelRatio(1),t._setXRLayerSize(n.framebufferWidth,n.framebufferHeight),this._xrRenderTarget=new vi(n.framebufferWidth,n.framebufferHeight,{format:er,type:St,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:n.ignoreDepthValues===!1,resolveStencilBuffer:n.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(t===null)return;const r=e.near,s=e.far,n=this._cameraXR,o=this._cameraL,a=this._cameraR;n.near=a.near=o.near=r,n.far=a.far=o.far=s,n.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==n.near||this._currentDepthFar!==n.far)&&(t.updateRenderState({depthNear:n.near,depthFar:n.far}),this._currentDepthNear=n.near,this._currentDepthFar=n.far),n.layers.mask=e.layers.mask|6,o.layers.mask=n.layers.mask&-5,a.layers.mask=n.layers.mask&-3;const u=e.parent,l=n.cameras;Sf(n,u);for(let c=0;c=0&&(t[n]=null,e[n].disconnect(s))}for(let r=0;r=t.length){t.push(s),n=a;break}else if(t[a]===null){t[a]=s,n=a;break}if(n===-1)break}const o=e[n];o&&o.connect(s)}}function bA(i){return i.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(i.translation,i.quaternion),width:i.width/2,height:i.height/2,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(i.translation,i.quaternion),radius:i.radius,centralAngle:i.centralAngle,aspectRatio:i.aspectRatio,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1})}function _A(i,e){if(e===void 0)return;const t=this._cameraXR,r=this._renderer,s=r.backend,n=this._glBaseLayer,o=this.getReferenceSpace(),a=e.getViewerPose(o);if(this._xrFrame=e,a!==null){const u=a.views,l=this._isWebGPUSession()?this._getWebGPUViewData(u):null;this._glBaseLayer!==null&&l===null&&s.setXRTarget(n.framebuffer);let c=!1;u.length!==t.cameras.length&&(t.cameras.length=0,c=!0);for(let h=0;h{await this.compileAsync(m,g,p);const x=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,_=this._renderLists.get(p,g),N=this._renderContexts.get(x,this._mrt),A=p.overrideMaterial||m.material,v=this._objects.get(m,A,p,g,_.lightsNode,N,N.clippingContext),{fragmentShader:S,vertexShader:P}=v.getNodeBuilderState();return{fragmentShader:S,vertexShader:P}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(s){if(this._getFallback!==null)try{this.backend=r=this._getFallback(s),await r.init(this)}catch(n){t(n);return}else{t(s);return}}this._nodes=new aA(this,r),this._animation=new kw(this,this._nodes,this.info),this._attributes=new Hw(r,this.info),this._background=new TE(this,this._nodes),this._geometries=new qw(this._attributes,this.info),this._textures=new uR(this,r,this.info),this._pipelines=new Zw(r,this._nodes,this.info),this._bindings=new Jw(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new zw(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new sR(this.lighting),this._bundles=new lA,this._renderContexts=new oR(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const s=this._nodes.nodeFrame,n=s.renderId,o=this._currentRenderContext,a=this._currentRenderObjectFunction,u=this._handleObjectFunction,l=this._compilationPromises;r===null&&(r=e);const c=e.isScene===!0?e:r.isScene===!0?r:Nf,h=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,f=this._renderContexts.get(h,this._mrt),p=this._activeMipmapLevel,g=[];this._currentRenderContext=f,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=g,s.renderId++,s.update(),f.depth=this.depth,f.stencil=this.stencil,f.clippingContext||(f.clippingContext=new Pa),f.clippingContext.updateGlobal(c,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),c.onBeforeRender(this,e,t,h);const m=t.isArrayCamera?Lo:Fo;t.isArrayCamera?m.setFromArrayCamera(t):(on.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(on,t.coordinateSystem,t.reversedDepth));const y=this._renderLists.get(c,t);if(y.begin(),this._projectObject(e,t,0,y,f.clippingContext),r!==e&&r.traverseVisible(function(v){v.isLight&&v.layers.test(t.layers)&&y.pushLight(v)}),y.finish(),h!==null){this._textures.updateRenderTarget(h,p);const v=this._textures.get(h);f.textures=v.textures,f.depthTexture=v.depthTexture}else f.textures=null,f.depthTexture=null;r!==e?this._background.update(r,y,f):this._background.update(c,y,f);const x=y.opaque,_=y.transparent,N=y.transparentDoublePass,A=y.lightsNode;this.opaque===!0&&x.length>0&&this._renderObjects(x,t,c,A),this.transparent===!0&&_.length>0&&this._renderTransparents(_,N,t,c,A),s.renderId=n,this._currentRenderContext=o,this._currentRenderObjectFunction=a,this._handleObjectFunction=u,this._compilationPromises=l;for(const v of g){const S=this._objects.get(v.object,v.material,v.scene,v.camera,v.lightsNode,v.renderContext,v.clippingContext,v.passId);S.drawRange=v.object.geometry.drawRange,S.group=v.group,await this._nodes.getForRenderAsync(S),this._nodes.updateBefore(S),this._geometries.updateForRender(S),this._nodes.updateForRender(S),this._bindings.updateForRender(S);const P=[];this._pipelines.getForRender(S,P),P.length>0&&await Promise.all(P),this._nodes.updateAfter(S),await up()}}async renderAsync(e,t){Be('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){O("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=bh,t.modelNormalViewMatrix=_h):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===bh&&e.modelNormalViewMatrix===_h}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Be('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: + +Message: ${e.message}`;e.reason&&(t+=` +Reason: ${e.reason}`),O(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),O(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,r){const{bundleGroup:s,camera:n,renderList:o}=e,a=this._currentRenderContext,u=this._bundles.get(s,n,a),l=this.backend.get(u);if(this._bundleNeedsUpdate(s,l)){this.backend.beginBundle(a),this._currentRenderBundle=u;const{transparentDoublePass:d,transparent:h,opaque:f}=o;this.opaque===!0&&f.length>0&&this._renderObjects(f,n,t,r),this.transparent===!0&&h.length>0&&this._renderTransparents(h,d,n,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,u),l.version=s.version}else{const{renderObjects:d}=l;for(let h=0,f=d.length;h{l.removeEventListener("dispose",m),c.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",m),this._frameBufferTargets.set(l,c)}const d=this.getOutputRenderTarget();c.depthBuffer=a,c.stencilBuffer=u,d!==null?c.setSize(d.width,d.height,d.depth):c.setSize(n,o,1);const h=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,p=this._outputRenderTarget?1:l._pixelRatio,g=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return c.viewport.copy(h),c.scissor.copy(f),c.viewport.multiplyScalar(p),c.scissor.multiplyScalar(p),c.scissorTest=g,c.multiview=d!==null?d.multiview:!1,c.useArrayDepthTexture=d!==null?d.useArrayDepthTexture:!1,c.resolveDepthBuffer=d!==null?d.resolveDepthBuffer:!0,c._autoAllocateDepthBuffer=d!==null?d._autoAllocateDepthBuffer:!1,c}_renderScene(e,t,r=!0){if(this._isDeviceLost===!0)return;const s=r?this._getFrameBufferTarget():null,n=this._nodes.nodeFrame,o=n.renderId,a=this._currentRenderContext,u=this._currentRenderObjectFunction,l=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;const c=e.isScene===!0?e:Nf,d=this._renderTarget||this._outputRenderTarget,h=this._activeCubeFace,f=this._activeMipmapLevel;let p;if(s!==null?(p=s,this.setRenderTarget(p)):p=d,p!==null&&p.depthBuffer===!0){const ie=this._textures.get(p);ie.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),ie.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);const m=this._canvasTarget;let y=m._viewport,x=m._scissor,_=m._pixelRatio;p!==null&&(y=p.viewport,x=p.scissor,_=1),this.getDrawingBufferSize(nn),Zu.set(0,0,nn.width,nn.height);const N=y.minDepth===void 0?0:y.minDepth,A=y.maxDepth===void 0?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(_).floor(),g.viewportValue.width>>=f,g.viewportValue.height>>=f,g.viewportValue.minDepth=N,g.viewportValue.maxDepth=A,g.viewport=g.viewportValue.equals(Zu)===!1,g.scissorValue.copy(x).multiplyScalar(_).floor(),g.scissor=m._scissorTest&&g.scissorValue.equals(Zu)===!1,g.scissorValue.width>>=f,g.scissorValue.height>>=f,g.clippingContext||(g.clippingContext=new Pa),g.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?Lo:Fo;t.isArrayCamera?v.setFromArrayCamera(t):(on.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(on,t.coordinateSystem,t.reversedDepth));const S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,g.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);const ie=this._textures.get(p);g.textures=ie.textures,g.depthTexture=ie.depthTexture,g.width=ie.width,g.height=ie.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=nn.width,g.height=nn.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=f,g.height>>=f,g.activeCubeFace=h,g.activeMipmapLevel=f,g.occlusionQueryCount=S.occlusionQueryCount,g.scissorValue.max(Cr.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(c,S,g),g.camera=t,this.backend.beginRender(g);const{bundles:P,lightsNode:F,transparentDoublePass:U,transparent:W,opaque:se}=S;return P.length>0&&this._renderBundles(P,c,F),this.opaque===!0&&se.length>0&&this._renderObjects(se,t,c,F),this.transparent===!0&&W.length>0&&this._renderTransparents(W,U,t,c,F),this.backend.finishRender(g),n.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=u,this._handleObjectFunction=l,this.lighting.finishRender(e),this._callDepth--,s!==null&&(this.setRenderTarget(d,h,f),this._renderOutput(p)),c.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r=this._quadCache.get(e.texture),s;if(r===void 0){s=new iy(new qe),s.name="Output Color Transform",s.material.name="outputColorTransform",s.material.fragmentNode=this._nodes.getOutputNode(e.texture),r={quad:s,cacheKey:t},this._quadCache.set(e.texture,r);const a=()=>{s.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",a)};e.texture.addEventListener("dispose",a)}else s=r.quad,r.cacheKey!==t&&(s.material.fragmentNode=this._nodes.getOutputNode(e.texture),s.material.needsUpdate=!0,r.cacheKey=t);const n=this.autoClear,o=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(s,e),this.autoClear=n,this.xr.enabled=o}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);const n=()=>{t.removeEventListener("dispose",n),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",n)}if(r%4!==0||s>0&&s%4!==0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,n=0,o=1){this._canvasTarget.setViewport(e,t,r,s,n,o)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(this._initialized===!1)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let n=null;if(s!==null){this._textures.updateRenderTarget(s);const o=this._textures.get(s);n=this._renderContexts.get(s,null,-1),n.textures=o.textures,n.depthTexture=o.depthTexture,n.width=o.width,n.height=o.height,n.renderTarget=s,n.depth=s.depthBuffer,n.stencil=s.stencilBuffer;const a=this.backend.getClearColor();n.clearColorValue.r=a.r,n.clearColorValue.g=a.g,n.clearColorValue.b=a.b,n.clearColorValue.a=a.a,n.clearDepthValue=this.getClearDepth(),n.clearStencilValue=this.getClearStencil(),n.activeCubeFace=this.getActiveCubeFace(),n.activeMipmapLevel=this.getActiveMipmapLevel(),s.depthBuffer===!0&&(o.depthInitialized=!0)}this.backend.clear(e,t,r,n),s!==null&&this._renderTarget===null&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){Be('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){Be('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){Be('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){Be('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==Ds,t=this.currentColorSpace!==We.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Ds}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:We.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return z("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const n=this.backend,o=this._pipelines,a=this._bindings,u=this._nodes,l=Array.isArray(e)?e:[e];if(l[0]===void 0||l[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");n.beginCompute(e);for(const c of l){if(o.has(c)===!1){const f=()=>{c.removeEventListener("dispose",f),o.delete(c),a.deleteForCompute(c),u.delete(c)};c.addEventListener("dispose",f);const p=c.onInitFunction;p!==null&&p.call(c,{renderer:this})}u.updateForCompute(c),a.updateForCompute(c);const d=a.getForCompute(c),h=o.getForCompute(c,d);n.compute(e,c,d,h,t)}n.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Be('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Be('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Cr.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Cr.copy(t).floor();else{O("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Cr.set(0,0,e.image.width,e.image.height);let r=this._currentRenderContext,s;r!==null?s=r.renderTarget:(s=this._renderTarget||this._getFrameBufferTarget(),s!==null&&(this._textures.updateRenderTarget(s),r=this._textures.get(s))),this._textures.updateTexture(e,{renderTarget:s}),this.backend.copyFramebufferToTexture(e,r,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,n=0,o=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,n,o),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,n,o=0,a=0){return this.backend.copyTextureToBuffer(e.textures[o],t,r,s,n,a)}_projectObject(e,t,r,s,n){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(n=n.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const u=t.isArrayCamera?Lo:Fo;if(!e.frustumCulled||u.intersectsSprite(e)){this.sortObjects===!0&&Cr.setFromMatrixPosition(e.matrixWorld).applyMatrix4(on);const{geometry:l,material:c}=e;c.visible&&s.push(e,l,c,r,Cr.z,null,n)}}else if(e.isLineLoop)O("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const u=t.isArrayCamera?Lo:Fo;if(!e.frustumCulled||u.intersectsObject(e)){const{geometry:l,material:c}=e;if(this.sortObjects===!0&&(l.boundingSphere===null&&l.computeBoundingSphere(),Cr.copy(l.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(on)),Array.isArray(c)){const d=l.groups;for(let h=0,f=d.length;h0){for(const{material:o}of t)o.side=ft;this._renderObjects(t,r,s,n,"backSide");for(const{material:o}of t)o.side=Ls;this._renderObjects(e,r,s,n);for(const{material:o}of t)o.side=Gr}else this._renderObjects(e,r,s,n)}_renderObjects(e,t,r,s,n=null){for(let o=0,a=e.length;o(f.not().discard(),p))(l)}}e.depthNode&&e.depthNode.isNode&&(c=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?u=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(u=e.positionNode),r={version:t,colorNode:l,depthNode:c,positionNode:u},this._cacheShadowNodes.set(e,r)}return r}_updateCamera(e){const t=this.xr;if(t.isPresenting===!1){let r=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(const n of e.cameras)n._reversedDepth=!0;r=!0}const s=this.coordinateSystem;if(e.coordinateSystem!==s){if(e.coordinateSystem=s,e.isArrayCamera)for(const n of e.cameras)n.coordinateSystem=s;r=!0}if(r===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(const n of e.cameras)n.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,r,s,n,o,a,u=null,l=null){let c=!1,d,h,f,p,g,m,y;const x=this._currentSourceMaterial;if(e.onBeforeRender(this,t,r,s,n,o),n.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=n;const _=t.overrideMaterial;if(c=!0,d=_.isNodeMaterial?_.colorNode:null,h=_.isNodeMaterial?_.depthNode:null,f=_.isNodeMaterial?_.positionNode:null,p=t.overrideMaterial.side,g=_.displacementMap,m=_.displacementScale,y=_.displacementBias,n.positionNode&&n.positionNode.isNode&&(_.positionNode=n.positionNode),_.alphaTest=n.alphaTest,_.alphaMap=n.alphaMap,_.displacementMap=n.displacementMap,_.displacementScale=n.displacementScale,_.displacementBias=n.displacementBias,_.transparent=n.transparent||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode,_.isShadowPassMaterial){const{colorNode:N,depthNode:A,positionNode:v}=this._getShadowNodes(n);this.shadowMap.type===Ni?_.side=n.shadowSide!==null?n.shadowSide:n.side:_.side=n.shadowSide!==null?n.shadowSide:TA[n.side],N!==null&&(_.colorNode=N),A!==null&&(_.depthNode=A),v!==null&&(_.positionNode=v)}n=_}n.transparent===!0&&n.side===Gr&&n.forceSinglePass===!1?(n.side=ft,this._handleObjectFunction(e,n,t,r,a,o,u,"backSide"),n.side=Ls,this._handleObjectFunction(e,n,t,r,a,o,u,l),n.side=Gr):this._handleObjectFunction(e,n,t,r,a,o,u,l),c&&(t.overrideMaterial.colorNode=d,t.overrideMaterial.depthNode=h,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=g,t.overrideMaterial.displacementScale=m,t.overrideMaterial.displacementBias=y),this._currentSourceMaterial=x,e.onAfterRender(this,t,r,s,n,o)}hasCompatibility(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,n,o,a,u){const l=this._objects.get(e,t,r,s,n,this._currentRenderContext,a,u);l.drawRange=e.geometry.drawRange,l.group=o,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);const c=this._nodes.needsRefresh(l);c&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),this._pipelines.isReady(l)&&(this.backend.draw(l,this.info),c&&this._nodes.updateAfter(l))}_createObjectPipeline(e,t,r,s,n,o,a,u){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:n,group:o,clippingContext:a,passId:u,renderContext:this._currentRenderContext});return}const l=this._objects.get(e,t,r,s,n,this._currentRenderContext,a,u);l.drawRange=e.geometry.drawRange,l.group=o,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class _y{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function xy(i){return i+(is-i%is)%is}class Ty extends _y{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return xy(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class vy extends Ty{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let SA=0;class Sy extends vy{constructor(e,t){super("UniformBuffer_"+SA++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return xy(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class NA extends vy{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);r===void 0&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?d:"";a=`${l.name} { + ${c} ${o.name}[${h}]; +}; +`}else{const l=o.groupNode.name;if(s[l]===void 0){const c=this.uniformGroups[l];if(c!==void 0){const d=[];for(const h of c.uniforms){const f=h.getType(),p=this.getVectorType(f),g=h.nodeUniform.node.precision;let m=`${p} ${h.name};`;g!==null&&(m=Rf[g]+" "+m),d.push(" "+m)}s[l]=d}}u=!0}if(!u){const l=o.node.precision;l!==null&&(a=Rf[l]+" "+a),a="uniform "+a,r.push(a)}}let n="";for(const o in s){const a=s[o];n+=this._getGLSLUniformStruct(o,a.join(` +`))+` +`}return n+=r.join(` +`),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ze){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;s instanceof Uint32Array||s instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const r=this.getAttributesArray();let s=0;for(const n of r)t+=`layout( location = ${s++} ) in ${n.type} ${n.name}; +`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(` ${r.type} ${r.name};`);return t.join(` +`)}getStructs(e){const t=[],r=this.structs[e],s=[];for(const n of r)if(n.output)for(const o of n.members)s.push(`layout( location = ${o.index} ) out ${o.type} ${o.name};`);else{let o="struct "+n.name+` { +`;o+=this.getStructMembers(n),o+=` +}; +`,t.push(o)}return e==="fragment"&&s.length===0&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),` +`+s.join(` +`)+` + +`+t.join(` +`)}getVaryings(e){let t="";const r=this.varyings;if(e==="vertex"||e==="compute")for(const s of r){e==="compute"&&(s.needsInterpolation=!0);const n=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const o=Af[s.interpolationType]||s.interpolationType,a=Cf[s.interpolationSampling]||"";t+=`${o} ${a} out ${n} ${s.name}; +`}else{const o=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${o}out ${n} ${s.name}; +`}else t+=`${n} ${s.name}; +`}else if(e==="fragment"){for(const s of r)if(s.needsInterpolation){const n=this.getType(s.type);if(s.interpolationType){const o=Af[s.interpolationType]||s.interpolationType,a=Cf[s.interpolationSampling]||"";t+=`${o} ${a} in ${n} ${s.name}; +`}else{const o=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${o}in ${n} ${s.name}; +`}}}for(const s of this.builtins[e])t+=`${s}; +`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((r,s)=>r*s,1)}u`}getSubgroupSize(){O("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){O("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){O("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(r!==void 0)for(const{name:s,behavior:n}of r.values())t.push(`#extension ${s} : ${n}`);return t.join(` +`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Ef[e];if(t===void 0){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance";break}if(r!==void 0){const s=this.renderer.backend.extensions;s.has(r)&&(s.get(r),t=!0)}Ef[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+=` +`),r+=` // flow -> ${l} + `),r+=`${u.code} + `,a===n&&t!=="compute"&&(r+=`// result + `,t==="vertex"?(r+="gl_Position = ",r+=`${this.format(u.result,n.getNodeType(this),"vec4")};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(u.result,n.getNodeType(this),this.getOutputType())};`)))}const o=e[t];if(o.extensions=this.getExtensions(t),o.uniforms=this.getUniforms(t),o.attributes=this.getAttributes(t),o.varyings=this.getVaryings(t),o.vars=this.getVars(t,!0),o.structs=this.getStructs(t),o.codes=this.getCodes(t),o.transforms=this.getTransforms(t),o.flow=r,t==="vertex"){const a=this.renderer.backend.extensions;this.object.isBatchedMesh&&a.has("WEBGL_multi_draw")===!1&&(o.uniforms+=` +uniform uint nodeUniformDrawId; +`)}}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const n=super.getUniformFromNode(e,t,r,s),o=this.getDataFromNode(e,r,this.globalCache);let a=o.uniformGPU;if(a===void 0){const u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,r);if(t==="texture")a=new Ja(n.name,n.node,u),c.push(a);else if(t==="cubeTexture"||t==="cubeDepthTexture")a=new Ry(n.name,n.node,u),c.push(a);else if(t==="texture3D")a=new bc(n.name,n.node,u),c.push(a);else if(t==="buffer"){n.name=`buffer${e.id}`;const d=this.getSharedDataFromNode(e);let h=d.buffer;h===void 0&&(e.name=`NodeBuffer_${e.id}`,h=new Sy(e,u),h.name=e.name,d.buffer=h),c.push(h),a=h}else{let d=this.uniformGroups[l];d===void 0?(d=new Ny(l,u),this.uniformGroups[l]=d,c.push(d)):c.indexOf(d)===-1&&c.push(d),a=this.getNodeUniform(n,t);const h=a.name;d.uniforms.some(p=>p.name===h)||d.addUniform(a)}o.uniformGPU=a}return n}}let Ju=null,an=null;class Ey{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[br.RENDER]:null,[br.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;e.isComputeNode===!0?s="c:"+this.renderer.info.compute.frameCalls:s="r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?br.COMPUTE:br.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){Be("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return Ju=Ju||new ce,this.renderer.getDrawingBufferSize(Ju)}setScissorTest(){}getClearColor(){const e=this.renderer;return an=an||new gd,e.getClearColor(an),an.getRGB(an),an}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:gb(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${ka} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let PA=0;class DA{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class FA{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,n=e.array,o=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,u=r.get(a);let l=u.bufferGPU;l===void 0&&(l=this._createBuffer(s,t,n,o),u.bufferGPU=l,u.bufferType=t,u.version=a.version);let c;if(n instanceof Float32Array)c=s.FLOAT;else if(typeof Float16Array<"u"&&n instanceof Float16Array)c=s.HALF_FLOAT;else if(n instanceof Uint16Array)e.isFloat16BufferAttribute?c=s.HALF_FLOAT:c=s.UNSIGNED_SHORT;else if(n instanceof Int16Array)c=s.SHORT;else if(n instanceof Uint32Array)c=s.UNSIGNED_INT;else if(n instanceof Int32Array)c=s.INT;else if(n instanceof Int8Array)c=s.BYTE;else if(n instanceof Uint8Array)c=s.UNSIGNED_BYTE;else if(n instanceof Uint8ClampedArray)c=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+n);let d={bufferGPU:l,bufferType:t,type:c,byteLength:n.byteLength,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:c===s.INT||c===s.UNSIGNED_INT||e.gpuType===Ze,id:PA++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const h=this._createBuffer(s,t,n,o);d=new DA(d,h)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,n=e.isInterleavedBufferAttribute?e.data:e,o=t.get(n),a=o.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,o.bufferGPU),u.length===0)r.bufferSubData(a,0,s);else{for(let l=0,c=u.length;l{t.buffer=null,t._mapped=!1,t.removeEventListener("release",h),t.removeEventListener("dispose",h)};t.addEventListener("release",h),t.addEventListener("dispose",h),d=new Uint8Array(new ArrayBuffer(c)),t.buffer=d.buffer}else d=new Uint8Array(t);return o.bindBuffer(o.COPY_READ_BUFFER,l),o.getBufferSubData(o.COPY_READ_BUFFER,r,d),o.bindBuffer(o.COPY_READ_BUFFER,null),o.bindBuffer(o.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const n=e.createBuffer();return e.bindBuffer(t,n),e.bufferData(t,r,s),e.bindBuffer(t,null),n}}let fi,Mr;class LA{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;fi={[Dr]:e.FUNC_ADD,[Tp]:e.FUNC_SUBTRACT,[xp]:e.FUNC_REVERSE_SUBTRACT},Mr={[rs]:e.ZERO,[Bp]:e.ONE,[Mp]:e.SRC_COLOR,[Cp]:e.SRC_ALPHA,[Ap]:e.SRC_ALPHA_SATURATE,[Ep]:e.DST_COLOR,[Rp]:e.DST_ALPHA,[wp]:e.ONE_MINUS_SRC_COLOR,[Np]:e.ONE_MINUS_SRC_ALPHA,[Sp]:e.ONE_MINUS_DST_COLOR,[vp]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new He().fromArray(t),this.currentViewport=new He().fromArray(r),this._tempVec4=new He}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==yb?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===bb?t.cullFace(t.BACK):e===_b?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,n=this.backend.drawBuffersIndexedExt;if(!n){Be("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let o=0;o0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(let u=0;u<8;u++)u{function n(){const o=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(o===e.WAIT_FAILED){e.deleteSync(t),s();return}if(o===e.TIMEOUT_EXPIRED){requestAnimationFrame(n);return}e.deleteSync(t),r()}n()})}}let Bf=!1,Uo,el,Pf;class OA{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,Bf===!1&&(this._init(),Bf=!0)}_init(){const e=this.gl;Uo={[Va]:e.REPEAT,[Oi]:e.CLAMP_TO_EDGE,[Ga]:e.MIRRORED_REPEAT},el={[Lt]:e.NEAREST,[gp]:e.NEAREST_MIPMAP_NEAREST,[Bn]:e.NEAREST_MIPMAP_LINEAR,[yt]:e.LINEAR,[yl]:e.LINEAR_MIPMAP_NEAREST,[ls]:e.LINEAR_MIPMAP_LINEAR},Pf={[_p]:e.NEVER,[bp]:e.ALWAYS,[Uc]:e.LESS,[Zi]:e.LEQUAL,[yp]:e.EQUAL,[Pn]:e.GEQUAL,[ma]:e.GREATER,[mp]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return e.isCubeTexture===!0?r=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?r=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?r=t.TEXTURE_3D:r=t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,n,o=!1){const{gl:a,extensions:u}=this;if(e!==null){if(a[e]!==void 0)return a[e];z("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=null;s&&(l=u.get("EXT_texture_norm16"),l||z("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=t;if(t===a.RED&&(r===a.FLOAT&&(c=a.R32F),r===a.HALF_FLOAT&&(c=a.R16F),r===a.UNSIGNED_BYTE&&(c=a.R8),r===a.BYTE&&(c=a.R8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),r===a.SHORT&&l&&(c=l.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.R8UI),r===a.UNSIGNED_SHORT&&(c=a.R16UI),r===a.UNSIGNED_INT&&(c=a.R32UI),r===a.BYTE&&(c=a.R8I),r===a.SHORT&&(c=a.R16I),r===a.INT&&(c=a.R32I)),t===a.RG&&(r===a.FLOAT&&(c=a.RG32F),r===a.HALF_FLOAT&&(c=a.RG16F),r===a.UNSIGNED_BYTE&&(c=a.RG8),r===a.BYTE&&(c=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),r===a.SHORT&&l&&(c=l.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RG8UI),r===a.UNSIGNED_SHORT&&(c=a.RG16UI),r===a.UNSIGNED_INT&&(c=a.RG32UI),r===a.BYTE&&(c=a.RG8I),r===a.SHORT&&(c=a.RG16I),r===a.INT&&(c=a.RG32I)),t===a.RGB){const d=o?Ed:We.getTransfer(n);r===a.FLOAT&&(c=a.RGB32F),r===a.HALF_FLOAT&&(c=a.RGB16F),r===a.UNSIGNED_BYTE&&(c=d===oe?a.SRGB8:a.RGB8),r===a.BYTE&&(c=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),r===a.SHORT&&l&&(c=l.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(c=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(c=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(c=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(c=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(c=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RGB8UI),r===a.UNSIGNED_SHORT&&(c=a.RGB16UI),r===a.UNSIGNED_INT&&(c=a.RGB32UI),r===a.BYTE&&(c=a.RGB8I),r===a.SHORT&&(c=a.RGB16I),r===a.INT&&(c=a.RGB32I)),t===a.RGBA){const d=o?Ed:We.getTransfer(n);r===a.FLOAT&&(c=a.RGBA32F),r===a.HALF_FLOAT&&(c=a.RGBA16F),r===a.UNSIGNED_BYTE&&(c=d===oe?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(c=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),r===a.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(c=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(c=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(c=a.RGBA16UI),r===a.UNSIGNED_INT&&(c=a.RGBA32UI),r===a.BYTE&&(c=a.RGBA8I),r===a.SHORT&&(c=a.RGBA16I),r===a.INT&&(c=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(c=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(c=a.DEPTH_COMPONENT24),r===a.FLOAT&&(c=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(c=a.DEPTH24_STENCIL8),(c===a.R16F||c===a.R32F||c===a.RG16F||c===a.RG32F||c===a.RGBA16F||c===a.RGBA32F)&&u.get("EXT_color_buffer_float"),c}setTextureParameters(e,t){const{gl:r,extensions:s,backend:n}=this,{state:o}=this.backend,a=We.getPrimaries(We.workingColorSpace),u=t.colorSpace===Dn?null:We.getPrimaries(t.colorSpace),l=t.colorSpace===Dn||a===u?r.NONE:r.BROWSER_DEFAULT_WEBGL;o.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),o.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),o.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),o.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,l),r.texParameteri(e,r.TEXTURE_WRAP_S,Uo[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,Uo[t.wrapT]),(e===r.TEXTURE_3D||e===r.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,Uo[t.wrapR])),r.texParameteri(e,r.TEXTURE_MAG_FILTER,el[t.magFilter]);const c=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===yt&&c?ls:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,el[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,Pf[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Lt||t.minFilter!==Bn&&t.minFilter!==ls||t.type===dt&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const h=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,n.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,n=this.getGLTextureType(e);let o=s[n];o===void 0&&(o=t.createTexture(),r.state.bindTexture(n,o),t.texParameteri(n,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),s[n]=o),r.set(e,{textureGPU:o,glTextureType:n})}createTexture(e,t){const{gl:r,backend:s}=this;let n,o,a,u,l;if(e.isExternalTexture===!0)n=e.sourceTexture,o=this.getGLTextureType(e);else{const{levels:c,width:d,height:h,depth:f}=t;a=s.utils.convert(e.format,e.colorSpace),u=s.utils.convert(e.type),l=this.getInternalFormat(e.internalFormat,a,u,e.normalized,e.colorSpace,e.isVideoTexture),n=r.createTexture(),o=this.getGLTextureType(e),s.state.bindTexture(o,n),this.setTextureParameters(o,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,c,l,d,h,f):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,c,l,d,h,f):e.isVideoTexture||r.texStorage2D(o,c,l,d,h)}s.set(e,{textureGPU:n,glTextureType:o,glFormat:a,glType:u,glInternalFormat:l})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:n}=s,{textureGPU:o,glTextureType:a,glFormat:u,glType:l}=s.get(t),{width:c,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,o),n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,c,d,u,l,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:n}=t,{textureGPU:o,glTextureType:a,glFormat:u,glType:l,glInternalFormat:c}=this.backend.get(e);if(!(e.isRenderTargetTexture||o===void 0))if(this.backend.state.bindTexture(a,o),this.setTextureParameters(a,e),e.isCompressedTexture){const d=e.mipmaps,h=t.image;for(let f=0;f0){const h=mb(d.width,d.height,e.format,e.type);for(const f of e.layerUpdates){const p=d.data.subarray(f*h/d.data.BYTES_PER_ELEMENT,(f+1)*h/d.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,f,d.width,d.height,1,u,l,p)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,d.width,d.height,d.depth,u,l,d.data)}else if(e.isData3DTexture){const d=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,d.width,d.height,d.depth,u,l,d.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,c,u,l,t.image);else if(e.isHTMLTexture)typeof r.texElementImage2D=="function"&&(r.texElementImage2D.length===3?r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,t.image):r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image));else{const d=e.mipmaps;if(d.length>0)for(let h=0,f=d.length;h0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const f=a!==0||u!==0;let p,g;if(e.isDepthTexture===!0?(p=s.DEPTH_BUFFER_BIT,g=s.DEPTH_ATTACHMENT,t.stencil&&(p|=s.STENCIL_BUFFER_BIT)):(p=s.COLOR_BUFFER_BIT,g=s.COLOR_ATTACHMENT0),f){const m=this.backend.get(t.renderTarget),y=m.framebuffers[t.getCacheKey()],x=m.msaaFrameBuffer;n.bindFramebuffer(s.DRAW_FRAMEBUFFER,y),n.bindFramebuffer(s.READ_FRAMEBUFFER,x);const _=h-u-c;s.blitFramebuffer(a,_,a+l,_+c,a,_,a+l,_+c,p,s.NEAREST),n.bindFramebuffer(s.READ_FRAMEBUFFER,y),n.bindTexture(s.TEXTURE_2D,o),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,_,l,c),n.unbindTexture()}else{const m=s.createFramebuffer();n.bindFramebuffer(s.DRAW_FRAMEBUFFER,m),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,g,s.TEXTURE_2D,o,0),s.blitFramebuffer(0,0,l,c,0,0,l,c,p,s.NEAREST),s.deleteFramebuffer(m)}}else n.bindTexture(s.TEXTURE_2D,o),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,h-c-u,l,c),n.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:n}=this,o=t.renderTarget,{depthTexture:a,depthBuffer:u,stencilBuffer:l,width:c,height:d}=o;if(n.bindRenderbuffer(n.RENDERBUFFER,e),u&&!l){let h=n.DEPTH_COMPONENT24;s===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(n.RENDERBUFFER,o.samples,h,c,d):r>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(h=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,r,h,c,d)):n.renderbufferStorage(n.RENDERBUFFER,h,c,d),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else u&&l&&(r>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,r,n.DEPTH24_STENCIL8,c,d):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,c,d),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e));n.bindRenderbuffer(n.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,n,o){const{backend:a,gl:u}=this,{textureGPU:l,glFormat:c,glType:d}=this.backend.get(e),h=u.createFramebuffer();a.state.bindFramebuffer(u.READ_FRAMEBUFFER,h);const f=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+o:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,f,l,0);const p=this._getTypedArrayType(d),g=this._getBytesPerTexel(d,c),y=s*n*g,x=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,x),u.bufferData(u.PIXEL_PACK_BUFFER,y,u.STREAM_READ),u.readPixels(t,r,s,n,c,d,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const _=new p(y/p.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,x),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,_),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.deleteFramebuffer(h),_}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;if(e===r.UNSIGNED_BYTE&&(s=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(s=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(s=4),t===r.RGBA)return s*4;if(t===r.RGB)return s*3;if(t===r.ALPHA)return s}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function Oo(i){return i.isDataTexture?i.image.data:typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?i:i.data}class IA{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class kA{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const Df={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class GA{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:n,type:o,info:a,index:u}=this;u!==0?r.drawElements(s,t,o,e):r.drawArrays(s,e,t),a.update(n,t,1)}renderInstances(e,t,r){const{gl:s,mode:n,type:o,index:a,object:u,info:l}=this;r!==0&&(a!==0?s.drawElementsInstanced(n,t,o,e,r):s.drawArraysInstanced(n,e,t,r),l.update(u,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:n,object:o,info:a}=this;if(r===0)return;const u=s.get("WEBGL_multi_draw");if(u===null)for(let l=0;lthis.maxQueries)return Be(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const r=this.queries[t];if(r)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(s){O("Error in beginQuery:",s),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(r){O("Error in endQuery:",r),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[n,o]of this.queryOffsets)if(this.queryStates.get(o)==="ended"){const u=this.queries[o];e.set(n,this.resolveQuery(u))}if(e.size===0)return this.lastValue;const t={},r=[];for(const[n,o]of e){const a=n.match(/^(.*):f(\d+)$/),u=parseInt(a[2]);r.includes(u)===!1&&r.push(u),t[u]===void 0&&(t[u]=0);const l=await o;this.timestamps.set(n,l),t[u]+=l}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return O("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let r,s=!1;const n=()=>{r&&(clearTimeout(r),r=null)},o=u=>{s||(s=!0,n(),t(u))},a=()=>{if(this.isDisposed){o(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){o(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){r=setTimeout(a,1);return}const c=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(c)/1e6)}catch(u){O("Error checking query:",u),t(this.lastValue)}};a()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class Ff extends Ey{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=t.context!==void 0?t.context:e.domElement.getContext("webgl2",r);function n(o){o.preventDefault();const a={api:"WebGL",message:o.statusMessage||"Unknown reason",reason:null,originalEvent:o};e.onDeviceLost(a)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=s,this.extensions=new IA(this),this.capabilities=new kA(this),this.attributeUtils=new FA(this),this.textureUtils=new OA(this),this.bufferRenderer=new GA(this),this.state=new LA(this),this.utils=new UA(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(z("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return fa}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),r!==null){const n=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:n}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&z("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new VA(this.gl,e,2048));const r=this.timestampQueryPool[e];r.allocateQueriesForContext(t)!==null&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:n,height:o}=this.getDrawingBufferSize();t.viewport(0,0,n,o)}if(e.scissor)this.updateScissor(e);else{const{width:n,height:o}=this.getDrawingBufferSize();t.scissor(0,0,n,o)}this.initTimestampQuery(br.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),n=s.previousContext;r.resetVertexState();const o=e.occlusionQueryCount;o>0&&(o>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(a!==null)for(let u=0;u{let u=0;for(let l=0;l1?t.renderInstances(r,s,n):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:n,hardwareClippingPlanes:o}=e,{programGPU:a}=this.get(r),{gl:u,state:l}=this,c=this.get(n),d=e.getDrawParameters();if(d===null)return;this._bindUniforms(e.getBindings());const h=t.isMesh&&t.matrixWorld.determinantAffine()<0;l.setMaterial(s,h,o),n.mrt!==null&&n.textures!==null&&l.setMRTBlending(n.textures,n.mrt,s),l.useProgram(a);const f=e.getAttributes(),p=this.get(f);let g=p.vaoGPU;if(g===void 0){const S=this._getVaoKey(f);g=this.vaoCache[S],g===void 0&&(g=this._createVao(f),this.vaoCache[S]=g,p.vaoGPU=g)}const m=e.getIndex(),y=m!==null?this.get(m).bufferGPU:null;l.setVertexState(g,y);const x=c.lastOcclusionObject;if(x!==t&&x!==void 0){if(x!==null&&x.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),c.occlusionQueryIndex++),t.occlusionTest===!0){const S=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,S),c.occlusionQueries[c.occlusionQueryIndex]=S,c.occlusionQueryObjects[c.occlusionQueryIndex]=t}c.lastOcclusionObject=t}const _=this.bufferRenderer;t.isPoints?_.mode=u.POINTS:t.isLineSegments?_.mode=u.LINES:t.isLine?_.mode=u.LINE_STRIP:t.isLineLoop?_.mode=u.LINE_LOOP:s.wireframe===!0?(l.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),_.mode=u.LINES):_.mode=u.TRIANGLES;const{vertexCount:N,instanceCount:A}=d;let{firstVertex:v}=d;if(_.object=t,m!==null){v*=m.array.BYTES_PER_ELEMENT;const S=this.get(m);_.index=m.count,_.type=S.type}else _.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const S=this.get(e.camera),P=e.camera.cameras,F=e.getBindingGroup("cameraIndex").bindings[0];if(S.indexesGPU===void 0||S.indexesGPU.length!==P.length){const X=new Uint32Array([0,0,0,0]),ue=[];for(let D=0,I=P.length;D{const h=this.parallel,f=()=>{r.getProgramParameter(a,h.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),d()):requestAnimationFrame(f)};f()});t.push(c);return}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split(` +`),s=[],n=Math.max(t-6,0),o=Math.min(t+6,r.length);for(let a=n;a":" "} ${u}: ${r[a]}`)}return s.join(` +`)}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),o=(e.getShaderInfoLog(t)||"").trim();if(s&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const u=parseInt(a[1]);return r.toUpperCase()+` + +`+o+` + +`+this._handleSource(e.getShaderSource(t),u)}else return o}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,o=(s.getProgramInfoLog(e)||"").trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,r,t);else{const a=this._getShaderErrors(s,r,"vertex"),u=this._getShaderErrors(s,t,"fragment");O("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+` + +Program Info Log: `+o+` +`+a+` +`+u)}else o!==""&&z("WebGLProgram: Program Info Log:",o)}}_completeCompile(e,t){const{state:r,gl:s}=this,n=this.get(t),{programGPU:o,fragmentShader:a,vertexShader:u}=n;s.getProgramParameter(o,s.LINK_STATUS)===!1&&this._logProgramError(o,a,u),r.useProgram(o);const l=e.getBindings();this._setupBindings(l,o),this.set(t,{programGPU:o,pipeline:o})}createComputePipeline(e,t){const{state:r,gl:s}=this,n={stage:"fragment",code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(n);const{computeProgram:o}=e,a=s.createProgram(),u=this.get(n).shaderGPU,l=this.get(o).shaderGPU,c=o.transforms,d=[],h=[];for(let m=0;mDf[s]===e),r=this.extensions;for(let s=0;s1,f=n.isXRRenderTarget===!0,p=f===!0&&n._hasExternalTextures===!0;let g=o.msaaFrameBuffer,m=o.depthRenderbuffer;const y=this.extensions.get("WEBGL_multisampled_render_to_texture"),x=this.extensions.get("OVR_multiview2"),_=this._useMultisampledExtension(n),N=ry(e);let A;if(c?(o.cubeFramebuffers||(o.cubeFramebuffers={}),A=o.cubeFramebuffers[N]):f&&p===!1?A=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),A=o.framebuffers[N]),A===void 0){A=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,A);const v=e.textures,S=[];if(c){o.cubeFramebuffers[N]=A;const{textureGPU:F}=this.get(v[0]),U=this.renderer._activeCubeFace,W=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+U,F,W)}else{o.framebuffers[N]=A;for(let F=0;F0&&_===!1&&!n.multiview){if(g===void 0){const v=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const S=[],P=e.textures;for(let F=0;F0&&this._useMultisampledExtension(s)===!1){const o=n.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const u=n.msaaFrameBuffer,l=n.msaaRenderbuffers,c=e.textures,d=c.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,u),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,o),d)for(let h=0;h0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const Si={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},Tr=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Je={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},gt={Store:"store"},Te={Load:"load",Clear:"clear"},Lf={CCW:"ccw",CW:"cw"},Uf={None:"none",Back:"back"},Da={Uint16:"uint16",Uint32:"uint32"},b={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},tl={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Vt={Linear:"linear",Nearest:"nearest"},fe={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},vs={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},Of={None:0,All:15},Qr={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},rl={Storage:"storage",ReadOnlyStorage:"read-only-storage"},sl={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},If={NonFiltering:"non-filtering",Comparison:"comparison"},Ss={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},kf={TwoD:"2d",ThreeD:"3d"},et={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},$A={All:"all"},Io={Vertex:"vertex",Instance:"instance"},Fa={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},Gf={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class zA extends wy{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class WA extends Ty{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let jA=0;class HA extends WA{constructor(e,t){super("StorageBuffer_"+jA++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:zt.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const nl=[null];class qA{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.stencil?this.backend.renderer.reversedDepthBuffer===!0?t=b.Depth32FloatStencil8:t=b.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?t=b.Depth32Float:t=b.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const n=this.backend.renderer,o=n.getRenderTarget();t=o?o.samples:n.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);const r=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Si.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Si.LineList;if(e.isLine)return Si.LineStrip;if(e.isMesh)return Si.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const t=this.backend.parameters.outputType;if(t===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(t===St)return b.BGRA8Unorm;if(t===ht)return b.RGBA16Float;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function yr(i,e){nl[0]=e,i.queue.submit(nl),nl[0]=null}class Cy{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class Kn{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class no{constructor(){this.label=""}reset(){this.label=""}}class My{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class Di{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class Fi{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class By{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new XA,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class XA{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class Py{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class Td{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class vd{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const Zr=new Cy,Jr=new Kn,ko=new no,il=new My,ol=new Fi,un=new By,pi=new Di,Go=new Py,ln=new Td,ze=new vd;class KA extends ms{constructor(e){super(),this.device=e;const t=` +struct VarysStruct { + @builtin( position ) Position: vec4f, + @location( 0 ) vTex : vec2f, + @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, +}; + +@group( 0 ) @binding ( 2 ) +var flipY: u32; + +@vertex +fn mainVS( + @builtin( vertex_index ) vertexIndex : u32, + @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array( + vec2f( -1, -1 ), + vec2f( -1, 3 ), + vec2f( 3, -1 ), + ); + + let p = pos[ vertexIndex ]; + let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); + Varys.vTex = p * mult + vec2f( 0.5 ); + Varys.Position = vec4f( p, 0, 1 ); + Varys.vBaseArrayLayer = instanceIndex; + + return Varys; + +} + +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img2d : texture_2d; + +@fragment +fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2d, imgSampler, Varys.vTex ); + +} + +@group( 0 ) @binding( 1 ) +var img2dArray : texture_2d_array; + +@fragment +fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); + +} + +const faceMat = array( + mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x + mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x + mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y + mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y + mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z + mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z +); + +@group( 0 ) @binding( 1 ) +var imgCube : texture_cube; + +@fragment +fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); + +} +`;this.mipmapSampler=e.createSampler({minFilter:Vt.Linear}),this.flipYSampler=e.createSampler({minFilter:Vt.Nearest}),Jr.size=4,Jr.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(Jr),Jr.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),Jr.size=4,Jr.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(Jr),Jr.reset(),this.transferPipelines={},Go.label="mipmap",Go.code=t,this.mipmapShaderModule=e.createShaderModule(Go),Go.reset()}getTransferPipeline(e,t){t=t||"2d-array";const r=`${e}-${t}`;let s=this.transferPipelines[r];return s===void 0&&(un.label=`mipmap-${e}-${t}`,un.vertex={module:this.mipmapShaderModule},un.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},un.layout="auto",s=this.device.createRenderPipeline(un),un.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:n,height:o}=t.size;ln.size.width=n,ln.size.height=o,ln.format=s,ln.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(ln);ln.reset();const u=this.getTransferPipeline(s,e.textureBindingViewDimension),l=this.getTransferPipeline(s,a.textureBindingViewDimension),c=this.device.createCommandEncoder(ko),d=(h,f,p,g,m,y)=>{const x=h.getBindGroupLayout(0);ze.dimension=f.textureBindingViewDimension||"2d-array",ze.mipLevelCount=1;const _=f.createView(ze);ze.reset(),Zr.layout=x,Zr.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:_},{binding:2,resource:{buffer:y?this.flipUniformBuffer:this.noFlipUniformBuffer}});const N=this.device.createBindGroup(Zr);Zr.reset(),ze.dimension="2d",ze.mipLevelCount=1,ze.baseArrayLayer=m,ze.arrayLayerCount=1;const A=g.createView(ze);ze.reset(),pi.view=A,pi.loadOp=Te.Clear,pi.storeOp=gt.Store,ol.colorAttachments.push(pi);const v=c.beginRenderPass(ol);ol.reset(),pi.reset(),v.setPipeline(h),v.setBindGroup(0,N),v.draw(3,1,0,p),v.end()};d(u,e,r,a,0,!1),d(l,a,0,e,r,!0),yr(this.device,c.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let n=t;n===null&&(ko.label="mipmapEncoder",n=this.device.createCommandEncoder(ko),ko.reset()),this._mipmapRunBundles(n,s),t===null&&yr(this.device,n.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),n=[];for(let o=1;o0)for(let o=0,a=s.length;o0){for(const o of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,n,o,e.flipY,o);e.clearLayerUpdates()}else for(let o=0;o0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,n,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,n);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,n);else if(e.isHTMLTexture){const o=this.backend.device,a=this.backend.renderer.domElement,u=e.image;if(typeof o.queue.copyElementImageToTexture!="function")return;if(!r.hasPaintCallback){r.hasPaintCallback=!0,a.requestPaint();return}const l=n.size.width,c=n.size.height;o.queue.copyElementImageToTexture.length===2?o.queue.copyElementImageToTexture({source:u},{destination:{texture:r.texture},width:l,height:c}):o.queue.copyElementImageToTexture(u,l,c,{texture:r.texture}),e.flipY&&this._flipY(r.texture,n)}else if(s.length>0)for(let o=0,a=s.length;o0?e.width:r.size.width,c=a>0?e.height:r.size.height;zo.source=e,zo.flipY=n,cn.texture=t,cn.mipLevel=a,cn.origin.z=s,cn.premultipliedAlpha=o,at.width=l,at.height=c;try{u.queue.copyExternalImageToTexture(zo,cn,at)}catch{}finally{zo.reset(),cn.reset(),at.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new KA(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,n,o=0,a=0){const u=this.backend.device,l=e.data,c=this._getBytesPerTexel(r.format),d=e.width*c;ut.texture=t,ut.mipLevel=a,ut.origin.z=s,Ir.offset=e.width*e.height*c*o,Ir.bytesPerRow=d,at.width=e.width,at.height=e.height,u.queue.writeTexture(ut,l,Ir,at),ut.reset(),Ir.reset(),at.reset(),n===!0&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const n=this.backend.device,o=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,u=s&&s.size>0?s:null;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,oC=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,$f={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},aC=i=>{i=i.trim();const e=i.match(iC);if(e!==null&&e.length===4){const t=e[2],r=[];let s=null;for(;(s=oC.exec(t))!==null;)r.push({name:s[1],type:s[2]});const n=[];for(let c=0;c "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class lC extends yy{parseFunction(e){return new uC(e)}}const cC={[zt.READ_ONLY]:"read",[zt.WRITE_ONLY]:"write",[zt.READ_WRITE]:"read_write"},zf={[Va]:"repeat",[Oi]:"clamp",[Ga]:"mirror"},al={vertex:Tr.VERTEX,fragment:Tr.FRAGMENT,compute:Tr.COMPUTE},Wf={instance:!0,swizzleAssign:!1,storageBuffer:!0},dC={"^^":"tsl_xor"},hC={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},jf={},gi={tsl_xor:new Fe("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Fe("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Fe("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Fe("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Fe("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Fe("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Fe("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Fe("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Fe("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Fe("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Fe("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Fe("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new Fe(` +fn tsl_inverse_mat2( m : mat2x2 ) -> mat2x2 { + + let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; + + return mat2x2( + m[ 1 ][ 1 ], - m[ 0 ][ 1 ], + - m[ 1 ][ 0 ], m[ 0 ][ 0 ] + ) * ( 1.0 / det ); + +} +`),inverse_mat3:new Fe(` +fn tsl_inverse_mat3( m : mat3x3 ) -> mat3x3 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; + + let b01 = a22 * a11 - a12 * a21; + let b11 = - a22 * a10 + a12 * a20; + let b21 = a21 * a10 - a11 * a20; + + let det = a00 * b01 + a01 * b11 + a02 * b21; + + return mat3x3( + b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), + b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), + b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) + ) * ( 1.0 / det ); + +} +`),inverse_mat4:new Fe(` +fn tsl_inverse_mat4( m : mat4x4 ) -> mat4x4 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; + let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + return mat4x4( + a11 * b11 - a12 * b10 + a13 * b09, + a02 * b10 - a01 * b11 - a03 * b09, + a31 * b05 - a32 * b04 + a33 * b03, + a22 * b04 - a21 * b05 - a23 * b03, + a12 * b08 - a10 * b11 - a13 * b07, + a00 * b11 - a02 * b08 + a03 * b07, + a32 * b02 - a30 * b05 - a33 * b01, + a20 * b05 - a22 * b02 + a23 * b01, + a10 * b10 - a11 * b08 + a13 * b06, + a01 * b08 - a00 * b10 - a03 * b06, + a30 * b04 - a31 * b02 + a33 * b00, + a21 * b02 - a20 * b04 - a23 * b00, + a11 * b07 - a10 * b09 - a12 * b06, + a00 * b09 - a01 * b07 + a02 * b06, + a31 * b01 - a30 * b03 - a32 * b00, + a20 * b03 - a21 * b01 + a22 * b00 + ) * ( 1.0 / det ); + +} +`),biquadraticTexture:new Fe(` +fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`),biquadraticTextureArray:new Fe(` +fn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`)},fC={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let Fy="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Fy+=`diagnostic( off, derivative_uniformity ); +`);class pC extends my{constructor(e,t){super(e,t,new lC),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,n,o=this.shaderStage){return o==="fragment"?s?n?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:n?`textureSample( ${t}, ${t}_sampler, ${r}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,n,o){return this.isUnfilterable(e)===!1?n?o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,o,s,n):this.generateTextureLod(e,t,r,n,o,s)}generateWrapFunction(e){const t=`tsl_coord_${zf[e.wrapS]}S_${zf[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=jf[t];if(r===void 0){const s=[],n=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let o=`fn ${t}( coord : ${n} ) -> ${n} { + + return ${n}( +`;const a=(u,l)=>{u===Va?(s.push(gi.repeatWrapping_float),o+=` tsl_repeatWrapping_float( coord.${l} )`):u===Oi?(s.push(gi.clampWrapping_float),o+=` tsl_clampWrapping_float( coord.${l} )`):u===Ga?(s.push(gi.mirrorWrapping_float),o+=` tsl_mirrorWrapping_float( coord.${l} )`):(o+=` coord.${l}`,z(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};a(e.wrapS,"x"),o+=`, +`,a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(o+=`, +`,a(e.wrapR,"z")),o+=` + ); + +} +`,jf[t]=r=new Fe(o,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let n=s.dimensionsSnippet[r];if(s.dimensionsSnippet[r]===void 0){let o,a;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),l=u>1;e.is3DTexture||e.isData3DTexture?a="vec3":a="vec2",l||e.isStorageTexture?o=t:o=`${t}${r?`, u32( ${r} )`:""}`,n=new ua(new la(`textureDimensions( ${o} )`,a)),s.dimensionsSnippet[r]=n,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new ua(new la(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new ua(new la("6u","u32")))}return n.build(this)}generateFilteredTexture(e,t,r,s,n="0u",o){const a=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,n);return s&&(r=`${r} + vec2(${s}) / ${u}`),o?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${u}, u32( ${o} ), u32( ${n} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${u}, u32( ${n} ) )`)}generateTextureLod(e,t,r,s,n,o="0u"){if(e.isCubeTexture===!0){n&&(r=`${r} + vec3(${n})`);const f=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${f}( ${o} ) )`}const a=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,o),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",c=l==="vec3"?"vec3( 1, 1, 1 )":"vec2( 1, 1 )";n&&(r=`${r} + ${l}(${n}) / ${l}( ${u} )`);const d=`${l}( 0 )`,h=`${l}( ${u} - ${c} )`;return r=`${l}( clamp( floor( ${a}( ${r} ) * ${l}( ${u} ) ), ${d}, ${h} ) )`,this.generateTextureLoad(e,t,r,o,s,null)}generateStorageTextureLoad(e,t,r,s,n,o){o&&(r=`${r} + ${o}`);let a;return n?a=`textureLoad( ${t}, ${r}, ${n} )`:a=`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,n,o){s===null&&(s="0u"),o&&(r=`${r} + ${o}`);let a;return n?a=`textureLoad( ${t}, ${r}, ${n}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,n){let o;return s?o=`textureStore( ${t}, ${r}, ${s}, ${n} )`:o=`textureStore( ${t}, ${r}, ${n} )`,o}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(js.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.type===dt||this.isSampleCompare(e)===!1&&e.minFilter===Lt&&e.magFilter===Lt||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,n,o=this.shaderStage){let a=null;return this.isUnfilterable(e)?a=this.generateTextureLod(e,t,r,s,n,"0",o):a=this._generateTextureSample(e,t,r,s,n,o),a}generateTextureGrad(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return n?o?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${s[0]}, ${s[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${s[0]}, ${s[1]} )`:o?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;O(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?o?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;O(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,n,o){const a=e.isDepthTexture===!0?"":`${s}, `;return n?o?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n}, ${o} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:o?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${o} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,n,o){return n?o?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s})`:o?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,n,o){return this.isUnfilterable(e)===!1?n?o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,o,s,n):this.generateTextureLod(e,t,r,n,o,s)}generateTextureBias(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return n?o?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;O(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const r=e.name,s=e.type;return s==="texture"||s==="cubeTexture"||s==="cubeDepthTexture"||s==="storageTexture"||s==="texture3D"?r:s==="buffer"||s==="storageBuffer"||s==="indirectStorageBuffer"?this.isCustomStruct(e)?r:r+".value":e.groupNode.name+"."+r}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=dC[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(z("WebGPURenderer: Atomic operations are only supported in compute shaders."),zt.READ_WRITE):zt.READ_ONLY:e.access}getStorageAccess(e,t){return cC[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const n=super.getUniformFromNode(e,t,r,s),o=this.getDataFromNode(e,r,this.globalCache);if(o.uniformGPU===void 0){let a;const u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,r);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let d=null;const h=this.getNodeAccess(e,r);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?d=new bc(n.name,n.node,u,h):d=new Ja(n.name,n.node,u,h):t==="cubeTexture"||t==="cubeDepthTexture"?d=new Ry(n.name,n.node,u,h):t==="texture3D"&&(d=new bc(n.name,n.node,u,h)),d.store=e.isStorageTextureNode===!0,d.mipLevel=d.store?e.mipLevel:0,d.setVisibility(al[r]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&d.store===!1||e.gatherNode!==null){const p=new zA(`${n.name}_sampler`,n.node,u);p.setVisibility(al[r]),c.push(p,d),a=[p,d]}else c.push(d),a=[d]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const d=this.getSharedDataFromNode(e);let h=d.buffer;if(h===void 0){const f=t==="buffer"?Sy:HA;h=new f(e,u),d.buffer=h}h.setVisibility(h.getVisibility()|al[r]),c.push(h),a=h,n.name=s||"NodeBuffer_"+n.id}else{let d=this.uniformGroups[l];d===void 0&&(d=new Ny(l,u),d.setVisibility(Tr.VERTEX|Tr.FRAGMENT|Tr.COMPUTE),this.uniformGroups[l]=d),c.indexOf(d)===-1&&c.push(d),a=this.getNodeUniform(n,t);const h=a.name;d.uniforms.some(p=>p.name===h)||d.addUniform(a)}o.uniformGPU=a}return n}getBuiltin(e,t,r,s=this.shaderStage){const n=this.builtins[s]||(this.builtins[s]=new Map);return n.has(e)===!1&&n.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const o of t.inputs)s.push(o.name+" : "+this.getType(o.type));let n=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} { +${r.vars} +${r.code} +`;return r.result&&(n+=` return ${r.result}; +`),n+=` +} +`,n}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(r!==void 0)for(const s of r)t.push(`enable ${s};`);return t.join(` +`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(r!==void 0)for(const{name:s,property:n,type:o}of r.values())t.push(`@builtin( ${s} ) ${n} : ${o}`);return t.join(`, + `)}getScopedArray(e,t,r,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:r,scope:s,bufferType:n,bufferCount:o}of this.scopedArrays.values()){const a=this.getType(n);t.push(`var<${s}> ${r}: array< ${a}, ${o} >;`)}return t.join(` +`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const r=this.getBuiltins("attribute");r&&t.push(r);const s=this.getAttributesArray();for(let n=0,o=s.length;n"),t.push(` ${s+r.name} : ${n}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, +`)}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const s=[];for(const n of r){let o=`struct ${n.name} { +`;o+=this.getStructMembers(n),o+=` +};`,s.push(o)}t=` +`+s.join(` + +`)+` +`}return t}getVar(e,t,r=null,s=""){let n=`var${s} ${t} : `;return r!==null?n+=this.generateArrayDeclaration(e,r):n+=this.getType(e),n}getVars(e,t=!1){let r="";t&&(r="");const s=[],n=this.vars[e];if(n!==void 0)for(const o of n)s.push(`${this.getVar(o.type,o.name,o.count,r)};`);return t?s.join(` +`):` + ${s.join(` + `)} +`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),e==="vertex"||e==="fragment"){const n=this.varyings,o=this.vars[e];let a=0;for(let u=0;ur.value.itemSize;return s&&!n}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],n=[],o=[],a={};for(const l of r){const c=l.groupNode.name,d=this.bindingsIndexes[c];if(l.type==="texture"||l.type==="cubeTexture"||l.type==="cubeDepthTexture"||l.type==="storageTexture"||l.type==="texture3D"){const h=l.node,f=h.value;(f.isCubeTexture===!0||this.isUnfilterable(f)===!1&&h.isStorageTextureNode!==!0||h.gatherNode!==null)&&(this.isSampleCompare(f)&&h.compareNode!==null?s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler_comparison;`):s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler;`));let g,m="";const{primarySamples:y}=t.utils.getTextureSampleData(f);if(y>1&&(m="_multisampled"),f.isCubeTexture===!0&&f.isDepthTexture===!0)g="texture_depth_cube";else if(f.isCubeTexture===!0)g="texture_cube";else if(f.isDepthTexture===!0)t.compatibilityMode&&f.compareFunction===null?g=`texture${m}_2d`:g=`texture_depth${m}_2d${f.isArrayTexture===!0?"_array":""}`;else if(l.node.isStorageTextureNode===!0){const x=_c(f,t.device),_=this.getStorageAccess(l.node,e),N=l.node.value.is3DTexture,A=l.node.value.isArrayTexture;g=`texture_storage_${N?"3d":`2d${A?"_array":""}`}<${x}, ${_}>`}else if(f.isArrayTexture===!0||f.isDataArrayTexture===!0||f.isCompressedArrayTexture===!0)g="texture_2d_array";else if(f.is3DTexture===!0||f.isData3DTexture===!0)g="texture_3d";else{const x=this.getComponentTypeFromTexture(f).charAt(0);g=`texture${m}_2d<${x}32>`}s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name} : ${g};`)}else if(l.type==="buffer"||l.type==="storageBuffer"||l.type==="indirectStorageBuffer"){const h=l.node,f=this.getType(h.getNodeType(this)),p=h.bufferCount,g=p>0&&l.type==="buffer"?", "+p:"",m=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(l))n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${m}> ${l.name} : ${f};`);else{const x=` value : array< ${h.isAtomic?`atomic<${f}>`:`${f}`}${g} >`;n.push(this._getWGSLStructBinding(l.name,x,m,d.binding++,d.group))}}else{const h=l.groupNode.name;if(a[h]===void 0){const f=this.uniformGroups[h];if(f!==void 0){const p=[];for(const m of f.uniforms){const y=m.getType(),x=this.getType(this.getVectorType(y));p.push(` ${m.name} : ${x}`)}let g=this.uniformGroupsBindings[h];g===void 0&&(g={index:d.binding++,id:d.group},this.uniformGroupsBindings[h]=g),a[h]={index:g.index,id:g.id,snippets:p}}}}}for(const l in a){const c=a[l];o.push(this._getWGSLStructBinding(l,c.snippets.join(`, +`),"uniform",c.index,c.id))}return[...s,...n,...o].join(` +`)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let n=`// code + +`;n+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],u=a.outputNode,l=u!==void 0&&u.isOutputStructNode===!0;for(const c of o){const d=this.getFlowData(c),h=c.name;if(h&&(n.length>0&&(n+=` +`),n+=` // flow -> ${h} +`),n+=`${d.code} + `,c===a&&t!=="compute"){if(n+=`// result + + `,t==="vertex")n+=`varyings.builtinClipSpace = ${d.result};`;else if(t==="fragment")if(l)s.returnType=u.getNodeType(this),s.structs+="var output : "+s.returnType+";",n+=`return ${d.result};`;else{let f=` @location( 0 ) color: ${this.getType(this.getOutputType())}`;const p=this.getBuiltins("output");p&&(f+=`, + `+p),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",f),s.structs+=` +var output : OutputStruct;`,n+=`output.color = ${this.format(d.result,a.getNodeType(this),this.getOutputType())}; + + return output;`}}}s.flow=n}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return t!==null&&(r=this._getWGSLMethod(e+"_"+t)),r===void 0&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hC[e]||e}isAvailable(e){let t=Wf[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),Wf[e]=t),t}_getWGSLMethod(e){return gi[e]!==void 0&&this._include(e),fC[e]}_include(e){const t=gi[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} +// directives +${e.directives} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// varyings +${e.varyings} +var varyings : VaryingsStruct; + +// vars +${e.vars} + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${Fy} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${e.vars} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){const[r,s,n]=t;return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${this.allowGlobalVariables?e.vars:""} + +// codes +${e.codes} + +@compute @workgroup_size( ${r}, ${s}, ${n} ) +fn main( ${e.attributes} ) { + + // local vars + ${this.allowGlobalVariables?"":e.vars} + + // system + instanceIndex = globalId.x + + globalId.y * ( ${r} * numWorkgroups.x ) + + globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y ); + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,r,s=0,n=0){const o=e+"Struct";return`${this._getWGSLStruct(o,t)} +@binding( ${s} ) @group( ${n} ) +var<${r}> ${e} : ${o};`}}const ot=new Kn,ul=new no,Ly=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&Ly.set(Float16Array,["float16"]);const gC=new Map([[zp,["float16"]]]),mC=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class yC{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,n=s.get(r);let o=n.buffer;if(o===void 0){const a=s.device;let u=r.array;if(e.normalized===!1){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(let h=0;h1&&r.itemSize*u.BYTES_PER_ELEMENT%4!==0){const h=r.itemSize*u.BYTES_PER_ELEMENT;l=Math.floor((h+3)/4)*4/u.BYTES_PER_ELEMENT}if(l!==void 0){const h=r.itemSize,f=new u.constructor(r.count*l);for(let p=0;p1&&d%4!==0&&(d=Math.floor((d+3)/4)*4)),n.normalized===!1&&(n.array.constructor===Int16Array||n.array.constructor===Uint16Array)&&(d=4),u={arrayStride:d,attributes:[],stepMode:h},r.set(a,u)}const l=this._getVertexFormat(n),c=n.isInterleavedBufferAttribute===!0?n.offset*o:0;u.attributes.push({shaderLocation:s,offset:c,format:l})}return Array.from(r.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,r=0,s=-1){const n=this.backend,o=n.device,u=n.get(this._getBufferAttribute(e)).buffer,l=s===-1?u.size-r:s;let c;if(t!==null&&t.isReadbackBuffer){const f=n.get(t);if(t._mapped===!0)throw new Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,f.readBufferGPU===void 0){ot.label=`${t.name}_readback`,ot.size=t.maxByteLength,ot.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=o.createBuffer(ot),ot.reset();const p=()=>{t.buffer=null,t._mapped=!1,c.unmap()},g=()=>{t.buffer=null,t._mapped=!1,c.destroy(),n.delete(t),t.removeEventListener("release",p),t.removeEventListener("dispose",g)};t.addEventListener("release",p),t.addEventListener("dispose",g),f.readBufferGPU=c}else c=f.readBufferGPU}else ot.label=`${e.name}_readback`,ot.size=l,ot.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=o.createBuffer(ot),ot.reset();ul.label=`readback_encoder_${e.name}`;const d=o.createCommandEncoder(ul);ul.reset(),d.copyBufferToBuffer(u,r,c,0,l);const h=d.finish();if(yr(o,h),await c.mapAsync(GPUMapMode.READ,0,l),t===null){const p=c.getMappedRange(0,l).slice();return c.destroy(),p}else{if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,l),t;{const f=c.getMappedRange(0,l);return new Uint8Array(t).set(new Uint8Array(f)),c.destroy(),t}}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,n=e.constructor;let o;if(t===1)o=mC.get(s);else{const u=(gC.get(n)||Ly.get(s))[r?1:0];if(u){const l=s.BYTES_PER_ELEMENT*t,d=Math.floor((l+3)/4)*4/s.BYTES_PER_ELEMENT;if(d%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");o=`${u}x${d}`}}return o||O("WebGPUAttributeUtils: Vertex format not supported yet."),o}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const Mt=new Cy,mi=new Kn,dn=new vd;class bC{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class _C{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const n=this._createLayoutEntries(e),o=Vn(JSON.stringify(n));let a=this._bindGroupLayoutCache.get(o);return a===void 0&&(a=new bC(r.createBindGroupLayout({entries:n})),this._bindGroupLayoutCache.set(o,a)),a.usedTimes++,s.layout=a,s.layoutKey=o,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:n}=this,o=n.get(e),a=this.createBindingsLayout(e);let u;r>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[r]===s&&(u=o.groups[r])),u===void 0&&(u=this.createBindGroup(e,a),r>0&&(o.groups[r]=u,o.versions[r]=s)),o.group=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,n=t.get(e).buffer,o=e.updateRanges;if(o.length===0)r.queue.writeBuffer(n,0,s,0);else{const a=ga(s),u=a?1:s.BYTES_PER_ELEMENT;let l=o[0].start;for(let c=0,d=o.length;c1&&(h+=`-${u.texture.depthOrArrayLayers}`),h+=`-${c}-${d}`,l=u[h],l===void 0){const f=$A.All;let p;a.isSampledCubeTexture?p=et.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?p=et.TwoDArray:a.isSampledTexture3D?p=et.ThreeD:p=et.TwoD,dn.aspect=f,dn.dimension=p,dn.mipLevelCount=c,dn.baseMipLevel=d,l=u[h]=u.texture.createView(dn),dn.reset()}}Mt.entries.push({binding:n,resource:l})}else if(a.isSampler){const u=r.get(a);Mt.entries.push({binding:n,resource:u.sampler})}n++}const o=s.createBindGroup(Mt);return Mt.reset(),o}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const n=this.backend,o={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const a={};s.isStorageBuffer&&(s.visibility&Tr.COMPUTE&&(s.access===zt.READ_WRITE||s.access===zt.WRITE_ONLY)?a.type=rl.Storage:a.type=rl.ReadOnlyStorage),o.buffer=a}else if(s.isSampledTexture&&s.store){const a={};a.format=this.backend.get(s.texture).texture.format;const u=s.access;u===zt.READ_WRITE?a.access=sl.ReadWrite:u===zt.WRITE_ONLY?a.access=sl.WriteOnly:a.access=sl.ReadOnly,s.texture.isArrayTexture?a.viewDimension=et.TwoDArray:s.texture.is3DTexture&&(a.viewDimension=et.ThreeD),o.storageTexture=a}else if(s.isSampledTexture){const a={},{primarySamples:u}=n.utils.getTextureSampleData(s.texture);if(u>1&&(a.multisampled=!0,s.texture.isDepthTexture||(a.sampleType=Ss.UnfilterableFloat)),s.texture.isDepthTexture)n.compatibilityMode&&s.texture.compareFunction===null?a.sampleType=Ss.UnfilterableFloat:a.sampleType=Ss.Depth;else{const l=s.texture.type;l===Ze?a.sampleType=Ss.SInt:l===Ge?a.sampleType=Ss.UInt:l===dt&&(this.backend.hasFeature("float32-filterable")?a.sampleType=Ss.Float:a.sampleType=Ss.UnfilterableFloat)}s.isSampledCubeTexture?a.viewDimension=et.Cube:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?a.viewDimension=et.TwoDArray:s.isSampledTexture3D&&(a.viewDimension=et.ThreeD),o.texture=a}else if(s.isSampler){const a={};s.texture.isDepthTexture&&(s.texture.compareFunction!==null&&s.textureNode.compareNode!==null&&n.hasCompatibility(js.TEXTURE_COMPARE)?a.type=If.Comparison:a.type=If.NonFiltering),o.sampler=a}else O(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(o),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,r.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class xC{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}class TC{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}}class vC{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}}const yi=new TC,hn=new vC,fn=new My,Bt=new By;class SC{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:n,pipeline:o}=e,{vertexProgram:a,fragmentProgram:u}=o,l=this.backend,c=l.device,d=l.utils,h=l.get(o),f=[];for(const X of e.getBindings()){const ue=l.get(X),{layoutGPU:D}=ue.layout;f.push(D)}const p=l.attributeUtils.createShaderVertexBuffers(e);let g;s.blending!==Wr&&(s.blending!==Fr||s.transparent!==!1)&&(g=this._getBlending(s));let m={};s.stencilWrite===!0&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),x=[];if(e.context.textures!==null){const X=e.context.textures,ue=e.context.mrt;for(let D=0;D1,Bt.layout=F;const U={},W=e.context.depth,se=e.context.stencil;(W===!0||se===!0)&&(W===!0&&(U.format=S,U.depthWriteEnabled=s.depthWrite,U.depthCompare=v),se===!0&&(U.stencilFront=m,U.stencilBack=m,U.stencilReadMask=s.stencilFuncMask,U.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&A.topology===Si.TriangleList&&(U.depthBias=s.polygonOffsetUnits,U.depthBiasSlopeScale=s.polygonOffsetFactor,U.depthBiasClamp=0),Bt.depthStencil=U),c.pushErrorScope("validation");const ie=[{program:a,module:_.module},{program:u,module:N.module}],he=Bt.label;if(t===null)h.pipeline=c.createRenderPipeline(Bt),Bt.reset(),c.popErrorScope().then(X=>{X!==null&&(h.error=!0,O(`WebGPURenderer: Render pipeline creation failed (${he}): ${X.message}`),this._reportShaderDiagnostics(ie,he))});else{const X=new Promise(async ue=>{try{let D=null,I=null;try{I=c.createRenderPipelineAsync(Bt)}catch(le){D=le}if(Bt.reset(),I!==null)try{h.pipeline=await I}catch(le){D=le}const Y=await c.popErrorScope();if(Y!==null||D!==null){h.error=!0;const le=Y&&Y.message||D&&D.message||"unknown";O(`WebGPURenderer: Async render pipeline creation failed (${he}): ${le}`),await this._reportShaderDiagnostics(ie,he)}}finally{ue()}});t.push(X)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:n}=r,o=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),u=this._getSampleCount(e);fn.label=t,fn.colorFormats=a,fn.depthStencilFormat=o,fn.sampleCount=u;const l=n.createRenderBundleEncoder(fn);return fn.reset(),l}createComputePipeline(e,t){const r=this.backend,s=r.device,n=r.get(e.computeProgram).module,o=r.get(e),a=[];for(const d of t){const h=r.get(d),{layoutGPU:f}=h.layout;a.push(f)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),hn.bindGroupLayouts=a;const c=s.createPipelineLayout(hn);hn.reset(),yi.label=l,yi.compute=n,yi.layout=c,o.pipeline=s.createComputePipeline(yi),yi.reset(),s.popErrorScope().then(d=>{d!==null&&(o.error=!0,O(`WebGPURenderer: Compute pipeline creation failed (${l}): ${d.message}`),this._reportShaderDiagnostics([{program:u,module:n.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const n=await s.getCompilationInfo();if(n.messages.length===0)continue;const o=r.code.split(` +`);for(const a of n.messages){const u=a.lineNum>0?` at line ${a.lineNum}${a.linePos>0?`:${a.linePos}`:""}`:"",l=`WebGPURenderer [${t} / ${r.stage} ${a.type}]${u}: ${a.message}`;let c="";a.lineNum>0&&a.lineNum<=o.length&&(c=` + ${o[a.lineNum-1]}`,a.linePos>0&&(c+=` + ${" ".repeat(a.linePos-1)}^`)),(a.type==="error"?O:z)(l+c)}}}_getBlending(e){let t,r;const s=e.blending,n=e.blendSrc,o=e.blendDst,a=e.blendEquation;if(s===Sn){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:n,l=e.blendDstAlpha!==null?e.blendDstAlpha:o,c=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(n),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(c)}}else{const u=e.premultipliedAlpha,l=(c,d,h,f)=>{t={srcFactor:c,dstFactor:d,operation:vs.Add},r={srcFactor:h,dstFactor:f,operation:vs.Add}};if(u)switch(s){case Fr:l(fe.One,fe.OneMinusSrcAlpha,fe.One,fe.OneMinusSrcAlpha);break;case bn:l(fe.One,fe.One,fe.One,fe.One);break;case yn:l(fe.Zero,fe.OneMinusSrc,fe.Zero,fe.One);break;case mn:l(fe.Dst,fe.OneMinusSrcAlpha,fe.Zero,fe.One);break}else switch(s){case Fr:l(fe.SrcAlpha,fe.OneMinusSrcAlpha,fe.One,fe.OneMinusSrcAlpha);break;case bn:l(fe.SrcAlpha,fe.One,fe.One,fe.One);break;case yn:O(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case mn:O(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&r!==void 0)return{color:t,alpha:r};O("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case rs:t=fe.Zero;break;case Bp:t=fe.One;break;case Mp:t=fe.Src;break;case wp:t=fe.OneMinusSrc;break;case Cp:t=fe.SrcAlpha;break;case Np:t=fe.OneMinusSrcAlpha;break;case Ep:t=fe.Dst;break;case Sp:t=fe.OneMinusDst;break;case Rp:t=fe.DstAlpha;break;case vp:t=fe.OneMinusDstAlpha;break;case Ap:t=fe.SrcAlphaSaturated;break;case Ww:t=fe.Constant;break;case jw:t=fe.OneMinusConstant;break;default:O("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case Vb:t=Je.Never;break;case Gb:t=Je.Always;break;case kb:t=Je.Less;break;case Ib:t=Je.LessEqual;break;case Ob:t=Je.Equal;break;case Ub:t=Je.GreaterEqual;break;case Lb:t=Je.Greater;break;case Fb:t=Je.NotEqual;break;default:O("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Kb:t=Qr.Keep;break;case Xb:t=Qr.Zero;break;case qb:t=Qr.Replace;break;case Hb:t=Qr.Invert;break;case jb:t=Qr.IncrementClamp;break;case Wb:t=Qr.DecrementClamp;break;case zb:t=Qr.IncrementWrap;break;case $b:t=Qr.DecrementWrap;break;default:O("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Dr:t=vs.Add;break;case Tp:t=vs.Subtract;break;case xp:t=vs.ReverseSubtract;break;case Qb:t=vs.Min;break;case Yb:t=vs.Max;break;default:O("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},n=this.backend.utils;s.topology=n.getPrimitiveTopology(e,r),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?Da.Uint16:Da.Uint32);let o=r.side===ft;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(o=!o),s.frontFace=o===!0?Lf.CW:Lf.CCW,s.cullMode=r.side===Gr?Uf.None:Uf.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?Of.All:Of.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Je.Always;else{const r=this.backend.parameters.reversedDepthBuffer?$p[e.depthFunc]:e.depthFunc;switch(r){case Gp:t=Je.Never;break;case kp:t=Je.Always;break;case Ip:t=Je.Less;break;case Op:t=Je.LessEqual;break;case Up:t=Je.Equal;break;case Lp:t=Je.GreaterEqual;break;case Fp:t=Je.Greater;break;case Dp:t=Je.NotEqual;break;default:O("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class Uy{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const dr=new Kn,NC=new no,bi=new Uy;class wC extends Ay{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,bi.label=`queryset_global_timestamp_${t}`,bi.type="timestamp",bi.count=this.maxQueries,this.querySet=this.device.createQuerySet(bi),bi.reset();const s=this.maxQueries*8;dr.label=`buffer_timestamp_resolve_${t}`,dr.size=s,dr.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(dr),dr.reset(),dr.label=`buffer_timestamp_result_${t}`,dr.size=s,dr.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(dr),dr.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Be(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(NC);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const n=s.finish();if(yr(this.device,n),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const o=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},u=[];for(const[c,d]of e){const h=c.match(/^(.*):f(\d+)$/),f=parseInt(h[2]);u.includes(f)===!1&&u.push(f),a[f]===void 0&&(a[f]=0);const p=o[d],g=o[d+1],m=Number(g-p)/1e6;this.timestamps.set(c,m),a[f]+=m}const l=a[u[u.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=u,l}catch(e){return O("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){O("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){O("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class RC{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}}class Wo{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}class EC{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}}const Qt={r:0,g:0,b:0,a:1},Pt=new Kn,pt=new no,jo=new RC,_i=new Uy,Ho=new Py,qo=new EC,kt=new eu,hr=new eu,De=new vd,Br=new Dy;class AC extends Ey{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new qA(this),this.attributeUtils=new yC(this),this.bindingUtils=new _C(this),this.capabilities=new xC(this),this.pipelineUtils=new SC(this),this.textureUtils=new nC(this),this.occludedResolveCache=new Map;const t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[js.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(t.device===void 0){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},n=typeof navigator<"u"?await navigator.gpu.requestAdapter(s):null;if(n===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const o=Object.values(Fa),a=[];for(const l of o)n.features.has(l)&&a.push(l);const u={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await n.requestDevice(u)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(s=>{if(s.reason==="destroyed")return;const n={api:"WebGPU",message:s.message||"Unknown reason",reason:s.reason||null,originalEvent:s};e.onDeviceLost(n)}),r.onuncapturederror=s=>{const n=s.error,o=n&&n.constructor?n.constructor.name:"GPUError",a=n&&n.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:o,message:a,originalEvent:s})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(Fa.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(r===void 0){const s=this.parameters;e.isDefaultCanvasTarget===!0&&s.context!==void 0?r=s.context:r=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${ka} webgpu`);const n=s.alpha?"premultiplied":"opaque",o=s.outputType===ht?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n,toneMapping:{mode:o}}),t.context=r}return r}get coordinateSystem(){return Ui}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let n=r.descriptor;if(n===void 0||r.samples!==s){if(n=new Fi,n.colorAttachments.push(new Di),e.depth===!0||e.stencil===!0){const u=new Wo;u.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),n.depthStencilAttachment=u}const a=n.colorAttachments[0];s>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,r.descriptor=n,r.samples=s}const o=n.colorAttachments[0];return s>0?o.resolveTarget=this.context.getCurrentTexture().createView():o.view=this.context.getCurrentTexture().createView(),n}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){const t=e.textures;if(t===null)return!1;for(let r=0;r1)if(f===!0){const y=e.camera.cameras;for(let x=0;x0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,_i.label=`occlusionQuerySet_${e.id}`,_i.type="occlusion",_i.count=s,n=r.createQuerySet(_i),_i.reset(),t.occlusionQuerySet=n,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null);let o;e.textures===null?o=this._getDefaultRenderPassDescriptor():o=this._getRenderPassDescriptor(e,{loadOp:Te.Load}),this.initTimestampQuery(br.RENDER,this.getTimestampUID(e),o),o.occlusionQuerySet=n;const a=o.depthStencilAttachment;if(e.textures!==null){const l=o.colorAttachments;for(let c=0;c0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const n=[];for(let o=0;o0){const n=r*8;let o=this.occludedResolveCache.get(n);o===void 0&&(Pt.size=n,Pt.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,o=this.device.createBuffer(Pt),Pt.reset(),this.occludedResolveCache.set(n,o)),Pt.size=n,Pt.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const a=this.device.createBuffer(Pt);Pt.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,o,0),t.encoder.copyBufferToBuffer(o,0,a,0,n),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(yr(this.device,t.encoder.finish()),e.textures!==null){const n=e.textures;for(let o=0;op&&(n[0]=Math.min(f,p),n[1]=Math.ceil(f/p)),o.dispatchSize=n}n=o.dispatchSize}u.dispatchWorkgroups(n[0],n[1]||1,n[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),yr(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,n,o,a,u,l){const{object:c,material:d,context:h}=e,f=e.getIndex(),p=f!==null;l.pipeline!==s&&(u.setPipeline(s),l.pipeline=s);const g=l.bindingGroups;for(let m=0,y=n.length;m65535?4:2);for(let N=0;N0){const h=this.get(e.camera),f=e.camera.cameras,p=e.getBindingGroup("cameraIndex");if(h.indexesGPU===void 0||h.indexesGPU.length!==f.length){const m=this.get(p),y=[],x=new Uint32Array([0,0,0,0]);for(let _=0,N=f.length;_(z("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new Ff(e)));const r=new t(e);super(r,e),this.library=new BC,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}const ll={type:"change"},Sd={type:"start"},Nd={type:"end"},Hf=1e-6,ve={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Xo=new ce,ts=new ce,DC=new V,Ko=new V,cl=new V,pn=new Mn,qf=new V,Yo=new V,dl=new V,Qo=new V;class FC extends Ua{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:tt.ROTATE,MIDDLE:tt.DOLLY,RIGHT:tt.PAN},this.target=new V,this.state=ve.NONE,this.keyState=ve.NONE,this._lastPosition=new V,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new V,this._movePrev=new ce,this._moveCurr=new ce,this._lastAxis=new V,this._zoomStart=new ce,this._zoomEnd=new ce,this._panStart=new ce,this._panEnd=new ce,this._pointers=[],this._pointerPositions={},this._onPointerMove=UC.bind(this),this._onPointerDown=LC.bind(this),this._onPointerUp=OC.bind(this),this._onPointerCancel=IC.bind(this),this._onContextMenu=jC.bind(this),this._onMouseWheel=WC.bind(this),this._onKeyDown=GC.bind(this),this._onKeyUp=kC.bind(this),this._onTouchStart=HC.bind(this),this._onTouchMove=qC.bind(this),this._onTouchEnd=XC.bind(this),this._onMouseDown=VC.bind(this),this._onMouseMove=$C.bind(this),this._onMouseUp=zC.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction=""}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>Hf&&(this.dispatchEvent(ll),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>Hf||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(ll),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=ve.NONE,this.keyState=ve.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(ll),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(ts.copy(this._panEnd).sub(this._panStart),ts.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;ts.x*=e,ts.y*=t}ts.multiplyScalar(this._eye.length()*this.panSpeed),Ko.copy(this._eye).cross(this.object.up).setLength(ts.x),Ko.add(DC.copy(this.object.up).setLength(ts.y)),this.object.position.add(Ko),this.target.add(Ko),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(ts.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Qo.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Qo.length();e?(this._eye.copy(this.object.position).sub(this.target),qf.copy(this._eye).normalize(),Yo.copy(this.object.up).normalize(),dl.crossVectors(Yo,qf).normalize(),Yo.setLength(this._moveCurr.y-this._movePrev.y),dl.setLength(this._moveCurr.x-this._movePrev.x),Qo.copy(Yo.add(dl)),cl.crossVectors(Qo,this._eye).normalize(),e*=this.rotateSpeed,pn.setFromAxisAngle(cl,e),this._eye.applyQuaternion(pn),this.object.up.applyQuaternion(pn),this._lastAxis.copy(cl),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),pn.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(pn),this.object.up.applyQuaternion(pn)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===ve.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=xa.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=xa.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Xo.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Xo}_getMouseOnCircle(e,t){return Xo.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Xo}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(r-=_t),s<-Math.PI?s+=_t:s>Math.PI&&(s-=_t),r<=s?this._spherical.theta=Math.max(r,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+s)/2?Math.max(r,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=o!=this._spherical.radius}if(Ye.setFromSpherical(this._spherical),Ye.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ye),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Ye.length();o=this._clampDistance(a*this._scale);const u=a-o;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),n=!!u}else if(this.object.isOrthographicCamera){const a=new V(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),n=u!==this.object.zoom;const l=new V(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=Ye.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Zo.origin.copy(this.object.position),Zo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Zo.direction))hl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>hl||this._lastTargetPosition.distanceToSquared(this.target)>hl?(this.dispatchEvent(Xf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?_t/60*this.autoRotateSpeed*e:_t/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ye.setFromMatrixColumn(t,0),Ye.multiplyScalar(-e),this._panOffset.add(Ye)}_panUp(e,t){this.screenSpacePanning===!0?Ye.setFromMatrixColumn(t,1):(Ye.setFromMatrixColumn(t,0),Ye.crossVectors(this.object.up,Ye)),Ye.multiplyScalar(e),this._panOffset.add(Ye)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ye.copy(s).sub(this.target);let n=Ye.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*n/r.clientHeight,this.object.matrix),this._panUp(2*t*n/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),s=e-r.left,n=t-r.top,o=r.width,a=r.height;this._mouse.x=s/o*2-1,this._mouse.y=-(n/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_t*this._rotateDelta.x/t.clientHeight),this._rotateUp(_t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(r,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(r,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,n=Math.sqrt(r*r+s*s);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),s=.5*(e.pageX+r.x),n=.5*(e.pageY+r.y);this._rotateEnd.set(s,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_t*this._rotateDelta.x/t.clientHeight),this._rotateUp(_t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(r,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,n=Math.sqrt(r*r+s*s);this._dollyEnd.set(0,n),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tYf||8*(1-this._lastQuaternion.dot(t.quaternion))>Yf)&&(this.dispatchEvent(lM),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function dM(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function hM(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function fM(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function pM(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,r=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-r)/r,this._updateRotationVector()}}function gM(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function mM(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function yM(i){this.enabled!==!1&&i.preventDefault()}const bM={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`};class tu{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const _M=new Lc(-1,1,1,-1,0,1);class xM extends Hi{constructor(){super(),this.setAttribute("position",new _a([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _a([0,2,0,0,2,0],2))}}const TM=new xM;class vM{constructor(e){this._mesh=new sr(TM,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,_M)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class SM extends tu{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Dd?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=m_.clone(e.uniforms),this.material=new Dd({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new vM(this.material)}render(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Zf extends tu{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){const s=e.getContext(),n=e.state;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),n.buffers.stencil.setFunc(s.ALWAYS,o,4294967295),n.buffers.stencil.setClear(a),n.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.color.setMask(!0),n.buffers.depth.setMask(!0),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(s.EQUAL,1,4294967295),n.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),n.buffers.stencil.setLocked(!0)}}class NM extends tu{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class wM{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const r=e.getSize(new ce);this._width=r.width,this._height=r.height,t=new y_(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ht}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new SM(bM),this.copyPass.material.blending=Wr,this.timer=new qp}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&s<1?(a=n,u=o):s>=1&&s<2?(a=o,u=n):s>=2&&s<3?(u=n,l=o):s>=3&&s<4?(u=o,l=n):s>=4&&s<5?(a=o,l=n):s>=5&&s<6&&(a=n,l=o);var c=t-n/2,d=a+c,h=u+c,f=l+c;return r(d,h,f)}var Jf={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function PM(i){if(typeof i!="string")return i;var e=i.toLowerCase();return Jf[e]?"#"+Jf[e]:i}var DM=/^#[a-fA-F0-9]{6}$/,FM=/^#[a-fA-F0-9]{8}$/,LM=/^#[a-fA-F0-9]{3}$/,UM=/^#[a-fA-F0-9]{4}$/,pl=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,OM=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,IM=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,kM=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function kn(i){if(typeof i!="string")throw new _r(3);var e=PM(i);if(e.match(DM))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(FM)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(LM))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(UM)){var r=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:r}}var s=pl.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var n=OM.exec(e.substring(0,50));if(n)return{red:parseInt(""+n[1],10),green:parseInt(""+n[2],10),blue:parseInt(""+n[3],10),alpha:parseFloat(""+n[4])>1?parseFloat(""+n[4])/100:parseFloat(""+n[4])};var o=IM.exec(e);if(o){var a=parseInt(""+o[1],10),u=parseInt(""+o[2],10)/100,l=parseInt(""+o[3],10)/100,c="rgb("+La(a,u,l)+")",d=pl.exec(c);if(!d)throw new _r(4,e,c);return{red:parseInt(""+d[1],10),green:parseInt(""+d[2],10),blue:parseInt(""+d[3],10)}}var h=kM.exec(e.substring(0,50));if(h){var f=parseInt(""+h[1],10),p=parseInt(""+h[2],10)/100,g=parseInt(""+h[3],10)/100,m="rgb("+La(f,p,g)+")",y=pl.exec(m);if(!y)throw new _r(4,e,m);return{red:parseInt(""+y[1],10),green:parseInt(""+y[2],10),blue:parseInt(""+y[3],10),alpha:parseFloat(""+h[4])>1?parseFloat(""+h[4])/100:parseFloat(""+h[4])}}throw new _r(5)}function GM(i){var e=i.red/255,t=i.green/255,r=i.blue/255,s=Math.max(e,t,r),n=Math.min(e,t,r),o=(s+n)/2;if(s===n)return i.alpha!==void 0?{hue:0,saturation:0,lightness:o,alpha:i.alpha}:{hue:0,saturation:0,lightness:o};var a,u=s-n,l=o>.5?u/(2-s-n):u/(s+n);switch(s){case e:a=(t-r)/u+(t=1?ky(i.hue,i.saturation,i.lightness):"rgba("+La(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new _r(2)}function Gy(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return vc("#"+Es(i)+Es(e)+Es(t));if(typeof i=="object"&&e===void 0&&t===void 0)return vc("#"+Es(i.red)+Es(i.green)+Es(i.blue));throw new _r(6)}function ru(i,e,t,r){if(typeof i=="object"&&e===void 0&&t===void 0&&r===void 0)return i.alpha>=1?Gy(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new _r(7)}var jM=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},HM=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},qM=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},XM=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function _s(i){if(typeof i!="object")throw new _r(8);if(HM(i))return ru(i);if(jM(i))return Gy(i);if(XM(i))return WM(i);if(qM(i))return zM(i);throw new _r(8)}function Vy(i,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?i.apply(this,s):Vy(i,e,s)}}function Ot(i){return Vy(i,i.length,[])}function KM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{hue:t.hue+parseFloat(i)}))}Ot(KM);function Yn(i,e,t){return Math.max(i,Math.min(e,t))}function YM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{lightness:Yn(0,1,t.lightness-parseFloat(i))}))}Ot(YM);function QM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{saturation:Yn(0,1,t.saturation-parseFloat(i))}))}Ot(QM);function ZM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{lightness:Yn(0,1,t.lightness+parseFloat(i))}))}Ot(ZM);function JM(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var r=kn(e),s=Et({},r,{alpha:typeof r.alpha=="number"?r.alpha:1}),n=kn(t),o=Et({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),a=s.alpha-o.alpha,u=parseFloat(i)*2-1,l=u*a===-1?u:u+a,c=1+u*a,d=(l/c+1)/2,h=1-d,f={red:Math.floor(s.red*d+o.red*h),green:Math.floor(s.green*d+o.green*h),blue:Math.floor(s.blue*d+o.blue*h),alpha:s.alpha*parseFloat(i)+o.alpha*(1-parseFloat(i))};return ru(f)}var eB=Ot(JM),$y=eB;function tB(i,e){if(e==="transparent")return e;var t=kn(e),r=typeof t.alpha=="number"?t.alpha:1,s=Et({},t,{alpha:Yn(0,1,(r*100+parseFloat(i)*100)/100)});return ru(s)}var rB=Ot(tB),sB=rB;function nB(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{saturation:Yn(0,1,t.saturation+parseFloat(i))}))}Ot(nB);function iB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{hue:parseFloat(i)}))}Ot(iB);function oB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{lightness:parseFloat(i)}))}Ot(oB);function aB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{saturation:parseFloat(i)}))}Ot(aB);function uB(i,e){return e==="transparent"?e:$y(parseFloat(i),"rgb(0, 0, 0)",e)}Ot(uB);function lB(i,e){return e==="transparent"?e:$y(parseFloat(i),"rgb(255, 255, 255)",e)}Ot(lB);function cB(i,e){if(e==="transparent")return e;var t=kn(e),r=typeof t.alpha=="number"?t.alpha:1,s=Et({},t,{alpha:Yn(0,1,+(r*100-parseFloat(i)*100).toFixed(2)/100)});return ru(s)}Ot(cB);function dB(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var hB=`.scene-nav-info { + position: absolute; + bottom: 5px; + width: 100%; + text-align: center; + color: slategrey; + opacity: 0.7; + font-size: 10px; + font-family: sans-serif; + pointer-events: none; + user-select: none; +} + +.scene-container canvas:focus { + outline: none; +}`;dB(hB);function Sc(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var r=null;if(e.hoverDuringDrag||!e.isPointerDragging){var s=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&s.sort(function(o,a){return e.hoverOrderComparator(o.object,a.object)});var n=s.find(function(o){return e.hoverFilter(o.object)})||null;r=n?n.object:null,e.intersection=n||null}r!==e.hoverObj&&(e.onHover(r,e.hoverObj,e.intersection),e.tooltip.content(r&&pe(e.tooltipContent)(r,e.intersection)||null),e.hoverObj=r)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,r=t.x,s=t.y;return{x:r,y:s}},cameraPosition:function(e,t,r,s){var n=e.camera;if(t&&e.initialised){var o,a,u=t,l=r||{x:0,y:0,z:0};if((o=e.povPosTween)===null||o===void 0||o.end(),(a=e.povTgtTween)===null||a===void 0||a.end(),!s)h(u),f(l);else{var c=Object.assign({},n.position),d=p();e.tweenGroup.add(e.povPosTween=new Fd(c).to(u,s).easing(Ld.Quadratic.Out).onUpdate(h).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new Fd(d).to(l,s/3).easing(Ld.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},n.position,{lookAt:p()});function h(g){var m=g.x,y=g.y,x=g.z;m!==void 0&&(n.position.x=m),y!==void 0&&(n.position.y=y),x!==void 0&&(n.position.z=x)}function f(g){var m=new Oe.Vector3(g.x,g.y,g.z);e.controls.enabled&&e.controls.target?e.controls.target=m:n.lookAt(m)}function p(){return Object.assign(new Oe.Vector3(0,0,-1e3).applyQuaternion(n.quaternion).add(n.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,n=new Array(s>3?s-3:0),o=3;o2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,n=e.camera;if(t){var o=new Oe.Vector3(0,0,0),a=Math.max.apply(Math,Ns(Object.entries(t).map(function(f){var p=xB(f,2),g=p[0],m=p[1];return Math.max.apply(Math,Ns(m.map(function(y){return Math.abs(o[g]-y)})))})))*2,u=(1-s*2/e.height)*n.fov,l=a/Math.atan(u*Math.PI/180),c=l/n.aspect,d=Math.max(l,c);if(d>0){var h=o.clone().sub(n.position).normalize().multiplyScalar(-d);this.cameraPosition(h,o,r)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},r=new Oe.Box3(new Oe.Vector3(0,0,0),new Oe.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(n){return r.expandByObject(n)}),Object.assign.apply(Object,Ns(["x","y","z"].map(function(n){return gB({},n,[r.min[n],r.max[n]])})))):null},getScreenCoords:function(e,t,r,s){var n=new Oe.Vector3(t,r,s);return n.project(this.camera()),{x:(n.x+1)*e.width/2,y:-(n.y-1)*e.height/2}},getSceneCoords:function(e,t,r){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,n=new Oe.Vector2(t/e.width*2-1,-(r/e.height)*2+1),o=new Oe.Raycaster;return o.setFromCamera(n,e.camera),Object.assign({},o.ray.at(s,new Oe.Vector3))},intersectingObjects:function(e,t,r){var s=new Oe.Vector2(t/e.width*2-1,-(r/e.height)*2+1),n=new Oe.Raycaster;return n.params.Line.threshold=e.lineHoverPrecision,n.params.Points.threshold=e.pointsHoverPrecision,n.setFromCamera(s,e.camera),n.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,r,s;SB(e.scene),(t=e.controls)===null||t===void 0||t.dispose(),(r=e.renderer)===null||r===void 0||r.dispose(),(s=e.postProcessingComposer)===null||s===void 0||s.dispose()}},stateInit:function(){return{scene:new Oe.Scene,camera:new Oe.PerspectiveCamera,timer:new Oe.Timer,tweenGroup:new w_,lastRaycasterCheck:0}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=r.controlType,n=s===void 0?"trackball":s,o=r.useWebGPU,a=o===void 0?!1:o,u=r.rendererConfig,l=u===void 0?{}:u,c=r.extraRenderers,d=c===void 0?[]:c,h=r.waitForLoadComplete,f=h===void 0?!0:h;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[n]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new N_(t.container),t.pointerPos=new Oe.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(p){return t.container.addEventListener(p,function(g){if(p==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&g.type==="pointermove"&&(g.pressure>0||t.isPointerPressed)&&(g.pointerType==="mouse"||g.movementX===void 0||[g.movementX,g.movementY].some(function(x){return Math.abs(x)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var m=y(t.container);t.pointerPos.x=g.pageX-m.left,t.pointerPos.y=g.pageY-m.top}function y(x){var _=x.getBoundingClientRect(),N=window.pageXOffset||document.documentElement.scrollLeft,A=window.pageYOffset||document.documentElement.scrollTop;return{top:_.top+A,left:_.left+N}}},{passive:!0})}),t.container.addEventListener("pointerup",function(p){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){p.button===0&&t.onClick(t.hoverObj||null,p,t.intersection),p.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,p,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(p){t.onRightClick&&p.preventDefault()}),t.renderer=new(a?PC:Oe.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},l)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=d,t.extraRenderers.forEach(function(p){p.domElement.style.position="absolute",p.domElement.style.top="0px",p.domElement.style.pointerEvents="none",t.container.appendChild(p.domElement)}),t.postProcessingComposer=new wM(t.renderer),t.postProcessingComposer.addPass(new RM(t.scene,t.camera)),t.controls=new{trackball:FC,orbit:YC,fly:cM}[n](t.camera,t.renderer.domElement),n==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(n==="trackball"||n==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Ns(t.extraRenderers)).forEach(function(p){return p.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Oe.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var r,s=e.width,n=e.height;e.container.style.width="".concat(s,"px"),e.container.style.height="".concat(n,"px"),[e.renderer,e.postProcessingComposer].concat(Ns(e.extraRenderers)).forEach(function(f){return f.setSize(s,n)}),e.camera.aspect=s/n;var o=e.viewOffset.slice(0,2);o.some(function(f){return f})&&(r=e.camera).setViewOffset.apply(r,[s,n].concat(Ns(o),[s,n])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var a,u=e.width,l=e.height,c=e.viewOffset.slice(0,2);c.some(function(f){return f})?(a=e.camera).setViewOffset.apply(a,[u,l].concat(Ns(c),[u,l])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Oe.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var d=kn(e.backgroundColor).alpha;d===void 0&&(d=1),e.renderer.setClearColor(new Oe.Color(sB(1,e.backgroundColor)),d)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Oe.TextureLoader().load(e.backgroundImageUrl,function(f){f.colorSpace=Oe.SRGBColorSpace,e.skysphere.material=new Oe.MeshBasicMaterial({map:f,side:Oe.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&h()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&h())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(f){return e.scene.remove(f)}),e.lights.forEach(function(f){return e.scene.add(f)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(f){return e.scene.remove(f)}),e.objects.forEach(function(f){return e.scene.add(f)}));function h(){e.loadComplete=e.scene.visible=!0}}});function NB(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var wB=`.graph-info-msg { + top: 50%; + width: 100%; + text-align: center; + color: lavender; + opacity: 0.7; + font-size: 22px; + position: absolute; + font-family: Sans-serif; +} + +.scene-container .clickable { + cursor: pointer; +} + +.scene-container .grabbable { + cursor: move; + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +.scene-container .grabbable:active { + cursor: grabbing; + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +}`;NB(wB);function Nc(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t1?a-1:0),l=1;l3?n-3:0),a=3;a=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Et.hasOwnProperty(e)?{space:Et[e],local:t}:t}function Pe(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===dt&&e.documentElement.namespaceURI===dt?e.createElement(t):e.createElementNS(n,t)}}function Ee(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Qt(t){var e=Kt(t);return(e.local?Ee:Pe)(e)}function Oe(){}function Jt(t){return t==null?Oe:function(){return this.querySelector(t)}}function Ie(t){typeof t!="function"&&(t=Jt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=A&&(A=g+1);!(M=b[A])&&++A=0;)(s=r[i])&&(a&&s.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(s,a),a=s);return this}function sn(t){t||(t=on);function e(_,u){return _&&u?t(_.__data__,u.__data__):!_-!u}for(var n=this._groups,r=n.length,i=new Array(r),a=0;ae?1:t>=e?0:NaN}function fn(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ln(){return Array.from(this)}function un(){for(var t=this._groups,e=0,n=t.length;e1?this.each((e==null?wn:typeof e=="function"?xn:Sn)(t,e,n??"")):kn(this.node(),t)}function kn(t,e){return t.style.getPropertyValue(e)||ee(t).getComputedStyle(t,null).getPropertyValue(e)}function Mn(t){return function(){delete this[t]}}function Tn(t,e){return function(){this[t]=e}}function Cn(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Pn(t,e){return arguments.length>1?this.each((e==null?Mn:typeof e=="function"?Cn:Tn)(t,e)):this.node()[t]}function ne(t){return t.trim().split(/^|\s+/)}function St(t){return t.classList||new re(t)}function re(t){this._node=t,this._names=ne(t.getAttribute("class")||"")}re.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function ie(t,e){for(var n=St(t),r=-1,i=e.length;++r=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function rr(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,a;n=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n=i)&&(n=i)}return n}function Yi(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}var yr=typeof global=="object"&&global&&global.Object===Object&&global,br=typeof self=="object"&&self&&self.Object===Object&&self,fe=yr||br||Function("return this")(),nt=fe.Symbol,le=Object.prototype,mr=le.hasOwnProperty,wr=le.toString,V=nt?nt.toStringTag:void 0;function Sr(t){var e=mr.call(t,V),n=t[V];try{t[V]=void 0;var r=!0}catch{}var i=wr.call(t);return r&&(e?t[V]=n:delete t[V]),i}var xr=Object.prototype,Ar=xr.toString;function kr(t){return Ar.call(t)}var Mr="[object Null]",Tr="[object Undefined]",Rt=nt?nt.toStringTag:void 0;function Cr(t){return t==null?t===void 0?Tr:Mr:Rt&&Rt in Object(t)?Sr(t):kr(t)}function Pr(t){return t!=null&&typeof t=="object"}var Er="[object Symbol]";function Or(t){return typeof t=="symbol"||Pr(t)&&Cr(t)==Er}var Ir=/\s/;function Rr(t){for(var e=t.length;e--&&Ir.test(t.charAt(e)););return e}var Fr=/^\s+/;function Hr(t){return t&&t.slice(0,Rr(t)+1).replace(Fr,"")}function pt(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Ft=NaN,Nr=/^[-+]0x[0-9a-f]+$/i,jr=/^0b[01]+$/i,Ur=/^0o[0-7]+$/i,Lr=parseInt;function Ht(t){if(typeof t=="number")return t;if(Or(t))return Ft;if(pt(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=pt(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Hr(t);var n=jr.test(t);return n||Ur.test(t)?Lr(t.slice(2),n?2:8):Nr.test(t)?Ft:+t}var ht=function(){return fe.Date.now()},Dr="Expected a function",$r=Math.max,Br=Math.min;function zr(t,e,n){var r,i,a,s,o,l,f=0,c=!1,_=!1,u=!0;if(typeof t!="function")throw new TypeError(Dr);e=Ht(e)||0,pt(n)&&(c=!!n.leading,_="maxWait"in n,a=_?$r(Ht(n.maxWait)||0,e):a,u="trailing"in n?!!n.trailing:u);function h(y){var T=r,m=i;return r=i=void 0,f=y,s=t.apply(m,T),s}function p(y){return f=y,o=setTimeout(v,e),c?h(y):s}function w(y){var T=y-l,m=y-f,D=e-T;return _?Br(D,a-m):D}function b(y){var T=y-l,m=y-f;return l===void 0||T>=e||T<0||_&&m>=a}function v(){var y=ht();if(b(y))return g(y);o=setTimeout(v,w(y))}function g(y){return o=void 0,u&&r?h(y):(r=i=void 0,s)}function A(){o!==void 0&&clearTimeout(o),f=0,r=l=i=o=void 0}function P(){return o===void 0?s:g(ht())}function M(){var y=ht(),T=b(y);if(r=arguments,i=this,l=y,T){if(o===void 0)return p(l);if(_)return clearTimeout(o),o=setTimeout(v,e),h(l)}return o===void 0&&(o=setTimeout(v,e)),s}return M.cancel=A,M.flush=P,M}var G=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return t},Out:function(t){return t},InOut:function(t){return t}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return .5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return t===0?0:Math.pow(1024,t-1)},Out:function(t){return t===1?1:1-Math.pow(2,-10*t)},InOut:function(t){return t===0?0:t===1?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return t===0?0:t===1?1:-Math.pow(2,10*(t-1))*Math.sin((t-1.1)*5*Math.PI)},Out:function(t){return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t-.1)*5*Math.PI)+1},InOut:function(t){return t===0?0:t===1?1:(t*=2,t<1?-.5*Math.pow(2,10*(t-1))*Math.sin((t-1.1)*5*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin((t-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(t){var e=1.70158;return t===1?1:t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return t===0?0:--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}}),Bounce:Object.freeze({In:function(t){return 1-G.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?G.Bounce.In(t*2)*.5:G.Bounce.Out(t*2-1)*.5+.5}}),generatePow:function(t){return t===void 0&&(t=4),t=t1e4?1e4:t,{In:function(e){return Math.pow(e,t)},Out:function(e){return 1-Math.pow(1-e,t)},InOut:function(e){return e<.5?Math.pow(e*2,t)/2:(1-Math.pow(2-e*2,t))/2+.5}}}}),W=function(){return performance.now()},Vr=(function(){function t(){for(var e=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?a(t[n],t[n-1],n-r):a(t[i],t[i+1>n?n:i+1],r-i)},Utils:{Linear:function(t,e,n){return(e-t)*n+t}}},ue=(function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t})(),vt=new Vr,Ki=(function(){function t(e,n){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=G.Linear.None,this._interpolationFunction=gt.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ue.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof n=="object"?(this._group=n,n.add(this)):n===!0&&(this._group=vt,vt.add(this))}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(e,n){if(n===void 0&&(n=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=n<0?0:n,this},t.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},t.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},t.prototype.start=function(e,n){if(e===void 0&&(e=W()),n===void 0&&(n=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var r in this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||n){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var a in this._valuesEnd)i[a]=this._valuesEnd[a];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,n)}return this},t.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},t.prototype._setupProperties=function(e,n,r,i,a){for(var s in r){var o=e[s],l=Array.isArray(o),f=l?"array":typeof o,c=!l&&Array.isArray(r[s]);if(!(f==="undefined"||f==="function")){if(c){var _=r[s];if(_.length===0)continue;for(var u=[o],h=0,p=_.length;h"u"||a)&&(n[s]=o),l||(n[s]*=1),c?i[s]=r[s].slice().reverse():i[s]=n[s]||0}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},t.prototype.pause=function(e){return e===void 0&&(e=W()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},t.prototype.resume=function(e){return e===void 0&&(e=W()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},t.prototype.stopChainedTweens=function(){for(var e=0,n=this._chainedTweens.length;el)return 1;var w=Math.trunc(s/o),b=s-w*o,v=Math.min(b/r._duration,1);return v===0&&s===r._duration?1:v},c=f(),_=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,_),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||s>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((s-this._duration)/o)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var h=0,p=this._chainedTweens.length;ht.length)&&(e=t.length);for(var n=0,r=Array(e);n=0,a=!n&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return a?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return d(this.toString())},_applyModification:function(e,n){var r=e.apply(null,[this].concat([].slice.call(n)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(ui,arguments)},brighten:function(){return this._applyModification(ci,arguments)},darken:function(){return this._applyModification(hi,arguments)},desaturate:function(){return this._applyModification(oi,arguments)},saturate:function(){return this._applyModification(fi,arguments)},greyscale:function(){return this._applyModification(li,arguments)},spin:function(){return this._applyModification(_i,arguments)},_applyCombination:function(e,n){return e.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(gi,arguments)},complement:function(){return this._applyCombination(di,arguments)},monochromatic:function(){return this._applyCombination(vi,arguments)},splitcomplement:function(){return this._applyCombination(pi,arguments)},triad:function(){return this._applyCombination($t,[3])},tetrad:function(){return this._applyCombination($t,[4])}};d.fromRatio=function(t,e){if(rt(t)=="object"){var n={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?n[r]=t[r]:n[r]=q(t[r]));t=n}return d(t,e)};function ni(t){var e={r:0,g:0,b:0},n=1,r=null,i=null,a=null,s=!1,o=!1;return typeof t=="string"&&(t=Si(t)),rt(t)=="object"&&(L(t.r)&&L(t.g)&&L(t.b)?(e=ri(t.r,t.g,t.b),s=!0,o=String(t.r).substr(-1)==="%"?"prgb":"rgb"):L(t.h)&&L(t.s)&&L(t.v)?(r=q(t.s),i=q(t.v),e=ai(t.h,r,i),s=!0,o="hsv"):L(t.h)&&L(t.s)&&L(t.l)&&(r=q(t.s),a=q(t.l),e=ii(t.h,r,a),s=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=ce(n),{ok:s,format:t.format||o,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}function ri(t,e,n){return{r:S(t,255)*255,g:S(e,255)*255,b:S(n,255)*255}}function jt(t,e,n){t=S(t,255),e=S(e,255),n=S(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),a,s,o=(r+i)/2;if(r==i)a=s=0;else{var l=r-i;switch(s=o>.5?l/(2-r-i):l/(r+i),r){case t:a=(e-n)/l+(e1&&(_-=1),_<1/6?f+(c-f)*6*_:_<1/2?c:_<2/3?f+(c-f)*(2/3-_)*6:f}if(e===0)r=i=a=n;else{var o=n<.5?n*(1+e):n+e-n*e,l=2*n-o;r=s(l,o,t+1/3),i=s(l,o,t),a=s(l,o,t-1/3)}return{r:r*255,g:i*255,b:a*255}}function Ut(t,e,n){t=S(t,255),e=S(e,255),n=S(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),a,s,o=r,l=r-i;if(s=r===0?0:l/r,r==i)a=0;else{switch(r){case t:a=(e-n)/l+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,a.push(d(r));return a}function vi(t,e){e=e||6;for(var n=d(t).toHsv(),r=n.h,i=n.s,a=n.v,s=[],o=1/e;e--;)s.push(d({h:r,s:i,v:a})),a=(a+o)%1;return s}d.mix=function(t,e,n){n=n===0?0:n||50;var r=d(t).toRgb(),i=d(e).toRgb(),a=n/100,s={r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a};return d(s)};d.readability=function(t,e){var n=d(t),r=d(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)};d.isReadable=function(t,e,n){var r=d.readability(t,e),i,a;switch(a=!1,i=xi(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=r>=4.5;break;case"AAlarge":a=r>=3;break;case"AAAsmall":a=r>=7;break}return a};d.mostReadable=function(t,e,n){var r=null,i=0,a,s,o,l;n=n||{},s=n.includeFallbackColors,o=n.level,l=n.size;for(var f=0;fi&&(i=a,r=d(e[f]));return d.isReadable(t,r,{level:o,size:l})||!s?r:(n.includeFallbackColors=!1,d.mostReadable(t,["#fff","#000"],n))};var yt=d.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},yi=d.hexNames=bi(yt);function bi(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function ce(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function S(t,e){mi(t)&&(t="100%");var n=wi(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function ft(t){return Math.min(1,Math.max(0,t))}function E(t){return parseInt(t,16)}function mi(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function wi(t){return typeof t=="string"&&t.indexOf("%")!=-1}function F(t){return t.length==1?"0"+t:""+t}function q(t){return t<=1&&(t=t*100+"%"),t}function he(t){return Math.round(parseFloat(t)*255).toString(16)}function Bt(t){return E(t)/255}var R=(function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",i="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function L(t){return!!R.CSS_UNIT.exec(t)}function Si(t){t=t.replace(ti,"").replace(ei,"").toLowerCase();var e=!1;if(yt[t])t=yt[t],e=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=R.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=R.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=R.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=R.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=R.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=R.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=R.hex8.exec(t))?{r:E(n[1]),g:E(n[2]),b:E(n[3]),a:Bt(n[4]),format:e?"name":"hex8"}:(n=R.hex6.exec(t))?{r:E(n[1]),g:E(n[2]),b:E(n[3]),format:e?"name":"hex"}:(n=R.hex4.exec(t))?{r:E(n[1]+""+n[1]),g:E(n[2]+""+n[2]),b:E(n[3]+""+n[3]),a:Bt(n[4]+""+n[4]),format:e?"name":"hex8"}:(n=R.hex3.exec(t))?{r:E(n[1]+""+n[1]),g:E(n[2]+""+n[2]),b:E(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function xi(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),n!=="small"&&n!=="large"&&(n="small"),{level:e,size:n}}var K,x,_e,de,$,zt,pe,ge,_t,Z,X,ve,xt,bt,mt,it={},at=[],Ai=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,lt=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function At(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ki(t,e,n){var r,i,a,s={};for(a in e)a=="key"?r=e[a]:a=="ref"?i=e[a]:s[a]=e[a];if(arguments.length>2&&(s.children=arguments.length>3?K.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(a in t.defaultProps)s[a]===void 0&&(s[a]=t.defaultProps[a]);return Y(t,s,r,i,null)}function Y(t,e,n,r,i){var a={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++_e,__i:-1,__u:0};return i==null&&x.vnode!=null&&x.vnode(a),a}function ut(t){return t.children}function tt(t,e){this.props=t,this.context=e}function z(t,e){if(e==null)return t.__?z(t.__,t.__i+1):null;for(var n;ee&&$.sort(ge),t=$.shift(),e=$.length,Mi(t)}finally{$.length=st.__r=0}}function be(t,e,n,r,i,a,s,o,l,f,c){var _,u,h,p,w,b,v=r&&r.__k||at,g=e.length;for(l=Ti(n,e,v,l,g),_=0;_0?s=t.__k[a]=Y(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[a]=s,l=a+u,s.__=t,s.__b=t.__b+1,o=null,(f=s.__i=Ci(s,n,l,_))!=-1&&(_--,(o=n[f])&&(o.__u|=2)),o==null||o.__v==null?(f==-1&&(i>c?u--:il?u--:u++,s.__u|=4))):t.__k[a]=null;if(_)for(a=0;a(c?1:0)){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&(2&f.__u)==0&&o==f.key&&l==f.type)return s}return-1}function Wt(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Ai.test(e)?n:n+"px"}function J(t,e,n,r,i){var a,s;t:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Wt(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Wt(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")a=e!=(e=e.replace(ve,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+a]=n,n?r?n[X]=r[X]:(n[X]=xt,t.addEventListener(e,a?mt:bt,a)):t.removeEventListener(e,a?mt:bt,a);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break t}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function qt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[Z]==null)e[Z]=xt++;else if(e[Z]0?t:lt(t)?t.map(xe):t.constructor!==void 0?null:H({},t)}function Pi(t,e,n,r,i,a,s,o,l){var f,c,_,u,h,p,w,b=n.props||it,v=e.props,g=e.type;if(g=="svg"?i="http://www.w3.org/2000/svg":g=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(f=0;f2&&(o.children=arguments.length>3?K.call(arguments,2):n),Y(t.type,o,r||t.key,i||t.ref,null)}K=at.slice,x={__e:function(t,e,n,r){for(var i,a,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(o){t=o}throw t}},_e=0,de=function(t){return t!=null&&t.constructor===void 0},tt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Vt(this))},tt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Vt(this))},tt.prototype.render=ut,$=[],pe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ge=function(t,e){return t.__v.__b-e.__v.__b},st.__r=0,_t=Math.random().toString(8),Z="__d"+_t,X="__a"+_t,ve=/(PointerCapture)$|Capture$/i,xt=0,bt=qt(!1),mt=qt(!0);function Gt(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",n==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}var Vi=`.float-tooltip-kap { + position: absolute; + width: max-content; /* prevent shrinking near right edge */ + max-width: max(50%, 150px); + padding: 3px 5px; + border-radius: 3px; + font: 12px sans-serif; + color: #eee; + background: rgba(0,0,0,0.6); + pointer-events: none; +} +`;zi(Vi);var Ji=Zr({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.style,a=i===void 0?{}:i,s=!!e&&ot(e)==="object"&&!!e.node&&typeof e.node=="function",o=hr(s?e.node():e);o.style("position")==="static"&&o.style("position","relative"),n.tooltipEl=o.append("div").attr("class","float-tooltip-kap"),Object.entries(a).forEach(function(f){var c=ji(f,2),_=c[0],u=c[1];return n.tooltipEl.style(_,u)}),n.tooltipEl.style("left","-10000px").style("display","none");var l="tooltip-".concat(Math.round(Math.random()*1e12));n.mouseInside=!1,o.on("mousemove.".concat(l),function(f){n.mouseInside=!0;var c=dr(f),_=o.node(),u=_.offsetWidth,h=_.offsetHeight,p=[n.offsetX===null||n.offsetX===void 0?"-".concat(c[0]/u*100,"%"):typeof n.offsetX=="number"?"calc(-50% + ".concat(n.offsetX,"px)"):n.offsetX,n.offsetY===null||n.offsetY===void 0?h>130&&h-c[1]<100?"calc(-100% - 6px)":"21px":typeof n.offsetY=="number"?n.offsetY<0?"calc(-100% - ".concat(Math.abs(n.offsetY),"px)"):"".concat(n.offsetY,"px"):n.offsetY];n.tooltipEl.style("left",c[0]+"px").style("top",c[1]+"px").style("transform","translate(".concat(p.join(","),")")),n.content&&n.tooltipEl.style("display","inline")}),o.on("mouseover.".concat(l),function(){n.mouseInside=!0,n.content&&n.tooltipEl.style("display","inline")}),o.on("mouseout.".concat(l),function(){n.mouseInside=!1,n.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):$i(e.content)?(e.tooltipEl.text(""),Bi(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function Wi(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}const Yt=Symbol("implicit");function qi(){var t=new Ot,e=[],n=[],r=Yt;function i(a){let s=t.get(a);if(s===void 0){if(r!==Yt)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new Ot;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return qi(e,n).unknown(r)},Wi.apply(i,arguments),i}function Gi(t){for(var e=t.length/6|0,n=new Array(e),r=0;r()=>n;function oe(n,{sourceEvent:e,subject:r,target:i,identifier:o,active:u,x:a,y:s,dx:l,dy:c,dispatch:f}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}oe.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function $n(n){return!n.ctrlKey&&!n.button}function jn(){return this.parentNode}function Ln(n,e){return e??{x:n.x,y:n.y}}function Fn(){return navigator.maxTouchPoints||"ontouchstart"in this}function qn(){var n=$n,e=jn,r=Ln,i=Fn,o={},u=pe("start","drag","end"),a=0,s,l,c,f,h=0;function d(v){v.on("mousedown.drag",g).filter(i).on("touchstart.drag",C).on("touchmove.drag",m,Un).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(v,_){if(!(f||!n.call(this,v,_))){var M=R(this,e.call(this,v,_),v,_,"mouse");M&&(Q(v.view).on("mousemove.drag",y,At).on("mouseup.drag",w,At),Be(v.view),Qt(v),c=!1,s=v.clientX,l=v.clientY,M("start",v))}}function y(v){if(wt(v),!c){var _=v.clientX-s,M=v.clientY-l;c=_*_+M*M>h}o.mouse("drag",v)}function w(v){Q(v.view).on("mousemove.drag mouseup.drag",null),Qe(v.view,c),wt(v),o.mouse("end",v)}function C(v,_){if(n.call(this,v,_)){var M=v.changedTouches,k=e.call(this,v,_),E=M.length,A,P;for(A=0;A>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?$t(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?$t(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Vn.exec(n))?new X(e[1],e[2],e[3],1):(e=Hn.exec(n))?new X(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Xn.exec(n))?$t(e[1],e[2],e[3],e[4]):(e=Wn.exec(n))?$t(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Yn.exec(n))?Oe(e[1],e[2]/100,e[3]/100,1):(e=Zn.exec(n))?Oe(e[1],e[2]/100,e[3]/100,e[4]):Ce.hasOwnProperty(n)?Ee(Ce[n]):n==="transparent"?new X(NaN,NaN,NaN,0):null}function Ee(n){return new X(n>>16&255,n>>8&255,n&255,1)}function $t(n,e,r,i){return i<=0&&(n=e=r=NaN),new X(n,e,r,i)}function Qn(n){return n instanceof Nt||(n=Dt(n)),n?(n=n.rgb(),new X(n.r,n.g,n.b,n.opacity)):new X}function ae(n,e,r,i){return arguments.length===1?Qn(n):new X(n,e,r,i??1)}function X(n,e,r,i){this.r=+n,this.g=+e,this.b=+r,this.opacity=+i}ye(X,ae,Je(Nt,{brighter(n){return n=n==null?Xt:Math.pow(Xt,n),new X(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Rt:Math.pow(Rt,n),new X(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new X(mt(this.r),mt(this.g),mt(this.b),Wt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Me,formatHex:Me,formatHex8:Jn,formatRgb:Te,toString:Te}));function Me(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}`}function Jn(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}${yt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Te(){const n=Wt(this.opacity);return`${n===1?"rgb(":"rgba("}${mt(this.r)}, ${mt(this.g)}, ${mt(this.b)}${n===1?")":`, ${n})`}`}function Wt(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function mt(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function yt(n){return n=mt(n),(n<16?"0":"")+n.toString(16)}function Oe(n,e,r,i){return i<=0?n=e=r=NaN:r<=0||r>=1?n=e=NaN:e<=0&&(n=NaN),new J(n,e,r,i)}function tn(n){if(n instanceof J)return new J(n.h,n.s,n.l,n.opacity);if(n instanceof Nt||(n=Dt(n)),!n)return new J;if(n instanceof J)return n;n=n.rgb();var e=n.r/255,r=n.g/255,i=n.b/255,o=Math.min(e,r,i),u=Math.max(e,r,i),a=NaN,s=u-o,l=(u+o)/2;return s?(e===u?a=(r-i)/s+(r0&&l<1?0:a,new J(a,s,l,n.opacity)}function tr(n,e,r,i){return arguments.length===1?tn(n):new J(n,e,r,i??1)}function J(n,e,r,i){this.h=+n,this.s=+e,this.l=+r,this.opacity=+i}ye(J,tr,Je(Nt,{brighter(n){return n=n==null?Xt:Math.pow(Xt,n),new J(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Rt:Math.pow(Rt,n),new J(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,r=this.l,i=r+(r<.5?r:1-r)*e,o=2*r-i;return new X(Jt(n>=240?n-240:n+120,o,i),Jt(n,o,i),Jt(n<120?n+240:n-120,o,i),this.opacity)},clamp(){return new J(Ae(this.h),jt(this.s),jt(this.l),Wt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Wt(this.opacity);return`${n===1?"hsl(":"hsla("}${Ae(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${n===1?")":`, ${n})`}`}}));function Ae(n){return n=(n||0)%360,n<0?n+360:n}function jt(n){return Math.max(0,Math.min(1,n||0))}function Jt(n,e,r){return(n<60?e+(r-e)*n/60:n<180?r:n<240?e+(r-e)*(240-n)/60:e)*255}const en=n=>()=>n;function er(n,e){return function(r){return n+r*e}}function nr(n,e,r){return n=Math.pow(n,r),e=Math.pow(e,r)-n,r=1/r,function(i){return Math.pow(n+i*e,r)}}function rr(n){return(n=+n)==1?nn:function(e,r){return r-e?nr(e,r,n):en(isNaN(e)?r:e)}}function nn(n,e){var r=e-n;return r?er(n,r):en(isNaN(n)?e:n)}const Re=(function n(e){var r=rr(e);function i(o,u){var a=r((o=ae(o)).r,(u=ae(u)).r),s=r(o.g,u.g),l=r(o.b,u.b),c=nn(o.opacity,u.opacity);return function(f){return o.r=a(f),o.g=s(f),o.b=l(f),o.opacity=c(f),o+""}}return i.gamma=n,i})(1);function gt(n,e){return n=+n,e=+e,function(r){return n*(1-r)+e*r}}var ue=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,te=new RegExp(ue.source,"g");function ir(n){return function(){return n}}function or(n){return function(e){return n(e)+""}}function ar(n,e){var r=ue.lastIndex=te.lastIndex=0,i,o,u,a=-1,s=[],l=[];for(n=n+"",e=e+"";(i=ue.exec(n))&&(o=te.exec(e));)(u=o.index)>r&&(u=e.slice(r,u),s[a]?s[a]+=u:s[++a]=u),(i=i[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,l.push({i:a,x:gt(i,o)})),r=te.lastIndex;return r180?f+=360:f-c>180&&(c+=360),d.push({i:h.push(o(h)+"rotate(",null,i)-2,x:gt(c,f)})):f&&h.push(o(h)+"rotate("+f+i)}function s(c,f,h,d){c!==f?d.push({i:h.push(o(h)+"skewX(",null,i)-2,x:gt(c,f)}):f&&h.push(o(h)+"skewX("+f+i)}function l(c,f,h,d,g,y){if(c!==h||f!==d){var w=g.push(o(g)+"scale(",null,",",null,")");y.push({i:w-4,x:gt(c,h)},{i:w-2,x:gt(f,d)})}else(h!==1||d!==1)&&g.push(o(g)+"scale("+h+","+d+")")}return function(c,f){var h=[],d=[];return c=n(c),f=n(f),u(c.translateX,c.translateY,f.translateX,f.translateY,h,d),a(c.rotate,f.rotate,h,d),s(c.skewX,f.skewX,h,d),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,h,d),c=f=null,function(g){for(var y=-1,w=d.length,C;++y{i.stop(),n(o+e)},e,r),i}var pr=pe("start","end","cancel","interrupt"),yr=[],an=0,Ne=1,le=2,Gt=3,Ue=4,ce=5,Vt=6;function Kt(n,e,r,i,o,u){var a=n.__transition;if(!a)n.__transition={};else if(r in a)return;mr(n,r,{name:e,index:i,group:o,on:pr,tween:yr,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:an})}function me(n,e){var r=tt(n,e);if(r.state>an)throw new Error("too late; already scheduled");return r}function rt(n,e){var r=tt(n,e);if(r.state>Gt)throw new Error("too late; already running");return r}function tt(n,e){var r=n.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function mr(n,e,r){var i=n.__transition,o;i[e]=r,r.timer=wn(u,0,r.time);function u(c){r.state=Ne,r.timer.restart(a,r.delay,r.time),r.delay<=c&&a(c-r.delay)}function a(c){var f,h,d,g;if(r.state!==Ne)return l();for(f in i)if(g=i[f],g.name===r.name){if(g.state===Gt)return Ie(a);g.state===Ue?(g.state=Vt,g.timer.stop(),g.on.call("interrupt",n,n.__data__,g.index,g.group),delete i[f]):+fle&&i.state=0&&(e=e.slice(0,r)),!e||e==="start"})}function Wr(n,e,r){var i,o,u=Xr(e)?me:rt;return function(){var a=u(this,n),s=a.on;s!==i&&(o=(i=s).copy()).on(e,r),a.on=o}}function Yr(n,e){var r=this._id;return arguments.length<2?tt(this.node(),r).on.on(n):this.each(Wr(r,n,e))}function Zr(n){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==n)return;e&&e.removeChild(this)}}function Kr(){return this.on("end.remove",Zr(this._id))}function Br(n){var e=this._name,r=this._id;typeof n!="function"&&(n=Mn(n));for(var i=this._groups,o=i.length,u=new Array(o),a=0;a()=>n;function _i(n,{sourceEvent:e,target:r,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function ct(n,e,r){this.k=n,this.x=e,this.y=r}ct.prototype={constructor:ct,scale:function(n){return n===1?this:new ct(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new ct(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xe=new ct(1,0,0);et.prototype=ct.prototype;function et(n){for(;!n.__zoom;)if(!(n=n.parentNode))return xe;return n.__zoom}function ee(n){n.stopImmediatePropagation()}function _t(n){n.preventDefault(),n.stopImmediatePropagation()}function ki(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function Ci(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function $e(){return this.__zoom||xe}function zi(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function Pi(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ei(n,e,r){var i=n.invertX(e[0][0])-r[0][0],o=n.invertX(e[1][0])-r[1][0],u=n.invertY(e[0][1])-r[0][1],a=n.invertY(e[1][1])-r[1][1];return n.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),a>u?(u+a)/2:Math.min(0,u)||Math.max(0,a))}function Mi(){var n=ki,e=Ci,r=Ei,i=zi,o=Pi,u=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,l=gr,c=pe("start","zoom","end"),f,h,d,g=500,y=150,w=0,C=10;function m(p){p.property("__zoom",$e).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",N).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(p,z,x,T){var S=p.selection?p.selection():p;S.property("__zoom",$e),p!==S?_(p,z,x,T):S.interrupt().each(function(){M(this,arguments).event(T).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},m.scaleBy=function(p,z,x,T){m.scaleTo(p,function(){var S=this.__zoom.k,D=typeof z=="function"?z.apply(this,arguments):z;return S*D},x,T)},m.scaleTo=function(p,z,x,T){m.transform(p,function(){var S=e.apply(this,arguments),D=this.__zoom,I=x==null?v(S):typeof x=="function"?x.apply(this,arguments):x,j=D.invert(I),F=typeof z=="function"?z.apply(this,arguments):z;return r(R(O(D,F),I,j),S,a)},x,T)},m.translateBy=function(p,z,x,T){m.transform(p,function(){return r(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof x=="function"?x.apply(this,arguments):x),e.apply(this,arguments),a)},null,T)},m.translateTo=function(p,z,x,T,S){m.transform(p,function(){var D=e.apply(this,arguments),I=this.__zoom,j=T==null?v(D):typeof T=="function"?T.apply(this,arguments):T;return r(xe.translate(j[0],j[1]).scale(I.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof x=="function"?-x.apply(this,arguments):-x),D,a)},T,S)};function O(p,z){return z=Math.max(u[0],Math.min(u[1],z)),z===p.k?p:new ct(z,p.x,p.y)}function R(p,z,x){var T=z[0]-x[0]*p.k,S=z[1]-x[1]*p.k;return T===p.x&&S===p.y?p:new ct(p.k,T,S)}function v(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function _(p,z,x,T){p.on("start.zoom",function(){M(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(T).end()}).tween("zoom",function(){var S=this,D=arguments,I=M(S,D).event(T),j=e.apply(S,D),F=x==null?v(j):typeof x=="function"?x.apply(S,D):x,V=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),G=S.__zoom,K=typeof z=="function"?z.apply(S,D):z,it=l(G.invert(F).concat(V/G.k),K.invert(F).concat(V/K.k));return function(B){if(B===1)B=K;else{var ot=it(B),Bt=V/ot[2];B=new ct(Bt,F[0]-ot[0]*Bt,F[1]-ot[1]*Bt)}I.zoom(null,B)}})}function M(p,z,x){return!x&&p.__zooming||new k(p,z)}function k(p,z){this.that=p,this.args=z,this.active=0,this.sourceEvent=null,this.extent=e.apply(p,z),this.taps=0}k.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,z){return this.mouse&&p!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var z=Q(this.that).datum();c.call(p,this.that,new _i(p,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),z)}};function E(p,...z){if(!n.apply(this,arguments))return;var x=M(this,z).event(p),T=this.__zoom,S=Math.max(u[0],Math.min(u[1],T.k*Math.pow(2,i.apply(this,arguments)))),D=lt(p);if(x.wheel)(x.mouse[0][0]!==D[0]||x.mouse[0][1]!==D[1])&&(x.mouse[1]=T.invert(x.mouse[0]=D)),clearTimeout(x.wheel);else{if(T.k===S)return;x.mouse=[D,T.invert(D)],Ht(this),x.start()}_t(p),x.wheel=setTimeout(I,y),x.zoom("mouse",r(R(O(T,S),x.mouse[0],x.mouse[1]),x.extent,a));function I(){x.wheel=null,x.end()}}function A(p,...z){if(d||!n.apply(this,arguments))return;var x=p.currentTarget,T=M(this,z,!0).event(p),S=Q(p.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",V,!0),D=lt(p,x),I=p.clientX,j=p.clientY;Be(p.view),ee(p),T.mouse=[D,this.__zoom.invert(D)],Ht(this),T.start();function F(G){if(_t(G),!T.moved){var K=G.clientX-I,it=G.clientY-j;T.moved=K*K+it*it>w}T.event(G).zoom("mouse",r(R(T.that.__zoom,T.mouse[0]=lt(G,x),T.mouse[1]),T.extent,a))}function V(G){S.on("mousemove.zoom mouseup.zoom",null),Qe(G.view,T.moved),_t(G),T.event(G).end()}}function P(p,...z){if(n.apply(this,arguments)){var x=this.__zoom,T=lt(p.changedTouches?p.changedTouches[0]:p,this),S=x.invert(T),D=x.k*(p.shiftKey?.5:2),I=r(R(O(x,D),T,S),e.apply(this,z),a);_t(p),s>0?Q(this).transition().duration(s).call(_,I,T,p):Q(this).call(m.transform,I,T,p)}}function N(p,...z){if(n.apply(this,arguments)){var x=p.touches,T=x.length,S=M(this,z,p.changedTouches.length===T).event(p),D,I,j,F;for(ee(p),I=0;In.length)&&(e=n.length);for(var r=0,i=Array(e);r0&&arguments[0]!==void 0?arguments[0]:6;Di(this,n),je(this,pt,void 0),je(this,ut,void 0),Le(ut,this,e),this.reset()}return Ni(n,[{key:"reset",value:function(){Le(pt,this,["__reserved for background__"])}},{key:"register",value:function(r){if(W(pt,this).length>=Math.pow(2,24-W(ut,this)))return null;var i=W(pt,this).length,o=Fe(i,W(ut,this)),u=Vi(i+(o<<24-W(ut,this)));return W(pt,this).push(r),u}},{key:"lookup",value:function(r){if(!r)return null;var i=typeof r=="string"?Hi(r):fn.apply(void 0,ji(r));if(!i)return null;var o=i&Math.pow(2,24-W(ut,this))-1,u=i>>24-W(ut,this)&Math.pow(2,W(ut,this))-1;return Fe(o,W(ut,this))!==u||o>=W(pt,this).length?null:W(pt,this)[o]}}])})();const{abs:kt,cos:st,sin:vt,acos:Wi,atan2:Ct,sqrt:ht,pow:Y}=Math;function zt(n){return n<0?-Y(-n,1/3):Y(n,1/3)}const hn=Math.PI,qt=2*hn,dt=hn/2,Yi=1e-6,ne=Number.MAX_SAFE_INTEGER||9007199254740991,re=Number.MIN_SAFE_INTEGER||-9007199254740991,Zi={x:0,y:0,z:0},b={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(n,e){const r=e(n);let i=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(i+=r.z*r.z),ht(i)},compute:function(n,e,r){if(n===0)return e[0].t=0,e[0];const i=e.length-1;if(n===1)return e[i].t=1,e[i];const o=1-n;let u=e;if(i===0)return e[0].t=n,e[0];if(i===1){const s={x:o*u[0].x+n*u[1].x,y:o*u[0].y+n*u[1].y,t:n};return r&&(s.z=o*u[0].z+n*u[1].z),s}if(i<4){let s=o*o,l=n*n,c,f,h,d=0;i===2?(u=[u[0],u[1],u[2],Zi],c=s,f=o*n*2,h=l):i===3&&(c=s*o,f=s*n*3,h=o*l*3,d=n*l);const g={x:c*u[0].x+f*u[1].x+h*u[2].x+d*u[3].x,y:c*u[0].y+f*u[1].y+h*u[2].y+d*u[3].y,t:n};return r&&(g.z=c*u[0].z+f*u[1].z+h*u[2].z+d*u[3].z),g}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let s=0;s1;o--,u--){const a=[];for(let s=0,l;s"u")n=.5;else if(n===0||n===1)return n;const r=Y(n,e)+Y(1-n,e),i=r-1;return kt(i/r)},projectionratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const r=Y(1-n,e),i=Y(n,e)+r;return r/i},lli8:function(n,e,r,i,o,u,a,s){const l=(n*i-e*r)*(o-a)-(n-r)*(o*s-u*a),c=(n*i-e*r)*(u-s)-(e-i)*(o*s-u*a),f=(n-r)*(u-s)-(e-i)*(o-a);return f==0?!1:{x:l/f,y:c/f}},lli4:function(n,e,r,i){const o=n.x,u=n.y,a=e.x,s=e.y,l=r.x,c=r.y,f=i.x,h=i.y;return b.lli8(o,u,a,s,l,c,f,h)},lli:function(n,e){return b.lli4(n,n.c,e,e.c)},makeline:function(n,e){return new q(n.x,n.y,(n.x+e.x)/2,(n.y+e.y)/2,e.x,e.y)},findbbox:function(n){let e=ne,r=ne,i=re,o=re;return n.forEach(function(u){const a=u.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),i0&&(f.c1=l,f.c2=c,f.s1=n,f.s2=r,u.push(f))})}),u},makeshape:function(n,e,r){const i=e.points.length,o=n.points.length,u=b.makeline(e.points[i-1],n.points[0]),a=b.makeline(n.points[o-1],e.points[0]),s={startcap:u,forward:n,back:e,endcap:a,bbox:b.findbbox([u,n,e,a])};return s.intersections=function(l){return b.shapeintersections(s,s.bbox,l,l.bbox,r)},s},getminmax:function(n,e,r){if(!r)return{min:0,max:0};let i=ne,o=re,u,a;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let s=0,l=r.length;so&&(o=a[e]);return{min:i,mid:(i+o)/2,max:o,size:o-i}},align:function(n,e){const r=e.p1.x,i=e.p1.y,o=-Ct(e.p2.y-i,e.p2.x-r),u=function(a){return{x:(a.x-r)*st(o)-(a.y-i)*vt(o),y:(a.x-r)*vt(o)+(a.y-i)*st(o)}};return n.map(u)},roots:function(n,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=n.length-1,i=b.align(n,e),o=function(k){return 0<=k&&k<=1};if(r===2){const k=i[0].y,E=i[1].y,A=i[2].y,P=k-2*E+A;if(P!==0){const N=-ht(E*E-k*A),U=-k+E,$=-(N+U)/P,p=-(-N+U)/P;return[$,p].filter(o)}else if(E!==A&&P===0)return[(2*E-A)/(2*E-2*A)].filter(o);return[]}const u=i[0].y,a=i[1].y,s=i[2].y,l=i[3].y;let c=-u+3*a-3*s+l,f=3*u-6*a+3*s,h=-3*u+3*a,d=u;if(b.approximately(c,0)){if(b.approximately(f,0))return b.approximately(h,0)?[]:[-d/h].filter(o);const k=ht(h*h-4*f*d),E=2*f;return[(k-h)/E,(-h-k)/E].filter(o)}f/=c,h/=c,d/=c;const g=(3*h-f*f)/3,y=g/3,w=(2*f*f*f-9*f*h+27*d)/27,C=w/2,m=C*C+y*y*y;let O,R,v,_,M;if(m<0){const k=-g/3,E=k*k*k,A=ht(E),P=-w/(2*A),N=P<-1?-1:P>1?1:P,U=Wi(N),$=zt(A),p=2*$;return v=p*st(U/3)-f/3,_=p*st((U+qt)/3)-f/3,M=p*st((U+2*qt)/3)-f/3,[v,_,M].filter(o)}else{if(m===0)return O=C<0?zt(-C):-zt(C),v=2*O-f/3,_=-O-f/3,[v,_].filter(o);{const k=ht(m);return O=zt(-C+k),R=zt(C+k),[O-R-f/3].filter(o)}}},droots:function(n){if(n.length===3){const e=n[0],r=n[1],i=n[2],o=e-2*r+i;if(o!==0){const u=-ht(r*r-e*i),a=-e+r,s=-(u+a)/o,l=-(-u+a)/o;return[s,l]}else if(r!==i&&o===0)return[(2*r-i)/(2*(r-i))];return[]}if(n.length===2){const e=n[0],r=n[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(n,e,r,i,o){let u,a,s,l,c=0,f=0;const h=b.compute(n,e),d=b.compute(n,r),g=h.x*h.x+h.y*h.y;if(i?(u=ht(Y(h.y*d.z-d.y*h.z,2)+Y(h.z*d.x-d.z*h.x,2)+Y(h.x*d.y-d.x*h.y,2)),a=Y(g+h.z*h.z,3/2)):(u=h.x*d.y-h.y*d.x,a=Y(g,3/2)),u===0||a===0)return{k:0,r:0};if(c=u/a,f=a/u,!o){const y=b.curvature(n-.001,e,r,i,!0).k,w=b.curvature(n+.001,e,r,i,!0).k;l=(w-c+(c-y))/2,s=(kt(w-c)+kt(c-y))/2}return{k:c,r:f,dk:l,adk:s}},inflections:function(n){if(n.length<4)return[];const e=b.align(n,{p1:n[0],p2:n.slice(-1)[0]}),r=e[2].x*e[1].y,i=e[3].x*e[1].y,o=e[1].x*e[2].y,u=e[3].x*e[2].y,a=18*(-3*r+2*i+3*o-u),s=18*(3*r-i-3*o),l=18*(o-r);if(b.approximately(a,0)){if(!b.approximately(s,0)){let d=-l/s;if(0<=d&&d<=1)return[d]}return[]}const c=2*a;if(b.approximately(c,0))return[];const f=s*s-4*a*l;if(f<0)return[];const h=Math.sqrt(f);return[(h-s)/c,-(s+h)/c].filter(function(d){return 0<=d&&d<=1})},bboxoverlap:function(n,e){const r=["x","y"],i=r.length;for(let o=0,u,a,s,l;o=l)return!1;return!0},expandbox:function(n,e){e.x.minn.x.max&&(n.x.max=e.x.max),e.y.max>n.y.max&&(n.y.max=e.y.max),e.z&&e.z.max>n.z.max&&(n.z.max=e.z.max),n.x.mid=(n.x.min+n.x.max)/2,n.y.mid=(n.y.min+n.y.max)/2,n.z&&(n.z.mid=(n.z.min+n.z.max)/2),n.x.size=n.x.max-n.x.min,n.y.size=n.y.max-n.y.min,n.z&&(n.z.size=n.z.max-n.z.min)},pairiteration:function(n,e,r){const i=n.bbox(),o=e.bbox(),u=1e5,a=r||.5;if(i.x.size+i.y.sizeM||M>k)&&(_+=qt),_>k&&(E=k,k=_,_=E)):k4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(u!==6&&u!==8&&u!==9&&u!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!o&&(u===9||u===12)||e&&e[0]&&typeof e[0].z<"u",s=this.points=[];for(let g=0,y=a?3:2;gg+Pt(y.y),0)"u"&&(o=.5),o===0)return new q(r,r,i);if(o===1)return new q(e,r,r);const u=q.getABC(2,e,r,i,o);return new q(e,u.A,i)}static cubicFromPoints(e,r,i,o,u){typeof o>"u"&&(o=.5);const a=q.getABC(3,e,r,i,o);typeof u>"u"&&(u=b.dist(r,a.C));const s=u*(1-o)/o,l=b.dist(e,i),c=(i.x-e.x)/l,f=(i.y-e.y)/l,h=u*c,d=u*f,g=s*c,y=s*f,w={x:r.x-h,y:r.y-d},C={x:r.x+g,y:r.y+y},m=a.A,O={x:m.x+(w.x-m.x)/(1-o),y:m.y+(w.y-m.y)/(1-o)},R={x:m.x+(C.x-m.x)/o,y:m.y+(C.y-m.y)/o},v={x:e.x+(O.x-e.x)/o,y:e.y+(O.y-e.y)/o},_={x:i.x+(R.x-i.x)/(1-o),y:i.y+(R.y-i.y)/(1-o)};return new q(e,v,_,i)}static getUtils(){return b}getUtils(){return q.getUtils()}static get PolyBezier(){return Mt}valueOf(){return this.toString()}toString(){return b.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,r=e[0].x,i=e[0].y,o=["M",r,i,this.order===2?"Q":"C"];for(let u=1,a=e.length;u0}length(){return b.length(this.derivative.bind(this))}static getABC(e=2,r,i,o,u=.5){const a=b.projectionratio(u,e),s=1-a,l={x:a*r.x+s*o.x,y:a*r.y+s*o.y},c=b.abcratio(u,e);return{A:{x:i.x+(i.x-l.x)/c,y:i.y+(i.y-l.y)/c},B:i,C:l,S:r,E:o}}getABC(e,r){r=r||this.get(e);let i=this.points[0],o=this.points[this.order];return q.getABC(this.order,i,r,o,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let r=0,i,o;r1?1:h,d=this.compute(h),d.t=h,d.d=c,d}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?b.computeWithRatios(e,this.points,this.ratios,this._3d):b.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,r=[e[0]],i=e.length;for(let o=1,u,a;o1;){i=[];for(let a=0,s,l=r.length-1;a=0&&a<=1}),r=r.concat(e[i].sort(b.numberSort))}).bind(this)),e.values=r.sort(b.numberSort).filter(function(i,o){return r.indexOf(i)===o}),e}bbox(){const e=this.extrema(),r={};return this.dims.forEach((function(i){r[i]=b.getminmax(this,i,e[i])}).bind(this)),r}overlaps(e){const r=this.bbox(),i=e.bbox();return b.bboxoverlap(r,i)}offset(e,r){if(typeof r<"u"){const i=this.get(e),o=this.normal(e),u={c:i,n:o,x:i.x+o.x*r,y:i.y+o.y*r};return this._3d&&(u.z=i.z+o.z*r),u}if(this._linear){const i=this.normal(0),o=this.points.map(function(u){const a={x:u.x+e*i.x,y:u.y+e*i.y};return u.z&&i.z&&(a.z=u.z+e*i.z),a});return[new q(o)]}return this.reduce().map(function(i){return i._linear?i.offset(e)[0]:i.scale(e)})}simple(){if(this.order===3){const o=b.angle(this.points[0],this.points[3],this.points[1]),u=b.angle(this.points[0],this.points[3],this.points[2]);if(o>0&&u<0||o<0&&u>0)return!1}const e=this.normal(0),r=this.normal(1);let i=e.x*r.x+e.y*r.y;return this._3d&&(i+=e.z*r.z),Pt(Qi(i))(1-s/o)*r+s/o*i);return new q(this.points.map((a,s)=>({x:a.x+e.x*u[s],y:a.y+e.y*u[s]})))}scale(e){const r=this.order;let i=!1;if(typeof e=="function"&&(i=e),i&&r===2)return this.raise().scale(i);const o=this.clockwise,u=this.points;if(this._linear)return this.translate(this.normal(0),i?i(0):e,i?i(1):e);const a=i?i(0):e,s=i?i(1):e,l=[this.offset(0,10),this.offset(1,10)],c=[],f=b.lli4(l[0],l[0].c,l[1],l[1].c);if(!f)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const d=c[h*r]=b.copy(u[h*r]);d.x+=(h?s:a)*l[h].n.x,d.y+=(h?s:a)*l[h].n.y}),i?([0,1].forEach(function(h){if(!(r===2&&h)){var d=u[h+1],g={x:d.x-f.x,y:d.y-f.y},y=i?i((h+1)/r):e;i&&!o&&(y=-y);var w=Et(g.x*g.x+g.y*g.y);g.x/=w,g.y/=w,c[h+1]={x:d.x+y*g.x,y:d.y+y*g.y}}}),new q(c)):([0,1].forEach(h=>{if(r===2&&h)return;const d=c[h*r],g=this.derivative(h),y={x:d.x+g.x,y:d.y+g.y};c[h+1]=b.lli4(d,y,f,u[h+1])}),new q(c))}outline(e,r,i,o){if(r=r===void 0?e:r,this._linear){const _=this.normal(0),M=this.points[0],k=this.points[this.points.length-1];let E,A,P;i===void 0&&(i=e,o=r),E={x:M.x+_.x*e,y:M.y+_.y*e},P={x:k.x+_.x*i,y:k.y+_.y*i},A={x:(E.x+P.x)/2,y:(E.y+P.y)/2};const N=[E,A,P];E={x:M.x-_.x*r,y:M.y-_.y*r},P={x:k.x-_.x*o,y:k.y-_.y*o},A={x:(E.x+P.x)/2,y:(E.y+P.y)/2};const U=[P,A,E],$=b.makeline(U[2],N[0]),p=b.makeline(N[2],U[0]),z=[$,new q(N),p,new q(U)];return new Mt(z)}const u=this.reduce(),a=u.length,s=[];let l=[],c,f=0,h=this.length();const d=typeof i<"u"&&typeof o<"u";function g(_,M,k,E,A){return function(P){const N=E/k,U=(E+A)/k,$=M-_;return b.map(P,0,1,_+N*$,_+U*$)}}u.forEach(function(_){const M=_.length();d?(s.push(_.scale(g(e,i,h,f,M))),l.push(_.scale(g(-r,-o,h,f,M)))):(s.push(_.scale(e)),l.push(_.scale(-r))),f+=M}),l=l.map(function(_){return c=_.points,c[3]?_.points=[c[3],c[2],c[1],c[0]]:_.points=[c[2],c[1],c[0]],_}).reverse();const y=s[0].points[0],w=s[a-1].points[s[a-1].points.length-1],C=l[a-1].points[l[a-1].points.length-1],m=l[0].points[0],O=b.makeline(C,y),R=b.makeline(w,m),v=[O].concat(s).concat([R]).concat(l);return new Mt(v)}outlineshapes(e,r,i){r=r||e;const o=this.outline(e,r).curves,u=[];for(let a=1,s=o.length;a1,l.endcap.virtual=a{var s=this.get(a);return b.between(s.x,r,o)&&b.between(s.y,i,u)})}selfintersects(e){const r=this.reduce(),i=r.length-2,o=[];for(let u=0,a,s,l;u0&&(u=u.concat(s))}),u}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,i,o){const u=(o-i)/4,a=this.get(i+u),s=this.get(o-u),l=b.dist(e,r),c=b.dist(e,a),f=b.dist(e,s);return Pt(c-l)+Pt(f-l)}_iterate(e,r){let i=0,o=1,u;do{u=0,o=1;let a=this.get(i),s,l,c,f,h=!1,d=!1,g,y=o,w=1;do if(d=h,f=c,y=(i+o)/2,s=this.get(y),l=this.get(o),c=b.getccenter(a,s,l),c.interval={start:i,end:o},h=this._error(c,a,i,o)<=e,g=d&&!h,g||(w=o),h){if(o>=1){if(c.interval.end=w=1,f=c,o>1){let m={x:c.x+c.r*Ki(c.e),y:c.y+c.r*Bi(c.e)};c.e+=b.angle({x:c.x,y:c.y},m,this.get(1))}break}o=o+(o-i)/2}else o=y;while(!g&&u++<100);if(u>=100)break;f=f||c,r.push(f),i=w}while(o<1);return r}}function he(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,i=Array(e);r0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(s){return{keyAccessor:s,isProp:!(s instanceof Function)}}),u=n.reduce(function(s,l){var c=s,f=l;return o.forEach(function(h,d){var g=h.keyAccessor,y=h.isProp,w;if(y){var C=f,m=C[g],O=ao(C,[g].map(fo));w=m,f=O}else w=g(f,d);d+11&&arguments[1]!==void 0?arguments[1]:1;c===o.length?Object.keys(l).forEach(function(f){return l[f]=r(l[f])}):Object.values(l).forEach(function(f){return s(f,c+1)})})(u);var a=u;return i&&(a=[],(function s(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];c.length===o.length?a.push({keys:c,vals:l}):Object.entries(l).forEach(function(f){var h=so(f,2),d=h[0],g=h[1];return s(g,[].concat(lo(c),[d]))})})(u),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a});function go(n,e){e===void 0&&(e={});var r=e.insertAt;if(!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r==="top"&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var po=`.force-graph-container canvas { + display: block; + user-select: none; + outline: none; + -webkit-tap-highlight-color: transparent; +} + +.force-graph-container .clickable { + cursor: pointer; +} + +.force-graph-container .grabbable { + cursor: move; + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +.force-graph-container .grabbable:active { + cursor: grabbing; + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +} +`;go(po);function de(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,i=Array(e);r2&&arguments[2]!==void 0?arguments[2]:{},u=o.nodeFilter,a=u===void 0?function(){return!0}:u,s=o.onLoopError,l=s===void 0?function(g){throw"Invalid DAG structure! Found cycle in node path: ".concat(g.join(" -> "),".")}:s,c={};r.forEach(function(g){return c[e(g)]={data:g,out:[],depth:-1,skip:!a(g)}}),i.forEach(function(g){var y=g.source,w=g.target,C=v(y),m=v(w);if(!c.hasOwnProperty(C))throw"Missing source node with id: ".concat(C);if(!c.hasOwnProperty(m))throw"Missing target node with id: ".concat(m);var O=c[C],R=c[m];O.out.push(R);function v(_){return ge(_)==="object"?e(_):_}});var f=[];d(Object.values(c));var h=Object.assign.apply(Object,[{}].concat(Z(Object.entries(c).filter(function(g){var y=Tt(g,2),w=y[1];return!w.skip}).map(function(g){var y=Tt(g,2),w=y[0],C=y[1];return It({},w,C.depth)}))));return h;function d(g){for(var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,C=function(){var v=g[m];if(y.indexOf(v)!==-1){var _=[].concat(Z(y.slice(y.indexOf(v))),[v]).map(function(M){return e(M.data)});return f.some(function(M){return M.length===_.length&&M.every(function(k,E){return k===_[E]})})||(f.push(_),l(_)),1}w>v.depth&&(v.depth=w,d(v.out,[].concat(Z(y),[v]),w+(v.skip?0:1)))},m=0,O=g.length;me.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||e.d3AlphaMin>0&&e.forceLayout.alpha()0){var U=Math.atan2(P.y-A.y,P.x-A.x),$=N*E,p={x:(A.x+P.x)/2+$*Math.cos(U-Math.PI/2),y:(A.y+P.y)/2+$*Math.sin(U-Math.PI/2)};k.__controlPoints=[p.x,p.y]}else{var z=E*70;k.__controlPoints=[P.x,P.y-z,P.x+z,P.y]}}}}function u(){var s=1.6,l=.2,c=L(e.linkDirectionalArrowLength),f=L(e.linkDirectionalArrowRelPos),h=L(e.linkVisibility),d=L(e.linkDirectionalArrowColor||e.linkColor),g=L(e.nodeVal),y=e.ctx;y.save(),e.graphData.links.filter(h).forEach(function(w){var C=c(w);if(!(!C||C<0)){var m=w.source,O=w.target;if(!(!m||!O||!m.hasOwnProperty("x")||!O.hasOwnProperty("x"))){var R=Math.sqrt(Math.max(0,g(m)||1))*e.nodeRelSize,v=Math.sqrt(Math.max(0,g(O)||1))*e.nodeRelSize,_=Math.min(1,Math.max(0,f(w))),M=d(w)||"rgba(0,0,0,0.28)",k=C/s/2,E=w.__controlPoints&&Ve(q,[m.x,m.y].concat(Z(w.__controlPoints),[O.x,O.y])),A=E?function(x){return E.get(x)}:function(x){return{x:m.x+(O.x-m.x)*x||0,y:m.y+(O.y-m.y)*x||0}},P=E?E.length():Math.sqrt(Math.pow(O.x-m.x,2)+Math.pow(O.y-m.y,2)),N=R+C+(P-R-v-C)*_,U=A(N/P),$=A((N-C)/P),p=A((N-C*(1-l))/P),z=Math.atan2(U.y-$.y,U.x-$.x)-Math.PI/2;y.beginPath(),y.moveTo(U.x,U.y),y.lineTo($.x+k*Math.cos(z),$.y+k*Math.sin(z)),y.lineTo(p.x,p.y),y.lineTo($.x-k*Math.cos(z),$.y-k*Math.sin(z)),y.fillStyle=M,y.fill()}}}),y.restore()}function a(){var s=L(e.linkDirectionalParticles),l=L(e.linkDirectionalParticleSpeed),c=L(e.linkDirectionalParticleOffset),f=L(e.linkDirectionalParticleWidth),h=L(e.linkVisibility),d=L(e.linkDirectionalParticleColor||e.linkColor),g=e.ctx;g.save(),e.graphData.links.filter(h).forEach(function(y){var w=s(y);if(!(!y.hasOwnProperty("__photons")||!y.__photons.length)){var C=y.source,m=y.target;if(!(!C||!m||!C.hasOwnProperty("x")||!m.hasOwnProperty("x"))){var O=l(y),R=Math.abs(c(y)),v=y.__photons||[],_=Math.max(0,f(y)/2)/Math.sqrt(e.globalScale),M=d(y)||"rgba(0,0,0,0.28)";g.fillStyle=M;var k=y.__controlPoints?Ve(q,[C.x,C.y].concat(Z(y.__controlPoints),[m.x,m.y])):null,E=0,A=!1;v.forEach(function(P){var N=!!P.__singleHop;if(P.hasOwnProperty("__progressRatio")||(P.__progressRatio=N?O<0?1:0:(E+R)/w),!N&&E++,P.__progressRatio+=O,P.__progressRatio>=1||P.__progressRatio<0)if(!N)P.__progressRatio=P.__progressRatio%1,P.__progressRatio<0&&P.__progressRatio++;else{A=!0;return}var U=P.__progressRatio,$=k?k.get(U):{x:C.x+(m.x-C.x)*U||0,y:C.y+(m.y-C.y)*U||0};e.linkDirectionalParticleCanvasObject?e.linkDirectionalParticleCanvasObject($.x,$.y,y,g,e.globalScale):(g.beginPath(),g.arc($.x,$.y,_,0,2*Math.PI,!1),g.fill())}),A&&(y.__photons=y.__photons.filter(function(P){return!P.__singleHop||P.__progressRatio<=1&&P.__progressRatio>=0}))}}}),g.restore()}},emitParticle:function(e,r){return r&&(!r.__photons&&(r.__photons=[]),r.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:kn().force("link",Cn()).force("charge",zn()).force("center",Pn()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,r){r.ctx=e},update:function(e,r){e.engineRunning=!1,e.onUpdate(),e.nodeAutoColorBy!==null&&Xe(e.graphData.nodes,L(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&Xe(e.graphData.links,L(e.linkAutoColorBy),e.linkColor),e.graphData.links.forEach(function(d){d.source=d[e.linkSource],d.target=d[e.linkTarget]}),e.forceLayout.stop().alpha(1).nodes(e.graphData.nodes);var i=e.forceLayout.force("link");i&&i.id(function(d){return d[e.nodeId]}).links(e.graphData.links);var o=e.dagMode&&zo(e.graphData,function(d){return d[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),u=Math.max.apply(Math,Z(Object.values(o||[]))),a=e.dagLevelDistance||e.graphData.nodes.length/(u||1)*Po*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu"].includes(r.dagMode)){var s=["lr","rl"].includes(r.dagMode)?"fx":"fy";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(d){return delete d[s]})}if(["lr","rl","td","bu"].includes(e.dagMode)){var l=["rl","bu"].includes(e.dagMode),c=function(g){return(o[g[e.nodeId]]-u/2)*a*(l?-1:1)},f=["lr","rl"].includes(e.dagMode)?"fx":"fy";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(d){return d[f]=c(d)})}e.forceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?_n(function(d){var g=o[d[e.nodeId]]||-1;return(e.dagMode==="radialin"?u-g:g)*a}).strength(function(d){return e.dagNodeFilter(d)?1:0}):null);for(var h=0;h0&&e.forceLayout.alpha()1?s-1:0),c=1;c1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,o=arguments.length,u=new Array(o>3?o-3:0),a=3;a1&&arguments[1]!==void 0?arguments[1]:function(){return!0},i=L(e.nodeVal),o=function(s){return Math.sqrt(Math.max(0,i(s)||1))*e.nodeRelSize},u=e.graphData.nodes.filter(r).map(function(a){return{x:a.x,y:a.y,r:o(a)}});return u.length?{x:[we(u,function(a){return a.x-a.r}),be(u,function(a){return a.x+a.r})],y:[we(u,function(a){return a.y-a.r}),be(u,function(a){return a.y+a.r})]}:null},pauseAnimation:function(e){return e.animationFrameRequestId&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},Ro),stateInit:function(){return{lastSetZoom:1,zoom:Mi(),forceGraph:new Yt,shadowGraph:new Yt().cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new Xi,tweenGroup:new Nn}},init:function(e,r){var i=this;e.innerHTML="";var o=document.createElement("div");o.classList.add("force-graph-container"),o.style.position="relative",e.appendChild(o),r.canvas=document.createElement("canvas"),r.backgroundColor&&(r.canvas.style.background=r.backgroundColor),o.appendChild(r.canvas),r.shadowCanvas=document.createElement("canvas");var u=r.canvas.getContext("2d"),a=r.shadowCanvas.getContext("2d",{willReadFrequently:!0}),s={x:-1e12,y:-1e12},l=function(){var h=null,d=window.devicePixelRatio,g=s.x>0&&s.y>0?a.getImageData(s.x*d,s.y*d,1,1):null;return g&&(h=r.colorTracker.lookup(g.data)),h};Q(r.canvas).call(qn().subject(function(){if(!r.enableNodeDrag)return null;var f=l();return f&&f.type==="Node"?f.d:null}).on("start",function(f){var h=f.subject;h.__initialDragPos={x:h.x,y:h.y,fx:h.fx,fy:h.fy},f.active||(h.fx=h.x,h.fy=h.y),r.canvas.classList.add("grabbable")}).on("drag",function(f){var h=f.subject,d=h.__initialDragPos,g=f,y=et(r.canvas).k,w={x:d.x+(g.x-d.x)/y-h.x,y:d.y+(g.y-d.y)/y-h.y};["x","y"].forEach(function(C){return h["f".concat(C)]=h[C]=d[C]+(g[C]-d[C])/y}),!(!h.__dragged&&To>=Math.sqrt(Ti(["x","y"].map(function(C){return Math.pow(f[C]-d[C],2)}))))&&(r.forceGraph.d3AlphaTarget(.3).resetCountdown(),r.isPointerDragging=!0,h.__dragged=!0,r.onNodeDrag(h,w))}).on("end",function(f){var h=f.subject,d=h.__initialDragPos,g={x:h.x-d.x,y:h.y-d.y};d.fx===void 0&&(h.fx=void 0),d.fy===void 0&&(h.fy=void 0),delete h.__initialDragPos,r.forceGraph.d3AlphaTarget()&&r.forceGraph.d3AlphaTarget(0).resetCountdown(),r.canvas.classList.remove("grabbable"),r.isPointerDragging=!1,h.__dragged&&(delete h.__dragged,r.onNodeDragEnd(h,g))})),r.zoom(r.zoom.__baseElem=Q(r.canvas)),r.zoom.__baseElem.on("dblclick.zoom",null),r.zoom.filter(function(f){return!f.button&&r.enableZoomPanInteraction&&(f.type!=="wheel"||L(r.enableZoomInteraction)(f))&&(f.type==="wheel"||L(r.enablePanInteraction)(f))}).on("zoom",function(f){var h=f.transform;[u,a].forEach(function(d){vn(d),d.translate(h.x,h.y),d.scale(h.k,h.k)}),r.isPointerDragging=!0,r.onZoom&&r.onZoom(xt(xt({},h),i.centerAt())),r.needsRedraw=!0}).on("end",function(f){r.isPointerDragging=!1,r.onZoomEnd&&r.onZoomEnd(xt(xt({},f.transform),i.centerAt()))}),ie(r),r.forceGraph.onNeedsRedraw(function(){return r.needsRedraw=!0}).onFinishUpdate(function(){et(r.canvas).k===r.lastSetZoom&&r.graphData.nodes.length&&(r.zoom.scaleTo(r.zoom.__baseElem,r.lastSetZoom=Mo/Math.cbrt(r.graphData.nodes.length)),r.needsRedraw=!0)}),r.tooltip=new In(o),["pointermove","pointerdown"].forEach(function(f){return o.addEventListener(f,function(h){f==="pointerdown"&&(r.isPointerPressed=!0,r.pointerDownEvent=h),!r.isPointerDragging&&h.type==="pointermove"&&r.onBackgroundClick&&(h.pressure>0||r.isPointerPressed)&&(h.pointerType==="mouse"||h.movementX===void 0||[h.movementX,h.movementY].some(function(y){return Math.abs(y)>1}))&&(r.isPointerDragging=!0);var d=g(o);s.x=h.pageX-d.left,s.y=h.pageY-d.top;function g(y){var w=y.getBoundingClientRect(),C=window.pageXOffset||document.documentElement.scrollLeft,m=window.pageYOffset||document.documentElement.scrollTop;return{top:w.top+m,left:w.left+C}}},{passive:!0})}),o.addEventListener("pointerup",function(f){if(r.isPointerPressed){if(r.isPointerPressed=!1,r.isPointerDragging){r.isPointerDragging=!1;return}var h=[f,r.pointerDownEvent];requestAnimationFrame(function(){if(f.button===0)if(r.hoverObj){var d=r["on".concat(r.hoverObj.type,"Click")];d&&d.apply(void 0,[r.hoverObj.d].concat(h))}else r.onBackgroundClick&&r.onBackgroundClick.apply(r,h);if(f.button===2)if(r.hoverObj){var g=r["on".concat(r.hoverObj.type,"RightClick")];g&&g.apply(void 0,[r.hoverObj.d].concat(h))}else r.onBackgroundRightClick&&r.onBackgroundRightClick.apply(r,h)})}},{passive:!0}),o.addEventListener("contextmenu",function(f){return!r.onBackgroundRightClick&&!r.onNodeRightClick&&!r.onLinkRightClick?!0:(f.preventDefault(),!1)}),r.forceGraph(u),r.shadowGraph(a);var c=Ai(function(){Ye(a,r.width,r.height),r.shadowGraph.linkWidth(function(h){return L(r.linkWidth)(h)+r.linkHoverPrecision});var f=et(r.canvas);r.shadowGraph.globalScale(f.k).tickFrame()},Eo);r.flushShadowCanvas=c.flush,(this._animationCycle=function f(){var h=!r.autoPauseRedraw||!!r.needsRedraw||r.forceGraph.isEngineRunning()||r.graphData.links.some(function(R){return R.__photons&&R.__photons.length});if(r.needsRedraw=!1,r.enablePointerInteraction){var d=r.isPointerDragging?null:l();if(d!==r.hoverObj){var g=r.hoverObj,y=g?g.type:null,w=d?d.type:null;if(y&&y!==w){var C=r["on".concat(y,"Hover")];C&&C(null,g.d)}if(w){var m=r["on".concat(w,"Hover")];m&&m(d.d,y===w?g.d:null)}r.tooltip.content(d&&L(r["".concat(d.type.toLowerCase(),"Label")])(d.d)||null),r.canvas.classList[(d&&r["on".concat(w,"Click")]||!d&&r.onBackgroundClick)&&L(r.showPointerCursor)(d==null?void 0:d.d)?"add":"remove"]("clickable"),r.hoverObj=d}h&&c()}if(h){Ye(u,r.width,r.height);var O=et(r.canvas).k;r.onRenderFramePre&&r.onRenderFramePre(u,O),r.forceGraph.globalScale(O).tickFrame(),r.onRenderFramePost&&r.onRenderFramePost(u,O)}r.tweenGroup.update(),r.animationFrameRequestId=requestAnimationFrame(f)})()},update:function(e){}});export{Io as default}; diff --git a/internal/ui/assets/assets/index-BGVtFZd1.css b/internal/ui/assets/assets/index-BGVtFZd1.css new file mode 100644 index 0000000..2e5a503 --- /dev/null +++ b/internal/ui/assets/assets/index-BGVtFZd1.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Inter,system-ui,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root,.dark{color-scheme:dark;--background: 240 10% 3.9%;--foreground: 0 0% 98%;--card: 240 9% 7%;--card-foreground: 0 0% 98%;--popover: 240 9% 7%;--popover-foreground: 0 0% 98%;--primary: 357 89% 47%;--primary-foreground: 0 0% 100%;--secondary: 240 4% 16%;--secondary-foreground: 0 0% 98%;--muted: 240 5% 14%;--muted-foreground: 240 5% 64.9%;--accent: 240 4% 16%;--accent-foreground: 0 0% 98%;--destructive: 0 62.8% 50.6%;--destructive-foreground: 0 0% 98%;--success: 142 71% 45%;--success-foreground: 0 0% 98%;--warning: 38 92% 50%;--warning-foreground: 0 0% 98%;--border: 240 6% 16%;--input: 240 6% 16%;--ring: 357 89% 47%;--radius: .25rem;--brand: 357 89% 47%;--pillar-memory: 217 91% 60%;--pillar-graph: 262 83% 66%;--pillar-review: 142 71% 45%;--pillar-tokens: 38 92% 50%}.\!dark{color-scheme:dark!important;--background: 240 10% 3.9% !important;--foreground: 0 0% 98% !important;--card: 240 9% 7% !important;--card-foreground: 0 0% 98% !important;--popover: 240 9% 7% !important;--popover-foreground: 0 0% 98% !important;--primary: 357 89% 47% !important;--primary-foreground: 0 0% 100% !important;--secondary: 240 4% 16% !important;--secondary-foreground: 0 0% 98% !important;--muted: 240 5% 14% !important;--muted-foreground: 240 5% 64.9% !important;--accent: 240 4% 16% !important;--accent-foreground: 0 0% 98% !important;--destructive: 0 62.8% 50.6% !important;--destructive-foreground: 0 0% 98% !important;--success: 142 71% 45% !important;--success-foreground: 0 0% 98% !important;--warning: 38 92% 50% !important;--warning-foreground: 0 0% 98% !important;--border: 240 6% 16% !important;--input: 240 6% 16% !important;--ring: 357 89% 47% !important;--radius: .25rem !important;--brand: 357 89% 47% !important;--pillar-memory: 217 91% 60% !important;--pillar-graph: 262 83% 66% !important;--pillar-review: 142 71% 45% !important;--pillar-tokens: 38 92% 50% !important}.light{color-scheme:light;--background: 240 20% 98%;--foreground: 240 10% 10%;--card: 0 0% 100%;--card-foreground: 240 10% 10%;--popover: 0 0% 100%;--popover-foreground: 240 10% 10%;--primary: 357 89% 47%;--primary-foreground: 0 0% 100%;--secondary: 240 10% 94%;--secondary-foreground: 240 10% 20%;--muted: 240 10% 94%;--muted-foreground: 240 5% 45%;--accent: 357 60% 96%;--accent-foreground: 357 70% 40%;--destructive: 0 84% 60%;--destructive-foreground: 0 0% 100%;--success: 142 70% 35%;--success-foreground: 0 0% 100%;--warning: 38 92% 45%;--warning-foreground: 0 0% 100%;--border: 240 10% 90%;--input: 240 10% 90%;--ring: 357 89% 47%;--brand: 357 89% 47%;--pillar-memory: 217 91% 55%;--pillar-graph: 262 83% 58%;--pillar-review: 142 71% 40%;--pillar-tokens: 38 92% 45%}*{border-color:hsl(var(--border))}body{background-color:hsl(var(--background));font-family:Inter,system-ui,sans-serif;color:hsl(var(--foreground));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}html{scroll-behavior:smooth}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media(min-width:1400px){.container{max-width:1400px}}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.25em}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:900;color:inherit}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:800;color:inherit}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){display:block;margin-top:2em;margin-bottom:2em}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-family:inherit;color:var(--tw-prose-kbd);box-shadow:0 0 0 1px var(--tw-prose-kbd-shadows),0 3px 0 var(--tw-prose-kbd-shadows);font-size:.875em;border-radius:.3125rem;padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;padding-inline-start:.375em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:"`"}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding-top:.8571429em;padding-inline-end:1.1428571em;padding-bottom:.8571429em;padding-inline-start:1.1428571em}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){background-color:transparent;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:none}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){width:100%;table-layout:auto;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.prose{--tw-prose-body: oklch(37.3% .034 259.733);--tw-prose-headings: oklch(21% .034 264.665);--tw-prose-lead: oklch(44.6% .03 256.802);--tw-prose-links: oklch(21% .034 264.665);--tw-prose-bold: oklch(21% .034 264.665);--tw-prose-counters: oklch(55.1% .027 264.364);--tw-prose-bullets: oklch(87.2% .01 258.338);--tw-prose-hr: oklch(92.8% .006 264.531);--tw-prose-quotes: oklch(21% .034 264.665);--tw-prose-quote-borders: oklch(92.8% .006 264.531);--tw-prose-captions: oklch(55.1% .027 264.364);--tw-prose-kbd: oklch(21% .034 264.665);--tw-prose-kbd-shadows: color-mix(in oklab, oklch(21% .034 264.665) 10%, transparent);--tw-prose-code: oklch(21% .034 264.665);--tw-prose-pre-code: oklch(92.8% .006 264.531);--tw-prose-pre-bg: oklch(27.8% .033 256.848);--tw-prose-th-borders: oklch(87.2% .01 258.338);--tw-prose-td-borders: oklch(92.8% .006 264.531);--tw-prose-invert-body: oklch(87.2% .01 258.338);--tw-prose-invert-headings: #fff;--tw-prose-invert-lead: oklch(70.7% .022 261.325);--tw-prose-invert-links: #fff;--tw-prose-invert-bold: #fff;--tw-prose-invert-counters: oklch(70.7% .022 261.325);--tw-prose-invert-bullets: oklch(44.6% .03 256.802);--tw-prose-invert-hr: oklch(37.3% .034 259.733);--tw-prose-invert-quotes: oklch(96.7% .003 264.542);--tw-prose-invert-quote-borders: oklch(37.3% .034 259.733);--tw-prose-invert-captions: oklch(70.7% .022 261.325);--tw-prose-invert-kbd: #fff;--tw-prose-invert-kbd-shadows: rgb(255 255 255 / 10%);--tw-prose-invert-code: #fff;--tw-prose-invert-pre-code: oklch(87.2% .01 258.338);--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);--tw-prose-invert-th-borders: oklch(44.6% .03 256.802);--tw-prose-invert-td-borders: oklch(37.3% .034 259.733);font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.5714286em;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.prose-sm{font-size:.875rem;line-height:1.7142857}.prose-sm :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;line-height:1.5555556;margin-top:.8888889em;margin-bottom:.8888889em}.prose-sm :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.3333333em;margin-bottom:1.3333333em;padding-inline-start:1.1111111em}.prose-sm :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:2.1428571em;margin-top:0;margin-bottom:.8em;line-height:1.2}.prose-sm :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.4285714em;margin-top:1.6em;margin-bottom:.8em;line-height:1.4}.prose-sm :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;margin-top:1.5555556em;margin-bottom:.4444444em;line-height:1.5555556}.prose-sm :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.4285714em;margin-bottom:.5714286em;line-height:1.4285714}.prose-sm :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;border-radius:.3125rem;padding-top:.1428571em;padding-inline-end:.3571429em;padding-bottom:.1428571em;padding-inline-start:.3571429em}.prose-sm :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em}.prose-sm :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.9em}.prose-sm :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8888889em}.prose-sm :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.6666667;margin-top:1.6666667em;margin-bottom:1.6666667em;border-radius:.25rem;padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;margin-bottom:.2857143em}.prose-sm :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(.prose-sm>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(.prose-sm>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;padding-inline-start:1.5714286em}.prose-sm :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2.8571429em;margin-bottom:2.8571429em}.prose-sm :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.5}.prose-sm :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.3333333;margin-top:.6666667em}.prose-sm :where(.prose-sm>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(.prose-sm>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.light .gradient-text{--tw-gradient-from: #9333ea var(--tw-gradient-from-position);--tw-gradient-to: rgb(147 51 234 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);--tw-gradient-to: rgb(124 58 237 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), #7c3aed var(--tw-gradient-via-position), var(--tw-gradient-to);--tw-gradient-to: #db2777 var(--tw-gradient-to-position)}.light .glass{border-bottom-width:1px;border-color:hsl(var(--border) / .5);background-color:hsl(var(--background) / .9);--tw-backdrop-blur: blur(24px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.glow{box-shadow:0 0 60px -15px hsl(var(--primary) / .3)}.light .glow{box-shadow:0 0 60px -15px hsl(var(--primary) / .15)}.glow-sm{box-shadow:0 0 30px -10px hsl(var(--primary) / .2)}.light .glow-sm{box-shadow:0 0 30px -10px hsl(var(--primary) / .1)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.left-2\.5{left:.625rem}.right-0{right:0}.right-4{right:1rem}.top-1\/2{top:50%}.top-4{top:1rem}.top-full{top:100%}.z-40{z-index:40}.z-50{z-index:50}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-1\.5{margin-left:.375rem}.ml-2{margin-left:.5rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-1\.5{margin-right:.375rem}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.block{display:block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-\[85vh\]{max-height:85vh}.min-h-0{min-height:0px}.min-h-10{min-height:2.5rem}.min-h-7{min-height:1.75rem}.min-h-8{min-height:2rem}.min-h-\[24rem\]{min-height:24rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-52{width:13rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-9{width:2.25rem}.w-auto{width:auto}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-10{min-width:2.5rem}.min-w-7{min-width:1.75rem}.min-w-8{min-width:2rem}.max-w-2xl{max-width:42rem}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-95{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fade-up{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-up{animation:fade-up .4s ease-out}@keyframes ping{75%,to{transform:scale(2);opacity:0}}.animate-ping{animation:ping 1s cubic-bezier(0,0,.2,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.list-none{list-style-type:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-x-8{-moz-column-gap:2rem;column-gap:2rem}.gap-y-1{row-gap:.25rem}.gap-y-1\.5{row-gap:.375rem}.gap-y-2{row-gap:.5rem}.gap-y-3{row-gap:.75rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-amber-600\/20{border-color:#d9770633}.border-blue-600\/20{border-color:#2563eb33}.border-border{border-color:hsl(var(--border))}.border-border\/60{border-color:hsl(var(--border) / .6)}.border-cyan-600\/20{border-color:#0891b233}.border-destructive\/40{border-color:hsl(var(--destructive) / .4)}.border-destructive\/60{border-color:hsl(var(--destructive) / .6)}.border-emerald-600\/20{border-color:#05966933}.border-input{border-color:hsl(var(--input))}.border-lime-600\/20{border-color:#65a30d33}.border-pink-600\/20{border-color:#db277733}.border-primary\/30{border-color:hsl(var(--primary) / .3)}.border-primary\/40{border-color:hsl(var(--primary) / .4)}.border-red-600\/20{border-color:#dc262633}.border-success\/40{border-color:hsl(var(--success) / .4)}.border-transparent{border-color:transparent}.border-violet-600\/20{border-color:#7c3aed33}.border-warning\/40{border-color:hsl(var(--warning) / .4)}.bg-amber-600{--tw-bg-opacity: 1;background-color:rgb(217 119 6 / var(--tw-bg-opacity, 1))}.bg-amber-600\/10{background-color:#d977061a}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.bg-blue-600\/10{background-color:#2563eb1a}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-card\/80{background-color:hsl(var(--card) / .8)}.bg-cyan-600{--tw-bg-opacity: 1;background-color:rgb(8 145 178 / var(--tw-bg-opacity, 1))}.bg-cyan-600\/10{background-color:#0891b21a}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-destructive\/15{background-color:hsl(var(--destructive) / .15)}.bg-destructive\/5{background-color:hsl(var(--destructive) / .05)}.bg-emerald-600{--tw-bg-opacity: 1;background-color:rgb(5 150 105 / var(--tw-bg-opacity, 1))}.bg-emerald-600\/10{background-color:#0596691a}.bg-lime-600{--tw-bg-opacity: 1;background-color:rgb(101 163 13 / var(--tw-bg-opacity, 1))}.bg-lime-600\/10{background-color:#65a30d1a}.bg-muted{background-color:hsl(var(--muted))}.bg-muted-foreground{background-color:hsl(var(--muted-foreground))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/40{background-color:hsl(var(--muted) / .4)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-muted\/60{background-color:hsl(var(--muted) / .6)}.bg-pillar-graph{--tw-bg-opacity: 1;background-color:hsl(var(--pillar-graph) / var(--tw-bg-opacity, 1))}.bg-pillar-graph\/15{background-color:hsl(var(--pillar-graph) / .15)}.bg-pillar-memory\/15{background-color:hsl(var(--pillar-memory) / .15)}.bg-pillar-review\/15{background-color:hsl(var(--pillar-review) / .15)}.bg-pillar-tokens\/15{background-color:hsl(var(--pillar-tokens) / .15)}.bg-pink-600{--tw-bg-opacity: 1;background-color:rgb(219 39 119 / var(--tw-bg-opacity, 1))}.bg-pink-600\/10{background-color:#db27771a}.bg-primary{background-color:hsl(var(--primary))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/15{background-color:hsl(var(--primary) / .15)}.bg-primary\/20{background-color:hsl(var(--primary) / .2)}.bg-primary\/5{background-color:hsl(var(--primary) / .05)}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-red-600\/10{background-color:#dc26261a}.bg-secondary{background-color:hsl(var(--secondary))}.bg-success{background-color:hsl(var(--success))}.bg-success\/10{background-color:hsl(var(--success) / .1)}.bg-success\/15{background-color:hsl(var(--success) / .15)}.bg-success\/20{background-color:hsl(var(--success) / .2)}.bg-success\/5{background-color:hsl(var(--success) / .05)}.bg-violet-600{--tw-bg-opacity: 1;background-color:rgb(124 58 237 / var(--tw-bg-opacity, 1))}.bg-violet-600\/10{background-color:#7c3aed1a}.bg-warning{background-color:hsl(var(--warning))}.bg-warning\/10{background-color:hsl(var(--warning) / .1)}.bg-warning\/15{background-color:hsl(var(--warning) / .15)}.bg-warning\/20{background-color:hsl(var(--warning) / .2)}.bg-warning\/5{background-color:hsl(var(--warning) / .05)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-10{padding:2.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-4{padding-bottom:1rem}.pl-2{padding-left:.5rem}.pl-2\.5{padding-left:.625rem}.pl-3{padding-left:.75rem}.pl-5{padding-left:1.25rem}.pl-8{padding-left:2rem}.pr-1{padding-right:.25rem}.pr-2{padding-right:.5rem}.pr-2\.5{padding-right:.625rem}.pr-3{padding-right:.75rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-5{padding-top:1.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-top{vertical-align:top}.align-middle{vertical-align:middle}.font-mono{font-family:JetBrains Mono,monospace}.font-sans{font-family:Inter,system-ui,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.lowercase{text-transform:lowercase}.capitalize{text-transform:capitalize}.normal-case{text-transform:none}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-relaxed{line-height:1.625}.tracking-normal{letter-spacing:0em}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-brand{color:hsl(var(--brand))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity, 1))}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-lime-600{--tw-text-opacity: 1;color:rgb(101 163 13 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-pillar-graph{--tw-text-opacity: 1;color:hsl(var(--pillar-graph) / var(--tw-text-opacity, 1))}.text-pillar-memory{--tw-text-opacity: 1;color:hsl(var(--pillar-memory) / var(--tw-text-opacity, 1))}.text-pillar-review{--tw-text-opacity: 1;color:hsl(var(--pillar-review) / var(--tw-text-opacity, 1))}.text-pillar-tokens{--tw-text-opacity: 1;color:hsl(var(--pillar-tokens) / var(--tw-text-opacity, 1))}.text-pink-600{--tw-text-opacity: 1;color:rgb(219 39 119 / var(--tw-text-opacity, 1))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-success{color:hsl(var(--success))}.text-violet-600{--tw-text-opacity: 1;color:rgb(124 58 237 / var(--tw-text-opacity, 1))}.text-warning{color:hsl(var(--warning))}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-75{transition-duration:75ms}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.hover\:glow:hover{box-shadow:0 0 60px -15px hsl(var(--primary) / .3)}.light .hover\:glow:hover{box-shadow:0 0 60px -15px hsl(var(--primary) / .15)}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.first\:pt-0:first-child{padding-top:0}.last\:pb-0:last-child{padding-bottom:0}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-primary\/50:hover{border-color:hsl(var(--primary) / .5)}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-background\/60:hover{background-color:hsl(var(--background) / .6)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:underline:hover{text-decoration-line:underline}.focus\:border-destructive:focus{border-color:hsl(var(--destructive))}.focus\:border-primary\/50:focus{border-color:hsl(var(--primary) / .5)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.prose-headings\:font-semibold :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){font-weight:600}.prose-headings\:text-foreground :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-p\:text-muted-foreground :is(:where(p):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--muted-foreground))}.prose-a\:text-primary :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--primary))}.prose-a\:no-underline :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-line:none}.hover\:prose-a\:underline :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))):hover{text-decoration-line:underline}.prose-blockquote\:border-border :is(:where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *))){border-color:hsl(var(--border))}.prose-blockquote\:text-muted-foreground :is(:where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--muted-foreground))}.prose-strong\:text-foreground :is(:where(strong):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-em\:text-foreground :is(:where(em):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-code\:rounded :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))){border-radius:.25rem}.prose-code\:bg-muted\/60 :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))){background-color:hsl(var(--muted) / .6)}.prose-code\:px-1 :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))){padding-left:.25rem;padding-right:.25rem}.prose-code\:py-0\.5 :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))){padding-top:.125rem;padding-bottom:.125rem}.prose-code\:text-foreground :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-code\:before\:content-none :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))):before{--tw-content: none;content:var(--tw-content)}.prose-code\:after\:content-none :is(:where(code):not(:where([class~=not-prose],[class~=not-prose] *))):after{--tw-content: none;content:var(--tw-content)}.prose-pre\:border :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){border-width:1px}.prose-pre\:bg-muted\/50 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){background-color:hsl(var(--muted) / .5)}.prose-pre\:text-foreground :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-li\:text-muted-foreground :is(:where(li):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--muted-foreground))}.prose-th\:text-foreground :is(:where(th):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--foreground))}.prose-td\:text-muted-foreground :is(:where(td):not(:where([class~=not-prose],[class~=not-prose] *))){color:hsl(var(--muted-foreground))}.prose-hr\:border-border :is(:where(hr):not(:where([class~=not-prose],[class~=not-prose] *))){border-color:hsl(var(--border))}@media(min-width:640px){.sm\:mr-3{margin-right:.75rem}.sm\:block{display:block}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.sm\:px-4{padding-left:1rem;padding-right:1rem}}@media(min-width:1024px){.lg\:block{display:block}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[16rem_1fr\]{grid-template-columns:16rem 1fr}.lg\:grid-cols-\[18rem_1fr\]{grid-template-columns:18rem 1fr}.lg\:grid-cols-\[1fr_20rem\]{grid-template-columns:1fr 20rem}.lg\:items-start{align-items:flex-start}.lg\:px-6{padding-left:1.5rem;padding-right:1.5rem}.lg\:pb-6{padding-bottom:1.5rem}.lg\:pt-4{padding-top:1rem}}@media(min-width:1280px){.xl\:inline{display:inline}}@media(min-width:1536px){.\32xl\:px-2\.5{padding-left:.625rem;padding-right:.625rem}}.\[\&\>p\]\:inline>p{display:inline} diff --git a/internal/ui/assets/assets/index-DHVCIEzJ.js b/internal/ui/assets/assets/index-DHVCIEzJ.js new file mode 100644 index 0000000..ed69463 --- /dev/null +++ b/internal/ui/assets/assets/index-DHVCIEzJ.js @@ -0,0 +1 @@ +import{g as p,j as C,h as Q,q as T,o as U,c as Z}from"./radial-aO03NmL0.js";import{e as fn,b as en,f as on,a as an}from"./radial-aO03NmL0.js";function $(i){return i.x+i.vx}function R(i){return i.y+i.vy}function V(i){return i.z+i.vz}function N(i){var e,t,c,s,o=1,g=1;typeof i!="function"&&(i=p(i==null?1:+i));function n(){for(var r,u=e.length,y,v,d,M,j,q,B,D=0;D1&&(M=v.y+v.vy),t>2&&(j=v.z+v.vz),y.visit(S);function S(L,X,Y,k,E,F,G){var A=[X,Y,k,E,F,G],H=A[0],I=A[1],J=A[2],K=A[t],O=A[t+1],P=A[t+2],l=L.data,b=L.r,a=q+b;if(l){if(l.index>v.index){var m=d-l.x-l.vx,z=t>1?M-l.y-l.vy:0,x=t>2?j-l.z-l.vz:0,h=m*m+z*z+x*x;h1&&z===0&&(z=C(s),h+=z*z),t>2&&x===0&&(x=C(s),h+=x*x),h=(a-(h=Math.sqrt(h)))/h*o,v.vx+=(m*=h)*(a=(b*=b)/(B+b)),t>1&&(v.vy+=(z*=h)*a),t>2&&(v.vz+=(x*=h)*a),l.vx-=m*(a=1-a),t>1&&(l.vy-=z*a),t>2&&(l.vz-=x*a))}return}return H>d+a||K1&&(I>M+a||O2&&(J>j+a||Pr.r&&(r.r=r[u].r)}function w(){if(e){var r,u=e.length,y;for(c=new Array(u),r=0;rtypeof y=="function")||Math.random,t=u.find(y=>[1,2,3].includes(y))||2,w()},n.iterations=function(r){return arguments.length?(g=+r,n):g},n.strength=function(r){return arguments.length?(o=+r,n):o},n.radius=function(r){return arguments.length?(i=typeof r=="function"?r:p(+r),w(),n):i},n}function _(i){var e=p(.1),t,c,s;typeof i!="function"&&(i=p(i==null?0:+i));function o(n){for(var f=0,w=t.length,r;fi.map(i=>d[i]); +var Bn=Object.defineProperty;var Sn=(e,t,n)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var O1=(e,t,n)=>Sn(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&l(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerPolicy&&(r.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?r.credentials="include":o.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function l(o){if(o.ep)return;o.ep=!0;const r=n(o);fetch(o.href,r)}})();/** +* @vue/shared v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function yt(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const W1={},le=[],z2=()=>{},H7=()=>!1,J4=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),z4=e=>e.startsWith("onUpdate:"),r2=Object.assign,bt=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Rn=Object.prototype.hasOwnProperty,N1=(e,t)=>Rn.call(e,t),v1=Array.isArray,M3=e=>u4(e)==="[object Map]",ie=e=>u4(e)==="[object Set]",zt=e=>u4(e)==="[object Date]",I1=e=>typeof e=="function",T1=e=>typeof e=="string",G2=e=>typeof e=="symbol",G1=e=>e!==null&&typeof e=="object",T7=e=>(G1(e)||I1(e))&&I1(e.then)&&I1(e.catch),Y7=Object.prototype.toString,u4=e=>Y7.call(e),Qn=e=>u4(e).slice(8,-1),V7=e=>u4(e)==="[object Object]",kt=e=>T1(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Se=yt(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),j4=e=>{const t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},Nn=/-\w/g,b2=j4(e=>e.replace(Nn,t=>t.slice(1).toUpperCase())),Kn=/\B([A-Z])/g,Z3=j4(e=>e.replace(Kn,"-$1").toLowerCase()),X4=j4(e=>e.charAt(0).toUpperCase()+e.slice(1)),y5=j4(e=>e?`on${X4(e)}`:""),V2=(e,t)=>!Object.is(e,t),D4=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:l,value:n})},Ct=e=>{const t=parseFloat(e);return isNaN(t)?e:t},Gn=e=>{const t=T1(e)?Number(e):NaN;return isNaN(t)?e:t};let jt;const q4=()=>jt||(jt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function S2(e){if(v1(e)){const t={};for(let n=0;n{if(n){const l=n.split($n);l.length>1&&(t[l[0].trim()]=l[1].trim())}}),t}function f1(e){let t="";if(T1(e))t=e;else if(v1(e))for(let n=0;npe(n,t))}const j7=e=>!!(e&&e.__v_isRef===!0),N=e=>T1(e)?e:e==null?"":v1(e)||G1(e)&&(e.toString===Y7||!I1(e.toString))?j7(e)?N(e.value):JSON.stringify(e,X7,2):String(e),X7=(e,t)=>j7(t)?X7(e,t.value):M3(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[l,o],r)=>(n[b5(l,r)+" =>"]=o,n),{})}:ie(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>b5(n))}:G2(t)?b5(t):G1(t)&&!v1(t)&&!V7(t)?String(t):t,b5=(e,t="")=>{var n;return G2(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** +* @vue/reactivity v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let a2;class Yn{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!t&&a2&&(a2.active?(this.parent=a2,this.index=(a2.scopes||(a2.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes){const l=this.scopes.slice();for(t=0,n=l.length;t0&&--this._on===0){if(a2===this)a2=this.prevScope;else{let t=a2;for(;t;){if(t.prevScope===this){t.prevScope=this.prevScope;break}t=t.prevScope}}this.prevScope=void 0}}stop(t){if(this._active){this._active=!1;let n,l;for(n=0,l=this.effects.length;n0)return;if(Qe){let t=Qe;for(Qe=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;Re;){let t=Re;for(Re=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(l){e||(e=l)}t=n}}if(e)throw e}function n8(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function l8(e){let t,n=e.depsTail,l=n;for(;l;){const o=l.prevDep;l.version===-1?(l===n&&(n=o),_t(l),Un(l)):t=l,l.dep.activeLink=l.prevActiveLink,l.prevActiveLink=void 0,l=o}e.deps=t,e.depsTail=n}function V5(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(o8(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function o8(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Pe)||(e.globalVersion=Pe,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!V5(e))))return;e.flags|=2;const t=e.dep,n=P1,l=N2;P1=e,N2=!0;try{n8(e);const o=e.fn(e._value);(t.version===0||V2(o,e._value))&&(e.flags|=128,e._value=o,t.version++)}catch(o){throw t.version++,o}finally{P1=n,N2=l,l8(e),e.flags&=-3}}function _t(e,t=!1){const{dep:n,prevSub:l,nextSub:o}=e;if(l&&(l.nextSub=o,e.prevSub=void 0),o&&(o.prevSub=l,e.nextSub=void 0),n.subs===e&&(n.subs=l,!l&&n.computed)){n.computed.flags&=-5;for(let r=n.computed.deps;r;r=r.nextDep)_t(r,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Un(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let N2=!0;const r8=[];function u3(){r8.push(N2),N2=!1}function d3(){const e=r8.pop();N2=e===void 0?!0:e}function qt(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=P1;P1=void 0;try{t()}finally{P1=n}}}let Pe=0;class Jn{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class It{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(t){if(!P1||!N2||P1===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==P1)n=this.activeLink=new Jn(P1,this),P1.deps?(n.prevDep=P1.depsTail,P1.depsTail.nextDep=n,P1.depsTail=n):P1.deps=P1.depsTail=n,s8(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const l=n.nextDep;l.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=l),n.prevDep=P1.depsTail,n.nextDep=void 0,P1.depsTail.nextDep=n,P1.depsTail=n,P1.deps===n&&(P1.deps=l)}return n}trigger(t){this.version++,Pe++,this.notify(t)}notify(t){wt();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{xt()}}}function s8(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let l=t.deps;l;l=l.nextDep)s8(l)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const U5=new WeakMap,Y3=Symbol(""),J5=Symbol(""),He=Symbol("");function f2(e,t,n){if(N2&&P1){let l=U5.get(e);l||U5.set(e,l=new Map);let o=l.get(n);o||(l.set(n,o=new It),o.map=l,o.key=n),o.track()}}function s3(e,t,n,l,o,r){const s=U5.get(e);if(!s){Pe++;return}const a=i=>{i&&i.trigger()};if(wt(),t==="clear")s.forEach(a);else{const i=v1(e),c=i&&kt(n);if(i&&n==="length"){const d=Number(l);s.forEach((u,A)=>{(A==="length"||A===He||!G2(A)&&A>=d)&&a(u)})}else switch((n!==void 0||s.has(void 0))&&a(s.get(n)),c&&a(s.get(He)),t){case"add":i?c&&a(s.get("length")):(a(s.get(Y3)),M3(e)&&a(s.get(J5)));break;case"delete":i||(a(s.get(Y3)),M3(e)&&a(s.get(J5)));break;case"set":M3(e)&&a(s.get(Y3));break}}xt()}function X3(e){const t=R1(e);return t===e?t:(f2(t,"iterate",He),E2(e)?t:t.map(O2))}function e5(e){return f2(e=R1(e),"iterate",He),e}function T2(e,t){return f3(e)?ce(V3(e)?O2(t):t):O2(t)}const zn={__proto__:null,[Symbol.iterator](){return C5(this,Symbol.iterator,e=>T2(this,e))},concat(...e){return X3(this).concat(...e.map(t=>v1(t)?X3(t):t))},entries(){return C5(this,"entries",e=>(e[1]=T2(this,e[1]),e))},every(e,t){return e3(this,"every",e,t,void 0,arguments)},filter(e,t){return e3(this,"filter",e,t,n=>n.map(l=>T2(this,l)),arguments)},find(e,t){return e3(this,"find",e,t,n=>T2(this,n),arguments)},findIndex(e,t){return e3(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return e3(this,"findLast",e,t,n=>T2(this,n),arguments)},findLastIndex(e,t){return e3(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return e3(this,"forEach",e,t,void 0,arguments)},includes(...e){return w5(this,"includes",e)},indexOf(...e){return w5(this,"indexOf",e)},join(e){return X3(this).join(e)},lastIndexOf(...e){return w5(this,"lastIndexOf",e)},map(e,t){return e3(this,"map",e,t,void 0,arguments)},pop(){return be(this,"pop")},push(...e){return be(this,"push",e)},reduce(e,...t){return e6(this,"reduce",e,t)},reduceRight(e,...t){return e6(this,"reduceRight",e,t)},shift(){return be(this,"shift")},some(e,t){return e3(this,"some",e,t,void 0,arguments)},splice(...e){return be(this,"splice",e)},toReversed(){return X3(this).toReversed()},toSorted(e){return X3(this).toSorted(e)},toSpliced(...e){return X3(this).toSpliced(...e)},unshift(...e){return be(this,"unshift",e)},values(){return C5(this,"values",e=>T2(this,e))}};function C5(e,t,n){const l=e5(e),o=l[t]();return l!==e&&!E2(e)&&(o._next=o.next,o.next=()=>{const r=o._next();return r.done||(r.value=n(r.value)),r}),o}const jn=Array.prototype;function e3(e,t,n,l,o,r){const s=e5(e),a=s!==e&&!E2(e),i=s[t];if(i!==jn[t]){const u=i.apply(e,r);return a?O2(u):u}let c=n;s!==e&&(a?c=function(u,A){return n.call(this,T2(e,u),A,e)}:n.length>2&&(c=function(u,A){return n.call(this,u,A,e)}));const d=i.call(s,c,l);return a&&o?o(d):d}function e6(e,t,n,l){const o=e5(e),r=o!==e&&!E2(e);let s=n,a=!1;o!==e&&(r?(a=l.length===0,s=function(c,d,u){return a&&(a=!1,c=T2(e,c)),n.call(this,c,T2(e,d),u,e)}):n.length>3&&(s=function(c,d,u){return n.call(this,c,d,u,e)}));const i=o[t](s,...l);return a?T2(e,i):i}function w5(e,t,n){const l=R1(e);f2(l,"iterate",He);const o=l[t](...n);return(o===-1||o===!1)&&Dt(n[0])?(n[0]=R1(n[0]),l[t](...n)):o}function be(e,t,n=[]){u3(),wt();const l=R1(e)[t].apply(e,n);return xt(),d3(),l}const Xn=yt("__proto__,__v_isRef,__isVue"),a8=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(G2));function qn(e){G2(e)||(e=String(e));const t=R1(this);return f2(t,"has",e),t.hasOwnProperty(e)}class i8{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,l){if(n==="__v_skip")return t.__v_skip;const o=this._isReadonly,r=this._isShallow;if(n==="__v_isReactive")return!o;if(n==="__v_isReadonly")return o;if(n==="__v_isShallow")return r;if(n==="__v_raw")return l===(o?r?cl:f8:r?d8:u8).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(l)?t:void 0;const s=v1(t);if(!o){let i;if(s&&(i=zn[n]))return i;if(n==="hasOwnProperty")return qn}const a=Reflect.get(t,n,n2(t)?t:l);if((G2(n)?a8.has(n):Xn(n))||(o||f2(t,"get",n),r))return a;if(n2(a)){const i=s&&kt(n)?a:a.value;return o&&G1(i)?j5(i):i}return G1(a)?o?j5(a):t5(a):a}}class c8 extends i8{constructor(t=!1){super(!1,t)}set(t,n,l,o){let r=t[n];const s=v1(t)&&kt(n);if(!this._isShallow){const c=f3(r);if(!E2(l)&&!f3(l)&&(r=R1(r),l=R1(l)),!s&&n2(r)&&!n2(l))return c||(r.value=l),!0}const a=s?Number(n)e,m4=e=>Reflect.getPrototypeOf(e);function ol(e,t,n){return function(...l){const o=this.__v_raw,r=R1(o),s=M3(r),a=e==="entries"||e===Symbol.iterator&&s,i=e==="keys"&&s,c=o[e](...l),d=n?z5:t?ce:O2;return!t&&f2(r,"iterate",i?J5:Y3),r2(Object.create(c),{next(){const{value:u,done:A}=c.next();return A?{value:u,done:A}:{value:a?[d(u[0]),d(u[1])]:d(u),done:A}}})}}function g4(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function rl(e,t){const n={get(o){const r=this.__v_raw,s=R1(r),a=R1(o);e||(V2(o,a)&&f2(s,"get",o),f2(s,"get",a));const{has:i}=m4(s),c=t?z5:e?ce:O2;if(i.call(s,o))return c(r.get(o));if(i.call(s,a))return c(r.get(a));r!==s&&r.get(o)},get size(){const o=this.__v_raw;return!e&&f2(R1(o),"iterate",Y3),o.size},has(o){const r=this.__v_raw,s=R1(r),a=R1(o);return e||(V2(o,a)&&f2(s,"has",o),f2(s,"has",a)),o===a?r.has(o):r.has(o)||r.has(a)},forEach(o,r){const s=this,a=s.__v_raw,i=R1(a),c=t?z5:e?ce:O2;return!e&&f2(i,"iterate",Y3),a.forEach((d,u)=>o.call(r,c(d),c(u),s))}};return r2(n,e?{add:g4("add"),set:g4("set"),delete:g4("delete"),clear:g4("clear")}:{add(o){const r=R1(this),s=m4(r),a=R1(o),i=!t&&!E2(o)&&!f3(o)?a:o;return s.has.call(r,i)||V2(o,i)&&s.has.call(r,o)||V2(a,i)&&s.has.call(r,a)||(r.add(i),s3(r,"add",i,i)),this},set(o,r){!t&&!E2(r)&&!f3(r)&&(r=R1(r));const s=R1(this),{has:a,get:i}=m4(s);let c=a.call(s,o);c||(o=R1(o),c=a.call(s,o));const d=i.call(s,o);return s.set(o,r),c?V2(r,d)&&s3(s,"set",o,r):s3(s,"add",o,r),this},delete(o){const r=R1(this),{has:s,get:a}=m4(r);let i=s.call(r,o);i||(o=R1(o),i=s.call(r,o)),a&&a.call(r,o);const c=r.delete(o);return i&&s3(r,"delete",o,void 0),c},clear(){const o=R1(this),r=o.size!==0,s=o.clear();return r&&s3(o,"clear",void 0,void 0),s}}),["keys","values","entries",Symbol.iterator].forEach(o=>{n[o]=ol(o,e,t)}),n}function Mt(e,t){const n=rl(e,t);return(l,o,r)=>o==="__v_isReactive"?!e:o==="__v_isReadonly"?e:o==="__v_raw"?l:Reflect.get(N1(n,o)&&o in l?n:l,o,r)}const sl={get:Mt(!1,!1)},al={get:Mt(!1,!0)},il={get:Mt(!0,!1)};const u8=new WeakMap,d8=new WeakMap,f8=new WeakMap,cl=new WeakMap;function ul(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function t5(e){return f3(e)?e:Et(e,!1,tl,sl,u8)}function A8(e){return Et(e,!1,ll,al,d8)}function j5(e){return Et(e,!0,nl,il,f8)}function Et(e,t,n,l,o){if(!G1(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;const r=o.get(e);if(r)return r;const s=ul(Qn(e));if(s===0)return e;const a=new Proxy(e,s===2?l:n);return o.set(e,a),a}function V3(e){return f3(e)?V3(e.__v_raw):!!(e&&e.__v_isReactive)}function f3(e){return!!(e&&e.__v_isReadonly)}function E2(e){return!!(e&&e.__v_isShallow)}function Dt(e){return e?!!e.__v_raw:!1}function R1(e){const t=e&&e.__v_raw;return t?R1(t):e}function dl(e){return!N1(e,"__v_skip")&&Object.isExtensible(e)&&U7(e,"__v_skip",!0),e}const O2=e=>G1(e)?t5(e):e,ce=e=>G1(e)?j5(e):e;function n2(e){return e?e.__v_isRef===!0:!1}function z(e){return h8(e,!1)}function fl(e){return h8(e,!0)}function h8(e,t){return n2(e)?e:new Al(e,t)}class Al{constructor(t,n){this.dep=new It,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:R1(t),this._value=n?t:O2(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,l=this.__v_isShallow||E2(t)||f3(t);t=l?t:R1(t),V2(t,n)&&(this._rawValue=t,this._value=l?t:O2(t),this.dep.trigger())}}function f(e){return n2(e)?e.value:e}const hl={get:(e,t,n)=>t==="__v_raw"?e:f(Reflect.get(e,t,n)),set:(e,t,n,l)=>{const o=e[t];return n2(o)&&!n2(n)?(o.value=n,!0):Reflect.set(e,t,n,l)}};function p8(e){return V3(e)?e:new Proxy(e,hl)}class pl{constructor(t,n,l){this.fn=t,this.setter=n,this._value=void 0,this.dep=new It(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Pe-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=l}notify(){if(this.flags|=16,!(this.flags&8)&&P1!==this)return t8(this,!0),!0}get value(){const t=this.dep.track();return o8(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function ml(e,t,n=!1){let l,o;return I1(e)?l=e:(l=e.get,o=e.set),new pl(l,o,n)}const v4={},R4=new WeakMap;let $3;function gl(e,t=!1,n=$3){if(n){let l=R4.get(n);l||R4.set(n,l=[]),l.push(e)}}function vl(e,t,n=W1){const{immediate:l,deep:o,once:r,scheduler:s,augmentJob:a,call:i}=n,c=_=>o?_:E2(_)||o===!1||o===0?a3(_,1):a3(_);let d,u,A,m,p=!1,y=!1;if(n2(e)?(u=()=>e.value,p=E2(e)):V3(e)?(u=()=>c(e),p=!0):v1(e)?(y=!0,p=e.some(_=>V3(_)||E2(_)),u=()=>e.map(_=>{if(n2(_))return _.value;if(V3(_))return c(_);if(I1(_))return i?i(_,2):_()})):I1(e)?t?u=i?()=>i(e,2):e:u=()=>{if(A){u3();try{A()}finally{d3()}}const _=$3;$3=d;try{return i?i(e,3,[m]):e(m)}finally{$3=_}}:u=z2,t&&o){const _=u,R=o===!0?1/0:o;u=()=>a3(_(),R)}const k=Vn(),F=()=>{d.stop(),k&&k.active&&bt(k.effects,d)};if(r&&t){const _=t;t=(...R)=>{const $=_(...R);return F(),$}}let M=y?new Array(e.length).fill(v4):v4;const E=_=>{if(!(!(d.flags&1)||!d.dirty&&!_))if(t){const R=d.run();if(_||o||p||(y?R.some(($,D)=>V2($,M[D])):V2(R,M))){A&&A();const $=$3;$3=d;try{const D=[R,M===v4?void 0:y&&M[0]===v4?[]:M,m];M=R,i?i(t,3,D):t(...D)}finally{$3=$}}}else d.run()};return a&&a(E),d=new q7(u),d.scheduler=s?()=>s(E,!1):E,m=_=>gl(_,!1,d),A=d.onStop=()=>{const _=R4.get(d);if(_){if(i)i(_,4);else for(const R of _)R();R4.delete(d)}},t?l?E(!0):M=d.run():s?s(E.bind(null,!0),!0):d.run(),F.pause=d.pause.bind(d),F.resume=d.resume.bind(d),F.stop=F,F}function a3(e,t=1/0,n){if(t<=0||!G1(e)||e.__v_skip||(n=n||new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,n2(e))a3(e.value,t,n);else if(v1(e))for(let l=0;l{a3(l,t,n)});else if(V7(e)){for(const l in e)a3(e[l],t,n);for(const l of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,l)&&a3(e[l],t,n)}return e}/** +* @vue/runtime-core v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function d4(e,t,n,l){try{return l?e(...l):e()}catch(o){n5(o,t,n)}}function D2(e,t,n,l){if(I1(e)){const o=d4(e,t,n,l);return o&&T7(o)&&o.catch(r=>{n5(r,t,n)}),o}if(v1(e)){const o=[];for(let r=0;r>>1,o=y2[l],r=Te(o);r=Te(n)?y2.push(e):y2.splice(bl(t),0,e),e.flags|=1,v8()}}function v8(){Q4||(Q4=m8.then(b8))}function kl(e){if(!v1(e))w3&&e.id===-1?w3.splice(te+1,0,e):e.flags&1||(oe.push(e),e.flags|=1);else for(let t=0;tTe(n)-Te(l));if(oe.length=0,w3){for(let n=0;ne.id==null?e.flags&2?-1:1/0:e.id;function b8(e){try{for(H2=0;H2{l._d&&$4(-1);const r=N4(t),s=c3.length;let a;try{a=e(...o)}finally{for(let i=c3.length;i>s;i--)Qt();N4(r),l._d&&$4(1)}return a};return l._n=!0,l._c=!0,l._d=!0,l}function Ne(e,t){if(i2===null)return e;const n=i5(i2),l=e.dirs||(e.dirs=[]);for(let o=0;o1)return n&&I1(t)?t.call(l&&l.proxy):t}}const Cl=Symbol.for("v-scx"),wl=()=>K2(Cl);function t2(e,t,n){return C8(e,t,n)}function C8(e,t,n=W1){const{immediate:l,deep:o,flush:r,once:s}=n,a=r2({},n),i=t&&l||!t&&r!=="post";let c;if(je){if(r==="sync"){const m=wl();c=m.__watcherHandles||(m.__watcherHandles=[])}else if(!i){const m=()=>{};return m.stop=z2,m.resume=z2,m.pause=z2,m}}const d=h2;a.call=(m,p,y)=>D2(m,d,p,y);let u=!1;r==="post"?a.scheduler=m=>{m2(m,d&&d.suspense)}:r!=="sync"&&(u=!0,a.scheduler=(m,p)=>{p?m():Zt(m)}),a.augmentJob=m=>{t&&(m.flags|=4),u&&(m.flags|=2,d&&(m.id=d.uid,m.i=d))};const A=vl(e,t,a);return je&&(c?c.push(A):i&&A()),A}function xl(e,t,n){const l=this.proxy,o=T1(e)?e.includes(".")?w8(l,e):()=>l[e]:e.bind(l,l);let r;I1(t)?r=t:(r=t.handler,n=t);const s=A4(this),a=C8(o,r.bind(l),n);return s(),a}function w8(e,t){const n=t.split(".");return()=>{let l=e;for(let o=0;oe.__isTeleport,W3=e=>e&&(e.disabled||e.disabled===""),_l=e=>e&&(e.defer||e.defer===""),n6=e=>typeof SVGElement<"u"&&e instanceof SVGElement,l6=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,X5=(e,t)=>{const n=e&&e.to;return T1(n)?t?t(n):null:n},Il={name:"Teleport",__isTeleport:!0,process(e,t,n,l,o,r,s,a,i,c){const{mc:d,pc:u,pbc:A,o:{insert:m,querySelector:p,createText:y,createComment:k,parentNode:F}}=c,M=W3(t.props);let{dynamicChildren:E}=t;const _=(D,x,Q)=>{D.shapeFlag&16&&d(D.children,x,Q,o,r,s,a,i)},R=(D=t)=>{const x=W3(D.props),Q=D.target=X5(D.props,p),B=q5(Q,D,y,m);Q&&(s!=="svg"&&n6(Q)?s="svg":s!=="mathml"&&l6(Q)&&(s="mathml"),o&&o.isCE&&(o.ce._teleportTargets||(o.ce._teleportTargets=new Set)).add(Q),x||(_(D,Q,B),Ze(D,!1)))},$=D=>{const x=()=>{if(C3.get(D)===x){if(C3.delete(D),W3(D.props)){const Q=F(D.el)||n;_(D,Q,D.anchor),Ze(D,!0)}R(D)}};C3.set(D,x),m2(x,r)};if(e==null){const D=t.el=y(""),x=t.anchor=y("");if(m(D,n,l),m(x,n,l),_l(t.props)||r&&r.pendingBranch){$(t);return}M&&(_(t,n,x),Ze(t,!0)),R()}else{t.el=e.el;const D=t.anchor=e.anchor,x=C3.get(e);if(x){x.flags|=8,C3.delete(e),$(t);return}t.targetStart=e.targetStart;const Q=t.target=e.target,B=t.targetAnchor=e.targetAnchor,X=W3(e.props),Y=X?n:Q,m1=X?D:B;if(s==="svg"||n6(Q)?s="svg":(s==="mathml"||l6(Q))&&(s="mathml"),E?(A(e.dynamicChildren,E,Y,o,r,s,a),Rt(e,t,!0)):i||u(e,t,Y,m1,o,r,s,a,!1),M)X?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):y4(t,n,D,c,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const w1=X5(t.props,p);w1&&(t.target=w1,y4(t,w1,null,c,0))}else X&&y4(t,Q,B,c,1);Ze(t,M)}},remove(e,t,n,{um:l,o:{remove:o}},r){const{shapeFlag:s,children:a,anchor:i,targetStart:c,targetAnchor:d,target:u,props:A}=e,m=W3(A),p=r||!m,y=C3.get(e);if(y&&(y.flags|=8,C3.delete(e)),u&&(o(c),o(d)),r&&o(i),!y&&(m||u)&&s&16)for(let k=0;k{e.isMounted=!0}),Ft(()=>{e.isUnmounting=!0}),e}const _2=[Function,Array],_8={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:_2,onEnter:_2,onAfterEnter:_2,onEnterCancelled:_2,onBeforeLeave:_2,onLeave:_2,onAfterLeave:_2,onLeaveCancelled:_2,onBeforeAppear:_2,onAppear:_2,onAfterAppear:_2,onAppearCancelled:_2},I8=e=>{const t=e.subTree;return t.component?I8(t.component):t},Zl={name:"BaseTransition",props:_8,setup(e,{slots:t}){const n=e0(),l=Dl();return()=>{const o=t.default&&D8(t.default(),!0),r=o&&o.length?M8(o):n.subTree?P():void 0;if(!r)return;const s=R1(e),{mode:a}=s;if(l.isLeaving)return x5(r);const i=K4(r);if(!i)return x5(r);let c=et(i,s,l,n,u=>c=u);i.type!==A2&&Ye(i,c);let d=n.subTree&&K4(n.subTree);if(d&&d.type!==A2&&!L3(d,i)&&I8(n).type!==A2){let u=et(d,s,l,n);if(Ye(d,u),a==="out-in"&&i.type!==A2)return l.isLeaving=!0,u.afterLeave=()=>{l.isLeaving=!1,n.job.flags&8||n.update(),delete u.afterLeave,d=void 0},x5(r);a==="in-out"&&i.type!==A2?u.delayLeave=(A,m,p)=>{const y=E8(l,d);y[String(d.key)]=d,A[I2]=()=>{m(),A[I2]=void 0,delete c.delayedLeave,d=void 0},c.delayedLeave=()=>{p(),delete c.delayedLeave,d=void 0}}:d=void 0}else d&&(d=void 0);return r}}};function M8(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==A2){t=n;break}}return t}const Fl=Zl;function E8(e,t){const{leavingVNodes:n}=e;let l=n.get(t.type);return l||(l=Object.create(null),n.set(t.type,l)),l}function et(e,t,n,l,o){const{appear:r,mode:s,persisted:a=!1,onBeforeEnter:i,onEnter:c,onAfterEnter:d,onEnterCancelled:u,onBeforeLeave:A,onLeave:m,onAfterLeave:p,onLeaveCancelled:y,onBeforeAppear:k,onAppear:F,onAfterAppear:M,onAppearCancelled:E}=t,_=String(e.key),R=E8(n,e),$=(Q,B)=>{Q&&D2(Q,l,9,B)},D=(Q,B)=>{const X=B[1];$(Q,B),v1(Q)?Q.every(Y=>Y.length<=1)&&X():Q.length<=1&&X()},x={mode:s,persisted:a,beforeEnter(Q){let B=i;if(!n.isMounted)if(r)B=k||i;else return;Q[I2]&&Q[I2](!0);const X=R[_];X&&L3(e,X)&&X.el[I2]&&X.el[I2](),$(B,[Q])},enter(Q){if(R[_]===e)return;let B=c,X=d,Y=u;if(!n.isMounted)if(r)B=F||c,X=M||d,Y=E||u;else return;let m1=!1;Q[ke]=r1=>{m1||(m1=!0,r1?$(Y,[Q]):$(X,[Q]),x.delayedLeave&&x.delayedLeave(),Q[ke]=void 0)};const w1=Q[ke].bind(null,!1);B?D(B,[Q,w1]):w1()},leave(Q,B){const X=String(e.key);if(Q[ke]&&Q[ke](!0),n.isUnmounting)return B();$(A,[Q]);let Y=!1;Q[I2]=w1=>{Y||(Y=!0,B(),w1?$(y,[Q]):$(p,[Q]),Q[I2]=void 0,R[X]===e&&delete R[X])};const m1=Q[I2].bind(null,!1);R[X]=e,m?D(m,[Q,m1]):m1()},clone(Q){const B=et(Q,t,n,l,o);return o&&o(B),B}};return x}function x5(e){if(o5(e))return e=E3(e),e.children=null,e}function K4(e){if(!o5(e))return l5(e.type)&&e.children?M8(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&I1(n.default))return n.default()}}function Ye(e,t){if(e.shapeFlag&6&&e.component){e.transition=t;const n=e.component.subTree;Ye(l5(n.type)&&K4(n)||n,t)}else e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function D8(e,t=!1,n){let l=[],o=0;for(let r=0;r1)for(let r=0;rKe(y,t&&(v1(t)?t[k]:t),n,l,o));return}if(re(l)&&!o){l.shapeFlag&512&&l.type.__asyncResolved&&l.component.subTree.component&&Ke(e,t,n,l.component.subTree);return}const r=l.shapeFlag&4?i5(l.component):l.el,s=o?null:r,{i:a,r:i}=e,c=t&&t.r,d=a.refs===W1?a.refs={}:a.refs,u=a.setupState,A=R1(u),m=u===W1?H7:y=>o6(d,y)?!1:N1(A,y),p=(y,k)=>!(k&&o6(d,k));if(c!=null&&c!==i){if(r6(t),T1(c))d[c]=null,m(c)&&(u[c]=null);else if(n2(c)){const y=t;p(c,y.k)&&(c.value=null),y.k&&(d[y.k]=null)}}if(I1(i))d4(i,a,12,[s,d]);else{const y=T1(i),k=n2(i);if(y||k){const F=()=>{if(e.f){const M=y?m(i)?u[i]:d[i]:p()||!e.k?i.value:d[e.k];if(o)v1(M)&&bt(M,r);else if(v1(M))M.includes(r)||M.push(r);else if(y)d[i]=[r],m(i)&&(u[i]=d[i]);else{const E=[r];p(i,e.k)&&(i.value=E),e.k&&(d[e.k]=E)}}else y?(d[i]=s,m(i)&&(u[i]=s)):k&&(p(i,e.k)&&(i.value=s),e.k&&(d[e.k]=s))};if(s){const M=()=>{F(),G4.delete(e)};M.id=-1,G4.set(e,M),m2(M,n)}else r6(e),F()}}}function r6(e){const t=G4.get(e);t&&(t.flags|=8,G4.delete(e))}q4().requestIdleCallback;q4().cancelIdleCallback;const re=e=>!!e.type.__asyncLoader,o5=e=>e.type.__isKeepAlive;function Bl(e,t){F8(e,"a",t)}function Sl(e,t){F8(e,"da",t)}function F8(e,t,n=h2){const l=e.__wdc||(e.__wdc=()=>{let o=n;for(;o;){if(o.isDeactivated)return;o=o.parent}return e()});if(r5(t,l,n),n){let o=n.parent;for(;o&&o.parent;)o5(o.parent.vnode)&&Rl(l,t,n,o),o=o.parent}}function Rl(e,t,n,l){const o=r5(t,e,l,!0);f4(()=>{bt(l[t],o)},n)}function r5(e,t,n=h2,l=!1){if(n){const o=n[e]||(n[e]=[]),r=t.__weh||(t.__weh=(...s)=>{u3();const a=A4(n),i=D2(t,n,e,s);return a(),d3(),i});return l?o.unshift(r):o.push(r),r}}const p3=e=>(t,n=h2)=>{(!je||e==="sp")&&r5(e,(...l)=>t(...l),n)},Ql=p3("bm"),d2=p3("m"),Nl=p3("bu"),Kl=p3("u"),Ft=p3("bum"),f4=p3("um"),Gl=p3("sp"),Ol=p3("rtg"),$l=p3("rtc");function Wl(e,t=h2){r5("ec",e,t)}const B8="components";function Ve(e,t){return R8(B8,e,!0,t)||e}const S8=Symbol.for("v-ndc");function k2(e){return T1(e)?R8(B8,e,!1)||e:e||S8}function R8(e,t,n=!0,l=!1){const o=i2||h2;if(o){const r=o.type;{const a=Io(r,!1);if(a&&(a===t||a===b2(t)||a===X4(b2(t))))return r}const s=s6(o[e]||r[e],t)||s6(o.appContext[e],t);return!s&&l?r:s}}function s6(e,t){return e&&(e[t]||e[b2(t)]||e[X4(b2(t))])}function _1(e,t,n,l){let o;const r=n,s=v1(e);if(s||T1(e)){const a=s&&V3(e);let i=!1,c=!1;a&&(i=!E2(e),c=f3(e),e=e5(e)),o=new Array(e.length);for(let d=0,u=e.length;dt(a,i,void 0,r));else{const a=Object.keys(e);o=new Array(a.length);for(let i=0,c=a.length;i{const r=l.fn(...o);return r&&(r.key=l.key),r}:l.fn)}return e}function K1(e,t,n,l,o,r){if(n==null&&(n={}),i2.ce||i2.parent&&re(i2.parent)&&i2.parent.ce){const c=n,d=Object.keys(c).length>0;return t!=="default"&&(c.name=t),h(),G(n1,null,[I("slot",c,l&&l())],d?-2:64)}let s=e[t];s&&s._c&&(s._d=!1);const a=c3.length;h();let i;try{const c=s&&Q8(s(n)),d=n.key||r||c&&c.key;i=G(n1,{key:(d&&!G2(d)?d:`_${t}`)+(!c&&l?"_fb":"")},c||(l?l():[]),c&&e._===1?64:-2)}catch(c){for(let d=c3.length;d>a;d--)Qt();throw c}finally{s&&s._c&&(s._d=!0)}return i.scopeId&&(i.slotScopeIds=[i.scopeId+"-s"]),i}function Q8(e){return e.some(t=>Je(t)?!(t.type===A2||t.type===n1&&!Q8(t.children)):!0)?e:null}const tt=e=>e?t0(e)?i5(e):tt(e.parent):null,Ge=r2(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>tt(e.parent),$root:e=>tt(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>K8(e),$forceUpdate:e=>e.f||(e.f=()=>{Zt(e.update)}),$nextTick:e=>e.n||(e.n=g8.bind(e.proxy)),$watch:e=>xl.bind(e)}),_5=(e,t)=>e!==W1&&!e.__isScriptSetup&&N1(e,t),Ll={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:l,data:o,props:r,accessCache:s,type:a,appContext:i}=e;if(t[0]!=="$"){const A=s[t];if(A!==void 0)switch(A){case 1:return l[t];case 2:return o[t];case 4:return n[t];case 3:return r[t]}else{if(_5(l,t))return s[t]=1,l[t];if(o!==W1&&N1(o,t))return s[t]=2,o[t];if(N1(r,t))return s[t]=3,r[t];if(n!==W1&&N1(n,t))return s[t]=4,n[t];nt&&(s[t]=0)}}const c=Ge[t];let d,u;if(c)return t==="$attrs"&&f2(e.attrs,"get",""),c(e);if((d=a.__cssModules)&&(d=d[t]))return d;if(n!==W1&&N1(n,t))return s[t]=4,n[t];if(u=i.config.globalProperties,N1(u,t))return u[t]},set({_:e},t,n){const{data:l,setupState:o,ctx:r}=e;return _5(o,t)?(o[t]=n,!0):l!==W1&&N1(l,t)?(l[t]=n,!0):N1(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(r[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:l,appContext:o,props:r,type:s}},a){let i;return!!(n[a]||e!==W1&&a[0]!=="$"&&N1(e,a)||_5(t,a)||N1(r,a)||N1(l,a)||N1(Ge,a)||N1(o.config.globalProperties,a)||(i=s.__cssModules)&&i[a])},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:N1(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function i6(e){return v1(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let nt=!0;function Pl(e){const t=K8(e),n=e.proxy,l=e.ctx;nt=!1,t.beforeCreate&&c6(t.beforeCreate,e,"bc");const{data:o,computed:r,methods:s,watch:a,provide:i,inject:c,created:d,beforeMount:u,mounted:A,beforeUpdate:m,updated:p,activated:y,deactivated:k,beforeDestroy:F,beforeUnmount:M,destroyed:E,unmounted:_,render:R,renderTracked:$,renderTriggered:D,errorCaptured:x,serverPrefetch:Q,expose:B,inheritAttrs:X,components:Y,directives:m1,filters:w1}=t;if(c&&Hl(c,l,null),s)for(const b1 in s){const y1=s[b1];I1(y1)&&(l[b1]=y1.bind(n))}if(o){const b1=o.call(n,n);G1(b1)&&(e.data=t5(b1))}if(nt=!0,r)for(const b1 in r){const y1=r[b1],k1=I1(y1)?y1.bind(n,n):I1(y1.get)?y1.get.bind(n,n):z2,c1=!I1(y1)&&I1(y1.set)?y1.set.bind(n):z2,L1=t1({get:k1,set:c1});Object.defineProperty(l,b1,{enumerable:!0,configurable:!0,get:()=>L1.value,set:S1=>L1.value=S1})}if(a)for(const b1 in a)N8(a[b1],l,n,b1);if(i){const b1=I1(i)?i.call(n):i;Reflect.ownKeys(b1).forEach(y1=>{Z4(y1,b1[y1])})}d&&c6(d,e,"c");function l1(b1,y1){v1(y1)?y1.forEach(k1=>b1(k1.bind(n))):y1&&b1(y1.bind(n))}if(l1(Ql,u),l1(d2,A),l1(Nl,m),l1(Kl,p),l1(Bl,y),l1(Sl,k),l1(Wl,x),l1($l,$),l1(Ol,D),l1(Ft,M),l1(f4,_),l1(Gl,Q),v1(B))if(B.length){const b1=e.exposed||(e.exposed={});B.forEach(y1=>{Object.defineProperty(b1,y1,{get:()=>n[y1],set:k1=>n[y1]=k1,enumerable:!0})})}else e.exposed||(e.exposed={});R&&e.render===z2&&(e.render=R),X!=null&&(e.inheritAttrs=X),Y&&(e.components=Y),m1&&(e.directives=m1),Q&&Z8(e)}function Hl(e,t,n=z2){v1(e)&&(e=lt(e));for(const l in e){const o=e[l];let r;G1(o)?"default"in o?r=K2(o.from||l,o.default,!0):r=K2(o.from||l):r=K2(o),n2(r)?Object.defineProperty(t,l,{enumerable:!0,configurable:!0,get:()=>r.value,set:s=>r.value=s}):t[l]=r}}function c6(e,t,n){D2(v1(e)?e.map(l=>l.bind(t.proxy)):e.bind(t.proxy),t,n)}function N8(e,t,n,l){let o=l.includes(".")?w8(n,l):()=>n[l];if(T1(e)){const r=t[e];I1(r)&&t2(o,r)}else if(I1(e))t2(o,e.bind(n));else if(G1(e))if(v1(e))e.forEach(r=>N8(r,t,n,l));else{const r=I1(e.handler)?e.handler.bind(n):t[e.handler];I1(r)&&t2(o,r,e)}}function K8(e){const t=e.type,{mixins:n,extends:l}=t,{mixins:o,optionsCache:r,config:{optionMergeStrategies:s}}=e.appContext,a=r.get(t);let i;return a?i=a:!o.length&&!n&&!l?i=t:(i={},o.length&&o.forEach(c=>O4(i,c,s,!0)),O4(i,t,s)),G1(t)&&r.set(t,i),i}function O4(e,t,n,l=!1){const{mixins:o,extends:r}=t;r&&O4(e,r,n,!0),o&&o.forEach(s=>O4(e,s,n,!0));for(const s in t)if(!(l&&s==="expose")){const a=Tl[s]||n&&n[s];e[s]=a?a(e[s],t[s]):t[s]}return e}const Tl={data:u6,props:d6,emits:d6,methods:Fe,computed:Fe,beforeCreate:p2,created:p2,beforeMount:p2,mounted:p2,beforeUpdate:p2,updated:p2,beforeDestroy:p2,beforeUnmount:p2,destroyed:p2,unmounted:p2,activated:p2,deactivated:p2,errorCaptured:p2,serverPrefetch:p2,components:Fe,directives:Fe,watch:Vl,provide:u6,inject:Yl};function u6(e,t){return t?e?function(){return r2(I1(e)?e.call(this,this):e,I1(t)?t.call(this,this):t)}:t:e}function Yl(e,t){return Fe(lt(e),lt(t))}function lt(e){if(v1(e)){const t={};for(let n=0;nt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${b2(t)}Modifiers`]||e[`${Z3(t)}Modifiers`];function jl(e,t,...n){if(e.isUnmounted)return;const l=e.vnode.props||W1;let o=n;const r=t.startsWith("update:"),s=r&&zl(l,t.slice(7));s&&(s.trim&&(o=n.map(d=>T1(d)?d.trim():d)),s.number&&(o=o.map(Ct)));let a,i=l[a=y5(t)]||l[a=y5(b2(t))];!i&&r&&(i=l[a=y5(Z3(t))]),i&&D2(i,e,6,o);const c=l[a+"Once"];if(c){if(!e.emitted)e.emitted={};else if(e.emitted[a])return;e.emitted[a]=!0,D2(c,e,6,o)}}const Xl=new WeakMap;function O8(e,t,n=!1){const l=n?Xl:t.emitsCache,o=l.get(e);if(o!==void 0)return o;const r=e.emits;let s={},a=!1;if(!I1(e)){const i=c=>{const d=O8(c,t,!0);d&&(a=!0,r2(s,d))};!n&&t.mixins.length&&t.mixins.forEach(i),e.extends&&i(e.extends),e.mixins&&e.mixins.forEach(i)}return!r&&!a?(G1(e)&&l.set(e,null),null):(v1(r)?r.forEach(i=>s[i]=null):r2(s,r),G1(e)&&l.set(e,s),s)}function s5(e,t){return!e||!J4(t)?!1:(t=t.slice(2),t=t==="Once"?t:t.replace(/Once$/,""),N1(e,t[0].toLowerCase()+t.slice(1))||N1(e,Z3(t))||N1(e,t))}function f6(e){const{type:t,vnode:n,proxy:l,withProxy:o,propsOptions:[r],slots:s,attrs:a,emit:i,render:c,renderCache:d,props:u,data:A,setupState:m,ctx:p,inheritAttrs:y}=e,k=N4(e);let F,M;try{if(n.shapeFlag&4){const _=o||l,R=_;F=Y2(c.call(R,_,d,u,m,A,p)),M=a}else{const _=t;F=Y2(_.length>1?_(u,{attrs:a,slots:s,emit:i}):_(u,null)),M=t.props?a:ql(a)}}catch(_){c3.length=0,n5(_,e,1),F=I(A2)}let E=F;if(M&&y!==!1){const _=Object.keys(M),{shapeFlag:R}=E;_.length&&R&7&&(r&&_.some(z4)&&(M=eo(M,r)),E=E3(E,M,!1,!0))}if(n.dirs&&(E=E3(E,null,!1,!0),E.dirs=E.dirs?E.dirs.concat(n.dirs):n.dirs),n.transition){const _=l5(E.type)&&K4(E)||E;Ye(_,n.transition)}return F=E,N4(k),F}const ql=e=>{let t;for(const n in e)(n==="class"||n==="style"||J4(n))&&((t||(t={}))[n]=e[n]);return t},eo=(e,t)=>{const n={};for(const l in e)(!z4(l)||!(l.slice(9)in t))&&(n[l]=e[l]);return n};function to(e,t,n){const{props:l,children:o,component:r}=e,{props:s,children:a,patchFlag:i}=t,c=r.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&i>=0){if(i&1024)return!0;if(i&16)return l?A6(l,s,c):!!s;if(i&8){const d=t.dynamicProps;for(let u=0;uObject.create(W8),P8=e=>Object.getPrototypeOf(e)===W8;function lo(e,t,n,l=!1){const o={},r=L8();e.propsDefaults=Object.create(null),H8(e,t,o,r);for(const s in e.propsOptions[0])s in o||(o[s]=void 0);n?e.props=l?o:A8(o):e.type.props?e.props=o:e.props=r,e.attrs=r}function oo(e,t,n,l){const{props:o,attrs:r,vnode:{patchFlag:s}}=e,a=R1(o),[i]=e.propsOptions;let c=!1;if((l||s>0)&&!(s&16)){if(s&8){const d=e.vnode.dynamicProps;for(let u=0;u{i=!0;const[A,m]=T8(u,t,!0);r2(s,A),m&&a.push(...m)};!n&&t.mixins.length&&t.mixins.forEach(d),e.extends&&d(e.extends),e.mixins&&e.mixins.forEach(d)}if(!r&&!i)return G1(e)&&l.set(e,le),le;if(v1(r))for(let d=0;de==="_"||e==="_ctx"||e==="$stable",St=e=>v1(e)?e.map(Y2):[Y2(e)],so=(e,t,n)=>{if(t._n)return t;const l=w((...o)=>St(t(...o)),n);return l._c=!1,l},Y8=(e,t,n)=>{const l=e._ctx;for(const o in e){if(Bt(o))continue;const r=e[o];if(I1(r))t[o]=so(o,r,l);else if(r!=null){const s=St(r);t[o]=()=>s}}},V8=(e,t)=>{const n=St(t);e.slots.default=()=>n},U8=(e,t,n)=>{for(const l in t)(n||!Bt(l))&&(e[l]=t[l])},ao=(e,t,n)=>{const l=e.slots=L8();if(e.vnode.shapeFlag&32){const o=t._;o?(U8(l,t,n),n&&U7(l,"_",o,!0)):Y8(t,l)}else t&&V8(e,t)},io=(e,t,n)=>{const{vnode:l,slots:o}=e;let r=!0,s=W1;if(l.shapeFlag&32){const a=t._;a?n&&a===1?r=!1:U8(o,t,n):(r=!t.$stable,Y8(t,o)),s=t}else t&&(V8(e,t),s={default:1});if(r)for(const a in o)!Bt(a)&&s[a]==null&&delete o[a]},m2=ho;function co(e){return uo(e)}function uo(e,t){const n=q4();n.__VUE__=!0;const{insert:l,remove:o,patchProp:r,createElement:s,createText:a,createComment:i,setText:c,setElementText:d,parentNode:u,nextSibling:A,setScopeId:m=z2,insertStaticContent:p}=e,y=(g,v,Z,L=null,T=null,W=null,a1=void 0,e1=null,j=!!v.dynamicChildren)=>{if(g===v)return;g&&!L3(g,v)&&(L=S(g),S1(g,T,W,!0),g=null),v.patchFlag===-2&&(j=!1,v.dynamicChildren=null);const{type:V,ref:g1,shapeFlag:i1}=v;switch(V){case a5:k(g,v,Z,L);break;case A2:F(g,v,Z,L);break;case F4:g==null&&M(v,Z,L,a1);break;case n1:Y(g,v,Z,L,T,W,a1,e1,j);break;default:i1&1?R(g,v,Z,L,T,W,a1,e1,j):i1&6?m1(g,v,Z,L,T,W,a1,e1,j):(i1&64||i1&128)&&V.process(g,v,Z,L,T,W,a1,e1,j,A1)}g1!=null&&T?Ke(g1,g&&g.ref,W,v||g,!v):g1==null&&g&&g.ref!=null&&Ke(g.ref,null,W,g,!0)},k=(g,v,Z,L)=>{if(g==null)l(v.el=a(v.children),Z,L);else{const T=v.el=g.el;v.children!==g.children&&c(T,v.children)}},F=(g,v,Z,L)=>{g==null?l(v.el=i(v.children||""),Z,L):v.el=g.el},M=(g,v,Z,L)=>{[g.el,g.anchor]=p(g.children,v,Z,L,g.el,g.anchor)},E=({el:g,anchor:v},Z,L)=>{let T;for(;g&&g!==v;)T=A(g),l(g,Z,L),g=T;l(v,Z,L)},_=({el:g,anchor:v})=>{let Z;for(;g&&g!==v;)Z=A(g),o(g),g=Z;o(v)},R=(g,v,Z,L,T,W,a1,e1,j)=>{if(v.type==="svg"?a1="svg":v.type==="math"&&(a1="mathml"),g==null)$(v,Z,L,T,W,a1,e1,j);else{const V=g.el&&g.el._isVueCE?g.el:null;try{V&&V._beginPatch(),Q(g,v,T,W,a1,e1,j)}finally{V&&V._endPatch()}}},$=(g,v,Z,L,T,W,a1,e1)=>{let j,V;const{props:g1,shapeFlag:i1,transition:K,dirs:O}=g;if(j=g.el=s(g.type,W,g1&&g1.is,g1),i1&8?d(j,g.children):i1&16&&x(g.children,j,null,L,T,I5(g,W),a1,e1),O&&S3(g,null,L,"created"),D(j,g,g.scopeId,a1,L),g1){for(const H in g1)H!=="value"&&!Se(H)&&r(j,H,null,g1[H],W,L);"value"in g1&&r(j,"value",null,g1.value,W),(V=g1.onVnodeBeforeMount)&&W2(V,L,g)}O&&S3(g,null,L,"beforeMount");const p1=fo(T,K);p1&&K.beforeEnter(j),l(j,v,Z),((V=g1&&g1.onVnodeMounted)||p1||O)&&m2(()=>{try{V&&W2(V,L,g),p1&&K.enter(j),O&&S3(g,null,L,"mounted")}finally{}},T)},D=(g,v,Z,L,T)=>{if(Z&&m(g,Z),L)for(let W=0;W{for(let V=j;V{const e1=v.el=g.el;let{patchFlag:j,dynamicChildren:V,dirs:g1}=v;j|=g.patchFlag&16;const i1=g.props||W1,K=v.props||W1;let O;if(Z&&R3(Z,!1),(O=K.onVnodeBeforeUpdate)&&W2(O,Z,v,g),g1&&S3(v,g,Z,"beforeUpdate"),Z&&R3(Z,!0),V&&(!g.dynamicChildren||g.dynamicChildren.length!==V.length)&&(j=0,a1=!1,V=null),(i1.innerHTML&&K.innerHTML==null||i1.textContent&&K.textContent==null)&&d(e1,""),V?B(g.dynamicChildren,V,e1,Z,L,I5(v,T),W):a1||y1(g,v,e1,null,Z,L,I5(v,T),W,!1),j>0){if(j&16)X(e1,i1,K,Z,T);else if(j&2&&i1.class!==K.class&&r(e1,"class",null,K.class,T),j&4&&r(e1,"style",i1.style,K.style,T),j&8){const p1=v.dynamicProps;for(let H=0;H{O&&W2(O,Z,v,g),g1&&S3(v,g,Z,"updated")},L)},B=(g,v,Z,L,T,W,a1)=>{for(let e1=0;e1{if(v!==Z){if(v!==W1)for(const W in v)!Se(W)&&!(W in Z)&&r(g,W,v[W],null,T,L);for(const W in Z){if(Se(W))continue;const a1=Z[W],e1=v[W];a1!==e1&&W!=="value"&&r(g,W,e1,a1,T,L)}"value"in Z&&r(g,"value",v.value,Z.value,T)}},Y=(g,v,Z,L,T,W,a1,e1,j)=>{const V=v.el=g?g.el:a(""),g1=v.anchor=g?g.anchor:a("");let{patchFlag:i1,dynamicChildren:K,slotScopeIds:O}=v;O&&(e1=e1?e1.concat(O):O),g==null?(l(V,Z,L),l(g1,Z,L),x(v.children||[],Z,g1,T,W,a1,e1,j)):i1>0&&i1&64&&K&&g.dynamicChildren&&g.dynamicChildren.length===K.length?(B(g.dynamicChildren,K,Z,T,W,a1,e1),(v.key!=null||T&&v===T.subTree)&&Rt(g,v,!0)):y1(g,v,Z,g1,T,W,a1,e1,j)},m1=(g,v,Z,L,T,W,a1,e1,j)=>{v.slotScopeIds=e1,g==null?v.shapeFlag&512?T.ctx.activate(v,Z,L,a1,j):w1(v,Z,L,T,W,a1,j):r1(g,v,j)},w1=(g,v,Z,L,T,W,a1)=>{const e1=g.component=ko(g,L,T);if(o5(g)&&(e1.ctx.renderer=A1),Co(e1,!1,a1),e1.asyncDep){if(T&&T.registerDep(e1,l1,a1),!g.el){const j=e1.subTree=I(A2);F(null,j,v,Z),g.placeholder=j.el}}else l1(e1,g,v,Z,T,W,a1)},r1=(g,v,Z)=>{const L=v.component=g.component;if(to(g,v,Z))if(L.asyncDep&&!L.asyncResolved){b1(L,v,Z);return}else L.next=v,L.update();else v.el=g.el,L.vnode=v},l1=(g,v,Z,L,T,W,a1)=>{const e1=()=>{if(g.isMounted){let{next:i1,bu:K,u:O,parent:p1,vnode:H}=g;{const w2=J8(g);if(w2){i1&&(i1.el=H.el,b1(g,i1,a1)),w2.asyncDep.then(()=>{m2(()=>{g.isUnmounted||V()},T)});return}}let D1=i1,V1;R3(g,!1),i1?(i1.el=H.el,b1(g,i1,a1)):i1=H,K&&D4(K),(V1=i1.props&&i1.props.onVnodeBeforeUpdate)&&W2(V1,p1,i1,H),R3(g,!0);const e2=f6(g),C2=g.subTree;g.subTree=e2,y(C2,e2,u(C2.el),S(C2),g,T,W),i1.el=e2.el,D1===null&&no(g,e2.el),O&&m2(O,T),(V1=i1.props&&i1.props.onVnodeUpdated)&&m2(()=>W2(V1,p1,i1,H),T)}else{let i1;const{el:K,props:O}=v,{bm:p1,m:H,parent:D1,root:V1,type:e2}=g,C2=re(v);R3(g,!1),p1&&D4(p1),!C2&&(i1=O&&O.onVnodeBeforeMount)&&W2(i1,D1,v),R3(g,!0);{V1.ce&&V1.ce._hasShadowRoot()&&V1.ce._injectChildStyle(e2,g.parent?g.parent.type:void 0);const w2=g.subTree=f6(g);y(null,w2,Z,L,g,T,W),v.el=w2.el}if(H&&m2(H,T),!C2&&(i1=O&&O.onVnodeMounted)){const w2=v;m2(()=>W2(i1,D1,w2),T)}(v.shapeFlag&256||D1&&re(D1.vnode)&&D1.vnode.shapeFlag&256)&&g.a&&m2(g.a,T),g.isMounted=!0,v=Z=L=null}};g.scope.on();const j=g.effect=new q7(e1);g.scope.off();const V=g.update=j.run.bind(j),g1=g.job=j.runIfDirty.bind(j);g1.i=g,g1.id=g.uid,j.scheduler=()=>Zt(g1),R3(g,!0),V()},b1=(g,v,Z)=>{v.component=g;const L=g.vnode.props;g.vnode=v,g.next=null,oo(g,v.props,L,Z),io(g,v.children,Z),u3(),t6(g),d3()},y1=(g,v,Z,L,T,W,a1,e1,j=!1)=>{const V=g&&g.children,g1=g?g.shapeFlag:0,i1=v.children,{patchFlag:K,shapeFlag:O}=v;if(K>0){if(K&128){c1(V,i1,Z,L,T,W,a1,e1,j);return}else if(K&256){k1(V,i1,Z,L,T,W,a1,e1,j);return}}O&8?(g1&16&&q(V,T,W),i1!==V&&d(Z,i1)):g1&16?O&16?c1(V,i1,Z,L,T,W,a1,e1,j):q(V,T,W,!0):(g1&8&&d(Z,""),O&16&&x(i1,Z,L,T,W,a1,e1,j))},k1=(g,v,Z,L,T,W,a1,e1,j)=>{g=g||le,v=v||le;const V=g.length,g1=v.length,i1=Math.min(V,g1);let K;for(K=0;Kg1?q(g,T,W,!0,!1,i1):x(v,Z,L,T,W,a1,e1,j,i1)},c1=(g,v,Z,L,T,W,a1,e1,j)=>{let V=0;const g1=v.length;let i1=g.length-1,K=g1-1;for(;V<=i1&&V<=K;){const O=g[V],p1=v[V]=j?r3(v[V]):Y2(v[V]);if(L3(O,p1))y(O,p1,Z,null,T,W,a1,e1,j);else break;V++}for(;V<=i1&&V<=K;){const O=g[i1],p1=v[K]=j?r3(v[K]):Y2(v[K]);if(L3(O,p1))y(O,p1,Z,null,T,W,a1,e1,j);else break;i1--,K--}if(V>i1){if(V<=K){const O=K+1,p1=OK)for(;V<=i1;)S1(g[V],T,W,!0),V++;else{const O=V,p1=V,H=new Map;for(V=p1;V<=K;V++){const M1=v[V]=j?r3(v[V]):Y2(v[V]);M1.key!=null&&H.set(M1.key,V)}let D1,V1=0;const e2=K-p1+1;let C2=!1,w2=0;const v3=new Array(e2);for(V=0;V=e2){S1(M1,T,W,!0);continue}let U1;if(M1.key!=null)U1=H.get(M1.key);else for(D1=p1;D1<=K;D1++)if(v3[D1-p1]===0&&L3(M1,v[D1])){U1=D1;break}U1===void 0?S1(M1,T,W,!0):(v3[U1-p1]=V+1,U1>=w2?w2=U1:C2=!0,y(M1,v[U1],Z,null,T,W,a1,e1,j),V1++)}const ye=C2?Ao(v3):le;for(D1=ye.length-1,V=e2-1;V>=0;V--){const M1=p1+V,U1=v[M1],v5=v[M1+1],Jt=M1+1{const{el:W,type:a1,transition:e1,children:j,shapeFlag:V}=g;if(V&6){L1(g.component.subTree,v,Z,L);return}if(V&128){g.suspense.move(v,Z,L);return}if(V&64){a1.move(g,v,Z,A1);return}if(a1===n1){l(W,v,Z);for(let i1=0;i1e1.enter(W),T));else{const{leave:i1,delayLeave:K,afterLeave:O}=e1,p1=()=>{g.ctx.isUnmounted?o(W):l(W,v,Z)},H=()=>{const D1=W._isLeaving||!!W[I2];W._isLeaving&&W[I2](!0),e1.persisted&&!D1?p1():i1(W,()=>{p1(),O&&O()})};K?K(W,p1,H):H()}else l(W,v,Z)},S1=(g,v,Z,L=!1,T=!1)=>{const{type:W,props:a1,ref:e1,children:j,dynamicChildren:V,shapeFlag:g1,patchFlag:i1,dirs:K,cacheIndex:O,memo:p1}=g;if(i1===-2&&(T=!1),e1!=null&&(u3(),Ke(e1,null,Z,g,!0),d3()),O!=null&&(v.renderCache[O]=void 0),g1&256){v.ctx.deactivate(g);return}const H=g1&1&&K,D1=!re(g);let V1;if(D1&&(V1=a1&&a1.onVnodeBeforeUnmount)&&W2(V1,v,g),g1&6)s1(g.component,Z,L);else{if(g1&128){g.suspense.unmount(Z,L);return}H&&S3(g,null,v,"beforeUnmount"),g1&64?g.type.remove(g,v,Z,A1,L):V&&!V.hasOnce&&(W!==n1||i1>0&&i1&64)?q(V,v,Z,!1,!0):(W===n1&&i1&384||!T&&g1&16)&&q(j,v,Z),L&&Y1(g)}const e2=p1!=null&&O==null;(D1&&(V1=a1&&a1.onVnodeUnmounted)||H||e2)&&m2(()=>{V1&&W2(V1,v,g),H&&S3(g,null,v,"unmounted"),e2&&(g.el=null)},Z)},Y1=g=>{const{type:v,el:Z,anchor:L,transition:T}=g;if(v===n1){q1(Z,L);return}if(v===F4){_(g);return}const W=()=>{o(Z),T&&!T.persisted&&T.afterLeave&&T.afterLeave()};if(g.shapeFlag&1&&T&&!T.persisted){const{leave:a1,delayLeave:e1}=T,j=()=>a1(Z,W);e1?e1(g.el,W,j):j()}else W()},q1=(g,v)=>{let Z;for(;g!==v;)Z=A(g),o(g),g=Z;o(v)},s1=(g,v,Z)=>{const{bum:L,scope:T,job:W,subTree:a1,um:e1,m:j,a:V}=g;p6(j),p6(V),L&&D4(L),T.stop(),W&&(W.flags|=8,S1(a1,g,v,Z)),e1&&m2(e1,v),m2(()=>{g.isUnmounted=!0},v)},q=(g,v,Z,L=!1,T=!1,W=0)=>{for(let a1=W;a1{if(g.shapeFlag&6)return S(g.component.subTree);if(g.shapeFlag&128)return g.suspense.next();const v=A(g.anchor||g.el),Z=v&&v[x8];return Z?A(Z):v};let o1=!1;const J=(g,v,Z)=>{let L;g==null?v._vnode&&(S1(v._vnode,null,null,!0),L=v._vnode.component):y(v._vnode||null,g,v,null,null,null,Z),v._vnode=g,o1||(o1=!0,t6(L),y8(),o1=!1)},A1={p:y,um:S1,m:L1,r:Y1,mt:w1,mc:x,pc:y1,pbc:B,n:S,o:e};return{render:J,hydrate:void 0,createApp:Jl(J)}}function I5({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function R3({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function fo(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Rt(e,t,n=!1){const l=e.children,o=t.children;if(v1(l)&&v1(o))for(let r=0;r>1,e[n[a]]0&&(t[l]=n[r-1]),n[r]=l)}}for(r=n.length,s=n[r-1];r-- >0;)n[r]=s,s=t[s];return n}function J8(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:J8(t)}function p6(e){if(e)for(let t=0;te.__isSuspense;function ho(e,t){t&&t.pendingBranch?v1(e)?t.effects.push(...e):t.effects.push(e):kl(e)}const n1=Symbol.for("v-fgt"),a5=Symbol.for("v-txt"),A2=Symbol.for("v-cmt"),F4=Symbol.for("v-stc"),c3=[];let x2=null;function h(e=!1){c3.push(x2=e?null:[])}function Qt(){c3.pop(),x2=c3[c3.length-1]||null}let Ue=1;function $4(e,t=!1){Ue+=e,e<0&&x2&&t&&(x2.hasOnce=!0)}function X8(e){return e.dynamicChildren=Ue>0?x2||le:null,Qt(),Ue>0&&x2&&x2.push(e),e}function C(e,t,n,l,o,r){return X8(b(e,t,n,l,o,r,!0))}function G(e,t,n,l,o){return X8(I(e,t,n,l,o,!0))}function Je(e){return e?e.__v_isVNode===!0:!1}function L3(e,t){return e.type===t.type&&e.key===t.key}const q8=({key:e})=>e??null,B4=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?T1(e)||n2(e)||I1(e)?{i:i2,r:e,k:t,f:!!n}:e:null);function b(e,t=null,n=null,l=0,o=null,r=e===n1?0:1,s=!1,a=!1){const i={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&q8(t),ref:t&&B4(t),scopeId:k8,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:r,patchFlag:l,dynamicProps:o,dynamicChildren:null,appContext:null,ctx:i2};return a?(W4(i,n),r&128&&e.normalize(i)):n&&(i.shapeFlag|=T1(n)?8:16),Ue>0&&!s&&x2&&(i.patchFlag>0||r&6)&&i.patchFlag!==32&&x2.push(i),i}const I=po;function po(e,t=null,n=null,l=0,o=null,r=!1){if((!e||e===S8)&&(e=A2),Je(e)){const a=E3(e,t,!0);return n&&W4(a,n),Ue>0&&!r&&x2&&(a.shapeFlag&6?x2[x2.indexOf(e)]=a:x2.push(a)),a.patchFlag=-2,a}if(Mo(e)&&(e=e.__vccOpts),t){t=mo(t);let{class:a,style:i}=t;a&&!T1(a)&&(t.class=f1(a)),G1(i)&&(Dt(i)&&!v1(i)&&(i=r2({},i)),t.style=S2(i))}const s=T1(e)?1:j8(e)?128:l5(e)?64:G1(e)?4:I1(e)?2:0;return b(e,t,n,l,o,s,r,!0)}function mo(e){return e?Dt(e)||P8(e)?r2({},e):e:null}function E3(e,t,n=!1,l=!1){const{props:o,ref:r,patchFlag:s,children:a,transition:i}=e,c=t?vo(o||{},t):o,d={__v_isVNode:!0,__v_skip:!0,type:e.type,props:c,key:c&&q8(c),ref:t&&t.ref?n&&r?v1(r)?r.concat(B4(t)):[r,B4(t)]:B4(t):r,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:a,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==n1?s===-1?16:s|16:s,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:i,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&E3(e.ssContent),ssFallback:e.ssFallback&&E3(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return i&&l&&Ye(d,i.clone(d)),d}function U(e=" ",t=0){return I(a5,null,e,t)}function go(e,t){const n=I(F4,null,e);return n.staticCount=t,n}function P(e="",t=!1){return t?(h(),G(A2,null,e)):I(A2,null,e)}function Y2(e){return e==null||typeof e=="boolean"?I(A2):v1(e)?I(n1,null,e.slice()):Je(e)?r3(e):I(a5,null,String(e))}function r3(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:E3(e)}function W4(e,t){let n=0;const{shapeFlag:l}=e;if(t==null)t=null;else if(v1(t))n=16;else if(typeof t=="object")if(l&65){const o=t.default;o&&(o._c&&(o._d=!1),W4(e,o()),o._c&&(o._d=!0));return}else{n=32;const o=t._;!o&&!P8(t)?t._ctx=i2:o===3&&i2&&(i2.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(I1(t)){if(l&65){W4(e,{default:t});return}t={default:t,_ctx:i2},n=32}else t=String(t),l&64?(n=16,t=[U(t)]):n=8;e.children=t,e.shapeFlag|=n}function vo(...e){const t={};for(let n=0;nh2||i2;let L4,ze;{const e=q4(),t=(n,l)=>{let o;return(o=e[n])||(o=e[n]=[]),o.push(l),r=>{o.length>1?o.forEach(s=>s(r)):o[0](r)}};L4=t("__VUE_INSTANCE_SETTERS__",n=>h2=n),ze=t("__VUE_SSR_SETTERS__",n=>je=n)}const A4=e=>{const t=h2;return L4(e),e.scope.on(),()=>{e.scope.off(),L4(t)}},m6=()=>{h2&&h2.scope.off(),L4(null)};function t0(e){return e.vnode.shapeFlag&4}let je=!1;function Co(e,t=!1,n=!1){t&&ze(t);const{props:l,children:o}=e.vnode,r=t0(e);lo(e,l,r,t),ao(e,o,n||t);const s=r?wo(e,t):void 0;return t&&ze(!1),s}function wo(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,Ll);const{setup:l}=n;if(l){u3();const o=e.setupContext=l.length>1?_o(e):null,r=A4(e),s=d4(l,e,0,[e.props,o]),a=T7(s);if(d3(),r(),(a||e.sp)&&!re(e)&&Z8(e),a){if(s.then(m6,m6),t)return s.then(i=>{ze(!0);try{g6(e,i,t)}finally{ze(!1)}}).catch(i=>{n5(i,e,0)});e.asyncDep=s}else g6(e,s)}else n0(e)}function g6(e,t,n){I1(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:G1(t)&&(e.setupState=p8(t)),n0(e)}function n0(e,t,n){const l=e.type;e.render||(e.render=l.render||z2);{const o=A4(e);u3();try{Pl(e)}finally{d3(),o()}}}const xo={get(e,t){return f2(e,"get",""),e[t]}};function _o(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,xo),slots:e.slots,emit:e.emit,expose:t}}function i5(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(p8(dl(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Ge)return Ge[n](e)},has(t,n){return n in t||n in Ge}})):e.proxy}function Io(e,t=!0){return I1(e)?e.displayName||e.name:e.name||t&&e.__name}function Mo(e){return I1(e)&&"__vccOpts"in e}const t1=(e,t)=>ml(e,t,je);function A3(e,t,n){try{$4(-1);const l=arguments.length;return l===2?G1(t)&&!v1(t)?Je(t)?I(e,null,[t]):I(e,t):I(e,null,t):(l>3?n=Array.prototype.slice.call(arguments,2):l===3&&Je(n)&&(n=[n]),I(e,t,n))}finally{$4(1)}}const Eo="3.5.42";/** +* @vue/runtime-dom v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let rt;const v6=typeof window<"u"&&window.trustedTypes;if(v6)try{rt=v6.createPolicy("vue",{createHTML:e=>e})}catch{}const l0=rt?e=>rt.createHTML(e):e=>e,Do="http://www.w3.org/2000/svg",Zo="http://www.w3.org/1998/Math/MathML",o3=typeof document<"u"?document:null,y6=o3&&o3.createElement("template"),Fo={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,l)=>{const o=t==="svg"?o3.createElementNS(Do,e):t==="mathml"?o3.createElementNS(Zo,e):n?o3.createElement(e,{is:n}):o3.createElement(e);return e==="select"&&l&&l.multiple!=null&&o.setAttribute("multiple",l.multiple),o},createText:e=>o3.createTextNode(e),createComment:e=>o3.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>o3.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,l,o,r){const s=n?n.previousSibling:t.lastChild;if(o&&(o===r||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===r||!(o=o.nextSibling)););else{y6.innerHTML=l0(l==="svg"?`${e}`:l==="mathml"?`${e}`:e);const a=y6.content;if(l==="svg"||l==="mathml"){const i=a.firstChild;for(;i.firstChild;)a.appendChild(i.firstChild);a.removeChild(i)}t.insertBefore(a,n)}return[s?s.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},y3="transition",Ce="animation",Xe=Symbol("_vtc"),o0={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},Bo=r2({},_8,o0),So=e=>(e.displayName="Transition",e.props=Bo,e),r0=So((e,{slots:t})=>A3(Fl,Ro(e),t)),Q3=(e,t=[])=>{v1(e)?e.forEach(n=>n(...t)):e&&e(...t)},b6=e=>e?v1(e)?e.some(t=>t.length>1):e.length>1:!1;function Ro(e){const t={};for(const Y in e)Y in o0||(t[Y]=e[Y]);if(e.css===!1)return t;const{name:n="v",type:l,duration:o,enterFromClass:r=`${n}-enter-from`,enterActiveClass:s=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:i=r,appearActiveClass:c=s,appearToClass:d=a,leaveFromClass:u=`${n}-leave-from`,leaveActiveClass:A=`${n}-leave-active`,leaveToClass:m=`${n}-leave-to`}=e,p=Qo(o),y=p&&p[0],k=p&&p[1],{onBeforeEnter:F,onEnter:M,onEnterCancelled:E,onLeave:_,onLeaveCancelled:R,onBeforeAppear:$=F,onAppear:D=M,onAppearCancelled:x=E}=t,Q=(Y,m1,w1,r1)=>{Y._enterCancelled=r1,N3(Y,m1?d:a),N3(Y,m1?c:s),w1&&w1()},B=(Y,m1)=>{Y._isLeaving=!1,N3(Y,u),N3(Y,m),N3(Y,A),m1&&m1()},X=Y=>(m1,w1)=>{const r1=Y?D:M,l1=()=>Q(m1,Y,w1);Q3(r1,[m1,l1]),k6(()=>{N3(m1,Y?i:r),t3(m1,Y?d:a),b6(r1)||C6(m1,l,y,l1)})};return r2(t,{onBeforeEnter(Y){Q3(F,[Y]),t3(Y,r),t3(Y,s)},onBeforeAppear(Y){Q3($,[Y]),t3(Y,i),t3(Y,c)},onEnter:X(!1),onAppear:X(!0),onLeave(Y,m1){Y._isLeaving=!0;const w1=()=>B(Y,m1);t3(Y,u),Y._enterCancelled?(t3(Y,A),_6(Y)):(_6(Y),t3(Y,A)),k6(()=>{Y._isLeaving&&(N3(Y,u),t3(Y,m),b6(_)||C6(Y,l,k,w1))}),Q3(_,[Y,w1])},onEnterCancelled(Y){Q(Y,!1,void 0,!0),Q3(E,[Y])},onAppearCancelled(Y){Q(Y,!0,void 0,!0),Q3(x,[Y])},onLeaveCancelled(Y){B(Y),Q3(R,[Y])}})}function Qo(e){if(e==null)return null;if(G1(e))return[M5(e.enter),M5(e.leave)];{const t=M5(e);return[t,t]}}function M5(e){return Gn(e)}function t3(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Xe]||(e[Xe]=new Set)).add(t)}function N3(e,t){t.split(/\s+/).forEach(l=>l&&e.classList.remove(l));const n=e[Xe];n&&(n.delete(t),n.size||(e[Xe]=void 0))}function k6(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let No=0;function C6(e,t,n,l){const o=e._endId=++No,r=()=>{o===e._endId&&l()};if(n!=null)return setTimeout(r,n);const{type:s,timeout:a,propCount:i}=Ko(e,t);if(!s)return l();const c=s+"end";let d=0;const u=()=>{e.removeEventListener(c,A),r()},A=m=>{m.target===e&&++d>=i&&u()};setTimeout(()=>{d(n[p]||"").split(", "),o=l(`${y3}Delay`),r=l(`${y3}Duration`),s=w6(o,r),a=l(`${Ce}Delay`),i=l(`${Ce}Duration`),c=w6(a,i);let d=null,u=0,A=0;t===y3?s>0&&(d=y3,u=s,A=r.length):t===Ce?c>0&&(d=Ce,u=c,A=i.length):(u=Math.max(s,c),d=u>0?s>c?y3:Ce:null,A=d?d===y3?r.length:i.length:0);const m=d===y3&&/\b(?:transform|all)(?:,|$)/.test(l(`${y3}Property`).toString());return{type:d,timeout:u,propCount:A,hasTransform:m}}function w6(e,t){for(;e.lengthx6(n)+x6(e[l])))}function x6(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function _6(e){return(e?e.ownerDocument:document).body.offsetHeight}function Go(e,t,n){const l=e[Xe];l&&(t=(t?[t,...l]:[...l]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const P4=Symbol("_vod"),s0=Symbol("_vsh"),Oo={name:"show",beforeMount(e,{value:t},{transition:n}){e[P4]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):we(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:l}){!t!=!n&&(l?t?(l.beforeEnter(e),we(e,!0),l.enter(e)):l.leave(e,()=>{we(e,!1)}):we(e,t))},beforeUnmount(e,{value:t}){we(e,t)}};function we(e,t){e.style.display=t?e[P4]:"none",e[s0]=!t}const $o=Symbol(""),Wo=/(?:^|;)\s*display\s*:/;function Lo(e,t,n){const l=e.style,o=T1(n);let r=!1;if(n&&!o){if(t)if(T1(t))for(const s of t.split(";")){const a=s.slice(0,s.indexOf(":")).trim();n[a]==null&&Be(l,a,"")}else for(const s in t)n[s]==null&&Be(l,s,"");for(const s in n){s==="display"&&(r=!0);const a=n[s];a!=null?Ho(e,s,!T1(t)&&t?t[s]:void 0,a)||Be(l,s,a):Be(l,s,"")}}else if(o){if(t!==n){const s=l[$o];s&&(n+=";"+s),l.cssText=n,r=Wo.test(n)}}else t&&e.removeAttribute("style");P4 in e&&(e[P4]=r?l.display:"",e[s0]&&(l.display="none"))}const b4=/\s*!important$/;function Be(e,t,n){if(v1(n))n.forEach(l=>Be(e,t,l));else if(n==null&&(n=""),t.startsWith("--"))b4.test(n)?e.setProperty(t,n.replace(b4,""),"important"):e.setProperty(t,n);else{const l=Po(e,t);b4.test(n)?e.setProperty(Z3(l),n.replace(b4,""),"important"):e[l]=n}}const I6=["Webkit","Moz","ms"],E5={};function Po(e,t){const n=E5[t];if(n)return n;let l=b2(t);if(l!=="filter"&&l in e)return E5[t]=l;l=X4(l);for(let o=0;oD5||(zo.then(()=>D5=0),D5=Date.now());function Xo(e,t){const n=l=>{if(!l._vts)l._vts=Date.now();else if(l._vts<=n.attached)return;const o=n.value;if(v1(o)){const r=l.stopImmediatePropagation;l.stopImmediatePropagation=()=>{r.call(l),l._stopped=!0};const s=o.slice(),a=[l];for(let i=0;ie.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,qo=(e,t,n,l,o,r)=>{const s=o==="svg";t==="class"?Go(e,l,s):t==="style"?Lo(e,n,l):J4(t)?z4(t)||Yo(e,t,n,l,r):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):er(e,t,l,s))?(D6(e,t,l),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&E6(e,t,l,s,r,t!=="value")):e._isVueCE&&(tr(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!T1(l)))?D6(e,b2(t),l,r,t):(t==="true-value"?e._trueValue=l:t==="false-value"&&(e._falseValue=l),E6(e,t,l,s))};function er(e,t,n,l){if(l)return!!(t==="innerHTML"||t==="textContent"||t in e&&F6(t)&&I1(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const o=e.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return F6(t)&&T1(n)?!1:t in e}function tr(e,t){const n=e._def.props;if(!n)return!1;const l=b2(t);return Array.isArray(n)?n.some(o=>b2(o)===l):Object.keys(n).some(o=>b2(o)===l)}const H4=e=>{const t=e.props["onUpdate:modelValue"]||!1;return v1(t)?n=>D4(t,n):t};function nr(e){e.target.composing=!0}function B6(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const H3=Symbol("_assign"),k4=Symbol("_initialValue");function Z5(e,t,n){return t&&(e=e.trim()),n&&(e=Ct(e)),e}const S6={created(e,{modifiers:{lazy:t,trim:n,number:l}},o){e.parentNode&&(e.type==="text"?e[k4]=e.defaultValue.replace(/[\r\n]/g,""):e.type==="textarea"&&(e[k4]=e.defaultValue.replace(/\r\n?/g,` +`))),e[H3]=H4(o);const r=l||o.props&&o.props.type==="number";P3(e,t?"change":"input",s=>{s.target.composing||e[H3](Z5(e.value,n,r))}),(n||r)&&P3(e,"change",()=>{e.value=Z5(e.value,n,r)}),t||(P3(e,"compositionstart",nr),P3(e,"compositionend",B6),P3(e,"change",B6))},mounted(e,{value:t,modifiers:{trim:n,number:l}}){const o=t??"",r=e[k4];delete e[k4],r!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==r?e[H3](Z5(e.value,n,l)):e.value=o},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:l,trim:o,number:r}},s){if(e[H3]=H4(s),e.composing)return;const a=(r||e.type==="number")&&!/^0\d/.test(e.value)?Ct(e.value):e.value,i=t??"";if(a===i)return;const c=e.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===e&&e.type!=="range"&&(l&&t===n||o&&e.value.trim()===i)||(e.value=i)}},a0={deep:!0,created(e,t,n){e[H3]=H4(n),P3(e,"change",()=>{const l=e._modelValue,o=lr(e),r=e.checked,s=e[H3];if(v1(l)){const a=z7(l,o),i=a!==-1;if(r&&!i)s(l.concat(o));else if(!r&&i){const c=[...l];c.splice(a,1),s(c)}}else if(ie(l)){const a=new Set(l);r?a.add(o):a.delete(o),s(a)}else s(i0(e,r))})},mounted:R6,beforeUpdate(e,t,n){e[H3]=H4(n),R6(e,t,n)}};function R6(e,{value:t,oldValue:n},l){e._modelValue=t;let o;if(v1(t))o=z7(t,l.props.value)>-1;else if(ie(t))o=t.has(l.props.value);else{if(t===n)return;o=pe(t,i0(e,!0))}e.checked!==o&&(e.checked=o)}function lr(e){return"_value"in e?e._value:e.value}function i0(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const or=["ctrl","shift","alt","meta"],rr={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)=>or.some(n=>e[`${n}Key`]&&!t.includes(n))},qe=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),l=t.join(".");return n[l]||(n[l]=((o,...r)=>{for(let s=0;s{const n=e._withKeys||(e._withKeys={}),l=t.join(".");return n[l]||(n[l]=(o=>{if(!("key"in o))return;const r=Z3(o.key);if(t.some(s=>s===r||sr[s]===r))return e(o)}))},ir=r2({patchProp:qo},Fo);let Q6;function cr(){return Q6||(Q6=co(ir))}const ur=((...e)=>{const t=cr().createApp(...e),{mount:n}=t;return t.mount=l=>{const o=fr(l);if(!o)return;const r=t._component;!I1(r)&&!r.render&&!r.template&&(r.template=o.innerHTML),o.nodeType===1&&(o.textContent="");const s=n(o,!1,dr(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),s},t});function dr(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function fr(e){return T1(e)?document.querySelector(e):e}/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */const ne=typeof document<"u";function c0(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function Ar(e){return e.__esModule||e[Symbol.toStringTag]==="Module"||e.default&&c0(e.default)}const Q1=Object.assign;function F5(e,t){const n={};for(const l in t){const o=t[l];n[l]=$2(o)?o.map(e):e(o)}return n}const Oe=()=>{},$2=Array.isArray;function N6(e,t){const n={};for(const l in e)n[l]=l in t?t[l]:e[l];return n}const u0=/#/g,hr=/&/g,pr=/\//g,mr=/=/g,gr=/\?/g,d0=/\+/g,vr=/%5B/g,yr=/%5D/g,f0=/%5E/g,br=/%60/g,A0=/%7B/g,kr=/%7C/g,h0=/%7D/g,Cr=/%20/g;function Nt(e){return e==null?"":encodeURI(""+e).replace(kr,"|").replace(vr,"[").replace(yr,"]")}function wr(e){return Nt(e).replace(A0,"{").replace(h0,"}").replace(f0,"^")}function st(e){return Nt(e).replace(d0,"%2B").replace(Cr,"+").replace(u0,"%23").replace(hr,"%26").replace(br,"`").replace(A0,"{").replace(h0,"}").replace(f0,"^")}function xr(e){return st(e).replace(mr,"%3D")}function _r(e){return Nt(e).replace(u0,"%23").replace(gr,"%3F")}function Ir(e){return _r(e).replace(pr,"%2F")}function e4(e){if(e==null)return null;try{return decodeURIComponent(""+e)}catch{}return""+e}const Mr=/\/$/,Er=e=>e.replace(Mr,"");function B5(e,t,n="/"){let l,o={},r="",s="";const a=t.indexOf("#");let i=t.indexOf("?");return i=a>=0&&i>a?-1:i,i>=0&&(l=t.slice(0,i),r=t.slice(i,a>0?a:t.length),o=e(r.slice(1))),a>=0&&(l=l||t.slice(0,a),s=t.slice(a,t.length)),l=Br(l??t,n),{fullPath:l+r+s,path:l,query:o,hash:e4(s)}}function Dr(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function K6(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function Zr(e,t,n){const l=t.matched.length-1,o=n.matched.length-1;return l>-1&&l===o&&ue(t.matched[l],n.matched[o])&&p0(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function ue(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function p0(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!Fr(e[n],t[n]))return!1;return!0}function Fr(e,t){return $2(e)?G6(e,t):$2(t)?G6(t,e):(e==null?void 0:e.valueOf())===(t==null?void 0:t.valueOf())}function G6(e,t){return $2(t)?e.length===t.length&&e.every((n,l)=>n===t[l]):e.length===1&&e[0]===t}function Br(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),l=e.split("/"),o=l[l.length-1];(o===".."||o===".")&&l.push("");let r=n.length-1,s,a;for(s=0;s1&&r--;else break;return n.slice(0,r).join("/")+"/"+l.slice(s).join("/")}const b3={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let at=(function(e){return e.pop="pop",e.push="push",e})({}),S5=(function(e){return e.back="back",e.forward="forward",e.unknown="",e})({});function Sr(e){if(!e)if(ne){const t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return e[0]!=="/"&&e[0]!=="#"&&(e="/"+e),Er(e)}const Rr=/^[^#]+#/;function Qr(e,t){return e.replace(Rr,"#")+t}function Nr(e,t){const n=document.documentElement.getBoundingClientRect(),l=e.getBoundingClientRect();return{behavior:t.behavior,left:l.left-n.left-(t.left||0),top:l.top-n.top-(t.top||0)}}const c5=()=>({left:window.scrollX,top:window.scrollY});function Kr(e){let t;if("el"in e){const n=e.el,l=typeof n=="string"&&n.startsWith("#"),o=typeof n=="string"?l?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!o)return;t=Nr(o,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.scrollX,t.top!=null?t.top:window.scrollY)}function O6(e,t){return(history.state?history.state.position-t:-1)+e}const it=new Map;function Gr(e,t){it.set(e,t)}function Or(e){const t=it.get(e);return it.delete(e),t}function $r(e){return typeof e=="string"||e&&typeof e=="object"}function m0(e){return typeof e=="string"||typeof e=="symbol"}let X1=(function(e){return e[e.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",e[e.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",e[e.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",e[e.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",e[e.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",e})({});const g0=Symbol("");X1.MATCHER_NOT_FOUND+"",X1.NAVIGATION_GUARD_REDIRECT+"",X1.NAVIGATION_ABORTED+"",X1.NAVIGATION_CANCELLED+"",X1.NAVIGATION_DUPLICATED+"";function de(e,t){return Q1(new Error,{type:e,[g0]:!0},t)}function n3(e,t){return e instanceof Error&&g0 in e&&(t==null||!!(e.type&t))}const Wr=["params","query","hash"];function Lr(e){if(typeof e=="string")return e;if(e.path!=null)return e.path;const t={};for(const n of Wr)n in e&&(t[n]=e[n]);return JSON.stringify(t,null,2)}function Pr(e){const t={};if(e===""||e==="?")return t;const n=(e[0]==="?"?e.slice(1):e).split("&");for(let l=0;lo&&st(o)):[l&&st(l)]).forEach(o=>{o!==void 0&&(t+=(t.length?"&":"")+n,o!=null&&(t+="="+o))})}return t}function Hr(e){const t={};for(const n in e){const l=e[n];l!==void 0&&(t[n]=$2(l)?l.map(o=>o==null?null:""+o):l==null?l:""+l)}return t}const Tr=Symbol(""),W6=Symbol(""),u5=Symbol(""),Kt=Symbol(""),ct=Symbol("");function xe(){let e=[];function t(l){return e.push(l),()=>{const o=e.indexOf(l);o>-1&&e.splice(o,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function x3(e,t,n,l,o,r=s=>s()){const s=l&&(l.enterCallbacks[o]=l.enterCallbacks[o]||[]);return()=>new Promise((a,i)=>{const c=A=>{A===!1?i(de(X1.NAVIGATION_ABORTED,{from:n,to:t})):A instanceof Error?i(A):$r(A)?i(de(X1.NAVIGATION_GUARD_REDIRECT,{from:t,to:A})):(s&&l.enterCallbacks[o]===s&&typeof A=="function"&&s.push(A),a())},d=r(()=>e.call(l&&l.instances[o],t,n,c));let u=Promise.resolve(d);e.length<3&&(u=u.then(c)),u.catch(A=>i(A))})}function R5(e,t,n,l,o=r=>r()){const r=[];for(const s of e)for(const a in s.components){let i=s.components[a];if(!(t!=="beforeRouteEnter"&&!s.instances[a]))if(c0(i)){const c=(i.__vccOpts||i)[t];c&&r.push(x3(c,n,l,s,a,o))}else{let c=i();r.push(()=>c.then(d=>{if(!d)throw new Error(`Couldn't resolve component "${a}" at "${s.path}"`);const u=Ar(d)?d.default:d;s.mods[a]=d,s.components[a]=u;const A=(u.__vccOpts||u)[t];return A&&x3(A,n,l,s,a,o)()}))}}return r}function Yr(e,t){const n=[],l=[],o=[],r=Math.max(t.matched.length,e.matched.length);for(let s=0;sue(c,a))?l.push(a):n.push(a));const i=e.matched[s];i&&(t.matched.find(c=>ue(c,i))||o.push(i))}return[n,l,o]}/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */let Vr=()=>location.protocol+"//"+location.host;function v0(e,t){const{pathname:n,search:l,hash:o}=t,r=e.indexOf("#");if(r>-1){let s=o.includes(e.slice(r))?e.slice(r).length:1,a=o.slice(s);return a[0]!=="/"&&(a="/"+a),K6(a,"")}return K6(n,e)+l+o}function Ur(e,t,n,l){let o=[],r=[],s=null;const a=({state:A})=>{const m=v0(e,location),p=n.value,y=t.value;let k=0;if(A){if(n.value=m,t.value=A,s&&s===p){s=null;return}k=y?A.position-y.position:0}else l(m);o.forEach(F=>{F(n.value,p,{delta:k,type:at.pop,direction:k?k>0?S5.forward:S5.back:S5.unknown})})};function i(){s=n.value}function c(A){o.push(A);const m=()=>{const p=o.indexOf(A);p>-1&&o.splice(p,1)};return r.push(m),m}function d(){if(document.visibilityState==="hidden"){const{history:A}=window;if(!A.state)return;A.replaceState(Q1({},A.state,{scroll:c5()}),"")}}function u(){for(const A of r)A();r=[],window.removeEventListener("popstate",a),window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",d)}return window.addEventListener("popstate",a),window.addEventListener("pagehide",d),document.addEventListener("visibilitychange",d),{pauseListeners:i,listen:c,destroy:u}}function L6(e,t,n,l=!1,o=!1){return{back:e,current:t,forward:n,replaced:l,position:window.history.length,scroll:o?c5():null}}function Jr(e){const{history:t,location:n}=window,l={value:v0(e,n)},o={value:t.state};o.value||r(l.value,{back:null,current:l.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function r(i,c,d){const u=e.indexOf("#"),A=u>-1?(n.host&&document.querySelector("base")?e:e.slice(u))+i:Vr()+e+i;try{t[d?"replaceState":"pushState"](c,"",A),o.value=c}catch(m){console.error(m),n[d?"replace":"assign"](A)}}function s(i,c){r(i,Q1({},t.state,L6(o.value.back,i,o.value.forward,!0),c,{position:o.value.position}),!0),l.value=i}function a(i,c){const d=Q1({},o.value,t.state,{forward:i,scroll:c5()});r(d.current,d,!0),r(i,Q1({},L6(l.value,i,null),{position:d.position+1},c),!1),l.value=i}return{location:l,state:o,push:a,replace:s}}function zr(e){e=Sr(e);const t=Jr(e),n=Ur(e,t.state,t.location,t.replace);function l(r,s=!0){s||n.pauseListeners(),history.go(r)}const o=Q1({location:"",base:e,go:l,createHref:Qr.bind(null,e)},t,n);return Object.defineProperty(o,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(o,"state",{enumerable:!0,get:()=>t.state.value}),o}let T3=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e})({});var o2=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e})(o2||{});const jr={type:T3.Static,value:""},Xr=/[a-zA-Z0-9_]/;function qr(e){if(!e)return[[]];if(e==="/")return[[jr]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(m){throw new Error(`ERR (${n})/"${c}": ${m}`)}let n=o2.Static,l=n;const o=[];let r;function s(){r&&o.push(r),r=[]}let a=0,i,c="",d="";function u(){c&&(n===o2.Static?r.push({type:T3.Static,value:c}):n===o2.Param||n===o2.ParamRegExp||n===o2.ParamRegExpEnd?(r.length>1&&(i==="*"||i==="+")&&t(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),r.push({type:T3.Param,value:c,regexp:d,repeatable:i==="*"||i==="+",optional:i==="*"||i==="?"})):t("Invalid state to consume buffer"),c="")}function A(){c+=i}for(;at.length?t.length===1&&t[0]===v2.Static+v2.Segment?1:-1:0}function y0(e,t){let n=0;const l=e.score,o=t.score;for(;n0&&t[t.length-1]<0}const os={strict:!1,end:!0,sensitive:!1};function rs(e,t,n){const l=ns(qr(e.path),n),o=Q1(l,{record:e,parent:t,children:[],alias:[]});return t&&!o.record.aliasOf==!t.record.aliasOf&&t.children.push(o),o}function ss(e,t){const n=[],l=new Map;t=N6(os,t);function o(u){return l.get(u)}function r(u,A,m){const p=!m,y=Y6(u);y.aliasOf=m&&m.record;const k=N6(t,u),F=[y];if("alias"in u){const _=typeof u.alias=="string"?[u.alias]:u.alias;for(const R of _)F.push(Y6(Q1({},y,{components:m?m.record.components:y.components,path:R,aliasOf:m?m.record:y})))}let M,E;for(const _ of F){const{path:R}=_;if(A&&R[0]!=="/"){const $=A.record.path,D=$[$.length-1]==="/"?"":"/";_.path=A.record.path+(R&&D+R)}if(M=rs(_,A,k),m?m.alias.push(M):(E=E||M,E!==M&&E.alias.push(M),p&&u.name&&!V6(M)&&s(u.name)),b0(M)&&i(M),y.children){const $=y.children;for(let D=0;D<$.length;D++)r($[D],M,m&&m.children[D])}m=m||M}return E?()=>{s(E)}:Oe}function s(u){if(m0(u)){const A=l.get(u);A&&(l.delete(u),n.splice(n.indexOf(A),1),A.children.forEach(s),A.alias.forEach(s))}else{const A=n.indexOf(u);A>-1&&(n.splice(A,1),u.record.name&&l.delete(u.record.name),u.children.forEach(s),u.alias.forEach(s))}}function a(){return n}function i(u){const A=cs(u,n);n.splice(A,0,u),u.record.name&&!V6(u)&&l.set(u.record.name,u)}function c(u,A){let m,p={},y,k;if("name"in u&&u.name){if(m=l.get(u.name),!m)throw de(X1.MATCHER_NOT_FOUND,{location:u});k=m.record.name,p=Q1(T6(A.params,m.keys.filter(E=>!E.optional).concat(m.parent?m.parent.keys.filter(E=>E.optional):[]).map(E=>E.name)),u.params&&T6(u.params,m.keys.map(E=>E.name))),y=m.stringify(p)}else if(u.path!=null)y=u.path,m=n.find(E=>E.re.test(y)),m&&(p=m.parse(y),k=m.record.name);else{if(m=A.name?l.get(A.name):n.find(E=>E.re.test(A.path)),!m)throw de(X1.MATCHER_NOT_FOUND,{location:u,currentLocation:A});k=m.record.name,p=Q1({},A.params,u.params),y=m.stringify(p)}const F=[];let M=m;for(;M;)F.unshift(M.record),M=M.parent;return{name:k,path:y,params:p,matched:F,meta:is(F)}}e.forEach(u=>r(u));function d(){n.length=0,l.clear()}return{addRoute:r,resolve:c,removeRoute:s,clearRoutes:d,getRoutes:a,getRecordMatcher:o}}function T6(e,t){const n={};for(const l of t)l in e&&(n[l]=e[l]);return n}function Y6(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:as(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function as(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const l in e.components)t[l]=typeof n=="object"?n[l]:n;return t}function V6(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function is(e){return e.reduce((t,n)=>Q1(t,n.meta),{})}function cs(e,t){let n=0,l=t.length;for(;n!==l;){const r=n+l>>1;y0(e,t[r])<0?l=r:n=r+1}const o=us(e);return o&&(l=t.lastIndexOf(o,l-1)),l}function us(e){let t=e;for(;t=t.parent;)if(b0(t)&&y0(e,t)===0)return t}function b0({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function U6(e){const t=K2(u5),n=K2(Kt),l=t1(()=>{const i=f(e.to);return t.resolve(i)}),o=t1(()=>{const{matched:i}=l.value,{length:c}=i,d=i[c-1],u=n.matched;if(!d||!u.length)return-1;const A=u.findIndex(ue.bind(null,d));if(A>-1)return A;const m=J6(i[c-2]);return c>1&&J6(d)===m&&u[u.length-1].path!==m?u.findIndex(ue.bind(null,i[c-2])):A}),r=t1(()=>o.value>-1&&ps(n.params,l.value.params)),s=t1(()=>o.value>-1&&o.value===n.matched.length-1&&p0(n.params,l.value.params));function a(i={}){if(hs(i)){const c=t[f(e.replace)?"replace":"push"](f(e.to)).catch(Oe);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>c),c}return Promise.resolve()}return{route:l,href:t1(()=>l.value.href),isActive:r,isExactActive:s,navigate:a}}function ds(e){return e.length===1?e[0]:e}const fs=$1({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:U6,setup(e,{slots:t}){const n=t5(U6(e)),{options:l}=K2(u5),o=t1(()=>({[z6(e.activeClass,l.linkActiveClass,"router-link-active")]:n.isActive,[z6(e.exactActiveClass,l.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const r=t.default&&ds(t.default(n));return e.custom?r:A3("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:o.value},r)}}}),As=fs;function hs(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function ps(e,t){for(const n in t){const l=t[n],o=e[n];if(typeof l=="string"){if(l!==o)return!1}else if(!$2(o)||o.length!==l.length||l.some((r,s)=>r.valueOf()!==o[s].valueOf()))return!1}return!0}function J6(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const z6=(e,t,n)=>e??t??n,ms=$1({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const l=K2(ct),o=t1(()=>e.route||l.value),r=K2(W6,0),s=t1(()=>{let c=f(r);const{matched:d}=o.value;let u;for(;(u=d[c])&&!u.components;)c++;return c}),a=t1(()=>o.value.matched[s.value]);Z4(W6,t1(()=>s.value+1)),Z4(Tr,a),Z4(ct,o);const i=z();return t2(()=>[i.value,a.value,e.name],([c,d,u],[A,m,p])=>{d&&(d.instances[u]=c,m&&m!==d&&c&&c===A&&(d.leaveGuards.size||(d.leaveGuards=m.leaveGuards),d.updateGuards.size||(d.updateGuards=m.updateGuards))),c&&d&&(!m||!ue(d,m)||!A)&&(d.enterCallbacks[u]||[]).forEach(y=>y(c))},{flush:"post"}),()=>{const c=o.value,d=e.name,u=a.value,A=u&&u.components[d];if(!A)return j6(n.default,{Component:A,route:c});const m=u.props[d],p=m?m===!0?c.params:typeof m=="function"?m(c):m:null,k=A3(A,Q1({},p,t,{onVnodeUnmounted:F=>{F.component.isUnmounted&&(u.instances[d]=null)},ref:i}));return j6(n.default,{Component:k,route:c})||k}}});function j6(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const gs=ms;function vs(e){const t=ss(e.routes,e),n=e.parseQuery||Pr,l=e.stringifyQuery||$6,o=e.history,r=xe(),s=xe(),a=xe(),i=fl(b3);let c=b3;ne&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const d=F5.bind(null,S=>""+S),u=F5.bind(null,Ir),A=F5.bind(null,e4);function m(S,o1){let J,A1;return m0(S)?(J=t.getRecordMatcher(S),A1=o1):A1=S,t.addRoute(A1,J)}function p(S){const o1=t.getRecordMatcher(S);o1&&t.removeRoute(o1)}function y(){return t.getRoutes().map(S=>S.record)}function k(S){return!!t.getRecordMatcher(S)}function F(S,o1){if(o1=Q1({},o1||i.value),typeof S=="string"){const Z=B5(n,S,o1.path),L=t.resolve({path:Z.path},o1),T=o.createHref(Z.fullPath);return Q1(Z,L,{params:A(L.params),hash:e4(Z.hash),redirectedFrom:void 0,href:T})}let J;if(S.path!=null)J=Q1({},S,{path:B5(n,S.path,o1.path).path});else{const Z=Q1({},S.params);for(const L in Z)Z[L]==null&&delete Z[L];J=Q1({},S,{params:u(Z)}),o1.params=u(o1.params)}const A1=t.resolve(J,o1),x1=S.hash||"";A1.params=d(A(A1.params));const g=Dr(l,Q1({},S,{hash:wr(x1),path:A1.path})),v=o.createHref(g);return Q1({fullPath:g,hash:x1,query:l===$6?Hr(S.query):S.query||{}},A1,{redirectedFrom:void 0,href:v})}function M(S){return typeof S=="string"?B5(n,S,i.value.path):Q1({},S)}function E(S,o1){if(c!==S)return de(X1.NAVIGATION_CANCELLED,{from:o1,to:S})}function _(S){return D(S)}function R(S){return _(Q1(M(S),{replace:!0}))}function $(S,o1){const J=S.matched[S.matched.length-1];if(J&&J.redirect){const{redirect:A1}=J;let x1=typeof A1=="function"?A1(S,o1):A1;return typeof x1=="string"&&(x1=x1.includes("?")||x1.includes("#")?x1=M(x1):{path:x1},x1.params={}),Q1({query:S.query,hash:S.hash,params:x1.path!=null?{}:S.params},x1)}}function D(S,o1){const J=c=F(S),A1=i.value,x1=S.state,g=S.force,v=S.replace===!0,Z=$(J,A1);if(Z)return D(Q1(M(Z),{state:typeof Z=="object"?Q1({},x1,Z.state):x1,force:g,replace:v}),o1||J);const L=J;L.redirectedFrom=o1;let T;return!g&&Zr(l,A1,J)&&(T=de(X1.NAVIGATION_DUPLICATED,{to:L,from:A1}),L1(A1,A1,!0,!1)),(T?Promise.resolve(T):B(L,A1)).catch(W=>n3(W)?n3(W,X1.NAVIGATION_GUARD_REDIRECT)?W:c1(W):y1(W,L,A1)).then(W=>{if(W){if(n3(W,X1.NAVIGATION_GUARD_REDIRECT))return D(Q1({replace:v},M(W.to),{state:typeof W.to=="object"?Q1({},x1,W.to.state):x1,force:g}),o1||L)}else W=Y(L,A1,!0,v,x1);return X(L,A1,W),W})}function x(S,o1){const J=E(S,o1);return J?Promise.reject(J):Promise.resolve()}function Q(S){const o1=q1.values().next().value;return o1&&typeof o1.runWithContext=="function"?o1.runWithContext(S):S()}function B(S,o1){let J;const[A1,x1,g]=Yr(S,o1);J=R5(A1.reverse(),"beforeRouteLeave",S,o1);for(const Z of A1)Z.leaveGuards.forEach(L=>{J.push(x3(L,S,o1))});const v=x.bind(null,S,o1);return J.push(v),q(J).then(()=>{J=[];for(const Z of r.list())J.push(x3(Z,S,o1));return J.push(v),q(J)}).then(()=>{J=R5(x1,"beforeRouteUpdate",S,o1);for(const Z of x1)Z.updateGuards.forEach(L=>{J.push(x3(L,S,o1))});return J.push(v),q(J)}).then(()=>{J=[];for(const Z of g)if(Z.beforeEnter)if($2(Z.beforeEnter))for(const L of Z.beforeEnter)J.push(x3(L,S,o1));else J.push(x3(Z.beforeEnter,S,o1));return J.push(v),q(J)}).then(()=>(S.matched.forEach(Z=>Z.enterCallbacks={}),J=R5(g,"beforeRouteEnter",S,o1,Q),J.push(v),q(J))).then(()=>{J=[];for(const Z of s.list())J.push(x3(Z,S,o1));return J.push(v),q(J)}).catch(Z=>n3(Z,X1.NAVIGATION_CANCELLED)?Z:Promise.reject(Z))}function X(S,o1,J){a.list().forEach(A1=>Q(()=>A1(S,o1,J)))}function Y(S,o1,J,A1,x1){const g=E(S,o1);if(g)return g;const v=o1===b3,Z=ne?history.state:{};J&&(A1||v?o.replace(S.fullPath,Q1({scroll:v&&Z&&Z.scroll},x1)):o.push(S.fullPath,x1)),i.value=S,L1(S,o1,J,v),c1()}let m1;function w1(){m1||(m1=o.listen((S,o1,J)=>{if(!s1.listening)return;const A1=F(S),x1=$(A1,s1.currentRoute.value);if(x1){D(Q1(x1,{replace:!0,force:!0}),A1).catch(Oe);return}c=A1;const g=i.value;ne&&Gr(O6(g.fullPath,J.delta),c5()),B(A1,g).catch(v=>n3(v,X1.NAVIGATION_ABORTED|X1.NAVIGATION_CANCELLED)?v:n3(v,X1.NAVIGATION_GUARD_REDIRECT)?(D(Q1(M(v.to),{force:!0}),A1).then(Z=>{n3(Z,X1.NAVIGATION_ABORTED|X1.NAVIGATION_DUPLICATED)&&!J.delta&&J.type===at.pop&&o.go(-1,!1)}).catch(Oe),Promise.reject()):(J.delta&&o.go(-J.delta,!1),y1(v,A1,g))).then(v=>{v=v||Y(A1,g,!1),v&&(J.delta&&!n3(v,X1.NAVIGATION_CANCELLED)?o.go(-J.delta,!1):J.type===at.pop&&n3(v,X1.NAVIGATION_ABORTED|X1.NAVIGATION_DUPLICATED)&&o.go(-1,!1)),X(A1,g,v)}).catch(Oe)}))}let r1=xe(),l1=xe(),b1;function y1(S,o1,J){c1(S);const A1=l1.list();return A1.length?A1.forEach(x1=>x1(S,o1,J)):console.error(S),Promise.reject(S)}function k1(){return b1&&i.value!==b3?Promise.resolve():new Promise((S,o1)=>{r1.add([S,o1])})}function c1(S){return b1||(b1=!S,w1(),r1.list().forEach(([o1,J])=>S?J(S):o1()),r1.reset()),S}function L1(S,o1,J,A1){const{scrollBehavior:x1}=e;if(!ne||!x1)return Promise.resolve();const g=!J&&Or(O6(S.fullPath,0))||(A1||!J)&&history.state&&history.state.scroll||null;return g8().then(()=>x1(S,o1,g)).then(v=>v&&Kr(v)).catch(v=>y1(v,S,o1))}const S1=S=>o.go(S);let Y1;const q1=new Set,s1={currentRoute:i,listening:!0,addRoute:m,removeRoute:p,clearRoutes:t.clearRoutes,hasRoute:k,getRoutes:y,resolve:F,options:e,push:_,replace:R,go:S1,back:()=>S1(-1),forward:()=>S1(1),beforeEach:r.add,beforeResolve:s.add,afterEach:a.add,onError:l1.add,isReady:k1,install(S){S.component("RouterLink",As),S.component("RouterView",gs),S.config.globalProperties.$router=s1,Object.defineProperty(S.config.globalProperties,"$route",{enumerable:!0,get:()=>f(i)}),ne&&!Y1&&i.value===b3&&(Y1=!0,_(o.location).catch(A1=>{}));const o1={};for(const A1 in b3)Object.defineProperty(o1,A1,{get:()=>i.value[A1],enumerable:!0});S.provide(u5,s1),S.provide(Kt,A8(o1)),S.provide(ct,i);const J=S.unmount;q1.add(S),S.unmount=function(){q1.delete(S),q1.size<1&&(c=b3,m1&&m1(),m1=null,i.value=b3,Y1=!1,b1=!1),J()}}};function q(S){return S.reduce((o1,J)=>o1.then(()=>Q(J)),Promise.resolve())}return s1}function me(){return K2(u5)}function d5(e){return K2(Kt)}function k0(e){var t,n,l="";if(typeof e=="string"||typeof e=="number")l+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t{const n=new Array(e.length+t.length);for(let l=0;l({classGroupId:e,validator:t}),w0=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),T4="-",X6=[],ks="arbitrary..",Cs=e=>{const t=xs(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:l}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return ws(s);const a=s.split(T4),i=a[0]===""&&a.length>1?1:0;return x0(a,i,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const i=l[s],c=n[s];return i?c?ys(c,i):i:c||X6}return n[s]||X6}}},x0=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],r=n.nextPart.get(o);if(r){const c=x0(e,t+1,r);if(c)return c}const s=n.validators;if(s===null)return;const a=t===0?e.join(T4):e.slice(t).join(T4),i=s.length;for(let c=0;ce.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),l=t.slice(0,n);return l?ks+l:void 0})(),xs=e=>{const{theme:t,classGroups:n}=e;return _s(n,t)},_s=(e,t)=>{const n=w0();for(const l in e){const o=e[l];Gt(o,n,l,t)}return n},Gt=(e,t,n,l)=>{const o=e.length;for(let r=0;r{if(typeof e=="string"){Ms(e,t,n);return}if(typeof e=="function"){Es(e,t,n,l);return}Ds(e,t,n,l)},Ms=(e,t,n)=>{const l=e===""?t:_0(t,e);l.classGroupId=n},Es=(e,t,n,l)=>{if(Zs(e)){Gt(e(l),t,n,l);return}t.validators===null&&(t.validators=[]),t.validators.push(bs(n,e))},Ds=(e,t,n,l)=>{const o=Object.entries(e),r=o.length;for(let s=0;s{let n=e;const l=t.split(T4),o=l.length;for(let r=0;r"isThemeGetter"in e&&e.isThemeGetter===!0,Fs=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),l=Object.create(null);const o=(r,s)=>{n[r]=s,t++,t>e&&(t=0,l=n,n=Object.create(null))};return{get(r){let s=n[r];if(s!==void 0)return s;if((s=l[r])!==void 0)return o(r,s),s},set(r,s){r in n?n[r]=s:o(r,s)}}},ut="!",q6=":",Bs=[],e7=(e,t,n,l,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:l,isExternal:o}),Ss=e=>{const{prefix:t,experimentalParseClassName:n}=e;let l=o=>{const r=[];let s=0,a=0,i=0,c;const d=o.length;for(let y=0;yi?c-i:void 0;return e7(r,m,A,p)};if(t){const o=t+q6,r=l;l=s=>s.startsWith(o)?r(s.slice(o.length)):e7(Bs,!1,s,void 0,!0)}if(n){const o=l;l=r=>n({className:r,parseClassName:o})}return l},Rs=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,l)=>{t.set(n,1e6+l)}),n=>{const l=[];let o=[];for(let r=0;r0&&(o.sort(),l.push(...o),o=[]),l.push(s)):o.push(s)}return o.length>0&&(o.sort(),l.push(...o)),l}},Qs=e=>({cache:Fs(e.cacheSize),parseClassName:Ss(e),sortModifiers:Rs(e),postfixLookupClassGroupIds:Ns(e),...Cs(e)}),Ns=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let l=0;l{const{parseClassName:n,getClassGroupId:l,getConflictingClassGroupIds:o,sortModifiers:r,postfixLookupClassGroupIds:s}=t,a=[],i=e.trim().split(Ks);let c="";for(let d=i.length-1;d>=0;d-=1){const u=i[d],{isExternal:A,modifiers:m,hasImportantModifier:p,baseClassName:y,maybePostfixModifierPosition:k}=n(u);if(A){c=u+(c.length>0?" "+c:c);continue}let F=!!k,M;if(F){const D=y.substring(0,k);M=l(D);const x=M&&s[M]?l(y):void 0;x&&x!==M&&(M=x,F=!1)}else M=l(y);if(!M){if(!F){c=u+(c.length>0?" "+c:c);continue}if(M=l(y),!M){c=u+(c.length>0?" "+c:c);continue}F=!1}const E=m.length===0?"":m.length===1?m[0]:r(m).join(":"),_=p?E+ut:E,R=_+M;if(a.indexOf(R)>-1)continue;a.push(R);const $=o(M,F);for(let D=0;D<$.length;++D){const x=$[D];a.push(_+x)}c=u+(c.length>0?" "+c:c)}return c},Os=(...e)=>{let t=0,n,l,o="";for(;t{if(typeof e=="string")return e;let t,n="";for(let l=0;l{let n,l,o,r;const s=i=>{const c=t.reduce((d,u)=>u(d),e());return n=Qs(c),l=n.cache.get,o=n.cache.set,r=a,a(i)},a=i=>{const c=l(i);if(c)return c;const d=Gs(i,n);return o(i,d),d};return r=s,(...i)=>r(Os(...i))},Ws=[],l2=e=>{const t=n=>n[e]||Ws;return t.isThemeGetter=!0,t},M0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,E0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ls=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ps=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hs=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ts=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ys=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vs=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,k3=e=>Ls.test(e),Z1=e=>!!e&&!Number.isNaN(Number(e)),L2=e=>!!e&&Number.isInteger(Number(e)),Q5=e=>e.endsWith("%")&&Z1(e.slice(0,-1)),l3=e=>Ps.test(e),D0=()=>!0,Us=e=>Hs.test(e)&&!Ts.test(e),Ot=()=>!1,Js=e=>Ys.test(e),zs=e=>Vs.test(e),js=e=>!u1(e)&&!d1(e),Xs=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),qs=e=>F3(e,B0,Ot),u1=e=>M0.test(e),K3=e=>F3(e,S0,Us),t7=e=>F3(e,aa,Z1),ea=e=>F3(e,Q0,D0),ta=e=>F3(e,R0,Ot),n7=e=>F3(e,Z0,Ot),na=e=>F3(e,F0,zs),C4=e=>F3(e,N0,Js),d1=e=>E0.test(e),_e=e=>j3(e,S0),la=e=>j3(e,R0),l7=e=>j3(e,Z0),oa=e=>j3(e,B0),ra=e=>j3(e,F0),w4=e=>j3(e,N0,!0),sa=e=>j3(e,Q0,!0),F3=(e,t,n)=>{const l=M0.exec(e);return l?l[1]?t(l[1]):n(l[2]):!1},j3=(e,t,n=!1)=>{const l=E0.exec(e);return l?l[1]?t(l[1]):n:!1},Z0=e=>e==="position"||e==="percentage",F0=e=>e==="image"||e==="url",B0=e=>e==="length"||e==="size"||e==="bg-size",S0=e=>e==="length",aa=e=>e==="number",R0=e=>e==="family-name",Q0=e=>e==="number"||e==="weight",N0=e=>e==="shadow",ia=()=>{const e=l2("color"),t=l2("font"),n=l2("text"),l=l2("font-weight"),o=l2("tracking"),r=l2("leading"),s=l2("breakpoint"),a=l2("container"),i=l2("spacing"),c=l2("radius"),d=l2("shadow"),u=l2("inset-shadow"),A=l2("text-shadow"),m=l2("drop-shadow"),p=l2("blur"),y=l2("perspective"),k=l2("aspect"),F=l2("ease"),M=l2("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[..._(),d1,u1],$=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],x=()=>[d1,u1,i],Q=()=>[k3,"full","auto",...x()],B=()=>[L2,"none","subgrid",d1,u1],X=()=>["auto",{span:["full",L2,d1,u1]},L2,d1,u1],Y=()=>[L2,"auto",d1,u1],m1=()=>["auto","min","max","fr",d1,u1],w1=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],r1=()=>["start","end","center","stretch","center-safe","end-safe"],l1=()=>["auto",...x()],b1=()=>[k3,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],y1=()=>[k3,"screen","full","dvw","lvw","svw","min","max","fit",...x()],k1=()=>[k3,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],c1=()=>[e,d1,u1],L1=()=>[..._(),l7,n7,{position:[d1,u1]}],S1=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Y1=()=>["auto","cover","contain",oa,qs,{size:[d1,u1]}],q1=()=>[Q5,_e,K3],s1=()=>["","none","full",c,d1,u1],q=()=>["",Z1,_e,K3],S=()=>["solid","dashed","dotted","double"],o1=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],J=()=>[Z1,Q5,l7,n7],A1=()=>["","none",p,d1,u1],x1=()=>["none",Z1,d1,u1],g=()=>["none",Z1,d1,u1],v=()=>[Z1,d1,u1],Z=()=>[k3,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[l3],breakpoint:[l3],color:[D0],container:[l3],"drop-shadow":[l3],ease:["in","out","in-out"],font:[js],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[l3],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[l3],shadow:[l3],spacing:["px",Z1],text:[l3],"text-shadow":[l3],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",k3,u1,d1,k]}],container:["container"],"container-type":[{"@container":["","normal","size",d1,u1]}],"container-named":[Xs],columns:[{columns:[Z1,u1,d1,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:$()}],"overflow-x":[{"overflow-x":$()}],"overflow-y":[{"overflow-y":$()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Q()}],"inset-x":[{"inset-x":Q()}],"inset-y":[{"inset-y":Q()}],start:[{"inset-s":Q(),start:Q()}],end:[{"inset-e":Q(),end:Q()}],"inset-bs":[{"inset-bs":Q()}],"inset-be":[{"inset-be":Q()}],top:[{top:Q()}],right:[{right:Q()}],bottom:[{bottom:Q()}],left:[{left:Q()}],visibility:["visible","invisible","collapse"],z:[{z:[L2,"auto",d1,u1]}],basis:[{basis:[k3,"full","auto",a,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Z1,k3,"auto","initial","none",u1]}],grow:[{grow:["",Z1,d1,u1]}],shrink:[{shrink:["",Z1,d1,u1]}],order:[{order:[L2,"first","last","none",d1,u1]}],"grid-cols":[{"grid-cols":B()}],"col-start-end":[{col:X()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":B()}],"row-start-end":[{row:X()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":m1()}],"auto-rows":[{"auto-rows":m1()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...w1(),"normal"]}],"justify-items":[{"justify-items":[...r1(),"normal"]}],"justify-self":[{"justify-self":["auto",...r1()]}],"align-content":[{content:["normal",...w1()]}],"align-items":[{items:[...r1(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...r1(),{baseline:["","last"]}]}],"place-content":[{"place-content":w1()}],"place-items":[{"place-items":[...r1(),"baseline"]}],"place-self":[{"place-self":["auto",...r1()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:l1()}],mx:[{mx:l1()}],my:[{my:l1()}],ms:[{ms:l1()}],me:[{me:l1()}],mbs:[{mbs:l1()}],mbe:[{mbe:l1()}],mt:[{mt:l1()}],mr:[{mr:l1()}],mb:[{mb:l1()}],ml:[{ml:l1()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:b1()}],"inline-size":[{inline:["auto",...y1()]}],"min-inline-size":[{"min-inline":["auto",...y1()]}],"max-inline-size":[{"max-inline":["none",...y1()]}],"block-size":[{block:["auto",...k1()]}],"min-block-size":[{"min-block":["auto",...k1()]}],"max-block-size":[{"max-block":["none",...k1()]}],w:[{w:[a,"screen",...b1()]}],"min-w":[{"min-w":[a,"screen","none",...b1()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...b1()]}],h:[{h:["screen","lh",...b1()]}],"min-h":[{"min-h":["screen","lh","none",...b1()]}],"max-h":[{"max-h":["screen","lh",...b1()]}],"font-size":[{text:["base",n,_e,K3]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,sa,ea]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Q5,u1]}],"font-family":[{font:[la,ta,t]}],"font-features":[{"font-features":[u1]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,d1,u1]}],"line-clamp":[{"line-clamp":[Z1,"none",d1,t7]}],leading:[{leading:[r,...x()]}],"list-image":[{"list-image":["none",d1,u1]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",d1,u1]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:c1()}],"text-color":[{text:c1()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...S(),"wavy"]}],"text-decoration-thickness":[{decoration:[Z1,"from-font","auto",d1,K3]}],"text-decoration-color":[{decoration:c1()}],"underline-offset":[{"underline-offset":[Z1,"auto",d1,u1]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[L2,d1,u1]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",d1,u1]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",d1,u1]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:L1()}],"bg-repeat":[{bg:S1()}],"bg-size":[{bg:Y1()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},L2,d1,u1],radial:["",d1,u1],conic:[L2,d1,u1]},ra,na]}],"bg-color":[{bg:c1()}],"gradient-from-pos":[{from:q1()}],"gradient-via-pos":[{via:q1()}],"gradient-to-pos":[{to:q1()}],"gradient-from":[{from:c1()}],"gradient-via":[{via:c1()}],"gradient-to":[{to:c1()}],rounded:[{rounded:s1()}],"rounded-s":[{"rounded-s":s1()}],"rounded-e":[{"rounded-e":s1()}],"rounded-t":[{"rounded-t":s1()}],"rounded-r":[{"rounded-r":s1()}],"rounded-b":[{"rounded-b":s1()}],"rounded-l":[{"rounded-l":s1()}],"rounded-ss":[{"rounded-ss":s1()}],"rounded-se":[{"rounded-se":s1()}],"rounded-ee":[{"rounded-ee":s1()}],"rounded-es":[{"rounded-es":s1()}],"rounded-tl":[{"rounded-tl":s1()}],"rounded-tr":[{"rounded-tr":s1()}],"rounded-br":[{"rounded-br":s1()}],"rounded-bl":[{"rounded-bl":s1()}],"border-w":[{border:q()}],"border-w-x":[{"border-x":q()}],"border-w-y":[{"border-y":q()}],"border-w-s":[{"border-s":q()}],"border-w-e":[{"border-e":q()}],"border-w-bs":[{"border-bs":q()}],"border-w-be":[{"border-be":q()}],"border-w-t":[{"border-t":q()}],"border-w-r":[{"border-r":q()}],"border-w-b":[{"border-b":q()}],"border-w-l":[{"border-l":q()}],"divide-x":[{"divide-x":q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...S(),"hidden","none"]}],"divide-style":[{divide:[...S(),"hidden","none"]}],"border-color":[{border:c1()}],"border-color-x":[{"border-x":c1()}],"border-color-y":[{"border-y":c1()}],"border-color-s":[{"border-s":c1()}],"border-color-e":[{"border-e":c1()}],"border-color-bs":[{"border-bs":c1()}],"border-color-be":[{"border-be":c1()}],"border-color-t":[{"border-t":c1()}],"border-color-r":[{"border-r":c1()}],"border-color-b":[{"border-b":c1()}],"border-color-l":[{"border-l":c1()}],"divide-color":[{divide:c1()}],"outline-style":[{outline:[...S(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Z1,d1,u1]}],"outline-w":[{outline:["",Z1,_e,K3]}],"outline-color":[{outline:c1()}],shadow:[{shadow:["","none",d,w4,C4]}],"shadow-color":[{shadow:c1()}],"inset-shadow":[{"inset-shadow":["none",u,w4,C4]}],"inset-shadow-color":[{"inset-shadow":c1()}],"ring-w":[{ring:q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:c1()}],"ring-offset-w":[{"ring-offset":[Z1,K3]}],"ring-offset-color":[{"ring-offset":c1()}],"inset-ring-w":[{"inset-ring":q()}],"inset-ring-color":[{"inset-ring":c1()}],"text-shadow":[{"text-shadow":["none",A,w4,C4]}],"text-shadow-color":[{"text-shadow":c1()}],opacity:[{opacity:[Z1,d1,u1]}],"mix-blend":[{"mix-blend":[...o1(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":o1()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Z1]}],"mask-image-linear-from-pos":[{"mask-linear-from":J()}],"mask-image-linear-to-pos":[{"mask-linear-to":J()}],"mask-image-linear-from-color":[{"mask-linear-from":c1()}],"mask-image-linear-to-color":[{"mask-linear-to":c1()}],"mask-image-t-from-pos":[{"mask-t-from":J()}],"mask-image-t-to-pos":[{"mask-t-to":J()}],"mask-image-t-from-color":[{"mask-t-from":c1()}],"mask-image-t-to-color":[{"mask-t-to":c1()}],"mask-image-r-from-pos":[{"mask-r-from":J()}],"mask-image-r-to-pos":[{"mask-r-to":J()}],"mask-image-r-from-color":[{"mask-r-from":c1()}],"mask-image-r-to-color":[{"mask-r-to":c1()}],"mask-image-b-from-pos":[{"mask-b-from":J()}],"mask-image-b-to-pos":[{"mask-b-to":J()}],"mask-image-b-from-color":[{"mask-b-from":c1()}],"mask-image-b-to-color":[{"mask-b-to":c1()}],"mask-image-l-from-pos":[{"mask-l-from":J()}],"mask-image-l-to-pos":[{"mask-l-to":J()}],"mask-image-l-from-color":[{"mask-l-from":c1()}],"mask-image-l-to-color":[{"mask-l-to":c1()}],"mask-image-x-from-pos":[{"mask-x-from":J()}],"mask-image-x-to-pos":[{"mask-x-to":J()}],"mask-image-x-from-color":[{"mask-x-from":c1()}],"mask-image-x-to-color":[{"mask-x-to":c1()}],"mask-image-y-from-pos":[{"mask-y-from":J()}],"mask-image-y-to-pos":[{"mask-y-to":J()}],"mask-image-y-from-color":[{"mask-y-from":c1()}],"mask-image-y-to-color":[{"mask-y-to":c1()}],"mask-image-radial":[{"mask-radial":[d1,u1]}],"mask-image-radial-from-pos":[{"mask-radial-from":J()}],"mask-image-radial-to-pos":[{"mask-radial-to":J()}],"mask-image-radial-from-color":[{"mask-radial-from":c1()}],"mask-image-radial-to-color":[{"mask-radial-to":c1()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[Z1]}],"mask-image-conic-from-pos":[{"mask-conic-from":J()}],"mask-image-conic-to-pos":[{"mask-conic-to":J()}],"mask-image-conic-from-color":[{"mask-conic-from":c1()}],"mask-image-conic-to-color":[{"mask-conic-to":c1()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:L1()}],"mask-repeat":[{mask:S1()}],"mask-size":[{mask:Y1()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",d1,u1]}],filter:[{filter:["","none",d1,u1]}],blur:[{blur:A1()}],brightness:[{brightness:[Z1,d1,u1]}],contrast:[{contrast:[Z1,d1,u1]}],"drop-shadow":[{"drop-shadow":["","none",m,w4,C4]}],"drop-shadow-color":[{"drop-shadow":c1()}],grayscale:[{grayscale:["",Z1,d1,u1]}],"hue-rotate":[{"hue-rotate":[Z1,d1,u1]}],invert:[{invert:["",Z1,d1,u1]}],saturate:[{saturate:[Z1,d1,u1]}],sepia:[{sepia:["",Z1,d1,u1]}],"backdrop-filter":[{"backdrop-filter":["","none",d1,u1]}],"backdrop-blur":[{"backdrop-blur":A1()}],"backdrop-brightness":[{"backdrop-brightness":[Z1,d1,u1]}],"backdrop-contrast":[{"backdrop-contrast":[Z1,d1,u1]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Z1,d1,u1]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Z1,d1,u1]}],"backdrop-invert":[{"backdrop-invert":["",Z1,d1,u1]}],"backdrop-opacity":[{"backdrop-opacity":[Z1,d1,u1]}],"backdrop-saturate":[{"backdrop-saturate":[Z1,d1,u1]}],"backdrop-sepia":[{"backdrop-sepia":["",Z1,d1,u1]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",d1,u1]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Z1,"initial",d1,u1]}],ease:[{ease:["linear","initial",F,d1,u1]}],delay:[{delay:[Z1,d1,u1]}],animate:[{animate:["none",M,d1,u1]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[y,d1,u1]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:x1()}],"rotate-x":[{"rotate-x":x1()}],"rotate-y":[{"rotate-y":x1()}],"rotate-z":[{"rotate-z":x1()}],scale:[{scale:g()}],"scale-x":[{"scale-x":g()}],"scale-y":[{"scale-y":g()}],"scale-z":[{"scale-z":g()}],"scale-3d":["scale-3d"],skew:[{skew:v()}],"skew-x":[{"skew-x":v()}],"skew-y":[{"skew-y":v()}],transform:[{transform:[d1,u1,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Z()}],"translate-x":[{"translate-x":Z()}],"translate-y":[{"translate-y":Z()}],"translate-z":[{"translate-z":Z()}],"translate-none":["translate-none"],zoom:[{zoom:[L2,d1,u1]}],accent:[{accent:c1()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:c1()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",d1,u1]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":c1()}],"scrollbar-track-color":[{"scrollbar-track":c1()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",d1,u1]}],fill:[{fill:["none",...c1()]}],"stroke-w":[{stroke:[Z1,_e,K3,t7]}],stroke:[{stroke:["none",...c1()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ca=$s(ia);function E1(...e){return ca(C0(e))}const ua=["src","alt"],da={key:1,class:"flex h-full w-full items-center justify-center bg-muted font-medium text-muted-foreground"},fa=$1({__name:"Avatar",props:{src:{},alt:{},fallback:{default:"?"},size:{default:"md"},class:{}},setup(e){const t=e,n={sm:"h-8 w-8 text-xs",md:"h-10 w-10 text-sm",lg:"h-12 w-12 text-base"},l=z(!1),o=t1(()=>!t.src||l.value);return(r,s)=>(h(),C("div",{class:f1(f(E1)("relative flex shrink-0 overflow-hidden rounded-full",n[e.size],t.class))},[o.value?(h(),C("div",da,N(e.fallback),1)):(h(),C("img",{key:0,src:e.src??void 0,alt:e.alt,class:"aspect-square h-full w-full object-cover",onError:s[0]||(s[0]=a=>l.value=!0)},null,40,ua))],2))}}),o7=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,r7=C0,f5=(e,t)=>n=>{var l;if((t==null?void 0:t.variants)==null)return r7(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:r}=t,s=Object.keys(o).map(c=>{const d=n==null?void 0:n[c],u=r==null?void 0:r[c];if(d===null)return null;const A=o7(d)||o7(u);return o[c][A]}),a=n&&Object.entries(n).reduce((c,d)=>{let[u,A]=d;return A===void 0||(c[u]=A),c},{}),i=t==null||(l=t.compoundVariants)===null||l===void 0?void 0:l.reduce((c,d)=>{let{class:u,className:A,...m}=d;return Object.entries(m).every(p=>{let[y,k]=p;return Array.isArray(k)?k.includes({...r,...a}[y]):{...r,...a}[y]===k})?[...c,u,A]:c},[]);return r7(e,s,i,n==null?void 0:n.class,n==null?void 0:n.className)},c2=$1({__name:"Badge",props:{variant:{default:"default"},class:{}},setup(e){const t=f5("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground",success:"border-transparent bg-success/20 text-success",warning:"border-transparent bg-warning/20 text-warning",glow:"border-primary/30 bg-primary/10 text-primary"}},defaultVariants:{variant:"default"}}),n=e;return(l,o)=>(h(),C("div",{class:f1(f(E1)(f(t)({variant:e.variant}),n.class))},[K1(l.$slots,"default")],2))}}),C1=$1({__name:"Button",props:{variant:{default:"default"},size:{default:"default"},as:{default:"button"},class:{},disabled:{type:Boolean}},setup(e){const t=f5("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",glow:"bg-primary text-primary-foreground shadow-lg hover:bg-primary/90 glow-sm hover:glow"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-11 rounded-md px-8",xl:"h-12 rounded-lg px-10 text-base",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),n=e;return(l,o)=>(h(),G(k2(e.as),{class:f1(f(E1)(f(t)({variant:e.variant,size:e.size}),n.class)),disabled:e.disabled},{default:w(()=>[K1(l.$slots,"default")]),_:3},8,["class","disabled"]))}}),z1=$1({__name:"Card",props:{class:{},hover:{type:Boolean,default:!1},glow:{type:Boolean,default:!1}},setup(e){const t=e;return(n,l)=>(h(),C("div",{class:f1(f(E1)("rounded-lg border bg-card text-card-foreground shadow-sm",e.hover&&"transition-all duration-200 hover:border-primary/50 hover:-translate-y-1",e.glow&&"glow-sm",t.class))},[K1(n.$slots,"default")],2))}}),Aa="modulepreload",ha=function(e){return"/"+e},s7={},x4=function(t,n,l){let o=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),i=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));o=s(n.map(c=>{if(c=ha(c),c in s7)return;s7[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const A=document.createElement("link");if(A.rel=d?"stylesheet":Aa,d||(A.as="script"),A.crossOrigin="",A.href=c,i&&A.setAttribute("nonce",i),document.head.appendChild(A),d)return new Promise((m,p)=>{A.addEventListener("load",m),A.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})},a7={decision:"bg-blue-600/10 text-blue-600 border-blue-600/20",constraint:"bg-amber-600/10 text-amber-600 border-amber-600/20",workaround:"bg-red-600/10 text-red-600 border-red-600/20",convention:"bg-violet-600/10 text-violet-600 border-violet-600/20",pattern:"bg-emerald-600/10 text-emerald-600 border-emerald-600/20",discussion:"bg-cyan-600/10 text-cyan-600 border-cyan-600/20",review:"bg-pink-600/10 text-pink-600 border-pink-600/20",plan:"bg-lime-600/10 text-lime-600 border-lime-600/20"},pa={decision:"bg-blue-600",constraint:"bg-amber-600",workaround:"bg-red-600",convention:"bg-violet-600",pattern:"bg-emerald-600",discussion:"bg-cyan-600",review:"bg-pink-600",plan:"bg-lime-600"},N5={system:"#7c3aed",part:"#d97706",contract:"#0891b2",decision:"#2563eb",constraint:"#d97706",workaround:"#dc2626",convention:"#7c3aed",pattern:"#059669",discussion:"#0891b2",review:"#db2777",plan:"#65a30d"};function K0(){const e="bg-muted text-muted-foreground border-border";function t(r){return a7[(r??"").toLowerCase()]??e}function n(r){return pa[(r??"").toLowerCase()]??"bg-muted-foreground"}function l(r){return N5[(r??"").toLowerCase()]??"#a1a1aa"}const o=Object.keys(N5).map(r=>({kind:r,label:r.charAt(0).toUpperCase()+r.slice(1),color:N5[r]}));return{tone:t,fill:n,ink:l,legend:o,kinds:Object.keys(a7)}}const _4="#6b7280",ma=$1({__name:"CodeGraph",props:{height:{default:"460px"},repo:{default:""},mode:{default:"2d"},data:{default:null},hidden:{default:()=>[]}},emits:["select"],setup(e,{expose:t,emit:n}){const l=n,o=e,r=Q=>[typeof Q.source=="object"?Q.source:null,typeof Q.target=="object"?Q.target:null],s=Q=>{const[B,X]=r(Q);return B&&X&&B.community===X.community&&B.community!==null?B:null},a=z(null);let i=null,c=null,d=null;const u=new Map,{ink:A}=K0(),m=["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"];function p(Q){if(typeof Q.community=="number")return m[Q.community%m.length];const B=(Q.kind||"").toLowerCase();return B==="code"?"#E20C18":B==="file"||["class","function","method","module","route","variable","symbol"].includes(B)?_4:A(B)}function y(Q){return Q&&Q.length>28?`${Q.slice(0,27)}…`:Q}const k=t1(()=>!!o.data&&o.data.nodes.length>0);t({hasGraph:k});const F=t1(()=>new Set(o.hidden));function M(){const Q=o.data??{nodes:[],links:[]},B=Q.nodes.filter(r1=>typeof r1.community!="number"||!F.value.has(r1.community)),X=new Set(B.map(r1=>r1.id)),Y=Math.max(1,...B.map(r1=>r1.degree??0)),m1=B.map(r1=>{const l1=u.get(r1.id);return{...r1,...l1??{},color:p(r1),radius:Math.min(3+2.4*Math.sqrt(r1.degree??0),11),named:(r1.degree??0)>=Math.max(4,Y*.5)}}),w1=Q.links.filter(r1=>X.has(String(r1.source))&&X.has(String(r1.target))).map(r1=>({...r1}));return{nodes:m1,links:w1}}function E(Q){return Math.max(.06,Math.min(.5,Math.sqrt(400/Math.max(1,Q))))}function _(Q,B){const X=parseInt(Q.slice(1),16),Y=Math.max(0,Math.min(1,B)).toFixed(3);return`rgba(${X>>16&255}, ${X>>8&255}, ${X&255}, ${Y})`}const R=Q=>Q==="tree"?"td":Q==="radial"?"radialout":Q==="layered"?"zout":null;function $(){if(i)for(const Q of i.graphData().nodes)Number.isFinite(Q.x)&&u.set(Q.id,{x:Q.x,y:Q.y,z:Q.z??0})}function D(){var Q;$(),i&&((Q=i._destructor)==null||Q.call(i),i=null),a.value&&(a.value.innerHTML="")}async function x(Q){var w1,r1;if(!a.value)return;const B=Q==="2d"?"2d":"3d";if(i&&c===B){B==="3d"&&i.dagMode(R(Q)),$(),i.graphData(M());return}if(D(),c=B,B==="2d"){const l1=(await x4(async()=>{const{default:s1}=await import("./force-graph-HZtkkbK0.js");return{default:s1}},__vite__mapDeps([0,1,2]))).default,{forceCollide:b1,forceManyBody:y1,forceX:k1,forceY:c1}=await x4(async()=>{const{forceCollide:s1,forceManyBody:q,forceX:S,forceY:o1}=await import("./index-DHVCIEzJ.js");return{forceCollide:s1,forceManyBody:q,forceX:S,forceY:o1}},__vite__mapDeps([3,1])),L1=M(),S1=E(L1.links.length);let Y1=null;i=new l1(a.value),i.backgroundColor("rgba(0,0,0,0)").graphData(L1).nodeRelSize(4).nodeColor(s1=>s1.color).nodeLabel(s1=>s1.path?`${s1.name} — ${s1.path}`:s1.name).nodeCanvasObject((s1,q,S)=>{const o1=!Y1||Y1===s1.id;if(q.globalAlpha=o1?1:.25,q.beginPath(),q.arc(s1.x,s1.y,s1.radius,0,2*Math.PI),q.fillStyle=s1.color,q.fill(),!s1.named&&Y1!==s1.id){q.globalAlpha=1;return}const J=Math.max(11/S,1.5);q.font=`${J}px ui-sans-serif, system-ui, sans-serif`,q.fillStyle=s1.color,q.textAlign="left",q.textBaseline="middle",q.fillText(y(s1.name),s1.x+s1.radius+2/S,s1.y),q.globalAlpha=1}).nodePointerAreaPaint((s1,q,S)=>{S.fillStyle=q,S.beginPath(),S.arc(s1.x,s1.y,s1.radius+2,0,2*Math.PI),S.fill()}).linkColor(s1=>{const q=s(s1);return _(q?q.color:_4,S1*(q?1.6:1))}).linkWidth(.6).linkDirectionalArrowLength(2.5).linkDirectionalArrowRelPos(1).linkLabel(s1=>s1.type??"").onNodeHover(s1=>{var q;Y1=s1?s1.id:null,a.value&&(a.value.style.cursor=s1?"pointer":""),(q=i==null?void 0:i.refresh)==null||q.call(i)}).width(a.value.clientWidth).height(a.value.clientHeight).onNodeClick(s1=>l("select",String(s1.id))),i.d3AlphaDecay(.02).d3VelocityDecay(.35).cooldownTicks(220),i.d3Force("charge",y1().strength(-140).distanceMax(420)),i.d3Force("center",null),i.d3Force("x",k1(0).strength(.03)),i.d3Force("y",c1(0).strength(.03)),i.d3Force("collide",b1(s1=>s1.radius+2).iterations(2)),(w1=i.d3Force("link"))==null||w1.distance(s1=>s(s1)?26:70).strength(s1=>s(s1)?.7:.08);let q1=!1;i.onEngineTick(()=>{!q1&&i.d3Force("link")&&(q1=!0,setTimeout(()=>i==null?void 0:i.zoomToFit(600,60),700))}),i.onEngineStop(()=>{$(),i==null||i.zoomToFit(600,60)});return}const X=(await x4(async()=>{const{default:l1}=await import("./3d-force-graph-B8lgMx4q.js");return{default:l1}},__vite__mapDeps([4,5,2,1]))).default,Y=await x4(()=>import("./three.module-D-PgY1-x.js").then(l1=>l1.df),[]),m1=M();i=new X(a.value),i.backgroundColor("rgba(0,0,0,0)").showNavInfo(!1).onDagError(()=>{}).dagLevelDistance(46).dagMode(R(Q)).graphData(m1).nodeLabel(l1=>l1.path?`${l1.name} — ${l1.path}`:l1.name).nodeThreeObject(l1=>{const b1=new Y.SphereGeometry(l1.radius,12,10),y1=new Y.MeshLambertMaterial({color:l1.color,transparent:!0,opacity:.92});return new Y.Mesh(b1,y1)}).linkColor(()=>_4).linkOpacity(E(m1.links.length)).linkWidth(.5).linkDirectionalArrowLength(2).linkDirectionalArrowRelPos(1).linkLabel(l1=>l1.type??"").width(a.value.clientWidth).height(a.value.clientHeight).onNodeClick(l1=>l("select",String(l1.id))),(r1=i.d3Force("charge"))==null||r1.strength(-140).distanceMax(420),i.onEngineStop(()=>{$(),i==null||i.zoomToFit(600,60)})}return d2(async()=>{await x(o.mode),d=new ResizeObserver(()=>{i&&a.value&&i.width(a.value.clientWidth).height(a.value.clientHeight)}),a.value&&d.observe(a.value)}),t2(()=>o.mode,Q=>x(Q)),t2(()=>o.repo,()=>{u.clear(),x(o.mode)}),t2(()=>o.data,()=>x(o.mode)),t2(()=>o.hidden,()=>x(o.mode),{deep:!0}),Ft(()=>{d&&(d.disconnect(),d=null),D()}),(Q,B)=>(h(),C("div",{ref_key:"el",ref:a,style:S2({height:o.height}),class:"w-full"},null,4))}}),ga=["for"],va={key:1,class:"mt-1 text-xs text-destructive"},ya={key:2,class:"mt-1 text-xs text-muted-foreground"},R2=$1({__name:"Field",props:{label:{},hint:{},error:{},for:{},class:{}},setup(e){const t=e;return(n,l)=>(h(),C("div",{class:f1(f(E1)("w-full",t.class))},[e.label?(h(),C("label",{key:0,for:t.for,class:"mb-1.5 flex items-center gap-2 text-xs font-medium uppercase tracking-wider text-muted-foreground"},[U(N(e.label)+" ",1),K1(n.$slots,"label")],8,ga)):P("",!0),K1(n.$slots,"default"),e.error?(h(),C("p",va,N(e.error),1)):e.hint?(h(),C("p",ya,N(e.hint),1)):P("",!0)],2))}}),G0=f5(["w-full rounded-md border bg-muted/50 text-foreground outline-none transition-colors","placeholder:text-muted-foreground focus:border-primary/50","disabled:cursor-not-allowed disabled:opacity-50"].join(" "),{variants:{size:{sm:"h-8 px-3 text-xs",default:"h-9 px-3 text-sm",lg:"h-11 px-4 text-base"},invalid:{true:"border-destructive/60 focus:border-destructive",false:""}},defaultVariants:{size:"default",invalid:!1}}),ba=f5(["w-full resize-y rounded-md border bg-muted/50 text-foreground outline-none transition-colors","placeholder:text-muted-foreground focus:border-primary/50","disabled:cursor-not-allowed disabled:opacity-50"].join(" "),{variants:{size:{sm:"px-3 py-1.5 text-xs",default:"px-3 py-2 text-sm",lg:"px-4 py-2.5 text-base"},invalid:{true:"border-destructive/60 focus:border-destructive",false:""}},defaultVariants:{size:"default",invalid:!1}}),ka=["value"],J3=$1({__name:"Input",props:{modelValue:{},size:{default:"default"},class:{},invalid:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e){const t=e;return(n,l)=>(h(),C("input",{value:e.modelValue,class:f1(f(E1)(f(G0)({size:e.size,invalid:e.invalid}),t.class)),onInput:l[0]||(l[0]=o=>n.$emit("update:modelValue",o.target.value))},null,42,ka))}}),Ca={class:"flex items-start gap-4"},wa={class:"min-w-0 flex-1"},xa={class:"mb-1 flex flex-wrap items-center gap-2"},_a={class:"break-all font-semibold"},Ia={key:0,class:"break-all font-mono text-sm text-muted-foreground"},Ma={key:1,class:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground"},Ea={key:1,class:"flex shrink-0 items-center gap-1"},z3=$1({__name:"ItemCard",props:{title:{},subtitle:{},pillar:{default:"graph"},hover:{type:Boolean,default:!1},class:{}},setup(e){const t=e,n={memory:"bg-pillar-memory/15 text-pillar-memory",graph:"bg-pillar-graph/15 text-pillar-graph",review:"bg-pillar-review/15 text-pillar-review",tokens:"bg-pillar-tokens/15 text-pillar-tokens",brand:"bg-primary/15 text-primary"};return(l,o)=>(h(),G(z1,{hover:e.hover,class:f1(f(E1)("p-5",t.class))},{default:w(()=>[b("div",Ca,[l.$slots.icon?(h(),C("div",{key:0,class:f1(f(E1)("flex h-11 w-11 shrink-0 items-center justify-center rounded-lg",n[e.pillar]))},[K1(l.$slots,"icon")],2)):P("",!0),b("div",wa,[b("div",xa,[b("h3",_a,N(e.title),1),K1(l.$slots,"badges")]),e.subtitle?(h(),C("p",Ia,N(e.subtitle),1)):P("",!0),K1(l.$slots,"default"),l.$slots.meta?(h(),C("div",Ma,[K1(l.$slots,"meta")])):P("",!0)]),l.$slots.actions?(h(),C("div",Ea,[K1(l.$slots,"actions")])):P("",!0)])]),_:3},8,["hover","class"]))}}),Da={class:"flex min-w-0 items-center gap-3"},Za={class:"min-w-0"},Fa={class:"flex flex-wrap items-center gap-2"},Ba={class:"text-xl font-semibold"},Sa={key:1,class:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground"},Ra={key:0,class:"flex flex-wrap items-center gap-2"},m3=$1({__name:"PageHead",props:{title:{},sub:{},pillar:{default:"graph"},tone:{},mono:{type:Boolean,default:!1},class:{}},setup(e){const t=e,n={memory:"bg-pillar-memory/15 text-pillar-memory",graph:"bg-pillar-graph/15 text-pillar-graph",review:"bg-pillar-review/15 text-pillar-review",tokens:"bg-pillar-tokens/15 text-pillar-tokens",brand:"bg-primary/15 text-primary"},l={neutral:"bg-muted text-muted-foreground",info:"bg-primary/15 text-primary",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-destructive/15 text-destructive"},o=t1(()=>t.tone?l[t.tone]:n[t.pillar]);return(r,s)=>(h(),C("div",{class:f1(f(E1)("mb-6 flex flex-wrap items-start justify-between gap-4",t.class))},[b("div",Da,[K1(r.$slots,"back"),r.$slots.icon?(h(),C("div",{key:0,class:f1(f(E1)("flex h-11 w-11 shrink-0 items-center justify-center rounded-lg",o.value))},[K1(r.$slots,"icon")],2)):P("",!0),b("div",Za,[b("div",Fa,[b("h1",Ba,N(e.title),1),K1(r.$slots,"badges")]),e.sub?(h(),C("p",{key:0,class:f1(f(E1)("text-sm text-muted-foreground",e.mono&&"break-all font-mono"))},N(e.sub),3)):P("",!0),r.$slots.meta?(h(),C("div",Sa,[K1(r.$slots,"meta")])):P("",!0)])]),r.$slots.actions?(h(),C("div",Ra,[K1(r.$slots,"actions")])):P("",!0)],2))}}),Qa=["value"],j2=$1({__name:"Select",props:{modelValue:{},size:{default:"default"},class:{},invalid:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e){const t=e;return(n,l)=>(h(),C("select",{value:e.modelValue,class:f1(f(E1)(f(G0)({size:e.size,invalid:e.invalid}),"w-auto",t.class)),onChange:l[0]||(l[0]=o=>n.$emit("update:modelValue",o.target.value))},[K1(n.$slots,"default")],42,Qa))}}),Na=["aria-label"],Ka=["aria-pressed","onClick"],ge=$1({__name:"Tabs",props:{modelValue:{},tabs:{},label:{},class:{}},emits:["update:modelValue"],setup(e){const t=e;return(n,l)=>(h(),C("div",{role:"group","aria-label":e.label,class:f1(f(E1)("inline-flex rounded-md border bg-card p-0.5",t.class))},[(h(!0),C(n1,null,_1(e.tabs,o=>(h(),C("button",{key:o.id,type:"button","aria-pressed":e.modelValue===o.id,class:f1(f(E1)("rounded px-3 py-1 text-xs font-medium transition-colors",e.modelValue===o.id?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground")),onClick:r=>n.$emit("update:modelValue",o.id)},N(o.label),11,Ka))),128))],10,Na))}}),Ga=["value","rows"],dt=$1({__name:"Textarea",props:{modelValue:{},rows:{default:3},size:{default:"default"},class:{},invalid:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e){const t=e;return(n,l)=>(h(),C("textarea",{value:e.modelValue,rows:e.rows,class:f1(f(E1)(f(ba)({size:e.size,invalid:e.invalid}),t.class)),onInput:l[0]||(l[0]=o=>n.$emit("update:modelValue",o.target.value))},null,42,Ga))}});/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Oa=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i7=e=>e==="";/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $a=(...e)=>e.filter((t,n,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===n).join(" ").trim();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c7=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wa=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,l)=>l?l.toUpperCase():n.toLowerCase());/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const La=e=>{const t=Wa(e);return t.charAt(0).toUpperCase()+t.slice(1)};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Ie={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pa=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":l,strokeWidth:o,"stroke-width":r,size:s=Ie.width,color:a=Ie.stroke,...i},{slots:c})=>A3("svg",{...Ie,...i,width:s,height:s,stroke:a,"stroke-width":i7(n)||i7(l)||n===!0||l===!0?Number(o||r||Ie["stroke-width"])*24/Number(s):o||r||Ie["stroke-width"],class:$a("lucide",i.class,...e?[`lucide-${c7(La(e))}-icon`,`lucide-${c7(e)}`]:["lucide-icon"]),...!c.default&&!Oa(i)&&{"aria-hidden":"true"}},[...t.map(d=>A3(...d)),...c.default?[c.default()]:[]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const B3=(e,t)=>(n,{slots:l,attrs:o})=>A3(Pa,{...o,...n,iconNode:t,name:e},l);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ha=B3("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ta=B3("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ya=B3("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Va=B3("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ua=B3("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ja=B3("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const za=B3("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $t=B3("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ja={key:0,class:"space-y-1.5"},Xa={class:"flex gap-2"},O0=$1({__name:"ListInput",props:{modelValue:{default:()=>[]},placeholder:{},noun:{default:"entry"},mono:{type:Boolean,default:!1},size:{default:"default"},class:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,l=t,o=z("");function r(){const a=o.value.trim();if(!a||n.modelValue.includes(a)){o.value="";return}l("update:modelValue",[...n.modelValue,a]),o.value=""}function s(a){l("update:modelValue",n.modelValue.filter(i=>i!==a))}return(a,i)=>(h(),C("div",{class:f1(f(E1)("space-y-2",n.class))},[e.modelValue.length?(h(),C("ul",ja,[(h(!0),C(n1,null,_1(e.modelValue,c=>(h(),C("li",{key:c,class:"flex items-center gap-2 rounded-md border bg-muted/40 py-1 pl-3 pr-1 text-sm"},[b("span",{class:f1(f(E1)("min-w-0 flex-1 break-all",e.mono&&"font-mono text-xs"))},N(c),3),I(C1,{variant:"ghost",size:"icon",class:"h-6 w-6 shrink-0","aria-label":`Remove ${c}`,onClick:d=>s(c)},{default:w(()=>[I(f($t),{class:"h-3.5 w-3.5"})]),_:1},8,["aria-label","onClick"])]))),128))])):P("",!0),b("div",Xa,[I(J3,{modelValue:o.value,"onUpdate:modelValue":i[0]||(i[0]=c=>o.value=c),size:e.size,placeholder:e.placeholder,class:f1(e.mono?"font-mono":void 0),"aria-label":`Add ${e.noun}`,onKeydown:ar(qe(r,["prevent"]),["enter"])},null,8,["modelValue","size","placeholder","class","aria-label","onKeydown"]),I(C1,{size:e.size,variant:"outline",class:"shrink-0",disabled:!o.value.trim(),onClick:r},{default:w(()=>[I(f(Ja),{class:"mr-1.5 h-3.5 w-3.5"}),i[1]||(i[1]=U(" Add ",-1))]),_:1},8,["size","disabled"])])],2))}}),qa={class:"min-w-0 truncate"},ei=["aria-label"],u7=$1({__name:"Chip",props:{tone:{default:"default"},removable:{type:Boolean,default:!1},label:{},class:{}},emits:["remove"],setup(e){const t=e,n={default:"border-primary/30 bg-primary/10 text-foreground",success:"border-success/40 bg-success/10 text-foreground",warning:"border-warning/40 bg-warning/10 text-foreground",danger:"border-destructive/40 bg-destructive/10 text-foreground",muted:"border-border bg-muted/60 text-muted-foreground"};return(l,o)=>(h(),C("span",{class:f1(f(E1)("inline-flex max-w-full items-center gap-1 rounded-full border py-0.5 pl-2.5 text-xs",e.removable?"pr-1":"pr-2.5",n[e.tone],t.class))},[K1(l.$slots,"mark"),b("span",qa,[K1(l.$slots,"default")]),e.removable?(h(),C("button",{key:0,type:"button",class:"shrink-0 rounded-full p-0.5 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground","aria-label":e.label?`Remove ${e.label}`:"Remove",onClick:o[0]||(o[0]=r=>l.$emit("remove"))},[I(f($t),{class:"h-3 w-3"})],8,ei)):P("",!0)],2))}}),ti=["title"],ni={class:"relative flex h-2 w-2 shrink-0"},li={key:1,class:"sr-only"},$e=$1({__name:"DotIndicator",props:{tone:{default:"neutral"},title:{},label:{},pulse:{type:Boolean,default:!1},class:{}},setup(e){const t=e,n={neutral:"bg-muted-foreground",info:"bg-primary",success:"bg-success",warning:"bg-warning",danger:"bg-destructive"},l={neutral:"text-muted-foreground",info:"text-primary",success:"text-success",warning:"text-warning",danger:"text-destructive"};return(o,r)=>(h(),C("span",{class:f1(f(E1)("inline-flex items-center gap-1.5 align-middle",t.class)),title:e.title},[b("span",ni,[e.pulse?(h(),C("span",{key:0,class:f1(f(E1)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-60",n[e.tone]))},null,2)):P("",!0),b("span",{class:f1(f(E1)("relative inline-flex h-2 w-2 rounded-full",n[e.tone]))},null,2)]),e.label?(h(),C("span",{key:0,class:f1(f(E1)("text-xs font-medium",l[e.tone]))},N(e.label),3)):(h(),C("span",li,N(e.title),1))],10,ti))}}),d7={};function oi(e){let t=d7[e];if(t)return t;t=d7[e]=[];for(let n=0;n<128;n++){const l=String.fromCharCode(n);t.push(l)}for(let n=0;n=55296&&d<=57343?o+="���":o+=String.fromCharCode(d),r+=6;continue}}if((a&248)===240&&r+91114111?o+="����":(u-=65536,o+=String.fromCharCode(55296+(u>>10),56320+(u&1023))),r+=9;continue}}o+="�"}return o})}fe.defaultChars=";/?:@&=+$,#";fe.componentChars="";const f7={};function ri(e){let t=f7[e];if(t)return t;t=f7[e]=[];for(let n=0;n<128;n++){const l=String.fromCharCode(n);/^[0-9a-z]$/i.test(l)?t.push(l):t.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2))}for(let n=0;n"u"&&(n=!0);const l=ri(t);let o="";for(let r=0,s=e.length;r=55296&&a<=57343){if(a>=55296&&a<=56319&&r+1=56320&&i<=57343){o+=encodeURIComponent(e[r]+e[r+1]),r++;continue}}o+="%EF%BF%BD";continue}o+=encodeURIComponent(e[r])}return o}i3.defaultChars=";/?:@&=+$,-_.!~*'()#";i3.componentChars="-_.!~*'()";function ft(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&e.hostname.indexOf(":")!==-1?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function Y4(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}const si=/^([a-z0-9.+-]+:)/i,ai=/:[0-9]*$/,ii=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,ci=["<",">",'"',"`"," ","\r",` +`," "],ui=["{","}","|","\\","^","`"].concat(ci),di=["'"].concat(ui),A7=["%","/","?",";","#"].concat(di),h7=["/","?","#"],fi=255,p7=/^[+a-z0-9A-Z_-]{0,63}$/,Ai=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m7={javascript:!0,"javascript:":!0},g7={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function At(e,t){if(e&&e instanceof Y4)return e;const n=new Y4;return n.parse(e,t),n}Y4.prototype.parse=function(e,t){let n,l,o,r=e;if(r=r.trim(),!t&&e.split("#").length===1){const c=ii.exec(r);if(c)return this.pathname=c[1],c[2]&&(this.search=c[2]),this}let s=si.exec(r);if(s&&(s=s[0],n=s.toLowerCase(),this.protocol=s,r=r.substr(s.length)),(t||s||r.match(/^\/\/[^@\/]+@[^@\/]+/))&&(o=r.substr(0,2)==="//",o&&!(s&&m7[s])&&(r=r.substr(2),this.slashes=!0)),!m7[s]&&(o||s&&!g7[s])){let c=-1;for(let p=0;p127?M+="x":M+=F[E];if(!M.match(p7)){const E=p.slice(0,y),_=p.slice(y+1),R=F.match(Ai);R&&(E.push(R[1]),_.unshift(R[2])),_.length&&(r=_.join(".")+r),this.hostname=E.join(".");break}}}}this.hostname.length>fi&&(this.hostname=""),m&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const a=r.indexOf("#");a!==-1&&(this.hash=r.substr(a),r=r.slice(0,a));const i=r.indexOf("?");return i!==-1&&(this.search=r.substr(i),r=r.slice(0,i)),r&&(this.pathname=r),g7[n]&&this.hostname&&!this.pathname&&(this.pathname=""),this};Y4.prototype.parseHost=function(e){let t=ai.exec(e);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};const hi=Object.freeze(Object.defineProperty({__proto__:null,decode:fe,encode:i3,format:ft,parse:At},Symbol.toStringTag,{value:"Module"})),$0=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,W0=/[\0-\x1F\x7F-\x9F]/,pi=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,Wt=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]/,L0=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/,P0=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,mi=Object.freeze(Object.defineProperty({__proto__:null,Any:$0,Cc:W0,Cf:pi,P:Wt,S:L0,Z:P0},Symbol.toStringTag,{value:"Module"})),gi=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function vi(e){return e>=55296&&e<=57343||e>1114111?65533:gi.get(e)??e}function yi(e){const t=atob(e),n=t.length&-2,l=new Uint16Array(n/2);for(let o=0,r=0;o=J1.ZERO&&e<=J1.NINE}function ki(e){return e>=J1.UPPER_A&&e<=J1.UPPER_F||e>=J1.LOWER_A&&e<=J1.LOWER_F}function Ci(e){return e>=J1.UPPER_A&&e<=J1.UPPER_Z||e>=J1.LOWER_A&&e<=J1.LOWER_Z||ht(e)}function wi(e){return e===J1.EQUALS||Ci(e)}var s2;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(s2||(s2={}));var I3;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(I3||(I3={}));class xi{constructor(t,n,l){O1(this,"decodeTree");O1(this,"emitCodePoint");O1(this,"errors");O1(this,"state",s2.EntityStart);O1(this,"consumed",1);O1(this,"result",0);O1(this,"treeIndex",0);O1(this,"excess",1);O1(this,"decodeMode",I3.Strict);O1(this,"runConsumed",0);this.decodeTree=t,this.emitCodePoint=n,this.errors=l}startEntity(t){this.decodeMode=t,this.state=s2.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(t,n){switch(this.state){case s2.EntityStart:return t.charCodeAt(n)===J1.NUM?(this.state=s2.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=s2.NamedEntity,this.stateNamedEntity(t,n));case s2.NumericStart:return this.stateNumericStart(t,n);case s2.NumericDecimal:return this.stateNumericDecimal(t,n);case s2.NumericHex:return this.stateNumericHex(t,n);case s2.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|v7)===J1.LOWER_X?(this.state=s2.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=s2.NumericDecimal,this.stateNumericDecimal(t,n))}stateNumericHex(t,n){for(;n>14;for(;n>7;if(this.runConsumed===0){const i=o&g2.JUMP_TABLE;if(t.charCodeAt(n)!==i)return this.result===0?0:this.emitNotTerminatedNamedEntity();n++,this.excess++,this.runConsumed++}for(;this.runConsumed=t.length)return-1;const i=this.runConsumed-1,c=l[this.treeIndex+1+(i>>1)],d=i%2===0?c&255:c>>8&255;if(t.charCodeAt(n)!==d)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();n++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(a>>1),o=l[this.treeIndex],r=(o&g2.VALUE_LENGTH)>>14}if(n>=t.length)break;const s=t.charCodeAt(n);if(s===J1.SEMI&&r!==0&&(o&g2.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,r,this.consumed+this.excess);if(this.treeIndex=Ii(l,o,this.treeIndex+Math.max(1,r),s),this.treeIndex<0)return this.result===0||this.decodeMode===I3.Attribute&&(r===0||wi(s))?0:this.emitNotTerminatedNamedEntity();if(o=l[this.treeIndex],r=(o&g2.VALUE_LENGTH)>>14,r!==0){if(s===J1.SEMI)return this.emitNamedEntityData(this.treeIndex,r,this.consumed+this.excess);this.decodeMode!==I3.Strict&&(o&g2.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}n++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var o;const{result:t,decodeTree:n}=this,l=(n[t]&g2.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,l,this.consumed),(o=this.errors)==null||o.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,l){const{decodeTree:o}=this;return this.emitCodePoint(n===1?o[t]&~(g2.VALUE_LENGTH|g2.FLAG13):o[t+1],l),n===3&&this.emitCodePoint(o[t+2],l),l}end(){var t;switch(this.state){case s2.NamedEntity:return this.result!==0&&(this.decodeMode!==I3.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case s2.NumericDecimal:return this.emitNumericEntity(0,2);case s2.NumericHex:return this.emitNumericEntity(0,3);case s2.NumericStart:return(t=this.errors)==null||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case s2.EntityStart:return 0}}}function _i(e){let t="";const n=new xi(e,l=>t+=String.fromCodePoint(l));return function(o,r){let s=0,a=0;for(;(a=o.indexOf("&",a))>=0;){t+=o.slice(s,a),n.startEntity(r);const c=n.write(o,a+1);if(c<0){s=a+n.end();break}s=a+c,a=c===0?s+1:s}const i=t+o.slice(s);return t="",i}}function Ii(e,t,n,l){const o=(t&g2.BRANCH_LENGTH)>>7,r=t&g2.JUMP_TABLE;if(o===0)return r!==0&&l===r?n:-1;if(r){const c=l-r;return c<0||c>=o?-1:e[n+c]-1}const s=o+1>>1;let a=0,i=o-1;for(;a<=i;){const c=a+i>>>1,d=c>>1,A=e[n+d]>>(c&1)*8&255;if(Al)i=c-1;else return e[n+s+c]}return-1}const Mi=_i(bi);function H0(e){return Mi(e,I3.Strict)}var Ei=class{constructor(e={}){O1(this,"src_Any",$0.source);O1(this,"src_Cc",W0.source);O1(this,"src_Z",P0.source);O1(this,"src_P",Wt.source);O1(this,"src_ZPCc",[this.src_Z,this.src_P,this.src_Cc].join("|"));O1(this,"src_ZCc",[this.src_Z,this.src_Cc].join("|"));O1(this,"cache",{});O1(this,"opts",{maxLength:1e4,urlAuth:!1,schema_names:[]});this.opts={...this.opts,...e}}set(e={}){return this.opts={...this.opts,...e},this.cache={},this}escapeRE(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}nestedPairRE(e,t,n=4){const l=this.escapeRE(e),o=this.escapeRE(t),r=`(?:(?!${this.src_ZCc}|${l}|${o}).)`;let s=`${l}${r}{0,1000}${o}`;for(let a=2;a<=n;a++)s=`${l}(?:${r}|${s}){0,1000}${o}`;return s}get_text_separators(){var e;return(e=this.cache).text_separators??(e.text_separators=/[><\uff5c]/)}get_pseudo_letter(){var e;return(e=this.cache).src_pseudo_letter??(e.src_pseudo_letter=new RegExp(`(?:(?!${this.get_text_separators().source}|${this.src_ZPCc})${this.src_Any})`))}get_ipv4_addr(){var e;return(e=this.cache).src_ip4??(e.src_ip4=new RegExp("(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])"))}get_ipv6_addr(){var n;const e="[0-9A-Fa-f]{1,4}",t=`(?:(?:${e}:${e})|${this.get_ipv4_addr().source})`;return(n=this.cache).src_ip6_addr??(n.src_ip6_addr=new RegExp(`(?:(?:${e}:){6}${t}|::(?:${e}:){5}${t}|(?:${e})?::(?:${e}:){4}${t}|(?:(?:${e}:){0,1}${e})?::(?:${e}:){3}${t}|(?:(?:${e}:){0,2}${e})?::(?:${e}:){2}${t}|(?:(?:${e}:){0,3}${e})?::${e}:${t}|(?:(?:${e}:){0,4}${e})?::${t}|(?:(?:${e}:){0,5}${e})?::${e}|(?:(?:${e}:){0,6}${e})?::)`))}get_ipv6_url_host(){var e;return(e=this.cache).src_ip6_host??(e.src_ip6_host=new RegExp(`\\[${this.get_ipv6_addr().source}\\]`))}get_ipv6_mail_host(){var e;return(e=this.cache).src_ipv6_mail_host??(e.src_ipv6_mail_host=new RegExp(`\\[IPv6:${this.get_ipv6_addr().source}\\]`))}get_auth(){var e;return(e=this.cache).src_auth??(e.src_auth=new RegExp(`(?:(?:(?!${this.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`))}get_port(){var e;return(e=this.cache).src_port??(e.src_port=new RegExp("(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?"))}get_host_terminator(){var e;return(e=this.cache).src_host_terminator??(e.src_host_terminator=new RegExp(`(?=$|${this.get_text_separators().source}|${this.src_ZPCc})(?!${this.opts["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${this.src_ZPCc}))`))}get_path_terminator(){var e;return(e=this.cache).src_path_terminator??(e.src_path_terminator=new RegExp(`${this.src_ZPCc}|${this.get_text_separators().source}`))}get_path(){var e;return(e=this.cache).src_path??(e.src_path=new RegExp(`(?:[/?#](?:${this.nestedPairRE("[","]")}|${this.nestedPairRE("(",")")}|${this.nestedPairRE("{","}")}|\\"(?:(?!${this.src_ZCc}|["]).){1,100}\\"|\\'(?:(?!${this.src_ZCc}|[']).){1,100}\\'|\\'(?=${this.get_pseudo_letter().source}|[-])|\\.{2,20}[:]?[a-zA-Z0-9%/&]|\\.(?!${this.src_ZCc}|[.]|$)|`+(this.opts["---"]?"\\-(?!--(?:[^-]|$))(?:-{0,19})|":"\\-{1,20}|")+`,(?!${this.src_ZCc}|$)|;(?!${this.src_ZCc}|$)|\\!{1,20}(?!${this.src_ZCc}|[!]|$)|\\?(?!${this.src_ZCc}|[?]|$)|`+this.get_path_extra().source+`[\\\\/:%@#&=_~*]|(?!${this.get_path_terminator().source}).){1,${this.opts.maxLength}}|\\/)?`))}get_mail_name(){var e;return(e=this.cache).src_mail_name??(e.src_mail_name=new RegExp("[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9](?:[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9]|[.](?=[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9])){0,63}"))}get_xn(){var e;return(e=this.cache).src_xn??(e.src_xn=new RegExp("xn--[a-z0-9\\-]{1,59}"))}get_tld(){if(this.cache.tld)return this.cache.tld;const e=[...new Set(this.opts.tlds||[])].sort().reverse().join("|");return this.cache.tld=new RegExp(`${e||"$#none#$"}|${this.get_xn().source}`),this.cache.tld}get_domain_root(){var e;return(e=this.cache).src_domain_root??(e.src_domain_root=new RegExp("(?:"+this.get_xn().source+`|${this.get_pseudo_letter().source}{1,63})`))}get_domain(){var e;return(e=this.cache).src_domain??(e.src_domain=new RegExp("(?:"+this.get_xn().source+`|(?:${this.get_pseudo_letter().source})|(?:${this.get_pseudo_letter().source}(?:-|${this.get_pseudo_letter().source}){0,61}${this.get_pseudo_letter().source}))`))}get_url_host_port(){var e;return(e=this.cache).url_host_port??(e.url_host_port=new RegExp("(?:"+this.get_ipv6_url_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,10}${this.get_domain().source}))`+this.get_port().source+this.get_host_terminator().source))}get_fuzzy_url_host_port(){var e;return(e=this.cache).fuzzy_url_host_port??(e.fuzzy_url_host_port=new RegExp("(?:"+(this.opts.fuzzyIP?this.get_ipv4_addr().source+"|":"")+`(?:(?:(?:${this.get_domain().source})\\.){1,10}(?:${this.get_tld().source})))`+this.get_host_terminator().source))}get_mail_host(){var e;return(e=this.cache).src_mail_host??(e.src_mail_host=new RegExp("(?:"+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,4}${this.get_domain().source}))`+this.get_host_terminator().source))}get_fuzzy_mail_host(){var e;return(e=this.cache).src_fuzzy_mail_host??(e.src_fuzzy_mail_host=new RegExp("(?:"+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})[.]){1,4}${this.get_domain_root().source}))`+this.get_host_terminator().source))}get_path_extra(){var e;return(e=this.cache).src_path_extra??(e.src_path_extra=new RegExp(""))}get_fuzzy_mail_host_search(){var e;return(e=this.cache).mail_fuzzy_host_search??(e.mail_fuzzy_host_search=new RegExp(`@${this.get_fuzzy_mail_host().source}`,"ig"))}get_fuzzy_link_search(){var e;return(e=this.cache).link_fuzzy_search??(e.link_fuzzy_search=new RegExp(`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${this.src_ZPCc}))(?:(?![$+<=>^\`||])${this.get_fuzzy_url_host_port().source}${this.get_path().source})`,"ig"))}get_http_validator(){var e;return(e=this.cache).http_validator??(e.http_validator=new RegExp("\\/\\/"+(this.opts.urlAuth?this.get_auth().source:"")+this.get_url_host_port().source+this.get_path().source,"iy"))}get_relative_proto_validator(){var e;return(e=this.cache).relative_proto_validator??(e.relative_proto_validator=new RegExp((this.opts.urlAuth?this.get_auth().source:"")+`(?:localhost|${this.get_ipv6_url_host().source}|(?:(?:${this.get_domain().source})[.]){1,10}${this.get_domain_root().source})`+this.get_port().source+this.get_host_terminator().source+this.get_path().source,"iy"))}get_mail_name_validator(){var e;return(e=this.cache).mail_name_validator??(e.mail_name_validator=new RegExp(`(?:^|${this.get_text_separators().source}|"|\\(|${this.src_ZCc})(${this.get_mail_name().source})$`))}get_mailto_validator(){var e;return(e=this.cache).mailto_validator??(e.mailto_validator=new RegExp(`${this.get_mail_name().source}@${this.get_mail_host().source}`,"iy"))}get_schema_names(){var e;return(e=this.cache).schema_names??(e.schema_names=new RegExp((this.opts.schema_names||[]).map(t=>this.escapeRE(t)).join("|")))}get_schema_search(){var e;return(e=this.cache).schema_search??(e.schema_search=new RegExp(`(^|(?!_)(?:[><|]|${this.src_ZPCc}))(${this.get_schema_names().source})`,"ig"))}get_schema_at_start(){var e;return(e=this.cache).schema_at_start??(e.schema_at_start=new RegExp(`^${this.get_schema_search().source}`,"i"))}},K5={validate:(e,t,n)=>{const l=n.re.get_http_validator();l.lastIndex=t;const o=l.exec(e);return o?o[0].length:0},normalize:(e,t)=>t.normalize(e)},Di={"http:":K5,"https:":K5,"ftp:":K5,"//":{validate:function(e,t,n){const l=n.re.get_relative_proto_validator();l.lastIndex=t;const o=l.exec(e);return o?t>=3&&e[t-3]===":"||t>=3&&e[t-3]==="/"?0:o[0].length:0},normalize:(e,t)=>t.normalize(e)},"mailto:":{validate:function(e,t,n){const l=n.re.get_mailto_validator();l.lastIndex=t;const o=l.exec(e);return o?o[0].length:0},normalize:(e,t)=>t.normalize(e)}},Zi="a:cdefgilmnoqrstuwxz|b:abdefghijmnorstvwyz|c:acdfghiklmnoruvwxyz|d:ejkmoz|e:cegrstu|f:ijkmor|g:abdefghilmnpqrstuwy|h:kmnrtu|i:delmnoqrst|j:emop|k:eghimnprwyz|l:abcikrstuvy|m:acdeghklmnopqrstuvwxyz|n:acefgilopruz|o:m|p:aefghklmnrstwy|q:a|r:eosuw|s:abcdeghijklmnortuvxyz|t:cdfghjklmnortvwz|u:agksyz|v:aceginu|w:fs|y:et|z:amw",Fi="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф";function Bi(){const e=Fi.split("|");return Zi.split("|").forEach(t=>{const n=t.indexOf(":"),l=t.slice(0,n);for(const o of t.slice(n+1))e.push(l+o)}),e}var Si={fuzzyLink:!1,fuzzyEmail:!0,fuzzyIP:!1,"---":!1,tlds:Bi(),urlAuth:!1,maxLength:1e4},y7=class{constructor(e,t,n,l){O1(this,"schema");O1(this,"index");O1(this,"lastIndex");O1(this,"raw");O1(this,"text");O1(this,"url");const o=e.slice(n,l);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=l,this.raw=o,this.text=o,this.url=o}},Ri=class{constructor(e={}){O1(this,"__opts__");O1(this,"__schemas__");O1(this,"re");const{rebuilder:t,...n}=e;this.__opts__={...Si,...n},this.__schemas__={...Di},this.re=t||new Ei,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)})}add(e,t=null){if(!t)delete this.__schemas__[e];else{const n={normalize:(l,o)=>o.normalize(l),...t};this.__schemas__[e]=n}return this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}set(e={}){return this.__opts__={...this.__opts__,...e},this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}test(e){if(!e.length)return!1;let t,n;for(n=this.re.get_schema_search(),n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0;if(this.__opts__.fuzzyLink&&this.__schemas__["http:"]&&(n=this.re.get_fuzzy_link_search(),n.lastIndex=0,n.exec(e)!==null))return!0;if(this.__opts__.fuzzyEmail&&this.__schemas__["mailto:"]&&e.indexOf("@")>=0){const l=this.re.get_fuzzy_mail_host_search(),o=this.re.get_mail_name_validator();for(l.lastIndex=0;(t=l.exec(e))!==null;){const r=e.slice(Math.max(0,t.index-65),t.index);if(o.test(r))return!0}}return!1}testSchemaAt(e,t,n){return this.__schemas__[t.toLowerCase()]?this.__schemas__[t.toLowerCase()].validate(e.slice(0,n+this.__opts__.maxLength),n,this):0}match(e){const t=[],n=this.re.get_schema_search();let l,o,r,s,a,i,c=!1,d=!1,u=!1,A=0;if(!e.length)return null;for(n.lastIndex=0,this.__opts__.fuzzyLink&&this.__schemas__["http:"]&&(l=this.re.get_fuzzy_link_search(),l.lastIndex=0),this.__opts__.fuzzyEmail&&this.__schemas__["mailto:"]&&(o=this.re.get_fuzzy_mail_host_search(),o.lastIndex=0,r=this.re.get_mail_name_validator());;){const m=Math.max(A-1,0);if(o&&r&&!u&&(!a||a.index=A)break;o.lastIndex=A)break;l.lastIndexp.lastIndex))&&(p=s);let y;if(!c)for(;;){if(!i){n.lastIndexp.index)break;const M=i;i=void 0;const E=this.testSchemaAt(e,M.schema,M.lastIndex);if(E){y={schema:M.schema,index:M.index,lastIndex:M.lastIndex+E};break}}let k=y;if((!k||a&&(a.indexk.lastIndex))&&(k=a),(!k||s&&(s.indexk.lastIndex))&&(k=s),!k)break;k===a?a=void 0:k===s&&(s=void 0);const F=new y7(e,k.schema,k.index,k.lastIndex);F.schema?this.__schemas__[F.schema].normalize(F,this):this.normalize(F),t.push(F),A=k.lastIndex}return t.length?t:null}matchAtStart(e){if(!e.length)return null;const t=this.re.get_schema_at_start().exec(e);if(!t)return null;const n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;const l=new y7(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__schemas__[l.schema].normalize(l,this),l}tlds(e,t=!1){return e=Array.isArray(e)?e:[e],t?this.__opts__.tlds=this.__opts__.tlds.concat(e):this.__opts__.tlds=e,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}normalize(e){e.schema||(e.url=`http://${e.url}`),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)}};const ae=2147483647,U2=36,Lt=1,t4=26,Qi=38,Ni=700,T0=72,Y0=128,V0="-",Ki=/^xn--/,Gi=/[^\0-\x7F]/,Oi=/[\x2E\u3002\uFF0E\uFF61]/g,$i={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},G5=U2-Lt,J2=Math.floor,O5=String.fromCharCode;function _3(e){throw new RangeError($i[e])}function Wi(e,t){const n=[];let l=e.length;for(;l--;)n[l]=t(e[l]);return n}function U0(e,t){const n=e.split("@");let l="";n.length>1&&(l=n[0]+"@",e=n[1]),e=e.replace(Oi,".");const o=e.split("."),r=Wi(o,t).join(".");return l+r}function J0(e){const t=[];let n=0;const l=e.length;for(;n=55296&&o<=56319&&nString.fromCodePoint(...e),Pi=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:U2},b7=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},z0=function(e,t,n){let l=0;for(e=n?J2(e/Ni):e>>1,e+=J2(e/t);e>G5*t4>>1;l+=U2)e=J2(e/G5);return J2(l+(G5+1)*e/(e+Qi))},j0=function(e){const t=[],n=e.length;let l=0,o=Y0,r=T0,s=e.lastIndexOf(V0);s<0&&(s=0);for(let a=0;a=128&&_3("not-basic"),t.push(e.charCodeAt(a));for(let a=s>0?s+1:0;a=n&&_3("invalid-input");const A=Pi(e.charCodeAt(a++));A>=U2&&_3("invalid-input"),A>J2((ae-l)/d)&&_3("overflow"),l+=A*d;const m=u<=r?Lt:u>=r+t4?t4:u-r;if(AJ2(ae/p)&&_3("overflow"),d*=p}const c=t.length+1;r=z0(l-i,c,i==0),J2(l/c)>ae-o&&_3("overflow"),o+=J2(l/c),l%=c,t.splice(l++,0,o)}return String.fromCodePoint(...t)},X0=function(e){const t=[];e=J0(e);const n=e.length;let l=Y0,o=0,r=T0;for(const i of e)i<128&&t.push(O5(i));const s=t.length;let a=s;for(s&&t.push(V0);a=l&&dJ2((ae-o)/c)&&_3("overflow"),o+=(i-l)*c,l=i;for(const d of e)if(dae&&_3("overflow"),d===l){let u=o;for(let A=U2;;A+=U2){const m=A<=r?Lt:A>=r+t4?t4:A-r;if(u{let n={};for(var l in e)C7(n,l,{get:e[l],enumerable:!0});return C7(n,Symbol.toStringTag,{value:"Module"}),n},Yi=q0({arrayReplaceAt:()=>Vi,asciiTrim:()=>h5,callable:()=>en,escapeHtml:()=>D3,escapeRE:()=>lc,fromCodePoint:()=>n4,isMdAsciiPunct:()=>r4,isPunctChar:()=>nn,isPunctCharCode:()=>o4,isSpace:()=>H1,isValidEntityCode:()=>Pt,isWhiteSpace:()=>l4,lib:()=>oc,normalizeReference:()=>A5,unescapeAll:()=>Ae,unescapeMd:()=>ji});function en(e){const t=function(...n){return Reflect.construct(e,n,new.target&&new.target!==t?new.target:e)};return Object.defineProperty(t,"name",{value:e.name}),Object.setPrototypeOf(t,e),t.prototype=e.prototype,t}function Vi(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function Pt(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function n4(e){if(e>65535){e-=65536;const t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var tn=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,Ui=new RegExp(`${tn.source}|${/&([a-z#][a-z0-9]{1,31});/gi.source}`,"gi"),Ji=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function zi(e,t){if(t.charCodeAt(0)===35&&Ji.test(t)){const l=t[1].toLowerCase()==="x"?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Pt(l)?n4(l):e}const n=H0(e);return n!==e?n:e}function ji(e){return e.indexOf("\\")<0?e:e.replace(tn,"$1")}function Ae(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(Ui,function(t,n,l){return n||zi(t,l)})}var Xi=/[&<>"]/,qi=/[&<>"]/g,ec={"&":"&","<":"<",">":">",'"':"""};function tc(e){return ec[e]}function D3(e){return Xi.test(e)?e.replace(qi,tc):e}var nc=/[.?*+^$[\]\\(){}|-]/g;function lc(e){return e.replace(nc,"\\$&")}function H1(e){switch(e){case 9:case 32:return!0}return!1}function l4(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function nn(e){return Wt.test(e)||L0.test(e)}function o4(e){return nn(n4(e))}function r4(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function A5(e){return e=e.trim().replace(/\s+/g," "),e.toLowerCase().toUpperCase()}function w7(e){return e===32||e===9||e===10||e===13}function h5(e){let t=0;for(;t=t&&w7(e.charCodeAt(n));n--);return e.slice(t,n+1)}var oc={mdurl:hi,ucmicro:mi};function rc(e,t,n){let l,o,r,s;const a=e.posMax,i=e.pos;for(e.pos=t+1,l=1;e.pos32))return r;if(l===41){if(s===0)break;s--}o++}return t===o||s!==0||(r.str=Ae(e.slice(t,o)),r.pos=o,r.ok=!0),r}function ac(e,t,n,l){let o,r=t;const s={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(l)s.str=l.str,s.marker=l.marker;else{if(r>=n)return s;let a=e.charCodeAt(r);if(a!==34&&a!==39&&a!==40)return s;t++,r++,a===40&&(a=41),s.marker=a}for(;rsc,parseLinkLabel:()=>rc,parseLinkTitle:()=>ac});function s4(e){"@babel/helpers - typeof";return s4=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s4(e)}function cc(e,t){if(s4(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var l=n.call(e,t);if(s4(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function uc(e){var t=cc(e,"string");return s4(t)=="symbol"?t:t+""}function h1(e,t,n){return(t=uc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var U3=class{constructor(e,t,n){h1(this,"map",null),h1(this,"level",0),h1(this,"children",null),h1(this,"content",""),h1(this,"markup",""),h1(this,"info",""),h1(this,"block",!1),h1(this,"hidden",!1),this.type=e,this.tag=t,this.attrs=null,this.nesting=n,this.meta=null}attrIndex(e){if(!this.attrs)return-1;const t=this.attrs;for(let n=0,l=t.length;n=0&&(n=this.attrs[t][1]),n}attrJoin(e,t){const n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=`${this.attrs[n][1]} ${t}`}},a4=class{constructor(){h1(this,"__rules__",[]),h1(this,"__cache__",null)}__find__(e){for(let t=0;t{t.enabled&&t.alt.forEach(n=>{n&&e.add(n)})}),this.__cache__=Object.create(null),this.__cache__[""]=[],this.__rules__.forEach(t=>{t.enabled&&this.__cache__[""].push(t.fn)}),e.forEach(t=>{this.__cache__[t]=[],this.__rules__.forEach(n=>{n.enabled&&n.alt.indexOf(t)>=0&&this.__cache__[t].push(n.fn)})})}at(e,t,n={}){const l=this.__find__(e);if(l===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__[l].fn=t,this.__rules__[l].alt=n.alt||[],this.__cache__=null}before(e,t,n,l={}){const o=this.__find__(e);if(o===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__.splice(o,0,{name:t,enabled:!0,fn:n,alt:l.alt||[]}),this.__cache__=null}after(e,t,n,l={}){const o=this.__find__(e);if(o===-1)throw new Error(`Parser rule not found: ${e}`);this.__rules__.splice(o+1,0,{name:t,enabled:!0,fn:n,alt:l.alt||[]}),this.__cache__=null}push(e,t,n={}){this.__rules__.push({name:e,enabled:!0,fn:t,alt:n.alt||[]}),this.__cache__=null}enable(e,t=!1){Array.isArray(e)||(e=[e]);const n=[];return e.forEach(l=>{const o=this.__find__(l);if(o<0){if(t)return;throw new Error(`Rules manager: invalid rule name ${l}`)}this.__rules__[o].enabled=!0,n.push(l)}),this.__cache__=null,n}enableOnly(e,t=!1){Array.isArray(e)||(e=[e]),this.__rules__.forEach(n=>{n.enabled=!1}),this.enable(e,t)}disable(e,t=!1){Array.isArray(e)||(e=[e]);const n=[];return e.forEach(l=>{const o=this.__find__(l);if(o<0){if(t)return;throw new Error(`Rules manager: invalid rule name ${l}`)}this.__rules__[o].enabled=!1,n.push(l)}),this.__cache__=null,n}getRules(e){return this.__cache__||this.__compile__(),this.__cache__[e]||[]}},X2={};X2.code_inline=function(e,t,n,l,o){const r=e[t];return`${D3(r.content)}`};X2.code_block=function(e,t,n,l,o){const r=e[t];return`${D3(e[t].content)} +`};X2.fence=function(e,t,n,l,o){const r=e[t],s=r.info?Ae(r.info).trim():"";let a="",i="";if(s){const d=s.split(/(\s+)/g);a=d[0],i=d.slice(2).join("")}let c;if(n.highlight?c=n.highlight(r.content,a,i)||D3(r.content):c=D3(r.content),c.indexOf("${c} +`}return`
${c}
+`};X2.image=function(e,t,n,l,o){const r=e[t];return r.attrs[r.attrIndex("alt")][1]=o.renderInlineAsText(r.children,n,l),o.renderToken(e,t,n)};X2.hardbreak=function(e,t,n){return n.xhtmlOut?`
+`:`
+`};X2.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`
+`:`
+`:` +`};X2.text=function(e,t){return D3(e[t].content)};X2.html_block=function(e,t){return e[t].content};X2.html_inline=function(e,t){return e[t].content};var ln=class{constructor(){h1(this,"rules",Object.assign({},X2))}renderAttrs(e){let t,n,l;if(!e.attrs)return"";for(l="",t=0,n=e.attrs.length;t=0&&e[r].hidden&&e[r].nesting===0;)r--;l.block&&l.nesting!==-1&&r>=0&&e[r].hidden&&e[r].nesting===-1&&(o+=` +`),o+=(l.nesting===-1?" +`:">",o}renderInline(e,t,n){let l="";const o=this.rules;for(let r=0,s=e.length;r\s]/i.test(e)}function vc(e){return/^<\/a\s*>/i.test(e)}function yc(e){const t=e.tokens;if(e.md.options.linkify)for(let n=0,l=t.length;n=0;a--){const i=o[a];if(i.type==="link_close"){for(a--;o[a].level!==i.level&&o[a].type!=="link_open";)a--;continue}if(i.type==="html_inline"&&(gc(i.content)&&s>0&&s--,vc(i.content)&&s++),!(s>0)&&i.type==="text"&&e.md.linkify.test(i.content)){const c=i.content;let d=e.md.linkify.match(c);const u=[];let A=i.level,m=0;d.length>0&&d[0].index===0&&a>0&&o[a-1].type==="text_special"&&(d=d.slice(1));for(let p=0;pm){const $=new e.Token("text","",0);$.content=c.slice(m,M),$.level=A,u.push($)}const E=new e.Token("link_open","a",1);E.attrs=[["href",k]],E.level=A++,E.markup="linkify",E.info="auto",u.push(E);const _=new e.Token("text","",0);_.content=F,_.level=A,u.push(_);const R=new e.Token("link_close","a",-1);R.level=--A,R.markup="linkify",R.info="auto",u.push(R),m=d[p].lastIndex}if(m0){let a=o.length;for(const u of r)a+=u.nodes.length-1;const i=new Array(a);let c=0,d=0;r.reverse();for(let u=0;u=0;n--){const l=e[n];l.type==="text"&&!t&&(l.content=l.content.replace(kc,wc)),l.type==="link_open"&&l.info==="auto"&&t--,l.type==="link_close"&&l.info==="auto"&&t++}}function _c(e){let t=0;for(let n=e.length-1;n>=0;n--){const l=e[n];l.type==="text"&&!t&&rn.test(l.content)&&(l.content=l.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),l.type==="link_open"&&l.info==="auto"&&t--,l.type==="link_close"&&l.info==="auto"&&t++}}function Ic(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(bc.test(e.tokens[t].content)&&xc(e.tokens[t].children),rn.test(e.tokens[t].content)&&_c(e.tokens[t].children))}var Mc=/['"]/,x7=/['"]/g,_7="’";function I4(e,t,n,l){e[t]||(e[t]=[]),e[t].push({pos:n,ch:l})}function Ec(e,t){let n="",l=0;t.sort((o,r)=>o.pos-r.pos);for(let o=0;o=0&&!(l[n].level<=a);n--);if(l.length=n+1,s.type!=="text")continue;const i=s.content;let c=0;const d=i.length;e:for(;c=0)y=i.charCodeAt(u.index-1);else for(n=r-1;n>=0&&!(e[n].type==="softbreak"||e[n].type==="hardbreak");n--)if(e[n].content){y=e[n].content.charCodeAt(e[n].content.length-1);break}let k=32;if(c=48&&y<=57&&(m=A=!1),A&&m&&(A=F,m=M),!A&&!m){p&&I4(o,r,u.index,_7);continue}if(m)for(n=l.length-1;n>=0;n--){let R=l[n];if(l[n].level=0;t--)e.tokens[t].type!=="inline"||!Mc.test(e.tokens[t].content)||Dc(e.tokens[t].children,e)}function Fc(e){let t,n;const l=e.length;for(t=0;t0&&this.level++,this.tokens.push(l),l}isEmpty(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]}skipEmptyLines(e){for(let t=this.lineMax;et;)if(!H1(this.src.charCodeAt(--e)))return e+1;return e}skipChars(e,t){for(let n=this.src.length;en;)if(t!==this.src.charCodeAt(--e))return e+1;return e}getLines(e,t,n,l){if(e>=t)return"";const o=new Array(t-e);for(let r=0,s=e;sn?o[r]=new Array(a-n+1).join(" ")+this.src.slice(c,d):o[r]=this.src.slice(c,d)}return o.join("")}},Sc=65536;function W5(e,t){const n=e.bMarks[t]+e.tShift[t],l=e.eMarks[t];return e.src.slice(n,l)}function I7(e){const t=[],n=e.length;let l=0,o=e.charCodeAt(l),r=!1,s=0,a="";for(;ln)return!1;let o=t+1;if(e.sCount[o]=4)return!1;let r=e.bMarks[o]+e.tShift[o];if(r>=e.eMarks[o])return!1;const s=e.src.charCodeAt(r++);if(s!==124&&s!==45&&s!==58||r>=e.eMarks[o])return!1;const a=e.src.charCodeAt(r++);if(a!==124&&a!==45&&a!==58&&!H1(a)||s===45&&H1(a))return!1;for(;r=4)return!1;c=I7(i),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop();const u=c.length;if(u===0||u!==d.length)return!1;if(l)return!0;const A=e.parentType;e.parentType="table";const m=e.md.block.ruler.getRules("blockquote"),p=e.push("table_open","table",1),y=[t,0];p.map=y;const k=e.push("thead_open","thead",1);k.map=[t,t+1];const F=e.push("tr_open","tr",1);F.map=[t,t+1];for(let _=0;_=4||(c=I7(i),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop(),E+=u-c.length,E>Sc))break;if(o===t+2){const $=e.push("tbody_open","tbody",1);$.map=M=[t+2,0]}const R=e.push("tr_open","tr",1);R.map=[o,o+1];for(let $=0;$=4){l++,o=l;continue}break}e.line=o;const r=e.push("code_block","code",0);return r.content=e.getLines(t,o,4+e.blkIndent,!1)+` +`,r.map=[t,e.line],!0}function Nc(e,t,n,l){let o=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||o+3>r)return!1;const s=e.src.charCodeAt(o);if(s!==126&&s!==96)return!1;let a=o;o=e.skipChars(o,s);let i=o-a;if(i<3)return!1;const c=e.src.slice(a,o),d=e.src.slice(o,r);if(s===96&&d.indexOf(String.fromCharCode(s))>=0)return!1;if(l)return!0;let u=t,A=!1;for(;u++,!(u>=n||(o=a=e.bMarks[u]+e.tShift[u],r=e.eMarks[u],o=4)&&(o=e.skipChars(o,s),!(o-a=4||e.src.charCodeAt(o)!==62)return!1;if(l)return!0;const a=[],i=[],c=[],d=[],u=e.md.block.ruler.getRules("blockquote"),A=e.parentType;e.parentType="blockquote";let m=!1,p;for(p=t;p=r)break;if(e.src.charCodeAt(o++)===62&&!E){let R=e.sCount[p]+1,$,D;e.src.charCodeAt(o)===32?(o++,R++,D=!1,$=!0):e.src.charCodeAt(o)===9?($=!0,(e.bsCount[p]+R)%4===3?(o++,R++,D=!1):D=!0):$=!1;let x=R;for(a.push(e.bMarks[p]),e.bMarks[p]=o;o=r,i.push(e.bsCount[p]),e.bsCount[p]=e.sCount[p]+1+($?1:0),c.push(e.sCount[p]),e.sCount[p]=x-R,d.push(e.tShift[p]),e.tShift[p]=o-e.bMarks[p];continue}if(m)break;let _=!1;for(let R=0,$=u.length;R<$;R++)if(u[R](e,p,n,!0)){_=!0;break}if(_){e.lineMax=p,e.blkIndent!==0&&(a.push(e.bMarks[p]),i.push(e.bsCount[p]),d.push(e.tShift[p]),c.push(e.sCount[p]),e.sCount[p]-=e.blkIndent);break}a.push(e.bMarks[p]),i.push(e.bsCount[p]),d.push(e.tShift[p]),c.push(e.sCount[p]),e.sCount[p]=-1}const y=e.blkIndent;e.blkIndent=0;const k=e.push("blockquote_open","blockquote",1);k.markup=">";const F=[t,0];k.map=F,e.md.block.tokenize(e,t,p);const M=e.push("blockquote_close","blockquote",-1);M.markup=">",e.lineMax=s,e.parentType=A,F[1]=e.line;for(let E=0;E=4)return!1;let r=e.bMarks[t]+e.tShift[t];const s=e.src.charCodeAt(r++);if(s!==42&&s!==45&&s!==95)return!1;let a=1;for(;r=l)return-1;let r=e.src.charCodeAt(o++);if(r<48||r>57)return-1;for(;;){if(o>=l)return-1;if(r=e.src.charCodeAt(o++),r>=48&&r<=57){if(o-n>=10)return-1;continue}if(r===41||r===46)break;return-1}return o=4||e.listIndent>=0&&e.sCount[i]-e.listIndent>=4&&e.sCount[i]=e.blkIndent&&(d=!0);let u,A,m;if((m=E7(e,i))>=0){if(u=!0,s=e.bMarks[i]+e.tShift[i],A=Number(e.src.slice(s,m-1)),d&&A!==1)return!1}else if((m=M7(e,i))>=0)u=!1;else return!1;if(d&&e.skipSpaces(m)>=e.eMarks[i])return!1;if(l)return!0;const p=e.src.charCodeAt(m-1),y=e.tokens.length;u?(a=e.push("ordered_list_open","ol",1),A!==1&&(a.attrs=[["start",A]])):a=e.push("bullet_list_open","ul",1);const k=[i,0];a.map=k,a.markup=String.fromCharCode(p);let F=!1;const M=e.md.block.ruler.getRules("list"),E=e.parentType;for(e.parentType="list";i=o?D=1:D=R-_,D>4&&(D=1);const x=_+D;a=e.push("list_item_open","li",1),a.markup=String.fromCharCode(p);const Q=[i,0];a.map=Q,u&&(a.info=e.src.slice(s,m-1));const B=e.tight,X=e.tShift[i],Y=e.sCount[i],m1=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=x,e.tight=!0,e.tShift[i]=$-e.bMarks[i],e.sCount[i]=R,$>=o&&e.isEmpty(i+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,i,n),(!e.tight||F)&&(c=!1),F=e.line-i>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=m1,e.tShift[i]=X,e.sCount[i]=Y,e.tight=B,a=e.push("list_item_close","li",-1),a.markup=String.fromCharCode(p),i=e.line,Q[1]=i,i>=n||e.sCount[i]=4)break;let w1=!1;for(let r1=0,l1=M.length;r1=4||e.src.charCodeAt(o)!==91)return!1;function a(_){const R=e.lineMax;if(_>=R||e.isEmpty(_))return null;let $=!1;if(e.sCount[_]-e.blkIndent>3&&($=!0),e.sCount[_]<0&&($=!0),!$){const Q=e.md.block.ruler.getRules("reference"),B=e.parentType;e.parentType="reference";let X=!1;for(let Y=0,m1=Q.length;Y"u"&&(e.env.references={}),typeof e.env.references[F]>"u"&&(e.env.references[F]={title:k,href:u});const M=e.push("reference_definition","",0);M.map=[t,s],M.hidden=!0;const E=Object.create(null);return E.label=F,M.meta=E,e.line=s,!0}var Lc=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],cn=`<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`,un="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Pc=new RegExp(`^(?:${cn}|${un}||<[?][\\s\\S]*?[?]>|]*>|)`),Hc=new RegExp(`^(?:${cn}|${un})`),G3=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp(`^|$))`,"i"),/^$/,!0],[new RegExp(`${Hc.source}\\s*$`),/^$/,!1]];function Tc(e,t,n,l){let o=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(o)!==60)return!1;let s=e.src.slice(o,r),a=0;for(;a=4)return!1;let s=e.src.charCodeAt(o);if(s!==35||o>=r)return!1;let a=1;for(s=e.src.charCodeAt(++o);s===35&&o6||oo&&H1(e.src.charCodeAt(i-1))&&(r=i),e.line=t+1;const c=e.push("heading_open",`h${a}`,1);c.markup="########".slice(0,a),c.map=[t,e.line];const d=e.push("inline","",0);d.content=h5(e.src.slice(o,r)),d.map=[t,e.line],d.children=[];const u=e.push("heading_close",`h${a}`,-1);return u.markup="########".slice(0,a),!0}function Vc(e,t,n){const l=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const o=e.parentType;e.parentType="paragraph";let r=0,s,a=t+1;for(;a3)continue;if(e.sCount[a]>=e.blkIndent){let m=e.bMarks[a]+e.tShift[a];const p=e.eMarks[a];if(m=p))){r=s===61?1:2;break}}if(e.sCount[a]<0)continue;let A=!1;for(let m=0,p=l.length;m3||e.sCount[r]<0)continue;let c=!1;for(let d=0,u=l.length;d=n||e.sCount[s]=r){e.line=n;break}const i=e.line;let c=!1;for(let d=0;d=e.line)throw new Error("block rule didn't increment state.line");break}if(!c)throw new Error("none of the block rules matched");e.tight=!a,e.isEmpty(e.line-1)&&(a=!0),s=e.line,s0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],o={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(l),this.tokens_meta.push(o),l}scanDelims(e,t){const n=this.posMax,l=this.src.charCodeAt(e);let o;if(e===0)o=32;else if(e===1)o=this.src.charCodeAt(0),(o&63488)===55296&&(o=65533);else if(o=this.src.charCodeAt(e-1),(o&64512)===56320){const p=this.src.charCodeAt(e-2);o=(p&64512)===55296?65536+(p-55296<<10)+(o-56320):65533}else(o&64512)===55296&&(o=65533);let r=e;for(;r=65&&e<=90||e>=97&&e<=122}function Xc(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===45||e===46}function qc(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;const n=e.pos,l=e.posMax;if(n+3>l||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;const o=n-Math.min(10,e.pending.length,n);let r=n;for(;r>o&&Xc(e.src.charCodeAt(r-1));)r--;if(r===n||!jc(e.src.charCodeAt(r)))return!1;const s=n-r,a=e.md.linkify.matchAtStart(e.src.slice(r));if(!a)return!1;let i=a.url;if(i.length<=s)return!1;let c=i.length;for(;c>0&&i.charCodeAt(c-1)===42;)c--;c!==i.length&&(i=i.slice(0,c));const d=e.md.normalizeLink(i);if(!e.md.validateLink(d))return!1;if(!t){e.pending=e.pending.slice(0,-s);const u=e.push("link_open","a",1);u.attrs=[["href",d]],u.markup="linkify",u.info="auto";const A=e.push("text","",0);A.content=e.md.normalizeLinkText(i);const m=e.push("link_close","a",-1);m.markup="linkify",m.info="auto"}return e.pos+=i.length-s,!0}function e9(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;const l=e.pending.length-1,o=e.posMax;if(!t)if(l>=0&&e.pending.charCodeAt(l)===32)if(l>=1&&e.pending.charCodeAt(l-1)===32){let r=l-1;for(;r>=1&&e.pending.charCodeAt(r-1)===32;)r--;e.pending=e.pending.slice(0,r),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(n++;n?@[]^_`{|}~-".split("").forEach(function(e){Ht[e.charCodeAt(0)]=1});function t9(e,t){let n=e.pos;const l=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=l))return!1;let o=e.src.charCodeAt(n);if(o===10){for(t||e.push("hardbreak","br",0),n++;n=55296&&o<=56319&&n+1=56320&&a<=57343&&(r+=e.src[n+1],n++)}const s="\\"+r;if(!t){const a=e.push("text_special","",0);o<256&&Ht[o]!==0?a.content=r:a.content=s,a.markup=s,a.info="escape"}return e.pos=n+1,!0}function n9(e){const t={};let n=0;for(;(n=e.indexOf("`",n))!==-1;){const l=n;for(;e.charCodeAt(++n)===96;);t[n-l]=l}return t}function l9(e,t){var n;const l=e.pos;if(e.src.charCodeAt(l)!==96)return!1;const o=e.posMax;let r=l+1;for(;r=r){let i=r,c;for(;(c=e.src.indexOf("`",i))!==-1&&co)break;if(i-c===a){if(!t){const d=e.push("code_inline","code",0);d.markup=s;let u=e.src.slice(r,c).replace(/\n/g," ");u.startsWith(" ")&&u.endsWith(" ")&&/[^ ]/.test(u)&&(u=u.slice(1,-1)),d.content=u}return e.pos=i,!0}}}return t||(e.pending+=s),e.pos=r,!0}function o9(e,t){const n=e.pos,l=e.src.charCodeAt(n);if(t||l!==126)return!1;const o=e.scanDelims(e.pos,!0);let r=o.length;const s=String.fromCharCode(l);if(r<2)return!1;let a;r%2&&(a=e.push("text","",0),a.content=s,r--);for(let i=0;i=0;l--){const o=t[l];if(o.marker!==95&&o.marker!==42||o.end===-1)continue;const r=t[o.end],s=l>0&&t[l-1].end===o.end+1&&t[l-1].marker===o.marker&&t[l-1].token===o.token-1&&t[o.end+1].token===r.token+1,a=String.fromCharCode(o.marker),i=e.tokens[o.token];i.type=s?"strong_open":"em_open",i.tag=s?"strong":"em",i.nesting=1,i.markup=s?a+a:a,i.content="";const c=e.tokens[r.token];c.type=s?"strong_close":"em_close",c.tag=s?"strong":"em",c.nesting=-1,c.markup=s?a+a:a,c.content="",s&&(e.tokens[t[l-1].token].content="",e.tokens[t[o.end+1].token].content="",l--)}}function a9(e){const t=e.tokens_meta,n=e.tokens_meta.length;Z7(e,e.delimiters);for(let o=0;o=u)return!1;if(i=p,o=e.md.helpers.parseLinkDestination(e.src,p,e.posMax),o.ok){for(s=e.md.normalizeLink(o.str),e.md.validateLink(s)?p=o.pos:s="",i=p;p=u||e.src.charCodeAt(p)!==41)&&(c=!0),p++}if(c){if(typeof e.env.references>"u")return!1;if(p=0?l=e.src.slice(i,p++):p=m+1):p=m+1,l||(l=e.src.slice(A,m)),l=A5(l),r=e.env.references[l],!r)return e.pos=d,!1;s=r.href,a=r.title}if(!t){e.pos=A,e.posMax=m;const y=e.push("link_open","a",1),k=[["href",s]];if(y.attrs=k,a&&k.push(["title",a]),l){const F=Object.create(null);F.label=l,y.meta=F}e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=p,e.posMax=u,!0}function c9(e,t){let n,l,o,r,s,a,i,c,d="";const u=e.pos,A=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;const m=e.pos+2,p=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(p<0)return!1;if(r=p+1,r=A)return!1;for(c=r,a=e.md.helpers.parseLinkDestination(e.src,r,e.posMax),a.ok&&(d=e.md.normalizeLink(a.str),e.md.validateLink(d)?r=a.pos:d=""),c=r;r=A||e.src.charCodeAt(r)!==41)return e.pos=u,!1;r++}else{if(typeof e.env.references>"u")return!1;if(r=0?o=e.src.slice(c,r++):r=p+1):r=p+1,o||(o=e.src.slice(m,p)),o=A5(o),s=e.env.references[o],!s)return e.pos=u,!1;d=s.href,i=s.title}if(!t){l=e.src.slice(m,p);const y=[];e.md.inline.parse(l,e.md,e.env,y);const k=e.push("image","img",0),F=[["src",d],["alt",""]];if(k.attrs=F,k.children=y,k.content=l,i&&F.push(["title",i]),o){const M=Object.create(null);M.label=o,k.meta=M}}return e.pos=r,e.posMax=A,!0}var u9=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,d9=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function f9(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;const l=e.pos,o=e.posMax;for(;;){if(++n>=o)return!1;const s=e.src.charCodeAt(n);if(s===60)return!1;if(s===62)break}const r=e.src.slice(l+1,n);if(d9.test(r)){const s=e.md.normalizeLink(r);if(!e.md.validateLink(s))return!1;if(!t){const a=e.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const i=e.push("text","",0);i.content=e.md.normalizeLinkText(r);const c=e.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return e.pos+=r.length+2,!0}if(u9.test(r)){const s=e.md.normalizeLink(`mailto:${r}`);if(!e.md.validateLink(s))return!1;if(!t){const a=e.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const i=e.push("text","",0);i.content=e.md.normalizeLinkText(r);const c=e.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return e.pos+=r.length+2,!0}return!1}function A9(e){return/^\s]/i.test(e)}function h9(e){return/^<\/a\s*>/i.test(e)}function p9(e){const t=e|32;return t>=97&&t<=122}function m9(e,t){if(!e.md.options.html)return!1;const n=e.posMax,l=e.pos;if(e.src.charCodeAt(l)!==60||l+2>=n)return!1;const o=e.src.charCodeAt(l+1);if(o!==33&&o!==63&&o!==47&&!p9(o))return!1;const r=e.src.slice(l).match(Pc);if(!r)return!1;if(!t){const s=e.push("html_inline","",0);s.content=r[0],A9(s.content)&&e.linkLevel++,h9(s.content)&&e.linkLevel--}return e.pos+=r[0].length,!0}var g9=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,v9=/^&([a-z][a-z0-9]{1,31});/i;function y9(e,t){const n=e.pos,l=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=l)return!1;if(e.src.charCodeAt(n+1)===35){const o=e.src.slice(n).match(g9);if(o){if(!t){const r=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0);s.content=Pt(r)?n4(r):n4(65533),s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}else{const o=e.src.slice(n).match(v9);if(o){const r=H0(o[0]);if(r!==o[0]){if(!t){const s=e.push("text_special","",0);s.content=r,s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}}return!1}function F7(e){const t={},n=e.length;if(!n)return;let l=0,o=-2;const r=[];for(let s=0;si;c-=r[c]+1){const u=e[c];if(u.marker===a.marker&&u.open&&u.end<0){let A=!1;if((u.close||a.open)&&(u.length+a.length)%3===0&&(u.length%3!==0||a.length%3!==0)&&(A=!0),!A){const m=c>0&&!e[c-1].open?r[c-1]+1:0;r[s]=s-c+m,r[c]=m,a.open=!1,u.end=s,u.close=!1,d=-1,o=-2;break}}}d!==-1&&(t[a.marker][(a.open?3:0)+(a.length||0)%3]=d)}}function b9(e){const t=e.tokens_meta,n=e.tokens_meta.length;F7(e.delimiters);for(let o=0;o0&&l++,o[t].type==="text"&&t+1=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;s||e.pos++,r[t]=e.pos}tokenize(e){const t=this.ruler.getRules(""),n=t.length,l=e.posMax,o=e.md.options.maxNesting;for(;e.pos=e.pos)throw new Error("inline rule didn't increment state.pos");break}}if(s){if(e.pos>=l)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()}parse(e,t,n,l){const o=new this.State(e,t,n,l);this.tokenize(o);const r=this.ruler2.getRules(""),s=r.length;for(let a=0;a=0))try{t.hostname=k7.toASCII(t.hostname)}catch{}return t.auth&&(t.auth=i3(t.auth)),t.hostname&&(t.hostname=i3(t.hostname)),t.pathname&&(t.pathname=i3(t.pathname)),t.search&&(t.search=i3(t.search)),t.hash&&(t.hash=i3(t.hash)),ft(t)}normalizeLinkText(e){const t=At(e,!0);if(t.hostname&&(!t.protocol||B7.indexOf(t.protocol)>=0))try{t.hostname=k7.toUnicode(t.hostname)}catch{}return fe(ft(t),fe.defaultChars+"%")}constructor(...e){h1(this,"inline",new pn),h1(this,"block",new dn),h1(this,"core",new sn),h1(this,"renderer",new ln),h1(this,"linkify",new Ri),h1(this,"utils",Yi),h1(this,"helpers",Object.assign({},ic));const[t,n]=e;typeof t=="string"?(this.configure(t),n&&this.set(n)):(this.configure("default"),this.set(t||{}))}set(e){return Object.assign(this.options,e),this}configure(e){let t;if(typeof e=="string"){const o=e;if(t=C9[o],!t)throw new Error(`Wrong 'markdown-it' preset "${o}", check name`)}else t=e;if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");t.options&&(this.options={...t.options});const n=t.components;if(n){var l;["core","block","inline"].forEach(r=>{var s;const a=(s=n[r])===null||s===void 0?void 0:s.rules;a&&this[r].ruler.enableOnly(a)});const o=(l=n.inline)===null||l===void 0?void 0:l.rules2;o&&this.inline.ruler2.enableOnly(o)}return this}enable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(o=>{n=n.concat(this[o].ruler.enable(e,!0))}),n=n.concat(this.inline.ruler2.enable(e,!0));const l=e.filter(o=>n.indexOf(o)<0);if(l.length&&!t)throw new Error(`MarkdownIt. Failed to enable unknown rule(s): ${l}`);return this}disable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(o=>{n=n.concat(this[o].ruler.disable(e,!0))}),n=n.concat(this.inline.ruler2.disable(e,!0));const l=e.filter(o=>n.indexOf(o)<0);if(l.length&&!t)throw new Error(`MarkdownIt. Failed to disable unknown rule(s): ${l}`);return this}use(e,...t){return e.apply(e,[this,...t]),this}parse(e,t){if(typeof e!="string")throw new Error("Input data should be a String");const n=new this.core.State(e,this,t);return this.core.process(n),n.tokens}render(e,t={}){return this.renderer.render(this.parse(e,t),this.options,t)}parseInline(e,t){const n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens}renderInline(e,t={}){return this.renderer.render(this.parseInline(e,t),this.options,t)}};h1(q2,"Token",U3);h1(q2,"Ruler",a4);h1(q2,"Renderer",ln);h1(q2,"ParserCore",sn);h1(q2,"StateCore",on);h1(q2,"ParserBlock",dn);h1(q2,"StateBlock",an);h1(q2,"ParserInline",pn);h1(q2,"StateInline",fn);var _9=en(q2);const I9=["innerHTML"],B2=$1({__name:"Markdown",props:{source:{},class:{}},setup(e){const t=e,n=new _9({html:!1,linkify:!0,breaks:!1}),l=t1(()=>n.render(t.source??"")),o=["prose prose-sm max-w-none","prose-headings:text-foreground prose-headings:font-semibold","prose-p:text-muted-foreground prose-li:text-muted-foreground","prose-strong:text-foreground prose-em:text-foreground","prose-a:text-primary prose-a:no-underline hover:prose-a:underline","prose-code:text-foreground prose-code:before:content-none prose-code:after:content-none","prose-code:rounded prose-code:bg-muted/60 prose-code:px-1 prose-code:py-0.5","prose-pre:bg-muted/50 prose-pre:text-foreground prose-pre:border","prose-blockquote:border-border prose-blockquote:text-muted-foreground","prose-hr:border-border prose-th:text-foreground prose-td:text-muted-foreground"].join(" ");return(r,s)=>(h(),C("div",{class:f1(f(E1)(f(o),t.class)),innerHTML:l.value},null,10,I9))}}),M9={key:0,class:"space-y-2 border-b bg-muted/30 p-3"},E9={class:"px-3 py-2"},D9={key:0,class:"overflow-x-auto border-t bg-destructive/10 px-3 py-2 font-mono text-xs"},Z9={key:1,class:"overflow-x-auto border-t bg-success/10 px-3 py-2 font-mono text-xs"},F9={key:1,class:"p-4 text-sm text-muted-foreground"},B9={key:2,class:"overflow-x-auto"},S9={class:"w-full border-collapse font-mono text-xs leading-relaxed"},R9={class:"w-12 select-none border-r px-2 text-right align-top text-muted-foreground"},Q9={class:"w-12 select-none border-r px-2 text-right align-top text-muted-foreground"},N9={class:"w-4 select-none pl-2 align-top text-muted-foreground"},K9={class:"whitespace-pre-wrap break-all py-0.5 pr-3 align-top"},G9={colspan:"4",class:"px-3 py-2"},O9={class:"px-3 py-2"},$9={key:0,class:"overflow-x-auto border-t bg-destructive/10 px-3 py-2 font-mono text-xs"},W9={key:1,class:"overflow-x-auto border-t bg-success/10 px-3 py-2 font-mono text-xs"},L9=$1({__name:"Diff",props:{patch:{default:""},notes:{default:()=>[]},class:{}},setup(e){const t=e,n={neutral:"bg-card",info:"border-primary/30 bg-primary/5",success:"border-success/40 bg-success/5",warning:"border-warning/40 bg-warning/5",danger:"border-destructive/40 bg-destructive/5"};function l(d){return d.severity==="blocking"?n.danger:n[d.tone??"neutral"]??n.neutral}const o=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,r=t1(()=>{const d=[];let u=0,A=0,m=!1;for(const p of(t.patch??"").split(` +`)){const y=o.exec(p);if(y){u=Number(y[1]),A=Number(y[2]),m=!0,d.push({kind:"hunk",text:p,before:null,after:null});continue}m&&(p.startsWith("+")?d.push({kind:"added",text:p.slice(1),before:null,after:A++}):p.startsWith("-")?d.push({kind:"removed",text:p.slice(1),before:u++,after:null}):p.startsWith("\\")?d.push({kind:"meta",text:p,before:null,after:null}):d.push({kind:"kept",text:p.slice(1),before:u++,after:A++}))}return d}),s={added:"bg-success/10",removed:"bg-destructive/10",hunk:"bg-muted/60 text-muted-foreground",meta:"text-muted-foreground",kept:""},a={added:"+",removed:"-",kept:" ",hunk:"",meta:""},i=t1(()=>{const d=new Map;for(const u of t.notes??[])u.line&&d.set(u.line,[...d.get(u.line)??[],u]);return d}),c=t1(()=>(t.notes??[]).filter(d=>!d.line));return(d,u)=>(h(),C("div",{class:f1(f(E1)("overflow-hidden rounded-md border",t.class))},[c.value.length?(h(),C("div",M9,[(h(!0),C(n1,null,_1(c.value,(A,m)=>(h(),C("div",{key:m,class:f1(["rounded border text-sm",l(A)])},[b("div",E9,[A.from?(h(),G($e,{key:0,tone:A.severity==="blocking"?"danger":A.tone??"neutral",title:String(A.from),label:String(A.from).toLowerCase(),class:"mr-2"},null,8,["tone","title","label"])):P("",!0),I(B2,{source:A.detail,class:"inline [&>p]:inline"},null,8,["source"])]),A.replacing?(h(),C("pre",D9,N(A.replacing),1)):P("",!0),A.code?(h(),C("pre",Z9,N(A.code),1)):P("",!0)],2))),128))])):P("",!0),r.value.length?(h(),C("div",B9,[b("table",S9,[b("tbody",null,[(h(!0),C(n1,null,_1(r.value,(A,m)=>(h(),C(n1,{key:m},[b("tr",{class:f1(s[A.kind])},[b("td",R9,N(A.before??""),1),b("td",Q9,N(A.after??""),1),b("td",N9,N(a[A.kind]),1),b("td",K9,N(A.text),1)],2),(h(!0),C(n1,null,_1(i.value.get(A.after??-1)??[],(p,y)=>(h(),C("tr",{key:`${m}-${y}`},[b("td",G9,[b("div",{class:f1(["rounded border font-sans text-sm",l(p)])},[b("div",O9,[p.from?(h(),G($e,{key:0,tone:p.severity==="blocking"?"danger":p.tone??"neutral",title:String(p.from),label:String(p.from).toLowerCase(),class:"mr-2"},null,8,["tone","title","label"])):P("",!0),I(B2,{source:p.detail,class:"inline [&>p]:inline"},null,8,["source"])]),p.replacing?(h(),C("pre",$9,N(p.replacing),1)):P("",!0),p.code?(h(),C("pre",W9,N(p.code),1)):P("",!0)],2)])]))),128))],64))),128))])])])):(h(),C("div",F9," Nothing to show for this one. It may be a file git stores whole rather than as lines. "))],2))}}),P9={class:"flex items-center gap-2.5"},H9=$1({__name:"Logo",props:{size:{default:"md"},showText:{type:Boolean,default:!0}},setup(e){const t={sm:"h-7 w-7 min-h-7 min-w-7",md:"h-8 w-8 min-h-8 min-w-8",lg:"h-10 w-10 min-h-10 min-w-10"},n={sm:"text-base",md:"text-lg",lg:"text-xl"};return(l,o)=>(h(),C("div",P9,[b("div",{class:f1([t[e.size],"relative flex-shrink-0"])},[...o[0]||(o[0]=[go('',1)])],2),e.showText?(h(),C("span",{key:0,class:f1([n[e.size],"font-semibold tracking-tight"])},[...o[1]||(o[1]=[b("span",{class:"text-brand"},"Source",-1),b("span",{class:"text-brand"},"Ant",-1),b("span",{class:"text-muted-foreground font-normal ml-1"},"Memory",-1)])],2)):P("",!0)]))}}),T9={key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4"},Tt=$1({__name:"Modal",props:{open:{type:Boolean},class:{},maxWidth:{default:"lg"}},emits:["close"],setup(e,{emit:t}){const n=e,l=t,o={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"};function r(s){s.key==="Escape"&&l("close")}return d2(()=>window.addEventListener("keydown",r)),f4(()=>window.removeEventListener("keydown",r)),(s,a)=>(h(),G(El,{to:"body"},[I(r0,{"enter-active-class":"transition duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:w(()=>[e.open?(h(),C("div",T9,[b("div",{class:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:a[0]||(a[0]=i=>l("close"))}),I(z1,{class:f1(f(E1)("relative w-full max-h-[85vh] overflow-auto p-6 animate-fade-up",o[e.maxWidth],n.class))},{default:w(()=>[b("button",{class:"absolute top-4 right-4 p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",onClick:a[1]||(a[1]=i=>l("close"))},[I(f($t),{class:"h-4 w-4"})]),K1(s.$slots,"default")]),_:3},8,["class"])])):P("",!0)]),_:3})]))}}),Y9=["role"],V9={class:"min-w-0 flex-1"},u2=$1({__name:"Notice",props:{tone:{default:"info"},icon:{type:Boolean,default:!0},class:{}},setup(e){const t=e,n={info:"border-border bg-muted/50 text-foreground",success:"border-success/40 bg-success/10 text-foreground",warning:"border-warning/40 bg-warning/10 text-foreground",danger:"border-destructive/40 bg-destructive/10 text-foreground"},l={info:Va,success:Ya,warning:za,danger:Ta},o={info:"text-muted-foreground",success:"text-success",warning:"text-warning",danger:"text-destructive"},r=t1(()=>l[t.tone]);return(s,a)=>(h(),C("div",{class:f1(f(E1)("flex gap-3 rounded-md border px-4 py-3 text-sm",n[e.tone],t.class)),role:e.tone==="danger"?"alert":"status"},[e.icon?(h(),G(k2(r.value),{key:0,class:f1(f(E1)("mt-0.5 h-4 w-4 shrink-0",o[e.tone]))},null,8,["class"])):P("",!0),b("div",V9,[K1(s.$slots,"default")]),K1(s.$slots,"actions")],10,Y9))}}),U9={class:"relative flex h-2 w-2 shrink-0"},J9={key:0,class:"text-muted-foreground tabular-nums"},mn=$1({__name:"Status",props:{tone:{default:"neutral"},label:{},count:{default:null},busy:{type:Boolean,default:!1},class:{}},setup(e){const t=e,n={neutral:"bg-muted-foreground",info:"bg-primary",success:"bg-success",warning:"bg-warning",danger:"bg-destructive"},l={neutral:"text-muted-foreground",info:"text-foreground",success:"text-foreground",warning:"text-foreground",danger:"text-foreground"},o=t1(()=>t.count===null||t.count===void 0?null:t.count);return(r,s)=>(h(),C("span",{class:f1(f(E1)("inline-flex items-center gap-2 text-sm font-medium",l[e.tone],t.class)),role:"status"},[b("span",U9,[e.busy?(h(),C("span",{key:0,class:f1(f(E1)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-60",n[e.tone]))},null,2)):P("",!0),b("span",{class:f1(f(E1)("relative inline-flex h-2 w-2 rounded-full",n[e.tone]))},null,2)]),b("span",null,N(e.label),1),o.value!==null?(h(),C("span",J9,N(o.value),1)):P("",!0)],2))}}),z9={key:0,class:"mb-3 flex justify-center text-muted-foreground"},j9={key:1,class:"mx-auto mt-1 max-w-lg text-sm text-muted-foreground"},X9={key:2,class:"mt-4 flex flex-wrap items-center justify-center gap-2"},We=$1({__name:"Empty",props:{title:{},compact:{type:Boolean,default:!1},class:{}},setup(e){const t=e;return(n,l)=>(h(),G(z1,{class:f1(f(E1)("px-6 text-center",t.compact?"py-8":"py-16",t.class))},{default:w(()=>[n.$slots.icon?(h(),C("div",z9,[K1(n.$slots,"icon")])):P("",!0),b("h2",{class:f1(f(E1)("font-semibold",t.compact?"text-base":"text-lg"))},N(e.title),3),n.$slots.default?(h(),C("p",j9,[K1(n.$slots,"default")])):P("",!0),n.$slots.actions?(h(),C("div",X9,[K1(n.$slots,"actions")])):P("",!0)]),_:3},8,["class"]))}}),q9={class:"relative flex items-center justify-center"},eu={key:0,class:"max-w-md text-sm text-muted-foreground"},tu=$1({__name:"Loading",props:{label:{default:"Working"},note:{},size:{default:"md"},fill:{type:Boolean,default:!0},class:{}},setup(e){const t=e,n={sm:"h-5 w-5",md:"h-8 w-8",lg:"h-10 w-10"},l={sm:"text-sm",md:"text-base",lg:"text-lg"},o=t1(()=>t.size==="sm"?"py-8":"py-16");return(r,s)=>(h(),C("div",{class:f1(f(E1)("flex flex-col items-center justify-center gap-3 text-center",e.fill?"min-h-0 flex-1":o.value,t.class)),role:"status","aria-live":"polite"},[b("span",q9,[b("span",{class:f1(f(E1)("absolute inline-flex animate-ping rounded-full bg-primary/20",n[e.size]))},null,2),I(f(Ua),{class:f1(f(E1)("relative animate-spin text-muted-foreground",n[e.size]))},null,8,["class"])]),b("p",{class:f1(f(E1)("font-medium",l[e.size]))},N(e.label),3),e.note||r.$slots.default?(h(),C("p",eu,[K1(r.$slots,"default",{},()=>[U(N(e.note),1)])])):P("",!0)],2))}}),nu={key:0,class:"shrink-0"},lu={class:"truncate"},gn=$1({__name:"Origin",props:{name:{},mono:{type:Boolean,default:!0},class:{}},setup(e){const t=e;return(n,l)=>(h(),C("span",{class:f1(f(E1)("inline-flex max-w-full items-center gap-1 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] text-muted-foreground",t.mono&&"font-mono",t.class))},[n.$slots.icon?(h(),C("span",nu,[K1(n.$slots,"icon")])):P("",!0),b("span",lu,N(e.name),1)],2))}}),ou={class:"font-semibold"},ru={class:"mt-3"},O3=$1({__name:"Section",props:{title:{},tone:{default:"neutral"},count:{default:null},collapsible:{type:Boolean,default:!1},closed:{type:Boolean,default:!1},class:{}},setup(e){const t=e,n=z(!t.closed),l={neutral:"text-muted-foreground",info:"text-primary",success:"text-success",warning:"text-warning",danger:"text-destructive"},o={neutral:"bg-muted text-muted-foreground",info:"bg-primary/10 text-primary",success:"bg-success/10 text-success",warning:"bg-warning/10 text-warning",danger:"bg-destructive/10 text-destructive"},r=t1(()=>t.collapsible?n.value:!0);return(s,a)=>(h(),C("section",{class:f1(f(E1)("py-4 first:pt-0 last:pb-0",t.class))},[(h(),G(k2(e.collapsible?"button":"div"),{type:e.collapsible?"button":void 0,"aria-expanded":e.collapsible?String(n.value):void 0,class:f1(f(E1)("flex w-full items-center gap-2 text-left",e.collapsible&&"cursor-pointer")),onClick:a[0]||(a[0]=i=>e.collapsible&&(n.value=!n.value))},{default:w(()=>[s.$slots.icon?(h(),C("span",{key:0,class:f1(f(E1)("shrink-0",l[e.tone]))},[K1(s.$slots,"icon")],2)):P("",!0),b("h2",ou,N(e.title),1),e.count!==null?(h(),C("span",{key:1,class:f1(f(E1)("rounded-full px-2 py-0.5 text-xs font-medium tabular-nums",o[e.tone]))},N(e.count),3)):P("",!0),e.collapsible?(h(),G(f(Ha),{key:2,class:f1(f(E1)("ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform",n.value&&"rotate-180"))},null,8,["class"])):P("",!0)]),_:3},8,["type","aria-expanded","class"])),Ne(b("div",ru,[K1(s.$slots,"default")],512),[[Oo,r.value]])],2))}});/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const su=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S7=e=>e==="";/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const au=(...e)=>e.filter((t,n,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===n).join(" ").trim();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const R7=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iu=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,l)=>l?l.toUpperCase():n.toLowerCase());/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cu=e=>{const t=iu(e);return t.charAt(0).toUpperCase()+t.slice(1)};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Me={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const uu=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":l,strokeWidth:o,"stroke-width":r,size:s=Me.width,color:a=Me.stroke,...i},{slots:c})=>A3("svg",{...Me,...i,width:s,height:s,stroke:a,"stroke-width":S7(n)||S7(l)||n===!0||l===!0?Number(o||r||Me["stroke-width"])*24/Number(s):o||r||Me["stroke-width"],class:au("lucide",i.class,...e?[`lucide-${R7(cu(e))}-icon`,`lucide-${R7(e)}`]:["lucide-icon"]),...!c.default&&!su(i)&&{"aria-hidden":"true"}},[...t.map(d=>A3(...d)),...c.default?[c.default()]:[]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const F1=(e,t)=>(n,{slots:l,attrs:o})=>A3(uu,{...o,...n,iconNode:t,name:e},l);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yt=F1("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const du=F1("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vn=F1("book-open-check",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S4=F1("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i4=F1("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fu=F1("bug",[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const he=F1("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Au=F1("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Q7=F1("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hu=F1("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pu=F1("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pt=F1("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mu=F1("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const p5=F1("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const N7=F1("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m5=F1("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gu=F1("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yn=F1("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const V4=F1("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bn=F1("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const M2=F1("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vu=F1("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yu=F1("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kn=F1("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g5=F1("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bu=F1("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const h3=F1("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cn=F1("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ku=F1("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c4=F1("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wn=F1("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mt=F1("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Le=F1("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gt=F1("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xn=F1("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const h4=F1("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cu=F1("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _n=F1("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const In=F1("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Q2(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">")}function wu(e){var t,n,l,o,r,s,a;const i=(t=e.meta)===null||t===void 0?void 0:t.title,c=(n=e.meta)===null||n===void 0?void 0:n.creator,d=(l=e.meta)===null||l===void 0?void 0:l.source,u=(r=(o=e.meta)===null||o===void 0?void 0:o.license)===null||r===void 0?void 0:r.url,A=xu(e);return!i&&!c&&!d&&!u&&!A?"":''+(i?`${Q2(i)}`:"")+(c?`${Q2(c)}`:"")+(d?`${Q2((a=(s=e.meta)===null||s===void 0?void 0:s.source)!==null&&a!==void 0?a:"")}`:"")+(u?`${Q2(u)}`:"")+(A?`${Q2(A)}`:"")+""}function xu(e){var t,n,l,o,r,s,a,i,c,d,u,A,m,p,y;let k=!((t=e.meta)===null||t===void 0)&&t.title?`„${(n=e.meta)===null||n===void 0?void 0:n.title}”`:"Design",F=`„${(o=(l=e.meta)===null||l===void 0?void 0:l.creator)!==null&&o!==void 0?o:"Unknown"}”`;!((r=e.meta)===null||r===void 0)&&r.source&&(k+=` (${e.meta.source})`);let M="";return((a=(s=e.meta)===null||s===void 0?void 0:s.license)===null||a===void 0?void 0:a.name)!=="MIT"&&((i=e.meta)===null||i===void 0?void 0:i.creator)!=="DiceBear"&&(!((c=e.meta)===null||c===void 0)&&c.title)&&(M+="Remix of "),M+=`${k} by ${F}`,!((u=(d=e.meta)===null||d===void 0?void 0:d.license)===null||u===void 0)&&u.name&&(M+=`, licensed under „${(m=(A=e.meta)===null||A===void 0?void 0:A.license)===null||m===void 0?void 0:m.name}”`,!((y=(p=e.meta)===null||p===void 0?void 0:p.license)===null||y===void 0)&&y.url&&(M+=` (${e.meta.license.url})`)),M}const K7=-2147483648,_u=2147483647,Iu=1024;function Mn(e){return e^=e<<13,e^=e>>17,e^=e<<5,e}function Mu(e){let t=0;for(let n=0;nt=Mn(t),l=(o,r)=>Math.floor((n()-K7)/(_u-K7)*(r+1-o)+o);return{seed:e,next:n,bool(o=50){return l(1,100)<=o},integer(o,r){return l(o,r)},pick(o,r){var s;return o.length===0?(n(),r):(s=o[l(0,o.length-1)])!==null&&s!==void 0?s:r},shuffle(o){const r=U4(n().toString()),s=[...o];for(let a=s.length-1;a>0;a--){const i=r.integer(0,a);[s[a],s[i]]=[s[i],s[a]]}return s},string(o,r="abcdefghijklmnopqrstuvwxyz1234567890"){const s=U4(n().toString());let a="";for(let i=0;i`;switch(l){case"solid":return c+e.body;case"gradientLinear":return``+e.body}}function Du(e,t){let{width:n,height:l,x:o,y:r}=ve(e),s=t?(t-100)/100:0,a=(n/2+o)*s*-1,i=(l/2+r)*s*-1;return`${e.body}`}function Zu(e,t,n){let l=ve(e),o=(l.width+l.x*2)*((t??0)/100),r=(l.height+l.y*2)*((n??0)/100);return`${e.body}`}function Fu(e,t){let{width:n,height:l,x:o,y:r}=ve(e);return`${e.body}`}function Bu(e){let{width:t,x:n}=ve(e);return`${e.body}`}function Su(e,t){let{width:n,height:l,x:o,y:r}=ve(e),s=t?n*t/100:0,a=t?l*t/100:0;return`${e.body}`}function Ru(e){const t={xmlns:"http://www.w3.org/2000/svg",...e.attributes};return Object.keys(t).map(n=>`${Q2(n)}="${Q2(t[n])}"`).join(" ")}function Qu(e){const t=U4(Math.random().toString()),n={};return e.body.replace(/(id="|url\(#)([a-z0-9-_]+)([")])/gi,(l,o,r,s)=>(n[r]=n[r]||t.string(8),`${o}${n[r]}${s}`))}const Nu={properties:{seed:{type:"string"},flip:{type:"boolean",default:!1},rotate:{type:"integer",minimum:0,maximum:360,default:0},scale:{type:"integer",minimum:0,maximum:200,default:100},radius:{type:"integer",minimum:0,maximum:50,default:0},size:{type:"integer",minimum:1},backgroundColor:{type:"array",items:{type:"string",pattern:"^(transparent|[a-fA-F0-9]{6})$"}},backgroundType:{type:"array",items:{type:"string",enum:["solid","gradientLinear"]},default:["solid"]},backgroundRotation:{type:"array",items:{type:"integer",minimum:-360,maximum:360},default:[0,360]},translateX:{type:"integer",minimum:-100,maximum:100,default:0},translateY:{type:"integer",minimum:-100,maximum:100,default:0},clip:{type:"boolean",default:!0},randomizeIds:{type:"boolean",default:!1}}};function G7(e){var t;let n={},l=(t=e.properties)!==null&&t!==void 0?t:{};return Object.keys(l).forEach(o=>{let r=l[o];typeof r=="object"&&r.default!==void 0&&(Array.isArray(r.default)?n[o]=[...r.default]:typeof r.default=="object"?n[o]={...r.default}:n[o]=r.default)}),n}function Ku(e,t){var n;let l={...G7(Nu),...G7((n=e.schema)!==null&&n!==void 0?n:{}),...t};return JSON.parse(JSON.stringify(l))}function O7(e){return e==="transparent"?e:`#${e}`}function Gu(e,t,n){var l;let o=e.shuffle(t);o.length<=1||t.length==2&&n=="gradientLinear"?(o=t,e.next()):o=e.shuffle(t),o.length===0&&(o=["transparent"]);const r=o[0],s=(l=o[1])!==null&&l!==void 0?l:o[0];return{primary:O7(r),secondary:O7(s)}}function Ou(e,t={}){var n,l,o,r,s;t=Ku(e,t);const a=U4(t.seed),i=e.create({prng:a,options:t}),c=a.pick((n=t.backgroundType)!==null&&n!==void 0?n:[],"solid"),{primary:d,secondary:u}=Gu(a,(l=t.backgroundColor)!==null&&l!==void 0?l:[],c),A=a.integer(!((o=t.backgroundRotation)===null||o===void 0)&&o.length?Math.min(...t.backgroundRotation):0,!((r=t.backgroundRotation)===null||r===void 0)&&r.length?Math.max(...t.backgroundRotation):0);t.size&&(i.attributes.width=t.size.toString(),i.attributes.height=t.size.toString()),t.scale!==void 0&&t.scale!==100&&(i.body=Du(i,t.scale)),t.flip&&(i.body=Bu(i)),t.rotate&&(i.body=Fu(i,t.rotate)),(t.translateX||t.translateY)&&(i.body=Zu(i,t.translateX,t.translateY)),d!=="transparent"&&u!=="transparent"&&(i.body=Eu(i,d,u,c,A)),(t.radius||t.clip)&&(i.body=Su(i,(s=t.radius)!==null&&s!==void 0?s:0)),t.randomizeIds&&(i.body=Qu(i));const m=Ru(i),p=wu(e),y=`${p}${i.body}`;return{toString:()=>y,toJson:()=>{var k;return{svg:y,extra:{primaryBackgroundColor:d,secondaryBackgroundColor:u,backgroundType:c,backgroundRotation:A,...(k=i.extra)===null||k===void 0?void 0:k.call(i)}}},toDataUri:()=>`data:image/svg+xml;utf8,${encodeURIComponent(y)}`}}const $u={variant01:(e,t)=>''},Wu={variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant09:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant08:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant07:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant06:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant05:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant04:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant03:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant02:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`},variant01:(e,t)=>{var n,l;return`${(l=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&l!==void 0?l:""}`}},Lu={variant63:(e,t)=>'',variant62:(e,t)=>'',variant61:(e,t)=>'',variant60:(e,t)=>'',variant59:(e,t)=>'',variant58:(e,t)=>'',variant57:(e,t)=>'',variant56:(e,t)=>'',variant55:(e,t)=>'',variant54:(e,t)=>'',variant53:(e,t)=>'',variant52:(e,t)=>'',variant51:(e,t)=>'',variant50:(e,t)=>'',variant49:(e,t)=>'',variant48:(e,t)=>'',variant47:(e,t)=>'',variant46:(e,t)=>'',variant45:(e,t)=>'',variant44:(e,t)=>'',variant43:(e,t)=>'',variant42:(e,t)=>'',variant41:(e,t)=>'',variant40:(e,t)=>'',variant39:(e,t)=>'',variant38:(e,t)=>'',variant37:(e,t)=>'',variant36:(e,t)=>'',variant35:(e,t)=>'',variant34:(e,t)=>'',variant33:(e,t)=>'',variant32:(e,t)=>'',variant31:(e,t)=>'',variant30:(e,t)=>'',variant29:(e,t)=>'',variant28:(e,t)=>'',variant27:(e,t)=>'',variant26:(e,t)=>'',variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>'',hat:(e,t)=>''},Pu={variant30:(e,t)=>'',variant29:(e,t)=>'',variant28:(e,t)=>'',variant27:(e,t)=>'',variant26:(e,t)=>'',variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Hu={variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Tu={variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Yu={variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Vu={variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Uu={variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},Ju={wavePointLongArms:(e,t)=>'',waveOkLongArms:(e,t)=>'',waveLongArms:(e,t)=>'',waveLongArm:(e,t)=>'',pointLongArm:(e,t)=>'',okLongArm:(e,t)=>'',point:(e,t)=>'',ok:(e,t)=>'',hand:(e,t)=>'',handPhone:(e,t)=>''},zu={electric:(e,t)=>'',saturn:(e,t)=>'',galaxy:(e,t)=>''},ju=Object.freeze(Object.defineProperty({__proto__:null,base:$u,beard:Hu,body:Wu,bodyIcon:zu,brows:Uu,eyes:Yu,gesture:Ju,glasses:Vu,hair:Lu,lips:Pu,nose:Tu},Symbol.toStringTag,{value:"Module"}));function Z2({prng:e,group:t,values:n=[]}){const l=ju,o=e.pick(n);if(o&&l[t][o])return{name:o,value:l[t][o]}}function Xu({prng:e,options:t}){const n=Z2({prng:e,group:"base",values:t.base}),l=Z2({prng:e,group:"body",values:t.body}),o=Z2({prng:e,group:"hair",values:t.hair}),r=Z2({prng:e,group:"lips",values:t.lips}),s=Z2({prng:e,group:"beard",values:t.beard}),a=Z2({prng:e,group:"nose",values:t.nose}),i=Z2({prng:e,group:"eyes",values:t.eyes}),c=Z2({prng:e,group:"glasses",values:t.glasses}),d=Z2({prng:e,group:"brows",values:t.brows}),u=Z2({prng:e,group:"gesture",values:t.gesture}),A=Z2({prng:e,group:"bodyIcon",values:t.bodyIcon});return{base:n,body:l,hair:o,lips:r,beard:e.bool(t.beardProbability)?s:void 0,nose:a,eyes:i,glasses:e.bool(t.glassesProbability)?c:void 0,brows:d,gesture:e.bool(t.gestureProbability)?u:void 0,bodyIcon:e.bool(t.bodyIconProbability)?A:void 0}}function qu({prng:e,options:t}){return{}}const ed={$schema:"http://json-schema.org/draft-07/schema#",properties:{base:{type:"array",items:{type:"string",enum:["variant01"]},default:["variant01"]},beard:{type:"array",items:{type:"string",enum:["variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},beardProbability:{type:"integer",minimum:0,maximum:100,default:10},body:{type:"array",items:{type:"string",enum:["variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},bodyIcon:{type:"array",items:{type:"string",enum:["electric","saturn","galaxy"]},default:["electric","saturn","galaxy"]},bodyIconProbability:{type:"integer",minimum:0,maximum:100,default:75},brows:{type:"array",items:{type:"string",enum:["variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},eyes:{type:"array",items:{type:"string",enum:["variant05","variant04","variant03","variant02","variant01"]},default:["variant05","variant04","variant03","variant02","variant01"]},gesture:{type:"array",items:{type:"string",enum:["wavePointLongArms","waveOkLongArms","waveLongArms","waveLongArm","pointLongArm","okLongArm","point","ok","hand","handPhone"]},default:["wavePointLongArms","waveOkLongArms","waveLongArms","waveLongArm","pointLongArm","okLongArm","point","ok","hand","handPhone"]},gestureProbability:{type:"integer",minimum:0,maximum:100,default:10},glasses:{type:"array",items:{type:"string",enum:["variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},glassesProbability:{type:"integer",minimum:0,maximum:100,default:20},hair:{type:"array",items:{type:"string",enum:["variant63","variant62","variant61","variant60","variant59","variant58","variant57","variant56","variant55","variant54","variant53","variant52","variant51","variant50","variant49","variant48","variant47","variant46","variant45","variant44","variant43","variant42","variant41","variant40","variant39","variant38","variant37","variant36","variant35","variant34","variant33","variant32","variant31","variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01","hat"]},default:["variant63","variant62","variant61","variant60","variant59","variant58","variant57","variant56","variant55","variant54","variant53","variant52","variant51","variant50","variant49","variant48","variant47","variant46","variant45","variant44","variant43","variant42","variant41","variant40","variant39","variant38","variant37","variant36","variant35","variant34","variant33","variant32","variant31","variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01","hat"]},lips:{type:"array",items:{type:"string",enum:["variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},nose:{type:"array",items:{type:"string",enum:["variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]}}},td={title:"Notionists",creator:"Zoish",source:"https://heyzoish.gumroad.com/l/notionists",homepage:"https://bio.link/heyzoish",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},nd=({prng:e,options:t})=>{var n,l,o,r,s,a,i,c,d,u,A,m,p,y,k,F,M,E,_,R;const $=Xu({prng:e,options:t}),D=qu({prng:e,options:t});return{attributes:{viewBox:"0 0 1744 1744",fill:"none","shape-rendering":"auto"},body:`${(l=(n=$.base)===null||n===void 0?void 0:n.value($,D))!==null&&l!==void 0?l:""}${(r=(o=$.body)===null||o===void 0?void 0:o.value($,D))!==null&&r!==void 0?r:""}${(a=(s=$.hair)===null||s===void 0?void 0:s.value($,D))!==null&&a!==void 0?a:""}${(c=(i=$.lips)===null||i===void 0?void 0:i.value($,D))!==null&&c!==void 0?c:""}${(u=(d=$.beard)===null||d===void 0?void 0:d.value($,D))!==null&&u!==void 0?u:""}${(m=(A=$.nose)===null||A===void 0?void 0:A.value($,D))!==null&&m!==void 0?m:""}${(y=(p=$.eyes)===null||p===void 0?void 0:p.value($,D))!==null&&y!==void 0?y:""}${(F=(k=$.glasses)===null||k===void 0?void 0:k.value($,D))!==null&&F!==void 0?F:""}${(E=(M=$.brows)===null||M===void 0?void 0:M.value($,D))!==null&&E!==void 0?E:""}${(R=(_=$.gesture)===null||_===void 0?void 0:_.value($,D))!==null&&R!==void 0?R:""}`,extra:()=>({...Object.entries($).reduce((x,[Q,B])=>(x[Q]=B==null?void 0:B.name,x),{}),...Object.entries(D).reduce((x,[Q,B])=>(x[`${Q}Color`]=B,x),{})})}},ld=Object.freeze(Object.defineProperty({__proto__:null,create:nd,meta:td,schema:ed},Symbol.toStringTag,{value:"Module"})),vt=z(!0);function $7(e){vt.value=e,document.documentElement.classList.toggle("dark",e),document.documentElement.classList.toggle("light",!e);try{localStorage.setItem("sourceant-theme",e?"dark":"light")}catch{}}function En(){return{isDark:vt,toggleTheme:()=>$7(!vt.value),restoreTheme:()=>{let e=null;try{e=localStorage.getItem("sourceant-theme")}catch{e=null}$7(e!=="light")}}}async function j1(e,t={}){const n=await fetch(e,{...t,headers:t.body?{"Content-Type":"application/json"}:void 0}),l=await n.text(),o=l?JSON.parse(l):null;if(!n.ok)throw new Error((o==null?void 0:o.error)||`the agent answered ${n.status}`);return o}const F2=e=>new URLSearchParams(Object.entries(e).filter(([,t])=>t!==""&&t!==!1)),B1={status:()=>j1("/health"),repositories:()=>j1("/api/repositories"),addRepository:(e,t)=>j1("/api/repositories",{method:"POST",body:JSON.stringify({path:e,name:t})}),dropRepository:e=>j1(`/api/repositories?${F2({path:e})}`,{method:"DELETE"}),index:(e="",{everything:t=!1,update:n=!1}={})=>j1("/api/index",{method:"POST",body:JSON.stringify({repository:e,everything:t,update:n})}),attention:e=>j1(`/api/attention?${F2({repository:e})}`),graph:(e,{includeTests:t=!1,pathPrefix:n=""}={})=>j1(`/api/graph?${F2({repository:e,include_tests:t,path_prefix:n})}`),knowledge:e=>j1(`/api/knowledge?${F2({repository:e,limit:100})}`),recordKnowledge:e=>j1("/api/knowledge",{method:"PUT",body:JSON.stringify(e)}),forgetKnowledge:(e,t)=>j1(`/api/knowledge?${F2({repository:e,id:t})}`,{method:"DELETE"}),browse:(e="")=>j1(`/api/browse?${F2({path:e})}`),initialize:(e,{dryRun:t=!1,useModel:n=!1}={})=>j1("/api/knowledge/initialize",{method:"POST",body:JSON.stringify({repository:e,dry_run:t,use_model:n})}),skills:(e="")=>j1(`/api/skills?${F2({repository:e})}`),skill:(e,t="")=>j1(`/api/skills/${e}?${F2({repository:t})}`),recordSkill:e=>j1("/api/skills",{method:"PUT",body:JSON.stringify({scope:"repository",paths:[],reviews:null,...e})}),forgetSkill:(e,t,n)=>j1(`/api/skills?${F2({repository:e,scope:t,id:n})}`,{method:"DELETE"}),startReview:(e,{against:t="",title:n="",description:l="",skills:o=[],useModel:r=!0}={})=>j1("/api/reviews",{method:"POST",body:JSON.stringify({repository:e,against:t,title:n,description:l,skills:o,use_model:r})}),reviewed:e=>j1(`/api/reviews/${e}`),reviews:(e="")=>j1(`/api/reviews?${F2({repository:e})}`),settings:()=>j1("/api/settings"),setSetting:(e,t)=>j1("/api/settings",{method:"PUT",body:JSON.stringify({key:e,value:t})}),resetSetting:e=>j1(`/api/settings?${F2({key:e})}`,{method:"DELETE"})},od={class:"space-y-4"},rd={key:0,class:"flex items-center gap-2 py-6 text-sm text-muted-foreground"},sd=["onClick"],ad=["value"],id={key:1,class:"flex items-center gap-2 text-sm"},cd=["id","onUpdate:modelValue"],ud={class:"text-muted-foreground"},dd={key:0,class:"py-6 text-sm text-muted-foreground"},fd={key:2,class:"flex items-center gap-3"},Ad={key:0,class:"text-xs text-success"},Dn={__name:"SettingsPanel",props:{group:{type:String,required:!0}},emits:["saved"],setup(e,{emit:t}){const n=e,l=t,o=z([]),r=z({}),s=z(!1),a=z(!0),i=z(""),c=z(!1),d=t1(()=>o.value.filter(E=>E.group===n.group));function u(E){return E.secret?"":E.listed?String(E.value??"").split(` +`).map(_=>_.trim()).filter(Boolean):E.value??""}const A=(E,_)=>E.listed?(_??[]).join(` +`):_,m=(E,_)=>String(A(E,_)??"")===String(E.value??""),p=t1(()=>d.value.some(E=>{const _=r.value[E.key];return E.secret?!!_:!m(E,_)}));async function y(){a.value=!0;try{o.value=await B1.settings(),r.value=Object.fromEntries(d.value.map(E=>[E.key,u(E)])),i.value=""}catch(E){i.value=E.message}finally{a.value=!1}}async function k(){s.value=!0,c.value=!1,i.value="";try{for(const E of d.value){const _=r.value[E.key];E.secret&&!_||!E.secret&&m(E,_)||await B1.setSetting(E.key,A(E,_))}await y(),c.value=!0,l("saved")}catch(E){i.value=E.message}finally{s.value=!1}}async function F(E){i.value="";try{await B1.resetSetting(E.key),await y()}catch(_){i.value=_.message}}function M(E){return E.secret?E.is_set:String(E.value??"")!==String(E.default??"")}return t2(()=>n.group,y),d2(y),(E,_)=>(h(),C("div",od,[a.value?(h(),C("p",rd,[I(f(M2),{class:"h-4 w-4 animate-spin"}),_[0]||(_[0]=U(" Reading what this machine can be told. ",-1))])):(h(),C(n1,{key:1},[(h(!0),C(n1,null,_1(d.value,R=>(h(),G(f(R2),{key:R.key,label:R.label,for:R.key,hint:R.description},{label:w(()=>[R.secret&&R.is_set?(h(),G(f(c2),{key:0,variant:"success"},{default:w(()=>[..._[1]||(_[1]=[U("set",-1)])]),_:1})):P("",!0),M(R)?(h(),C("button",{key:1,type:"button",class:"inline-flex items-center gap-1 text-[11px] font-normal normal-case tracking-normal text-muted-foreground hover:text-foreground",onClick:$=>F(R)},[I(f(ku),{class:"h-3 w-3"}),_[2]||(_[2]=U(" put back ",-1))],8,sd)):P("",!0)]),default:w(()=>{var $;return[($=R.choices)!=null&&$.length?(h(),G(f(j2),{key:0,id:R.key,modelValue:r.value[R.key],"onUpdate:modelValue":D=>r.value[R.key]=D,class:"w-full"},{default:w(()=>[(h(!0),C(n1,null,_1(R.choices,D=>(h(),C("option",{key:D,value:D},N(D),9,ad))),128))]),_:2},1032,["id","modelValue","onUpdate:modelValue"])):R.type==="bool"?(h(),C("label",id,[Ne(b("input",{id:R.key,"onUpdate:modelValue":D=>r.value[R.key]=D,type:"checkbox",class:"h-3.5 w-3.5 rounded border"},null,8,cd),[[a0,r.value[R.key]]]),b("span",ud,N(r.value[R.key]?"On":"Off"),1)])):R.listed?(h(),G(f(O0),{key:2,modelValue:r.value[R.key],"onUpdate:modelValue":D=>r.value[R.key]=D,mono:"",noun:"a folder",placeholder:"/home/you/work/knowledgebase/skills"},null,8,["modelValue","onUpdate:modelValue"])):(h(),G(f(J3),{key:3,id:R.key,modelValue:r.value[R.key],"onUpdate:modelValue":D=>r.value[R.key]=D,type:R.secret?"password":R.type==="int"||R.type==="float"?"number":"text",autocomplete:R.secret?"off":void 0,placeholder:R.secret&&R.is_set?"Leave empty to keep what is set":String(R.default??"")},null,8,["id","modelValue","onUpdate:modelValue","type","autocomplete","placeholder"]))]}),_:2},1032,["label","for","hint"]))),128)),d.value.length?P("",!0):(h(),C("p",dd," Nothing in this group is configurable here. ")),i.value?(h(),G(f(u2),{key:1,tone:"danger"},{default:w(()=>[U(N(i.value),1)]),_:1})):P("",!0),d.value.length?(h(),C("div",fd,[I(f(C1),{disabled:s.value||!p.value,onClick:k},{default:w(()=>[s.value?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(f(he),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),_[3]||(_[3]=U(" Save ",-1))]),_:1},8,["disabled"]),c.value&&!p.value?(h(),C("span",Ad,"Saved.")):P("",!0),K1(E.$slots,"after")])):P("",!0)],64))]))}},hd={class:"mb-2 text-xs font-mono text-muted-foreground break-all"},pd={class:"h-64 overflow-y-auto rounded-md border bg-muted/30"},md=["onClick"],gd={class:"truncate"},vd={key:1,class:"px-3 py-6 text-center text-sm text-muted-foreground"},yd={class:"mt-2 text-xs text-muted-foreground"},bd={class:"font-mono"},kd={class:"flex items-center gap-2 pt-5"},Zn={__name:"FolderPicker",props:{open:Boolean},emits:["close","added"],setup(e,{emit:t}){const n=e,l=t,o=z(null),r=z(""),s=z(!1),a=z("");async function i(d){try{o.value=await B1.browse(d),a.value=""}catch(u){a.value=u.message}}t2(()=>n.open,d=>{d&&(r.value="",a.value="",s.value=!1,i(""))});async function c(){if(o.value){s.value=!0,a.value="";try{await B1.addRepository(o.value.path,r.value.trim()),await B1.index("",{everything:!0}),l("added"),l("close")}catch(d){a.value=d.message}finally{s.value=!1}}}return(d,u)=>(h(),G(f(Tt),{open:e.open,"max-width":"lg",onClose:u[3]||(u[3]=A=>l("close"))},{default:w(()=>{var A,m,p,y;return[u[8]||(u[8]=b("h2",{class:"text-lg font-semibold mb-3"},"Add a folder",-1)),b("p",hd,N((A=o.value)==null?void 0:A.path),1),b("div",pd,[(m=o.value)!=null&&m.parent?(h(),C("button",{key:0,class:"flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-accent",onClick:u[0]||(u[0]=k=>i(o.value.parent))},[I(f(Au),{class:"h-3.5 w-3.5"}),u[4]||(u[4]=b("span",{class:"text-muted-foreground"},"Up one",-1))])):P("",!0),(h(!0),C(n1,null,_1(((p=o.value)==null?void 0:p.entries)??[],k=>(h(),C("button",{key:k.path,class:"flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-accent",onClick:F=>i(k.path)},[I(f(m5),{class:"h-3.5 w-3.5 text-muted-foreground"}),b("span",gd,N(k.name),1),k.repository?(h(),G(f(c2),{key:0,variant:"glow",class:"ml-auto shrink-0"},{default:w(()=>[...u[5]||(u[5]=[U("git",-1)])]),_:1})):P("",!0)],8,md))),128)),o.value&&o.value.entries.length===0?(h(),C("p",vd," Nothing inside. ")):P("",!0)]),I(f(R2),{label:"Name it (optional)",for:"repo-name",class:"mt-4"},{default:w(()=>[I(f(J3),{id:"repo-name",modelValue:r.value,"onUpdate:modelValue":u[1]||(u[1]=k=>r.value=k),placeholder:"Taken from the git remote, or the folder name"},null,8,["modelValue"])]),_:1}),b("p",yd,[u[6]||(u[6]=U(" Adding ",-1)),b("code",bd,N((y=o.value)==null?void 0:y.path),1)]),a.value?(h(),G(f(u2),{key:0,tone:"danger",class:"mt-3"},{default:w(()=>[U(N(a.value),1)]),_:1})):P("",!0),b("div",kd,[I(f(C1),{disabled:s.value||!o.value,onClick:c},{default:w(()=>[s.value?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(f(h3),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),U(" "+N(s.value?"Reading…":"Add and index"),1)]),_:1},8,["disabled"]),I(f(C1),{variant:"outline",onClick:u[2]||(u[2]=k=>l("close"))},{default:w(()=>[...u[7]||(u[7]=[U("Cancel",-1)])]),_:1})])]}),_:1},8,["open"]))}},q3=z([]),Ee=z(""),H5=z(""),T5=z(!1),Vt="";function g3({all:e=!1}={}){const t=t1(()=>e&&!Ee.value&&q3.value.length>1);async function n(){var l;T5.value=!0;try{q3.value=await B1.repositories(),H5.value=""}catch(o){q3.value=[],H5.value=`${o.message}. Is sourceant-agent running?`}finally{T5.value=!1}Ee.value===Vt&&e||q3.value.some(o=>o.name===Ee.value)||(Ee.value=((l=q3.value[0])==null?void 0:l.name)??"")}return{repositories:q3,chosen:Ee,error:H5,loading:T5,mixed:t,fetchRepositories:n}}const Cd={class:"flex items-center gap-2"},W7="sourceant-onboarded",wd={__name:"Onboarding",setup(e){const{repositories:t,fetchRepositories:n}=g3(),l=z(!1),o=z("folder"),r=z(!1),s=t1(()=>t.value.length>0);function a(){try{localStorage.setItem(W7,"yes")}catch{}l.value=!1}return d2(async()=>{let i=null;try{i=localStorage.getItem(W7)}catch{i=null}i||(await n(),l.value=t.value.length===0)}),(i,c)=>(h(),G(f(Tt),{open:l.value,"max-width":"xl",onClose:a},{default:w(()=>[o.value==="folder"?(h(),C(n1,{key:0},[c[4]||(c[4]=b("h2",{class:"text-lg font-semibold mb-1"},"Point it at some code",-1)),c[5]||(c[5]=b("p",{class:"text-sm text-muted-foreground mb-5"}," SourceAnt reads a folder on this machine into a graph, and keeps what you record about it beside the code it belongs to. Nothing leaves this machine. ",-1)),b("div",Cd,[I(f(C1),{onClick:c[0]||(c[0]=d=>r.value=!0)},{default:w(()=>[I(f(h3),{class:"mr-1.5 h-3.5 w-3.5"}),c[3]||(c[3]=U(" Add a folder ",-1))]),_:1}),I(f(C1),{variant:"outline",onClick:c[1]||(c[1]=d=>o.value="model")},{default:w(()=>[s.value?(h(),C(n1,{key:0},[U("Next")],64)):(h(),C(n1,{key:1},[U("Skip for now")],64)),I(f(du),{class:"ml-1.5 h-3.5 w-3.5"})]),_:1})]),I(Zn,{open:r.value,onClose:c[2]||(c[2]=d=>r.value=!1),onAdded:f(n)},null,8,["open","onAdded"])],64)):(h(),C(n1,{key:1},[c[7]||(c[7]=b("h2",{class:"text-lg font-semibold mb-1"},"Bring a model, or don't",-1)),c[8]||(c[8]=b("p",{class:"text-sm text-muted-foreground mb-5"}," Reading your code and reading what it already states about itself need no model at all. Proposing what nobody wrote down does. Your key stays on this machine and goes to that provider and nowhere else. ",-1)),I(Dn,{group:"Model",onSaved:a},{after:w(()=>[I(f(C1),{variant:"ghost",onClick:a},{default:w(()=>[...c[6]||(c[6]=[U("Not now",-1)])]),_:1})]),_:1})],64))]),_:1},8,["open"]))}},xd={class:"flex h-screen flex-col bg-background"},_d={class:"z-40 h-12 shrink-0 border-b bg-card/80 backdrop-blur-sm"},Id={class:"flex items-center h-full min-w-0 px-3 gap-1 sm:px-4"},Md={class:"hidden lg:flex items-center gap-0.5 min-w-0"},Ed={class:"hidden xl:inline"},Dd={class:"relative shrink-0","data-dropdown":"user"},Zd={key:0,class:"absolute top-full right-0 mt-1 w-52 bg-card border rounded-lg shadow-lg py-1 z-50"},Fd=["aria-label"],Bd={key:0,class:"lg:hidden shrink-0 border-b bg-card px-4 py-2 space-y-0.5"},Sd={class:"min-h-0 flex-1 overflow-y-auto"},Rd={class:"container mx-auto flex h-full flex-col px-4 pb-4 pt-3 lg:px-6 lg:pb-6 lg:pt-4"},Qd={__name:"App",setup(e){const{isDark:t,toggleTheme:n,restoreTheme:l}=En(),o=d5(),r=z(!1),s=z(!1),a=[{name:"Overview",href:"/",icon:yn},{name:"Knowledge",href:"/knowledge",icon:S4},{name:"Graphs",href:"/graph",icon:g5},{name:"Reviews",href:"/reviews",icon:Le},{name:"Skills",href:"/skills",icon:vn},{name:"Repositories",href:"/repositories",icon:i4},{name:"Settings",href:"/settings",icon:mt}],i=t1(()=>Ou(ld,{seed:location.hostname||"sourceant",radius:50}).toDataUri());function c(d){d.target.closest('[data-dropdown="user"]')||(s.value=!1)}return d2(()=>{l(),document.addEventListener("click",c)}),f4(()=>document.removeEventListener("click",c)),(d,u)=>{const A=Ve("RouterLink"),m=Ve("RouterView");return h(),C("div",xd,[b("header",_d,[b("div",Id,[I(A,{to:"/",class:"shrink-0 mr-1 sm:mr-3"},{default:w(()=>[I(f(H9),{size:"sm","show-text":!1})]),_:1}),u[7]||(u[7]=b("span",{class:"hidden lg:block h-4 w-px bg-border mx-1 shrink-0"},null,-1)),b("nav",Md,[(h(),C(n1,null,_1(a,p=>I(A,{key:p.href,to:p.href,title:p.name,class:f1(["flex shrink-0 items-center gap-1.5 px-2 py-1 rounded-md text-sm transition-colors 2xl:px-2.5",f(o).path===p.href?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-muted hover:text-foreground"])},{default:w(()=>[(h(),G(k2(p.icon),{class:"h-3.5 w-3.5 shrink-0"})),b("span",Ed,N(p.name),1)]),_:2},1032,["to","title","class"])),64))]),u[8]||(u[8]=b("div",{class:"flex-1 min-w-0"},null,-1)),b("div",Dd,[b("button",{class:"flex items-center gap-1.5 p-1 rounded-md hover:bg-muted transition-colors","aria-label":"Account",onClick:u[0]||(u[0]=qe(p=>s.value=!s.value,["stop"]))},[I(f(fa),{src:i.value,size:"sm",class:"h-6 w-6"},null,8,["src"])]),I(r0,{"enter-active-class":"transition duration-100 ease-out","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition duration-75 ease-in","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:w(()=>[s.value?(h(),C("div",Zd,[u[6]||(u[6]=b("div",{class:"px-3 py-2 border-b"},[b("p",{class:"text-sm font-medium truncate"},"This machine"),b("p",{class:"text-xs text-muted-foreground truncate"},"Nothing here has been shared.")],-1)),I(A,{to:"/settings",class:"flex items-center gap-2 px-3 py-1.5 text-sm hover:bg-muted transition-colors",onClick:u[1]||(u[1]=p=>s.value=!1)},{default:w(()=>[I(f(mt),{class:"h-3.5 w-3.5 text-muted-foreground"}),u[5]||(u[5]=U(" Settings ",-1))]),_:1}),b("button",{class:"flex items-center gap-2 w-full px-3 py-1.5 text-sm hover:bg-muted transition-colors",onClick:u[2]||(u[2]=(...p)=>f(n)&&f(n)(...p))},[(h(),G(k2(f(t)?f(xn):f(kn)),{class:"h-3.5 w-3.5 text-muted-foreground"})),b("span",null,N(f(t)?"Light mode":"Dark mode"),1)])])):P("",!0)]),_:1})]),b("button",{class:"lg:hidden shrink-0 p-1 rounded-md hover:bg-muted transition-colors","aria-label":r.value?"Close menu":"Open menu",onClick:u[3]||(u[3]=p=>r.value=!r.value)},[r.value?(h(),G(f(In),{key:1,class:"h-5 w-5"})):(h(),G(f(vu),{key:0,class:"h-5 w-5"}))],8,Fd)])]),r.value?(h(),C("div",Bd,[(h(),C(n1,null,_1(a,p=>I(A,{key:p.href,to:p.href,class:f1(["flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",f(o).path===p.href?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-muted hover:text-foreground"]),onClick:u[4]||(u[4]=y=>r.value=!1)},{default:w(()=>[(h(),G(k2(p.icon),{class:"h-4 w-4"})),U(" "+N(p.name),1)]),_:2},1032,["to","class"])),64))])):P("",!0),b("main",Sd,[b("div",Rd,[I(m)])]),I(wd)])}}},p4={__name:"EmptyMachine",setup(e){return(t,n)=>(h(),G(f(z1),{class:"text-center py-16 px-6"},{default:w(()=>[n[1]||(n[1]=b("h2",{class:"text-lg font-semibold mb-1"},"Nothing indexed yet",-1)),n[2]||(n[2]=b("p",{class:"text-muted-foreground text-sm mb-4 max-w-lg mx-auto"}," Point SourceAnt at a folder on this machine and it reads the code into a graph you can look at and record against. ",-1)),I(f(C1),{as:"a",href:"/repositories",variant:"glow"},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),n[0]||(n[0]=U(" Add a repository ",-1))]),_:1})]),_:1}))}},Nd={class:"grid gap-3 mb-6 sm:grid-cols-2 lg:grid-cols-4"},Kd={class:"text-xs text-muted-foreground capitalize"},Gd={class:"mt-1 text-2xl font-semibold tabular-nums"},Od={class:"grid gap-3"},$d={class:"flex items-center gap-1.5"},Wd={class:"flex items-center gap-1.5"},Ld={__name:"Overview",setup(e){const{repositories:t,error:n,fetchRepositories:l}=g3(),o=z([]),r=t1(()=>({repositories:t.value.length,files:o.value.reduce((s,a)=>s+a.files,0),nodes:o.value.reduce((s,a)=>s+a.nodes,0),knowledge:o.value.reduce((s,a)=>s+a.knowledge,0)}));return d2(async()=>{await l(),o.value=await Promise.all(t.value.map(async s=>{const[a,i]=await Promise.all([B1.graph(s.name).catch(()=>null),B1.knowledge(s.name).catch(()=>null)]);return{repository:s,files:a?a.nodes.filter(c=>c.kind==="file").length:0,nodes:a?a.nodes.length:0,knowledge:i?i.total:0}}))}),(s,a)=>(h(),C("div",null,[I(f(m3),{pillar:"memory",title:"Overview",sub:"What SourceAnt has on this machine."},{icon:w(()=>[I(f(yn),{class:"h-6 w-6"})]),_:1}),f(n)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(n)),1)]),_:1})):P("",!0),!f(n)&&f(t).length===0?(h(),G(p4,{key:1})):f(t).length?(h(),C(n1,{key:2},[b("div",Nd,[(h(!0),C(n1,null,_1(r.value,(i,c)=>(h(),G(f(z1),{key:c,class:"p-5"},{default:w(()=>[b("p",Kd,N(c),1),b("p",Gd,N(i.toLocaleString()),1)]),_:2},1024))),128))]),b("div",Od,[(h(!0),C(n1,null,_1(o.value,i=>(h(),G(f(z3),{key:i.repository.name,title:i.repository.name,subtitle:i.repository.path,hover:""},{icon:w(()=>[I(f(m5),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:i.files?"success":"warning"},{default:w(()=>[U(N(i.files?"Indexed":"Not indexed"),1)]),_:2},1032,["variant"])]),meta:w(()=>[b("span",$d,[I(f(p5),{class:"h-3.5 w-3.5"}),U(N(i.files.toLocaleString())+" files ",1)]),b("span",Wd,[I(f(V4),{class:"h-3.5 w-3.5"}),U(N(i.knowledge.toLocaleString())+" recorded ",1)])]),actions:w(()=>[I(f(C1),{as:"a",href:"/graph",variant:"ghost",size:"sm"},{default:w(()=>[...a[0]||(a[0]=[U("Graph",-1)])]),_:1})]),_:2},1032,["title","subtitle"]))),128))]),a[1]||(a[1]=b("p",{class:"mt-4 text-xs text-muted-foreground"}," Reviews are not here. A review reads a pull request, and nothing on this machine produces one. ",-1))],64)):P("",!0)]))}};function Pd(){const e=z(null),t=z(!1),n=z(null);async function l(o,r,s={}){t.value=!0;try{e.value=await B1.graph(`${o}/${r}`,s),n.value=null}catch(a){e.value=null,n.value=a}finally{t.value=!1}}return{graph:e,loading:t,fetchCodeGraph:l,failureFor:()=>n.value}}function Hd(){const e=z(null);async function t(){return e.value={nodes:[],links:[]},e.value}return{fetchGraph:t,failureFor:()=>null}}const Td={key:0},Yd={class:"inline-flex w-full rounded-md border bg-muted/40 p-0.5"},Vd=["onClick"],Ud={class:"mt-1.5 text-[11px] text-muted-foreground"},Jd={key:1},zd={class:"relative"},jd={key:2},Xd={class:"space-y-0.5"},qd=["onClick"],ef={class:"flex-1 truncate text-foreground"},tf={class:"tabular-nums text-muted-foreground"},nf={key:3},lf={class:"flex flex-wrap gap-1.5"},of=["onClick"],rf={key:4},sf={class:"flex cursor-pointer items-center gap-2 text-[11px] text-muted-foreground"},af={key:5},cf={key:6},uf={class:"mb-1.5 flex items-center justify-between"},df=["disabled"],ff={key:0,class:"mt-1 text-[11px] text-muted-foreground"},Af={key:1,class:"mt-1.5 space-y-1.5"},hf={class:"flex items-start gap-1.5 text-[11px]"},pf={class:"min-w-0 break-words"},mf={class:"font-medium"},gf={class:"min-w-0"},vf={class:"min-w-0"},yf={class:"overflow-hidden rounded-lg border bg-card"},bf={class:"space-y-1"},kf={class:"mx-auto max-w-sm text-xs text-muted-foreground"},Cf={key:0,class:"mt-2 text-xs text-warning"},wf={key:1,class:"mt-2 text-xs text-muted-foreground"},Fn=$1({__name:"GraphWorkbench",props:{repository:{},sources:{default:()=>["knowledge","code"]},controls:{default:()=>["filter","kinds","parts","layouts","depth","retired"]},height:{default:"640px"}},emits:["select"],setup(e,{expose:t,emit:n}){const l=e,o=n,{fetchGraph:r,failureFor:s}=Hd(),{legend:a}=K0(),{graph:i,loading:c,fetchCodeGraph:d,failureFor:u}=Pd(),A=z(l.sources[0]??"knowledge"),m=z(null),p=z(!1),y=t1(()=>A.value==="code"?i.value:m.value),k=t1(()=>A.value==="code"?c.value:p.value),F=t1(()=>A.value==="code"?u("code-graph"):s("graph")),M=t1(()=>l.repository.split("/").pop()??l.repository),E=t1(()=>!!y.value&&y.value.nodes.length>0);function _(q){return l.controls.includes(q)}const R=z(""),$=z(2),D=z([]),x=z(""),Q=z("2d"),B=z([]),X=z(!1),Y=t1(()=>!!R.value),m1=t1(()=>{var S;const q=(S=y.value)==null?void 0:S.nodes.find(o1=>o1.id===R.value);return(q==null?void 0:q.name)??R.value.replace(/^(file|symbol):/,"")}),w1=t1(()=>{var q;return((q=y.value)==null?void 0:q.communities)??[]}),r1=[{id:"2d",label:"2D"},{id:"3d",label:"3D"},{id:"tree",label:"Tree"},{id:"radial",label:"Radial"},{id:"layered",label:"Layered"},{id:"web",label:"Force"}],l1={knowledge:"Knowledge",code:"Code"},b1=["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"];async function y1(){const[q,S]=l.repository.split("/");if(!q||!S){m.value=null;return}if(A.value==="code"){await d(q,S,{focus:R.value||void 0,depth:Y.value?$.value:void 0,q:x.value.trim()||void 0});return}p.value=!0;try{m.value=await r(q,S,{focus:R.value||void 0,depth:Y.value?$.value:void 0,kind:D.value,q:x.value.trim()||void 0,status:X.value?"all":void 0})}finally{p.value=!1}}let k1=null;function c1(){k1&&clearTimeout(k1),k1=setTimeout(y1,250)}t2([$,D,x,X],c1,{deep:!0}),t2(R,y1),t2(A,()=>{R.value="",B.value=[],y1()}),t2(()=>l.repository,()=>{R.value="",B.value=[],y1()},{immediate:!0});function L1(q){o("select",q),_("depth")&&(R.value=R.value===q?"":q)}function S1(){R.value=""}function Y1(q){D.value=D.value.includes(q)?D.value.filter(S=>S!==q):[...D.value,q]}function q1(q){B.value=B.value.includes(q)?B.value.filter(S=>S!==q):[...B.value,q]}const s1=t1(()=>l.sources.length>1||_("filter")||_("kinds")||_("parts")||_("layouts")||_("depth")||_("retired"));return t({reload:y1}),(q,S)=>{var A1,x1,g;const o1=Ve("UiLoadFailure"),J=Ve("UiLoadingState");return h(),C("div",{class:f1(["grid gap-4 lg:items-start",s1.value?"lg:grid-cols-[16rem_1fr]":""])},[s1.value?(h(),C("aside",{key:0,class:"space-y-4 overflow-y-auto rounded-lg border bg-card p-3",style:S2({height:e.height})},[e.sources.length>1?(h(),C("div",Td,[S[5]||(S[5]=b("p",{class:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"},"Draw",-1)),b("div",Yd,[(h(!0),C(n1,null,_1(e.sources,v=>(h(),C("button",{key:v,type:"button",class:f1(["flex-1 rounded px-2 py-1 text-xs font-medium transition-colors",A.value===v?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"]),onClick:Z=>A.value=v},N(l1[v]),11,Vd))),128))]),b("p",Ud,N(A.value==="code"?"What is defined and what calls what, read from the code.":"What your team decided, and the files it covers."),1)])):P("",!0),_("filter")?(h(),C("div",Jd,[S[6]||(S[6]=b("label",{class:"mb-1.5 block text-[11px] font-medium uppercase tracking-wide text-muted-foreground"}," Only what mentions ",-1)),b("div",zd,[I(f(wn),{class:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),Ne(b("input",{"onUpdate:modelValue":S[0]||(S[0]=v=>x.value=v),type:"search",placeholder:"a word",class:"w-full rounded-md border bg-background py-1.5 pl-8 pr-2 text-sm"},null,512),[[S6,x.value]])])])):P("",!0),_("parts")&&A.value==="code"&&w1.value.length?(h(),C("div",jd,[S[7]||(S[7]=b("p",{class:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"},"Parts",-1)),b("ul",Xd,[(h(!0),C(n1,null,_1(w1.value,v=>(h(),C("li",{key:v.id},[b("button",{type:"button",class:f1(["flex w-full items-center gap-2 rounded-md px-1 py-1 text-left text-[11px] transition-colors hover:bg-muted",B.value.includes(v.id)?"opacity-40":""]),onClick:Z=>q1(v.id)},[b("span",{class:"h-2.5 w-2.5 shrink-0 rounded-full",style:S2({backgroundColor:b1[v.id%b1.length]})},null,4),b("span",ef,N(v.name),1),b("span",tf,N(v.size),1)],10,qd)]))),128))]),S[8]||(S[8]=b("p",{class:"mt-1.5 text-[11px] text-muted-foreground"}," Grouped by what calls what. Click one to hide it. ",-1))])):P("",!0),_("kinds")&&A.value==="knowledge"?(h(),C("div",nf,[S[9]||(S[9]=b("p",{class:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"},"Kinds",-1)),b("div",lf,[(h(!0),C(n1,null,_1(f(a),v=>(h(),C("button",{key:v.label,type:"button",class:f1(["inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors",D.value.includes(v.label.toLowerCase())?"border-primary/40 bg-primary/10 text-primary":"text-muted-foreground hover:text-foreground"]),onClick:Z=>Y1(v.label.toLowerCase())},[b("span",{class:"h-2 w-2 rounded-sm",style:S2({backgroundColor:v.color})},null,4),U(" "+N(v.label),1)],10,of))),128)),D.value.length?(h(),C("button",{key:0,type:"button",class:"text-[11px] text-muted-foreground underline-offset-2 hover:underline",onClick:S[1]||(S[1]=v=>D.value=[])},"Any")):P("",!0)])])):P("",!0),_("retired")&&A.value==="knowledge"?(h(),C("div",rf,[b("label",sf,[Ne(b("input",{"onUpdate:modelValue":S[2]||(S[2]=v=>X.value=v),type:"checkbox",class:"h-3 w-3 rounded border"},null,512),[[a0,X.value]]),S[10]||(S[10]=U(" Include retired records ",-1))])])):P("",!0),_("layouts")?(h(),C("div",af,[S[11]||(S[11]=b("p",{class:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"},"Shape",-1)),I(f(ge),{modelValue:Q.value,"onUpdate:modelValue":S[3]||(S[3]=v=>Q.value=v),tabs:r1,label:"Shape",class:"grid w-full grid-cols-2"},null,8,["modelValue"])])):P("",!0),_("depth")?(h(),C("div",cf,[b("div",uf,[b("span",{class:f1(["text-[11px] font-medium uppercase tracking-wide",Y.value?"text-muted-foreground":"text-muted-foreground/50"])}," Steps out ",2),b("span",{class:f1(["font-mono text-xs",Y.value?"":"opacity-50"])},N($.value),3)]),Ne(b("input",{"onUpdate:modelValue":S[4]||(S[4]=v=>$.value=v),type:"range",min:"1",max:"5",disabled:!Y.value,class:"w-full"},null,8,df),[[S6,$.value,void 0,{number:!0}]]),Y.value?(h(),C("div",Af,[b("p",hf,[I(f(mu),{class:"mt-0.5 h-3 w-3 shrink-0 text-primary"}),b("span",pf,[S[12]||(S[12]=U("From ",-1)),b("span",mf,N(m1.value),1)])]),b("button",{type:"button",class:"inline-flex w-full items-center justify-center gap-1 rounded-md border px-2 py-1 text-[11px] hover:bg-muted",onClick:S1},[I(f(In),{class:"h-3 w-3"}),S[13]||(S[13]=U(" Draw everything ",-1))])])):(h(),C("p",ff," Click anything on the graph to walk out from it. "))])):P("",!0)],4)):P("",!0),b("div",gf,[b("div",{class:f1(["grid gap-4",q.$slots.inspector?"lg:grid-cols-[1fr_20rem]":""])},[b("div",vf,[b("div",yf,[F.value?(h(),G(o1,{key:0,what:"this graph",message:F.value,onRetry:y1},null,8,["message"])):k.value?(h(),C("div",{key:1,style:S2({height:e.height})},[I(J,{label:A.value==="code"?"Reading the code":"Reading the knowledge graph",compact:""},null,8,["label"])],4)):E.value?(h(),G(f(ma),{key:3,repo:M.value,mode:Q.value,data:y.value,hidden:B.value,height:e.height,onSelect:L1},null,8,["repo","mode","data","hidden","height"])):(h(),C("div",{key:2,class:"flex flex-col items-center justify-center gap-3 px-6 text-center",style:S2({height:e.height})},[I(f(g5),{class:"h-7 w-7 text-muted-foreground"}),b("div",bf,[S[14]||(S[14]=b("p",{class:"text-sm font-medium"},"Nothing to draw",-1)),b("p",kf,N(A.value==="code"?"This repository has not been read yet, so there is no code map for it.":"Initialize this repository and approve what it proposes, and its decisions appear here."),1)])],4))]),(A1=y.value)!=null&&A1.truncated?(h(),C("p",Cf," More than fits in one drawing, so this is the most connected part of it. Narrow it"+N(s1.value?" on the left":"")+", or click something to walk out from it. ",1)):E.value?(h(),C("p",wf,N((x1=y.value)==null?void 0:x1.nodes.length)+" symbols, "+N((g=y.value)==null?void 0:g.links.length)+" connections. ",1)):P("",!0)]),q.$slots.inspector?(h(),C("div",{key:0,class:"overflow-y-auto rounded-lg border bg-card",style:S2({height:e.height})},[K1(q.$slots,"inspector")],4)):P("",!0)],2)])],2)}}}),xf={class:"flex h-full min-h-0 flex-col"},_f=["value"],If={__name:"Graph",setup(e){const{repositories:t,chosen:n,error:l,fetchRepositories:o}=g3();return d2(o),(r,s)=>(h(),C("div",xf,[I(f(m3),{title:"Graphs",sub:"Your code, and how it holds together."},{icon:w(()=>[I(f(g5),{class:"h-6 w-6"})]),actions:w(()=>[f(t).length>1?(h(),G(f(j2),{key:0,modelValue:f(n),"onUpdate:modelValue":s[0]||(s[0]=a=>n2(n)?n.value=a:null),size:"sm","aria-label":"Repository"},{default:w(()=>[(h(!0),C(n1,null,_1(f(t),a=>(h(),C("option",{key:a.name,value:a.name},N(a.name),9,_f))),128))]),_:1},8,["modelValue"])):P("",!0)]),_:1}),f(l)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(l)),1)]),_:1})):P("",!0),f(t).length===0?(h(),G(p4,{key:1})):(h(),G(Fn,{key:f(n),repository:f(n),sources:["code"],controls:["filter","kinds","parts","layouts","depth"],height:"calc(100vh - 15rem)"},null,8,["repository"]))]))}},Mf=["value"],Ef=["value"],Df=["value"],Zf={key:4,class:"grid gap-3"},Ff={class:"text-sm text-muted-foreground"},Bf={key:0,class:"mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs"},Sf={class:"break-all font-mono"},Rf={class:"text-lg font-semibold mb-4"},Qf={class:"space-y-4"},Nf={class:"flex items-center gap-2 pt-2"},Kf={__name:"Knowledge",setup(e){const t=["decision","convention","constraint","pattern","workaround","requirement"],{repositories:n,chosen:l,error:o,mixed:r,fetchRepositories:s}=g3({all:!0});async function a(D){D&&(l.value=D)}const i=z([]),c=z(null),d=z({id:"",kind:"decision",summary:"",why:""}),u=z(""),A=z(!1),m=z(!1),p=z(!1),y=z(null),k=z(!1);async function F(){try{const D=await B1.settings(),x=D.find(B=>B.key==="model.name"),Q=D.find(B=>B.key==="model.api_key");k.value=!!(x!=null&&x.value)&&!!(Q!=null&&Q.is_set)}catch{k.value=!1}}async function M(D=!1){const x=D?p:m;x.value=!0,y.value=null;try{const Q=await B1.initialize(l.value,{useModel:D});y.value=Q.recorded,o.value="",await E()}catch(Q){o.value=Q.message}finally{x.value=!1}}async function E(){if(l.value)try{const D=await B1.knowledge(l.value);i.value=D.items,o.value=""}catch(D){i.value=[],o.value=D.message}}function _(D){var x;c.value=D??{fresh:!0},d.value=D?{id:D.id,kind:D.kind,summary:D.summary,why:((x=D.properties)==null?void 0:x.why)??""}:{id:"",kind:"decision",summary:"",why:""},u.value=""}async function R(){var D,x,Q;if(!d.value.id.trim()||!d.value.summary.trim()){u.value="A name and what is true are both needed.";return}A.value=!0;try{await B1.recordKnowledge({repository:l.value,id:d.value.id.trim(),kind:d.value.kind,status:((D=c.value)==null?void 0:D.status)??"accepted",summary:d.value.summary.trim(),properties:d.value.why.trim()?{...((x=c.value)==null?void 0:x.properties)??{},why:d.value.why.trim()}:((Q=c.value)==null?void 0:Q.properties)??{}}),c.value=null,await E()}catch(B){u.value=B.message}finally{A.value=!1}}async function $(D){if(confirm(`Forget ${D.id}?`)){try{await B1.forgetKnowledge(l.value,D.id)}catch(x){o.value=x.message}await E()}}return t2(l,E),d2(async()=>{await s(),await Promise.all([E(),F()])}),(D,x)=>{const Q=Ve("X");return h(),C("div",null,[I(f(m3),{pillar:"memory",title:"Knowledge",sub:"The decisions, conventions and constraints behind this code."},{icon:w(()=>[I(f(V4),{class:"h-6 w-6"})]),actions:w(()=>[f(n).length>1?(h(),G(f(j2),{key:0,modelValue:f(l),"onUpdate:modelValue":x[0]||(x[0]=B=>n2(l)?l.value=B:null),size:"sm","aria-label":"Repository"},{default:w(()=>[b("option",{value:f(Vt)},"All repositories",8,Mf),(h(!0),C(n1,null,_1(f(n),B=>(h(),C("option",{key:B.name,value:B.name},N(B.name),9,Ef))),128))]),_:1},8,["modelValue"])):P("",!0),f(n).length&&f(l)?(h(),G(f(C1),{key:1,size:"sm",variant:"outline",disabled:m.value,onClick:M},{default:w(()=>[m.value?(h(),G(f(M2),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):(h(),G(f(gt),{key:1,class:"mr-2 h-4 w-4"})),U(" "+N(m.value?"Finding…":"Find in what the repo states"),1)]),_:1},8,["disabled"])):P("",!0),f(n).length&&k.value&&f(l)?(h(),G(f(C1),{key:2,size:"sm",variant:"outline",disabled:p.value,onClick:x[1]||(x[1]=B=>M(!0))},{default:w(()=>[p.value?(h(),G(f(M2),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):(h(),G(f(_n),{key:1,class:"mr-2 h-4 w-4"})),U(" "+N(p.value?"Finding…":"Find more with a model"),1)]),_:1},8,["disabled"])):P("",!0),f(n).length&&f(l)?(h(),G(f(C1),{key:3,size:"sm",variant:"glow",onClick:x[2]||(x[2]=B=>_(null))},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),x[10]||(x[10]=U(" Record something ",-1))]),_:1})):f(n).length?(h(),G(f(j2),{key:4,"model-value":"",size:"sm","aria-label":"Choose a repository","onUpdate:modelValue":a},{default:w(()=>[x[11]||(x[11]=b("option",{value:""},"Choose a repository…",-1)),(h(!0),C(n1,null,_1(f(n),B=>(h(),C("option",{key:B.name,value:B.name},N(B.name),9,Df))),128))]),_:1})):P("",!0)]),_:1}),f(o)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(o)),1)]),_:1})):P("",!0),y.value!==null?(h(),G(f(u2),{key:1,tone:"info",class:"mb-4"},{default:w(()=>[y.value?(h(),C(n1,{key:0},[U(" Read "+N(y.value)+" thing"+N(y.value===1?"":"s")+" this repository already states. Nobody has agreed to any of it, so it is all proposed. ",1)],64)):(h(),C(n1,{key:1},[U(" This repository does not state anything in the places projects usually write these down: a decision record, or a conventions section in a contributing guide. ")],64))]),_:1})):P("",!0),f(n).length===0?(h(),G(p4,{key:2})):i.value.length===0?(h(),G(f(We),{key:3,title:"Nothing recorded yet"},{actions:w(()=>[I(f(C1),{variant:"glow",onClick:x[3]||(x[3]=B=>_(null))},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),x[12]||(x[12]=U(" Record something ",-1))]),_:1}),I(f(C1),{variant:"outline",disabled:m.value,onClick:M},{default:w(()=>[m.value?(h(),G(f(M2),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):(h(),G(f(gt),{key:1,class:"mr-2 h-4 w-4"})),x[13]||(x[13]=U(" Read what the repo states ",-1))]),_:1},8,["disabled"])]),default:w(()=>[x[14]||(x[14]=U(" Why a thing is the way it is outlives the code that does it. Write one down and every agent reading this repository over MCP gets it too. ",-1))]),_:1})):(h(),C("div",Zf,[(h(!0),C(n1,null,_1(i.value,B=>(h(),G(f(z3),{key:`${B.repository??""}${B.id}`,title:B.id,pillar:"memory"},{icon:w(()=>[I(f(V4),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:"secondary"},{default:w(()=>[U(N(B.kind),1)]),_:2},1024),B.status?(h(),G(f(c2),{key:0,variant:"outline"},{default:w(()=>[U(N(B.status),1)]),_:2},1024)):P("",!0),f(r)&&B.repository?(h(),G(f(gn),{key:1,name:B.repository},{icon:w(()=>[I(f(i4),{class:"h-3 w-3"})]),_:1},8,["name"])):P("",!0)]),actions:w(()=>[B.status===D.PROPOSED?(h(),C(n1,{key:0},[I(f(C1),{variant:"outline",size:"sm",disabled:D.deciding===B.id,"aria-label":`Accept ${B.id}`,onClick:X=>D.decide(B,D.ACCEPTED)},{default:w(()=>[D.deciding===B.id?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(f(he),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),x[16]||(x[16]=U(" Accept ",-1))]),_:2},1032,["disabled","aria-label","onClick"]),I(f(C1),{variant:"ghost",size:"icon","aria-label":`Throw out ${B.id}`,onClick:X=>D.decide(B,null)},{default:w(()=>[I(Q,{class:"h-4 w-4"})]),_:1},8,["aria-label","onClick"])],64)):(h(),C(n1,{key:1},[I(f(C1),{variant:"ghost",size:"icon","aria-label":"Edit",onClick:X=>_(B)},{default:w(()=>[I(f(bu),{class:"h-4 w-4"})]),_:1},8,["onClick"]),I(f(C1),{variant:"ghost",size:"icon","aria-label":"Remove",onClick:X=>$(B)},{default:w(()=>[I(f(h4),{class:"h-4 w-4"})]),_:1},8,["onClick"])],64))]),default:w(()=>{var X;return[b("p",Ff,N(B.summary),1),(X=B.properties)!=null&&X.why?(h(),C("dl",Bf,[x[15]||(x[15]=b("dt",{class:"text-muted-foreground"},"why",-1)),b("dd",Sf,N(B.properties.why),1)])):P("",!0)]}),_:2},1032,["title"]))),128))])),I(f(Tt),{open:!!c.value,"max-width":"xl",onClose:x[9]||(x[9]=B=>c.value=null)},{default:w(()=>{var B;return[b("h2",Rf,N((B=c.value)!=null&&B.fresh?"Record something":"Edit"),1),b("div",Qf,[I(f(R2),{label:"Name",hint:"What this will be called, and how it is found again."},{default:w(()=>{var X;return[I(f(J3),{modelValue:d.value.id,"onUpdate:modelValue":x[4]||(x[4]=Y=>d.value.id=Y),readonly:!((X=c.value)!=null&&X.fresh),placeholder:"retry-limit"},null,8,["modelValue","readonly"])]}),_:1}),I(f(R2),{label:"Kind"},{default:w(()=>[I(f(j2),{modelValue:d.value.kind,"onUpdate:modelValue":x[5]||(x[5]=X=>d.value.kind=X),class:"w-full"},{default:w(()=>[(h(),C(n1,null,_1(t,X=>b("option",{key:X},N(X),1)),64))]),_:1},8,["modelValue"])]),_:1}),I(f(R2),{label:"What is true"},{default:w(()=>[I(f(dt),{modelValue:d.value.summary,"onUpdate:modelValue":x[6]||(x[6]=X=>d.value.summary=X),placeholder:"Charges retry three times, then stop."},null,8,["modelValue"])]),_:1}),I(f(R2),{label:"Why",hint:"What stops somebody undoing it next year."},{default:w(()=>[I(f(dt),{modelValue:d.value.why,"onUpdate:modelValue":x[7]||(x[7]=X=>d.value.why=X),placeholder:"The provider rate limits after four."},null,8,["modelValue"])]),_:1}),u.value?(h(),G(f(u2),{key:0,tone:"danger"},{default:w(()=>[U(N(u.value),1)]),_:1})):P("",!0),b("div",Nf,[I(f(C1),{disabled:A.value,onClick:R},{default:w(()=>[I(f(he),{class:"mr-1.5 h-3.5 w-3.5"}),x[17]||(x[17]=U(" Save ",-1))]),_:1},8,["disabled"]),I(f(C1),{variant:"outline",onClick:x[8]||(x[8]=X=>c.value=null)},{default:w(()=>[...x[18]||(x[18]=[U("Cancel",-1)])]),_:1})])])]}),_:1},8,["open"])])}}},Gf={key:2,class:"grid gap-3"},Of={class:"flex items-center gap-1.5"},$f={class:"flex items-center gap-1.5"},Wf={key:1},Lf={key:2},Pf={key:3,class:"text-primary"},Hf={__name:"Repositories",setup(e){const t=me(),{repositories:n,error:l,fetchRepositories:o}=g3(),r=z({}),s=z(""),a=z(!1),i=z({});async function c(){for(const p of n.value){const y=await B1.graph(p.name).catch(()=>null);r.value={...r.value,[p.name]:y?{files:y.nodes.filter(k=>k.kind==="file").length,links:y.links.length}:null}}}async function d(){await o(),await c()}async function u(p){s.value=p;try{const[y]=await B1.index(p);i.value={...i.value,[p]:y},l.value=""}catch(y){l.value=y.message}s.value="",await c()}function A(p){return p?p.indexed?`Read ${p.indexed.toLocaleString()} files just now.`:"Nothing had changed.":""}async function m(p){if(confirm(`Stop covering ${p.path}? + +What was already indexed is left alone.`)){try{await B1.dropRepository(p.path)}catch(y){l.value=y.message}await d()}}return d2(d),(p,y)=>(h(),C("div",null,[I(f(m3),{title:"Repositories",sub:"The folders SourceAnt reads on this machine."},{icon:w(()=>[I(f(i4),{class:"h-6 w-6"})]),actions:w(()=>[I(f(C1),{variant:"glow",onClick:y[0]||(y[0]=k=>a.value=!0)},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),y[3]||(y[3]=U(" Add a folder ",-1))]),_:1})]),_:1}),f(l)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(l)),1)]),_:1})):P("",!0),f(n).length===0?(h(),G(f(We),{key:1,title:"No folders yet"},{actions:w(()=>[I(f(C1),{variant:"glow",onClick:y[1]||(y[1]=k=>a.value=!0)},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),y[4]||(y[4]=U(" Add a folder ",-1))]),_:1})]),default:w(()=>[y[5]||(y[5]=U(" Point SourceAnt at a repository and it reads the files into a graph. ",-1))]),_:1})):(h(),C("div",Gf,[(h(!0),C(n1,null,_1(f(n),k=>(h(),G(f(z3),{key:k.path,title:k.name,subtitle:k.path,hover:"",class:"cursor-pointer",onClick:F=>f(t).push(`/repositories/${k.name}`)},{icon:w(()=>[I(f(m5),{class:"h-5 w-5"})]),meta:w(()=>[r.value[k.name]?(h(),C(n1,{key:0},[b("span",Of,[I(f(p5),{class:"h-3.5 w-3.5"}),U(N(r.value[k.name].files.toLocaleString())+" files ",1)]),b("span",$f,[I(f(bn),{class:"h-3.5 w-3.5"}),U(N(r.value[k.name].links.toLocaleString())+" links ",1)])],64)):r.value[k.name]===null?(h(),C("span",Wf,"Not read yet. Re-index to read it.")):(h(),C("span",Lf,"Reading…")),i.value[k.name]?(h(),C("span",Pf,N(A(i.value[k.name])),1)):P("",!0)]),actions:w(()=>[I(f(C1),{variant:"outline",size:"sm",disabled:s.value===k.name,onClick:qe(F=>u(k.name),["stop"])},{default:w(()=>[s.value===k.name?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(f(Cn),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),U(" "+N(s.value===k.name?"Reading…":"Re-index"),1)]),_:2},1032,["disabled","onClick"]),I(f(C1),{variant:"ghost",size:"icon","aria-label":`Remove ${k.name}`,onClick:qe(F=>m(k),["stop"])},{default:w(()=>[I(f(h4),{class:"h-4 w-4"})]),_:1},8,["aria-label","onClick"])]),_:2},1032,["title","subtitle","onClick"]))),128))])),I(Zn,{open:a.value,onClose:y[2]||(y[2]=k=>a.value=!1),onAdded:d},null,8,["open"])]))}};function Ut(){const e=me();return t=>e.push(t)}const Tf={class:"flex h-full min-h-0 flex-col"},Yf={key:1,class:"space-y-3"},Vf={class:"flex flex-wrap gap-x-8 gap-y-3"},Uf={class:"flex items-center gap-1.5 text-xs uppercase tracking-wider text-muted-foreground"},Jf={class:"mt-0.5 text-lg font-semibold"},zf={key:0,class:"mt-4 text-sm text-primary"},jf={key:1,class:"mt-4 text-sm text-muted-foreground"},Xf={class:"mt-4 flex flex-wrap gap-2"},qf={class:"mb-4 mt-0.5 text-sm text-muted-foreground"},eA={class:"space-y-2"},tA=["title"],nA={class:"hidden h-1.5 w-24 shrink-0 overflow-hidden rounded-full bg-muted sm:block"},lA={class:"w-28 shrink-0 text-right text-xs tabular-nums text-muted-foreground"},oA={class:"w-24 shrink-0 text-right text-xs tabular-nums text-muted-foreground"},rA={key:2,class:"space-y-3"},sA={class:"text-sm text-muted-foreground"},aA={key:3,class:"space-y-3"},iA={class:"text-sm text-muted-foreground"},cA={__name:"Repository",setup(e){const t=d5(),n=me(),l=Ut(),{repositories:o,chosen:r,fetchRepositories:s}=g3(),a=t1(()=>String(t.params.name??"")),i=t1(()=>o.value.find(D=>D.name===a.value)),c=z("overview"),d=z(null),u=z([]),A=z([]),m=z({files:[],since:""}),p=z(!1),y=z(null),k=z(""),F=t1(()=>{var D,x,Q;return[{label:"Files",value:((D=d.value)==null?void 0:D.files)??0,icon:p5},{label:"Connections",value:((x=d.value)==null?void 0:x.links)??0,icon:bn},{label:"Parts",value:((Q=d.value)==null?void 0:Q.parts)??0,icon:g5},{label:"Recorded",value:u.value.length,icon:S4},{label:"Rules",value:A.value.length,icon:c4}]}),M=t1(()=>{var D;return((D=m.value.files[0])==null?void 0:D.changes)||1}),E=t1(()=>[{id:"overview",label:"Overview"},{id:"knowledge",label:`Knowledge${u.value.length?` ${u.value.length}`:""}`},{id:"skills",label:`Skills${A.value.length?` ${A.value.length}`:""}`},{id:"graph",label:"Graph"}]);async function _(){if(!a.value)return;r.value=a.value;const[D,x,Q,B]=await Promise.all([B1.graph(a.value).catch(()=>null),B1.knowledge(a.value).catch(()=>({items:[]})),B1.skills(a.value).catch(()=>({skills:[]})),B1.attention(a.value).catch(()=>({files:[],since:""}))]);d.value=D?{files:D.nodes.filter(X=>X.kind==="file").length,links:D.links.length,parts:(D.communities??[]).length}:null,u.value=x.items??[],A.value=Q.skills??[],m.value=B}async function R(){p.value=!0;try{const[D]=await B1.index(a.value);y.value=D,k.value=""}catch(D){k.value=D.message}p.value=!1,await _()}async function $(){if(confirm(`Stop covering ${i.value.path}? + +What was already indexed is left alone.`))try{await B1.dropRepository(i.value.path),await s(),n.push("/repositories")}catch(D){k.value=D.message}}return t2(a,_),d2(async()=>{await s(),await _()}),(D,x)=>{var Q;return h(),C("div",Tf,[I(f(m3),{title:a.value,sub:(Q=i.value)==null?void 0:Q.path,mono:""},{back:w(()=>[I(f(C1),{variant:"ghost",size:"icon","aria-label":"Back to repositories",onClick:x[0]||(x[0]=B=>f(l)("/repositories"))},{default:w(()=>[I(f(Yt),{class:"h-4 w-4"})]),_:1})]),icon:w(()=>[I(f(m5),{class:"h-5 w-5"})]),badges:w(()=>{var B;return[I(f(c2),{variant:(B=d.value)!=null&&B.files?"success":"warning"},{default:w(()=>{var X;return[U(N((X=d.value)!=null&&X.files?"Indexed":"Not indexed"),1)]}),_:1},8,["variant"])]}),actions:w(()=>[I(f(C1),{variant:"outline",disabled:p.value,onClick:R},{default:w(()=>[p.value?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(f(Cn),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),U(" "+N(p.value?"Reading…":"Re-index"),1)]),_:1},8,["disabled"]),I(f(C1),{variant:"ghost",size:"icon","aria-label":"Stop covering this folder",onClick:$},{default:w(()=>[I(f(h4),{class:"h-4 w-4"})]),_:1})]),_:1},8,["title","sub"]),k.value?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(k.value),1)]),_:1})):P("",!0),I(f(ge),{modelValue:c.value,"onUpdate:modelValue":x[1]||(x[1]=B=>c.value=B),tabs:E.value,label:"What to look at",class:"mb-4 w-fit"},null,8,["modelValue","tabs"]),c.value==="overview"?(h(),C("div",Yf,[I(f(z1),{class:"p-5"},{default:w(()=>[b("dl",Vf,[(h(!0),C(n1,null,_1(F.value,B=>(h(),C("div",{key:B.label},[b("dt",Uf,[(h(),G(k2(B.icon),{class:"h-3.5 w-3.5"})),U(N(B.label),1)]),b("dd",Jf,N(B.value.toLocaleString()),1)]))),128))]),y.value?(h(),C("p",zf,[y.value.indexed?(h(),C(n1,{key:0},[U("Read "+N(y.value.indexed.toLocaleString())+" files just now.",1)],64)):(h(),C(n1,{key:1},[U("Nothing had changed.")],64))])):d.value===null?(h(),C("p",jf," Not read yet. Re-index to read it. ")):P("",!0),b("div",Xf,[I(f(C1),{variant:"outline",size:"sm",onClick:x[2]||(x[2]=B=>f(n).push("/reviews"))},{default:w(()=>[I(f(Le),{class:"mr-1.5 h-3.5 w-3.5"}),x[6]||(x[6]=U(" Review what has changed ",-1))]),_:1}),I(f(C1),{variant:"outline",size:"sm",onClick:x[3]||(x[3]=B=>f(n).push("/knowledge"))},{default:w(()=>[I(f(S4),{class:"mr-1.5 h-3.5 w-3.5"}),x[7]||(x[7]=U(" Record something ",-1))]),_:1})])]),_:1}),m.value.files.length?(h(),G(f(z1),{key:0,class:"p-5"},{default:w(()=>[x[8]||(x[8]=b("h2",{class:"font-semibold"},"Where to look first",-1)),b("p",qf," Files that have been changing in the last "+N(m.value.since)+" and that the rest of the code leans on. Either on its own says little: something everything imports and nobody touches is settled, and something nothing imports that changes daily is a scratch pad. Where they meet is where a change is most likely to catch somebody out, and is the shortest list worth reading first. ",1),b("ul",eA,[(h(!0),C(n1,null,_1(m.value.files,B=>(h(),C("li",{key:B.path,class:"flex items-center gap-3"},[b("span",{class:"min-w-0 flex-1 truncate font-mono text-sm",title:B.path},N(B.path),9,tA),b("span",nA,[b("span",{class:"block h-full rounded-full bg-pillar-graph",style:S2({width:`${Math.max(4,B.changes/M.value*100)}%`})},null,4)]),b("span",lA,N(B.changes)+" change"+N(B.changes===1?"":"s"),1),b("span",oA,N(B.dependants)+" depend"+N(B.dependants===1?"s":""),1)]))),128))])]),_:1})):P("",!0)])):c.value==="knowledge"?(h(),C("div",rA,[(h(!0),C(n1,null,_1(u.value,B=>(h(),G(f(z3),{key:B.id,title:B.id,pillar:"memory"},{icon:w(()=>[I(f(S4),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:"secondary"},{default:w(()=>[U(N(B.kind),1)]),_:2},1024),B.status?(h(),G(f(c2),{key:0,variant:"outline"},{default:w(()=>[U(N(B.status),1)]),_:2},1024)):P("",!0)]),default:w(()=>[b("p",sA,N(B.summary),1)]),_:2},1032,["title"]))),128)),u.value.length?P("",!0):(h(),G(f(z1),{key:0,class:"p-10 text-center"},{default:w(()=>[x[10]||(x[10]=b("p",{class:"font-medium"},"Nothing recorded about this repository yet.",-1)),I(f(C1),{class:"mt-3",variant:"outline",onClick:x[4]||(x[4]=B=>f(n).push("/knowledge"))},{default:w(()=>[...x[9]||(x[9]=[U("Record something",-1)])]),_:1})]),_:1}))])):c.value==="skills"?(h(),C("div",aA,[(h(!0),C(n1,null,_1(A.value,B=>(h(),G(f(z3),{key:B.id,title:B.name,subtitle:B.path,pillar:"review"},{icon:w(()=>[I(f(c4),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:B.origin==="repository"?"success":"outline"},{default:w(()=>[U(N(B.origin==="repository"?"this repository":B.origin),1)]),_:2},1032,["variant"])]),default:w(()=>[b("p",iA,N(B.description),1)]),_:2},1032,["title","subtitle"]))),128)),A.value.length?P("",!0):(h(),G(f(z1),{key:0,class:"p-10 text-center"},{default:w(()=>[x[12]||(x[12]=b("p",{class:"font-medium"},"Nothing written down for this repository yet.",-1)),I(f(C1),{class:"mt-3",variant:"outline",onClick:x[5]||(x[5]=B=>f(n).push("/skills/new"))},{default:w(()=>[...x[11]||(x[11]=[U("Write one down",-1)])]),_:1})]),_:1}))])):(h(),G(Fn,{key:a.value,repository:a.value,sources:["code"],controls:["filter","kinds","parts","layouts","depth"],height:"calc(100vh - 19rem)"},null,8,["repository"]))])}}},uA={class:"flex h-full min-h-0 flex-col"},dA={key:0},fA=["value"],AA=["value"],hA=["value"],pA={class:"space-y-2"},mA={key:1,class:"font-mono"},gA={class:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-2"},vA={class:"ml-auto flex flex-wrap items-center gap-1.5"},yA=["value"],bA={key:1,class:"min-h-0 flex-1 overflow-y-auto"},kA={class:"min-w-0 flex-1 truncate font-medium"},CA={class:"shrink-0 font-mono text-xs text-muted-foreground"},wA={class:"shrink-0 text-xs text-muted-foreground"},xA={class:"shrink-0 text-xs text-muted-foreground"},_A={key:0,class:"mt-2 whitespace-pre-wrap pl-5 text-sm text-muted-foreground"},IA={key:2,class:"min-h-0 flex-1 overflow-y-auto"},MA={class:"divide-y"},EA={class:"flex cursor-pointer items-center gap-2 text-sm"},DA={class:"font-medium"},ZA={class:"min-w-0 flex-1 truncate text-muted-foreground"},FA={class:"flex cursor-pointer items-center gap-2 text-sm"},BA={class:"font-medium"},SA={class:"min-w-0 flex-1 truncate text-muted-foreground"},RA={class:"space-y-2"},QA={class:"space-y-2"},NA={class:"space-y-2"},KA={class:"space-y-1.5 text-sm"},GA=["onClick"],OA={class:"font-mono text-xs"},$A={key:3,class:"grid min-h-0 flex-1 gap-3 lg:grid-cols-[18rem_1fr]"},WA={class:"min-h-0 flex-1 overflow-y-auto py-1"},LA=["onClick"],PA=["title"],HA={class:"shrink-0 text-[10px] uppercase text-muted-foreground"},TA={class:"min-h-0 overflow-y-auto"},YA={class:"mb-2 flex flex-wrap items-center gap-2"},VA={class:"break-all font-mono text-sm"},UA=1500,L7={__name:"Reviews",setup(e){const t=d5(),n=me(),l=Ut(),{repositories:o,chosen:r,error:s,mixed:a,fetchRepositories:i}=g3({all:!0}),c=z(!1),d=z(!1),u=z(null),A=z(null),m=z(!1),p=z(""),y=z([]),k=z(""),F=z([]),M=z([]),E=z("overview"),_=t1(()=>{var K;return((K=u.value)==null?void 0:K.changed)??[]}),R=t1(()=>String(t.params.id??"")),$=t1(()=>F.value.filter(K=>!y.value.includes(K.id))),D=t1(()=>Object.fromEntries(F.value.map(K=>[K.id,K]))),x=K=>{var O;return((O=D.value[K])==null?void 0:O.name)??K},Q=K=>{var O;return(O=m1.value.find(p1=>p1.skill===K))==null?void 0:O.passed};function B(K){y.value=y.value.filter(O=>O!==K)}function X(K){K&&!y.value.includes(K)&&(y.value=[...y.value,K]),k.value=""}const Y=t1(()=>{var K;return((K=u.value)==null?void 0:K.where)??null}),m1=t1(()=>{var K;return((K=u.value)==null?void 0:K.verdicts)??[]}),w1=t1(()=>m1.value.flatMap(K=>K.findings.map(O=>({...O,skill:K.skill})))),r1=t1(()=>w1.value.filter(K=>K.severity==="blocking")),l1=t1(()=>w1.value.filter(K=>K.severity!=="blocking")),b1=t1(()=>{const K={};for(const O of w1.value)O.path&&(K[O.path]=(K[O.path]??0)+(O.severity==="blocking"?10:1));for(const O of Y1.value)K[O.path]=(K[O.path]??0)+1;return K}),y1=t1(()=>[..._.value].sort((K,O)=>(b1.value[O.path]??0)-(b1.value[K.path]??0))),k1=t1(()=>_.value.find(K=>K.path===p.value)??y1.value[0]??null),c1=t1(()=>w1.value.filter(K=>!K.path)),L1=t1(()=>{var K;return((K=u.value)==null?void 0:K.review)??null}),S1=t1(()=>{var K;return((K=L1.value)==null?void 0:K.summary)??null}),Y1=t1(()=>{var K;return((K=L1.value)==null?void 0:K.suggestions)??[]}),q1=t1(()=>m1.value.filter(K=>!K.passed)),s1=t1(()=>{var K;return((K=u.value)==null?void 0:K.commits)??[]}),q=t1(()=>{var K,O;return!!((K=S1.value)!=null&&K.overview)||q1.value.length>0||c1.value.length>0||Y1.value.length>0||Object.keys(((O=L1.value)==null?void 0:O.notes)??{}).length>0}),S=t1(()=>{const K=[{id:"overview",label:"Overview"},{id:"details",label:`Files${_.value.length?` ${_.value.length}`:""}`}];return K.push({id:"commits",label:`Commits${s1.value.length?` ${s1.value.length}`:""}`}),K}),o1={APPROVE:{label:"Approved",tone:"success"},REQUEST_CHANGES:{label:"Changes requested",tone:"danger"},COMMENT:{label:"Commented",tone:"warning"}},J=t1(()=>{var O;if(r1.value.length)return{label:"Changes requested",tone:"danger",count:r1.value.length};const K=(O=L1.value)==null?void 0:O.verdict;return K&&o1[K]?{...o1[K],count:Y1.value.length||null}:!m1.value.length&&!L1.value?{label:"Not reviewed",tone:"neutral",count:null}:{label:"Commented",tone:"warning",count:l1.value.length||null}}),A1={success:hu,danger:Q7,warning:yu,neutral:Le},x1=t1(()=>u.value?A1[J.value.tone]:Le),g={BUG:"danger",SECURITY:"danger",PERFORMANCE:"warning",REFACTOR:"info",STYLE:"neutral",CLARITY:"neutral",TEST:"info",DOCUMENTATION:"neutral"},v=K=>g[String(K||"").toUpperCase()]??"info",Z=K=>[...w1.value.filter(O=>O.path===K).map(O=>({...O,from:O.skill,tone:O.severity==="blocking"?"danger":"warning"})),...Y1.value.filter(O=>O.path===K).map(O=>({line:O.start_line,severity:"suggestion",detail:O.comment,code:O.suggested_code,replacing:O.existing_code,from:O.category||"review",tone:v(O.category)}))];async function L(K){K&&(r.value=K,await Promise.all([e1(),T()]))}async function T(){try{M.value=await B1.reviews(r.value)}catch{M.value=[]}}function W(K){if(!K)return"";const O=new Date(K),p1=Math.round((Date.now()-O.getTime())/6e4);if(p1<1)return"just now";if(p1<60)return`${p1} minute${p1===1?"":"s"} ago`;const H=Math.round(p1/60);return H<24?`${H} hour${H===1?"":"s"} ago`:O.toLocaleDateString()}async function a1(){try{const K=await B1.settings(),O=K.find(H=>H.key==="model.name"),p1=K.find(H=>H.key==="model.api_key");m.value=!!(O!=null&&O.value)&&!!(p1!=null&&p1.is_set)}catch{m.value=!1}}async function e1(){try{F.value=(await B1.skills(r.value)).skills}catch{F.value=[]}}let j=null;function V(){j&&clearTimeout(j),j=null}async function g1(K){V();const O=K?d:c;O.value=!0,s.value="";try{const p1=await B1.startReview(r.value,{useModel:K,skills:[...y.value]});n.replace(`/reviews/${p1.id}`),await i1(p1.id,K)}catch(p1){s.value=p1.message,O.value=!1}}async function i1(K,O=!0){const p1=O?d:c;let H;try{H=await B1.reviewed(K)}catch(D1){s.value=D1.message,p1.value=!1;return}if(A.value=H,H.status==="running"){p1.value=!0,j=setTimeout(()=>i1(K,O),UA);return}if(p1.value=!1,H.status==="failed"){s.value=H.error;return}H.repository&&H.repository!==r.value&&(r.value=H.repository),u.value=H.review,p.value="",E.value="overview",T(),H.repository&&(r.value=H.repository),y.value=(H.review.skills??[]).map(D1=>D1.id)}return t2(r,()=>{V(),e1(),T()}),t2(R,K=>{if(V(),!K){u.value=null,A.value=null,T();return}i1(K)}),f4(V),d2(async()=>{await i(),await Promise.all([a1(),e1(),T()]),R.value&&await i1(R.value)}),(K,O)=>{var p1;return h(),C("div",uA,[I(f(m3),{pillar:"review",title:Y.value?`${Y.value.branch||"no branch"} → ${Y.value.against}`:"Reviews",sub:Y.value?Y.value.path:"Your work read here, before anybody else is asked to read it.",mono:!!Y.value,tone:u.value?J.value.tone:void 0},a6({icon:w(()=>[(h(),G(k2(x1.value),{class:"h-6 w-6"}))]),actions:w(()=>[f(o).length>1?(h(),G(f(j2),{key:0,modelValue:f(r),"onUpdate:modelValue":O[1]||(O[1]=H=>n2(r)?r.value=H:null),size:"sm","aria-label":"Repository"},{default:w(()=>[b("option",{value:f(Vt)},"All repositories",8,fA),(h(!0),C(n1,null,_1(f(o),H=>(h(),C("option",{key:H.name,value:H.name},N(H.name),9,AA))),128))]),_:1},8,["modelValue"])):P("",!0),f(o).length&&f(r)?(h(),G(f(C1),{key:1,size:"sm",variant:"outline",disabled:c.value,onClick:O[2]||(O[2]=H=>g1(!1))},{default:w(()=>[c.value?(h(),G(f(M2),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):(h(),G(f(p5),{key:1,class:"mr-2 h-4 w-4"})),U(" "+N(c.value?"Reading…":"Read what changed"),1)]),_:1},8,["disabled"])):P("",!0),f(o).length&&m.value&&f(r)?(h(),G(f(C1),{key:2,size:"sm",variant:"glow",disabled:d.value,onClick:O[3]||(O[3]=H=>g1(!0))},{default:w(()=>[d.value?(h(),G(f(M2),{key:0,class:"mr-2 h-4 w-4 animate-spin"})):(h(),G(f(_n),{key:1,class:"mr-2 h-4 w-4"})),U(" "+N(d.value?"Reviewing…":"Review it"),1)]),_:1},8,["disabled"])):f(o).length&&m.value?(h(),G(f(j2),{key:3,"model-value":"",size:"sm","aria-label":"Choose a repository to review","onUpdate:modelValue":L},{default:w(()=>[O[5]||(O[5]=b("option",{value:""},"Choose a repository…",-1)),(h(!0),C(n1,null,_1(f(o),H=>(h(),C("option",{key:H.name,value:H.name},N(H.name),9,hA))),128))]),_:1})):P("",!0)]),_:2},[R.value?{name:"back",fn:w(()=>[I(f(C1),{variant:"ghost",size:"icon","aria-label":"Back to reviews",onClick:O[0]||(O[0]=H=>f(l)("/reviews"))},{default:w(()=>[I(f(Yt),{class:"h-4 w-4"})]),_:1})]),key:"0"}:void 0,u.value?{name:"meta",fn:w(()=>[I(f(mn),{label:J.value.label,tone:J.value.tone,count:J.value.count},null,8,["label","tone","count"]),Y.value?(h(),C("span",dA,N(Y.value.commits)+" commit"+N(Y.value.commits===1?"":"s")+" ahead",1)):P("",!0),b("span",null,N(_.value.length)+" file"+N(_.value.length===1?"":"s"),1)]),key:"1"}:void 0]),1032,["title","sub","mono","tone"]),f(s)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(s)),1)]),_:1})):P("",!0),f(o).length===0?(h(),G(p4,{key:1})):(h(),C(n1,{key:2},[!m.value&&f(r)?(h(),G(f(u2),{key:0,tone:"info",class:"mb-4"},{default:w(()=>[...O[6]||(O[6]=[U(" No model is configured, so nothing here can be judged. Reading what changed needs nothing. Choose a model in Settings to have the work read against your skills. ",-1)])]),_:1})):P("",!0),u.value?(h(),C(n1,{key:2},[b("div",gA,[I(f(ge),{modelValue:E.value,"onUpdate:modelValue":O[4]||(O[4]=H=>E.value=H),tabs:S.value,label:"What to look at",class:"w-fit"},null,8,["modelValue","tabs"]),b("div",vA,[O[11]||(O[11]=b("span",{class:"text-xs uppercase tracking-wider text-muted-foreground"}," Skills applied ",-1)),(h(!0),C(n1,null,_1(y.value,H=>(h(),G(f(u7),{key:H,label:x(H),tone:Q(H)===void 0?"default":Q(H)?"success":"danger",removable:"",onRemove:D1=>B(H)},{default:w(()=>[U(N(x(H)),1)]),_:2},1032,["label","tone","onRemove"]))),128)),y.value.length?P("",!0):(h(),G(f(u7),{key:0,tone:"muted"},{default:w(()=>[...O[9]||(O[9]=[U("Whatever applies",-1)])]),_:1})),$.value.length?(h(),G(f(j2),{key:1,"model-value":k.value,size:"sm","aria-label":"Add a skill","onUpdate:modelValue":X},{default:w(()=>[O[10]||(O[10]=b("option",{value:""},"Add…",-1)),(h(!0),C(n1,null,_1($.value,H=>(h(),C("option",{key:H.id,value:H.id},N(H.name),9,yA))),128))]),_:1},8,["model-value"])):P("",!0)])]),u.value.note&&!L1.value?(h(),G(f(u2),{key:0,tone:"info",class:"mb-3"},{default:w(()=>[U(N(u.value.note),1)]),_:1})):P("",!0),E.value==="commits"?(h(),C("div",bA,[s1.value.length?(h(),G(f(z1),{key:1,class:"divide-y px-4 py-1"},{default:w(()=>[(h(!0),C(n1,null,_1(s1.value,H=>(h(),C("div",{key:H.sha,class:"py-2.5"},[(h(),G(k2(H.body?"details":"div"),{class:f1(H.body&&"group")},{default:w(()=>[(h(),G(k2(H.body?"summary":"div"),{class:f1(["flex items-baseline gap-2 text-sm",H.body&&"cursor-pointer list-none"])},{default:w(()=>[I(f(gu),{class:"h-3.5 w-3.5 shrink-0 self-center text-muted-foreground"}),b("span",kA,N(H.subject),1),b("span",CA,N(H.sha.slice(0,8)),1),b("span",wA,N(H.author),1),b("span",xA,N(W(H.at)),1)]),_:2},1032,["class"])),H.body?(h(),C("p",_A,N(H.body),1)):P("",!0)]),_:2},1032,["class"]))]))),128))]),_:1})):(h(),G(f(We),{key:0,title:"Nothing committed on this branch",compact:""},{default:w(()=>[...O[12]||(O[12]=[U(" Everything here is uncommitted work, which is in the diff rather than in a commit. ",-1)])]),_:1}))])):E.value==="overview"?(h(),C("div",IA,[q.value?(h(),G(f(z1),{key:1,class:"divide-y px-5 py-1"},{default:w(()=>{var H,D1,V1,e2,C2,w2,v3,ye;return[(H=S1.value)!=null&&H.overview?(h(),G(f(O3),{key:0,title:"What this change does",tone:"info"},{icon:w(()=>[I(f(N7),{class:"h-4 w-4"})]),default:w(()=>[I(f(B2),{source:S1.value.overview},null,8,["source"])]),_:1})):P("",!0),q1.value.length||c1.value.length?(h(),G(f(O3),{key:1,title:"Against what this team wrote down",tone:"warning",count:q1.value.length+c1.value.length,collapsible:"",closed:""},{icon:w(()=>[I(f(Cu),{class:"h-4 w-4"})]),default:w(()=>[b("ul",MA,[(h(!0),C(n1,null,_1(q1.value,M1=>(h(),C("li",{key:M1.skill,class:"py-2 first:pt-0"},[b("details",null,[b("summary",EA,[I(f($e),{tone:"danger",title:`${M1.skill} is not met`},null,8,["title"]),b("span",DA,N(M1.skill),1),b("span",ZA,N((M1.note||"").split(` +`)[0]),1)]),M1.note?(h(),G(f(B2),{key:0,source:M1.note,class:"mt-2 pl-5 text-sm text-muted-foreground"},null,8,["source"])):P("",!0)])]))),128)),(h(!0),C(n1,null,_1(c1.value,(M1,U1)=>(h(),C("li",{key:`o${U1}`,class:"py-2 first:pt-0"},[b("details",null,[b("summary",FA,[I(f($e),{tone:M1.severity==="blocking"?"danger":"warning",title:M1.skill||"A skill"},null,8,["tone","title"]),b("span",BA,N(M1.skill),1),b("span",SA,N((M1.detail||"").split(` +`)[0]),1)]),I(f(B2),{source:M1.detail,class:"mt-2 pl-5 text-sm text-muted-foreground"},null,8,["source"])])]))),128))])]),_:1},8,["count"])):P("",!0),(V1=(D1=S1.value)==null?void 0:D1.critical_issues)!=null&&V1.length?(h(),G(f(O3),{key:2,title:"Worth stopping for",tone:"danger",count:S1.value.critical_issues.length,collapsible:""},{icon:w(()=>[I(f(Q7),{class:"h-4 w-4"})]),default:w(()=>[b("ul",RA,[(h(!0),C(n1,null,_1(S1.value.critical_issues,(M1,U1)=>(h(),C("li",{key:U1},[I(f(B2),{source:M1},null,8,["source"])]))),128))])]),_:1},8,["count"])):P("",!0),(C2=(e2=S1.value)==null?void 0:e2.key_improvements)!=null&&C2.length?(h(),G(f(O3),{key:3,title:"Worth changing",tone:"warning",count:S1.value.key_improvements.length,collapsible:""},{icon:w(()=>[I(f(V4),{class:"h-4 w-4"})]),default:w(()=>[b("ul",QA,[(h(!0),C(n1,null,_1(S1.value.key_improvements,(M1,U1)=>(h(),C("li",{key:U1},[I(f(B2),{source:M1},null,8,["source"])]))),128))])]),_:1},8,["count"])):P("",!0),(v3=(w2=S1.value)==null?void 0:w2.minor_suggestions)!=null&&v3.length?(h(),G(f(O3),{key:4,title:"Nice to have",count:S1.value.minor_suggestions.length,collapsible:"",closed:""},{icon:w(()=>[I(f(gt),{class:"h-4 w-4"})]),default:w(()=>[b("ul",NA,[(h(!0),C(n1,null,_1(S1.value.minor_suggestions,(M1,U1)=>(h(),C("li",{key:U1},[I(f(B2),{source:M1},null,8,["source"])]))),128))])]),_:1},8,["count"])):P("",!0),Y1.value.length?(h(),G(f(O3),{key:5,title:"Suggestions",tone:"info",count:Y1.value.length,collapsible:""},{icon:w(()=>[I(f(fu),{class:"h-4 w-4"})]),default:w(()=>[O[13]||(O[13]=b("p",{class:"mb-3 text-sm text-muted-foreground"}," Each one is drawn against the line it is about, under Files. ",-1)),b("ul",KA,[(h(!0),C(n1,null,_1(Y1.value,(M1,U1)=>(h(),C("li",{key:U1,class:"flex gap-2"},[M1.category?(h(),G(f($e),{key:0,tone:v(M1.category),title:M1.category,label:M1.category.toLowerCase(),class:"mt-0.5 shrink-0"},null,8,["tone","title","label"])):P("",!0),b("button",{type:"button",class:"min-w-0 text-left hover:underline",onClick:v5=>{p.value=M1.path,E.value="details"}},[b("span",OA,N(M1.path)+":"+N(M1.start_line),1),I(f(B2),{source:M1.comment,class:"text-muted-foreground"},null,8,["source"])],8,GA)]))),128))])]),_:1},8,["count"])):P("",!0),(h(!0),C(n1,null,_1(((ye=L1.value)==null?void 0:ye.notes)??{},(M1,U1)=>(h(),G(f(O3),{key:U1,title:String(U1).replace(/_/g," "),collapsible:"",closed:"",class:"capitalize"},{icon:w(()=>[I(f(N7),{class:"h-4 w-4"})]),default:w(()=>[I(f(B2),{source:M1,class:"normal-case"},null,8,["source"])]),_:2},1032,["title"]))),128))]}),_:1})):(h(),G(f(We),{key:0,title:"Read, not judged",compact:""},{default:w(()=>[U(N(u.value.note||"Ask for a review to have it read properly."),1)]),_:1}))])):(h(),C("div",$A,[I(f(z1),{class:"flex min-h-0 flex-col overflow-hidden"},{default:w(()=>[O[14]||(O[14]=b("div",{class:"border-b px-3 py-2 text-xs uppercase tracking-wider text-muted-foreground"}," Changed ",-1)),b("ul",WA,[(h(!0),C(n1,null,_1(y1.value,H=>{var D1;return h(),C("li",{key:H.path},[b("button",{type:"button",class:f1(["flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",((D1=k1.value)==null?void 0:D1.path)===H.path?"bg-primary/10 text-primary":"hover:bg-muted"]),onClick:V1=>p.value=H.path},[b("span",{class:"min-w-0 flex-1 truncate font-mono text-xs",title:H.path},N(H.path),9,PA),Z(H.path).length?(h(),G(f(c2),{key:0,variant:b1.value[H.path]>=10?"destructive":"secondary"},{default:w(()=>[U(N(Z(H.path).length),1)]),_:2},1032,["variant"])):P("",!0),b("span",HA,N(H.change.slice(0,3)),1)],10,LA)])}),128))])]),_:1}),b("div",TA,[k1.value?(h(),C(n1,{key:0},[b("div",YA,[b("span",VA,N(k1.value.path),1),I(f(c2),{variant:"secondary"},{default:w(()=>[U(N(k1.value.change),1)]),_:1})]),I(f(L9),{patch:k1.value.patch,notes:Z(k1.value.path)},null,8,["patch","notes"])],64)):(h(),G(f(z1),{key:1,class:"p-10 text-center text-sm text-muted-foreground"},{default:w(()=>[...O[15]||(O[15]=[U(" Nothing has changed in this checkout. ",-1)])]),_:1}))])]))],64)):(h(),C(n1,{key:1},[((p1=A.value)==null?void 0:p1.status)==="running"?(h(),G(f(tu),{key:0,label:"Reading it",note:"This keeps going whether or not anybody is watching, and the link to it keeps working."})):(h(),C(n1,{key:1},[M.value.length?P("",!0):(h(),G(f(We),{key:0,title:"Nothing read here yet"},a6({icon:w(()=>[I(f(Le),{class:"h-8 w-8"})]),default:w(()=>[O[7]||(O[7]=U(" Everything comes off the checkout, so work you have not pushed, or not committed, still gets a review. ",-1))]),_:2},[f(r)?void 0:{name:"actions",fn:w(()=>[(h(!0),C(n1,null,_1(f(o),H=>(h(),G(f(C1),{key:H.name,size:"sm",variant:"outline",onClick:D1=>L(H.name)},{default:w(()=>[I(f(i4),{class:"mr-2 h-4 w-4"}),U(" "+N(H.name),1)]),_:2},1032,["onClick"]))),128))]),key:"0"}]),1024)),M.value.length?(h(),C(n1,{key:1},[O[8]||(O[8]=b("p",{class:"mb-2 text-xs uppercase tracking-wider text-muted-foreground"},"Earlier",-1)),b("div",pA,[(h(!0),C(n1,null,_1(M.value,H=>(h(),G(f(z3),{key:H.id,title:H.title||H.repository,subtitle:H.id,pillar:"review",hover:"",class:"cursor-pointer",onClick:D1=>f(n).push(`/reviews/${H.id}`)},{icon:w(()=>[I(f(pu),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:H.status==="done"?"success":H.status==="failed"?"destructive":"secondary"},{default:w(()=>[U(N(H.status),1)]),_:2},1032,["variant"])]),meta:w(()=>[b("span",null,N(W(H.started)),1),f(a)?(h(),G(f(gn),{key:0,name:H.repository},{icon:w(()=>[I(f(i4),{class:"h-3 w-3"})]),_:1},8,["name"])):(h(),C("span",mA,N(H.repository),1))]),_:2},1032,["title","subtitle","onClick"]))),128))])],64)):P("",!0)],64))],64))],64))])}}},JA={class:"flex h-full min-h-0 flex-col"},zA={key:0,class:"text-xs text-success"},jA={key:2,class:"py-10 text-center text-sm text-muted-foreground"},XA=["value"],qA={class:"flex flex-wrap gap-1.5"},eh={class:"mt-2 text-xs text-muted-foreground"},th={class:"mb-2 flex items-center justify-between gap-3"},nh={class:"text-xs text-muted-foreground"},lh={class:"grid min-h-0 flex-1 gap-3 lg:grid-cols-2"},oh={key:1,class:"text-sm text-muted-foreground"},rh="new",E4="repository",P2="global",sh={__name:"Skill",setup(e){const t=[E4,P2],n=d5(),l=me(),o=Ut(),{repositories:r,chosen:s,fetchRepositories:a}=g3(),i=t1(()=>String(n.params.id??"")),c=t1(()=>i.value===rh),d=z(null),u=z({id:"",name:"",description:"",body:"",paths:[],reviews:null}),A=z(P2),m=z("write"),p=z(!1),y=z(!1),k=z(""),F=z(!0),M=[{id:"write",label:"Write"},{id:"preview",label:"Preview"}],E=[{id:null,label:"When it looks relevant"},{id:!0,label:"Always"},{id:!1,label:"Never"}],_=t1(()=>u.value.reviews===!0?"Read against every change here.":u.value.reviews===!1?"Left out of reviews entirely.":"Picked when what it says matches what a change touches."),R=t1(()=>D.value?"Kept on this machine and read for every repository you work in.":`Kept on this machine and read for ${A.value}. Nothing is written into the checkout.`),$=t1(()=>[{id:P2,label:"Everywhere"},...r.value.map(r1=>({id:r1.name,label:r1.name}))]),D=t1(()=>A.value===P2),x=t1(()=>!!d.value&&!t.includes(d.value.origin)),Q=t1(()=>x.value),B=t1(()=>c.value?!!(u.value.id||u.value.description||u.value.body):d.value?u.value.name!==d.value.name||u.value.description!==d.value.description||u.value.body!==(d.value.body??"")||u.value.paths.join(` +`)!==(d.value.paths??[]).join(` +`)||u.value.reviews!==d.value.reviews:!1),X=t1(()=>u.value.body?u.value.body.split(` +`).length:0);async function Y(){if(F.value=!0,k.value="",c.value){d.value=null,u.value={id:"",name:"",description:"",body:"",paths:[],reviews:null},A.value=n.query.for||s.value||P2,F.value=!1;return}try{const r1=await B1.skill(i.value,s.value);d.value=r1,A.value=r1.origin===E4?s.value:r1.origin===P2?P2:s.value||P2,u.value={id:r1.id.split("/").pop(),name:r1.name,description:r1.description,body:r1.body??"",paths:[...r1.paths??[]],reviews:r1.reviews}}catch(r1){k.value=r1.message}finally{F.value=!1}}async function m1(){p.value=!0,y.value=!1,k.value="";try{const r1=await B1.recordSkill({scope:D.value?P2:E4,repository:D.value?"":A.value,id:u.value.id||u.value.name,name:u.value.name||u.value.id,description:u.value.description,body:u.value.body,paths:u.value.paths,reviews:u.value.reviews});y.value=!0,c.value||r1.id!==i.value?l.replace(`/skills/${r1.id}`):await Y()}catch(r1){k.value=r1.message}finally{p.value=!1}}async function w1(){const r1=D.value?"everywhere":A.value;if(confirm(`Forget ${u.value.name}? + +It stops being read for ${r1}.`))try{await B1.forgetSkill(D.value?"":A.value,D.value?P2:E4,i.value),l.push("/skills")}catch(l1){k.value=l1.message}}return t2(i,Y),d2(async()=>{await a(),await Y()}),(r1,l1)=>{var b1,y1;return h(),C("div",JA,[I(f(m3),{pillar:"review",title:c.value?"A new skill":u.value.name||i.value,sub:((b1=d.value)==null?void 0:b1.path)||R.value,mono:!!((y1=d.value)!=null&&y1.path)},{back:w(()=>[I(f(C1),{variant:"ghost",size:"icon","aria-label":"Back to skills",onClick:l1[0]||(l1[0]=k1=>f(o)("/skills"))},{default:w(()=>[I(f(Yt),{class:"h-4 w-4"})]),_:1})]),icon:w(()=>[I(f(c4),{class:"h-5 w-5"})]),badges:w(()=>[d.value?(h(),G(f(c2),{key:0,variant:x.value?"outline":"success"},{default:w(()=>[U(N(x.value?d.value.origin:D.value?"everywhere":A.value),1)]),_:1},8,["variant"])):P("",!0)]),actions:w(()=>[y.value&&!B.value?(h(),C("span",zA,"Saved.")):P("",!0),d.value&&!x.value?(h(),G(f(C1),{key:1,variant:"ghost",size:"icon","aria-label":"Forget this skill",onClick:w1},{default:w(()=>[I(f(h4),{class:"h-4 w-4"})]),_:1})):P("",!0),I(f(C1),{size:"sm",disabled:p.value||!B.value,onClick:m1},{default:w(()=>[p.value?(h(),G(f(M2),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(h(),G(k2(Q.value?f(pt):f(he)),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),U(" "+N(Q.value?"Save your own copy":"Save"),1)]),_:1},8,["disabled"])]),_:1},8,["title","sub","mono"]),Q.value?(h(),G(f(u2),{key:0,tone:"info",class:"mb-4"},{default:w(()=>[...l1[7]||(l1[7]=[U(" This one is not ours to change: it belongs to your coding agent, or your team committed it to the repository. Saving keeps a copy of our own, for whatever you choose below, and the copy is then the one that gets used. ",-1)])]),_:1})):P("",!0),k.value?(h(),G(f(u2),{key:1,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(k.value),1)]),_:1})):P("",!0),F.value?(h(),C("p",jA,"Reading it.")):(h(),C(n1,{key:3},[I(f(z1),{class:"mb-3 grid gap-4 p-5 lg:grid-cols-3"},{default:w(()=>[I(f(R2),{label:"Name",for:"skill-id",hint:"Lower case words joined by hyphens. It names the folder the skill is saved in."},{default:w(()=>[I(f(J3),{id:"skill-id",modelValue:u.value.id,"onUpdate:modelValue":l1[1]||(l1[1]=k1=>u.value.id=k1),readonly:!!d.value&&!x.value,placeholder:"retry-limit"},null,8,["modelValue","readonly"])]),_:1}),I(f(R2),{label:"Used for",for:"skill-belongs",hint:D.value?"Read for every repository you work in.":"Read only when reviewing that repository."},{default:w(()=>[I(f(j2),{id:"skill-belongs",modelValue:A.value,"onUpdate:modelValue":l1[2]||(l1[2]=k1=>A.value=k1),disabled:!!d.value&&!x.value,class:"w-full"},{default:w(()=>[(h(!0),C(n1,null,_1($.value,k1=>(h(),C("option",{key:k1.id,value:k1.id},N(k1.label),9,XA))),128))]),_:1},8,["modelValue","disabled"])]),_:1},8,["hint"]),I(f(R2),{label:"When it applies",for:"skill-description",hint:"One sentence. It decides whether a change gets read against this skill."},{default:w(()=>[I(f(J3),{id:"skill-description",modelValue:u.value.description,"onUpdate:modelValue":l1[3]||(l1[3]=k1=>u.value.description=k1),placeholder:"Use when a change adds or edits a database migration."},null,8,["modelValue"])]),_:1})]),_:1}),I(f(z1),{class:"mb-3 grid gap-4 p-5 lg:grid-cols-2"},{default:w(()=>[I(f(R2),{label:"Files it is about",for:"skill-paths",hint:`Globs, one to a line. Named here, a change is read against this only when it + touches one of them, whatever the wording says. Left empty, the wording decides.`},{default:w(()=>[I(f(O0),{modelValue:u.value.paths,"onUpdate:modelValue":l1[4]||(l1[4]=k1=>u.value.paths=k1),mono:"",size:"sm",noun:"a pattern",placeholder:"db/migrations/**"},null,8,["modelValue"])]),_:1}),I(f(R2),{label:"Use in reviews",hint:"Not everything you teach an agent is about judging a change."},{default:w(()=>[b("div",qA,[(h(),C(n1,null,_1(E,k1=>I(f(C1),{key:String(k1.id),size:"sm",variant:u.value.reviews===k1.id?"default":"outline",onClick:c1=>u.value.reviews=k1.id},{default:w(()=>[U(N(k1.label),1)]),_:2},1032,["variant","onClick"])),64))]),b("p",eh,N(_.value),1)]),_:1})]),_:1}),b("div",th,[I(f(ge),{modelValue:m.value,"onUpdate:modelValue":l1[5]||(l1[5]=k1=>m.value=k1),tabs:M,label:"Write or preview",class:"lg:hidden"},null,8,["modelValue"]),l1[8]||(l1[8]=b("p",{class:"hidden text-xs uppercase tracking-wider text-muted-foreground lg:block"}," What it says ",-1)),b("p",nh,N(X.value)+" line"+N(X.value===1?"":"s")+" · markdown ",1)]),b("div",lh,[I(f(dt),{modelValue:u.value.body,"onUpdate:modelValue":l1[6]||(l1[6]=k1=>u.value.body=k1),class:f1(["h-full min-h-[24rem] resize-none font-mono leading-relaxed",m.value==="write"?"":"hidden lg:block"]),placeholder:"Never edit a migration that has already run. Add a new one instead.","aria-label":"What the skill says"},null,8,["modelValue","class"]),I(f(z1),{class:f1(["h-full min-h-[24rem] overflow-auto p-5",m.value==="preview"?"":"hidden lg:block"])},{default:w(()=>[u.value.body?(h(),G(f(B2),{key:0,source:u.value.body},null,8,["source"])):(h(),C("p",oh," Nothing written yet. What appears here is what a person reads, and what a model is given when your work is checked against this skill. "))]),_:1},8,["class"])])],64))])}}},ah=["value"],ih={class:"relative"},ch={key:0,class:"space-y-3"},uh={class:"text-sm text-muted-foreground"},dh={key:0,class:"text-success"},fh={key:1},Ah={key:2},hh={key:3,class:"font-mono"},De="repository",ee="global",ph={__name:"Skills",setup(e){const t=[De,ee],n=me(),{repositories:l,chosen:o,error:r,fetchRepositories:s}=g3(),a=z([]),i=z(""),c=z("all"),d=[{id:"all",label:"All"},{id:De,label:"This repository"},{id:ee,label:"Everywhere"},{id:"agents",label:"Your coding agents"}],u=t1(()=>{const k=i.value.trim().toLowerCase();return a.value.filter(F=>c.value===De&&F.origin!==De||c.value===ee&&F.origin!==ee||c.value==="agents"&&t.includes(F.origin)?!1:k?F.name.toLowerCase().includes(k)||F.description.toLowerCase().includes(k):!0)}),A=k=>t.includes(k.origin),m=k=>k.origin===ee?"everywhere":k.origin===De?o.value:k.origin;async function p(){try{const k=await B1.skills(o.value);a.value=k.skills,r.value=""}catch(k){a.value=[],r.value=k.message}}async function y(k){if(confirm(`Forget ${k.name}? + +The file is removed from ${m(k)}.`))try{await B1.forgetSkill(k.origin===ee?"":o.value,k.origin,k.id),await p()}catch(F){r.value=F.message}}return t2(o,p),d2(async()=>{await s(),await p()}),(k,F)=>(h(),C("div",null,[I(f(m3),{pillar:"review",title:"Skills",sub:"What your work is read against: this repository's, this machine's, and your own."},{icon:w(()=>[I(f(vn),{class:"h-6 w-6"})]),actions:w(()=>[f(l).length>1?(h(),G(f(j2),{key:0,modelValue:f(o),"onUpdate:modelValue":F[0]||(F[0]=M=>n2(o)?o.value=M:null),size:"sm","aria-label":"Repository"},{default:w(()=>[(h(!0),C(n1,null,_1(f(l),M=>(h(),C("option",{key:M.name,value:M.name},N(M.name),9,ah))),128))]),_:1},8,["modelValue"])):P("",!0),b("div",ih,[I(f(wn),{class:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),I(f(J3),{modelValue:i.value,"onUpdate:modelValue":F[1]||(F[1]=M=>i.value=M),size:"sm",placeholder:"Find a skill",class:"w-48 pl-8","aria-label":"Find a skill"},null,8,["modelValue"])]),f(l).length?(h(),G(f(C1),{key:1,size:"sm",variant:"glow",onClick:F[2]||(F[2]=M=>f(n).push({path:"/skills/new",query:{for:f(o)}}))},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),F[5]||(F[5]=U(" Write one down ",-1))]),_:1})):P("",!0)]),_:1}),f(r)?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(f(r)),1)]),_:1})):P("",!0),f(l).length===0?(h(),G(p4,{key:1})):(h(),C(n1,{key:2},[I(f(ge),{modelValue:c.value,"onUpdate:modelValue":F[3]||(F[3]=M=>c.value=M),tabs:d,label:"Where they are kept",class:"mb-4"},null,8,["modelValue"]),u.value.length?(h(),C("div",ch,[(h(!0),C(n1,null,_1(u.value,M=>(h(),G(f(z3),{key:M.id,title:M.name,subtitle:M.path,pillar:"review",hover:"",class:"cursor-pointer",onClick:E=>f(n).push(`/skills/${M.id}`)},{icon:w(()=>[I(f(c4),{class:"h-5 w-5"})]),badges:w(()=>[I(f(c2),{variant:A(M)?"success":"outline"},{default:w(()=>[U(N(m(M)),1)]),_:2},1032,["variant"])]),meta:w(()=>{var E;return[M.reviews===!0?(h(),C("span",dh,"always in reviews")):M.reviews===!1?(h(),C("span",fh,"not used in reviews")):M.automatic?P("",!0):(h(),C("span",Ah,"only when you invoke it")),(E=M.paths)!=null&&E.length?(h(),C("span",hh,N(M.paths.join(" ")),1)):P("",!0)]}),actions:w(()=>[A(M)?(h(),G(f(C1),{key:0,variant:"ghost",size:"icon","aria-label":`Forget ${M.name}`,onClick:qe(E=>y(M),["stop"])},{default:w(()=>[I(f(h4),{class:"h-4 w-4"})]),_:1},8,["aria-label","onClick"])):P("",!0)]),default:w(()=>[b("p",uh,N(M.description),1)]),_:2},1032,["title","subtitle","onClick"]))),128))])):(h(),G(f(z1),{key:1,class:"p-10 text-center"},{default:w(()=>[I(f(c4),{class:"mx-auto mb-3 h-8 w-8 text-muted-foreground"}),F[7]||(F[7]=b("p",{class:"font-medium"},"Nothing written down here yet.",-1)),F[8]||(F[8]=b("p",{class:"mx-auto mt-1 max-w-lg text-sm text-muted-foreground"}," A skill says when it applies and what it says to do. Anything you have already taught Claude or Codex is read from their own folders, and anything your team committed is read from the repository. What you write here is kept beside the index rather than in anybody's checkout. ",-1)),I(f(C1),{class:"mt-4",variant:"glow",onClick:F[4]||(F[4]=M=>f(n).push({path:"/skills/new",query:{for:f(o)}}))},{default:w(()=>[I(f(h3),{class:"mr-2 h-4 w-4"}),F[6]||(F[6]=U(" Write one down ",-1))]),_:1})]),_:1}))],64))]))}},mh={class:"space-y-4"},gh={class:"mb-3 flex flex-wrap items-center justify-between gap-2"},vh={class:"font-mono text-sm text-muted-foreground"},yh={class:"mb-2 flex flex-wrap items-center justify-between gap-2"},bh={class:"overflow-x-auto rounded-md bg-muted/50 p-3 text-xs"},kh={class:"mb-2 flex flex-wrap items-center justify-between gap-2"},Ch={class:"overflow-x-auto rounded-md bg-muted/50 p-3 text-xs"},wh={__name:"McpPanel",setup(e){const t=z(""),n=z(null),l=z(""),o=t1(()=>window.location.origin),r=t1(()=>JSON.stringify({mcpServers:{sourceant:{command:"sourceant",args:["mcp"],env:{SOURCEANT_UI_URL:o.value}}}},null,2)),s=t1(()=>JSON.stringify({mcpServers:{sourceant:{type:"http",url:`${o.value}/mcp`}}},null,2));async function a(i,c){await navigator.clipboard.writeText(c),l.value=i,setTimeout(()=>l.value="",1500)}return d2(async()=>{t.value=`${o.value}/mcp`;try{const i=await fetch(t.value,{method:"GET"});n.value=i.status!==404}catch{n.value=!1}}),(i,c)=>(h(),C("div",mh,[I(f(z1),{class:"p-5"},{default:w(()=>[b("div",gh,[c[2]||(c[2]=b("h2",{class:"font-semibold"},"Endpoint",-1)),I(f(mn),{label:n.value===null?"Checking":n.value?"Serving":"Not mounted",tone:n.value===null?"neutral":n.value?"success":"warning",busy:n.value===null},null,8,["label","tone","busy"])]),b("p",vh,N(t.value),1),n.value===!1?(h(),G(f(u2),{key:0,tone:"info",class:"mt-3"},{default:w(()=>[...c[3]||(c[3]=[U(" Nothing is mounted there. The HTTP endpoint is served when this machine is running in local mode; over stdio it needs no endpoint at all. ",-1)])]),_:1})):P("",!0)]),_:1}),I(f(z1),{class:"p-5"},{default:w(()=>[b("div",yh,[c[4]||(c[4]=b("h2",{class:"font-semibold"},"Over stdio",-1)),I(f(C1),{size:"sm",variant:"outline",onClick:c[0]||(c[0]=d=>a("stdio",r.value))},{default:w(()=>[(h(),G(k2(l.value==="stdio"?f(he):f(pt)),{class:"mr-2 h-3.5 w-3.5"})),U(" "+N(l.value==="stdio"?"Copied":"Copy"),1)]),_:1})]),c[5]||(c[5]=b("p",{class:"mb-3 text-sm text-muted-foreground"}," One process per client, started by the client. A review asked for this way is handed to this agent, so it finishes even after the client goes away. ",-1)),b("pre",bh,[b("code",null,N(r.value),1)])]),_:1}),I(f(z1),{class:"p-5"},{default:w(()=>[b("div",kh,[c[6]||(c[6]=b("h2",{class:"font-semibold"},"Over HTTP",-1)),I(f(C1),{size:"sm",variant:"outline",onClick:c[1]||(c[1]=d=>a("http",s.value))},{default:w(()=>[(h(),G(k2(l.value==="http"?f(he):f(pt)),{class:"mr-2 h-3.5 w-3.5"})),U(" "+N(l.value==="http"?"Copied":"Copy"),1)]),_:1})]),c[7]||(c[7]=b("p",{class:"mb-3 text-sm text-muted-foreground"}," One server, several clients. Reachable from this machine only. ",-1)),b("pre",Ch,[b("code",null,N(s.value),1)])]),_:1})]))}},xh={key:0,class:"grid gap-x-4 gap-y-2 text-sm sm:grid-cols-[auto_1fr]"},_h={class:"font-mono"},Ih={class:"break-all font-mono"},Mh={class:"font-mono"},Eh={key:0,class:"ml-2 text-xs text-muted-foreground"},Dh={class:"break-all font-mono"},Zh={class:"font-mono"},Fh={class:"font-mono"},Bh={class:"mb-1 font-semibold"},Sh={key:0,class:"mb-4 text-sm text-muted-foreground"},Y5="overview",P7="mcp",Rh={__name:"Settings",setup(e){const{isDark:t,toggleTheme:n}=En(),l=z(null),o=z([]),r=z([]),s=z(""),a=z(Y5),i=t1(()=>[{id:Y5,label:"Overview"},...r.value.map(d=>({id:d,label:d})),{id:P7,label:"MCP"}]),c=t1(()=>{var u;return((u=l.value)==null?void 0:u.model)||"None chosen"});return d2(async()=>{var d,u;try{const[A,m,p]=await Promise.all([B1.status(),B1.settings(),B1.repositories().catch(()=>[])]);l.value={...A,model:((d=m.find(y=>y.key==="model.name"))==null?void 0:d.value)??"",keySet:!!((u=m.find(y=>y.key==="model.api_key"))!=null&&u.is_set)},o.value=p,r.value=[...new Set(m.map(y=>y.group).filter(Boolean))].sort()}catch(A){s.value=A.message}}),(d,u)=>(h(),C("div",null,[I(f(m3),{pillar:"tokens",title:"Settings",sub:"What is running, and how this looks."},{icon:w(()=>[I(f(mt),{class:"h-6 w-6"})]),actions:w(()=>[I(f(ge),{modelValue:a.value,"onUpdate:modelValue":u[0]||(u[0]=A=>a.value=A),tabs:i.value,label:"Settings"},null,8,["modelValue","tabs"])]),_:1}),s.value?(h(),G(f(u2),{key:0,tone:"danger",class:"mb-4"},{default:w(()=>[U(N(s.value),1)]),_:1})):P("",!0),a.value===Y5?(h(),C(n1,{key:1},[I(f(z1),{class:"mb-3 p-5"},{default:w(()=>[u[9]||(u[9]=b("h2",{class:"mb-3 font-semibold"},"This machine",-1)),l.value?(h(),C("dl",xh,[u[4]||(u[4]=b("dt",{class:"text-muted-foreground"},"Agent",-1)),b("dd",_h,N(l.value.version),1),u[5]||(u[5]=b("dt",{class:"text-muted-foreground"},"Indexer",-1)),b("dd",Ih,[U(N(l.value.core_url)+" ",1),I(f(c2),{variant:l.value.core_up?"success":"destructive",class:"ml-2"},{default:w(()=>[U(N(l.value.core_up?"answering":"not answering"),1)]),_:1},8,["variant"])]),u[6]||(u[6]=b("dt",{class:"text-muted-foreground"},"Starts",-1)),b("dd",Mh,[U(N(l.value.core_starts)+" ",1),l.value.core_starts>1?(h(),C("span",Eh," a number that keeps climbing is an indexer that keeps dying ")):P("",!0)]),l.value.last_exit?(h(),C(n1,{key:0},[u[1]||(u[1]=b("dt",{class:"text-muted-foreground"},"Last exit",-1)),b("dd",Dh,N(l.value.last_exit),1)],64)):P("",!0),u[7]||(u[7]=b("dt",{class:"text-muted-foreground"},"Folders read",-1)),b("dd",Zh,N(o.value.length),1),u[8]||(u[8]=b("dt",{class:"text-muted-foreground"},"Model",-1)),b("dd",Fh,[U(N(c.value)+" ",1),l.value.model&&l.value.keySet?(h(),G(f(c2),{key:0,variant:"success",class:"ml-2"},{default:w(()=>[...u[2]||(u[2]=[U("key set",-1)])]),_:1})):l.value.model?(h(),G(f(c2),{key:1,variant:"warning",class:"ml-2"},{default:w(()=>[...u[3]||(u[3]=[U("no key",-1)])]),_:1})):P("",!0)])])):P("",!0),u[10]||(u[10]=b("p",{class:"mt-4 text-xs text-muted-foreground"},[U(" Where the indexer comes from is chosen at install time and kept in "),b("code",{class:"font-mono"},"~/.sourceant/config.json"),U(". Nothing on this page has left this machine. ")],-1))]),_:1}),I(f(z1),{class:"p-5"},{default:w(()=>[u[11]||(u[11]=b("h2",{class:"mb-1 font-semibold"},"Appearance",-1)),u[12]||(u[12]=b("p",{class:"mb-4 text-sm text-muted-foreground"}," Kept in this browser, so it follows the screen rather than the machine. ",-1)),I(f(C1),{variant:"outline",onClick:f(n)},{default:w(()=>[(h(),G(k2(f(t)?f(xn):f(kn)),{class:"mr-2 h-4 w-4"})),U(" "+N(f(t)?"Light mode":"Dark mode"),1)]),_:1},8,["onClick"])]),_:1})],64)):a.value===P7?(h(),G(wh,{key:2})):(h(),G(f(z1),{key:3,class:"p-5"},{default:w(()=>[b("h2",Bh,N(a.value),1),a.value==="Model"?(h(),C("p",Sh," Reading a repository needs none of this. Anything that proposes or judges rather than reads does, and it stays off until you say which model to ask. ")):P("",!0),(h(),G(Dn,{key:a.value,group:a.value},null,8,["group"]))]),_:1}))]))}},Qh=vs({history:zr(),routes:[{path:"/",component:Ld},{path:"/graph",component:If},{path:"/knowledge",component:Kf},{path:"/reviews",component:L7},{path:"/reviews/:id",component:L7},{path:"/skills",component:ph},{path:"/skills/:id(.*)",component:sh},{path:"/repositories",component:Hf},{path:"/repositories/:name(.*)",component:cA},{path:"/settings",component:Rh},{path:"/:rest(.*)*",redirect:"/"}]});ur(Qd).use(Qh).mount("#app"); diff --git a/internal/ui/assets/assets/radial-aO03NmL0.js b/internal/ui/assets/assets/radial-aO03NmL0.js new file mode 100644 index 0000000..5b90e41 --- /dev/null +++ b/internal/ui/assets/assets/radial-aO03NmL0.js @@ -0,0 +1 @@ +var Nt={value:()=>{}};function ot(){for(var t=0,n=arguments.length,i={},e;t=0&&(e=i.slice(r+1),i=i.slice(0,r)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:e}})}C.prototype=ot.prototype={constructor:C,on:function(t,n){var i=this._,e=zt(t+"",i),r,s=-1,h=e.length;if(arguments.length<2){for(;++s0)for(var i=new Array(r),e=0,r,s;e=0&&t._call.call(void 0,n),t=t._next;--S}function nt(){O=(L=Y.now())+Q,S=X=0;try{Mt()}finally{S=0,qt(),O=0}}function $t(){var t=Y.now(),n=t-L;n>ut&&(Q-=n,L=t)}function qt(){for(var t,n=H,i,e=1/0;n;)n._call?(e>n._time&&(e=n._time),t=n,n=n._next):(i=n._next,n._next=null,n=t?t._next=i:H=i);B=t,G(e)}function G(t){if(!S){X&&(X=clearTimeout(X));var n=t-O;n>24?(t<1/0&&(X=setTimeout(nt,t-Y.now()-Q)),R&&(R=clearInterval(R))):(R||(L=Y.now(),R=setInterval($t,ut)),S=1,lt(nt))}}function Dn(t,n,i){var e,r=1;t==null&&(t=0),n==null&&(n=0),i==null&&(i=0);function s(){var h,l=e.length,u,f=0,c=0,a=0;for(h=0;h=(u=(h+l)/2))?h=u:l=u,e=r,!(r=r[a=+c]))return e[a]=s,t;if(f=+t._x.call(null,r.data),n===f)return s.next=r,e?e[a]=s:t._root=s,t;do e=e?e[a]=new Array(2):t._root=new Array(2),(c=n>=(u=(h+l)/2))?h=u:l=u;while((a=+c)==(v=+(f>=u)));return e[v]=r,e[a]=s,t}function It(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,i=new Float64Array(n);let e=1/0,r=-1/0;for(let s=0,h;sr&&(r=h));if(e>r)return this;this.cover(e).cover(r);for(let s=0;st||t>=i;)switch(h=+(th||(s=f.x1)=a))&&(f=l[l.length-1],l[l.length-1]=l[l.length-1-c],l[l.length-1-c]=f)}else{var v=Math.abs(t-+this._x.call(null,u.data));v=(f=(h+l)/2))?h=f:l=f,n=i,!(i=i[a=+c]))return this;if(!i.length)break;n[a+1&1]&&(e=n,v=a)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(s=i.next)&&delete i.next,r?(s?r.next=s:delete r.next,this):n?(s?n[a]=s:delete n[a],(i=n[0]||n[1])&&i===(n[1]||n[0])&&!i.length&&(e?e[v]=i:this._root=i),this):(this._root=s,this)}function Tt(t){for(var n=0,i=t.length;n=(a=(l+f)/2))?l=a:f=a,(y=i>=(v=(u+c)/2))?u=v:c=v,r=s,!(s=s[o=y<<1|z]))return r[o]=h,t;if(x=+t._x.call(null,s.data),_=+t._y.call(null,s.data),n===x&&i===_)return h.next=s,r?r[o]=h:t._root=h,t;do r=r?r[o]=new Array(4):t._root=new Array(4),(z=n>=(a=(l+f)/2))?l=a:f=a,(y=i>=(v=(u+c)/2))?u=v:c=v;while((o=y<<1|z)===(p=(_>=v)<<1|x>=a));return r[p]=s,r[o]=h,t}function Yt(t){var n,i,e=t.length,r,s,h=new Array(e),l=new Array(e),u=1/0,f=1/0,c=-1/0,a=-1/0;for(i=0;ic&&(c=r),sa&&(a=s));if(u>c||f>a)return this;for(this.cover(u,f).cover(c,a),i=0;it||t>=r||e>n||n>=s;)switch(f=(nc||(l=_.y0)>a||(u=_.x1)=o)<<1|t>=y)&&(_=v[v.length-1],v[v.length-1]=v[v.length-1-z],v[v.length-1-z]=_)}else{var p=t-+this._x.call(null,x.data),w=n-+this._y.call(null,x.data),N=p*p+w*w;if(N=(v=(h+u)/2))?h=v:u=v,(z=a>=(x=(l+f)/2))?l=x:f=x,n=i,!(i=i[y=z<<1|_]))return this;if(!i.length)break;(n[y+1&3]||n[y+2&3]||n[y+3&3])&&(e=n,o=y)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(s=i.next)&&delete i.next,r?(s?r.next=s:delete r.next,this):n?(s?n[y]=s:delete n[y],(i=n[0]||n[1]||n[2]||n[3])&&i===(n[3]||n[2]||n[1]||n[0])&&!i.length&&(e?e[o]=i:this._root=i),this):(this._root=s,this)}function Zt(t){for(var n=0,i=t.length;n=(_=(u+a)/2))?u=_:a=_,(g=i>=(z=(f+v)/2))?f=z:v=z,(d=e>=(y=(c+x)/2))?c=y:x=y,s=h,!(h=h[A=d<<2|g<<1|N]))return s[A]=l,t;if(o=+t._x.call(null,h.data),p=+t._y.call(null,h.data),w=+t._z.call(null,h.data),n===o&&i===p&&e===w)return l.next=h,s?s[A]=l:t._root=l,t;do s=s?s[A]=new Array(8):t._root=new Array(8),(N=n>=(_=(u+a)/2))?u=_:a=_,(g=i>=(z=(f+v)/2))?f=z:v=z,(d=e>=(y=(c+x)/2))?c=y:x=y;while((A=d<<2|g<<1|N)===(M=(w>=y)<<2|(p>=z)<<1|o>=_));return s[M]=h,s[A]=l,t}function sn(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,i=new Float64Array(n),e=new Float64Array(n),r=new Float64Array(n);let s=1/0,h=1/0,l=1/0,u=-1/0,f=-1/0,c=-1/0;for(let a=0,v,x,_,z;au&&(u=x),_f&&(f=_),zc&&(c=z));if(s>u||h>f||l>c)return this;this.cover(s,h,l).cover(u,f,c);for(let a=0;at||t>=h||r>n||n>=l||s>i||i>=u;)switch(v=(i_||(f=w.y0)>z||(c=w.z0)>y||(a=w.x1)=A)<<2|(n>=d)<<1|t>=g)&&(w=o[o.length-1],o[o.length-1]=o[o.length-1-N],o[o.length-1-N]=w)}else{var M=t-+this._x.call(null,p.data),D=n-+this._y.call(null,p.data),E=i-+this._z.call(null,p.data),k=M*M+D*D+E*E;if(kMath.sqrt((t-e)**2+(n-r)**2+(i-s)**2);function ln(t,n,i,e){const r=[],s=t-e,h=n-e,l=i-e,u=t+e,f=n+e,c=i+e;return this.visit((a,v,x,_,z,y,o)=>{if(!a.length)do{const p=a.data;un(t,n,i,this._x(p),this._y(p),this._z(p))<=e&&r.push(p)}while(a=a.next);return v>u||x>f||_>c||z=(z=(h+f)/2))?h=z:f=z,(w=x>=(y=(l+c)/2))?l=y:c=y,(N=_>=(o=(u+a)/2))?u=o:a=o,n=i,!(i=i[g=N<<2|w<<1|p]))return this;if(!i.length)break;(n[g+1&7]||n[g+2&7]||n[g+3&7]||n[g+4&7]||n[g+5&7]||n[g+6&7]||n[g+7&7])&&(e=n,d=g)}for(;i.data!==t;)if(r=i,!(i=i.next))return this;return(s=i.next)&&delete i.next,r?(s?r.next=s:delete r.next,this):n?(s?n[g]=s:delete n[g],(i=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&i===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!i.length&&(e?e[d]=i:this._root=i),this):(this._root=s,this)}function _n(t){for(var n=0,i=t.length;n1&&(D=A.y+A.vy-d.y-d.vy||T(c)),l>2&&(E=A.z+A.vz-d.z-d.vz||T(c)),k=Math.sqrt(M*M+D*D+E*E),k=(k-s[N])/k*o*e[N],M*=k,D*=k,E*=k,A.vx-=M*(q=f[N]),l>1&&(A.vy-=D*q),l>2&&(A.vz-=E*q),d.vx+=M*(q=1-q),l>1&&(d.vy+=D*q),l>2&&(d.vz+=E*q)}function _(){if(h){var o,p=h.length,w=t.length,N=new Map(h.map((d,A)=>[n(d,A,h),d])),g;for(o=0,u=new Array(p);otypeof w=="function")||Math.random,l=p.find(w=>[1,2,3].includes(w))||2,_()},x.links=function(o){return arguments.length?(t=o,_(),x):t},x.id=function(o){return arguments.length?(n=o,x):n},x.iterations=function(o){return arguments.length?(a=+o,x):a},x.strength=function(o){return arguments.length?(i=typeof o=="function"?o:F(+o),z(),x):i},x.distance=function(o){return arguments.length?(r=typeof o=="function"?o:F(+o),y(),x):r},x}const $n=1664525,qn=1013904223,ht=4294967296;function mn(){let t=1;return()=>(t=($n*t+qn)%ht)/ht}var at=3;function W(t){return t.x}function ft(t){return t.y}function In(t){return t.z}var bn=10,kn=Math.PI*(3-Math.sqrt(5)),jn=Math.PI*20/(9+Math.sqrt(221));function Tn(t,n){n=n||2;var i=Math.min(at,Math.max(1,Math.round(n))),e,r=1,s=.001,h=1-Math.pow(s,1/300),l=0,u=.6,f=new Map,c=_t(x),a=ot("tick","end"),v=mn();t==null&&(t=[]);function x(){_(),a.call("tick",e),r1&&(N.fy==null?N.y+=N.vy*=u:(N.y=N.fy,N.vy=0)),i>2&&(N.fz==null?N.z+=N.vz*=u:(N.z=N.fz,N.vz=0));return e}function z(){for(var o=0,p=t.length,w;o1&&isNaN(w.y)||i>2&&isNaN(w.z)){var N=bn*(i>2?Math.cbrt(.5+o):i>1?Math.sqrt(.5+o):o),g=o*kn,d=o*jn;i===1?w.x=N:i===2?(w.x=N*Math.cos(g),w.y=N*Math.sin(g)):(w.x=N*Math.sin(g)*Math.cos(d),w.y=N*Math.cos(g),w.z=N*Math.sin(g)*Math.sin(d))}(isNaN(w.vx)||i>1&&isNaN(w.vy)||i>2&&isNaN(w.vz))&&(w.vx=0,i>1&&(w.vy=0),i>2&&(w.vz=0))}}function y(o){return o.initialize&&o.initialize(t,v,i),o}return z(),e={tick:_,restart:function(){return c.restart(x),e},stop:function(){return c.stop(),e},numDimensions:function(o){return arguments.length?(i=Math.min(at,Math.max(1,Math.round(o))),f.forEach(y),e):i},nodes:function(o){return arguments.length?(t=o,z(),f.forEach(y),e):t},alpha:function(o){return arguments.length?(r=+o,e):r},alphaMin:function(o){return arguments.length?(s=+o,e):s},alphaDecay:function(o){return arguments.length?(h=+o,e):+h},alphaTarget:function(o){return arguments.length?(l=+o,e):l},velocityDecay:function(o){return arguments.length?(u=1-o,e):1-u},randomSource:function(o){return arguments.length?(v=o,f.forEach(y),e):v},force:function(o,p){return arguments.length>1?(p==null?f.delete(o):f.set(o,y(p)),e):f.get(o)},find:function(){var o=Array.prototype.slice.call(arguments),p=o.shift()||0,w=(i>1?o.shift():null)||0,N=(i>2?o.shift():null)||0,g=o.shift()||1/0,d=0,A=t.length,M,D,E,k,q,V;for(g*=g,d=0;d1?(a.on(o,p),e):a.on(o)}}}function Fn(){var t,n,i,e,r,s=F(-30),h,l=1,u=1/0,f=.81;function c(_){var z,y=t.length,o=(n===1?xt(t,W):n===2?yt(t,W,ft):n===3?pt(t,W,ft,In):null).visitAfter(v);for(r=_,z=0;z1&&(_.y=N/p),n>2&&(_.z=g/p)}else{y=_,y.x=y.data.x,n>1&&(y.y=y.data.y),n>2&&(y.z=y.data.z);do z+=h[y.data.index];while(y=y.next)}_.value=z}function x(_,z,y,o,p){if(!_.value)return!0;var w=[y,o,p][n-1],N=_.x-i.x,g=n>1?_.y-i.y:0,d=n>2?_.z-i.z:0,A=w-z,M=N*N+g*g+d*d;if(A*A/f1&&g===0&&(g=T(e),M+=g*g),n>2&&d===0&&(d=T(e),M+=d*d),M1&&(i.vy+=g*_.value*r/M),n>2&&(i.vz+=d*_.value*r/M)),!0;if(_.length||M>=u)return;(_.data!==i||_.next)&&(N===0&&(N=T(e),M+=N*N),n>1&&g===0&&(g=T(e),M+=g*g),n>2&&d===0&&(d=T(e),M+=d*d),M1&&(i.vy+=g*A),n>2&&(i.vz+=d*A));while(_=_.next)}return c.initialize=function(_,...z){t=_,e=z.find(y=>typeof y=="function")||Math.random,n=z.find(y=>[1,2,3].includes(y))||2,a()},c.strength=function(_){return arguments.length?(s=typeof _=="function"?_:F(+_),a(),c):s},c.distanceMin=function(_){return arguments.length?(l=_*_,c):Math.sqrt(l)},c.distanceMax=function(_){return arguments.length?(u=_*_,c):Math.sqrt(u)},c.theta=function(_){return arguments.length?(f=_*_,c):Math.sqrt(f)},c}function Pn(t,n,i,e){var r,s,h=F(.1),l,u;typeof t!="function"&&(t=F(+t)),n==null&&(n=0),i==null&&(i=0),e==null&&(e=0);function f(a){for(var v=0,x=r.length;v1&&(_.vy+=y*w),s>2&&(_.vz+=o*w)}}function c(){if(r){var a,v=r.length;for(l=new Array(v),u=new Array(v),a=0;a[1,2,3].includes(x))||2,c()},f.strength=function(a){return arguments.length?(h=typeof a=="function"?a:F(+a),c(),f):h},f.radius=function(a){return arguments.length?(t=typeof a=="function"?a:F(+a),c(),f):t},f.x=function(a){return arguments.length?(n=+a,f):n},f.y=function(a){return arguments.length?(i=+a,f):i},f.z=function(a){return arguments.length?(e=+a,f):e},f}export{Z as T,Tn as a,En as b,Fn as c,ot as d,Dn as e,Pn as f,F as g,xt as h,T as j,ct as n,pt as o,yt as q,_t as t}; diff --git a/internal/ui/assets/assets/three.module-D-PgY1-x.js b/internal/ui/assets/assets/three.module-D-PgY1-x.js new file mode 100644 index 0000000..d203f97 --- /dev/null +++ b/internal/ui/assets/assets/three.module-D-PgY1-x.js @@ -0,0 +1,4116 @@ +/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const qM="185",jf={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ep={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ju=0,Zl=1,$u=2,tp=3,np=0,Zs=1,Ku=2,ms=3,Xn=0,Xt=1,Cn=2,Pn=0,Ni=1,Jl=2,$l=3,Kl=4,Qu=5,ip=6,ri=100,ju=101,ed=102,td=103,nd=104,id=200,sd=201,rd=202,ad=203,wa=204,Ca=205,od=206,ld=207,cd=208,hd=209,ud=210,dd=211,fd=212,pd=213,md=214,Ra=0,Ia=1,Pa=2,Oi=3,La=4,Da=5,Ua=6,Na=7,Sr=0,gd=1,_d=2,vn=0,fc=1,pc=2,mc=3,gc=4,_c=5,xc=6,vc=7,Ql="attached",xd="detached",xo=300,Ln=301,hi=302,Js=303,$s=304,Es=306,rr=1e3,jt=1001,ar=1002,Et=1003,yc=1004,sp=1004,gs=1005,rp=1005,_t=1006,Ks=1007,ap=1007,Rn=1008,op=1008,Kt=1009,Mc=1010,Sc=1011,ys=1012,vo=1013,un=1014,Ht=1015,Dn=1016,yo=1017,Mo=1018,Ms=1020,bc=35902,Tc=35899,Ac=1021,Ec=1022,Wt=1023,Un=1026,ai=1027,So=1028,br=1029,ui=1030,bo=1031,lp=1032,To=1033,Qs=33776,js=33777,er=33778,tr=33779,Fa=35840,Oa=35841,Ba=35842,za=35843,Va=36196,ka=37492,Ga=37496,Ha=37488,Wa=37489,or=37490,Xa=37491,qa=37808,Ya=37809,Za=37810,Ja=37811,$a=37812,Ka=37813,Qa=37814,ja=37815,eo=37816,to=37817,no=37818,io=37819,so=37820,ro=37821,ao=36492,oo=36494,lo=36495,co=36283,ho=36284,lr=36285,uo=36286,vd=2200,yd=2201,Md=2202,cr=2300,fo=2301,Ta=2302,jl=2303,Li=2400,Di=2401,hr=2402,Ao=2500,wc=2501,cp=0,hp=1,up=2,Sd=3200,dp=3201,fp=3202,pp=3203,qn=0,bd=1,Gn="",$t="srgb",ur="srgb-linear",dr="linear",ot="srgb",mp="",gp="rg",_p="ga",xp=0,Ii=7680,vp=7681,yp=7682,Mp=7683,Sp=34055,bp=34056,Tp=5386,Ap=512,Ep=513,wp=514,Cp=515,Rp=516,Ip=517,Pp=518,ec=519,Td=512,Ad=513,Ed=514,Eo=515,wd=516,Cd=517,wo=518,Rd=519,fr=35044,Lp=35048,Dp=35040,Up=35045,Np=35049,Fp=35041,Op=35046,Bp=35050,zp=35042,Vp="100",tc="300 es",rn=2e3,Bi=2001,kp={COMPUTE:"compute",RENDER:"render"},Gp={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Hp={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},Wp={TEXTURE_COMPARE:"depthTextureCompare"};function Xp(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const qp={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function _s(s,e){return new qp[s](e)}function Id(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function pr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Pd(){const s=pr("canvas");return s.style.display="block",s}const _h={};let di=null;function Yp(s){di=s}function Zp(){return di}function mr(...s){const e="THREE."+s.shift();di?di("log",e,...s):console.log(e,...s)}function Ld(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function oe(...s){s=Ld(s);const e="THREE."+s.shift();if(di)di("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function Re(...s){s=Ld(s);const e="THREE."+s.shift();if(di)di("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function ci(...s){const e=s.join(" ");e in _h||(_h[e]=!0,oe(...s))}function YM(){return typeof self<"u"&&typeof self.scheduler<"u"&&typeof self.scheduler.yield<"u"?self.scheduler.yield():new Promise(s=>{requestAnimationFrame(s)})}function Jp(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const $p={[Ra]:Ia,[Pa]:Ua,[La]:Na,[Oi]:Da,[Ia]:Ra,[Ua]:Pa,[Na]:La,[Da]:Oi};class Mn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r>8&255]+Ft[s>>16&255]+Ft[s>>24&255]+"-"+Ft[e&255]+Ft[e>>8&255]+"-"+Ft[e>>16&15|64]+Ft[e>>24&255]+"-"+Ft[t&63|128]+Ft[t>>8&255]+"-"+Ft[t>>16&255]+Ft[t>>24&255]+Ft[n&255]+Ft[n>>8&255]+Ft[n>>16&255]+Ft[n>>24&255]).toLowerCase()}function Ve(s,e,t){return Math.max(e,Math.min(t,s))}function Cc(s,e){return(s%e+e)%e}function Kp(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function Qp(s,e,t){return s!==e?(t-s)/(e-s):0}function nr(s,e,t){return(1-t)*s+t*e}function jp(s,e,t,n){return nr(s,e,1-Math.exp(-t*n))}function em(s,e=1){return e-Math.abs(Cc(s,e*2)-e)}function tm(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function nm(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function im(s,e){return s+Math.floor(Math.random()*(e-s+1))}function sm(s,e){return s+Math.random()*(e-s)}function rm(s){return s*(.5-Math.random())}function am(s){s!==void 0&&(xh=s);let e=xh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function om(s){return s*Fi}function lm(s){return s*Ss}function cm(s){return(s&s-1)===0&&s!==0}function hm(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function um(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function dm(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),h=a((e+n)/2),d=r((e-n)/2),u=a((e-n)/2),f=r((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":s.set(o*h,l*d,l*u,o*c);break;case"YZY":s.set(l*u,o*h,l*d,o*c);break;case"ZXZ":s.set(l*d,l*u,o*h,o*c);break;case"XZX":s.set(o*h,l*p,l*f,o*c);break;case"YXY":s.set(l*f,o*h,l*p,o*c);break;case"ZYZ":s.set(l*p,l*f,o*h,o*c);break;default:oe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Gt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function $e(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const fm={DEG2RAD:Fi,RAD2DEG:Ss,generateUUID:an,clamp:Ve,euclideanModulo:Cc,mapLinear:Kp,inverseLerp:Qp,lerp:nr,damp:jp,pingpong:em,smoothstep:tm,smootherstep:nm,randInt:im,randFloat:sm,randFloatSpread:rm,seededRandom:am,degToRad:om,radToDeg:lm,isPowerOfTwo:cm,ceilPowerOfTwo:hm,floorPowerOfTwo:um,setQuaternionFromProperEuler:dm,normalize:$e,denormalize:Gt},ih=class ih{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ve(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ih.prototype.isVector2=!0;let Q=ih;class qt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],d=n[i+3],u=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==u||c!==f||h!==p){let g=l*u+c*f+h*p+d*_;g<0&&(u=-u,f=-f,p=-p,_=-_,g=-g);let m=1-o;if(g<.9995){const M=Math.acos(g),S=Math.sin(M);m=Math.sin(m*M)/S,o=Math.sin(o*M)/S,l=l*m+u*o,c=c*m+f*o,h=h*m+p*o,d=d*m+_*o}else{l=l*m+u*o,c=c*m+f*o,h=h*m+p*o,d=d*m+_*o;const M=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=M,c*=M,h*=M,d*=M}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],d=r[a],u=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+h*d+l*f-c*u,e[t+1]=l*p+h*u+c*d-o*f,e[t+2]=c*p+h*f+o*u-l*d,e[t+3]=h*p-o*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),d=o(r/2),u=l(n/2),f=l(i/2),p=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"YXZ":this._x=u*h*d+c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"ZXY":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d-u*f*p;break;case"ZYX":this._x=u*h*d-c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d+u*f*p;break;case"YZX":this._x=u*h*d+c*f*p,this._y=c*f*d+u*h*p,this._z=c*h*p-u*f*d,this._w=c*h*d-u*f*p;break;case"XZY":this._x=u*h*d-c*f*p,this._y=c*f*d-u*h*p,this._z=c*h*p+u*f*d,this._w=c*h*d+u*f*p;break;default:oe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(a-i)*f}else if(n>o&&n>d){const f=2*Math.sqrt(1+n-o-d);this._w=(h-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-n-d);this._w=(r-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+d-n-o);this._w=(a-i)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ve(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+i*c-r*l,this._y=i*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const sh=class sh{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(vh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(vh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),h=2*(o*t-r*i),d=2*(r*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-r*d,this.z=i+l*d+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sl.copy(this).projectOnVector(e),this.sub(sl)}reflect(e){return this.sub(sl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ve(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};sh.prototype.isVector3=!0;let C=sh;const sl=new C,vh=new qt,rh=class rh{constructor(e,t,n,i,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],p=n[8],_=i[0],g=i[3],m=i[6],M=i[1],S=i[4],v=i[7],E=i[2],T=i[5],R=i[8];return r[0]=a*_+o*M+l*E,r[3]=a*g+o*S+l*T,r[6]=a*m+o*v+l*R,r[1]=c*_+h*M+d*E,r[4]=c*g+h*S+d*T,r[7]=c*m+h*v+d*R,r[2]=u*_+f*M+p*E,r[5]=u*g+f*S+p*T,r[8]=u*m+f*v+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*r,f=c*r-a*l,p=t*d+n*u+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(i*c-h*n)*_,e[2]=(o*n-i*a)*_,e[3]=u*_,e[4]=(h*t-i*l)*_,e[5]=(i*r-o*t)*_,e[6]=f*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ci("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(rl.makeScale(e,t)),this}rotate(e){return ci("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(rl.makeRotation(-e)),this}translate(e,t){return ci("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(rl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};rh.prototype.isMatrix3=!0;let Xe=rh;const rl=new Xe,yh=new Xe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Mh=new Xe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pm(){const s={enabled:!0,workingColorSpace:ur,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ot&&(i.r=Wn(i.r),i.g=Wn(i.g),i.b=Wn(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ot&&(i.r=vs(i.r),i.g=vs(i.g),i.b=vs(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Gn?dr:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return ci("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return ci("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ur]:{primaries:e,whitePoint:n,transfer:dr,toXYZ:yh,fromXYZ:Mh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:$t},outputColorSpaceConfig:{drawingBufferColorSpace:$t}},[$t]:{primaries:e,whitePoint:n,transfer:ot,toXYZ:yh,fromXYZ:Mh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:$t}}}),s}const tt=pm();function Wn(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function vs(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Zi;class Dd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Zi===void 0&&(Zi=pr("canvas")),Zi.width=e.width,Zi.height=e.height;const i=Zi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Zi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=pr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ol).x}get height(){return this.source.getSize(ol).y}get depth(){return this.source.getSize(ol).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){oe(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rr:e.x=e.x-Math.floor(e.x);break;case jt:e.x=e.x<0?0:1;break;case ar:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case rr:e.y=e.y-Math.floor(e.y);break;case jt:e.y=e.y<0?0:1;break;case ar:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}vt.DEFAULT_IMAGE=null;vt.DEFAULT_MAPPING=xo;vt.DEFAULT_ANISOTROPY=1;const ah=class ah{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],p=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-_)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+_)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const S=(c+1)/2,v=(f+1)/2,E=(m+1)/2,T=(h+u)/4,R=(d+_)/4,x=(p+g)/4;return S>v&&S>E?S<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(S),i=T/n,r=R/n):v>E?v<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(v),n=T/i,r=x/i):E<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(E),n=R/r,i=x/r),this.set(n,i,r,t),this}let M=Math.sqrt((g-p)*(g-p)+(d-_)*(d-_)+(u-h)*(u-h));return Math.abs(M)<.001&&(M=1),this.x=(g-p)/M,this.y=(d-_)/M,this.z=(u-h)/M,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this.w=Ve(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this.w=Ve(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};ah.prototype.isVector4=!0;let lt=ah;class Rc extends Mn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:_t,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new lt(0,0,e,t),this.scissorTest=!1,this.viewport=new lt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new vt(i),a=n.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nf+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Am)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new xs;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Ud={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Qn={h:0,s:0,l:0},Nr={h:0,s:0,l:0};function cl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Se{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=$t){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=tt.workingColorSpace){return this.r=e,this.g=t,this.b=n,tt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=tt.workingColorSpace){if(e=Cc(e,1),t=Ve(t,0,1),n=Ve(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=cl(a,r,e+1/3),this.g=cl(a,r,e),this.b=cl(a,r,e-1/3)}return tt.colorSpaceToWorking(this,i),this}setStyle(e,t=$t){function n(r){r!==void 0&&parseFloat(r)<1&&oe("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:oe("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=$t){const n=Ud[e.toLowerCase()];return n!==void 0?this.setHex(n,t):oe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Wn(e.r),this.g=Wn(e.g),this.b=Wn(e.b),this}copyLinearToSRGB(e){return this.r=vs(e.r),this.g=vs(e.g),this.b=vs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$t){return tt.workingToColorSpace(Ot.copy(this),e),Math.round(Ve(Ot.r*255,0,255))*65536+Math.round(Ve(Ot.g*255,0,255))*256+Math.round(Ve(Ot.b*255,0,255))}getHexString(e=$t){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tt.workingColorSpace){tt.workingToColorSpace(Ot.copy(this),t);const n=Ot.r,i=Ot.g,r=Ot.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(i-r)/d+(i0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const mn=new C,On=new C,hl=new C,Bn=new C,Qi=new C,ji=new C,Rh=new C,ul=new C,dl=new C,fl=new C,pl=new lt,ml=new lt,gl=new lt;class Qt{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),mn.subVectors(e,t),i.cross(mn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){mn.subVectors(i,t),On.subVectors(n,t),hl.subVectors(e,t);const a=mn.dot(mn),o=mn.dot(On),l=mn.dot(hl),c=On.dot(On),h=On.dot(hl),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,f=(c*l-o*h)*u,p=(a*h-o*l)*u;return r.set(1-f-p,p,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Bn)===null?!1:Bn.x>=0&&Bn.y>=0&&Bn.x+Bn.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,Bn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Bn.x),l.addScaledVector(a,Bn.y),l.addScaledVector(o,Bn.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return pl.setScalar(0),ml.setScalar(0),gl.setScalar(0),pl.fromBufferAttribute(e,t),ml.fromBufferAttribute(e,n),gl.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(pl,r.x),a.addScaledVector(ml,r.y),a.addScaledVector(gl,r.z),a}static isFrontFacing(e,t,n,i){return mn.subVectors(n,t),On.subVectors(e,t),mn.cross(On).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return mn.subVectors(this.c,this.b),On.subVectors(this.a,this.b),mn.cross(On).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Qt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Qt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Qt.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Qt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Qt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;Qi.subVectors(i,n),ji.subVectors(r,n),ul.subVectors(e,n);const l=Qi.dot(ul),c=ji.dot(ul);if(l<=0&&c<=0)return t.copy(n);dl.subVectors(e,i);const h=Qi.dot(dl),d=ji.dot(dl);if(h>=0&&d<=h)return t.copy(i);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Qi,a);fl.subVectors(e,r);const f=Qi.dot(fl),p=ji.dot(fl);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(ji,o);const g=h*p-f*d;if(g<=0&&d-h>=0&&f-p>=0)return Rh.subVectors(r,i),o=(d-h)/(d-h+(f-p)),t.copy(i).addScaledVector(Rh,o);const m=1/(g+_+u);return a=_*m,o=u*m,t.copy(n).addScaledVector(Qi,a).addScaledVector(ji,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class zt{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,gn),gn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ls),Or.subVectors(this.max,Ls),es.subVectors(e.a,Ls),ts.subVectors(e.b,Ls),ns.subVectors(e.c,Ls),jn.subVectors(ts,es),ei.subVectors(ns,ts),xi.subVectors(es,ns);let t=[0,-jn.z,jn.y,0,-ei.z,ei.y,0,-xi.z,xi.y,jn.z,0,-jn.x,ei.z,0,-ei.x,xi.z,0,-xi.x,-jn.y,jn.x,0,-ei.y,ei.x,0,-xi.y,xi.x,0];return!_l(t,es,ts,ns,Or)||(t=[1,0,0,0,1,0,0,0,1],!_l(t,es,ts,ns,Or))?!1:(Br.crossVectors(jn,ei),t=[Br.x,Br.y,Br.z],_l(t,es,ts,ns,Or))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,gn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(gn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const zn=[new C,new C,new C,new C,new C,new C,new C,new C],gn=new C,Fr=new zt,es=new C,ts=new C,ns=new C,jn=new C,ei=new C,xi=new C,Ls=new C,Or=new C,Br=new C,vi=new C;function _l(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){vi.fromArray(s,r);const o=i.x*Math.abs(vi.x)+i.y*Math.abs(vi.y)+i.z*Math.abs(vi.z),l=e.dot(vi),c=t.dot(vi),h=n.dot(vi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Hn=Em();function Em(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,r[l]=c|h}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Jt(s){Math.abs(s)>65504&&oe("DataUtils.toHalfFloat(): Value out of range."),s=Ve(s,-65504,65504),Hn.floatView[0]=s;const e=Hn.uint32View[0],t=e>>23&511;return Hn.baseTable[t]+((e&8388607)>>Hn.shiftTable[t])}function Xs(s){const e=s>>10;return Hn.uint32View[0]=Hn.mantissaTable[Hn.offsetTable[e]+(s&1023)]+Hn.exponentTable[e],Hn.floatView[0]}class wm{static toHalfFloat(e){return Jt(e)}static fromHalfFloat(e){return Xs(e)}}const wt=new C,zr=new Q;let Cm=0;class ut extends Mn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Cm++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=fr,this.updateRanges=[],this.gpuType=Ht,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;ithis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ds.subVectors(e,this.center);const t=Ds.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ds,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(xl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(xl)),this.expandByPoint(Ds.copy(e.center).sub(xl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Fm=0;const cn=new He,vl=new rt,is=new C,sn=new zt,Us=new zt,Pt=new C;class Ye extends Mn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Fm++}),this.uuid=an(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Xp(e)?Pc:Ic)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Xe().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return cn.makeRotationFromQuaternion(e),this.applyMatrix4(cn),this}rotateX(e){return cn.makeRotationX(e),this.applyMatrix4(cn),this}rotateY(e){return cn.makeRotationY(e),this.applyMatrix4(cn),this}rotateZ(e){return cn.makeRotationZ(e),this.applyMatrix4(cn),this}translate(e,t,n){return cn.makeTranslation(e,t,n),this.applyMatrix4(cn),this}scale(e,t,n){return cn.makeScale(e,t,n),this.applyMatrix4(cn),this}lookAt(e){return vl.lookAt(e),vl.updateMatrix(),this.applyMatrix4(vl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(is).negate(),this.translate(is.x,is.y,is.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;it.count&&oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Re("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(i[l]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,f=d.length;u0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){oe(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ni&&(n.blending=this.blending),this.side!==Xn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==wa&&(n.blendSrc=this.blendSrc),this.blendDst!==Ca&&(n.blendDst=this.blendDst),this.blendEquation!==ri&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Oi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ec&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ii&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ii&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ii&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Se().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Q().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Lc extends Ut{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ss;const Ns=new C,rs=new C,as=new C,os=new Q,Fs=new Q,Fd=new He,Vr=new C,Os=new C,kr=new C,Ih=new Q,yl=new Q,Ph=new Q;class Od extends rt{constructor(e=new Lc){if(super(),this.isSprite=!0,this.type="Sprite",ss===void 0){ss=new Ye;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Do(t,5);ss.setIndex([0,1,2,0,2,3]),ss.setAttribute("position",new zi(n,3,0,!1)),ss.setAttribute("uv",new zi(n,2,3,!1))}this.geometry=ss,this.material=e,this.center=new Q(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Re('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),rs.setFromMatrixScale(this.matrixWorld),Fd.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),as.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&rs.multiplyScalar(-as.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Gr(Vr.set(-.5,-.5,0),as,a,rs,i,r),Gr(Os.set(.5,-.5,0),as,a,rs,i,r),Gr(kr.set(.5,.5,0),as,a,rs,i,r),Ih.set(0,0),yl.set(1,0),Ph.set(1,1);let o=e.ray.intersectTriangle(Vr,Os,kr,!1,Ns);if(o===null&&(Gr(Os.set(-.5,.5,0),as,a,rs,i,r),yl.set(0,1),o=e.ray.intersectTriangle(Vr,kr,Os,!1,Ns),o===null))return;const l=e.ray.origin.distanceTo(Ns);le.far||t.push({distance:l,point:Ns.clone(),uv:Qt.getInterpolation(Ns,Vr,Os,kr,Ih,yl,Ph,new Q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Gr(s,e,t,n,i,r){os.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Fs.x=r*os.x-i*os.y,Fs.y=i*os.x+r*os.y):Fs.copy(os),s.copy(e),s.x+=Fs.x,s.y+=Fs.y,s.applyMatrix4(Fd)}const Hr=new C,Lh=new C;class Bd extends rt{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Hr.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Hr);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Hr.setFromMatrixPosition(e.matrixWorld),Lh.setFromMatrixPosition(this.matrixWorld);const n=Hr.distanceTo(Lh)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i=a)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i0)if(d=a*l-o,u=a*o-l,p=r*h,d>=0)if(u>=-p)if(u<=p){const _=1/h;d*=_,u*=_,f=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;else u<=-p?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=p?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(Ml).addScaledVector(Wr,u),f}intersectSphere(e,t){Vn.subVectors(e.center,this.origin);const n=Vn.dot(this.direction),i=Vn.dot(Vn)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(o=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||o>i)||((o>n||n!==n)&&(n=o),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Vn)!==null}intersectTriangle(e,t,n,i,r){Sl.subVectors(t,e),Xr.subVectors(n,e),bl.crossVectors(Sl,Xr);let a=this.direction.dot(bl),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ti.subVectors(this.origin,e);const l=o*this.direction.dot(Xr.crossVectors(ti,Xr));if(l<0)return null;const c=o*this.direction.dot(Sl.cross(ti));if(c<0||l+c>a)return null;const h=-o*ti.dot(bl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class pi extends Ut{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yn,this.combine=Sr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Dh=new He,yi=new ws,qr=new Dt,Uh=new C,Yr=new C,Zr=new C,Jr=new C,Tl=new C,$r=new C,Nh=new C,Kr=new C;class Ct extends rt{constructor(e=new Ye,t=new pi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r(e.far-e.near)**2))&&(Dh.copy(r).invert(),yi.copy(e.ray).applyMatrix4(Dh),!(n.boundingBox!==null&&yi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,yi)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=u.length;p<_;p++){const g=u[p],m=a[g.materialIndex],M=Math.max(g.start,f.start),S=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let v=M,E=S;vt.far?null:{distance:c,point:Kr.clone(),object:s}}function Qr(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,Yr),s.getVertexPosition(l,Zr),s.getVertexPosition(c,Jr);const h=Bm(s,e,t,n,Yr,Zr,Jr,Nh);if(h){const d=new C;Qt.getBarycoord(Nh,Yr,Zr,Jr,d),i&&(h.uv=Qt.getInterpolatedAttribute(i,o,l,c,d,new Q)),r&&(h.uv1=Qt.getInterpolatedAttribute(r,o,l,c,d,new Q)),a&&(h.normal=Qt.getInterpolatedAttribute(a,o,l,c,d,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new C,materialIndex:0};Qt.getNormal(Yr,Zr,Jr,u.normal),h.face=u,h.barycoord=d}return h}const Bs=new lt,Fh=new lt,Oh=new lt,zm=new lt,Bh=new He,jr=new C,Al=new Dt,zh=new He,El=new ws;class zd extends Ct{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ql,this.bindMatrix=new He,this.bindMatrixInverse=new He,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Hm.getNormalMatrix(e),i=this.coplanarPoint(wl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Mi=new Dt,Wm=new Q(.5,.5),ta=new C;class Vi{constructor(e=new si,t=new si,n=new si,i=new si,r=new si,a=new si){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=rn,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],f=r[7],p=r[8],_=r[9],g=r[10],m=r[11],M=r[12],S=r[13],v=r[14],E=r[15];if(i[0].setComponents(c-a,f-h,m-p,E-M).normalize(),i[1].setComponents(c+a,f+h,m+p,E+M).normalize(),i[2].setComponents(c+o,f+d,m+_,E+S).normalize(),i[3].setComponents(c-o,f-d,m-_,E-S).normalize(),n)i[4].setComponents(l,u,g,v).normalize(),i[5].setComponents(c-l,f-u,m-g,E-v).normalize();else if(i[4].setComponents(c-l,f-u,m-g,E-v).normalize(),t===rn)i[5].setComponents(c+l,f+u,m+g,E+v).normalize();else if(t===Bi)i[5].setComponents(l,u,g,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mi)}intersectsSprite(e){Mi.center.set(0,0,0);const t=Wm.distanceTo(e.center);return Mi.radius=.7071067811865476+t,Mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,ta.y=i.normal.y>0?e.max.y:e.min.y,ta.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ta)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Hh=new He;class No{constructor(){this.coordinateSystem=rn,this._frustums=[],this._count=0}setFromArrayCamera(e){const t=e.cameras,n=this._frustums;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=i}reset(){this.list.length=0,this.index=0}}const Zt=new He,Zm=new Se(1,1,1),Jm=new Vi,$m=new No,na=new zt,Si=new Dt,ks=new C,Wh=new C,Km=new C,Rl=new Ym,Bt=new Ct,ia=[];function Qm(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new ut(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Cl),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const r=this._matricesTexture;Zt.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(Zm.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?a.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Cl),l=this._availableGeometryIds.shift(),r[l]=i):(l=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(l,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(i&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const h in n.attributes){const d=t.getAttribute(h),u=n.getAttribute(h);Qm(d,u,l);const f=d.itemSize;for(let p=d.count,_=c;p<_;p++){const g=l+p;for(let m=0;m=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,r=n.length;io).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),r=this.geometry;for(let a=0,o=n.length;a=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const r=new zt,a=n.index,o=n.attributes.position;for(let l=i.start,c=i.start+i.count;l=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const r=new Dt;this.getBoundingBoxAt(e,na),na.getCenter(r.center);const a=n.index,o=n.attributes.position;let l=0;for(let c=i.start,h=i.start+i.count;co.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ye,this._initializeGeometry(r));const a=this.geometry;r.index&&bi(r.index.array,a.index.array);for(const o in r.attributes)bi(r.attributes[o].array,a.attributes[o].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;Bt.material=this.material,Bt.geometry.index=a.index,Bt.geometry.attributes=a.attributes,Bt.geometry.boundingBox===null&&(Bt.geometry.boundingBox=new zt),Bt.geometry.boundingSphere===null&&(Bt.geometry.boundingSphere=new Dt);for(let o=0,l=n.length;o({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;r.wireframe&&(l=2,o=i.attributes.position.count>65535?4:2);const c=this._instanceInfo,h=this._multiDrawStarts,d=this._multiDrawCounts,u=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,_=p.image.data,g=n.isArrayCamera?$m:Jm;f&&(n.isArrayCamera?g.setFromArrayCamera(n):(Zt.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),g.setFromProjectionMatrix(Zt,n.coordinateSystem,n.reversedDepth)));let m=0;if(this.sortObjects){Zt.copy(this.matrixWorld).invert(),ks.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Zt),Wh.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Zt);for(let v=0,E=c.length;v0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;rn)return;Il.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(Il);if(!(ce.far))return{distance:c,point:qh.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Yh=new C,Zh=new C;class Nn extends fi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;ri.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Wd extends vt{constructor(e,t,n,i,r=_t,a=_t,o,l,c){super(e,t,n,i,r,a,o,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const h=this;function d(){h.needsUpdate=!0,h._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class jm extends Wd{constructor(e,t,n,i,r,a,o,l){super({},e,t,n,i,r,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class eg extends vt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Et,this.minFilter=Et,this.generateMipmaps=!1,this.needsUpdate=!0}}class Fo extends vt{constructor(e,t,n,i,r,a,o,l,c,h,d,u){super(null,a,o,l,c,h,i,r,d,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class tg extends Fo{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=jt,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ng extends Fo{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ln),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Tr extends vt{constructor(e=[],t=Ln,n,i,r,a,o,l,c,h){super(e,t,n,i,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ig extends vt{constructor(e,t,n,i,r,a,o,l,c){super(e,t,n,i,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class sg extends vt{constructor(e,t,n,i,r,a,o,l,c){super(e,t,n,i,r,a,o,l,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;const h=e?e.parentNode:null;h!==null&&"requestPaint"in h&&(h.onpaint=()=>{this.needsUpdate=!0},h.requestPaint())}dispose(){const e=this.image?this.image.parentNode:null;e!==null&&"onpaint"in e&&(e.onpaint=null),super.dispose()}}class ki extends vt{constructor(e,t,n=un,i,r,a,o=Et,l=Et,c,h=Un,d=1){if(h!==Un&&h!==ai)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,i,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new oi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Xd extends ki{constructor(e,t=un,n=Ln,i,r,a=Et,o=Et,l,c=Un){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,i,r,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Nc extends vt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Hi extends Ye{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,f=0;p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new Ee(c,3)),this.setAttribute("normal",new Ee(h,3)),this.setAttribute("uv",new Ee(d,2));function p(_,g,m,M,S,v,E,T,R,x,A){const I=v/R,P=E/x,U=v/2,H=E/2,X=T/2,O=R+1,W=x+1;let G=0,K=0;const ie=new C;for(let ue=0;ue0?1:-1,h.push(ie.x,ie.y,ie.z),d.push(be/R),d.push(1-ue/x),G+=1}}for(let ue=0;ue0){const A=(M-1)*_;for(let I=0;I0&&S(!0),t>0&&S(!1)),this.setIndex(h),this.setAttribute("position",new Ee(d,3)),this.setAttribute("normal",new Ee(u,3)),this.setAttribute("uv",new Ee(f,2));function M(){const v=new C,E=new C;let T=0;const R=(t-e)/n;for(let x=0;x<=r;x++){const A=[],I=x/r,P=I*(t-e)+e;for(let U=0;U<=i;U++){const H=U/i,X=H*l+o,O=Math.sin(X),W=Math.cos(X);E.x=P*O,E.y=-I*n+g,E.z=P*W,d.push(E.x,E.y,E.z),v.set(O,R,W).normalize(),u.push(v.x,v.y,v.z),f.push(H,1-I),A.push(p++)}_.push(A)}for(let x=0;x0||A!==0)&&(h.push(I,P,H),T+=3),(t>0||A!==r-1)&&(h.push(P,U,H),T+=3)}c.addGroup(m,T,0),m+=T}function S(v){const E=p,T=new Q,R=new C;let x=0;const A=v===!0?e:t,I=v===!0?1:-1;for(let U=1;U<=i;U++)d.push(0,g*I,0),u.push(0,I,0),f.push(.5,.5),p++;const P=p;for(let U=0;U<=i;U++){const X=U/i*l+o,O=Math.cos(X),W=Math.sin(X);R.x=A*W,R.y=g*I,R.z=A*O,d.push(R.x,R.y,R.z),u.push(0,I,0),T.x=O*.5+.5,T.y=W*.5*I+.5,f.push(T.x,T.y),p++}for(let U=0;U.9&&R<.1&&(S<.2&&(a[M+0]+=1),v<.2&&(a[M+2]+=1),E<.2&&(a[M+4]+=1))}}function u(M){r.push(M.x,M.y,M.z)}function f(M,S){const v=M*3;S.x=e[v+0],S.y=e[v+1],S.z=e[v+2]}function p(){const M=new C,S=new C,v=new C,E=new C,T=new Q,R=new Q,x=new Q;for(let A=0,I=0;A0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(r-1);const h=n[i],u=n[i+1]-h,f=(a-h)/u;return(i+f)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),o=this.getPoint(r),l=t||(a.isVector2?new Q:new C);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new C,i=[],r=[],a=[],o=new C,l=new He;for(let f=0;f<=e;f++){const p=f/e;i[f]=this.getTangentAt(p,new C)}r[0]=new C,a[0]=new C;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),d=Math.abs(i[0].y),u=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),u<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(Ve(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(i[f],r[f])}if(t===!0){let f=Math.acos(Ve(r[0].dot(r[e]),-1,1));f/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),a[p].crossVectors(i[p],r[p])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Vo extends Sn{constructor(e=0,t=0,n=1,i=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Q){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%r]:(Qh.subVectors(i[0],i[1]).add(i[0]),c=Qh);const d=i[o%r],u=i[(o+1)%r];if(this.closed||o+2i.length-2?i.length-1:a+1],d=i[a>i.length-3?i.length-1:a+2];return n.set(jh(o,l.x,c.x,h.x,d.x),jh(o,l.y,c.y,h.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=i[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class wr extends gr{constructor(e){super(e),this.uuid=an(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n80*t){o=s[0],l=s[1];let h=o,d=l;for(let u=t;uh&&(h=f),p>d&&(d=p)}c=Math.max(h-o,d-l),c=c!==0?32767/c:0}return _r(r,a,t,o,l,c,0),a}function Qd(s,e,t,n,i){let r;if(i===Cg(s,e,t,n)>0)for(let a=e;a=e;a-=n)r=eu(a/n|0,s[a],s[a+1],r);return r&&Ts(r,r.next)&&(vr(r),r=r.next),r}function Gi(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(Ts(t,t.next)||xt(t.prev,t,t.next)===0)){if(vr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function _r(s,e,t,n,i,r,a){if(!s)return;!a&&r&&Sg(s,n,i,r);let o=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?pg(s,n,i,r):fg(s)){e.push(l.i,s.i,c.i),vr(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=mg(Gi(s),e),_r(s,e,t,n,i,r,2)):a===2&&gg(s,e,t,n,i,r):_r(Gi(s),e,t,n,i,r,1);break}}}function fg(s){const e=s.prev,t=s,n=s.next;if(xt(e,t,n)>=0)return!1;const i=e.x,r=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=Math.min(i,r,a),d=Math.min(o,l,c),u=Math.max(i,r,a),f=Math.max(o,l,c);let p=n.next;for(;p!==e;){if(p.x>=h&&p.x<=u&&p.y>=d&&p.y<=f&&qs(i,o,r,l,a,c,p.x,p.y)&&xt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function pg(s,e,t,n){const i=s.prev,r=s,a=s.next;if(xt(i,r,a)>=0)return!1;const o=i.x,l=r.x,c=a.x,h=i.y,d=r.y,u=a.y,f=Math.min(o,l,c),p=Math.min(h,d,u),_=Math.max(o,l,c),g=Math.max(h,d,u),m=ic(f,p,e,t,n),M=ic(_,g,e,t,n);let S=s.prevZ,v=s.nextZ;for(;S&&S.z>=m&&v&&v.z<=M;){if(S.x>=f&&S.x<=_&&S.y>=p&&S.y<=g&&S!==i&&S!==a&&qs(o,h,l,d,c,u,S.x,S.y)&&xt(S.prev,S,S.next)>=0||(S=S.prevZ,v.x>=f&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&qs(o,h,l,d,c,u,v.x,v.y)&&xt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;S&&S.z>=m;){if(S.x>=f&&S.x<=_&&S.y>=p&&S.y<=g&&S!==i&&S!==a&&qs(o,h,l,d,c,u,S.x,S.y)&&xt(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;v&&v.z<=M;){if(v.x>=f&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&qs(o,h,l,d,c,u,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function mg(s,e){let t=s;do{const n=t.prev,i=t.next.next;!Ts(n,i)&&ef(n,t,t.next,i)&&xr(n,i)&&xr(i,n)&&(e.push(n.i,t.i,i.i),vr(t),vr(t.next),t=s=i),t=t.next}while(t!==s);return Gi(t)}function gg(s,e,t,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Ag(a,o)){let l=tf(a,o);a=Gi(a,a.next),l=Gi(l,l.next),_r(a,e,t,n,i,r,0),_r(l,e,t,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function _g(s,e,t,n){const i=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&n!==t.x&&jd(ia.x||t.x===a.x&&Mg(a,t)))&&(a=t,h=d)}t=t.next}while(t!==o);return a}function Mg(s,e){return xt(s.prev,s,e.prev)<0&&xt(e.next,s,s.next)<0}function Sg(s,e,t,n){let i=s;do i.z===0&&(i.z=ic(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,bg(i)}function bg(s){let e,t=1;do{let n=s,i;s=null;let r=null;for(e=0;n;){e++;let a=n,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||n.z<=a.z)?(i=n,n=n.nextZ,o--):(i=a,a=a.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=a}r.nextZ=null,t*=2}while(e>1);return s}function ic(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Tg(s){let e=s,t=s;do(e.x=(s-a)*(r-o)&&(s-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(i-a)*(n-o)}function qs(s,e,t,n,i,r,a,o){return!(s===a&&e===o)&&jd(s,e,t,n,i,r,a,o)}function Ag(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Eg(s,e)&&(xr(s,e)&&xr(e,s)&&wg(s,e)&&(xt(s.prev,s,e.prev)||xt(s,e.prev,e))||Ts(s,e)&&xt(s.prev,s,s.next)>0&&xt(e.prev,e,e.next)>0)}function xt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Ts(s,e){return s.x===e.x&&s.y===e.y}function ef(s,e,t,n){const i=da(xt(s,e,t)),r=da(xt(s,e,n)),a=da(xt(t,n,s)),o=da(xt(t,n,e));return!!(i!==r&&a!==o||i===0&&ua(s,t,e)||r===0&&ua(s,n,e)||a===0&&ua(t,s,n)||o===0&&ua(t,e,n))}function ua(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function da(s){return s>0?1:s<0?-1:0}function Eg(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ef(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function xr(s,e){return xt(s.prev,s,s.next)<0?xt(s,e,s.next)>=0&&xt(s,s.prev,e)>=0:xt(s,e,s.prev)<0||xt(s,s.next,e)<0}function wg(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function tf(s,e){const t=sc(s.i,s.x,s.y),n=sc(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function eu(s,e,t,n){const i=sc(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vr(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function sc(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Cg(s,e,t,n){let i=0;for(let r=e,a=t-n;r2&&s[e-1].equals(s[0])&&s.pop()}function nu(s,e){for(let t=0;tNumber.EPSILON){const w=Math.sqrt(ct),y=Math.sqrt(qe*qe+L*L),F=ne.x-Ge/w,V=ne.y+Pe/w,q=te.x-L/y,re=te.y+qe/y,ae=((q-F)*L-(re-V)*qe)/(Pe*L-Ge*qe);xe=F+Pe*ae-j.x,ge=V+Ge*ae-j.y;const Y=xe*xe+ge*ge;if(Y<=2)return new Q(xe,ge);Be=Math.sqrt(Y/2)}else{let w=!1;Pe>Number.EPSILON?qe>Number.EPSILON&&(w=!0):Pe<-Number.EPSILON?qe<-Number.EPSILON&&(w=!0):Math.sign(Ge)===Math.sign(L)&&(w=!0),w?(xe=-Ge,ge=Pe,Be=Math.sqrt(ct)):(xe=Pe,ge=Ge,Be=Math.sqrt(ct/2))}return new Q(xe/Be,ge/Be)}const ie=[];for(let j=0,ne=O.length,te=ne-1,xe=j+1;j=0;j--){const ne=j/g,te=f*Math.cos(ne*Math.PI/2),xe=p*Math.sin(ne*Math.PI/2)+_;for(let ge=0,Be=O.length;ge=0;){const xe=te;let ge=te-1;ge<0&&(ge=j.length-1);for(let Be=0,Pe=h+g*2;Be0)&&f.push(S,v,T),(m!==n-1||l0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Se().setHex(i.value);break;case"v2":this.uniforms[n].value=new Q().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new lt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Xe().fromArray(i.value);break;case"m4":this.uniforms[n].value=new He().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Gc extends dn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Hc extends Ut{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class of extends Hc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ve(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Se(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class lf extends Ut{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Se(16777215),this.specular=new Se(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yn,this.combine=Sr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class cf extends Ut{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Se(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class hf extends Ut{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class uf extends Ut{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Se(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yn,this.combine=Sr,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Wc extends Ut{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Sd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Xc extends Ut{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class df extends Ut{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Se(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qn,this.normalScale=new Q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ff extends Yt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Ui(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function pf(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function rc(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function mf(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}function Fg(s,e,t,n,i=30){const r=s.clone();r.name=e;const a=[];for(let l=0;l=n)){d.push(c.times[f]);for(let _=0;_r.tracks[l].times[0]&&(o=r.tracks[l].times[0]);for(let l=0;l=o.times[p]){const m=p*d+h,M=m+d-h;_=o.values.slice(m,M)}else{const m=o.createInterpolant(),M=h,S=d-h;m.evaluate(r),_=m.resultBuffer.slice(M,S)}l==="quaternion"&&new qt().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let m=0;m=r)){const o=t[1];e=r)break t}a=n,n=0;break n}break e}for(;n>>1;et;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Re("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(Re("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){Re("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Re("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Id(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){Re("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Ta,r=e.length-1;let a=1;for(let o=1;o0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}fn.prototype.ValueTypeName="";fn.prototype.TimeBufferType=Float32Array;fn.prototype.ValueBufferType=Float32Array;fn.prototype.DefaultInterpolation=fo;class Wi extends fn{constructor(e,t,n){super(e,t,n)}}Wi.prototype.ValueTypeName="bool";Wi.prototype.ValueBufferType=Array;Wi.prototype.DefaultInterpolation=cr;Wi.prototype.InterpolantFactoryMethodLinear=void 0;Wi.prototype.InterpolantFactoryMethodSmooth=void 0;class Yc extends fn{constructor(e,t,n,i){super(e,t,n,i)}}Yc.prototype.ValueTypeName="color";class $o extends fn{constructor(e,t,n,i){super(e,t,n,i)}}$o.prototype.ValueTypeName="number";class vf extends Rs{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)qt.slerpFlat(r,0,a,c-o,a,c,l);return r}}class Ko extends fn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new vf(this.times,this.values,this.getValueSize(),e)}}Ko.prototype.ValueTypeName="quaternion";Ko.prototype.InterpolantFactoryMethodSmooth=void 0;class Xi extends fn{constructor(e,t,n){super(e,t,n)}}Xi.prototype.ValueTypeName="string";Xi.prototype.ValueBufferType=Array;Xi.prototype.DefaultInterpolation=cr;Xi.prototype.InterpolantFactoryMethodLinear=void 0;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;class Zc extends fn{constructor(e,t,n,i){super(e,t,n,i)}}Zc.prototype.ValueTypeName="vector";class yr{constructor(e="",t=-1,n=[],i=Ao){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=an(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Vg(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(fn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o1){const d=h[1];let u=i[d];u||(i[d]=u=[]),u.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(r),this.manager.itemEnd(e)},0);return}if(kn[e]!==void 0){kn[e].push({onLoad:t,onProgress:n,onError:i});return}kn[e]=[],kn[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&oe("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=kn[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,p=f!==0;let _=0;const g=new ReadableStream({start(m){M();function M(){d.read().then(({done:S,value:v})=>{if(S)m.close();else{_+=v.byteLength;const E=new ProgressEvent("progress",{lengthComputable:p,loaded:_,total:f});for(let T=0,R=h.length;T{m.error(S)})}}});return new Response(g)}else throw new kg(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{In.add(`file:${e}`,c);const h=kn[e];delete kn[e];for(let d=0,u=h.length;d{const h=kn[e];if(h===void 0)throw this.manager.itemError(e),c;delete kn[e];for(let d=0,u=h.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class Gg extends en{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Yn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(l){i?i(l):Re(l),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0){const l=new Jc(t);r=new Mr(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c0){i=new Mr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a{let m=null,M=null;return g.boundingBox!==void 0&&(m=new zt().fromJSON(g.boundingBox)),g.boundingSphere!==void 0&&(M=new Dt().fromJSON(g.boundingSphere)),{...g,boundingBox:m,boundingSphere:M}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new Dt().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new zt().fromJSON(e.boundingBox));break;case"LOD":a=new Bd;break;case"Line":a=new fi(o(e.geometry),l(e.material));break;case"LineLoop":a=new Gd(o(e.geometry),l(e.material));break;case"LineSegments":a=new Nn(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new Hd(o(e.geometry),l(e.material));break;case"Sprite":a=new Od(l(e.material));break;case"Group":a=new xs;break;case"Bone":a=new Dc;break;default:a=new rt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new C().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const u=e.children;for(let f=0;f"u"&&oe("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&oe("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=In.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{Ol.has(a)===!0?(i&&i(Ol.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(c),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){In.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e)}).catch(function(c){i&&i(c),Ol.set(l,c),In.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});In.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let ma;class Qc{static getContext(){return ma===void 0&&(ma=new(window.AudioContext||window.webkitAudioContext)),ma}static setContext(e){ma=e}}class jg extends en{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Yn(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0),h=Qc.getContext(),d=e+"#decode";r.manager.itemStart(d),h.decodeAudioData(c,function(u){t(u),r.manager.itemEnd(d)}).catch(function(u){o(u),r.manager.itemEnd(d)})}catch(c){o(c)}},n,i);function o(l){i?i(l):Re(l),r.manager.itemError(e)}}}const pu=new He,mu=new He,Ti=new He;class e0{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Lt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Lt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Ti.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,a=t.near*Math.tan(Fi*t.fov*.5)/t.zoom;let o,l;mu.elements[12]=-i,pu.elements[12]=i,o=-a*t.aspect+r,l=a*t.aspect+r,Ti.elements[0]=2*t.near/(l-o),Ti.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Ti),o=-a*t.aspect-r,l=a*t.aspect-r,Ti.elements[0]=2*t.near/(l-o),Ti.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Ti)}this.cameraL.matrix.copy(e.matrixWorld).multiply(mu),this.cameraL.matrixWorldNeedsUpdate=!0,this.cameraR.matrix.copy(e.matrixWorld).multiply(pu),this.cameraR.matrixWorldNeedsUpdate=!0}}const hs=-90,us=1;class If extends rt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Lt(hs,us,e,t);i.layers=this.layers,this.add(i);const r=new Lt(hs,us,e,t);r.layers=this.layers,this.add(r);const a=new Lt(hs,us,e,t);a.layers=this.layers,this.add(a);const o=new Lt(hs,us,e,t);o.layers=this.layers,this.add(o);const l=new Lt(hs,us,e,t);l.layers=this.layers,this.add(l);const c=new Lt(hs,us,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===rn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Bi)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Pf extends Lt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Lf{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=t0.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function t0(){this._document.hidden===!1&&this.reset()}const Ai=new C,Bl=new qt,n0=new C,Ei=new C,wi=new C;class i0 extends rt{constructor(){super(),this.type="AudioListener",this.context=Qc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new Lf}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Ai,Bl,n0),Ei.set(0,0,-1).applyQuaternion(Bl),wi.set(0,1,0).applyQuaternion(Bl),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ai.x,n),t.positionY.linearRampToValueAtTime(Ai.y,n),t.positionZ.linearRampToValueAtTime(Ai.z,n),t.forwardX.linearRampToValueAtTime(Ei.x,n),t.forwardY.linearRampToValueAtTime(Ei.y,n),t.forwardZ.linearRampToValueAtTime(Ei.z,n),t.upX.linearRampToValueAtTime(wi.x,n),t.upY.linearRampToValueAtTime(wi.y,n),t.upZ.linearRampToValueAtTime(wi.z,n)}else t.setPosition(Ai.x,Ai.y,Ai.z),t.setOrientation(Ei.x,Ei.y,Ei.z,wi.x,wi.y,wi.z)}}class Df extends rt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){oe("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){oe("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){oe("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){oe("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){qt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const a=this._workIndex*r;qt.multiplyQuaternionsFlat(e,a,e,t,e,n),qt.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){const o=t+a;e[o]=e[o]+e[n+a]*i}}}const jc="\\[\\]\\.:\\/",o0=new RegExp("["+jc+"]","g"),eh="[^"+jc+"]",l0="[^"+jc.replace("\\.","")+"]",c0=/((?:WC+[\/:])*)/.source.replace("WC",eh),h0=/(WCOD+)?/.source.replace("WCOD",l0),u0=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eh),d0=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eh),f0=new RegExp("^"+c0+h0+u0+d0+"$"),p0=["material","materials","bones","map"];class m0{constructor(e,t,n){const i=n||st.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class st{constructor(e,t,n){this.path=t,this.parsedPath=n||st.parseTrackName(t),this.node=st.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new st.Composite(e,t,n):new st(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(o0,"")}static parseTrackName(e){const t=f0.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);p0.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a=r){const d=r++,u=e[d];t[u.uuid]=h,e[h]=u,t[c]=d,e[d]=l;for(let f=0,p=i;f!==p;++f){const _=n[f],g=_[d],m=_[h];_[h]=g,_[d]=m}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,d=t[h];if(d!==void 0)if(delete t[h],d0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,_=i;p!==_;++p){const g=n[p];g[d]=g[u],g.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,d=new Array(c);i=r.length,n[e]=i,a.push(e),o.push(t),r.push(d);for(let u=h,f=l.length;u!==f;++u){const p=l[u];d[u]=new st(p,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}class Nf{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,o=new Array(a),l={endingStart:Li,endingEnd:Li};for(let c=0;c!==a;++c){const h=r[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=yd,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const i=this._clip.duration,r=e._clip.duration,a=r/i,o=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=r,l[1]=r+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case wc:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Ao:default:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const a=n===Md;if(e===0)return r===-1?i:a&&(r&1)===1?t-i:i;if(n===vd){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,r+=Math.abs(o);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=i;if(a&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Di,i.endingEnd=Di):(e?i.endingStart=this.zeroSlopeAtStart?Di:Li:i.endingStart=hr,t?i.endingEnd=this.zeroSlopeAtEnd?Di:Li:i.endingEnd=hr)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,l[0]=t,o[1]=r+e,l[1]=n,this}}const _0=new Float32Array(1);class x0 extends Mn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let d=0;d!==r;++d){const u=i[d],f=u.name;let p=h[f];if(p!==void 0)++p.referenceCount,a[d]=p;else{if(p=a[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}const _=t&&t._propertyBindings[d].binding.parsedPath;p=new Uf(st.create(n,f,_),u.ValueTypeName,u.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),a[d]=p}o[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vu).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const yu=new C,ga=new C,ds=new C,fs=new C,zl=new C,C0=new C,R0=new C;class I0{constructor(e=new C,t=new C){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){yu.subVectors(e,this.start),ga.subVectors(this.end,this.start);const n=ga.dot(ga);if(n===0)return 0;let r=ga.dot(yu)/n;return t&&(r=Ve(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=C0,n=R0){const i=10000000000000001e-32;let r,a;const o=this.start,l=e.start,c=this.end,h=e.end;ds.subVectors(c,o),fs.subVectors(h,l),zl.subVectors(o,l);const d=ds.dot(ds),u=fs.dot(fs),f=fs.dot(zl);if(d<=i&&u<=i)return t.copy(o),n.copy(l),t.sub(n),t.dot(t);if(d<=i)r=0,a=f/u,a=Ve(a,0,1);else{const p=ds.dot(zl);if(u<=i)a=0,r=Ve(-p/d,0,1);else{const _=ds.dot(fs),g=d*u-_*_;g!==0?r=Ve((_*f-p*u)/g,0,1):r=0,a=(_*r+f)/u,a<0?(a=0,r=Ve(-p/d,0,1)):a>1&&(a=1,r=Ve((_-p)/d,0,1))}}return t.copy(o).addScaledVector(ds,r),n.copy(l).addScaledVector(fs,a),t.distanceToSquared(n)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Mu=new C;class P0 extends rt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Ye,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let d=0;d.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Eu.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Eu,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class W0 extends Nn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ye;i.setAttribute("position",new Ee(t,3)),i.setAttribute("color",new Ee(n,3));const r=new Yt({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new Se,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class X0{constructor(){this.type="ShapePath",this.color=new Se,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new gr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(l,c){let h=!1;const d=c.length;for(let u=0,f=d-1;ul.y!=_.y>l.y&&l.x<(_.x-p.x)*(l.y-p.y)/(_.y-p.y)+p.x&&(h=!h)}return h}function t(l,c){const h=c.getCenter(new Q);if(e(h,l))return h;const d=h.y,u=[],f=l.length;for(let p=0;pd!=g.y>d){const m=_.x+(d-_.y)*(g.x-_.x)/(g.y-_.y);u.push(m)}}return u.length>1&&(u.sort((p,_)=>p-_),h.x=(u[0]+u[1])/2),h}let n=this.userData.style&&this.userData.style.fillRule||"nonzero";n!=="nonzero"&&n!=="evenodd"&&(oe('Fill-rule "'+n+'" is not supported, falling back to "nonzero".'),n="nonzero");const i=n==="nonzero"?(l=>l!==0):(l=>(l&1)!==0),r=[];for(const l of this.subPaths){const c=l.getPoints();if(c.length<3)continue;const h=xn.area(c);if(h===0)continue;const d=new Ff;for(let u=0;uc.absArea-l.absArea);for(let l=0;l=0;d--){const u=r[d];if(u.boundingBox.containsBox(c.boundingBox)&&e(c.interiorPoint,u.points)){c.container=u.exclude?u.container:u,h=u.winding,c.winding+=h;break}}i(c.winding)===i(h)&&(c.exclude=!0)}for(const l of r)l.exclude||(l.role=l.container===null||l.container.role==="hole"?"outer":"hole");const a=[],o=new Map;for(const l of r){if(l.exclude||l.role!=="outer")continue;const c=new wr;c.curves=l.subPath.curves,a.push(c),o.set(l,c)}for(const l of r){if(l.exclude||l.role!=="hole")continue;const c=o.get(l.container);if(!c)continue;const h=new gr;h.curves=l.subPath.curves,c.holes.push(h)}return a}}class q0 extends Mn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){oe("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Y0(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function Z0(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function J0(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function cc(s,e,t,n){const i=$0(n);switch(t){case Ac:return s*e;case So:return s*e/i.components*i.byteLength;case br:return s*e/i.components*i.byteLength;case ui:return s*e*2/i.components*i.byteLength;case bo:return s*e*2/i.components*i.byteLength;case Ec:return s*e*3/i.components*i.byteLength;case Wt:return s*e*4/i.components*i.byteLength;case To:return s*e*4/i.components*i.byteLength;case Qs:case js:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case er:case tr:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Oa:case za:return Math.max(s,16)*Math.max(e,8)/4;case Fa:case Ba:return Math.max(s,8)*Math.max(e,8)/2;case Va:case ka:case Ha:case Wa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Ga:case or:case Xa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case qa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Ya:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Za:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Ja:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case $a:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Ka:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Qa:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case ja:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case eo:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case to:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case no:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case io:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case so:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case ro:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case ao:case oo:case lo:return Math.ceil(s/4)*Math.ceil(e/4)*16;case co:case ho:return Math.ceil(s/4)*Math.ceil(e/4)*8;case lr:case uo:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function $0(s){switch(s){case Kt:case Mc:return{byteLength:1,components:1};case ys:case Sc:case Dn:return{byteLength:2,components:1};case yo:case Mo:return{byteLength:2,components:4};case un:case vo:case Ht:return{byteLength:4,components:1};case bc:case Tc:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}class K0{static contain(e,t){return Y0(e,t)}static cover(e,t){return Z0(e,t)}static fill(e){return J0(e)}static getByteLength(e,t,n,i){return cc(e,t,n,i)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}}));typeof window<"u"&&(window.__THREE__?oe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function Bf(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&s!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function Q0(s){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,u=s.createBuffer();s.bindBuffer(l,u),s.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,l,c){const h=l.array,d=l.updateRanges;if(s.bindBuffer(c,o),d.length===0)s.bufferSubData(c,0,h);else{d.sort((f,p)=>f.start-p.start);let u=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,m_=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,g_=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,__=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,x_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,v_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,y_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,M_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,S_=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,b_=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,T_=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,A_=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,E_=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,w_=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,C_=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,R_="gl_FragColor = linearToOutputTexel( gl_FragColor );",I_=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,P_=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,L_=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,D_=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,U_=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,N_=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,F_=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,O_=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,B_=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,z_=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,V_=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,k_=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,G_=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,H_=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,W_=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,X_=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,q_=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Y_=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Z_=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,J_=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$_=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,K_=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,Q_=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,j_=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,ex=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,tx=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,nx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,ix=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,sx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,rx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,ax=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,ox=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,lx=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,cx=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,hx=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,ux=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,dx=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,fx=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,px=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,mx=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,gx=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,_x=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,xx=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,vx=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,yx=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Mx=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,Sx=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,bx=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,Tx=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Ax=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Ex=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,wx=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cx=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,Rx=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Ix=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Px=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Lx=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,Dx=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Ux=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,Nx=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,Fx=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Ox=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,Bx=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,zx=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,Vx=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,kx=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Gx=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,Hx=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Wx=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Xx=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,qx=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Yx=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Zx=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Jx=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$x=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Kx=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,Qx=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const jx=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ev=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tv=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nv=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,iv=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sv=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rv=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,av=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ov=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lv=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cv=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,hv=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,uv=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dv=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fv=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,pv=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mv=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gv=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_v=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xv=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,vv=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,yv=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Mv=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Sv=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,bv=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Tv=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Av=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Ev=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,wv=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Cv=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rv=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Iv=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Pv=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Lv=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Ke={alphahash_fragment:j0,alphahash_pars_fragment:e_,alphamap_fragment:t_,alphamap_pars_fragment:n_,alphatest_fragment:i_,alphatest_pars_fragment:s_,aomap_fragment:r_,aomap_pars_fragment:a_,batching_pars_vertex:o_,batching_vertex:l_,begin_vertex:c_,beginnormal_vertex:h_,bsdfs:u_,iridescence_fragment:d_,bumpmap_pars_fragment:f_,clipping_planes_fragment:p_,clipping_planes_pars_fragment:m_,clipping_planes_pars_vertex:g_,clipping_planes_vertex:__,color_fragment:x_,color_pars_fragment:v_,color_pars_vertex:y_,color_vertex:M_,common:S_,cube_uv_reflection_fragment:b_,defaultnormal_vertex:T_,displacementmap_pars_vertex:A_,displacementmap_vertex:E_,emissivemap_fragment:w_,emissivemap_pars_fragment:C_,colorspace_fragment:R_,colorspace_pars_fragment:I_,envmap_fragment:P_,envmap_common_pars_fragment:L_,envmap_pars_fragment:D_,envmap_pars_vertex:U_,envmap_physical_pars_fragment:X_,envmap_vertex:N_,fog_vertex:F_,fog_pars_vertex:O_,fog_fragment:B_,fog_pars_fragment:z_,gradientmap_pars_fragment:V_,lightmap_pars_fragment:k_,lights_lambert_fragment:G_,lights_lambert_pars_fragment:H_,lights_pars_begin:W_,lights_toon_fragment:q_,lights_toon_pars_fragment:Y_,lights_phong_fragment:Z_,lights_phong_pars_fragment:J_,lights_physical_fragment:$_,lights_physical_pars_fragment:K_,lights_fragment_begin:Q_,lights_fragment_maps:j_,lights_fragment_end:ex,lightprobes_pars_fragment:tx,logdepthbuf_fragment:nx,logdepthbuf_pars_fragment:ix,logdepthbuf_pars_vertex:sx,logdepthbuf_vertex:rx,map_fragment:ax,map_pars_fragment:ox,map_particle_fragment:lx,map_particle_pars_fragment:cx,metalnessmap_fragment:hx,metalnessmap_pars_fragment:ux,morphinstance_vertex:dx,morphcolor_vertex:fx,morphnormal_vertex:px,morphtarget_pars_vertex:mx,morphtarget_vertex:gx,normal_fragment_begin:_x,normal_fragment_maps:xx,normal_pars_fragment:vx,normal_pars_vertex:yx,normal_vertex:Mx,normalmap_pars_fragment:Sx,clearcoat_normal_fragment_begin:bx,clearcoat_normal_fragment_maps:Tx,clearcoat_pars_fragment:Ax,iridescence_pars_fragment:Ex,opaque_fragment:wx,packing:Cx,premultiplied_alpha_fragment:Rx,project_vertex:Ix,dithering_fragment:Px,dithering_pars_fragment:Lx,roughnessmap_fragment:Dx,roughnessmap_pars_fragment:Ux,shadowmap_pars_fragment:Nx,shadowmap_pars_vertex:Fx,shadowmap_vertex:Ox,shadowmask_pars_fragment:Bx,skinbase_vertex:zx,skinning_pars_vertex:Vx,skinning_vertex:kx,skinnormal_vertex:Gx,specularmap_fragment:Hx,specularmap_pars_fragment:Wx,tonemapping_fragment:Xx,tonemapping_pars_fragment:qx,transmission_fragment:Yx,transmission_pars_fragment:Zx,uv_pars_fragment:Jx,uv_pars_vertex:$x,uv_vertex:Kx,worldpos_vertex:Qx,background_vert:jx,background_frag:ev,backgroundCube_vert:tv,backgroundCube_frag:nv,cube_vert:iv,cube_frag:sv,depth_vert:rv,depth_frag:av,distance_vert:ov,distance_frag:lv,equirect_vert:cv,equirect_frag:hv,linedashed_vert:uv,linedashed_frag:dv,meshbasic_vert:fv,meshbasic_frag:pv,meshlambert_vert:mv,meshlambert_frag:gv,meshmatcap_vert:_v,meshmatcap_frag:xv,meshnormal_vert:vv,meshnormal_frag:yv,meshphong_vert:Mv,meshphong_frag:Sv,meshphysical_vert:bv,meshphysical_frag:Tv,meshtoon_vert:Av,meshtoon_frag:Ev,points_vert:wv,points_frag:Cv,shadow_vert:Rv,shadow_frag:Iv,sprite_vert:Pv,sprite_frag:Lv},me={common:{diffuse:{value:new Se(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},envMapRotation:{value:new Xe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new Q(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Se(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Se(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new Se(16777215)},opacity:{value:1},center:{value:new Q(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},_n={basic:{uniforms:kt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:kt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Se(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:kt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Se(0)},specular:{value:new Se(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:kt([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Se(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:kt([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Se(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:kt([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:kt([me.points,me.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:kt([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:kt([me.common,me.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:kt([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:kt([me.sprite,me.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xe}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:kt([me.common,me.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:kt([me.lights,me.fog,{color:{value:new Se(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};_n.physical={uniforms:kt([_n.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new Q(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new Se(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new Q},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new Se(0)},specularColor:{value:new Se(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new Q},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const Sa={r:0,b:0,g:0},Dv=new He,zf=new Xe;zf.set(-1,0,0,0,1,0,0,0,1);function Uv(s,e,t,n,i,r){const a=new Se(0);let o=i===!0?0:1,l,c,h=null,d=0,u=null;function f(M){let S=M.isScene===!0?M.background:null;if(S&&S.isTexture){const v=M.backgroundBlurriness>0;S=e.get(S,v)}return S}function p(M){let S=!1;const v=f(M);v===null?g(a,o):v&&v.isColor&&(g(v,1),S=!0);const E=s.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||S)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function _(M,S){const v=f(S);v&&(v.isCubeTexture||v.mapping===Es)?(c===void 0&&(c=new Ct(new Hi(1,1,1),new dn({name:"BackgroundCubeMaterial",uniforms:As(_n.backgroundCube.uniforms),vertexShader:_n.backgroundCube.vertexShader,fragmentShader:_n.backgroundCube.fragmentShader,side:Xt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(E,T,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Dv.makeRotationFromEuler(S.backgroundRotation)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(zf),c.material.toneMapped=tt.getTransfer(v.colorSpace)!==ot,(h!==v||d!==v.version||u!==s.toneMapping)&&(c.material.needsUpdate=!0,h=v,d=v.version,u=s.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new Ct(new Cs(2,2),new dn({name:"BackgroundMaterial",uniforms:As(_n.background.uniforms),vertexShader:_n.background.vertexShader,fragmentShader:_n.background.fragmentShader,side:Xn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,l.material.toneMapped=tt.getTransfer(v.colorSpace)!==ot,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||u!==s.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,u=s.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function g(M,S){M.getRGB(Sa,rf(s)),t.buffers.color.setClear(Sa.r,Sa.g,Sa.b,S,r)}function m(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(M,S=1){a.set(M),o=S,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(M){o=M,g(a,o)},render:p,addToRenderList:_,dispose:m}}function Nv(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=u(null);let r=i,a=!1;function o(P,U,H,X,O){let W=!1;const G=d(P,X,H,U);r!==G&&(r=G,c(r.object)),W=f(P,X,H,O),W&&p(P,X,H,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,v(P,U,H,X),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return s.createVertexArray()}function c(P){return s.bindVertexArray(P)}function h(P){return s.deleteVertexArray(P)}function d(P,U,H,X){const O=X.wireframe===!0;let W=n[U.id];W===void 0&&(W={},n[U.id]=W);const G=P.isInstancedMesh===!0?P.id:0;let K=W[G];K===void 0&&(K={},W[G]=K);let ie=K[H.id];ie===void 0&&(ie={},K[H.id]=ie);let ue=ie[O];return ue===void 0&&(ue=u(l()),ie[O]=ue),ue}function u(P){const U=[],H=[],X=[];for(let O=0;O=0){const le=O[ie];let be=W[ie];if(be===void 0&&(ie==="instanceMatrix"&&P.instanceMatrix&&(be=P.instanceMatrix),ie==="instanceColor"&&P.instanceColor&&(be=P.instanceColor)),le===void 0||le.attribute!==be||be&&le.data!==be.data)return!0;G++}return r.attributesNum!==G||r.index!==X}function p(P,U,H,X){const O={},W=U.attributes;let G=0;const K=H.getAttributes();for(const ie in K)if(K[ie].location>=0){let le=W[ie];le===void 0&&(ie==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),ie==="instanceColor"&&P.instanceColor&&(le=P.instanceColor));const be={};be.attribute=le,le&&le.data&&(be.data=le.data),O[ie]=be,G++}r.attributes=O,r.attributesNum=G,r.index=X}function _(){const P=r.newAttributes;for(let U=0,H=P.length;U=0){let ue=O[K];if(ue===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(ue=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(ue=P.instanceColor)),ue!==void 0){const le=ue.normalized,be=ue.itemSize,Qe=e.get(ue);if(Qe===void 0)continue;const dt=Qe.buffer,nt=Qe.type,J=Qe.bytesPerElement,ce=nt===s.INT||nt===s.UNSIGNED_INT||ue.gpuType===vo;if(ue.isInterleavedBufferAttribute){const se=ue.data,Ue=se.stride,ke=ue.offset;if(se.isInstancedInterleavedBuffer){for(let Oe=0;Oe0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(oe("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),M=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),S=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),E=s.getParameter(s.MAX_SAMPLES),T=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:v,maxSamples:E,samples:T}}function Bv(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new si,o=new Xe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const f=d.length!==0||u||n!==0||i;return i=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){const p=d.clippingPlanes,_=d.clipIntersection,g=d.clipShadows,m=s.get(d);if(!i||p===null||p.length===0||r&&!g)r?h(null):c();else{const M=r?0:n,S=M*4;let v=m.clippingState||null;l.value=v,v=h(p,u,S,f);for(let E=0;E!==S;++E)v[E]=t[E];m.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,p){const _=d!==null?d.length:0;let g=null;if(_!==0){if(g=l.value,p!==!0||g===null){const m=f+_*4,M=u.matrixWorldInverse;o.getNormalMatrix(M),(g===null||g.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Iu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?E:0,E,E),d.setRenderTarget(i),m&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=M}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Ln||e.mapping===hi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Iu());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;ps(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Hs)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;rp-li?n-p+li:0),m=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,ps(r,g,m,3*_,2*_),i.setRenderTarget(r),i.render(o,Hs),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-n,ps(e,g,m,3*_,2*_),i.setRenderTarget(e),i.render(o,Hs)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Re("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[i];d.material=c;const u=c.uniforms,f=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Pi-1),_=r/p,g=isFinite(r)?1+Math.floor(h*_):Pi;g>Pi&&oe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Pi}`);const m=[];let M=0;for(let R=0;RS-li?i-S+li:0),T=4*(this._cubeSize-v);ps(t,E,T,3*v,2*v),l.setRenderTarget(t),l.render(d,Hs)}}function kv(s){const e=[],t=[],n=[];let i=s;const r=s-li+1+wu.length;for(let a=0;as-li?l=wu[a-s+li-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,p=6,_=3,g=2,m=1,M=new Float32Array(_*p*f),S=new Float32Array(g*p*f),v=new Float32Array(m*p*f);for(let T=0;T2?0:-1,A=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];M.set(A,_*p*T),S.set(u,g*p*T);const I=[T,T,T,T,T,T];v.set(I,m*p*T)}const E=new Ye;E.setAttribute("position",new ut(M,_)),E.setAttribute("uv",new ut(S,g)),E.setAttribute("faceIndex",new ut(v,m)),n.push(new Ct(E,null)),i>li&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Ru(s,e,t){const n=new on(s,e,t);return n.texture.mapping=Es,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ps(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Gv(s,e,t){return new dn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:zv,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:el(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:Pn,depthTest:!1,depthWrite:!1})}function Hv(s,e,t){const n=new Float32Array(Pi),i=new C(0,1,0);return new dn({name:"SphericalGaussianBlur",defines:{n:Pi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:el(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:Pn,depthTest:!1,depthWrite:!1})}function Iu(){return new dn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:el(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:Pn,depthTest:!1,depthWrite:!1})}function Pu(){return new dn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:el(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:Pn,depthTest:!1,depthWrite:!1})}function el(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class nh extends on{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Tr(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new Hi(5,5,5),r=new dn({name:"CubemapFromEquirect",uniforms:As(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Xt,blending:Pn});r.uniforms.tEquirect.value=t;const a=new Ct(i,r),o=t.minFilter;return t.minFilter===Rn&&(t.minFilter=_t),new If(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}function Wv(s){let e=new WeakMap,t=new WeakMap,n=null;function i(u,f=!1){return u==null?null:f?a(u):r(u)}function r(u){if(u&&u.isTexture){const f=u.mapping;if(f===Js||f===$s)if(e.has(u)){const p=e.get(u).texture;return o(p,u.mapping)}else{const p=u.image;if(p&&p.height>0){const _=new nh(p.height);return _.fromEquirectangularTexture(s,u),e.set(u,_),u.addEventListener("dispose",c),o(_.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const f=u.mapping,p=f===Js||f===$s,_=f===Ln||f===hi;if(p||_){let g=t.get(u);const m=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==m)return n===null&&(n=new hc(s)),g=p?n.fromEquirectangular(u,g):n.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),g.texture;if(g!==void 0)return g.texture;{const M=u.image;return p&&M&&M.height>0||_&&M&&l(M)?(n===null&&(n=new hc(s)),g=p?n.fromEquirectangular(u):n.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),u.addEventListener("dispose",h),g.texture):null}}}return u}function o(u,f){return f===Js?u.mapping=Ln:f===$s&&(u.mapping=hi),u}function l(u){let f=0;const p=6;for(let _=0;_=65535?Pc:Ic)(u,1);g.version=_;const m=r.get(d);m&&e.remove(m),r.set(d,g)}function h(d){const u=r.get(d);if(u){const f=d.index;f!==null&&u.versione.maxTextureSize&&(E=Math.ceil(v/e.maxTextureSize),v=e.maxTextureSize);const T=new Float32Array(v*E*4*d),R=new Co(T,v,E,d);R.type=Ht,R.needsUpdate=!0;const x=S*4;for(let I=0;I + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),h=new Ct(l,c),d=new Ir(-1,1,1,-1,0,1);let u=null,f=null,p=!1,_,g=null,m=[],M=!1;this.setSize=function(S,v){a.setSize(S,v),o.setSize(S,v);for(let E=0;E0&&m[0].isRenderPass===!0;const v=a.width,E=a.height;for(let T=0;T0)return s;const i=e*t;let r=Lu[i];if(r===void 0&&(r=new Float32Array(i),Lu[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function Rt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function Bu(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const Hy=37297;let Wy=0;function Xy(s,e){const t=s.split(` +`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=i;a":" "} ${o}: ${t[a]}`)}return n.join(` +`)}const zu=new Xe;function qy(s){tt._getMatrix(zu,tt.workingColorSpace,s);const e=`mat3( ${zu.elements.map(t=>t.toFixed(4))} )`;switch(tt.getTransfer(s)){case dr:return[e,"LinearTransferOETF"];case ot:return[e,"sRGBTransferOETF"];default:return oe("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Vu(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+Xy(s.getShaderSource(e),o)}else return r}function Yy(s,e){const t=qy(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const Zy={[fc]:"Linear",[pc]:"Reinhard",[mc]:"Cineon",[gc]:"ACESFilmic",[xc]:"AgX",[vc]:"Neutral",[_c]:"Custom"};function Jy(s,e){const t=Zy[e];return t===void 0?(oe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ba=new C;function $y(){tt.getLuminanceCoefficients(ba);const s=ba.x.toFixed(4),e=ba.y.toFixed(4),t=ba.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Ky(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ys).join(` +`)}function Qy(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function jy(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function dc(s){return s.replace(eM,nM)}const tM=new Map;function nM(s,e){let t=Ke[e];if(t===void 0){const n=tM.get(e);if(n!==void 0)t=Ke[n],oe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return dc(t)}const iM=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Hu(s){return s.replace(iM,sM)}function sM(s,e,t,n){let i="";for(let r=parseInt(e);r0&&(g+=` +`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Ys).join(` +`),m.length>0&&(m+=` +`)):(g=[Wu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Ys).join(` +`),m=[Wu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==vn?"#define TONE_MAPPING":"",t.toneMapping!==vn?Ke.tonemapping_pars_fragment:"",t.toneMapping!==vn?Jy("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ke.colorspace_pars_fragment,Yy("linearToOutputTexel",t.outputColorSpace),$y(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(Ys).join(` +`)),a=dc(a),a=ku(a,t),a=Gu(a,t),o=dc(o),o=ku(o,t),o=Gu(o,t),a=Hu(a),o=Hu(o),t.isRawShaderMaterial!==!0&&(M=`#version 300 es +`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,m=["#define varying in",t.glslVersion===tc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===tc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+m);const S=M+g+a,v=M+m+o,E=Bu(i,i.VERTEX_SHADER,S),T=Bu(i,i.FRAGMENT_SHADER,v);i.attachShader(_,E),i.attachShader(_,T),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function R(P){if(s.debug.checkShaderErrors){const U=i.getProgramInfoLog(_)||"",H=i.getShaderInfoLog(E)||"",X=i.getShaderInfoLog(T)||"",O=U.trim(),W=H.trim(),G=X.trim();let K=!0,ie=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(K=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,E,T);else{const ue=Vu(i,E,"vertex"),le=Vu(i,T,"fragment");Re("WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` + +Material Name: `+P.name+` +Material Type: `+P.type+` + +Program Info Log: `+O+` +`+ue+` +`+le)}else O!==""?oe("WebGLProgram: Program Info Log:",O):(W===""||G==="")&&(ie=!1);ie&&(P.diagnostics={runnable:K,programLog:O,vertexShader:{log:W,prefix:g},fragmentShader:{log:G,prefix:m}})}i.deleteShader(E),i.deleteShader(T),x=new Ea(i,_),A=jy(i,_)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=i.getProgramParameter(_,Hy)),I},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Wy++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=E,this.fragmentShader=T,this}let mM=0;class gM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new _M(e),t.set(e,n)),n}}class _M{constructor(e){this.id=mM++,this.code=e,this.usedTimes=0}}function xM(s){return s===ui||s===or||s===lr}function vM(s,e,t,n,i,r){const a=new Io,o=new gM,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer;let u=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x){return l.add(x),x===0?"uv":`uv${x}`}function _(x,A,I,P,U,H){const X=P.fog,O=U.geometry,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?P.environment:null,G=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,K=e.get(x.envMap||W,G),ie=K&&K.mapping===Es?K.image.height:null,ue=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&oe("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));const le=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,be=le!==void 0?le.length:0;let Qe=0;O.morphAttributes.position!==void 0&&(Qe=1),O.morphAttributes.normal!==void 0&&(Qe=2),O.morphAttributes.color!==void 0&&(Qe=3);let dt,nt,J,ce;if(ue){const we=_n[ue];dt=we.vertexShader,nt=we.fragmentShader}else{dt=x.vertexShader,nt=x.fragmentShader;const we=o.getVertexShaderStage(x),yt=o.getFragmentShaderStage(x);o.update(x,we,yt),J=we.id,ce=yt.id}const se=s.getRenderTarget(),Ue=s.state.buffers.depth.getReversed(),ke=U.isInstancedMesh===!0,Oe=U.isBatchedMesh===!0,at=!!x.map,We=!!x.matcap,j=!!K,ne=!!x.aoMap,te=!!x.lightMap,xe=!!x.bumpMap&&x.wireframe===!1,ge=!!x.normalMap,Be=!!x.displacementMap,Pe=!!x.emissiveMap,Ge=!!x.metalnessMap,qe=!!x.roughnessMap,L=x.anisotropy>0,ct=x.clearcoat>0,et=x.dispersion>0,w=x.iridescence>0,y=x.sheen>0,F=x.transmission>0,V=L&&!!x.anisotropyMap,q=ct&&!!x.clearcoatMap,re=ct&&!!x.clearcoatNormalMap,ae=ct&&!!x.clearcoatRoughnessMap,Y=w&&!!x.iridescenceMap,$=w&&!!x.iridescenceThicknessMap,de=y&&!!x.sheenColorMap,Le=y&&!!x.sheenRoughnessMap,_e=!!x.specularMap,fe=!!x.specularColorMap,Fe=!!x.specularIntensityMap,ze=F&&!!x.transmissionMap,Ze=F&&!!x.thicknessMap,D=!!x.gradientMap,he=!!x.alphaMap,Z=x.alphaTest>0,pe=!!x.alphaHash,Me=!!x.extensions;let ee=vn;x.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(ee=s.toneMapping);const Ie={shaderID:ue,shaderType:x.type,shaderName:x.name,vertexShader:dt,fragmentShader:nt,defines:x.defines,customVertexShaderID:J,customFragmentShaderID:ce,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:Oe,batchingColor:Oe&&U._colorsTexture!==null,instancing:ke,instancingColor:ke&&U.instanceColor!==null,instancingMorph:ke&&U.morphTexture!==null,outputColorSpace:se===null?s.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:tt.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:at,matcap:We,envMap:j,envMapMode:j&&K.mapping,envMapCubeUVHeight:ie,aoMap:ne,lightMap:te,bumpMap:xe,normalMap:ge,displacementMap:Be,emissiveMap:Pe,normalMapObjectSpace:ge&&x.normalMapType===bd,normalMapTangentSpace:ge&&x.normalMapType===qn,packedNormalMap:ge&&x.normalMapType===qn&&xM(x.normalMap.format),metalnessMap:Ge,roughnessMap:qe,anisotropy:L,anisotropyMap:V,clearcoat:ct,clearcoatMap:q,clearcoatNormalMap:re,clearcoatRoughnessMap:ae,dispersion:et,iridescence:w,iridescenceMap:Y,iridescenceThicknessMap:$,sheen:y,sheenColorMap:de,sheenRoughnessMap:Le,specularMap:_e,specularColorMap:fe,specularIntensityMap:Fe,transmission:F,transmissionMap:ze,thicknessMap:Ze,gradientMap:D,opaque:x.transparent===!1&&x.blending===Ni&&x.alphaToCoverage===!1,alphaMap:he,alphaTest:Z,alphaHash:pe,combine:x.combine,mapUv:at&&p(x.map.channel),aoMapUv:ne&&p(x.aoMap.channel),lightMapUv:te&&p(x.lightMap.channel),bumpMapUv:xe&&p(x.bumpMap.channel),normalMapUv:ge&&p(x.normalMap.channel),displacementMapUv:Be&&p(x.displacementMap.channel),emissiveMapUv:Pe&&p(x.emissiveMap.channel),metalnessMapUv:Ge&&p(x.metalnessMap.channel),roughnessMapUv:qe&&p(x.roughnessMap.channel),anisotropyMapUv:V&&p(x.anisotropyMap.channel),clearcoatMapUv:q&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:re&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Y&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:$&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:de&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:Le&&p(x.sheenRoughnessMap.channel),specularMapUv:_e&&p(x.specularMap.channel),specularColorMapUv:fe&&p(x.specularColorMap.channel),specularIntensityMapUv:Fe&&p(x.specularIntensityMap.channel),transmissionMapUv:ze&&p(x.transmissionMap.channel),thicknessMapUv:Ze&&p(x.thicknessMap.channel),alphaMapUv:he&&p(x.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ge||L),vertexNormals:!!O.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!O.attributes.uv&&(at||he),fog:!!X,useFog:x.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||O.attributes.normal===void 0&&ge===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ue,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:Qe,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:H.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:ee,decodeVideoTexture:at&&x.map.isVideoTexture===!0&&tt.getTransfer(x.map.colorSpace)===ot,decodeVideoTextureEmissive:Pe&&x.emissiveMap.isVideoTexture===!0&&tt.getTransfer(x.emissiveMap.colorSpace)===ot,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Cn,flipSided:x.side===Xt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:Me&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&x.extensions.multiDraw===!0||Oe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Ie.vertexUv1s=l.has(1),Ie.vertexUv2s=l.has(2),Ie.vertexUv3s=l.has(3),l.clear(),Ie}function g(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)A.push(I),A.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(m(A,x),M(A,x),A.push(s.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function m(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function M(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function S(x){const A=f[x.type];let I;if(A){const P=_n[A];I=af.clone(P.uniforms)}else I=x.uniforms;return I}function v(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new pM(s,A,x,i),c.push(I),h.set(A,I)),I}function E(x){if(--x.usedTimes===0){const A=c.indexOf(x);c[A]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function T(x){o.remove(x)}function R(){o.dispose()}return{getParameters:_,getProgramCacheKey:g,getUniforms:S,acquireProgram:v,releaseProgram:E,releaseShaderCache:T,programs:c,dispose:R}}function yM(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function MM(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Xu(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function qu(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function o(u,f,p,_,g,m){let M=s[e];return M===void 0?(M={id:u.id,object:u,geometry:f,material:p,materialVariant:a(u),groupOrder:_,renderOrder:u.renderOrder,z:g,group:m},s[e]=M):(M.id=u.id,M.object=u,M.geometry=f,M.material=p,M.materialVariant=a(u),M.groupOrder=_,M.renderOrder=u.renderOrder,M.z=g,M.group=m),e++,M}function l(u,f,p,_,g,m){const M=o(u,f,p,_,g,m);p.transmission>0?n.push(M):p.transparent===!0?i.push(M):t.push(M)}function c(u,f,p,_,g,m){const M=o(u,f,p,_,g,m);p.transmission>0?n.unshift(M):p.transparent===!0?i.unshift(M):t.unshift(M)}function h(u,f,p){t.length>1&&t.sort(u||MM),n.length>1&&n.sort(f||Xu),i.length>1&&i.sort(f||Xu),p&&(t.reverse(),n.reverse(),i.reverse())}function d(){for(let u=e,f=s.length;u=r.length?(a=new qu,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function bM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new Se};break;case"SpotLight":t={position:new C,direction:new C,color:new Se,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new Se,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new Se,groundColor:new Se};break;case"RectAreaLight":t={color:new Se,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function TM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let AM=0;function EM(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function wM(s){const e=new bM,t=TM(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const i=new C,r=new He,a=new He;function o(c){let h=0,d=0,u=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,p=0,_=0,g=0,m=0,M=0,S=0,v=0,E=0,T=0,R=0;c.sort(EM);for(let A=0,I=c.length;A0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=me.LTC_FLOAT_1,n.rectAreaLTC2=me.LTC_FLOAT_2):(n.rectAreaLTC1=me.LTC_HALF_1,n.rectAreaLTC2=me.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;const x=n.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==_||x.rectAreaLength!==g||x.hemiLength!==m||x.numDirectionalShadows!==M||x.numPointShadows!==S||x.numSpotShadows!==v||x.numSpotMaps!==E||x.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=M,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=v+E-T,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=R,x.directionalLength=f,x.pointLength=p,x.spotLength=_,x.rectAreaLength=g,x.hemiLength=m,x.numDirectionalShadows=M,x.numPointShadows=S,x.numSpotShadows=v,x.numSpotMaps=E,x.numLightProbes=R,n.version=AM++)}function l(c,h){let d=0,u=0,f=0,p=0,_=0;const g=h.matrixWorldInverse;for(let m=0,M=c.length;m=a.length?(o=new Yu(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const RM=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,IM=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,PM=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],LM=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],Zu=new He,Ws=new C,Yl=new C;function DM(s,e,t){let n=new Vi;const i=new Q,r=new Q,a=new lt,o=new Wc,l=new Xc,c={},h=t.maxTextureSize,d={[Xn]:Xt,[Xt]:Xn,[Cn]:Cn},u=new dn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},radius:{value:4}},vertexShader:RM,fragmentShader:IM}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ye;p.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Ct(p,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Zs;let m=this.type;this.render=function(T,R,x){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;this.type===Ku&&(oe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Zs);const A=s.getRenderTarget(),I=s.getActiveCubeFace(),P=s.getActiveMipmapLevel(),U=s.state;U.setBlending(Pn),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const H=m!==this.type;H&&R.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(O=>O.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,O=T.length;Xh||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/K.x),i.x=r.x*K.x,G.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/K.y),i.y=r.y*K.y,G.mapSize.y=r.y));const ie=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=ie,G.map===null||H===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===ms){if(W.isPointLight){oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new on(i.x,i.y,{format:ui,type:Dn,minFilter:_t,magFilter:_t,generateMipmaps:!1}),G.map.texture.name=W.name+".shadowMap",G.map.depthTexture=new ki(i.x,i.y,Ht),G.map.depthTexture.name=W.name+".shadowMapDepth",G.map.depthTexture.format=Un,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Et,G.map.depthTexture.magFilter=Et}else W.isPointLight?(G.map=new nh(i.x),G.map.depthTexture=new Xd(i.x,un)):(G.map=new on(i.x,i.y),G.map.depthTexture=new ki(i.x,i.y,un)),G.map.depthTexture.name=W.name+".shadowMap",G.map.depthTexture.format=Un,this.type===Zs?(G.map.depthTexture.compareFunction=ie?wo:Eo,G.map.depthTexture.minFilter=_t,G.map.depthTexture.magFilter=_t):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Et,G.map.depthTexture.magFilter=Et);G.camera.updateProjectionMatrix()}const ue=G.map.isWebGLCubeRenderTarget?6:1;for(let le=0;le0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const U=I.uuid,H=R.uuid;let X=c[U];X===void 0&&(X={},c[U]=X);let O=X[H];O===void 0&&(O=I.clone(),X[H]=O,R.addEventListener("dispose",E)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,A===ms?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:d[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const U=s.properties.get(I);U.light=x}return I}function v(T,R,x,A,I){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&I===ms)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,T.matrixWorld);const H=e.update(T),X=T.material;if(Array.isArray(X)){const O=H.groups;for(let W=0,G=O.length;W=1):ie.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),G=K>=2);let ue=null,le={};const be=s.getParameter(s.SCISSOR_BOX),Qe=s.getParameter(s.VIEWPORT),dt=new lt().fromArray(be),nt=new lt().fromArray(Qe);function J(D,he,Z,pe){const Me=new Uint8Array(4),ee=s.createTexture();s.bindTexture(D,ee),s.texParameteri(D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(D,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Ie=0;Ie"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Q,h=new WeakMap,d=new Set;let u;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(w,y){return p?new OffscreenCanvas(w,y):pr("canvas")}function g(w,y,F){let V=1;const q=et(w);if((q.width>F||q.height>F)&&(V=F/Math.max(q.width,q.height)),V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){const re=Math.floor(V*q.width),ae=Math.floor(V*q.height);u===void 0&&(u=_(re,ae));const Y=y?_(re,ae):u;return Y.width=re,Y.height=ae,Y.getContext("2d").drawImage(w,0,0,re,ae),oe("WebGLRenderer: Texture has been resized from ("+q.width+"x"+q.height+") to ("+re+"x"+ae+")."),Y}else return"data"in w&&oe("WebGLRenderer: Image in DataTexture is too big ("+q.width+"x"+q.height+")."),w;return w}function m(w){return w.generateMipmaps}function M(w){s.generateMipmap(w)}function S(w){return w.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?s.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(w,y,F,V,q,re=!1){if(w!==null){if(s[w]!==void 0)return s[w];oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ae;V&&(ae=e.get("EXT_texture_norm16"),ae||oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Y=y;if(y===s.RED&&(F===s.FLOAT&&(Y=s.R32F),F===s.HALF_FLOAT&&(Y=s.R16F),F===s.UNSIGNED_BYTE&&(Y=s.R8),F===s.UNSIGNED_SHORT&&ae&&(Y=ae.R16_EXT),F===s.SHORT&&ae&&(Y=ae.R16_SNORM_EXT)),y===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.R8UI),F===s.UNSIGNED_SHORT&&(Y=s.R16UI),F===s.UNSIGNED_INT&&(Y=s.R32UI),F===s.BYTE&&(Y=s.R8I),F===s.SHORT&&(Y=s.R16I),F===s.INT&&(Y=s.R32I)),y===s.RG&&(F===s.FLOAT&&(Y=s.RG32F),F===s.HALF_FLOAT&&(Y=s.RG16F),F===s.UNSIGNED_BYTE&&(Y=s.RG8),F===s.UNSIGNED_SHORT&&ae&&(Y=ae.RG16_EXT),F===s.SHORT&&ae&&(Y=ae.RG16_SNORM_EXT)),y===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RG8UI),F===s.UNSIGNED_SHORT&&(Y=s.RG16UI),F===s.UNSIGNED_INT&&(Y=s.RG32UI),F===s.BYTE&&(Y=s.RG8I),F===s.SHORT&&(Y=s.RG16I),F===s.INT&&(Y=s.RG32I)),y===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGB8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGB16UI),F===s.UNSIGNED_INT&&(Y=s.RGB32UI),F===s.BYTE&&(Y=s.RGB8I),F===s.SHORT&&(Y=s.RGB16I),F===s.INT&&(Y=s.RGB32I)),y===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(Y=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(Y=s.RGBA16UI),F===s.UNSIGNED_INT&&(Y=s.RGBA32UI),F===s.BYTE&&(Y=s.RGBA8I),F===s.SHORT&&(Y=s.RGBA16I),F===s.INT&&(Y=s.RGBA32I)),y===s.RGB&&(F===s.UNSIGNED_SHORT&&ae&&(Y=ae.RGB16_EXT),F===s.SHORT&&ae&&(Y=ae.RGB16_SNORM_EXT),F===s.UNSIGNED_INT_5_9_9_9_REV&&(Y=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&(Y=s.R11F_G11F_B10F)),y===s.RGBA){const $=re?dr:tt.getTransfer(q);F===s.FLOAT&&(Y=s.RGBA32F),F===s.HALF_FLOAT&&(Y=s.RGBA16F),F===s.UNSIGNED_BYTE&&(Y=$===ot?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT&&ae&&(Y=ae.RGBA16_EXT),F===s.SHORT&&ae&&(Y=ae.RGBA16_SNORM_EXT),F===s.UNSIGNED_SHORT_4_4_4_4&&(Y=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(Y=s.RGB5_A1)}return(Y===s.R16F||Y===s.R32F||Y===s.RG16F||Y===s.RG32F||Y===s.RGBA16F||Y===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function E(w,y){let F;return w?y===null||y===un||y===Ms?F=s.DEPTH24_STENCIL8:y===Ht?F=s.DEPTH32F_STENCIL8:y===ys&&(F=s.DEPTH24_STENCIL8,oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===un||y===Ms?F=s.DEPTH_COMPONENT24:y===Ht?F=s.DEPTH_COMPONENT32F:y===ys&&(F=s.DEPTH_COMPONENT16),F}function T(w,y){return m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Et&&w.minFilter!==_t?Math.log2(Math.max(y.width,y.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?y.mipmaps.length:1}function R(w){const y=w.target;y.removeEventListener("dispose",R),A(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&d.delete(y)}function x(w){const y=w.target;y.removeEventListener("dispose",x),P(y)}function A(w){const y=n.get(w);if(y.__webglInit===void 0)return;const F=w.source,V=f.get(F);if(V){const q=V[y.__cacheKey];q.usedTimes--,q.usedTimes===0&&I(w),Object.keys(V).length===0&&f.delete(F)}n.remove(w)}function I(w){const y=n.get(w);s.deleteTexture(y.__webglTexture);const F=w.source,V=f.get(F);delete V[y.__cacheKey],a.memory.textures--}function P(w){const y=n.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),n.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(y.__webglFramebuffer[V]))for(let q=0;q=i.maxTextures&&oe("WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+i.maxTextures),U+=1,w}function G(w){const y=[];return y.push(w.wrapS),y.push(w.wrapT),y.push(w.wrapR||0),y.push(w.magFilter),y.push(w.minFilter),y.push(w.anisotropy),y.push(w.internalFormat),y.push(w.format),y.push(w.type),y.push(w.generateMipmaps),y.push(w.premultiplyAlpha),y.push(w.flipY),y.push(w.unpackAlignment),y.push(w.colorSpace),y.join()}function K(w,y){const F=n.get(w);if(w.isVideoTexture&&L(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&F.__version!==w.version){const V=w.image;if(V===null)oe("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)oe("WebGLRenderer: Texture marked for update but image is incomplete");else{Ue(F,w,y);return}}else w.isExternalTexture&&(F.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+y)}function ie(w,y){const F=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&F.__version!==w.version){Ue(F,w,y);return}else w.isExternalTexture&&(F.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+y)}function ue(w,y){const F=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&F.__version!==w.version){Ue(F,w,y);return}t.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+y)}function le(w,y){const F=n.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&F.__version!==w.version){ke(F,w,y);return}t.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+y)}const be={[rr]:s.REPEAT,[jt]:s.CLAMP_TO_EDGE,[ar]:s.MIRRORED_REPEAT},Qe={[Et]:s.NEAREST,[yc]:s.NEAREST_MIPMAP_NEAREST,[gs]:s.NEAREST_MIPMAP_LINEAR,[_t]:s.LINEAR,[Ks]:s.LINEAR_MIPMAP_NEAREST,[Rn]:s.LINEAR_MIPMAP_LINEAR},dt={[Td]:s.NEVER,[Rd]:s.ALWAYS,[Ad]:s.LESS,[Eo]:s.LEQUAL,[Ed]:s.EQUAL,[wo]:s.GEQUAL,[wd]:s.GREATER,[Cd]:s.NOTEQUAL};function nt(w,y){if(y.type===Ht&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===_t||y.magFilter===Ks||y.magFilter===gs||y.magFilter===Rn||y.minFilter===_t||y.minFilter===Ks||y.minFilter===gs||y.minFilter===Rn)&&oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(w,s.TEXTURE_WRAP_S,be[y.wrapS]),s.texParameteri(w,s.TEXTURE_WRAP_T,be[y.wrapT]),(w===s.TEXTURE_3D||w===s.TEXTURE_2D_ARRAY)&&s.texParameteri(w,s.TEXTURE_WRAP_R,be[y.wrapR]),s.texParameteri(w,s.TEXTURE_MAG_FILTER,Qe[y.magFilter]),s.texParameteri(w,s.TEXTURE_MIN_FILTER,Qe[y.minFilter]),y.compareFunction&&(s.texParameteri(w,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(w,s.TEXTURE_COMPARE_FUNC,dt[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Et||y.minFilter!==gs&&y.minFilter!==Rn||y.type===Ht&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");s.texParameterf(w,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,i.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function J(w,y){let F=!1;w.__webglInit===void 0&&(w.__webglInit=!0,y.addEventListener("dispose",R));const V=y.source;let q=f.get(V);q===void 0&&(q={},f.set(V,q));const re=G(y);if(re!==w.__cacheKey){q[re]===void 0&&(q[re]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),q[re].usedTimes++;const ae=q[w.__cacheKey];ae!==void 0&&(q[w.__cacheKey].usedTimes--,ae.usedTimes===0&&I(y)),w.__cacheKey=re,w.__webglTexture=q[re].texture}return F}function ce(w,y,F){return Math.floor(Math.floor(w/F)/y)}function se(w,y,F,V){const re=w.updateRanges;if(re.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,y.width,y.height,F,V,y.data);else{re.sort((Le,_e)=>Le.start-_e.start);let ae=0;for(let Le=1;Le0){ze&&Ze&&t.texStorage2D(s.TEXTURE_2D,he,_e,Fe[0].width,Fe[0].height);for(let Z=0,pe=Fe.length;Z0){const Me=cc(fe.width,fe.height,y.format,y.type);for(const ee of y.layerUpdates){const Ie=fe.data.subarray(ee*Me/fe.data.BYTES_PER_ELEMENT,(ee+1)*Me/fe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Z,0,0,ee,fe.width,fe.height,1,de,Ie)}y.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Z,0,0,0,fe.width,fe.height,$.depth,de,fe.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,Z,_e,fe.width,fe.height,$.depth,0,fe.data,0,0);else oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ze?D&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,Z,0,0,0,fe.width,fe.height,$.depth,de,Le,fe.data):t.texImage3D(s.TEXTURE_2D_ARRAY,Z,_e,fe.width,fe.height,$.depth,0,de,Le,fe.data)}else{ze&&Ze&&t.texStorage2D(s.TEXTURE_2D,he,_e,Fe[0].width,Fe[0].height);for(let Z=0,pe=Fe.length;Z0){const Z=cc($.width,$.height,y.format,y.type);for(const pe of y.layerUpdates){const Me=$.data.subarray(pe*Z/$.data.BYTES_PER_ELEMENT,(pe+1)*Z/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,pe,$.width,$.height,1,de,Le,Me)}y.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,de,Le,$.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,_e,$.width,$.height,$.depth,0,de,Le,$.data);else if(y.isData3DTexture)ze?(Ze&&t.texStorage3D(s.TEXTURE_3D,he,_e,$.width,$.height,$.depth),D&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,de,Le,$.data)):t.texImage3D(s.TEXTURE_3D,0,_e,$.width,$.height,$.depth,0,de,Le,$.data);else if(y.isFramebufferTexture){if(Ze)if(ze)t.texStorage2D(s.TEXTURE_2D,he,_e,$.width,$.height);else{let Z=$.width,pe=$.height;for(let Me=0;Me>=1,pe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in s){const Z=s.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),$.parentNode!==Z){Z.appendChild($),d.add(y),Z.onpaint=pe=>{const Me=pe.changedElements;for(const ee of d)Me.includes(ee.image)&&(ee.needsUpdate=!0)},Z.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,$);else{const Me=s.RGBA,ee=s.RGBA,Ie=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,Me,ee,Ie,$)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Fe.length>0){if(ze&&Ze){const Z=et(Fe[0]);t.texStorage2D(s.TEXTURE_2D,he,_e,Z.width,Z.height)}for(let Z=0,pe=Fe.length;Z0&&pe++;const ee=et(_e[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,pe,Ze,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(Le){D?Z&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,_e[ee].width,_e[ee].height,Fe,ze,_e[ee].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,Ze,_e[ee].width,_e[ee].height,0,Fe,ze,_e[ee].data);for(let Ie=0;Ie>re),fe=Math.max(1,y.height>>re);q===s.TEXTURE_3D||q===s.TEXTURE_2D_ARRAY?t.texImage3D(q,re,$,_e,fe,y.depth,0,ae,Y,null):t.texImage2D(q,re,$,_e,fe,0,ae,Y,null)}t.bindFramebuffer(s.FRAMEBUFFER,w),qe(y)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,V,q,Le.__webglTexture,0,Ge(y)):(q===s.TEXTURE_2D||q>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&q<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,V,q,Le.__webglTexture,re),t.bindFramebuffer(s.FRAMEBUFFER,null)}function at(w,y,F){if(s.bindRenderbuffer(s.RENDERBUFFER,w),y.depthBuffer){const V=y.depthTexture,q=V&&V.isDepthTexture?V.type:null,re=E(y.stencilBuffer,q),ae=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;qe(y)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ge(y),re,y.width,y.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ge(y),re,y.width,y.height):s.renderbufferStorage(s.RENDERBUFFER,re,y.width,y.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ae,s.RENDERBUFFER,w)}else{const V=y.textures;for(let q=0;q{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,V.removeEventListener("dispose",q)};V.addEventListener("dispose",q),y.__depthDisposeCallback=q}y.__boundDepthTexture=V}if(w.depthTexture&&!y.__autoAllocateDepthBuffer)if(F)for(let V=0;V<6;V++)We(y.__webglFramebuffer[V],w,V);else{const V=w.texture.mipmaps;V&&V.length>0?We(y.__webglFramebuffer[0],w,0):We(y.__webglFramebuffer,w,0)}else if(F){y.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(t.bindFramebuffer(s.FRAMEBUFFER,y.__webglFramebuffer[V]),y.__webglDepthbuffer[V]===void 0)y.__webglDepthbuffer[V]=s.createRenderbuffer(),at(y.__webglDepthbuffer[V],w,!1);else{const q=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,re=y.__webglDepthbuffer[V];s.bindRenderbuffer(s.RENDERBUFFER,re),s.framebufferRenderbuffer(s.FRAMEBUFFER,q,s.RENDERBUFFER,re)}}else{const V=w.texture.mipmaps;if(V&&V.length>0?t.bindFramebuffer(s.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=s.createRenderbuffer(),at(y.__webglDepthbuffer,w,!1);else{const q=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,re=y.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,re),s.framebufferRenderbuffer(s.FRAMEBUFFER,q,s.RENDERBUFFER,re)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function ne(w,y,F){const V=n.get(w);y!==void 0&&Oe(V.__webglFramebuffer,w,w.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&j(w)}function te(w){const y=w.texture,F=n.get(w),V=n.get(y);w.addEventListener("dispose",x);const q=w.textures,re=w.isWebGLCubeRenderTarget===!0,ae=q.length>1;if(ae||(V.__webglTexture===void 0&&(V.__webglTexture=s.createTexture()),V.__version=y.version,a.memory.textures++),re){F.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer[Y]=[];for(let $=0;$0){F.__webglFramebuffer=[];for(let Y=0;Y0&&qe(w)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Y=0;Y0)for(let $=0;$0)for(let $=0;$0){if(qe(w)===!1){const y=w.textures,F=w.width,V=w.height;let q=s.COLOR_BUFFER_BIT;const re=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ae=n.get(w),Y=y.length>1;if(Y)for(let de=0;de0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let de=0;de0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function L(w){const y=a.render.frame;h.get(w)!==y&&(h.set(w,y),w.update())}function ct(w,y){const F=w.colorSpace,V=w.format,q=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||F!==ur&&F!==Gn&&(tt.getTransfer(F)===ot?(V!==Wt||q!==Kt)&&oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Re("WebGLTextures: Unsupported texture color space:",F)),y}function et(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(c.width=w.naturalWidth||w.width,c.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(c.width=w.displayWidth,c.height=w.displayHeight):(c.width=w.width,c.height=w.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=H,this.getTextureUnits=X,this.setTextureUnits=O,this.setTexture2D=K,this.setTexture2DArray=ie,this.setTexture3D=ue,this.setTextureCube=le,this.rebindTextures=ne,this.setupRenderTarget=te,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=Oe,this.useMultisampledRTT=qe,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Wf(s,e){function t(n,i=Gn){let r;const a=tt.getTransfer(i);if(n===Kt)return s.UNSIGNED_BYTE;if(n===yo)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Mo)return s.UNSIGNED_SHORT_5_5_5_1;if(n===bc)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Tc)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Mc)return s.BYTE;if(n===Sc)return s.SHORT;if(n===ys)return s.UNSIGNED_SHORT;if(n===vo)return s.INT;if(n===un)return s.UNSIGNED_INT;if(n===Ht)return s.FLOAT;if(n===Dn)return s.HALF_FLOAT;if(n===Ac)return s.ALPHA;if(n===Ec)return s.RGB;if(n===Wt)return s.RGBA;if(n===Un)return s.DEPTH_COMPONENT;if(n===ai)return s.DEPTH_STENCIL;if(n===So)return s.RED;if(n===br)return s.RED_INTEGER;if(n===ui)return s.RG;if(n===bo)return s.RG_INTEGER;if(n===To)return s.RGBA_INTEGER;if(n===Qs||n===js||n===er||n===tr)if(a===ot)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Qs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Qs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===er)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===tr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Fa||n===Oa||n===Ba||n===za)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Fa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Oa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ba)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===za)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Va||n===ka||n===Ga||n===Ha||n===Wa||n===or||n===Xa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Va||n===ka)return a===ot?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ga)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ha)return r.COMPRESSED_R11_EAC;if(n===Wa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===or)return r.COMPRESSED_RG11_EAC;if(n===Xa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===qa||n===Ya||n===Za||n===Ja||n===$a||n===Ka||n===Qa||n===ja||n===eo||n===to||n===no||n===io||n===so||n===ro)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===qa)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ya)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Za)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ja)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===$a)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ka)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Qa)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ja)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===eo)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===to)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===no)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===io)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===so)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ro)return a===ot?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ao||n===oo||n===lo)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ao)return a===ot?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===oo)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===lo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===co||n===ho||n===lr||n===uo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===co)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ho)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===lr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===uo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ms?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const FM=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,OM=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class BM{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Nc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new dn({vertexShader:FM,fragmentShader:OM,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ct(new Cs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zM extends Mn{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",g=new BM,m={},M=t.getContextAttributes();let S=null,v=null;const E=[],T=[],R=new Q;let x=null;const A=new Lt;A.viewport=new lt;const I=new Lt;I.viewport=new lt;const P=[A,I],U=new Pf;let H=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ce=E[J];return ce===void 0&&(ce=new Aa,E[J]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(J){let ce=E[J];return ce===void 0&&(ce=new Aa,E[J]=ce),ce.getGripSpace()},this.getHand=function(J){let ce=E[J];return ce===void 0&&(ce=new Aa,E[J]=ce),ce.getHandSpace()};function O(J){const ce=T.indexOf(J.inputSource);if(ce===-1)return;const se=E[ce];se!==void 0&&(se.update(J.inputSource,J.frame,c||a),se.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",G);for(let J=0;J=0&&(T[Ue]=null,E[Ue].disconnect(se))}for(let ce=0;ce=T.length){T.push(se),Ue=Oe;break}else if(T[Oe]===null){T[Oe]=se,Ue=Oe;break}if(Ue===-1)break}const ke=E[Ue];ke&&ke.connect(se)}}const K=new C,ie=new C;function ue(J,ce,se){K.setFromMatrixPosition(ce.matrixWorld),ie.setFromMatrixPosition(se.matrixWorld);const Ue=K.distanceTo(ie),ke=ce.projectionMatrix.elements,Oe=se.projectionMatrix.elements,at=ke[14]/(ke[10]-1),We=ke[14]/(ke[10]+1),j=(ke[9]+1)/ke[5],ne=(ke[9]-1)/ke[5],te=(ke[8]-1)/ke[0],xe=(Oe[8]+1)/Oe[0],ge=at*te,Be=at*xe,Pe=Ue/(-te+xe),Ge=Pe*-te;if(ce.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ge),J.translateZ(Pe),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ke[10]===-1)J.projectionMatrix.copy(ce.projectionMatrix),J.projectionMatrixInverse.copy(ce.projectionMatrixInverse);else{const qe=at+Pe,L=We+Pe,ct=ge-Ge,et=Be+(Ue-Ge),w=j*We/L*qe,y=ne*We/L*qe;J.projectionMatrix.makePerspective(ct,et,w,y,qe,L),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function le(J,ce){ce===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ce.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;let ce=J.near,se=J.far;g.texture!==null&&(g.depthNear>0&&(ce=g.depthNear),g.depthFar>0&&(se=g.depthFar)),U.near=I.near=A.near=ce,U.far=I.far=A.far=se,(H!==U.near||X!==U.far)&&(i.updateRenderState({depthNear:U.near,depthFar:U.far}),H=U.near,X=U.far),U.layers.mask=J.layers.mask|6,A.layers.mask=U.layers.mask&-5,I.layers.mask=U.layers.mask&-3;const Ue=J.parent,ke=U.cameras;le(U,Ue);for(let Oe=0;Oe0&&(g.alphaTest.value=m.alphaTest);const M=e.get(m),S=M.envMap,v=M.envMapRotation;S&&(g.envMap.value=S,g.envMapRotation.value.setFromMatrix4(VM.makeRotationFromEuler(v)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(Xf),g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,M,S){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*M,g.scale.value=S*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function u(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,M){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Xt&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=M.texture,g.transmissionSamplerSize.value.set(M.width,M.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function _(g,m){const M=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(M.matrixWorld),g.nearDistance.value=M.shadow.camera.near,g.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function GM(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,E){const T=E.program;n.uniformBlockBinding(v,T)}function c(v,E){let T=i[v.id];T===void 0&&(g(v),T=h(v),i[v.id]=T,v.addEventListener("dispose",M));const R=E.program;n.updateUBOMapping(v,R);const x=e.render.frame;r[v.id]!==x&&(u(v),r[v.id]=x)}function h(v){const E=d();v.__bindingPointIndex=E;const T=s.createBuffer(),R=v.__size,x=v.usage;return s.bindBuffer(s.UNIFORM_BUFFER,T),s.bufferData(s.UNIFORM_BUFFER,R,x),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,E,T),T}function d(){for(let v=0;v0&&(T+=R-x),v.__size=T,v.__cache={},this}function m(v){const E={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(E.boundary=4,E.storage=4):v.isVector2?(E.boundary=8,E.storage=8):v.isVector3||v.isColor?(E.boundary=16,E.storage=12):v.isVector4?(E.boundary=16,E.storage=16):v.isMatrix3?(E.boundary=48,E.storage=48):v.isMatrix4?(E.boundary=64,E.storage=64):v.isTexture?oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(E.boundary=16,E.storage=v.byteLength):oe("WebGLRenderer: Unsupported uniform value type.",v),E}function M(v){const E=v.target;E.removeEventListener("dispose",M);const T=a.indexOf(E.__bindingPointIndex);a.splice(T,1),s.deleteBuffer(i[E.id]),delete i[E.id],delete r[E.id]}function S(){for(const v in i)s.deleteBuffer(i[v]);a=[],i={},r={}}return{bind:l,update:c,dispose:S}}const HM=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let wn=null;function WM(){return wn===null&&(wn=new hn(HM,16,16,ui,Dn),wn.name="DFG_LUT",wn.minFilter=_t,wn.magFilter=_t,wn.wrapS=jt,wn.wrapT=jt,wn.generateMipmaps=!1,wn.needsUpdate=!0),wn}class XM{constructor(e={}){const{canvas:t=Pd(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=Kt}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const _=f,g=new Set([To,bo,br]),m=new Set([Kt,un,ys,Ms,yo,Mo]),M=new Uint32Array(4),S=new Int32Array(4),v=new C;let E=null,T=null;const R=[],x=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=vn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let P=!1,U=null,H=null,X=null,O=null;this._outputColorSpace=$t;let W=0,G=0,K=null,ie=-1,ue=null;const le=new lt,be=new lt;let Qe=null;const dt=new Se(0);let nt=0,J=t.width,ce=t.height,se=1,Ue=null,ke=null;const Oe=new lt(0,0,J,ce),at=new lt(0,0,J,ce);let We=!1;const j=new Vi;let ne=!1,te=!1;const xe=new He,ge=new C,Be=new lt,Pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function qe(){return K===null?se:1}let L=n;function ct(b,N){return t.getContext(b,N)}try{const b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r185"),t.addEventListener("webglcontextlost",yt,!1),t.addEventListener("webglcontextrestored",mt,!1),t.addEventListener("webglcontextcreationerror",bn,!1),L===null){const N="webgl2";if(L=ct(N,b),L===null)throw ct(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(b){throw Re("WebGLRenderer: "+b.message),b}let et,w,y,F,V,q,re,ae,Y,$,de,Le,_e,fe,Fe,ze,Ze,D,he,Z,pe,Me,ee;function Ie(){et=new Xv(L),et.init(),pe=new Wf(L,et),w=new Ov(L,et,e,pe),y=new UM(L,et),w.reversedDepthBuffer&&u&&y.buffers.depth.setReversed(!0),H=L.createFramebuffer(),X=L.createFramebuffer(),O=L.createFramebuffer(),F=new Zv(L),V=new yM,q=new NM(L,et,y,V,w,pe,F),re=new Wv(I),ae=new Q0(L),Me=new Nv(L,ae),Y=new qv(L,ae,F,Me),$=new $v(L,Y,ae,Me,F),D=new Jv(L,w,q),Fe=new Bv(V),de=new vM(I,re,et,w,Me,Fe),Le=new kM(I,V),_e=new SM,fe=new CM(et),Ze=new Uv(I,re,y,$,p,l),ze=new DM(I,$,w),ee=new GM(L,F,w,y),he=new Fv(L,et,F),Z=new Yv(L,et,F),F.programs=de.programs,I.capabilities=w,I.extensions=et,I.properties=V,I.renderLists=_e,I.shadowMap=ze,I.state=y,I.info=F}Ie(),_!==Kt&&(A=new Qv(_,t.width,t.height,o,i,r));const we=new zM(I,L);this.xr=we,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const b=et.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){const b=et.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(b){b!==void 0&&(se=b,this.setSize(J,ce,!1))},this.getSize=function(b){return b.set(J,ce)},this.setSize=function(b,N,k=!0){if(we.isPresenting){oe("WebGLRenderer: Can't change size while VR device is presenting.");return}J=b,ce=N,t.width=Math.floor(b*se),t.height=Math.floor(N*se),k===!0&&(t.style.width=b+"px",t.style.height=N+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,b,N)},this.getDrawingBufferSize=function(b){return b.set(J*se,ce*se).floor()},this.setDrawingBufferSize=function(b,N,k){J=b,ce=N,se=k,t.width=Math.floor(b*k),t.height=Math.floor(N*k),this.setViewport(0,0,b,N)},this.setEffects=function(b){if(_===Kt){Re("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let N=0;N{function ye(){if(B.forEach(function(Ae){V.get(Ae).currentProgram.isReady()&&B.delete(Ae)}),B.size===0){z(b);return}setTimeout(ye,10)}et.get("KHR_parallel_shader_compile")!==null?ye():setTimeout(ye,10)})};let nl=null;function Zf(b){nl&&nl(b)}function ch(){_i.stop()}function hh(){_i.start()}const _i=new Bf;_i.setAnimationLoop(Zf),typeof self<"u"&&_i.setContext(self),this.setAnimationLoop=function(b){nl=b,we.setAnimationLoop(b),b===null?_i.stop():_i.start()},we.addEventListener("sessionstart",ch),we.addEventListener("sessionend",hh),this.render=function(b,N){if(N!==void 0&&N.isCamera!==!0){Re("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;U!==null&&U.renderStart(b,N);const k=we.enabled===!0&&we.isPresenting===!0,B=A!==null&&(K===null||k)&&A.begin(I,K);if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),we.enabled===!0&&we.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(we.cameraAutoUpdate===!0&&we.updateCamera(N),N=we.getCamera()),b.isScene===!0&&b.onBeforeRender(I,b,N,K),T=fe.get(b,x.length),T.init(N),T.state.textureUnits=q.getTextureUnits(),x.push(T),xe.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),j.setFromProjectionMatrix(xe,rn,N.reversedDepth),te=this.localClippingEnabled,ne=Fe.init(this.clippingPlanes,te),E=_e.get(b,R.length),E.init(),R.push(E),we.enabled===!0&&we.isPresenting===!0){const Ae=I.xr.getDepthSensingMesh();Ae!==null&&il(Ae,N,-1/0,I.sortObjects)}il(b,N,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(Ue,ke,N.reversedDepth),Ge=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,Ge&&Ze.addToRenderList(E,b),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ne===!0&&Fe.beginShadows();const z=T.state.shadowsArray;if(ze.render(z,b,N),ne===!0&&Fe.endShadows(),(B&&A.hasRenderPass())===!1){const Ae=E.opaque,ve=E.transmissive;if(T.setupLights(),N.isArrayCamera){const Ce=N.cameras;if(ve.length>0)for(let De=0,Je=Ce.length;De0&&dh(Ae,ve,b,N),Ge&&Ze.render(b),uh(E,b,N)}K!==null&&G===0&&(q.updateMultisampleRenderTarget(K),q.updateRenderTargetMipmap(K)),B&&A.end(I),b.isScene===!0&&b.onAfterRender(I,b,N),Me.resetDefaultState(),ie=-1,ue=null,x.pop(),x.length>0?(T=x[x.length-1],q.setTextureUnits(T.state.textureUnits),ne===!0&&Fe.setGlobalState(I.clippingPlanes,T.state.camera)):T=null,R.pop(),R.length>0?E=R[R.length-1]:E=null,U!==null&&U.renderEnd()};function il(b,N,k,B){if(b.visible===!1)return;if(b.layers.test(N.layers)){if(b.isGroup)k=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(N);else if(b.isLightProbeGrid)T.pushLightProbeGrid(b);else if(b.isLight)T.pushLight(b),b.castShadow&&T.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||j.intersectsSprite(b)){B&&Be.setFromMatrixPosition(b.matrixWorld).applyMatrix4(xe);const Ae=$.update(b),ve=b.material;ve.visible&&E.push(b,Ae,ve,k,Be.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(!b.frustumCulled||j.intersectsObject(b))){const Ae=$.update(b),ve=b.material;if(B&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Be.copy(b.boundingSphere.center)):(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),Be.copy(Ae.boundingSphere.center)),Be.applyMatrix4(b.matrixWorld).applyMatrix4(xe)),Array.isArray(ve)){const Ce=Ae.groups;for(let De=0,Je=Ce.length;De0&&Pr(z,N,k),ye.length>0&&Pr(ye,N,k),Ae.length>0&&Pr(Ae,N,k),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function dh(b,N,k,B){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(T.state.transmissionRenderTarget[B.id]===void 0){const Ne=et.has("EXT_color_buffer_half_float")||et.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[B.id]=new on(1,1,{generateMipmaps:!0,type:Ne?Dn:Kt,minFilter:Rn,samples:Math.max(4,w.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:tt.workingColorSpace})}const ye=T.state.transmissionRenderTarget[B.id],Ae=B.viewport||le;ye.setSize(Ae.z*I.transmissionResolutionScale,Ae.w*I.transmissionResolutionScale);const ve=I.getRenderTarget(),Ce=I.getActiveCubeFace(),De=I.getActiveMipmapLevel();I.setRenderTarget(ye),I.getClearColor(dt),nt=I.getClearAlpha(),nt<1&&I.setClearColor(16777215,.5),I.clear(),Ge&&Ze.render(k);const Je=I.toneMapping;I.toneMapping=vn;const je=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),T.setupLightsView(B),ne===!0&&Fe.setGlobalState(I.clippingPlanes,B),Pr(b,k,B),q.updateMultisampleRenderTarget(ye),q.updateRenderTargetMipmap(ye),et.has("WEBGL_multisampled_render_to_texture")===!1){let Ne=!1;for(let ht=0,bt=N.length;ht0,B.currentProgram=je,B.uniformsList=null,je}function ph(b){if(b.uniformsList===null){const N=b.currentProgram.getUniforms();b.uniformsList=Ea.seqWithValue(N.seq,b.uniforms)}return b.uniformsList}function mh(b,N){const k=V.get(b);k.outputColorSpace=N.outputColorSpace,k.batching=N.batching,k.batchingColor=N.batchingColor,k.instancing=N.instancing,k.instancingColor=N.instancingColor,k.instancingMorph=N.instancingMorph,k.skinning=N.skinning,k.morphTargets=N.morphTargets,k.morphNormals=N.morphNormals,k.morphColors=N.morphColors,k.morphTargetsCount=N.morphTargetsCount,k.numClippingPlanes=N.numClippingPlanes,k.numIntersection=N.numClipIntersection,k.vertexAlphas=N.vertexAlphas,k.vertexTangents=N.vertexTangents,k.toneMapping=N.toneMapping}function Jf(b,N){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;v.setFromMatrixPosition(N.matrixWorld);for(let k=0,B=b.length;k0),Ne=!!k.morphAttributes.position,ht=!!k.morphAttributes.normal,bt=!!k.morphAttributes.color;let Mt=vn;B.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Mt=I.toneMapping);const ft=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,Nt=ft!==void 0?ft.length:0,Te=V.get(B),tn=T.state.lights;if(ne===!0&&(te===!0||b!==ue)){const gt=b===ue&&B.id===ie;Fe.setState(B,b,gt)}let it=!1;B.version===Te.__version?(Te.needsLights&&Te.lightsStateVersion!==tn.state.version||Te.outputColorSpace!==ve||z.isBatchedMesh&&Te.batching===!1||!z.isBatchedMesh&&Te.batching===!0||z.isBatchedMesh&&Te.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&Te.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&Te.instancing===!1||!z.isInstancedMesh&&Te.instancing===!0||z.isSkinnedMesh&&Te.skinning===!1||!z.isSkinnedMesh&&Te.skinning===!0||z.isInstancedMesh&&Te.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Te.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&Te.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&Te.instancingMorph===!1&&z.morphTexture!==null||Te.envMap!==De||B.fog===!0&&Te.fog!==ye||Te.numClippingPlanes!==void 0&&(Te.numClippingPlanes!==Fe.numPlanes||Te.numIntersection!==Fe.numIntersection)||Te.vertexAlphas!==Je||Te.vertexTangents!==je||Te.morphTargets!==Ne||Te.morphNormals!==ht||Te.morphColors!==bt||Te.toneMapping!==Mt||Te.morphTargetsCount!==Nt||!!Te.lightProbeGrid!=T.state.lightProbeGridArray.length>0)&&(it=!0):(it=!0,Te.__version=B.version);let ln=Te.currentProgram;it===!0&&(ln=Lr(B,N,z),U&&B.isNodeMaterial&&U.onUpdateProgram(B,ln,Te));let An=!1,Zn=!1,qi=!1;const pt=ln.getUniforms(),Tt=Te.uniforms;if(y.useProgram(ln.program)&&(An=!0,Zn=!0,qi=!0),B.id!==ie&&(ie=B.id,Zn=!0),Te.needsLights){const gt=Jf(T.state.lightProbeGridArray,z);Te.lightProbeGrid!==gt&&(Te.lightProbeGrid=gt,Zn=!0)}if(An||ue!==b){y.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),pt.setValue(L,"projectionMatrix",b.projectionMatrix),pt.setValue(L,"viewMatrix",b.matrixWorldInverse);const $n=pt.map.cameraPosition;$n!==void 0&&$n.setValue(L,ge.setFromMatrixPosition(b.matrixWorld)),w.logarithmicDepthBuffer&&pt.setValue(L,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&pt.setValue(L,"isOrthographic",b.isOrthographicCamera===!0),ue!==b&&(ue=b,Zn=!0,qi=!0)}if(Te.needsLights&&(tn.state.directionalShadowMap.length>0&&pt.setValue(L,"directionalShadowMap",tn.state.directionalShadowMap,q),tn.state.spotShadowMap.length>0&&pt.setValue(L,"spotShadowMap",tn.state.spotShadowMap,q),tn.state.pointShadowMap.length>0&&pt.setValue(L,"pointShadowMap",tn.state.pointShadowMap,q)),z.isSkinnedMesh){pt.setOptional(L,z,"bindMatrix"),pt.setOptional(L,z,"bindMatrixInverse");const gt=z.skeleton;gt&&(gt.boneTexture===null&>.computeBoneTexture(),pt.setValue(L,"boneTexture",gt.boneTexture,q))}z.isBatchedMesh&&(pt.setOptional(L,z,"batchingTexture"),pt.setValue(L,"batchingTexture",z._matricesTexture,q),pt.setOptional(L,z,"batchingIdTexture"),pt.setValue(L,"batchingIdTexture",z._indirectTexture,q),pt.setOptional(L,z,"batchingColorTexture"),z._colorsTexture!==null&&pt.setValue(L,"batchingColorTexture",z._colorsTexture,q));const Jn=k.morphAttributes;if((Jn.position!==void 0||Jn.normal!==void 0||Jn.color!==void 0)&&D.update(z,k,ln),(Zn||Te.receiveShadow!==z.receiveShadow)&&(Te.receiveShadow=z.receiveShadow,pt.setValue(L,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(Tt.envMapIntensity.value=N.environmentIntensity),Tt.dfgLUT!==void 0&&(Tt.dfgLUT.value=WM()),Zn){if(pt.setValue(L,"toneMappingExposure",I.toneMappingExposure),Te.needsLights&&Kf(Tt,qi),ye&&B.fog===!0&&Le.refreshFogUniforms(Tt,ye),Le.refreshMaterialUniforms(Tt,B,se,ce,T.state.transmissionRenderTarget[b.id]),Te.needsLights&&Te.lightProbeGrid){const gt=Te.lightProbeGrid;Tt.probesSH.value=gt.texture,Tt.probesMin.value.copy(gt.boundingBox.min),Tt.probesMax.value.copy(gt.boundingBox.max),Tt.probesResolution.value.copy(gt.resolution)}Ea.upload(L,ph(Te),Tt,q)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ea.upload(L,ph(Te),Tt,q),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&pt.setValue(L,"center",z.center),pt.setValue(L,"modelViewMatrix",z.modelViewMatrix),pt.setValue(L,"normalMatrix",z.normalMatrix),pt.setValue(L,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const gt=B.uniformsGroups;for(let $n=0,Yi=gt.length;$n0&&q.useMultisampledRTT(b)===!1?B=V.get(b).__webglMultisampledFramebuffer:Array.isArray(De)?B=De[k]:B=De,le.copy(b.viewport),be.copy(b.scissor),Qe=b.scissorTest}else le.copy(Oe).multiplyScalar(se).floor(),be.copy(at).multiplyScalar(se).floor(),Qe=We;if(k!==0&&(B=H),y.bindFramebuffer(L.FRAMEBUFFER,B)&&y.drawBuffers(b,B),y.viewport(le),y.scissor(be),y.setScissorTest(Qe),z){const ve=V.get(b.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,ve.__webglTexture,k)}else if(ye){const ve=N;for(let Ce=0;Ce1&&L.readBuffer(L.COLOR_ATTACHMENT0+ve),!w.textureFormatReadable(Je)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!w.textureTypeReadable(je)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=b.width-B&&k>=0&&k<=b.height-z&&L.readPixels(N,k,B,z,pe.convert(Je),pe.convert(je),ye)}finally{const De=K!==null?V.get(K).__webglFramebuffer:null;y.bindFramebuffer(L.FRAMEBUFFER,De)}}},this.readRenderTargetPixelsAsync=async function(b,N,k,B,z,ye,Ae,ve=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ce=V.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ae!==void 0&&(Ce=Ce[Ae]),Ce)if(N>=0&&N<=b.width-B&&k>=0&&k<=b.height-z){y.bindFramebuffer(L.FRAMEBUFFER,Ce);const De=b.textures[ve],Je=De.format,je=De.type;if(b.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ve),!w.textureFormatReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!w.textureTypeReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ne=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ne),L.bufferData(L.PIXEL_PACK_BUFFER,ye.byteLength,L.STREAM_READ),L.readPixels(N,k,B,z,pe.convert(Je),pe.convert(je),0);const ht=K!==null?V.get(K).__webglFramebuffer:null;y.bindFramebuffer(L.FRAMEBUFFER,ht);const bt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Jp(L,bt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ne),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ye),L.deleteBuffer(Ne),L.deleteSync(bt),ye}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,N=null,k=0){const B=Math.pow(2,-k),z=Math.floor(b.image.width*B),ye=Math.floor(b.image.height*B),Ae=N!==null?N.x:0,ve=N!==null?N.y:0;q.setTexture2D(b,0),L.copyTexSubImage2D(L.TEXTURE_2D,k,0,0,Ae,ve,z,ye),y.unbindTexture()},this.copyTextureToTexture=function(b,N,k=null,B=null,z=0,ye=0){let Ae,ve,Ce,De,Je,je,Ne,ht,bt;const Mt=b.isCompressedTexture?b.mipmaps[ye]:b.image;if(k!==null)Ae=k.max.x-k.min.x,ve=k.max.y-k.min.y,Ce=k.isBox3?k.max.z-k.min.z:1,De=k.min.x,Je=k.min.y,je=k.isBox3?k.min.z:0;else{const Tt=Math.pow(2,-z);Ae=Math.floor(Mt.width*Tt),ve=Math.floor(Mt.height*Tt),b.isDataArrayTexture?Ce=Mt.depth:b.isData3DTexture?Ce=Math.floor(Mt.depth*Tt):Ce=1,De=0,Je=0,je=0}B!==null?(Ne=B.x,ht=B.y,bt=B.z):(Ne=0,ht=0,bt=0);const ft=pe.convert(N.format),Nt=pe.convert(N.type);let Te;N.isData3DTexture?(q.setTexture3D(N,0),Te=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(q.setTexture2DArray(N,0),Te=L.TEXTURE_2D_ARRAY):(q.setTexture2D(N,0),Te=L.TEXTURE_2D),y.activeTexture(L.TEXTURE0),y.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),y.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),y.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const tn=y.getParameter(L.UNPACK_ROW_LENGTH),it=y.getParameter(L.UNPACK_IMAGE_HEIGHT),ln=y.getParameter(L.UNPACK_SKIP_PIXELS),An=y.getParameter(L.UNPACK_SKIP_ROWS),Zn=y.getParameter(L.UNPACK_SKIP_IMAGES);y.pixelStorei(L.UNPACK_ROW_LENGTH,Mt.width),y.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Mt.height),y.pixelStorei(L.UNPACK_SKIP_PIXELS,De),y.pixelStorei(L.UNPACK_SKIP_ROWS,Je),y.pixelStorei(L.UNPACK_SKIP_IMAGES,je);const qi=b.isDataArrayTexture||b.isData3DTexture,pt=N.isDataArrayTexture||N.isData3DTexture;if(b.isDepthTexture){const Tt=V.get(b),Jn=V.get(N),gt=V.get(Tt.__renderTarget),$n=V.get(Jn.__renderTarget);y.bindFramebuffer(L.READ_FRAMEBUFFER,gt.__webglFramebuffer),y.bindFramebuffer(L.DRAW_FRAMEBUFFER,$n.__webglFramebuffer);for(let Yi=0;Yi + + + + + + + + + diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html new file mode 100644 index 0000000..bb15d90 --- /dev/null +++ b/internal/ui/assets/index.html @@ -0,0 +1,14 @@ + + + + + + + SourceAnt + + + + +
+ + diff --git a/internal/ui/ui.go b/internal/ui/ui.go new file mode 100644 index 0000000..a92930b --- /dev/null +++ b/internal/ui/ui.go @@ -0,0 +1,69 @@ +// Package ui serves the local graph view. +// +// The assets are embedded rather than fetched, so the view works on a laptop +// with no network and cannot drift from the binary serving it. +package ui + +import ( + "embed" + "io/fs" + "net/http" + "path" + "strings" +) + +//go:embed assets +var assets embed.FS + +// Handler serves the graph view at the root of whatever it is mounted on. +func Handler() http.Handler { + files, err := fs.Sub(assets, "assets") + if err != nil { + // Only reachable if the embed directive and this path disagree, which + // is a build-time mistake rather than anything a run can recover from. + panic(err) + } + return noStore(spa(files, http.FileServer(http.FS(files)))) +} + +// spa answers a path the page owns with the page. +// +// Routes are real paths rather than fragments after a "#", so a link somebody +// is handed can be opened, bookmarked and pasted like any other URL. The +// browser then asks this server for "/reviews/abc123", which is not a file. +// Anything that is not a file is the application, and the application works +// out what to draw from the path once it is running. +func spa(files fs.FS, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodGet && isRoute(files, r.URL.Path) { + r = r.Clone(r.Context()) + r.URL.Path = "/" + } + next.ServeHTTP(w, r) + }) +} + +// isRoute is whether a path is the application's rather than a file's. +// +// An asset that is genuinely missing keeps its 404. Answering it with the page +// would hand a script tag an HTML document, and the failure would surface +// somewhere further away than the missing file. +func isRoute(files fs.FS, name string) bool { + clean := strings.TrimPrefix(path.Clean(name), "/") + if clean == "" || clean == "." { + return false + } + if strings.HasPrefix(clean, "assets/") || path.Ext(clean) != "" { + return false + } + stat, err := fs.Stat(files, clean) + return err != nil || stat.IsDir() +} + +// noStore keeps a browser from holding on to a view the next agent replaces. +func noStore(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", "no-store") + next.ServeHTTP(w, r) + }) +} diff --git a/internal/ui/ui_test.go b/internal/ui/ui_test.go new file mode 100644 index 0000000..b6203b4 --- /dev/null +++ b/internal/ui/ui_test.go @@ -0,0 +1,92 @@ +package ui + +import ( + "net/http" + "net/http/httptest" + "regexp" + "strings" + "testing" +) + +func fetch(t *testing.T, path string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + Handler().ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, path, nil)) + return recorder +} + +// The page is built by Vite, so the names are hashed and change every build. +// What has to hold is that whatever the page asks for is embedded beside it: +// the agent serves a machine that may have no network, and a missing chunk +// there is a blank page nobody finds out about until it is opened. +func TestEverythingThePageAsksForIsEmbeddedBesideIt(t *testing.T) { + page := fetch(t, "/") + if page.Code != http.StatusOK { + t.Fatalf("got %d for the page, want 200", page.Code) + } + + referenced := regexp.MustCompile(`(?:src|href)="\.?(/?assets/[^"]+|/?favicon\.svg)"`). + FindAllStringSubmatch(page.Body.String(), -1) + if len(referenced) < 2 { + t.Fatalf("the page asks for almost nothing, which means it did not build:\n%s", page.Body.String()) + } + + for _, match := range referenced { + asset := "/" + strings.TrimPrefix(match[1], "/") + if response := fetch(t, asset); response.Code != http.StatusOK { + t.Errorf("got %d for %s, want 200", response.Code, asset) + } + } +} + +func TestTheBuildCarriesItsOwnGraphLibraries(t *testing.T) { + page := fetch(t, "/") + entry := regexp.MustCompile(`src="\.?(/?assets/index-[^"]+\.js)"`). + FindStringSubmatch(page.Body.String()) + if entry == nil { + t.Fatal("the page has no entry script") + } + + body := fetch(t, "/"+strings.TrimPrefix(entry[1], "/")).Body.String() + + // Both renderers are pulled in dynamically, so the entry names their chunks + // rather than containing them. Either way nothing is fetched from a CDN. + for _, want := range []string{"force-graph", "3d-force-graph"} { + if !strings.Contains(body, want) { + t.Errorf("the entry script never reaches %s", want) + } + } + if strings.Contains(body, "https://cdn") || strings.Contains(body, "unpkg.com") { + t.Error("the page fetches something from a CDN, which a machine with no network cannot") + } +} + +func TestABrowserIsNotToldToKeepAViewTheNextAgentReplaces(t *testing.T) { + if got := fetch(t, "/").Header().Get("Cache-Control"); got != "no-store" { + t.Errorf("got Cache-Control %q, want no-store", got) + } +} + +// A link somebody was handed by an agent is a real path, not a fragment. The +// browser asks this server for it directly, so anything that is not a file has +// to answer with the page rather than 404. +func TestAPathThePageOwnsAnswersWithThePage(t *testing.T) { + for _, path := range []string{"/reviews/abc123", "/settings", "/repositories"} { + answered := fetch(t, path) + if answered.Code != http.StatusOK { + t.Fatalf("got %d for %s, want 200", answered.Code, path) + } + if !strings.Contains(answered.Body.String(), "id=\"app\"") { + t.Fatalf("%s did not answer with the page", path) + } + } +} + +// A missing asset still 404s. Answering with the page would hand a broken +// script tag an HTML document and fail somewhere less obvious. +func TestAMissingAssetIsStillMissing(t *testing.T) { + answered := fetch(t, "/assets/nothing-here.js") + if answered.Code != http.StatusNotFound { + t.Fatalf("got %d for a missing asset, want 404", answered.Code) + } +} diff --git a/ui/index.html b/ui/index.html new file mode 100644 index 0000000..8fef4b4 --- /dev/null +++ b/ui/index.html @@ -0,0 +1,13 @@ + + + + + + + SourceAnt + + +
+ + + diff --git a/ui/package-lock.json b/ui/package-lock.json new file mode 100644 index 0000000..40000e9 --- /dev/null +++ b/ui/package-lock.json @@ -0,0 +1,3542 @@ +{ + "name": "sourceant-agent-ui", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "sourceant-agent-ui", + "version": "0.1.0", + "dependencies": { + "@dicebear/collection": "^9.2.2", + "@dicebear/core": "^9.2.2", + "@sourceant/design": "file:../../design", + "@tailwindcss/typography": "^0.5.20", + "3d-force-graph": "^1.80.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "d3-force-3d": "^3.0.6", + "force-graph": "^1.51.4", + "lucide-vue-next": "^0.563.0", + "markdown-it": "^15.0.1", + "tailwind-merge": "^3.4.0", + "three-spritetext": "^1.10.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "autoprefixer": "^10.4.24", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "vite": "^6.0.7" + } + }, + "../../design": { + "name": "@sourceant/design", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "3d-force-graph": "^1.80.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "d3-force-3d": "^3.0.6", + "force-graph": "^1.51.4", + "lucide-vue-next": "^0.563.0", + "tailwind-merge": "^3.4.0", + "three-spritetext": "^1.10.0", + "vue": "^3.5.0" + } + }, + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@dicebear/adventurer": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/adventurer/-/adventurer-9.4.2.tgz", + "integrity": "sha512-jqYp834ZmGDA9HBBDQAdgF1O2UTCwHF4vVrktXWa2Dppp1JczPL5HnVOWsjtrLmXNn61Wd6OLmBb2e6rhzp3ig==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/adventurer-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/adventurer-neutral/-/adventurer-neutral-9.4.2.tgz", + "integrity": "sha512-5xgkG/mNL4j3Q4SJGQLBU/KnU90tng8Ze5ofThD+55wi0oeY/nSAUowg6UFCmHrktjifj/MEx3CQqbpcPWtfIA==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/avataaars": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/avataaars/-/avataaars-9.4.2.tgz", + "integrity": "sha512-3x9jKFkOkFSPmpTbt9xvhiU2E1GX7beCSsX0tXRUShj8x6+5Ks9yBRT1VlkySbnXrZ/GglADGg7vJ/D2uIx1Yw==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/avataaars-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/avataaars-neutral/-/avataaars-neutral-9.4.2.tgz", + "integrity": "sha512-/eNrp0YCNJRwQXqOloLm1+3Ss2C+pMpUQIGkbEnGsP1UK+13Ge80ggDDof1HpdqvG9HAZcKa7hnbG/0HSwyDSw==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-ears": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-ears/-/big-ears-9.4.2.tgz", + "integrity": "sha512-mNfz3ppNA7UBq0IO3nXCiV5pFPG7c1DfzRB0foNU2Wo1XXT8FIcSY2BvDlYqorZTOUOz7dHb0vx06hqvG0HP5w==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-ears-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-ears-neutral/-/big-ears-neutral-9.4.2.tgz", + "integrity": "sha512-M8Ozmzza4eY4hpLOYULgJxMYmBA0CsBnrE15/xw6LZkEREXnrX5z0NJsf8hUfdyF6BWZ+RBgzoiav32DAC5zcg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-smile": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-smile/-/big-smile-9.4.2.tgz", + "integrity": "sha512-hmT5i7rcPPhStjZyg28pbIhdTnnMBzK3RObI0vKCpY30EFrzaPkkdDL6Ck5fAFBdvDIW1EpOJkenyR0XPmhgbQ==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/bottts": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/bottts/-/bottts-9.4.2.tgz", + "integrity": "sha512-tsx+dII7EFUCVA8URj66G1GqORCCVduCAx4dY2prEY2IeFianVpkntXuFsWZ9BBGx1NZFndvDith5oTwKMQPbQ==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/bottts-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/bottts-neutral/-/bottts-neutral-9.4.2.tgz", + "integrity": "sha512-kFNwWt6j+gzZ5n5Pz7WVwePubREAQOF8ZwWA9ztwVYDVMLnOChWbAofy5FED4j5md2MXFH2EgLCFCMr5K2BmIA==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/collection": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/collection/-/collection-9.4.2.tgz", + "integrity": "sha512-KArubv7if8H7j9sIfpDK2hJJqrdNVR5zMPAMOSpIU2JPyXx8TC9o5wsmXb8il5wOHgaS9Q/cla7jUNIiDD7Gsg==", + "license": "MIT", + "dependencies": { + "@dicebear/adventurer": "9.4.2", + "@dicebear/adventurer-neutral": "9.4.2", + "@dicebear/avataaars": "9.4.2", + "@dicebear/avataaars-neutral": "9.4.2", + "@dicebear/big-ears": "9.4.2", + "@dicebear/big-ears-neutral": "9.4.2", + "@dicebear/big-smile": "9.4.2", + "@dicebear/bottts": "9.4.2", + "@dicebear/bottts-neutral": "9.4.2", + "@dicebear/croodles": "9.4.2", + "@dicebear/croodles-neutral": "9.4.2", + "@dicebear/dylan": "9.4.2", + "@dicebear/fun-emoji": "9.4.2", + "@dicebear/glass": "9.4.2", + "@dicebear/icons": "9.4.2", + "@dicebear/identicon": "9.4.2", + "@dicebear/initials": "9.4.2", + "@dicebear/lorelei": "9.4.2", + "@dicebear/lorelei-neutral": "9.4.2", + "@dicebear/micah": "9.4.2", + "@dicebear/miniavs": "9.4.2", + "@dicebear/notionists": "9.4.2", + "@dicebear/notionists-neutral": "9.4.2", + "@dicebear/open-peeps": "9.4.2", + "@dicebear/personas": "9.4.2", + "@dicebear/pixel-art": "9.4.2", + "@dicebear/pixel-art-neutral": "9.4.2", + "@dicebear/rings": "9.4.2", + "@dicebear/shapes": "9.4.2", + "@dicebear/thumbs": "9.4.2", + "@dicebear/toon-head": "9.4.2" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/core": { + "version": "9.4.3", + "resolved": "https://registry.npmjs.org/@dicebear/core/-/core-9.4.3.tgz", + "integrity": "sha512-9ITrQI57k3p5hKuU8HZJ1d0kPdrmTKEJDOdlKQ8CpaChbtmnD1R+dtWmNz5IesYThXM8F64pJ0ZvJ2rsY8Hciw==", + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@dicebear/croodles": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/croodles/-/croodles-9.4.2.tgz", + "integrity": "sha512-6VoO0JviIf7dKKMBTL/SMXxWhnXHaZuzufX90G0nXxS77ELG1YkGNMaZzawizN4C09Gbya2gJkozqrWiJN/aGw==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/croodles-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/croodles-neutral/-/croodles-neutral-9.4.2.tgz", + "integrity": "sha512-oG5IeUdtiYshQ89gkAVcl5w3xAEi5UZX2fTzIyelpBPCG176l7VuuFzlxi2umnB3E6LVHYy06DXvUo/p+rXB2Q==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/dylan": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/dylan/-/dylan-9.4.2.tgz", + "integrity": "sha512-1vQvRu9x9DrwFxhFaIU2rf0EUL04yDTbAt7fHyAjM0mEsKzTD4mRNf95tCRuavCoW6W48u7A/OY6jyIub6kxLQ==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/fun-emoji": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/fun-emoji/-/fun-emoji-9.4.2.tgz", + "integrity": "sha512-kqB6LPkdYCdEU/mwbyz34xLzoNUKL6ARcoo3fr5ASq9D6ZE07qIKybC3xv5+CPz7VmspJ1Q3c/VVWVMDRP7Twg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/glass": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/glass/-/glass-9.4.2.tgz", + "integrity": "sha512-z5qUogHQ1b6UJ2zCqT848mU2U9DKbVDhiX6GPDjD7tYLisCCJVisH9p6WyNdHvflUd4SHkA6gRqVJIh2v2HnTA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/icons": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/icons/-/icons-9.4.2.tgz", + "integrity": "sha512-QSMMz0NA03ypSGhXC8HQX8FSj8lYT+/5yqH+/N03OH2IjL0q7wwGZ7nqsrtlRp76O5WqMTwGfSbTUUYPjFr+Xw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/identicon": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/identicon/-/identicon-9.4.2.tgz", + "integrity": "sha512-JVDSmZsv11mSWqwAktK5x9Bslht2xY3TFUn8xzu6slAYe1Z7hEXZ76eb+UJ6F4qEzdwZ7xPWzAS6Nb0Y3A0pww==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/initials": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/initials/-/initials-9.4.2.tgz", + "integrity": "sha512-yePuIUasmwtl9IrtB6rEzE/zb5fImKP/neW0CdcTC2MwLgMuP1GLHEGRgg1zI8exIh+PMv1YdLGyyUuRTE2Qpw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/lorelei": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/lorelei/-/lorelei-9.4.2.tgz", + "integrity": "sha512-YMv6vnriW6VLFDsreKuOnUFFno6SRe7+7X7R7zPY0rZ+MaHX9V3jcioIG+1PSjIHEDfOLUHpr5vd1JBWv8y7UA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/lorelei-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/lorelei-neutral/-/lorelei-neutral-9.4.2.tgz", + "integrity": "sha512-yspanTthA5vh6iCdeLzn6xZ4yYMYRcfcxblcgSvHTF1ut0bjAXtw5SXzZ6aJTrJWiHkzYOQuTOR6GVYiW80Q7w==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/micah": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/micah/-/micah-9.4.2.tgz", + "integrity": "sha512-e4D3W/OlChSsLo7Llwsy0J18vk0azJqF/uFoY+EKACCNHBc1HGNsqVvu2CTf+OWOA8wTyAK6UkjBN5p01r7D+g==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/miniavs": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/miniavs/-/miniavs-9.4.2.tgz", + "integrity": "sha512-wLwyFNNUnDRd3BbhSBhXR0XEpX8sG0/xDA5M/OkDoapLqZnnI48YLUSDd2N5QTAVMmcSEuZOYxkcnj7WW79vlg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/notionists": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/notionists/-/notionists-9.4.2.tgz", + "integrity": "sha512-ZCySq+nxcD/x4xyYgytcj2N9uY3gxrL+qpnmOdp2BdA221KacVrxlsUPpIgEMqxS2rMmBQXfxg129Pzn4ycIpA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/notionists-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/notionists-neutral/-/notionists-neutral-9.4.2.tgz", + "integrity": "sha512-AyD9kEfVxQUwDGf4Op059gVmYIOAkTKg3dtE9h9mEKP7zl/kMy5B67BFFOo7sB0mXCjzAegZ6ekGU02E8+hIHw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/open-peeps": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/open-peeps/-/open-peeps-9.4.2.tgz", + "integrity": "sha512-i01tLgtp2g937T81sVeAOVlqsCtiTck/Kw20g7hN80+7xrXjOUepz2HPLy3HeiMjwjMGRy5o54kSd0/8Ht4Dqg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/personas": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/personas/-/personas-9.4.2.tgz", + "integrity": "sha512-NJlkvI5F5gugt6t2+7QrYNTwQC7+4IQZS3vG0dYk2BncxOHax0BuLovdSdiAesTL4ZkytFYIydWmKmV2/xcUwg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/pixel-art": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/pixel-art/-/pixel-art-9.4.2.tgz", + "integrity": "sha512-peHf7oKICDgBZ8dUyj+txPnS7VZEWgvKE+xW4mNQqBt6dYZIjmva2shOVHn0b1JU+FDxMx3uIkWVixKdUq4WGg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/pixel-art-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/pixel-art-neutral/-/pixel-art-neutral-9.4.2.tgz", + "integrity": "sha512-9e9Lz554uQvWaXV2P17ss+hPa6rTyuAKBtB8zk8ECjHiZzIl61N/KcTVLZ4dILVZwj7gYriaLo16QEqvL2GJCg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/rings": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/rings/-/rings-9.4.2.tgz", + "integrity": "sha512-Pc3ymWrRDQPJFNrbbLt7RJrzGvUuuxUiDkrfLhoVE+B6mZWEL1PC78DPbS1yUWYLErJOpJuM2GSwXmTbVjWf+g==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/shapes": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/shapes/-/shapes-9.4.2.tgz", + "integrity": "sha512-AFL6jAaiLztvcqyq+ds+lWZu6Vbp3PlGWhJeJRm842jxtiluJpl6r4f6nUXP2fdMz7MNpDzXfLooQK9E04NbUQ==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/thumbs": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/thumbs/-/thumbs-9.4.2.tgz", + "integrity": "sha512-ccWvDBqbkWS5uzHbsg5L6uML6vBfX7jT3J3jHCQksvz8haHItxTK02w+6e1UavZUsvza4lG5X/XY3eji3siJ4Q==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/toon-head": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/toon-head/-/toon-head-9.4.2.tgz", + "integrity": "sha512-lwFeSXyAnaKnCfMt9TiJwnD1cXQUGkey/0h6i/+4TVHVMCz5/Ri5u1ynovPNHy1SnBf858QwoXHkxilGLwQX/g==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.1.tgz", + "integrity": "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.1.tgz", + "integrity": "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.1.tgz", + "integrity": "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.1.tgz", + "integrity": "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.1.tgz", + "integrity": "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.1.tgz", + "integrity": "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.1.tgz", + "integrity": "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.1.tgz", + "integrity": "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.1.tgz", + "integrity": "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.1.tgz", + "integrity": "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.1.tgz", + "integrity": "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.1.tgz", + "integrity": "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.1.tgz", + "integrity": "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.1.tgz", + "integrity": "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.1.tgz", + "integrity": "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.1.tgz", + "integrity": "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.1.tgz", + "integrity": "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.1.tgz", + "integrity": "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.1.tgz", + "integrity": "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.1.tgz", + "integrity": "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.1.tgz", + "integrity": "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.1.tgz", + "integrity": "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.1.tgz", + "integrity": "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.1.tgz", + "integrity": "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.1.tgz", + "integrity": "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@sourceant/design": { + "resolved": "../../design", + "link": true + }, + "node_modules/@tailwindcss/typography": { + "version": "0.5.20", + "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.20.tgz", + "integrity": "sha512-hwbzQuNUfcPvbegQFatVPl/MY/tcM9KLl963hQ5laJKPh81TEZ1+dNG9PirGvcaDBkp+BCshExAyKVPW91dozw==", + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "6.0.10" + }, + "peerDependencies": { + "tailwindcss": ">=3.0.0 || >=4.0.0 || insiders" + } + }, + "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@tweenjs/tween.js": { + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-25.0.0.tgz", + "integrity": "sha512-XKLA6syeBUaPzx4j3qwMqzzq+V4uo72BnlbOjmuljLrRqdsd3qnzvZZoxvMHZ23ndsRS4aufU6JOZYpCbU6T1A==", + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "license": "MIT" + }, + "node_modules/@vitejs/plugin-vue": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz", + "integrity": "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "vite": "^5.0.0 || ^6.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.42.tgz", + "integrity": "sha512-2Ye1ilMtKXxl8qZUrQ5j0CdgenFp/HFQmta6rfRyfEsTG69L6Wk+tWuNoHYHMx9E8tF2Slvdg1FuwDvAXdy1LQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/shared": "3.5.42", + "entities": "^7.0.1", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.42.tgz", + "integrity": "sha512-qbhQZEFmycr+ni/qyuccS4sucNN7VAbDfbkvNxWOX2VfgFm90MNs3/UhRNKoPMEIVn0F8gdlYjLPvqxHwHeQOA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.42.tgz", + "integrity": "sha512-fkCAFB4okcAANGMThboWnScp/gzWjU0ZSkVnjTIiplmMDq2uq0tIB3j+xVu4rhv5rvOgBySCysudmbMd6xRRqw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/compiler-core": "3.5.42", + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-ssr": "3.5.42", + "@vue/shared": "3.5.42", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.19", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.42.tgz", + "integrity": "sha512-xmLk3wLkbizPAiLyomjgFFosf2ys9b5Ghb+oh/k2tnvipNz8OFrQOiTcWCzyK7MpBp9KkyGtfvgfLUivbmuGYA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, + "node_modules/@vue/reactivity": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.42.tgz", + "integrity": "sha512-TzNNfKpb7hDxbQltwAut8VDQA5YP+BuRlxntHUuRjyKwlMvmAPbs3unhCvieijifY6vFfVBwsS7wG/C7uq+bEQ==", + "license": "MIT", + "dependencies": { + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.42.tgz", + "integrity": "sha512-9uACtuHs7vJGkm5Bp3xu4xRDLFTIYy5DgxpToVjqGIAhAEKwQfsaLvKINhM6nFVp6bZPRFGdDqd1g52MqKsotA==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.42.tgz", + "integrity": "sha512-rsCmhiWLaRxGltLwhlCWyYkFn7WAbKRh0q17eZ1A6Dq6eqc2ACQ61IIryxz0LrsvCzHSilLA9JHovVwM8CNE2g==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/runtime-core": "3.5.42", + "@vue/shared": "3.5.42", + "csstype": "^3.2.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.42.tgz", + "integrity": "sha512-2++5dUyYS4gvo7xQXSECUDhB7TS0aOl5SeVfC5qSq1Jgfhjvegw1zqhwTIR3imZ+QYPJQw9gfcFvXGAjGZ7ajQ==", + "license": "MIT", + "dependencies": { + "@vue/compiler-ssr": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.42.tgz", + "integrity": "sha512-2rPxex1jQf4jvl9MOHl6YaXCPcrNqz/FstMOEh3QWY+/OME9nQTvl9WYeCwhW7AFjaR0SnngZGlp/wkR6rkI6g==", + "license": "MIT" + }, + "node_modules/3d-force-graph": { + "version": "1.80.0", + "resolved": "https://registry.npmjs.org/3d-force-graph/-/3d-force-graph-1.80.0.tgz", + "integrity": "sha512-tzI353gW1nXPpnC7VTa3JjMg+3cp77qOLUFO0vucPTfF+q5R6sQsNsIqVTbRIb7RSypn14nBa4yfkOe9ThxASw==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1", + "kapsule": "^1.16", + "three": ">=0.179 <1", + "three-forcegraph": "1", + "three-render-objects": "^1.41" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/accessor-fn": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/accessor-fn/-/accessor-fn-1.5.3.tgz", + "integrity": "sha512-rkAofCwe/FvYFUlMB0v0gWmhqtfAtV1IUkdPbfhTUyYniu5LrC0A0UJkTH0Jv3S8SvwkmfuAlY+mQIJATdocMA==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "license": "MIT" + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "license": "MIT" + }, + "node_modules/argparse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.1.tgz", + "integrity": "sha512-nM4mHF/KM1v59ZNKX7zfusQz5wUAxR511YG8Vo6TyiV4aqhu++rbJW4v04xsWhpSsHFj66flT8P7znVpyO20xQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "PSF-2.0" + }, + "node_modules/autoprefixer": { + "version": "10.5.4", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.4.tgz", + "integrity": "sha512-MaU0U/za7N3r6brxD4YB/l4NSrFzLPlANv6wEuQVaIPlD3L4W9rFcQPbL/EilY9BHhHvhfcz3gInDLrEtWT4EA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "browserslist": "^4.28.6", + "caniuse-lite": "^1.0.30001806", + "fraction.js": "^5.3.4", + "picocolors": "^1.1.1", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.20", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz", + "integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bezier-js": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/bezier-js/-/bezier-js-6.1.4.tgz", + "integrity": "sha512-PA0FW9ZpcHbojUCMu28z9Vg/fNkwTj5YhusSAjHHDfHDGLxJ6YUKrAN2vk1fP2MMOxVw4Oko16FMlRGVBGqLKg==", + "license": "MIT", + "funding": { + "type": "individual", + "url": "https://github.com/Pomax/bezierjs/blob/master/FUNDING.md" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.28.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", + "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.12", + "caniuse-lite": "^1.0.30001809", + "electron-to-chromium": "^1.5.402", + "node-releases": "^2.0.53", + "update-browserslist-db": "^1.3.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/canvas-color-tracker": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/canvas-color-tracker/-/canvas-color-tracker-1.3.2.tgz", + "integrity": "sha512-ryQkDX26yJ3CXzb3hxUVNlg1NKE4REc5crLBq661Nxzr8TNd236SaEf2ffYLXyI5tSABSeguHLqcVq4vf9L3Zg==", + "license": "MIT", + "dependencies": { + "tinycolor2": "^1.6.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/class-variance-authority": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", + "integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==", + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1" + }, + "funding": { + "url": "https://polar.sh/cva" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT" + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-binarytree": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/d3-binarytree/-/d3-binarytree-1.0.2.tgz", + "integrity": "sha512-cElUNH+sHu95L04m92pG73t2MEJXKu+GeKUN1TJkFsu93E5W8E9Sc3kHEGJKgenGvj19m6upSn2EunvMgMD2Yw==", + "license": "MIT" + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force-3d": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/d3-force-3d/-/d3-force-3d-3.0.6.tgz", + "integrity": "sha512-4tsKHUPLOVkyfEffZo1v6sFHvGFwAIIjt/W8IThbp08DYAsXZck+2pSHEG5W1+gQgEvFLdZkYvmJAbRM2EzMnA==", + "license": "MIT", + "dependencies": { + "d3-binarytree": "1", + "d3-dispatch": "1 - 3", + "d3-octree": "1", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-octree": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/d3-octree/-/d3-octree-1.1.0.tgz", + "integrity": "sha512-F8gPlqpP+HwRPMO/8uOu5wjH110+6q4cgJvgJT6vlpy3BEaDIKlTZrgHKZSp/i1InRpVfh4puY/kvL6MxK930A==", + "license": "MIT" + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/data-bind-mapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/data-bind-mapper/-/data-bind-mapper-1.0.3.tgz", + "integrity": "sha512-QmU3lyEnbENQPo0M1F9BMu4s6cqNNp8iJA+b/HP2sSb7pf3dxwF3+EP1eO69rwBfH9kFJ1apmzrtogAmVt2/Xw==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "license": "Apache-2.0" + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.416", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.416.tgz", + "integrity": "sha512-K6bvB2BjnNrugtIih6ewlbBI9DXa976jIdiIlRLHhBoEI9a4JaQjjHyF+A1IQI543aQYR4LnmOrT/K5fZj0aPA==", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fastq": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.2.tgz", + "integrity": "sha512-UpGiiODyCGprM8EPP6JodP6jC9Rws6TCuiDOD+nn0CJhR8guI3g/ozo4ugL0vJ+Yz1UtJuuRPqvQuybVOF1VQA==", + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/float-tooltip": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/float-tooltip/-/float-tooltip-1.7.5.tgz", + "integrity": "sha512-/kXzuDnnBqyyWyhDMH7+PfP8J/oXiAavGzcRxASOMRHFuReDtofizLLJsf7nnDLAfEaMW4pVWaXrAjtnglpEkg==", + "license": "MIT", + "dependencies": { + "d3-selection": "2 - 3", + "kapsule": "^1.16", + "preact": "10" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/force-graph": { + "version": "1.51.4", + "resolved": "https://registry.npmjs.org/force-graph/-/force-graph-1.51.4.tgz", + "integrity": "sha512-TdJ2KbkoiDQ7NIRx8IPGD0mAXXpLhamS7c+b7W98b0MHG7lphnda1VOQX/98UDTsttIAdH4TcP0l0MauSnLK8w==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "bezier-js": "3 - 6", + "canvas-color-tracker": "^1.3", + "d3-array": "1 - 3", + "d3-drag": "2 - 3", + "d3-force-3d": "2 - 3", + "d3-scale": "1 - 4", + "d3-scale-chromatic": "1 - 3", + "d3-selection": "2 - 3", + "d3-zoom": "2 - 3", + "float-tooltip": "^1.7", + "index-array-by": "1", + "kapsule": "^1.16", + "lodash-es": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fraction.js": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-5.3.4.tgz", + "integrity": "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/index-array-by": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/index-array-by/-/index-array-by-1.4.2.tgz", + "integrity": "sha512-SP23P27OUKzXWEC/TOyWlwLviofQkCSCKONnc62eItjp69yCZZPqDQtr3Pw5gJDnPeUMqExmKydNZaJO0FU9pw==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", + "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==", + "license": "MIT", + "dependencies": { + "hasown": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/jiti": { + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", + "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", + "license": "MIT", + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/kapsule": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/kapsule/-/kapsule-1.16.3.tgz", + "integrity": "sha512-4+5mNNf4vZDSwPhKprKwz3330iisPrb08JyMgbsdFrimBCKNHecua/WBwvVg3n7vwx0C1ARjfhwIpbrbd9n5wg==", + "license": "MIT", + "dependencies": { + "lodash-es": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/lilconfig": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", + "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==", + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "license": "MIT" + }, + "node_modules/linkify-it": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-6.1.0.tgz", + "integrity": "sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^3.0.0" + } + }, + "node_modules/lodash-es": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", + "license": "MIT" + }, + "node_modules/lucide-vue-next": { + "version": "0.563.0", + "resolved": "https://registry.npmjs.org/lucide-vue-next/-/lucide-vue-next-0.563.0.tgz", + "integrity": "sha512-zsE/lCKtmaa7bGfhSpN84br1K9YoQ5pCN+2oKWjQQG3Lo6ufUUKBuHSjNFI6RvUevxaajNXb8XwFUKeTXG3sIA==", + "deprecated": "Package deprecated. Please use @lucide/vue instead.", + "license": "ISC", + "peerDependencies": { + "vue": ">=3.0.1" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/markdown-it": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.1.tgz", + "integrity": "sha512-9/7gE95FNPkfUWrjJIoHZza2iLmuJlPD0UNMxPi7bxUrbCR525YZY0r+zyfes0dZI5ZZ/uNIXUJca0pJvtw41g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^3.0.0", + "entities": "^8.0.0", + "linkify-it": "^6.0.0", + "mdurl": "^2.1.0", + "punycode.js": "^2.3.1", + "uc.micro": "^3.0.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/entities": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz", + "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/mdurl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", + "license": "MIT" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/ngraph.events": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ngraph.events/-/ngraph.events-1.4.0.tgz", + "integrity": "sha512-NeDGI4DSyjBNBRtA86222JoYietsmCXbs8CEB0dZ51Xeh4lhVl1y3wpWLumczvnha8sFQIW4E0vvVWwgmX2mGw==", + "license": "BSD-3-Clause" + }, + "node_modules/ngraph.forcelayout": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ngraph.forcelayout/-/ngraph.forcelayout-3.3.1.tgz", + "integrity": "sha512-MKBuEh1wujyQHFTW57y5vd/uuEOK0XfXYxm3lC7kktjJLRdt/KEKEknyOlc6tjXflqBKEuYBBcu7Ax5VY+S6aw==", + "license": "BSD-3-Clause", + "dependencies": { + "ngraph.events": "^1.0.0", + "ngraph.merge": "^1.0.0", + "ngraph.random": "^1.0.0" + } + }, + "node_modules/ngraph.graph": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/ngraph.graph/-/ngraph.graph-20.1.2.tgz", + "integrity": "sha512-W/G3GBR3Y5UxMLHTUCPP9v+pbtpzwuAEIqP5oZV+9IwgxAIEZwh+Foc60iPc1idlnK7Zxu0p3puxAyNmDvBd0Q==", + "license": "BSD-3-Clause", + "dependencies": { + "ngraph.events": "^1.4.0" + } + }, + "node_modules/ngraph.merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ngraph.merge/-/ngraph.merge-1.0.0.tgz", + "integrity": "sha512-5J8YjGITUJeapsomtTALYsw7rFveYkM+lBj3QiYZ79EymQcuri65Nw3knQtFxQBU1r5iOaVRXrSwMENUPK62Vg==", + "license": "MIT" + }, + "node_modules/ngraph.random": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ngraph.random/-/ngraph.random-1.2.0.tgz", + "integrity": "sha512-4EUeAGbB2HWX9njd6bP6tciN6ByJfoaAvmVL9QTaZSeXrW46eNGA9GajiXiPBbvFqxUWFkEbyo6x5qsACUuVfA==", + "license": "BSD-3-Clause" + }, + "node_modules/node-releases": { + "version": "2.0.54", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", + "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/polished": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/polished/-/polished-4.3.1.tgz", + "integrity": "sha512-OBatVyC/N7SCW/FaDHrSd+vn0o5cS855TOmYi4OkdWUMSJCET/xip//ch8xGUvtr3i44X9LVyWwQlRMTN3pwSA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/postcss": { + "version": "8.5.26", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", + "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.17", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", + "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.1.0.tgz", + "integrity": "sha512-oIAOTqgIo7q2EOwbhb8UalYePMvYoIeRY2YKntdpFQXNosSu3vLrniGgmH9OKs/qAkfoj5oB3le/7mINW1LCfw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "peerDependencies": { + "postcss": "^8.4.21" + } + }, + "node_modules/postcss-load-config": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz", + "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "jiti": ">=1.21.0", + "postcss": ">=8.0.9", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + }, + "postcss": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/postcss-nested": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", + "integrity": "sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^6.1.1" + }, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.4.tgz", + "integrity": "sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==", + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "license": "MIT" + }, + "node_modules/preact": { + "version": "10.29.8", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.8.tgz", + "integrity": "sha512-ej2aVZ+vZ8WO7tvlQWRM9N63A0KzF9q4mWJfDUHgYaIofWY9hu74QdnQrjoPMmZi2/nZ5gN0bJCQF49xQqx09Q==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + }, + "peerDependencies": { + "preact-render-to-string": ">=5" + }, + "peerDependenciesMeta": { + "preact-render-to-string": { + "optional": true + } + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/read-cache": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.2.tgz", + "integrity": "sha512-/peqiBB/n07gQGLsWaHho3WfvUyRscw0gYTsEFMhrIe/nWLkYaf5SbKYjGYqtRV3aPwykJgF2VEMo1ac4bnsGA==", + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.12", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", + "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.1.tgz", + "integrity": "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.1", + "@rollup/rollup-android-arm64": "4.63.1", + "@rollup/rollup-darwin-arm64": "4.63.1", + "@rollup/rollup-darwin-x64": "4.63.1", + "@rollup/rollup-freebsd-arm64": "4.63.1", + "@rollup/rollup-freebsd-x64": "4.63.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", + "@rollup/rollup-linux-arm-musleabihf": "4.63.1", + "@rollup/rollup-linux-arm64-gnu": "4.63.1", + "@rollup/rollup-linux-arm64-musl": "4.63.1", + "@rollup/rollup-linux-loong64-gnu": "4.63.1", + "@rollup/rollup-linux-loong64-musl": "4.63.1", + "@rollup/rollup-linux-ppc64-gnu": "4.63.1", + "@rollup/rollup-linux-ppc64-musl": "4.63.1", + "@rollup/rollup-linux-riscv64-gnu": "4.63.1", + "@rollup/rollup-linux-riscv64-musl": "4.63.1", + "@rollup/rollup-linux-s390x-gnu": "4.63.1", + "@rollup/rollup-linux-x64-gnu": "4.63.1", + "@rollup/rollup-linux-x64-musl": "4.63.1", + "@rollup/rollup-openbsd-x64": "4.63.1", + "@rollup/rollup-openharmony-arm64": "4.63.1", + "@rollup/rollup-win32-arm64-msvc": "4.63.1", + "@rollup/rollup-win32-ia32-msvc": "4.63.1", + "@rollup/rollup-win32-x64-gnu": "4.63.1", + "@rollup/rollup-win32-x64-msvc": "4.63.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sucrase": { + "version": "3.35.1", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz", + "integrity": "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "tinyglobby": "^0.2.11", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tailwind-merge": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.6.0.tgz", + "integrity": "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "3.4.19", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz", + "integrity": "sha512-3ofp+LL8E+pK/JuPLPggVAIaEuhvIz4qNcf3nA1Xn2o/7fb7s/TYpHhwGDv1ZU3PkBluUVaF8PyCHcm48cKLWQ==", + "license": "MIT", + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "arg": "^5.0.2", + "chokidar": "^3.6.0", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.3.2", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "jiti": "^1.21.7", + "lilconfig": "^3.1.3", + "micromatch": "^4.0.8", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.1.1", + "postcss": "^8.4.47", + "postcss-import": "^15.1.0", + "postcss-js": "^4.0.1", + "postcss-load-config": "^4.0.2 || ^5.0 || ^6.0", + "postcss-nested": "^6.2.0", + "postcss-selector-parser": "^6.1.2", + "resolve": "^1.22.8", + "sucrase": "^3.35.0" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/three": { + "version": "0.185.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.185.1.tgz", + "integrity": "sha512-5aojFCXKwnjBRZvUnt3WFfEcvUJgkN5LlijRFN95hMy8WVkG4I0QNcJE+OuWvuJ0bOdStrbfXn0pkd6/QyiAlg==", + "license": "MIT" + }, + "node_modules/three-forcegraph": { + "version": "1.43.4", + "resolved": "https://registry.npmjs.org/three-forcegraph/-/three-forcegraph-1.43.4.tgz", + "integrity": "sha512-FtmiZP/T16ZQaHza3JDaDn0YTXFtg9e7pGnTeU8nzu0NNkx7MpWbF/GvmpbQsWHx3rukHtkRv1fTorLPB3FDEA==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1", + "d3-array": "1 - 3", + "d3-force-3d": "2 - 3", + "d3-scale": "1 - 4", + "d3-scale-chromatic": "1 - 3", + "data-bind-mapper": "1", + "kapsule": "^1.16", + "ngraph.forcelayout": "3", + "ngraph.graph": "20", + "tinycolor2": "1" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.118.3" + } + }, + "node_modules/three-render-objects": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/three-render-objects/-/three-render-objects-1.42.0.tgz", + "integrity": "sha512-KYfkPrYGEbIK8ChFocWqOF1aAN80FBUBWVYB8mB2oBpVuVN+52FvvngVYB5ieFANQu7Rt21rPYZ/xKaAgVWWRQ==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "float-tooltip": "^1.7", + "kapsule": "^1.16", + "polished": "4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.179" + } + }, + "node_modules/three-spritetext": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/three-spritetext/-/three-spritetext-1.10.0.tgz", + "integrity": "sha512-t08iP1FCU1lQh8T5MmCpdijKgas8GDHJE0LqMGBuVu3xqMMpFnEZhTlih7FlxLPQizHIGoumUSpfOlY1GO/Tgg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.86.0" + } + }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "license": "Apache-2.0" + }, + "node_modules/uc.micro": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-3.0.0.tgz", + "integrity": "sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==", + "license": "MIT" + }, + "node_modules/update-browserslist-db": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", + "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/vite": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.3.tgz", + "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vue": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.42.tgz", + "integrity": "sha512-4RyHQTbQvOPs3MfvUO1Sg0YRrKNnA0mAVtvpd12Tg1fKDN7OHBUl1IqSn8zGJjK9nI3NkNp8cgTpVrSZC5TTcA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-sfc": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/server-renderer": "3.5.42", + "@vue/shared": "3.5.42" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-router": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz", + "integrity": "sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + } + } +} diff --git a/ui/package.json b/ui/package.json new file mode 100644 index 0000000..28a8543 --- /dev/null +++ b/ui/package.json @@ -0,0 +1,38 @@ +{ + "name": "sourceant-agent-ui", + "version": "0.1.0", + "private": true, + "description": "The local SourceAnt view, served by the agent", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "eslint .", + "test": "vitest run" + }, + "dependencies": { + "@dicebear/collection": "^9.2.2", + "@dicebear/core": "^9.2.2", + "@sourceant/design": "file:../../design", + "@tailwindcss/typography": "^0.5.20", + "3d-force-graph": "^1.80.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "d3-force-3d": "^3.0.6", + "force-graph": "^1.51.4", + "lucide-vue-next": "^0.563.0", + "markdown-it": "^15.0.1", + "tailwind-merge": "^3.4.0", + "three-spritetext": "^1.10.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "autoprefixer": "^10.4.24", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "vite": "^6.0.7" + } +} diff --git a/ui/postcss.config.js b/ui/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/ui/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/ui/public/favicon.svg b/ui/public/favicon.svg new file mode 100644 index 0000000..c08eff2 --- /dev/null +++ b/ui/public/favicon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ui/src/App.vue b/ui/src/App.vue new file mode 100644 index 0000000..e86be45 --- /dev/null +++ b/ui/src/App.vue @@ -0,0 +1,175 @@ + + + diff --git a/ui/src/api.js b/ui/src/api.js new file mode 100644 index 0000000..7830fc8 --- /dev/null +++ b/ui/src/api.js @@ -0,0 +1,93 @@ +/* Everything comes from the agent. It is the process that is always up and the + * one that knows where the indexer is listening. */ + +async function call(path, options = {}) { + const response = await fetch(path, { + ...options, + headers: options.body ? { 'Content-Type': 'application/json' } : undefined, + }) + const text = await response.text() + const body = text ? JSON.parse(text) : null + if (!response.ok) throw new Error(body?.error || `the agent answered ${response.status}`) + return body +} + +const query = (values) => + new URLSearchParams(Object.entries(values).filter(([, value]) => value !== '' && value !== false)) + +export const api = { + status: () => call('/health'), + + repositories: () => call('/api/repositories'), + addRepository: (path, name) => + call('/api/repositories', { method: 'POST', body: JSON.stringify({ path, name }) }), + dropRepository: (path) => + call(`/api/repositories?${query({ path })}`, { method: 'DELETE' }), + /* Update reads only what changed, which is what a watcher wants. Somebody + * pressing a button for this means read it again: how a file is read changes + * with the indexer, and an update pass sees an unchanged file and skips it. */ + index: (repository = '', { everything = false, update = false } = {}) => + call('/api/index', { + method: 'POST', + body: JSON.stringify({ repository, everything, update }), + }), + + /* Where recent change has landed on what the rest of the code leans on. + * Either fact alone says little; it is the overlap that is worth a person's + * time, and is also the shortest list of files worth reading first. */ + attention: (repository) => call(`/api/attention?${query({ repository })}`), + + graph: (repository, { includeTests = false, pathPrefix = '' } = {}) => + call(`/api/graph?${query({ repository, include_tests: includeTests, path_prefix: pathPrefix })}`), + + knowledge: (repository) => call(`/api/knowledge?${query({ repository, limit: 100 })}`), + recordKnowledge: (item) => + call('/api/knowledge', { method: 'PUT', body: JSON.stringify(item) }), + forgetKnowledge: (repository, id) => + call(`/api/knowledge?${query({ repository, id })}`, { method: 'DELETE' }), + + browse: (path = '') => call(`/api/browse?${query({ path })}`), + + /* Reading what a repository already states. Asking without recording is the + * safe half, so a person can see what would be written before it is. */ + initialize: (repository, { dryRun = false, useModel = false } = {}) => + call('/api/knowledge/initialize', { + method: 'POST', + body: JSON.stringify({ repository, dry_run: dryRun, use_model: useModel }), + }), + + /* The rules a team already wrote down for whatever reads their code, from + * this machine's agent folders and from the repository's own. */ + skills: (repository = '') => call(`/api/skills?${query({ repository })}`), + skill: (id, repository = '') => call(`/api/skills/${id}?${query({ repository })}`), + /* Written where this product owns the folder: a repository, so the team gets + * it by pulling, or the machine, for what somebody wants everywhere. What + * sits in a coding agent's own folders is read and never written. */ + recordSkill: (skill) => + call('/api/skills', { + method: 'PUT', + body: JSON.stringify({ scope: 'repository', paths: [], reviews: null, ...skill }), + }), + forgetSkill: (repository, scope, id) => + call(`/api/skills?${query({ repository, scope, id })}`, { method: 'DELETE' }), + + /* Reading a checkout's own work before anybody else has been asked to. Asking + * without a model is the free half: what changed and what bears on it, with + * nothing judged. + * + * The agent runs it and holds the answer, because a review takes tens of + * seconds and a connection held open that long loses work when anything + * interrupts it. */ + startReview: (repository, { against = '', title = '', description = '', skills = [], useModel = true } = {}) => + call('/api/reviews', { + method: 'POST', + body: JSON.stringify({ repository, against, title, description, skills, use_model: useModel }), + }), + reviewed: (id) => call(`/api/reviews/${id}`), + reviews: (repository = '') => call(`/api/reviews?${query({ repository })}`), + + settings: () => call('/api/settings'), + setSetting: (key, value) => + call('/api/settings', { method: 'PUT', body: JSON.stringify({ key, value }) }), + resetSetting: (key) => call(`/api/settings?${query({ key })}`, { method: 'DELETE' }), +} diff --git a/ui/src/components/EmptyMachine.vue b/ui/src/components/EmptyMachine.vue new file mode 100644 index 0000000..fda9bb2 --- /dev/null +++ b/ui/src/components/EmptyMachine.vue @@ -0,0 +1,18 @@ + + + diff --git a/ui/src/components/FolderPicker.vue b/ui/src/components/FolderPicker.vue new file mode 100644 index 0000000..75ce448 --- /dev/null +++ b/ui/src/components/FolderPicker.vue @@ -0,0 +1,109 @@ + + + diff --git a/ui/src/components/GraphWorkbench.vue b/ui/src/components/GraphWorkbench.vue new file mode 100644 index 0000000..bddc088 --- /dev/null +++ b/ui/src/components/GraphWorkbench.vue @@ -0,0 +1,368 @@ + + + diff --git a/ui/src/components/McpPanel.vue b/ui/src/components/McpPanel.vue new file mode 100644 index 0000000..f099b61 --- /dev/null +++ b/ui/src/components/McpPanel.vue @@ -0,0 +1,108 @@ + + + diff --git a/ui/src/components/Onboarding.vue b/ui/src/components/Onboarding.vue new file mode 100644 index 0000000..b28fa18 --- /dev/null +++ b/ui/src/components/Onboarding.vue @@ -0,0 +1,83 @@ + + + diff --git a/ui/src/components/SettingsPanel.vue b/ui/src/components/SettingsPanel.vue new file mode 100644 index 0000000..f0ce3af --- /dev/null +++ b/ui/src/components/SettingsPanel.vue @@ -0,0 +1,207 @@ + + + diff --git a/ui/src/composables/useCodeGraph.js b/ui/src/composables/useCodeGraph.js new file mode 100644 index 0000000..0374985 --- /dev/null +++ b/ui/src/composables/useCodeGraph.js @@ -0,0 +1,50 @@ +import { ref } from 'vue' +import { api } from '~/api' + +/** The code itself: what is defined, and what calls what. */ +export function useCodeGraph() { + const graph = ref(null) + const loading = ref(false) + const problem = ref(null) + + async function fetchCodeGraph(owner, repo, ask = {}) { + loading.value = true + try { + graph.value = await api.graph(`${owner}/${repo}`, ask) + problem.value = null + } catch (caught) { + graph.value = null + problem.value = caught + } finally { + loading.value = false + } + } + + return { + graph, + loading, + fetchCodeGraph, + failureFor: () => problem.value, + } +} + +/** Knowledge as a graph, which a machine does not answer yet. + * + * Locally knowledge is a list: nothing serves the relationships between one + * record and another, so there is no graph to draw. Saying so is better than + * drawing an empty one and letting a reader conclude they have recorded + * nothing. + */ +export function useRepos() { + const graph = ref(null) + + async function fetchGraph() { + graph.value = { nodes: [], links: [] } + return graph.value + } + + return { + fetchGraph, + failureFor: () => null, + } +} diff --git a/ui/src/composables/useRepositories.js b/ui/src/composables/useRepositories.js new file mode 100644 index 0000000..812ffd9 --- /dev/null +++ b/ui/src/composables/useRepositories.js @@ -0,0 +1,38 @@ +import { computed, ref } from 'vue' +import { api } from '~/api' + +/* One list of repositories for the whole app, and one choice of which is being + * looked at, so moving between pages does not lose it. */ +const repositories = ref([]) +const chosen = ref('') +const error = ref('') +const loading = ref(false) + +// Every repository at once. Empty, because that is what the API already means +// by "not narrowed to one", so nothing below has to translate it. +export const EVERY = '' + +export function useRepositories({ all = false } = {}) { + // Whether the view is showing more than one repository's worth, which is + // what decides if a card has to say which one it came from. + const mixed = computed(() => all && !chosen.value && repositories.value.length > 1) + + async function fetchRepositories() { + loading.value = true + try { + repositories.value = await api.repositories() + error.value = '' + } catch (problem) { + repositories.value = [] + error.value = `${problem.message}. Is sourceant-agent running?` + } finally { + loading.value = false + } + if (chosen.value === EVERY && all) return + if (!repositories.value.some((item) => item.name === chosen.value)) { + chosen.value = repositories.value[0]?.name ?? '' + } + } + + return { repositories, chosen, error, loading, mixed, fetchRepositories } +} diff --git a/ui/src/composables/useTheme.js b/ui/src/composables/useTheme.js new file mode 100644 index 0000000..9a3faf7 --- /dev/null +++ b/ui/src/composables/useTheme.js @@ -0,0 +1,30 @@ +import { ref } from 'vue' + +const isDark = ref(true) + +function apply(dark) { + isDark.value = dark + document.documentElement.classList.toggle('dark', dark) + document.documentElement.classList.toggle('light', !dark) + try { + localStorage.setItem('sourceant-theme', dark ? 'dark' : 'light') + } catch { + // A browser that refuses storage still gets the theme, just not the memory. + } +} + +export function useTheme() { + return { + isDark, + toggleTheme: () => apply(!isDark.value), + restoreTheme: () => { + let stored = null + try { + stored = localStorage.getItem('sourceant-theme') + } catch { + stored = null + } + apply(stored !== 'light') + }, + } +} diff --git a/ui/src/composables/useUp.js b/ui/src/composables/useUp.js new file mode 100644 index 0000000..d675ca7 --- /dev/null +++ b/ui/src/composables/useUp.js @@ -0,0 +1,15 @@ +import { useRouter } from 'vue-router' + +/** Going up to the listing a detail page belongs to. + * + * Up, not back. This control carries a label saying where it goes, so it has + * to go there: sending it wherever somebody arrived from means "Back to + * repositories" lands on skills, which is the label lying about itself. + * + * Retracing is the browser's own back button, which is always there and needs + * no help from us. + */ +export function useUp() { + const router = useRouter() + return (to) => router.push(to) +} diff --git a/ui/src/main.js b/ui/src/main.js new file mode 100644 index 0000000..b8045f9 --- /dev/null +++ b/ui/src/main.js @@ -0,0 +1,37 @@ +import { createApp } from 'vue' +import { createRouter, createWebHistory } from 'vue-router' +import App from '~/App.vue' +import Overview from '~/pages/Overview.vue' +import Graph from '~/pages/Graph.vue' +import Knowledge from '~/pages/Knowledge.vue' +import Repositories from '~/pages/Repositories.vue' +import Repository from '~/pages/Repository.vue' +import Reviews from '~/pages/Reviews.vue' +import Skill from '~/pages/Skill.vue' +import Skills from '~/pages/Skills.vue' +import SettingsPage from '~/pages/Settings.vue' +import '@sourceant/design/tokens.css' + +// Real paths, so a link somebody is handed can be opened and pasted like any +// other URL. The agent answers anything that is not a file with the page. +const router = createRouter({ + history: createWebHistory(), + routes: [ + { path: '/', component: Overview }, + { path: '/graph', component: Graph }, + { path: '/knowledge', component: Knowledge }, + { path: '/reviews', component: Reviews }, + // A review has a name, so an agent can hand somebody a link to one. + { path: '/reviews/:id', component: Reviews }, + { path: '/skills', component: Skills }, + // A rule kept in a nested folder has a slash in its name. + { path: '/skills/:id(.*)', component: Skill }, + { path: '/repositories', component: Repositories }, + // A name has a slash in it, so the whole tail is the name. + { path: '/repositories/:name(.*)', component: Repository }, + { path: '/settings', component: SettingsPage }, + { path: '/:rest(.*)*', redirect: '/' }, + ], +}) + +createApp(App).use(router).mount('#app') diff --git a/ui/src/pages/Graph.vue b/ui/src/pages/Graph.vue new file mode 100644 index 0000000..d3a049c --- /dev/null +++ b/ui/src/pages/Graph.vue @@ -0,0 +1,45 @@ + + + diff --git a/ui/src/pages/Knowledge.vue b/ui/src/pages/Knowledge.vue new file mode 100644 index 0000000..96734ba --- /dev/null +++ b/ui/src/pages/Knowledge.vue @@ -0,0 +1,323 @@ + + +