diff --git a/.gitignore b/.gitignore index 511b935..3c5f2dd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,13 @@ /.nova/ /.vscode/ -dist/ +/dist/ +/cmd/**/dist/ + *.png -GAME/ \ No newline at end of file +cmd/savegame-editor/frontend/node_modules/ + +GAME/ +debug.log +GOG_Galaxy_X-Com_UFO_Defense.exe diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a683b94..c0a7052 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,6 +5,8 @@ before: hooks: - go mod tidy - go generate ./... + - npm --prefix cmd/savegame-editor/frontend install + - npm --prefix cmd/savegame-editor/frontend run build builds: - id: "image-server" @@ -17,6 +19,16 @@ builds: - windows - darwin + - id: "savegame-editor" + main: ./cmd/savegame-editor/ + binary: savegame-editor + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of `uname`. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..e9704c5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,19 @@ +# CLAUDE.md + +## Branching + +- When starting a new task, always create a new branch with prefix `feature/` for new features and `fix/` for bugfixes. Only create a new branch when working on `main` or `master`. + +## Commits + +- Before each commit make sure that all tests are passing. +- Commit often. +- Never force-push. + +## Testing + +- Before each test run `go generate ./...`. +- Always make sure that tests run successfully before considering a task complete. +- Loading of ALL savegame files must be tested with a round-trip (load and save identical to original). +- Always update tests and docs when making changes. +- Make sure that all examples (in `examples/`) and CLI tools (in `cmd/`, each in its own subdirectory) still run after making changes. diff --git a/cmd/editor/main.go b/cmd/editor/main.go new file mode 100644 index 0000000..b4cc1ea --- /dev/null +++ b/cmd/editor/main.go @@ -0,0 +1,73 @@ +package main + +import ( + "flag" + "fmt" + "log" + "os" + + "golang.org/x/text/currency" + "golang.org/x/text/language" + "golang.org/x/text/message" + + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/redtoad/xcom-editor/savegame" +) + +func FinishAllConstructions(path string) { + +} + +func main() { + + rootPath := flag.String("path", ".", "save game path") + flag.Parse() + + pathBasesFile := *rootPath + string(os.PathSeparator) + "BASE.DAT" + if _, err := os.Stat(pathBasesFile); os.IsNotExist(err) { + log.Fatalf("could not open file: %v", err) + } + + sg, _ := savegame.Load(*rootPath + string(os.PathSeparator)) + curr := currency.USD.Amount(sg.Financials.CurrentBalance) + p := message.NewPrinter(language.AmericanEnglish) + p.Printf("%v\n", curr) + + for no := 0; no < len(sg.BasesData.Bases); no++ { + base := &sg.BasesData.Bases[no] + fmt.Printf("%d %s (%v)\n", no, base.Name, base.Active) + if !base.Active { + continue + } + for no, cell := range base.Grid { + if no%6 == 0 { + println() + } + fmt.Print(cell.String()) + } + println() + fmt.Printf("%v\n", base.Grid) + fmt.Printf("%v\n", base.DaysToCompletion) + + // complete constructions in progress + for i := 0; i < len(base.Grid); i++ { + if base.Grid[i] != geoscape.Empty && base.DaysToCompletion[i] > 0 { + base.DaysToCompletion[i] = 0 + } + } + + // increase Elirium-115 + //Elirium115 := 60 + //base.Inventory[Elirium115] = 0x7f + + AlienAlloys := 88 + base.Inventory[AlienAlloys] = 0x7f + + } + + fmt.Printf("Storing %s...\n", sg.Path) + if err := sg.Save(); err != nil { + log.Fatalf("could not save game: %v\n", err) + } + +} diff --git a/cmd/image-server/main.go b/cmd/image-server/main.go index 56d9cf5..11fc806 100644 --- a/cmd/image-server/main.go +++ b/cmd/image-server/main.go @@ -21,7 +21,7 @@ import ( "time" "github.com/gorilla/mux" - "github.com/redtoad/xcom-editor/lib/resources" + "github.com/redtoad/xcom-editor/resources" ) var ( diff --git a/cmd/savegame-editor/api.go b/cmd/savegame-editor/api.go new file mode 100644 index 0000000..2ec1857 --- /dev/null +++ b/cmd/savegame-editor/api.go @@ -0,0 +1,694 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "net/http" + "sort" + "strconv" + + "github.com/gorilla/mux" + "github.com/redtoad/xcom-editor/internal/geoscape" +) + +// armorToString converts a geoscape.Armor value to a display string. +// NoArmor is mapped to "None" to match the frontend select options. +var armorToString = map[geoscape.Armor]string{ + geoscape.NoArmor: "None", + geoscape.PersonalArmour: "Personal Armour", + geoscape.PowerSuit: "Power Suit", + geoscape.FlyingSuit: "Flying Suit", +} + +// armorFromString converts a display string to a geoscape.Armor value. +// Accepts both "None" and "NoArmor" for the no-armor case. +var armorFromString = map[string]geoscape.Armor{ + "None": geoscape.NoArmor, + "NoArmor": geoscape.NoArmor, + "Personal Armour": geoscape.PersonalArmour, + "Power Suit": geoscape.PowerSuit, + "Flying Suit": geoscape.FlyingSuit, +} + +func writeJSON(w http.ResponseWriter, v interface{}) { + w.Header().Set("Content-Type", "application/json") + if err := json.NewEncoder(w).Encode(v); err != nil { + log.Printf("Error encoding JSON: %v", err) + } +} + +func writeError(w http.ResponseWriter, status int, msg string) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + json.NewEncoder(w).Encode(map[string]string{"error": msg}) +} + +func getGameEntry(w http.ResponseWriter, r *http.Request) *gameEntry { + slot := mux.Vars(r)["slot"] + entry, ok := games[slot] + if !ok { + writeError(w, http.StatusNotFound, fmt.Sprintf("game %s not found", slot)) + return nil + } + return entry +} + +// GET /api/games +func handleListGames(w http.ResponseWriter, r *http.Request) { + type gameSummary struct { + Slot string `json:"slot"` + Title string `json:"title"` + Time string `json:"time"` + SoldierCount int `json:"soldierCount"` + BaseCount int `json:"baseCount"` + CraftCount int `json:"craftCount"` + } + + result := make([]gameSummary, 0) + for slot, entry := range games { + entry.mu.RLock() + result = append(result, gameSummary{ + Slot: slot, + Title: entry.sg.Title(), + Time: entry.sg.Time().Format("2006-01-02 15:04"), + SoldierCount: len(entry.sg.Soldiers()), + BaseCount: len(entry.sg.Bases()), + CraftCount: len(entry.sg.Crafts()), + }) + entry.mu.RUnlock() + } + sort.Slice(result, func(i, j int) bool { return result[i].Slot < result[j].Slot }) + writeJSON(w, result) +} + +// GET /api/games/{slot} +func handleGetGame(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + writeJSON(w, map[string]interface{}{ + "slot": mux.Vars(r)["slot"], + "title": sg.Title(), + "time": sg.Time().Format("2006-01-02 15:04"), + "soldierCount": len(sg.Soldiers()), + "baseCount": len(sg.Bases()), + "craftCount": len(sg.Crafts()), + "balance": sg.Financials.CurrentBalance, + }) +} + +// GET /api/games/{slot}/soldiers +func handleListSoldiers(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + + type soldierSummary struct { + Index int `json:"index"` + Name string `json:"name"` + Rank string `json:"rank"` + BaseName string `json:"baseName"` + CraftName string `json:"craftName"` + IsDead bool `json:"isDead"` + IsWounded bool `json:"isWounded"` + Missions int `json:"missions"` + Kills int `json:"kills"` + } + + result := make([]soldierSummary, 0) + for _, s := range sg.Soldiers() { + baseName := "" + if b := s.Base(); b != nil { + baseName = b.Name() + } + craftName := "" + if c := s.Craft(); c != nil { + craftName = c.Name() + } + result = append(result, soldierSummary{ + Index: s.Index(), + Name: s.Name(), + Rank: s.Rank().String(), + BaseName: baseName, + CraftName: craftName, + IsDead: s.IsDead(), + IsWounded: s.IsWounded(), + Missions: s.Missions(), + Kills: s.Kills(), + }) + } + writeJSON(w, result) +} + +// GET /api/games/{slot}/soldiers/{idx} +func handleGetSoldier(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + idx, err := strconv.Atoi(mux.Vars(r)["idx"]) + if err != nil { + writeError(w, http.StatusBadRequest, "invalid soldier index") + return + } + + entry.mu.RLock() + defer entry.mu.RUnlock() + + // Find soldier by index + for _, s := range entry.sg.Soldiers() { + if s.Index() == idx { + baseName := "" + if b := s.Base(); b != nil { + baseName = b.Name() + } + craftName := "" + if c := s.Craft(); c != nil { + craftName = c.Name() + } + writeJSON(w, map[string]interface{}{ + "index": s.Index(), + "name": s.Name(), + "rank": s.Rank().String(), + "baseName": baseName, + "craftName": craftName, + "isDead": s.IsDead(), + "isWounded": s.IsWounded(), + "missions": s.Missions(), + "kills": s.Kills(), + "recoveryDays": s.RecoveryDays(), + "timeUnits": s.TimeUnits(), + "health": s.Health(), + "energy": s.Energy(), + "reactions": s.Reactions(), + "strength": s.Strength(), + "firingAccuracy": s.FiringAccuracy(), + "throwingAccuracy": s.ThrowingAccuracy(), + "meleeAccuracy": s.MeleeAccuracy(), + "psionicStrength": s.PsionicStrength(), + "psionicSkill": s.PsionicSkill(), + "bravery": s.Bravery(), + "armor": armorToString[s.Armor()], + "gender": s.Gender(), + "appearance": s.Appearance(), + // Initial stats for editing + "initialTimeUnits": s.InitialTimeUnits(), + "initialHealth": s.InitialHealth(), + "initialEnergy": s.InitialEnergy(), + "initialReactions": s.InitialReactions(), + "initialStrength": s.InitialStrength(), + "initialFiringAccuracy": s.InitialFiringAccuracy(), + "initialThrowingAccuracy": s.InitialThrowingAccuracy(), + "initialMeleeAccuracy": s.InitialMeleeAccuracy(), + "initialPsionicStrength": s.InitialPsionicStrength(), + "initialPsionicSkill": s.InitialPsionicSkill(), + "initialBravery": s.InitialBravery(), + }) + return + } + } + writeError(w, http.StatusNotFound, "soldier not found") +} + +type soldierUpdateRequest struct { + Name *string `json:"name"` + InitialTimeUnits *int `json:"initialTimeUnits"` + InitialHealth *int `json:"initialHealth"` + InitialEnergy *int `json:"initialEnergy"` + InitialReactions *int `json:"initialReactions"` + InitialStrength *int `json:"initialStrength"` + InitialFiringAccuracy *int `json:"initialFiringAccuracy"` + InitialThrowingAccuracy *int `json:"initialThrowingAccuracy"` + InitialMeleeAccuracy *int `json:"initialMeleeAccuracy"` + InitialPsionicStrength *int `json:"initialPsionicStrength"` + InitialPsionicSkill *int `json:"initialPsionicSkill"` + Armor *string `json:"armor"` +} + +// PUT /api/games/{slot}/soldiers/{idx} +func handleUpdateSoldier(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + idx, err := strconv.Atoi(mux.Vars(r)["idx"]) + if err != nil { + writeError(w, http.StatusBadRequest, "invalid soldier index") + return + } + + var req soldierUpdateRequest + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + writeError(w, http.StatusBadRequest, "invalid JSON") + return + } + + entry.mu.Lock() + defer entry.mu.Unlock() + + for _, s := range entry.sg.Soldiers() { + if s.Index() == idx { + if req.Name != nil { + s.SetName(*req.Name) + } + if req.InitialTimeUnits != nil { + s.SetInitialTimeUnits(*req.InitialTimeUnits) + } + if req.InitialHealth != nil { + s.SetInitialHealth(*req.InitialHealth) + } + if req.InitialEnergy != nil { + s.SetInitialEnergy(*req.InitialEnergy) + } + if req.InitialReactions != nil { + s.SetInitialReactions(*req.InitialReactions) + } + if req.InitialStrength != nil { + s.SetInitialStrength(*req.InitialStrength) + } + if req.InitialFiringAccuracy != nil { + s.SetInitialFiringAccuracy(*req.InitialFiringAccuracy) + } + if req.InitialThrowingAccuracy != nil { + s.SetInitialThrowingAccuracy(*req.InitialThrowingAccuracy) + } + if req.InitialMeleeAccuracy != nil { + s.SetInitialMeleeAccuracy(*req.InitialMeleeAccuracy) + } + if req.InitialPsionicStrength != nil { + s.SetInitialPsionicStrength(*req.InitialPsionicStrength) + } + if req.InitialPsionicSkill != nil { + s.SetInitialPsionicSkill(*req.InitialPsionicSkill) + } + if req.Armor != nil { + if a, found := armorFromString[*req.Armor]; found { + s.SetArmor(a) + } + } + writeJSON(w, map[string]string{"status": "ok"}) + return + } + } + writeError(w, http.StatusNotFound, "soldier not found") +} + +// GET /api/games/{slot}/bases +func handleListBases(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + + type baseSummary struct { + Index int `json:"index"` + Name string `json:"name"` + Active bool `json:"active"` + Engineers int `json:"engineers"` + Scientists int `json:"scientists"` + Coord string `json:"coord"` + } + + result := make([]baseSummary, 0) + for _, b := range sg.Bases() { + result = append(result, baseSummary{ + Index: b.Index(), + Name: b.Name(), + Active: b.Active(), + Engineers: b.Engineers(), + Scientists: b.Scientists(), + Coord: b.Coord().String(), + }) + } + writeJSON(w, result) +} + +// GET /api/games/{slot}/bases/{idx} +func handleGetBase(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + idx, err := strconv.Atoi(mux.Vars(r)["idx"]) + if err != nil { + writeError(w, http.StatusBadRequest, "invalid base index") + return + } + + entry.mu.RLock() + defer entry.mu.RUnlock() + + b := entry.sg.Base(idx) + if b == nil { + writeError(w, http.StatusNotFound, "base not found") + return + } + + type tileInfo struct { + Type string `json:"type"` + DaysToCompletion int `json:"daysToCompletion"` + } + + tiles := make([]tileInfo, 36) + for i, t := range b.Tiles() { + tiles[i] = tileInfo{ + Type: t.Type.String(), + DaysToCompletion: t.DaysToCompletion, + } + } + + inventory := b.Inventory() + inventoryMap := make(map[string]int) + for i := 0; i < 96; i++ { + if inventory[i] > 0 { + inventoryMap[geoscape.Inventory(i).String()] = inventory[i] + } + } + + writeJSON(w, map[string]interface{}{ + "index": b.Index(), + "name": b.Name(), + "active": b.Active(), + "engineers": b.Engineers(), + "scientists": b.Scientists(), + "coord": b.Coord().String(), + "tiles": tiles, + "inventory": inventoryMap, + }) +} + +type baseUpdateRequest struct { + Engineers *int `json:"engineers"` + Scientists *int `json:"scientists"` +} + +// PUT /api/games/{slot}/bases/{idx} +func handleUpdateBase(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + idx, err := strconv.Atoi(mux.Vars(r)["idx"]) + if err != nil { + writeError(w, http.StatusBadRequest, "invalid base index") + return + } + + entry.mu.Lock() + defer entry.mu.Unlock() + + if idx < 0 || idx >= len(entry.sg.BasesData.Bases) { + writeError(w, http.StatusNotFound, "base not found") + return + } + + var req baseUpdateRequest + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + writeError(w, http.StatusBadRequest, "invalid JSON") + return + } + + base := &entry.sg.BasesData.Bases[idx] + if req.Engineers != nil { + base.Engineers = *req.Engineers + } + if req.Scientists != nil { + base.Scientists = *req.Scientists + } + + writeJSON(w, map[string]string{"status": "ok"}) +} + +// GET /api/games/{slot}/craft +func handleListCraft(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + + type craftSummary struct { + Index int `json:"index"` + Name string `json:"name"` + Type string `json:"type"` + Status string `json:"status"` + Damage int `json:"damage"` + Fuel int `json:"fuel"` + BaseName string `json:"baseName"` + } + + result := make([]craftSummary, 0) + for _, c := range sg.Crafts() { + baseName := "" + if b := c.Base(); b != nil { + baseName = b.Name() + } + result = append(result, craftSummary{ + Index: c.Index(), + Name: c.Name(), + Type: c.Type().String(), + Status: c.Status().String(), + Damage: c.Damage(), + Fuel: c.Fuel(), + BaseName: baseName, + }) + } + writeJSON(w, result) +} + +// GET /api/games/{slot}/transfers +func handleListTransfers(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + + type transferSummary struct { + Index int `json:"index"` + Origin int `json:"origin"` + Destination int `json:"destination"` + HoursLeft int `json:"hoursLeft"` + Type int `json:"type"` + Quantity int `json:"quantity"` + } + + result := make([]transferSummary, 0) + for _, t := range sg.Transfers() { + result = append(result, transferSummary{ + Index: t.Index(), + Origin: t.Origin(), + Destination: t.Destination(), + HoursLeft: t.HoursLeft(), + Type: t.Type(), + Quantity: t.Quantity(), + }) + } + writeJSON(w, result) +} + +// GET /api/games/{slot}/financials +func handleGetFinancials(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + writeJSON(w, map[string]interface{}{ + "currentBalance": sg.Financials.CurrentBalance, + "expenditure": sg.Financials.Expenditure, + "maintenance": sg.Financials.Maintenance, + "balance": sg.Financials.Balance, + }) +} + +type financialsUpdateRequest struct { + CurrentBalance *int32 `json:"currentBalance"` +} + +// PUT /api/games/{slot}/financials +func handleUpdateFinancials(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + var req financialsUpdateRequest + if err := json.NewDecoder(r.Body).Decode(&req); err != nil { + writeError(w, http.StatusBadRequest, "invalid JSON") + return + } + + entry.mu.Lock() + defer entry.mu.Unlock() + + if req.CurrentBalance != nil { + entry.sg.Financials.CurrentBalance = *req.CurrentBalance + } + writeJSON(w, map[string]string{"status": "ok"}) +} + +// POST /api/games/{slot}/actions/heal-all +func handleHealAll(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.Lock() + defer entry.mu.Unlock() + entry.sg.HealAllSoldiers() + writeJSON(w, map[string]string{"status": "ok"}) +} + +// POST /api/games/{slot}/actions/complete-constructions +func handleCompleteConstructions(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.Lock() + defer entry.mu.Unlock() + entry.sg.CompleteConstructions() + writeJSON(w, map[string]string{"status": "ok"}) +} + +// POST /api/games/{slot}/actions/speedup-deliveries +func handleSpeedupDeliveries(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.Lock() + defer entry.mu.Unlock() + entry.sg.SpeedupDelivery() + writeJSON(w, map[string]string{"status": "ok"}) +} + +// POST /api/games/{slot}/save +func handleSave(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.Lock() + defer entry.mu.Unlock() + if err := entry.sg.Save(); err != nil { + writeError(w, http.StatusInternalServerError, err.Error()) + return + } + log.Printf("Saved game: %s", mux.Vars(r)["slot"]) + writeJSON(w, map[string]string{"status": "ok"}) +} + +// GET /api/games/{slot}/locations +func handleListLocations(w http.ResponseWriter, r *http.Request) { + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.RLock() + defer entry.mu.RUnlock() + sg := entry.sg + + type coordJS struct { + Lat float32 `json:"lat"` + Lon float32 `json:"lon"` + } + type locationSummary struct { + Type string `json:"type"` + TypeCode int `json:"typeCode"` + Name string `json:"name"` + Coord coordJS `json:"coord"` + DestCoord *coordJS `json:"destCoord,omitempty"` + } + + result := make([]locationSummary, 0) + for _, loc := range sg.Locations() { + var name string + switch loc.Type { + case geoscape.XCOMBase: + if b := sg.Base(loc.TableReference); b != nil { + name = b.Name() + } else { + name = "X-COM Base" + } + case geoscape.XCOMShip: + if c := sg.Craft(loc.TableReference); c != nil { + name = c.Name() + } else { + name = fmt.Sprintf("CRAFT-%d", loc.CountSuffix) + } + case geoscape.AlienShip: + if c := sg.Craft(loc.TableReference); c != nil { + name = fmt.Sprintf("UFO-%d (%s, %s)", loc.CountSuffix, c.Type(), c.MissionType()) + } else { + name = fmt.Sprintf("UFO-%d", loc.CountSuffix) + } + case geoscape.AlienBase: + name = "Alien Base" + case geoscape.CrashSite: + name = fmt.Sprintf("Crash Site-%d", loc.CountSuffix) + case geoscape.LandedUFO: + name = fmt.Sprintf("Landed UFO-%d", loc.CountSuffix) + case geoscape.TerrorSite: + name = fmt.Sprintf("Terror Site-%d", loc.CountSuffix) + default: + name = loc.Type.String() + } + + c := loc.Coord() + summary := locationSummary{ + Type: loc.Type.String(), + TypeCode: int(loc.Type), + Name: name, + Coord: coordJS{Lat: c.Lat, Lon: c.Lon}, + } + + if loc.Type == geoscape.XCOMShip || loc.Type == geoscape.AlienShip { + if craft := sg.Craft(loc.TableReference); craft != nil { + if dest := craft.Destination(); dest != nil { + summary.DestCoord = &coordJS{Lat: dest.Lat, Lon: dest.Lon} + } else if wp := craft.NextWaypoint(); wp != nil { + summary.DestCoord = &coordJS{Lat: wp.Lat, Lon: wp.Lon} + } + } + } + + result = append(result, summary) + } + writeJSON(w, result) +} + +// POST /api/games/{slot}/reload +func handleReload(w http.ResponseWriter, r *http.Request) { + slot := mux.Vars(r)["slot"] + entry := getGameEntry(w, r) + if entry == nil { + return + } + entry.mu.Lock() + defer entry.mu.Unlock() + if err := entry.sg.Reload(); err != nil { + writeError(w, http.StatusInternalServerError, err.Error()) + return + } + log.Printf("Reloaded game: %s", slot) + writeJSON(w, map[string]string{"status": "ok"}) +} diff --git a/cmd/savegame-editor/frontend/dist/assets/index-CTR1qmsZ.js b/cmd/savegame-editor/frontend/dist/assets/index-CTR1qmsZ.js new file mode 100644 index 0000000..a68a824 --- /dev/null +++ b/cmd/savegame-editor/frontend/dist/assets/index-CTR1qmsZ.js @@ -0,0 +1,4995 @@ +var pI=Object.defineProperty;var mI=(i,e,t)=>e in i?pI(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var h2=(i,e,t)=>mI(i,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function Bi(){}function QC(i){return i()}function bT(){return Object.create(null)}function uu(i){i.forEach(QC)}function YC(i){return typeof i=="function"}function Ca(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function gI(i){return Object.keys(i).length===0}function J(i,e){i.appendChild(e)}function ht(i,e,t){i.insertBefore(e,t||null)}function ct(i){i.parentNode&&i.parentNode.removeChild(i)}function ta(i,e){for(let t=0;ti.removeEventListener(e,t,n)}function ge(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Vi(i){return i===""?null:+i}function _I(i){return Array.from(i.childNodes)}function Dt(i,e){e=""+e,i.data!==e&&(i.data=e)}function wi(i,e){i.value=e??""}function vI(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}function ST(i,e,t){for(let n=0;n{const r=i.$$.callbacks[e];if(r){const s=yI(e,t,{cancelable:n});return r.slice().forEach(o=>{o.call(i,s)}),!s.defaultPrevented}return!0}}const Ef=[],ex=[];let Ff=[];const TT=[],SI=Promise.resolve();let tx=!1;function TI(){tx||(tx=!0,SI.then(KC))}function Lg(i){Ff.push(i)}const f2=new Set;let zh=0;function KC(){if(zh!==0)return;const i=m0;do{try{for(;zhi.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),Ff=e}const dg=new Set;let Zc;function np(){Zc={r:0,c:[],p:Zc}}function ip(){Zc.r||uu(Zc.c),Zc=Zc.p}function mr(i,e){i&&i.i&&(dg.delete(i),i.i(e))}function Pr(i,e,t,n){if(i&&i.o){if(dg.has(i))return;dg.add(i),Zc.c.push(()=>{dg.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}function er(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function Sl(i){i&&i.c()}function Ra(i,e,t){const{fragment:n,after_update:r}=i.$$;n&&n.m(e,t),Lg(()=>{const s=i.$$.on_mount.map(QC).filter(YC);i.$$.on_destroy?i.$$.on_destroy.push(...s):uu(s),i.$$.on_mount=[]}),r.forEach(Lg)}function Na(i,e){const t=i.$$;t.fragment!==null&&(MI(t.after_update),uu(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function EI(i,e){i.$$.dirty[0]===-1&&(Ef.push(i),TI(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const x=v.length?v[0]:g;return u.ctx&&r(u.ctx[A],u.ctx[A]=x)&&(!u.skip_bound&&u.bound[A]&&u.bound[A](x),d&&EI(i,A)),g}):[],u.update(),d=!0,uu(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const A=_I(e.target);u.fragment&&u.fragment.l(A),A.forEach(ct)}else u.fragment&&u.fragment.c();e.intro&&mr(i.$$.fragment),Ra(i,e.target,e.anchor),KC()}JA(l)}class Da{constructor(){h2(this,"$$");h2(this,"$$set")}$destroy(){Na(this,1),this.$destroy=Bi}$on(e,t){if(!YC(t))return Bi;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}$set(e){this.$$set&&!gI(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const CI="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(CI);async function Yr(i,e){const t=await fetch(i,e);if(!t.ok){const n=await t.json().catch(()=>({error:t.statusText}));throw new Error(n.error||t.statusText)}return t.json()}async function RI(){return Yr("/api/games")}async function NI(i){return Yr(`/api/games/${i}`)}async function PI(i){return Yr(`/api/games/${i}/soldiers`)}async function DI(i,e){return Yr(`/api/games/${i}/soldiers/${e}`)}async function LI(i,e,t){await Yr(`/api/games/${i}/soldiers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function II(i){return Yr(`/api/games/${i}/bases`)}async function BI(i,e){return Yr(`/api/games/${i}/bases/${e}`)}async function UI(i,e,t){await Yr(`/api/games/${i}/bases/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function FI(i){return Yr(`/api/games/${i}/craft`)}async function OI(i){return Yr(`/api/games/${i}/transfers`)}async function kI(i){return Yr(`/api/games/${i}/financials`)}async function VI(i,e){await Yr(`/api/games/${i}/financials`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function GI(i){await Yr(`/api/games/${i}/actions/heal-all`,{method:"POST"})}async function qI(i){await Yr(`/api/games/${i}/actions/complete-constructions`,{method:"POST"})}async function zI(i){await Yr(`/api/games/${i}/actions/speedup-deliveries`,{method:"POST"})}async function HI(i){await Yr(`/api/games/${i}/save`,{method:"POST"})}async function WI(i){await Yr(`/api/games/${i}/reload`,{method:"POST"})}async function $I(i){return Yr(`/api/games/${i}/locations`)}function wT(i,e,t){const n=i.slice();return n[5]=e[t],n}function MT(i){let e,t;return{c(){e=ye("div"),t=ut(i[2]),ge(e,"class","error svelte-19y2p2f")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&4&&Dt(t,n[2])},d(n){n&&ct(e)}}}function ET(i){let e,t,n=i[5].slot.replace("_"," ")+"",r,s,o,a=i[5].title+"",l,u,d,A,g=i[5].time+"",v,x,T,S=i[5].soldierCount+"",w,C,E=i[5].baseCount+"",N,L,B=i[5].craftCount+"",I,F,P,O,G;function q(){return i[4](i[5])}return{c(){e=ye("button"),t=ye("div"),r=ut(n),s=ke(),o=ye("div"),l=ut(a),u=ke(),d=ye("div"),A=ye("span"),v=ut(g),x=ke(),T=ye("div"),w=ut(S),C=ut(` soldiers · + `),N=ut(E),L=ut(` bases · + `),I=ut(B),F=ut(" craft"),P=ke(),ge(t,"class","slot svelte-19y2p2f"),ge(o,"class","title svelte-19y2p2f"),ge(d,"class","meta svelte-19y2p2f"),ge(T,"class","counts svelte-19y2p2f"),ge(e,"class","game-card svelte-19y2p2f"),Qr(e,"selected",i[0]===i[5].slot)},m(j,Y){ht(j,e,Y),J(e,t),J(t,r),J(e,s),J(e,o),J(o,l),J(e,u),J(e,d),J(d,A),J(A,v),J(e,x),J(e,T),J(T,w),J(T,C),J(T,N),J(T,L),J(T,I),J(T,F),J(e,P),O||(G=Mi(e,"click",q),O=!0)},p(j,Y){i=j,Y&2&&n!==(n=i[5].slot.replace("_"," ")+"")&&Dt(r,n),Y&2&&a!==(a=i[5].title+"")&&Dt(l,a),Y&2&&g!==(g=i[5].time+"")&&Dt(v,g),Y&2&&S!==(S=i[5].soldierCount+"")&&Dt(w,S),Y&2&&E!==(E=i[5].baseCount+"")&&Dt(N,E),Y&2&&B!==(B=i[5].craftCount+"")&&Dt(I,B),Y&3&&Qr(e,"selected",i[0]===i[5].slot)},d(j){j&&ct(e),O=!1,G()}}}function jI(i){let e,t,n=i[2]&&MT(i),r=er(i[1]),s=[];for(let o=0;o{try{t(1,s=await RI())}catch(l){t(2,o=l.message)}});const a=l=>r("select",l.slot);return i.$$set=l=>{"selectedSlot"in l&&t(0,n=l.selectedSlot)},[n,s,o,r,a]}class QI extends Da{constructor(e){super(),Pa(this,e,XI,jI,Ca,{selectedSlot:0})}}function CT(i,e,t){const n=i.slice();return n[33]=e[t],n}function RT(i){let e,t;return{c(){e=ye("div"),t=ut(i[1]),ge(e,"class","error svelte-1efrnwg")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r[0]&2&&Dt(t,n[1])},d(n){n&&ct(e)}}}function NT(i){let e,t,n,r=i[0].name+"",s,o,a,l=i[0].rank+"",u,d,A=i[0].gender+"",g,v,x=i[0].appearance+"",T,S,w,C,E,N,L=i[0].missions+"",B,I,F=i[0].kills+"",P,O,G,q,j,Y,$,Q,ee,ue,le,de,Te,Qe,Ye,Et,at,ve,Re,Je,Ct,et,qt,en,zt,Oe,tt,Ve,pt,ae,tn,St,jt,ft,ie,H,_e,Le,$e,De,Ht,mt,Ot,Qt,it,_t,kt,Nt,Tt,wn,ne,vt,dt,Rt,rt,Ge,xt,hn,ai,nn,Tr,gr,Pe,ze=i[0].timeUnits+"",yt,je,f,W,Nn,qn=i[0].health+"",Hi,bn,Pn,ms,kn,_n=i[0].energy+"",Br,El,Cl,Ba,Zr,go=i[0].reactions+"",gs,K,Se,Ce,xe,V=i[0].strength+"",Fe,It,wt,Ut,Kt,un=i[0].firingAccuracy+"",z,Bn,Yn,bi,Ui,ni=i[0].throwingAccuracy+"",rn,ei,On,_r,wr,Xn=i[0].meleeAccuracy+"",ra,li,ur,vr,Mr,cr=i[0].psionicStrength+"",Rl,Uo,mc,pi,Dh,gc=i[0].psionicSkill+"",nA,Np,_c,vc,Lh,mu=i[0].bravery+"",iA,Pp,Ih,Ua,Bh=i[2]?"Applying...":"Apply Changes",xc,yc,Dp,Jr=i[0].baseName&&PT(i),es=i[0].craftName&&DT(i),ts=i[0].recoveryDays>0&<(i),gu=er(i[16]),ns=[];for(let Vt=0;Vti[20].call(Te)),ge(ue,"class","svelte-1efrnwg"),ge(q,"class","fields svelte-1efrnwg"),ge(Ye,"class","svelte-1efrnwg"),ge(Re,"class","svelte-1efrnwg"),ge(Je,"type","number"),ge(Je,"min","0"),ge(Je,"max","255"),ge(Je,"class","svelte-1efrnwg"),ge(ve,"class","svelte-1efrnwg"),ge(qt,"class","svelte-1efrnwg"),ge(en,"type","number"),ge(en,"min","0"),ge(en,"max","255"),ge(en,"class","svelte-1efrnwg"),ge(et,"class","svelte-1efrnwg"),ge(tt,"class","svelte-1efrnwg"),ge(Ve,"type","number"),ge(Ve,"min","0"),ge(Ve,"max","255"),ge(Ve,"class","svelte-1efrnwg"),ge(Oe,"class","svelte-1efrnwg"),ge(tn,"class","svelte-1efrnwg"),ge(St,"type","number"),ge(St,"min","0"),ge(St,"max","255"),ge(St,"class","svelte-1efrnwg"),ge(ae,"class","svelte-1efrnwg"),ge(ie,"class","svelte-1efrnwg"),ge(H,"type","number"),ge(H,"min","0"),ge(H,"max","255"),ge(H,"class","svelte-1efrnwg"),ge(ft,"class","svelte-1efrnwg"),ge($e,"class","svelte-1efrnwg"),ge(De,"type","number"),ge(De,"min","0"),ge(De,"max","255"),ge(De,"class","svelte-1efrnwg"),ge(Le,"class","svelte-1efrnwg"),ge(Ot,"class","svelte-1efrnwg"),ge(Qt,"type","number"),ge(Qt,"min","0"),ge(Qt,"max","255"),ge(Qt,"class","svelte-1efrnwg"),ge(mt,"class","svelte-1efrnwg"),ge(kt,"class","svelte-1efrnwg"),ge(Nt,"type","number"),ge(Nt,"min","0"),ge(Nt,"max","255"),ge(Nt,"class","svelte-1efrnwg"),ge(_t,"class","svelte-1efrnwg"),ge(ne,"class","svelte-1efrnwg"),ge(vt,"type","number"),ge(vt,"min","0"),ge(vt,"max","255"),ge(vt,"class","svelte-1efrnwg"),ge(wn,"class","svelte-1efrnwg"),ge(rt,"class","svelte-1efrnwg"),ge(Ge,"type","number"),ge(Ge,"min","0"),ge(Ge,"max","255"),ge(Ge,"class","svelte-1efrnwg"),ge(Rt,"class","svelte-1efrnwg"),ge(at,"class","stats-grid svelte-1efrnwg"),ge(hn,"class","svelte-1efrnwg"),ge(gr,"class","svelte-1efrnwg"),ge(W,"class","svelte-1efrnwg"),ge(ms,"class","svelte-1efrnwg"),ge(Ba,"class","svelte-1efrnwg"),ge(Ce,"class","svelte-1efrnwg"),ge(Ut,"class","svelte-1efrnwg"),ge(bi,"class","svelte-1efrnwg"),ge(_r,"class","svelte-1efrnwg"),ge(vr,"class","svelte-1efrnwg"),ge(pi,"class","svelte-1efrnwg"),ge(vc,"class","svelte-1efrnwg"),ge(nn,"class","stats-display svelte-1efrnwg"),ge(Ua,"class","save-btn svelte-1efrnwg"),Ua.disabled=i[2],ge(Ih,"class","actions svelte-1efrnwg"),ge(e,"class","edit-form svelte-1efrnwg")},m(Vt,Vn){ht(Vt,e,Vn),J(e,t),J(t,n),J(t,s),J(e,o),J(e,a),J(a,u),J(a,d),J(a,g),J(a,v),J(a,T),J(a,S),Jr&&Jr.m(a,null),J(a,w),es&&es.m(a,null),J(e,C),J(e,E),J(E,N),J(E,B),J(E,I),J(E,P),J(E,O),ts&&ts.m(E,null),J(e,G),J(e,q),J(q,j),J(j,Y),J(j,$),J(j,Q),wi(Q,i[3]),J(q,ee),J(q,ue),J(ue,le),J(ue,de),J(ue,Te);for(let ii=0;ii0?ts?ts.p(Vt,Vn):(ts=LT(Vt),ts.c(),ts.m(E,null)):ts&&(ts.d(1),ts=null),Vn[0]&8&&Q.value!==Vt[3]&&wi(Q,Vt[3]),Vn[0]&65536){gu=er(Vt[16]);let ii;for(ii=0;ii{"gameSlot"in de&&t(17,n=de.gameSlot),"soldierIdx"in de&&t(18,r=de.soldierIdx)},[o,a,l,u,d,A,g,v,x,T,S,w,C,E,N,B,I,n,r,F,P,O,G,q,j,Y,$,Q,ee,ue,le]}class ZI extends Da{constructor(e){super(),Pa(this,e,KI,YI,Ca,{gameSlot:17,soldierIdx:18},null,[-1,-1])}}function BT(i,e,t){const n=i.slice();return n[7]=e[t],n}function UT(i){let e,t;return{c(){e=ye("div"),t=ut(i[3]),ge(e,"class","error svelte-8vrigc")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&8&&Dt(t,n[3])},d(n){n&&ct(e)}}}function JI(i){let e,t,n,r,s=er(i[1]),o=[];for(let a=0;aName Rank Base Craft Missions Kills Status',n=ke(),r=ye("tbody");for(let a=0;a{l[g]=null}),ip(),n=l[t],n?n.p(d,A):(n=l[t]=a[t](d),n.c()),mr(n,1),n.m(r.parentNode,r))},i(d){s||(mr(n),s=!0)},o(d){Pr(n),s=!1},d(d){d&&(ct(e),ct(r)),o&&o.d(d),l[t].d(d)}}}function sB(i,e,t){let{gameSlot:n}=e,r=[],s=null,o="";async function a(){try{t(1,r=await PI(n)),t(3,o="")}catch(d){t(3,o=d.message)}}bl(a);function l(){t(2,s=null),a()}const u=d=>t(2,s=d.index);return i.$$set=d=>{"gameSlot"in d&&t(0,n=d.gameSlot)},i.$$.update=()=>{i.$$.dirty&1&&n&&(t(2,s=null),a())},[n,r,s,o,l,u]}class oB extends Da{constructor(e){super(),Pa(this,e,sB,rB,Ca,{gameSlot:0})}}function OT(i,e,t){const n=i.slice();return n[12]=e[t][0],n[13]=e[t][1],n}function kT(i,e,t){const n=i.slice();return n[16]=e[t],n[18]=t,n}function VT(i,e,t){const n=i.slice();n[16]=e[t],n[21]=t;const r=n[0].tiles[n[21]+n[18]*6];return n[19]=r,n}function GT(i){let e,t;return{c(){e=ye("div"),t=ut(i[1]),ge(e,"class","error svelte-x2jonz")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&2&&Dt(t,n[1])},d(n){n&&ct(e)}}}function qT(i){let e,t=i[0].name+"",n,r,s,o=i[0].coord+"",a,l,u,d,A,g,v,x,T,S,w,C,E,N,L,B,I,F=Object.keys(i[0].inventory).length>0,P,O,G,q=i[2]?"Applying...":"Apply Changes",j,Y,$,Q=er({length:6}),ee=[];for(let le=0;le0),F?ue?ue.p(le,de):(ue=$T(le),ue.c(),ue.m(P.parentNode,P)):ue&&(ue.d(1),ue=null),de&4&&q!==(q=le[2]?"Applying...":"Apply Changes")&&Dt(j,q),de&4&&(G.disabled=le[2])},d(le){le&&(ct(e),ct(r),ct(s),ct(l),ct(u),ct(E),ct(N),ct(L),ct(B),ct(I),ct(P),ct(O)),ta(ee,le),ue&&ue.d(le),Y=!1,uu($)}}}function zT(i){let e,t=i[19].daysToCompletion+"",n,r;return{c(){e=ye("span"),n=ut(t),r=ut("d"),ge(e,"class","tile-days svelte-x2jonz")},m(s,o){ht(s,e,o),J(e,n),J(e,r)},p(s,o){o&1&&t!==(t=s[19].daysToCompletion+"")&&Dt(n,t)},d(s){s&&ct(e)}}}function HT(i){let e,t,n=(i[19].type==="Empty"?"":i[19].type.replace(/ *\(.*\)/,""))+"",r,s,o,a=i[19].daysToCompletion>0&&zT(i);return{c(){e=ye("div"),t=ye("span"),r=ut(n),s=ke(),a&&a.c(),ge(t,"class","tile-name svelte-x2jonz"),ge(e,"class","tile svelte-x2jonz"),ge(e,"title",o=i[19].type+(i[19].daysToCompletion>0?` (${i[19].daysToCompletion} days)`:"")),Qr(e,"empty",i[19].type==="Empty"),Qr(e,"building",i[19].daysToCompletion>0)},m(l,u){ht(l,e,u),J(e,t),J(t,r),J(e,s),a&&a.m(e,null)},p(l,u){u&1&&n!==(n=(l[19].type==="Empty"?"":l[19].type.replace(/ *\(.*\)/,""))+"")&&Dt(r,n),l[19].daysToCompletion>0?a?a.p(l,u):(a=zT(l),a.c(),a.m(e,null)):a&&(a.d(1),a=null),u&1&&o!==(o=l[19].type+(l[19].daysToCompletion>0?` (${l[19].daysToCompletion} days)`:""))&&ge(e,"title",o),u&1&&Qr(e,"empty",l[19].type==="Empty"),u&1&&Qr(e,"building",l[19].daysToCompletion>0)},d(l){l&&ct(e),a&&a.d()}}}function WT(i){let e,t,n=er({length:6}),r=[];for(let s=0;si[0].localeCompare(e[0]);function lB(i,e,t){let{gameSlot:n}=e,{baseIdx:r}=e;const s=ky();let o=null,a="",l=!1,u=0,d=0;async function A(){try{t(0,o=await BI(n,r)),t(3,u=o.engineers),t(4,d=o.scientists),t(1,a="")}catch(T){t(1,a=T.message)}}bl(A);async function g(){t(2,l=!0);try{await UI(n,r,{engineers:u,scientists:d}),s("saved")}catch(T){t(1,a=T.message)}t(2,l=!1)}function v(){u=Vi(this.value),t(3,u)}function x(){d=Vi(this.value),t(4,d)}return i.$$set=T=>{"gameSlot"in T&&t(6,n=T.gameSlot),"baseIdx"in T&&t(7,r=T.baseIdx)},[o,a,l,u,d,g,n,r,v,x]}class uB extends Da{constructor(e){super(),Pa(this,e,lB,aB,Ca,{gameSlot:6,baseIdx:7})}}function QT(i,e,t){const n=i.slice();return n[7]=e[t],n}function YT(i){let e,t;return{c(){e=ye("div"),t=ut(i[3]),ge(e,"class","error svelte-egad06")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&8&&Dt(t,n[3])},d(n){n&&ct(e)}}}function cB(i){let e,t=er(i[1]),n=[];for(let r=0;r{l[g]=null}),ip(),n=l[t],n?n.p(d,A):(n=l[t]=a[t](d),n.c()),mr(n,1),n.m(r.parentNode,r))},i(d){s||(mr(n),s=!0)},o(d){Pr(n),s=!1},d(d){d&&(ct(e),ct(r)),o&&o.d(d),l[t].d(d)}}}function dB(i,e,t){let{gameSlot:n}=e,r=[],s=null,o="";async function a(){try{t(1,r=await II(n)),t(3,o="")}catch(d){t(3,o=d.message)}}bl(a);function l(){t(2,s=null),a()}const u=d=>t(2,s=d.index);return i.$$set=d=>{"gameSlot"in d&&t(0,n=d.gameSlot)},i.$$.update=()=>{i.$$.dirty&1&&n&&(t(2,s=null),a())},[n,r,s,o,l,u]}class AB extends Da{constructor(e){super(),Pa(this,e,dB,fB,Ca,{gameSlot:0})}}function ZT(i,e,t){const n=i.slice();return n[4]=e[t],n}function JT(i){let e,t;return{c(){e=ye("div"),t=ut(i[1]),ge(e,"class","error svelte-15cjom9")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&2&&Dt(t,n[1])},d(n){n&&ct(e)}}}function pB(i){let e,t,n,r,s=er(i[0]),o=[];for(let a=0;aName Type Base Status Damage Fuel',n=ke(),r=ye("tbody");for(let a=0;a{"gameSlot"in a&&t(2,n=a.gameSlot)},i.$$.update=()=>{i.$$.dirty&4&&n&&o()},[r,s,n]}class vB extends Da{constructor(e){super(),Pa(this,e,_B,gB,Ca,{gameSlot:2})}}function tw(i,e,t){const n=i.slice();return n[4]=e[t],n}function nw(i){let e,t;return{c(){e=ye("div"),t=ut(i[1]),ge(e,"class","error svelte-qimr4z")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&2&&Dt(t,n[1])},d(n){n&&ct(e)}}}function xB(i){let e,t,n,r,s=er(i[0]),o=[];for(let a=0;aOrigin Destination Hours Left Type Quantity',n=ke(),r=ye("tbody");for(let a=0;a{"gameSlot"in a&&t(2,n=a.gameSlot)},i.$$.update=()=>{i.$$.dirty&4&&n&&o()},[r,s,n]}class TB extends Da{constructor(e){super(),Pa(this,e,SB,bB,Ca,{gameSlot:2})}}function rw(i,e,t){const n=i.slice();return n[10]=e[t],n[12]=t,n}function sw(i){let e,t;return{c(){e=ye("div"),t=ut(i[1]),ge(e,"class","error svelte-1sskyg0")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&2&&Dt(t,n[1])},d(n){n&&ct(e)}}}function ow(i){let e,t,n,r,s,o,a,l,u=i[3]?"...":i[4]?"Saved!":"Update",d,A,g,v=Ou(i[2])+"",x,T,S,w,C,E,N,L,B,I,F=er(i[0].expenditure),P=[];for(let O=0;OMonth Expenditure Maintenance Balance',N=ke(),L=ye("tbody");for(let O=0;Ot(4,l=!1),2e3)}catch(v){t(1,s=v.message)}t(3,a=!1)}const A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function g(){o=Vi(this.value),t(2,o)}return i.$$set=v=>{"gameSlot"in v&&t(7,n=v.gameSlot)},i.$$.update=()=>{i.$$.dirty&128&&n&&u()},[r,s,o,a,l,d,A,n,g]}class EB extends Da{constructor(e){super(),Pa(this,e,MB,wB,Ca,{gameSlot:7})}}/** + * @license + * Copyright 2010-2025 Three.js Authors + * SPDX-License-Identifier: MIT + */const wh="182",$o={ROTATE:0,DOLLY:1,PAN:2},Nf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ZC=0,nx=1,JC=2,CB=0,e0=1,RB=2,Hl=3,No=0,Ai=1,xr=2,$s=0,js=1,Qf=2,Yf=3,Kf=4,Of=5,bs=100,Vy=101,Gy=102,eR=103,tR=104,Ol=200,qy=201,zy=202,Hy=203,g0=204,_0=205,Wy=206,$y=207,jy=208,Xy=209,Qy=210,NB=211,PB=212,DB=213,LB=214,v0=0,x0=1,y0=2,tc=3,b0=4,S0=5,T0=6,w0=7,rp=0,nR=1,iR=2,ls=0,Yy=1,Ky=2,Zy=3,Jy=4,rR=5,eb=6,tb=7,nb=300,ba=301,ml=302,Zf=303,Jf=304,dh=306,Ah=1e3,io=1001,ph=1002,xi=1003,ib=1004,Wl=1005,ki=1006,kf=1007,ro=1008,IB=1008,Gi=1009,ah=1010,lh=1011,ga=1012,jr=1013,vi=1014,dr=1015,zi=1016,G1=1017,q1=1018,Po=1020,z1=35902,H1=35899,rb=1021,sp=1022,pr=1023,hs=1026,zs=1027,op=1028,zd=1029,Hs=1030,Hd=1031,BB=1032,Wd=1033,Qu=33776,Yu=33777,Ku=33778,Zu=33779,M0=35840,E0=35841,C0=35842,R0=35843,ed=36196,td=37492,nd=37496,id=37488,rd=37489,mh=37490,sd=37491,od=37808,ad=37809,ld=37810,ud=37811,cd=37812,hd=37813,fd=37814,dd=37815,Ad=37816,pd=37817,md=37818,gd=37819,_d=37820,vd=37821,xd=36492,ix=36494,rx=36495,yd=36283,bd=36284,gh=36285,Sd=36286,UB=0,FB=1,lw=2,OB=3200,ol=0,sR=1,to="",as="srgb",nc="srgb-linear",Td="linear",Pt="srgb",d2="",oR="rg",kB="ga",VB=0,qc=7680,GB=7681,qB=7682,zB=7683,HB=34055,WB=34056,$B=5386,jB=512,XB=513,QB=514,YB=515,KB=516,ZB=517,JB=518,sx=519,sb=512,ap=513,ob=514,lp=515,ab=516,lb=517,up=518,ub=519,wd=35044,Jc=35048,uw="300 es",Ws=2e3,Xo=2001,nl={COMPUTE:"compute",RENDER:"render"};function cb(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ig(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function N0(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function aR(){const i=N0("canvas");return i.style.display="block",i}const cw={};function P0(...i){const e="THREE."+i.shift();console.log(e,...i)}function Ue(...i){const e="THREE."+i.shift();console.warn(e,...i)}function He(...i){const e="THREE."+i.shift();console.error(e,...i)}function Ci(...i){const e=i.join(" ");e in cw||(cw[e]=!0,Ue(...i))}function e9(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}class La{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 r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,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 r=n.slice(0);for(let s=0,o=r.length;s>8&255]+_s[i>>16&255]+_s[i>>24&255]+"-"+_s[e&255]+_s[e>>8&255]+"-"+_s[e>>16&15|64]+_s[e>>24&255]+"-"+_s[t&63|128]+_s[t>>8&255]+"-"+_s[t>>16&255]+_s[t>>24&255]+_s[n&255]+_s[n>>8&255]+_s[n>>16&255]+_s[n>>24&255]).toLowerCase()}function Sn(i,e,t){return Math.max(e,Math.min(t,i))}function hb(i,e){return(i%e+e)%e}function t9(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function n9(i,e,t){return i!==e?(t-i)/(e-i):0}function n0(i,e,t){return(1-t)*i+t*e}function i9(i,e,t,n){return n0(i,e,1-Math.exp(-t*n))}function r9(i,e=1){return e-Math.abs(hb(i,e*2)-e)}function s9(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function o9(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function a9(i,e){return i+Math.floor(Math.random()*(e-i+1))}function l9(i,e){return i+Math.random()*(e-i)}function u9(i){return i*(.5-Math.random())}function c9(i){i!==void 0&&(hw=i);let e=hw+=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 h9(i){return i*t0}function f9(i){return i*_h}function d9(i){return(i&i-1)===0&&i!==0}function A9(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function p9(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function m9(i,e,t,n,r){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),u=s((e+n)/2),d=o((e+n)/2),A=s((e-n)/2),g=o((e-n)/2),v=s((n-e)/2),x=o((n-e)/2);switch(r){case"XYX":i.set(a*d,l*A,l*g,a*u);break;case"YZY":i.set(l*g,a*d,l*A,a*u);break;case"ZXZ":i.set(l*A,l*g,a*d,a*u);break;case"XZX":i.set(a*d,l*x,l*v,a*u);break;case"YXY":i.set(l*v,a*d,l*x,a*u);break;case"ZYZ":i.set(l*x,l*v,a*d,a*u);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Gs(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Fn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Md={DEG2RAD:t0,RAD2DEG:_h,generateUUID:al,clamp:Sn,euclideanModulo:hb,mapLinear:t9,inverseLerp:n9,lerp:n0,damp:i9,pingpong:r9,smoothstep:s9,smootherstep:o9,randInt:a9,randFloat:l9,randFloatSpread:u9,seededRandom:c9,degToRad:h9,radToDeg:f9,isPowerOfTwo:d9,ceilPowerOfTwo:A9,floorPowerOfTwo:p9,setQuaternionFromProperEuler:m9,normalize:Fn,denormalize:Gs};class qe{constructor(e=0,t=0){qe.prototype.isVector2=!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("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("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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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=Sn(this.x,e.x,t.x),this.y=Sn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Sn(this.x,e,t),this.y=Sn(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sn(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(Sn(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),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Sa{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let l=n[r+0],u=n[r+1],d=n[r+2],A=n[r+3],g=s[o+0],v=s[o+1],x=s[o+2],T=s[o+3];if(a<=0){e[t+0]=l,e[t+1]=u,e[t+2]=d,e[t+3]=A;return}if(a>=1){e[t+0]=g,e[t+1]=v,e[t+2]=x,e[t+3]=T;return}if(A!==T||l!==g||u!==v||d!==x){let S=l*g+u*v+d*x+A*T;S<0&&(g=-g,v=-v,x=-x,T=-T,S=-S);let w=1-a;if(S<.9995){const C=Math.acos(S),E=Math.sin(C);w=Math.sin(w*C)/E,a=Math.sin(a*C)/E,l=l*w+g*a,u=u*w+v*a,d=d*w+x*a,A=A*w+T*a}else{l=l*w+g*a,u=u*w+v*a,d=d*w+x*a,A=A*w+T*a;const C=1/Math.sqrt(l*l+u*u+d*d+A*A);l*=C,u*=C,d*=C,A*=C}}e[t]=l,e[t+1]=u,e[t+2]=d,e[t+3]=A}static multiplyQuaternionsFlat(e,t,n,r,s,o){const a=n[r],l=n[r+1],u=n[r+2],d=n[r+3],A=s[o],g=s[o+1],v=s[o+2],x=s[o+3];return e[t]=a*x+d*A+l*v-u*g,e[t+1]=l*x+d*g+u*A-a*v,e[t+2]=u*x+d*v+a*g-l*A,e[t+3]=d*x-a*A-l*g-u*v,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,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,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,u=a(n/2),d=a(r/2),A=a(s/2),g=l(n/2),v=l(r/2),x=l(s/2);switch(o){case"XYZ":this._x=g*d*A+u*v*x,this._y=u*v*A-g*d*x,this._z=u*d*x+g*v*A,this._w=u*d*A-g*v*x;break;case"YXZ":this._x=g*d*A+u*v*x,this._y=u*v*A-g*d*x,this._z=u*d*x-g*v*A,this._w=u*d*A+g*v*x;break;case"ZXY":this._x=g*d*A-u*v*x,this._y=u*v*A+g*d*x,this._z=u*d*x+g*v*A,this._w=u*d*A-g*v*x;break;case"ZYX":this._x=g*d*A-u*v*x,this._y=u*v*A+g*d*x,this._z=u*d*x-g*v*A,this._w=u*d*A+g*v*x;break;case"YZX":this._x=g*d*A+u*v*x,this._y=u*v*A+g*d*x,this._z=u*d*x-g*v*A,this._w=u*d*A-g*v*x;break;case"XZY":this._x=g*d*A-u*v*x,this._y=u*v*A-g*d*x,this._z=u*d*x+g*v*A,this._w=u*d*A+g*v*x;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],u=t[2],d=t[6],A=t[10],g=n+a+A;if(g>0){const v=.5/Math.sqrt(g+1);this._w=.25/v,this._x=(d-l)*v,this._y=(s-u)*v,this._z=(o-r)*v}else if(n>a&&n>A){const v=2*Math.sqrt(1+n-a-A);this._w=(d-l)/v,this._x=.25*v,this._y=(r+o)/v,this._z=(s+u)/v}else if(a>A){const v=2*Math.sqrt(1+a-n-A);this._w=(s-u)/v,this._x=(r+o)/v,this._y=.25*v,this._z=(l+d)/v}else{const v=2*Math.sqrt(1+A-n-a);this._w=(o-r)/v,this._x=(s+u)/v,this._y=(l+d)/v,this._z=.25*v}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(Sn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,u=t._z,d=t._w;return this._x=n*d+o*a+r*u-s*l,this._y=r*d+o*l+s*a-n*u,this._z=s*d+o*u+n*l-r*a,this._w=o*d-n*a-r*l-s*u,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,r=e._y,s=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,r=-r,s=-s,o=-o,a=-a);let l=1-t;if(a<.9995){const u=Math.acos(a),d=Math.sin(u);l=Math.sin(l*u)/d,t=Math.sin(t*u)/d,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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}}class te{constructor(e=0,t=0,n=0){te.prototype.isVector3=!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("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("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(fw.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fw.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,u=2*(o*r-a*n),d=2*(a*t-s*r),A=2*(s*n-o*t);return this.x=t+l*u+o*A-a*d,this.y=n+l*d+a*u-s*A,this.z=r+l*A+s*d-o*u,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,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,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=Sn(this.x,e.x,t.x),this.y=Sn(this.y,e.y,t.y),this.z=Sn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Sn(this.x,e,t),this.y=Sn(this.y,e,t),this.z=Sn(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sn(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,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-n*l,this.z=n*a-r*o,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 A2.copy(this).projectOnVector(e),this.sub(A2)}reflect(e){return this.sub(A2.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(Sn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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 r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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}}const A2=new te,fw=new Sa;class Cn{constructor(e,t,n,r,s,o,a,l,u){Cn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,l,u)}set(e,t,n,r,s,o,a,l,u){const d=this.elements;return d[0]=e,d[1]=r,d[2]=a,d[3]=t,d[4]=s,d[5]=l,d[6]=n,d[7]=o,d[8]=u,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,r=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],u=n[1],d=n[4],A=n[7],g=n[2],v=n[5],x=n[8],T=r[0],S=r[3],w=r[6],C=r[1],E=r[4],N=r[7],L=r[2],B=r[5],I=r[8];return s[0]=o*T+a*C+l*L,s[3]=o*S+a*E+l*B,s[6]=o*w+a*N+l*I,s[1]=u*T+d*C+A*L,s[4]=u*S+d*E+A*B,s[7]=u*w+d*N+A*I,s[2]=g*T+v*C+x*L,s[5]=g*S+v*E+x*B,s[8]=g*w+v*N+x*I,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],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],d=e[8];return t*o*d-t*a*u-n*s*d+n*a*l+r*s*u-r*o*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],d=e[8],A=d*o-a*u,g=a*l-d*s,v=u*s-o*l,x=t*A+n*g+r*v;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/x;return e[0]=A*T,e[1]=(r*u-d*n)*T,e[2]=(a*n-r*o)*T,e[3]=g*T,e[4]=(d*t-r*l)*T,e[5]=(r*s-a*t)*T,e[6]=v*T,e[7]=(n*l-u*t)*T,e[8]=(o*t-n*s)*T,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,r,s,o,a){const l=Math.cos(s),u=Math.sin(s);return this.set(n*l,n*u,-n*(l*o+u*a)+o+e,-r*u,r*l,-r*(-u*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(p2.makeScale(e,t)),this}rotate(e){return this.premultiply(p2.makeRotation(-e)),this}translate(e,t){return this.premultiply(p2.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 r=0;r<9;r++)if(t[r]!==n[r])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)}}const p2=new Cn,dw=new Cn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Aw=new Cn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function g9(){const i={enabled:!0,workingColorSpace:nc,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Pt&&(r.r=jl(r.r),r.g=jl(r.g),r.b=jl(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Pt&&(r.r=Vf(r.r),r.g=Vf(r.g),r.b=Vf(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===to?Td:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Ci("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Ci("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[nc]:{primaries:e,whitePoint:n,transfer:Td,toXYZ:dw,fromXYZ:Aw,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:as},outputColorSpaceConfig:{drawingBufferColorSpace:as}},[as]:{primaries:e,whitePoint:n,transfer:Pt,toXYZ:dw,fromXYZ:Aw,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:as}}}),i}const ln=g9();function jl(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Vf(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Hh;class _9{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{Hh===void 0&&(Hh=N0("canvas")),Hh.width=e.width,Hh.height=e.height;const r=Hh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Hh}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=N0("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o1),this.pmremVersion=0}get width(){return this.source.getSize(g2).x}get height(){return this.source.getSize(g2).y}get depth(){return this.source.getSize(g2).z}get image(){return this.source.data}set image(e=null){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.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){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.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,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!==nb)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ah:e.x=e.x-Math.floor(e.x);break;case io:e.x=e.x<0?0:1;break;case ph: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 Ah:e.y=e.y-Math.floor(e.y);break;case io:e.y=e.y<0?0:1;break;case ph: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++}}Dr.DEFAULT_IMAGE=null;Dr.DEFAULT_MAPPING=nb;Dr.DEFAULT_ANISOTROPY=1;class dn{constructor(e=0,t=0,n=0,r=1){dn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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("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("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,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,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,r,s;const l=e.elements,u=l[0],d=l[4],A=l[8],g=l[1],v=l[5],x=l[9],T=l[2],S=l[6],w=l[10];if(Math.abs(d-g)<.01&&Math.abs(A-T)<.01&&Math.abs(x-S)<.01){if(Math.abs(d+g)<.1&&Math.abs(A+T)<.1&&Math.abs(x+S)<.1&&Math.abs(u+v+w-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(u+1)/2,N=(v+1)/2,L=(w+1)/2,B=(d+g)/4,I=(A+T)/4,F=(x+S)/4;return E>N&&E>L?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=B/n,s=I/n):N>L?N<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(N),n=B/r,s=F/r):L<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),n=I/s,r=F/s),this.set(n,r,s,t),this}let C=Math.sqrt((S-x)*(S-x)+(A-T)*(A-T)+(g-d)*(g-d));return Math.abs(C)<.001&&(C=1),this.x=(S-x)/C,this.y=(A-T)/C,this.z=(g-d)/C,this.w=Math.acos((u+v+w-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=Sn(this.x,e.x,t.x),this.y=Sn(this.y,e.y,t.y),this.z=Sn(this.z,e.z,t.z),this.w=Sn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Sn(this.x,e,t),this.y=Sn(this.y,e,t),this.z=Sn(this.z,e,t),this.w=Sn(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sn(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}}class hu extends La{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ki,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new dn(0,0,e,t),this.scissorTest=!1,this.viewport=new dn(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Dr(r);this.textures=[];const o=n.count;for(let a=0;a1);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=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,sa),sa.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(hA),zp.subVectors(this.max,hA),Wh.subVectors(e.a,hA),$h.subVectors(e.b,hA),jh.subVectors(e.c,hA),Tu.subVectors($h,Wh),wu.subVectors(jh,$h),Mc.subVectors(Wh,jh);let t=[0,-Tu.z,Tu.y,0,-wu.z,wu.y,0,-Mc.z,Mc.y,Tu.z,0,-Tu.x,wu.z,0,-wu.x,Mc.z,0,-Mc.x,-Tu.y,Tu.x,0,-wu.y,wu.x,0,-Mc.y,Mc.x,0];return!_2(t,Wh,$h,jh,zp)||(t=[1,0,0,0,1,0,0,0,1],!_2(t,Wh,$h,jh,zp))?!1:(Hp.crossVectors(Tu,wu),t=[Hp.x,Hp.y,Hp.z],_2(t,Wh,$h,jh,zp))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,sa).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(sa).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:(Pl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pl),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 Pl=[new te,new te,new te,new te,new te,new te,new te,new te],sa=new te,qp=new fu,Wh=new te,$h=new te,jh=new te,Tu=new te,wu=new te,Mc=new te,hA=new te,zp=new te,Hp=new te,Ec=new te;function _2(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Ec.fromArray(i,s);const a=r.x*Math.abs(Ec.x)+r.y*Math.abs(Ec.y)+r.z*Math.abs(Ec.z),l=e.dot(Ec),u=t.dot(Ec),d=n.dot(Ec);if(Math.max(-Math.max(l,u,d),Math.min(l,u,d))>a)return!1}return!0}const b9=new fu,fA=new te,v2=new te;class ac{constructor(e=new te,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):b9.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;sthis.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;fA.subVectors(e,this.center);const t=fA.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(fA,r/n),this.radius+=r}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):(v2.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(fA.copy(e.center).add(v2)),this.expandByPoint(fA.copy(e.center).sub(v2))),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}}const Dl=new te,x2=new te,Wp=new te,Mu=new te,y2=new te,$p=new te,b2=new te;class cp{constructor(e=new te,t=new te(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Dl)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Dl.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Dl.copy(this.origin).addScaledVector(this.direction,t),Dl.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){x2.copy(e).add(t).multiplyScalar(.5),Wp.copy(t).sub(e).normalize(),Mu.copy(this.origin).sub(x2);const s=e.distanceTo(t)*.5,o=-this.direction.dot(Wp),a=Mu.dot(this.direction),l=-Mu.dot(Wp),u=Mu.lengthSq(),d=Math.abs(1-o*o);let A,g,v,x;if(d>0)if(A=o*l-a,g=o*a-l,x=s*d,A>=0)if(g>=-x)if(g<=x){const T=1/d;A*=T,g*=T,v=A*(A+o*g+2*a)+g*(o*A+g+2*l)+u}else g=s,A=Math.max(0,-(o*g+a)),v=-A*A+g*(g+2*l)+u;else g=-s,A=Math.max(0,-(o*g+a)),v=-A*A+g*(g+2*l)+u;else g<=-x?(A=Math.max(0,-(-o*s+a)),g=A>0?-s:Math.min(Math.max(-s,-l),s),v=-A*A+g*(g+2*l)+u):g<=x?(A=0,g=Math.min(Math.max(-s,-l),s),v=g*(g+2*l)+u):(A=Math.max(0,-(o*s+a)),g=A>0?s:Math.min(Math.max(-s,-l),s),v=-A*A+g*(g+2*l)+u);else g=o>0?-s:s,A=Math.max(0,-(o*g+a)),v=-A*A+g*(g+2*l)+u;return n&&n.copy(this.origin).addScaledVector(this.direction,A),r&&r.copy(x2).addScaledVector(Wp,g),v}intersectSphere(e,t){Dl.subVectors(e.center,this.origin);const n=Dl.dot(this.direction),r=Dl.dot(Dl)-n*n,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,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,r,s,o,a,l;const u=1/this.direction.x,d=1/this.direction.y,A=1/this.direction.z,g=this.origin;return u>=0?(n=(e.min.x-g.x)*u,r=(e.max.x-g.x)*u):(n=(e.max.x-g.x)*u,r=(e.min.x-g.x)*u),d>=0?(s=(e.min.y-g.y)*d,o=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-g.z)*A,l=(e.max.z-g.z)*A):(a=(e.max.z-g.z)*A,l=(e.min.z-g.z)*A),n>l||a>r)||((a>n||n!==n)&&(n=a),(l=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Dl)!==null}intersectTriangle(e,t,n,r,s){y2.subVectors(t,e),$p.subVectors(n,e),b2.crossVectors(y2,$p);let o=this.direction.dot(b2),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Mu.subVectors(this.origin,e);const l=a*this.direction.dot($p.crossVectors(Mu,$p));if(l<0)return null;const u=a*this.direction.dot(y2.cross(Mu));if(u<0||l+u>o)return null;const d=-a*Mu.dot(b2);return d<0?null:this.at(d/o,s)}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 gn{constructor(e,t,n,r,s,o,a,l,u,d,A,g,v,x,T,S){gn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,l,u,d,A,g,v,x,T,S)}set(e,t,n,r,s,o,a,l,u,d,A,g,v,x,T,S){const w=this.elements;return w[0]=e,w[4]=t,w[8]=n,w[12]=r,w[1]=s,w[5]=o,w[9]=a,w[13]=l,w[2]=u,w[6]=d,w[10]=A,w[14]=g,w[3]=v,w[7]=x,w[11]=T,w[15]=S,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new gn().fromArray(this.elements)}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],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,r=1/Xh.setFromMatrixColumn(e,0).length(),s=1/Xh.setFromMatrixColumn(e,1).length(),o=1/Xh.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(r),u=Math.sin(r),d=Math.cos(s),A=Math.sin(s);if(e.order==="XYZ"){const g=o*d,v=o*A,x=a*d,T=a*A;t[0]=l*d,t[4]=-l*A,t[8]=u,t[1]=v+x*u,t[5]=g-T*u,t[9]=-a*l,t[2]=T-g*u,t[6]=x+v*u,t[10]=o*l}else if(e.order==="YXZ"){const g=l*d,v=l*A,x=u*d,T=u*A;t[0]=g+T*a,t[4]=x*a-v,t[8]=o*u,t[1]=o*A,t[5]=o*d,t[9]=-a,t[2]=v*a-x,t[6]=T+g*a,t[10]=o*l}else if(e.order==="ZXY"){const g=l*d,v=l*A,x=u*d,T=u*A;t[0]=g-T*a,t[4]=-o*A,t[8]=x+v*a,t[1]=v+x*a,t[5]=o*d,t[9]=T-g*a,t[2]=-o*u,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const g=o*d,v=o*A,x=a*d,T=a*A;t[0]=l*d,t[4]=x*u-v,t[8]=g*u+T,t[1]=l*A,t[5]=T*u+g,t[9]=v*u-x,t[2]=-u,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const g=o*l,v=o*u,x=a*l,T=a*u;t[0]=l*d,t[4]=T-g*A,t[8]=x*A+v,t[1]=A,t[5]=o*d,t[9]=-a*d,t[2]=-u*d,t[6]=v*A+x,t[10]=g-T*A}else if(e.order==="XZY"){const g=o*l,v=o*u,x=a*l,T=a*u;t[0]=l*d,t[4]=-A,t[8]=u*d,t[1]=g*A+T,t[5]=o*d,t[9]=v*A-x,t[2]=x*A-v,t[6]=a*d,t[10]=T*A+g}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(S9,e,T9)}lookAt(e,t,n){const r=this.elements;return vo.subVectors(e,t),vo.lengthSq()===0&&(vo.z=1),vo.normalize(),Eu.crossVectors(n,vo),Eu.lengthSq()===0&&(Math.abs(n.z)===1?vo.x+=1e-4:vo.z+=1e-4,vo.normalize(),Eu.crossVectors(n,vo)),Eu.normalize(),jp.crossVectors(vo,Eu),r[0]=Eu.x,r[4]=jp.x,r[8]=vo.x,r[1]=Eu.y,r[5]=jp.y,r[9]=vo.y,r[2]=Eu.z,r[6]=jp.z,r[10]=vo.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],u=n[12],d=n[1],A=n[5],g=n[9],v=n[13],x=n[2],T=n[6],S=n[10],w=n[14],C=n[3],E=n[7],N=n[11],L=n[15],B=r[0],I=r[4],F=r[8],P=r[12],O=r[1],G=r[5],q=r[9],j=r[13],Y=r[2],$=r[6],Q=r[10],ee=r[14],ue=r[3],le=r[7],de=r[11],Te=r[15];return s[0]=o*B+a*O+l*Y+u*ue,s[4]=o*I+a*G+l*$+u*le,s[8]=o*F+a*q+l*Q+u*de,s[12]=o*P+a*j+l*ee+u*Te,s[1]=d*B+A*O+g*Y+v*ue,s[5]=d*I+A*G+g*$+v*le,s[9]=d*F+A*q+g*Q+v*de,s[13]=d*P+A*j+g*ee+v*Te,s[2]=x*B+T*O+S*Y+w*ue,s[6]=x*I+T*G+S*$+w*le,s[10]=x*F+T*q+S*Q+w*de,s[14]=x*P+T*j+S*ee+w*Te,s[3]=C*B+E*O+N*Y+L*ue,s[7]=C*I+E*G+N*$+L*le,s[11]=C*F+E*q+N*Q+L*de,s[15]=C*P+E*j+N*ee+L*Te,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],o=e[1],a=e[5],l=e[9],u=e[13],d=e[2],A=e[6],g=e[10],v=e[14],x=e[3],T=e[7],S=e[11],w=e[15],C=l*v-u*g,E=a*v-u*A,N=a*g-l*A,L=o*v-u*d,B=o*g-l*d,I=o*A-a*d;return t*(T*C-S*E+w*N)-n*(x*C-S*L+w*B)+r*(x*E-T*L+w*I)-s*(x*N-T*B+S*I)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],d=e[8],A=e[9],g=e[10],v=e[11],x=e[12],T=e[13],S=e[14],w=e[15],C=A*S*u-T*g*u+T*l*v-a*S*v-A*l*w+a*g*w,E=x*g*u-d*S*u-x*l*v+o*S*v+d*l*w-o*g*w,N=d*T*u-x*A*u+x*a*v-o*T*v-d*a*w+o*A*w,L=x*A*l-d*T*l-x*a*g+o*T*g+d*a*S-o*A*S,B=t*C+n*E+r*N+s*L;if(B===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/B;return e[0]=C*I,e[1]=(T*g*s-A*S*s-T*r*v+n*S*v+A*r*w-n*g*w)*I,e[2]=(a*S*s-T*l*s+T*r*u-n*S*u-a*r*w+n*l*w)*I,e[3]=(A*l*s-a*g*s-A*r*u+n*g*u+a*r*v-n*l*v)*I,e[4]=E*I,e[5]=(d*S*s-x*g*s+x*r*v-t*S*v-d*r*w+t*g*w)*I,e[6]=(x*l*s-o*S*s-x*r*u+t*S*u+o*r*w-t*l*w)*I,e[7]=(o*g*s-d*l*s+d*r*u-t*g*u-o*r*v+t*l*v)*I,e[8]=N*I,e[9]=(x*A*s-d*T*s-x*n*v+t*T*v+d*n*w-t*A*w)*I,e[10]=(o*T*s-x*a*s+x*n*u-t*T*u-o*n*w+t*a*w)*I,e[11]=(d*a*s-o*A*s-d*n*u+t*A*u+o*n*v-t*a*v)*I,e[12]=L*I,e[13]=(d*T*r-x*A*r+x*n*g-t*T*g-d*n*S+t*A*S)*I,e[14]=(x*a*r-o*T*r-x*n*l+t*T*l+o*n*S-t*a*S)*I,e[15]=(o*A*r-d*a*r+d*n*l-t*A*l-o*n*g+t*a*g)*I,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,u=s*o,d=s*a;return this.set(u*o+n,u*a-r*l,u*l+r*a,0,u*a+r*l,d*a+n,d*l-r*o,0,u*l-r*a,d*l+r*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,u=s+s,d=o+o,A=a+a,g=s*u,v=s*d,x=s*A,T=o*d,S=o*A,w=a*A,C=l*u,E=l*d,N=l*A,L=n.x,B=n.y,I=n.z;return r[0]=(1-(T+w))*L,r[1]=(v+N)*L,r[2]=(x-E)*L,r[3]=0,r[4]=(v-N)*B,r[5]=(1-(g+w))*B,r[6]=(S+C)*B,r[7]=0,r[8]=(x+E)*I,r[9]=(S-C)*I,r[10]=(1-(g+T))*I,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;if(e.x=r[12],e.y=r[13],e.z=r[14],this.determinant()===0)return n.set(1,1,1),t.identity(),this;let s=Xh.set(r[0],r[1],r[2]).length();const o=Xh.set(r[4],r[5],r[6]).length(),a=Xh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),oa.copy(this);const u=1/s,d=1/o,A=1/a;return oa.elements[0]*=u,oa.elements[1]*=u,oa.elements[2]*=u,oa.elements[4]*=d,oa.elements[5]*=d,oa.elements[6]*=d,oa.elements[8]*=A,oa.elements[9]*=A,oa.elements[10]*=A,t.setFromRotationMatrix(oa),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=Ws,l=!1){const u=this.elements,d=2*s/(t-e),A=2*s/(n-r),g=(t+e)/(t-e),v=(n+r)/(n-r);let x,T;if(l)x=s/(o-s),T=o*s/(o-s);else if(a===Ws)x=-(o+s)/(o-s),T=-2*o*s/(o-s);else if(a===Xo)x=-o/(o-s),T=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=A,u[9]=v,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=T,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,o,a=Ws,l=!1){const u=this.elements,d=2/(t-e),A=2/(n-r),g=-(t+e)/(t-e),v=-(n+r)/(n-r);let x,T;if(l)x=1/(o-s),T=o/(o-s);else if(a===Ws)x=-2/(o-s),T=-(o+s)/(o-s);else if(a===Xo)x=-1/(o-s),T=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=A,u[9]=0,u[13]=v,u[2]=0,u[6]=0,u[10]=x,u[14]=T,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;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[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Xh=new te,oa=new gn,S9=new te(0,0,0),T9=new te(1,1,1),Eu=new te,jp=new te,vo=new te,pw=new gn,mw=new Sa;class fs{constructor(e=0,t=0,n=0,r=fs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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 order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],l=r[1],u=r[5],d=r[9],A=r[2],g=r[6],v=r[10];switch(t){case"XYZ":this._y=Math.asin(Sn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,v),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Sn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,v),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-A,s),this._z=0);break;case"ZXY":this._x=Math.asin(Sn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-A,v),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Sn(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(g,v),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Sn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-A,s)):(this._x=0,this._y=Math.atan2(a,v));break;case"XZY":this._z=Math.asin(-Sn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-d,v),this._y=0);break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return pw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pw,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return mw.setFromEuler(this),this.setFromQuaternion(mw,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[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._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fs.DEFAULT_ORDER="XYZ";class Ab{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(a=>({...a})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let u=0,d=l.length;u0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),u.length>0&&(n.textures=u),d.length>0&&(n.images=d),A.length>0&&(n.shapes=A),g.length>0&&(n.skeletons=g),v.length>0&&(n.animations=v),x.length>0&&(n.nodes=x)}return n.object=r,n;function o(a){const l=[];for(const u in a){const d=a[u];delete d.metadata,l.push(d)}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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){aa.subVectors(r,t),Il.subVectors(n,t),T2.subVectors(e,t);const o=aa.dot(aa),a=aa.dot(Il),l=aa.dot(T2),u=Il.dot(Il),d=Il.dot(T2),A=o*u-a*a;if(A===0)return s.set(0,0,0),null;const g=1/A,v=(u*l-a*d)*g,x=(o*d-a*l)*g;return s.set(1-v-x,x,v)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Bl)===null?!1:Bl.x>=0&&Bl.y>=0&&Bl.x+Bl.y<=1}static getInterpolation(e,t,n,r,s,o,a,l){return this.getBarycoord(e,t,n,r,Bl)===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(s,Bl.x),l.addScaledVector(o,Bl.y),l.addScaledVector(a,Bl.z),l)}static getInterpolatedAttribute(e,t,n,r,s,o){return C2.setScalar(0),R2.setScalar(0),N2.setScalar(0),C2.fromBufferAttribute(e,t),R2.fromBufferAttribute(e,n),N2.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(C2,s.x),o.addScaledVector(R2,s.y),o.addScaledVector(N2,s.z),o}static isFrontFacing(e,t,n,r){return aa.subVectors(n,t),Il.subVectors(e,t),aa.cross(Il).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 aa.subVectors(this.c,this.b),Il.subVectors(this.a,this.b),aa.cross(Il).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Aa.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Aa.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Aa.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Aa.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Aa.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let o,a;Kh.subVectors(r,n),Zh.subVectors(s,n),w2.subVectors(e,n);const l=Kh.dot(w2),u=Zh.dot(w2);if(l<=0&&u<=0)return t.copy(n);M2.subVectors(e,r);const d=Kh.dot(M2),A=Zh.dot(M2);if(d>=0&&A<=d)return t.copy(r);const g=l*A-d*u;if(g<=0&&l>=0&&d<=0)return o=l/(l-d),t.copy(n).addScaledVector(Kh,o);E2.subVectors(e,s);const v=Kh.dot(E2),x=Zh.dot(E2);if(x>=0&&v<=x)return t.copy(s);const T=v*u-l*x;if(T<=0&&u>=0&&x<=0)return a=u/(u-x),t.copy(n).addScaledVector(Zh,a);const S=d*x-v*A;if(S<=0&&A-d>=0&&v-x>=0)return bw.subVectors(s,r),a=(A-d)/(A-d+(v-x)),t.copy(r).addScaledVector(bw,a);const w=1/(S+T+g);return o=T*w,a=g*w,t.copy(n).addScaledVector(Kh,o).addScaledVector(Zh,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const lR={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},Cu={h:0,s:0,l:0},Qp={h:0,s:0,l:0};function P2(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let Gt=class{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 r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=as){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ln.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ln.workingColorSpace){return this.r=e,this.g=t,this.b=n,ln.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ln.workingColorSpace){if(e=hb(e,1),t=Sn(t,0,1),n=Sn(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=P2(o,s,e+1/3),this.g=P2(o,s,e),this.b=P2(o,s,e-1/3)}return ln.colorSpaceToWorking(this,r),this}setStyle(e,t=as){function n(s){s!==void 0&&parseFloat(s)<1&&Ue("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=as){const n=lR[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ue("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=jl(e.r),this.g=jl(e.g),this.b=jl(e.b),this}copyLinearToSRGB(e){return this.r=Vf(e.r),this.g=Vf(e.g),this.b=Vf(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=as){return ln.workingToColorSpace(vs.copy(this),e),Math.round(Sn(vs.r*255,0,255))*65536+Math.round(Sn(vs.g*255,0,255))*256+Math.round(Sn(vs.b*255,0,255))}getHexString(e=as){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ln.workingColorSpace){ln.workingToColorSpace(vs.copy(this),t);const n=vs.r,r=vs.g,s=vs.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let l,u;const d=(a+o)/2;if(a===o)l=0,u=0;else{const A=o-a;switch(u=d<=.5?A/(o+a):A/(2-o-a),o){case n:l=(r-s)/A+(r0!=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){Ue(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.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!==js&&(n.blending=this.blending),this.side!==No&&(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!==g0&&(n.blendSrc=this.blendSrc),this.blendDst!==_0&&(n.blendDst=this.blendDst),this.blendEquation!==bs&&(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!==tc&&(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!==sx&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qc&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qc&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qc&&(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 r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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 r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].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 no extends Cs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Gt(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 fs,this.combine=rp,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 Gl=N9();function N9(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const u=l-127;u<-27?(n[l]=0,n[l|256]=32768,r[l]=24,r[l|256]=24):u<-14?(n[l]=1024>>-u-14,n[l|256]=1024>>-u-14|32768,r[l]=-u-1,r[l|256]=-u-1):u<=15?(n[l]=u+15<<10,n[l|256]=u+15<<10|32768,r[l]=13,r[l|256]=13):u<128?(n[l]=31744,n[l|256]=64512,r[l]=24,r[l|256]=24):(n[l]=31744,n[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,d=0;for(;!(u&8388608);)u<<=1,d-=8388608;u&=-8388609,d+=947912704,s[l]=u|d}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function xo(i){Math.abs(i)>65504&&Ue("DataUtils.toHalfFloat(): Value out of range."),i=Sn(i,-65504,65504),Gl.floatView[0]=i;const e=Gl.uint32View[0],t=e>>23&511;return Gl.baseTable[t]+((e&8388607)>>Gl.shiftTable[t])}function Yp(i){const e=i>>10;return Gl.uint32View[0]=Gl.mantissaTable[Gl.offsetTable[e]+(i&1023)]+Gl.exponentTable[e],Gl.floatView[0]}const Cr=new te,Kp=new qe;let P9=0;class Ji{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:P9++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=wd,this.updateRanges=[],this.gpuType=dr,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 r=0,s=this.itemSize;rt.count&&Ue("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 fu);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new te(-1/0,-1/0,-1/0),new te(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const u in l)l[u]!==void 0&&(e[u]=l[u]);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 u=n[l];e.data.attributes[l]=u.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const u=this.morphAttributes[l],d=[];for(let A=0,g=u.length;A0&&(r[l]=d,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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 r=e.attributes;for(const u in r){const d=r[u];this.setAttribute(u,d.clone(t))}const s=e.morphAttributes;for(const u in s){const d=[],A=s[u];for(let g=0,v=A.length;g0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(Sw.copy(s).invert(),Cc.copy(e.ray).applyMatrix4(Sw),!(n.boundingBox!==null&&Cc.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Cc)))}_computeIntersections(e,t,n){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,A=s.attributes.normal,g=s.groups,v=s.drawRange;if(a!==null)if(Array.isArray(o))for(let x=0,T=g.length;xt.far?null:{distance:u,point:im.clone(),object:i}}function rm(i,e,t,n,r,s,o,a,l,u){i.getVertexPosition(a,Jp),i.getVertexPosition(l,em),i.getVertexPosition(u,tm);const d=L9(i,e,t,n,Jp,em,tm,ww);if(d){const A=new te;Aa.getBarycoord(ww,Jp,em,tm,A),r&&(d.uv=Aa.getInterpolatedAttribute(r,a,l,u,A,new qe)),s&&(d.uv1=Aa.getInterpolatedAttribute(s,a,l,u,A,new qe)),o&&(d.normal=Aa.getInterpolatedAttribute(o,a,l,u,A,new te),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const g={a,b:l,c:u,normal:new te,materialIndex:0};Aa.getNormal(Jp,em,tm,g.normal),d.face=g,d.barycoord=A}return d}class lc extends ui{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const l=[],u=[],d=[],A=[];let g=0,v=0;x("z","y","x",-1,-1,n,t,e,o,s,0),x("z","y","x",1,-1,n,t,-e,o,s,1),x("x","z","y",1,1,e,n,t,r,o,2),x("x","z","y",1,-1,e,n,-t,r,o,3),x("x","y","z",1,-1,e,t,n,r,s,4),x("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Jn(u,3)),this.setAttribute("normal",new Jn(d,3)),this.setAttribute("uv",new Jn(A,2));function x(T,S,w,C,E,N,L,B,I,F,P){const O=N/I,G=L/F,q=N/2,j=L/2,Y=B/2,$=I+1,Q=F+1;let ee=0,ue=0;const le=new te;for(let de=0;de0?1:-1,d.push(le.x,le.y,le.z),A.push(Qe/I),A.push(1-de/F),ee+=1}}for(let de=0;de0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class hp extends ji{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new gn,this.projectionMatrix=new gn,this.projectionMatrixInverse=new gn,this.coordinateSystem=Ws,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ru=new te,Mw=new qe,Ew=new qe;class Xr extends hp{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=_h*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(t0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _h*2*Math.atan(Math.tan(t0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ru.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ru.x,Ru.y).multiplyScalar(-e/Ru.z),Ru.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ru.x,Ru.y).multiplyScalar(-e/Ru.z)}getViewSize(e,t){return this.getViewBounds(e,Mw,Ew),t.subVectors(Ew,Mw)}setViewOffset(e,t,n,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(t0*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,u=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*n/u,r*=o.width/l,n*=o.height/u}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ef=-90,tf=1;class hR extends ji{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Xr(ef,tf,e,t);r.layers=this.layers,this.add(r);const s=new Xr(ef,tf,e,t);s.layers=this.layers,this.add(s);const o=new Xr(ef,tf,e,t);o.layers=this.layers,this.add(o);const a=new Xr(ef,tf,e,t);a.layers=this.layers,this.add(a);const l=new Xr(ef,tf,e,t);l.layers=this.layers,this.add(l);const u=new Xr(ef,tf,e,t);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,l]=t;for(const u of t)this.remove(u);if(e===Ws)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Xo)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.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 u of t)this.add(u),u.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,u,d]=this.children,A=e.getRenderTarget(),g=e.getActiveCubeFace(),v=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const T=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,o),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,u),n.texture.generateMipmaps=T,e.setRenderTarget(n,5,r),e.render(t,d),e.setRenderTarget(A,g,v),e.xr.enabled=x,n.texture.needsPMREMUpdate=!0}}class fp extends Dr{constructor(e=[],t=ba,n,r,s,o,a,l,u,d){super(e,t,n,r,s,o,a,l,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class gb extends xa{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new fp(r),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 ); + + } + `},r=new lc(5,5,5),s=new Rs({name:"CubemapFromEquirect",uniforms:Ed(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ai,blending:$s});s.uniforms.tEquirect.value=t;const o=new si(r,s),a=t.minFilter;return t.minFilter===ro&&(t.minFilter=ki),new hR(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}}let so=class extends ji{constructor(){super(),this.isGroup=!0,this.type="Group"}};const F9={type:"move"};class Ag{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new so,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new so,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new te,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new te),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new so,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new te,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new te),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,u=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const T of e.hand.values()){const S=t.getJointPose(T,n),w=this._getHandJoint(u,T);S!==null&&(w.matrix.fromArray(S.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),w.matrixWorldNeedsUpdate=!0,w.jointRadius=S.radius),w.visible=S!==null}const d=u.joints["index-finger-tip"],A=u.joints["thumb-tip"],g=d.position.distanceTo(A.position),v=.02,x=.005;u.inputState.pinching&&g>v+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=v-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(F9)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new so;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class $1 extends ji{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fs,this.environmentIntensity=1,this.environmentRotation=new fs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(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}}class _b{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=wd,this.updateRanges=[],this.version=0,this.uuid=al()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}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||V9.getNormalMatrix(e),r=this.coplanarPoint(I2).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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 Rc=new ac,G9=new qe(.5,.5),sm=new te;class $d{constructor(e=new Ka,t=new Ka,n=new Ka,r=new Ka,s=new Ka,o=new Ka){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),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=Ws,n=!1){const r=this.planes,s=e.elements,o=s[0],a=s[1],l=s[2],u=s[3],d=s[4],A=s[5],g=s[6],v=s[7],x=s[8],T=s[9],S=s[10],w=s[11],C=s[12],E=s[13],N=s[14],L=s[15];if(r[0].setComponents(u-o,v-d,w-x,L-C).normalize(),r[1].setComponents(u+o,v+d,w+x,L+C).normalize(),r[2].setComponents(u+a,v+A,w+T,L+E).normalize(),r[3].setComponents(u-a,v-A,w-T,L-E).normalize(),n)r[4].setComponents(l,g,S,N).normalize(),r[5].setComponents(u-l,v-g,w-S,L-N).normalize();else if(r[4].setComponents(u-l,v-g,w-S,L-N).normalize(),t===Ws)r[5].setComponents(u+l,v+g,w+S,L+N).normalize();else if(t===Xo)r[5].setComponents(l,g,S,N).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(),Rc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Rc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rc)}intersectsSprite(e){Rc.center.set(0,0,0);const t=G9.distanceTo(e.center);return Rc.radius=.7071067811865476+t,Rc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rc)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,sm.y=r.normal.y>0?e.max.y:e.min.y,sm.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(sm)<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 ka=new gn,Va=new $d;class xb{constructor(){this.coordinateSystem=Ws}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sn)return;B2.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(B2);if(!(ue.far))return{distance:u,point:Rw.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}const Nw=new te,Pw=new te;class fR extends j1{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 r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:u,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class bb extends Dr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=xi,this.minFilter=xi,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ms extends Dr{constructor(e,t,n=vi,r,s,o,a=xi,l=xi,u,d=hs,A=1){if(d!==hs&&d!==zs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:t,depth:A};super(g,r,s,o,a,l,d,n,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new fb(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 dR extends Ms{constructor(e,t=vi,n=ba,r,s,o=xi,a=xi,l,u=hs){const d={width:e,height:e,depth:1},A=[d,d,d,d,d,d];super(e,e,t,n,r,s,o,a,l,u),this.image=A,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class AR extends Dr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class X1 extends ui{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],o=[],a=[],l=[],u=new te,d=new qe;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let A=0,g=3;A<=t;A++,g+=3){const v=n+A/t*r;u.x=e*Math.cos(v),u.y=e*Math.sin(v),o.push(u.x,u.y,u.z),a.push(0,0,1),d.x=(o[g]/e+1)/2,d.y=(o[g+1]/e+1)/2,l.push(d.x,d.y)}for(let A=1;A<=t;A++)s.push(A,A+1,0);this.setIndex(s),this.setAttribute("position",new Jn(o,3)),this.setAttribute("normal",new Jn(a,3)),this.setAttribute("uv",new Jn(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new X1(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Q1 extends ui{constructor(e=1,t=1,n=1,r=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const u=this;r=Math.floor(r),s=Math.floor(s);const d=[],A=[],g=[],v=[];let x=0;const T=[],S=n/2;let w=0;C(),o===!1&&(e>0&&E(!0),t>0&&E(!1)),this.setIndex(d),this.setAttribute("position",new Jn(A,3)),this.setAttribute("normal",new Jn(g,3)),this.setAttribute("uv",new Jn(v,2));function C(){const N=new te,L=new te;let B=0;const I=(t-e)/n;for(let F=0;F<=s;F++){const P=[],O=F/s,G=O*(t-e)+e;for(let q=0;q<=r;q++){const j=q/r,Y=j*l+a,$=Math.sin(Y),Q=Math.cos(Y);L.x=G*$,L.y=-O*n+S,L.z=G*Q,A.push(L.x,L.y,L.z),N.set($,I,Q).normalize(),g.push(N.x,N.y,N.z),v.push(j,1-O),P.push(x++)}T.push(P)}for(let F=0;F0||P!==0)&&(d.push(O,G,j),B+=3),(t>0||P!==s-1)&&(d.push(G,q,j),B+=3)}u.addGroup(w,B,0),w+=B}function E(N){const L=x,B=new qe,I=new te;let F=0;const P=N===!0?e:t,O=N===!0?1:-1;for(let q=1;q<=r;q++)A.push(0,S*O,0),g.push(0,O,0),v.push(.5,.5),x++;const G=x;for(let q=0;q<=r;q++){const Y=q/r*l+a,$=Math.cos(Y),Q=Math.sin(Y);I.x=P*Q,I.y=S*O,I.z=P*$,A.push(I.x,I.y,I.z),g.push(0,O,0),B.x=$*.5+.5,B.y=Q*.5*O+.5,v.push(B.x,B.y),x++}for(let q=0;q0)l=r-1;else{l=r;break}if(r=l,n[r]===o)return r/(s-1);const d=n[r],g=n[r+1]-d,v=(o-d)/g;return(r+v)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),l=t||(o.isVector2?new qe:new te);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new te,r=[],s=[],o=[],a=new te,l=new gn;for(let v=0;v<=e;v++){const x=v/e;r[v]=this.getTangentAt(x,new te)}s[0]=new te,o[0]=new te;let u=Number.MAX_VALUE;const d=Math.abs(r[0].x),A=Math.abs(r[0].y),g=Math.abs(r[0].z);d<=u&&(u=d,n.set(1,0,0)),A<=u&&(u=A,n.set(0,1,0)),g<=u&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let v=1;v<=e;v++){if(s[v]=s[v-1].clone(),o[v]=o[v-1].clone(),a.crossVectors(r[v-1],r[v]),a.length()>Number.EPSILON){a.normalize();const x=Math.acos(Sn(r[v-1].dot(r[v]),-1,1));s[v].applyMatrix4(l.makeRotationAxis(a,x))}o[v].crossVectors(r[v],s[v])}if(t===!0){let v=Math.acos(Sn(s[0].dot(s[e]),-1,1));v/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(v=-v);for(let x=1;x<=e;x++)s[x].applyMatrix4(l.makeRotationAxis(r[x],v*x)),o[x].crossVectors(r[x],s[x])}return{tangents:r,normals:s,binormals:o}}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 Sb extends Ia{constructor(e=0,t=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new qe){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,d;this.closed||a>0?u=r[(a-1)%s]:(cm.subVectors(r[0],r[1]).add(r[0]),u=cm);const A=r[a%s],g=r[(a+1)%s];if(this.closed||a+2r.length-2?r.length-1:o+1],A=r[o>r.length-3?r.length-1:o+2];return n.set(Iw(a,l.x,u.x,d.x,A.x),Iw(a,l.y,u.y,d.y,A.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const o=r[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,t)}s++}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,r=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 A=u.getPoint(0);A.equals(this.currentPoint)||this.lineTo(A.x,A.y)}this.curves.push(u);const d=u.getPoint(1);return this.currentPoint.copy(d),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 pg extends ax{constructor(e){super(e),this.uuid=al(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n80*t){a=i[0],l=i[1];let d=a,A=l;for(let g=t;gd&&(d=v),x>A&&(A=x)}u=Math.max(d-a,A-l),u=u!==0?32767/u:0}return D0(s,o,t,a,l,u,0),o}function yR(i,e,t,n,r){let s;if(r===mU(i,e,t,n)>0)for(let o=e;o=e;o-=n)s=Bw(o/n|0,i[o],i[o+1],s);return s&&Cd(s,s.next)&&(I0(s),s=s.next),s}function vh(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Cd(t,t.next)||or(t.prev,t,t.next)===0)){if(I0(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function D0(i,e,t,n,r,s,o){if(!i)return;!o&&s&&cU(i,n,r,s);let a=i;for(;i.prev!==i.next;){const l=i.prev,u=i.next;if(s?nU(i,n,r,s):tU(i)){e.push(l.i,i.i,u.i),I0(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=iU(vh(i),e),D0(i,e,t,n,r,s,2)):o===2&&rU(i,e,t,n,r,s):D0(vh(i),e,t,n,r,s,1);break}}}function tU(i){const e=i.prev,t=i,n=i.next;if(or(e,t,n)>=0)return!1;const r=e.x,s=t.x,o=n.x,a=e.y,l=t.y,u=n.y,d=Math.min(r,s,o),A=Math.min(a,l,u),g=Math.max(r,s,o),v=Math.max(a,l,u);let x=n.next;for(;x!==e;){if(x.x>=d&&x.x<=g&&x.y>=A&&x.y<=v&&qA(r,a,s,l,o,u,x.x,x.y)&&or(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function nU(i,e,t,n){const r=i.prev,s=i,o=i.next;if(or(r,s,o)>=0)return!1;const a=r.x,l=s.x,u=o.x,d=r.y,A=s.y,g=o.y,v=Math.min(a,l,u),x=Math.min(d,A,g),T=Math.max(a,l,u),S=Math.max(d,A,g),w=lx(v,x,e,t,n),C=lx(T,S,e,t,n);let E=i.prevZ,N=i.nextZ;for(;E&&E.z>=w&&N&&N.z<=C;){if(E.x>=v&&E.x<=T&&E.y>=x&&E.y<=S&&E!==r&&E!==o&&qA(a,d,l,A,u,g,E.x,E.y)&&or(E.prev,E,E.next)>=0||(E=E.prevZ,N.x>=v&&N.x<=T&&N.y>=x&&N.y<=S&&N!==r&&N!==o&&qA(a,d,l,A,u,g,N.x,N.y)&&or(N.prev,N,N.next)>=0))return!1;N=N.nextZ}for(;E&&E.z>=w;){if(E.x>=v&&E.x<=T&&E.y>=x&&E.y<=S&&E!==r&&E!==o&&qA(a,d,l,A,u,g,E.x,E.y)&&or(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;N&&N.z<=C;){if(N.x>=v&&N.x<=T&&N.y>=x&&N.y<=S&&N!==r&&N!==o&&qA(a,d,l,A,u,g,N.x,N.y)&&or(N.prev,N,N.next)>=0)return!1;N=N.nextZ}return!0}function iU(i,e){let t=i;do{const n=t.prev,r=t.next.next;!Cd(n,r)&&SR(n,t,t.next,r)&&L0(n,r)&&L0(r,n)&&(e.push(n.i,t.i,r.i),I0(t),I0(t.next),t=i=r),t=t.next}while(t!==i);return vh(t)}function rU(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&dU(o,a)){let l=TR(o,a);o=vh(o,o.next),l=vh(l,l.next),D0(o,e,t,n,r,s,0),D0(l,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function sU(i,e,t,n){const r=[];for(let s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const A=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(A<=n&&A>s&&(s=A,o=t.x=t.x&&t.x>=l&&n!==t.x&&bR(ro.x||t.x===o.x&&uU(o,t)))&&(o=t,d=A)}t=t.next}while(t!==a);return o}function uU(i,e){return or(i.prev,i,e.prev)<0&&or(e.next,i,i.next)<0}function cU(i,e,t,n){let r=i;do r.z===0&&(r.z=lx(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,hU(r)}function hU(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let u=0;u0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=o}s.nextZ=null,t*=2}while(e>1);return i}function lx(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function fU(i){let e=i,t=i;do(e.x=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function qA(i,e,t,n,r,s,o,a){return!(i===o&&e===a)&&bR(i,e,t,n,r,s,o,a)}function dU(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!AU(i,e)&&(L0(i,e)&&L0(e,i)&&pU(i,e)&&(or(i.prev,i,e.prev)||or(i,e.prev,e))||Cd(i,e)&&or(i.prev,i,i.next)>0&&or(e.prev,e,e.next)>0)}function or(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Cd(i,e){return i.x===e.x&&i.y===e.y}function SR(i,e,t,n){const r=fm(or(i,e,t)),s=fm(or(i,e,n)),o=fm(or(t,n,i)),a=fm(or(t,n,e));return!!(r!==s&&o!==a||r===0&&hm(i,t,e)||s===0&&hm(i,n,e)||o===0&&hm(t,i,n)||a===0&&hm(t,e,n))}function hm(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function fm(i){return i>0?1:i<0?-1:0}function AU(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&SR(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function L0(i,e){return or(i.prev,i,i.next)<0?or(i,e,i.next)>=0&&or(i,i.prev,e)>=0:or(i,e,i.prev)<0||or(i,i.next,e)<0}function pU(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function TR(i,e){const t=ux(i.i,i.x,i.y),n=ux(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Bw(i,e,t,n){const r=ux(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function I0(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ux(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function mU(i,e,t,n){let r=0;for(let s=e,o=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function Fw(i,e){for(let t=0;tNumber.EPSILON){const Le=Math.sqrt(H),$e=Math.sqrt(ft*ft+ie*ie),De=tt.x-jt/Le,Ht=tt.y+St/Le,mt=Ve.x-ie/$e,Ot=Ve.y+ft/$e,Qt=((mt-De)*ie-(Ot-Ht)*ft)/(St*ie-jt*ft);pt=De+St*Qt-Oe.x,ae=Ht+jt*Qt-Oe.y;const it=pt*pt+ae*ae;if(it<=2)return new qe(pt,ae);tn=Math.sqrt(it/2)}else{let Le=!1;St>Number.EPSILON?ft>Number.EPSILON&&(Le=!0):St<-Number.EPSILON?ft<-Number.EPSILON&&(Le=!0):Math.sign(jt)===Math.sign(ie)&&(Le=!0),Le?(pt=-jt,ae=St,tn=Math.sqrt(H)):(pt=St,ae=jt,tn=Math.sqrt(H/2))}return new qe(pt/tn,ae/tn)}const le=[];for(let Oe=0,tt=$.length,Ve=tt-1,pt=Oe+1;Oe=0;Oe--){const tt=Oe/S,Ve=v*Math.cos(tt*Math.PI/2),pt=x*Math.sin(tt*Math.PI/2)+T;for(let ae=0,tn=$.length;ae=0;){const pt=Ve;let ae=Ve-1;ae<0&&(ae=Oe.length-1);for(let tn=0,St=d+S*2;tn0)&&v.push(E,N,B),(w!==n-1||l0!=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 MR extends Cs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Gt(16777215),this.specular=new Gt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new qe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fs,this.combine=rp,this.reflectivity=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.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 TU extends Cs{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Gt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new qe(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 wU extends Cs{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new qe(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 du extends Cs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Gt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new qe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fs,this.combine=rp,this.reflectivity=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.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 MU extends Cs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=OB,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 EU extends Cs{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 CU extends Cs{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Gt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ol,this.normalScale=new qe(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 RU extends jd{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}}const k2={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class NU{constructor(e,t,n){const r=this;let s=!1,o=0,a=0,l;const u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(d){a++,s===!1&&r.onStart!==void 0&&r.onStart(d,o,a),s=!0},this.itemEnd=function(d){o++,r.onProgress!==void 0&&r.onProgress(d,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,A){return u.push(d,A),this},this.removeHandler=function(d){const A=u.indexOf(d);return A!==-1&&u.splice(A,2),this},this.getHandler=function(d){for(let A=0,g=u.length;A1&&(o=1,s=Sn((T-x)/A,0,1))}}return t.copy(a).add(rf.multiplyScalar(s)),n.copy(l).add(sf.multiplyScalar(o)),t.sub(n),t.dot(t)}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)}}class $U{constructor(){this.type="ShapePath",this.color=new Gt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ax,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,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,o){return this.currentPath.bezierCurveTo(e,t,n,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(w){const C=[];for(let E=0,N=w.length;ENumber.EPSILON){if(O<0&&(I=C[B],P=-P,F=C[L],O=-O),w.yF.y)continue;if(w.y===I.y){if(w.x===I.x)return!0}else{const G=O*(w.x-I.x)-P*(w.y-I.y);if(G===0)return!0;if(G<0)continue;N=!N}}else{if(w.y!==I.y)continue;if(F.x<=w.x&&w.x<=I.x||I.x<=w.x&&w.x<=F.x)return!0}}return N}const r=eh.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const u=[];if(s.length===1)return a=s[0],l=new pg,l.curves=a.curves,u.push(l),u;let d=!r(s[0].getPoints());d=e?!d:d;const A=[],g=[];let v=[],x=0,T;g[x]=void 0,v[x]=[];for(let w=0,C=s.length;w1){let w=!1,C=0;for(let E=0,N=g.length;E0&&w===!1&&(v=A)}let S;for(let w=0,C=g.length;wv.start-x.start);let g=0;for(let v=1;v 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`,hF=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,fF=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,dF=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,AF=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,pF=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,mF=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,gF=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,_F=`#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 ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).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`,vF=`#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`,xF=`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; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,yF=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,bF=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,SF=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,TF=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,wF="gl_FragColor = linearToOutputTexel( gl_FragColor );",MF=`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 ); +}`,EF=`#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 = inverseTransformDirection( 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 * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #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`,CF=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,RF=`#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`,NF=`#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`,PF=`#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 = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,DF=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,LF=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,IF=`#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`,BF=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,UF=`#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 +}`,FF=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,OF=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,kF=`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`,VF=`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 = inverseTransformDirection( 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`,GF=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( 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 = inverseTransformDirection( 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`,qF=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,zF=`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`,HF=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,WF=`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`,$F=`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`,jF=`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 ) ); + float v = 0.5 / ( gv + gl ); + return v; + } + 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 + ( vec3( 1.0 ) - 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 ); + } +#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 ); +}`,XF=` +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 +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,QF=`#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #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`,YF=`#if defined( RE_IndirectDiffuse ) + 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`,KF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,ZF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,JF=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,eO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,tO=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,nO=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,iO=`#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`,rO=`#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`,sO=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,oO=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,aO=`#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`,lO=`#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`,uO=`#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`,cO=`#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`,hO=`#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`,fO=`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 + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + 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 + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,dO=`#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; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,AO=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,pO=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,mO=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,gO=`#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`,_O=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,vO=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,xO=`#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`,yO=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,bO=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,SO=`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 ) { + return depth * ( near - far ) - near; +} +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 ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,TO=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,wO=`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;`,MO=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,EO=`#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`,CO=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,RO=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,NO=`#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 ) * 6.28318530718; + 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; + 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 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; + 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 ) { + 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 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + 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 ) * 6.28318530718; + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).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 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 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, dp ); + #else + shadow = step( dp, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,PO=`#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`,DO=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + 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`,LO=`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; +}`,IO=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,BO=`#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`,UO=`#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`,FO=`#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`,OO=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,kO=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,VO=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,GO=`#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; }`,qO=`#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 = inverseTransformDirection( 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`,zO=`#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`,HO=`#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`,WO=`#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`,$O=`#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`,jO=`#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 XO=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,QO=`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 +}`,YO=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,KO=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #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 +}`,ZO=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,JO=`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 +}`,ek=`#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; +}`,tk=`#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 +}`,nk=`#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; +}`,ik=`#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 ); +}`,rk=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,sk=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,ok=`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 +}`,ak=`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 +}`,lk=`#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 +}`,uk=`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 +}`,ck=`#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 +}`,hk=`#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 +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 +}`,fk=`#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; +}`,dk=`#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 +}`,Ak=`#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 +}`,pk=`#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 +}`,mk=`#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 +}`,gk=`#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 +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 +}`,_k=`#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 +}`,vk=`#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 +}`,xk=`#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 +}`,yk=`#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 +}`,bk=`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 +}`,Sk=`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 +}`,Tk=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,wk=`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 +}`,Mk=`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 +}`,Ek=`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 +}`,Ln={alphahash_fragment:QU,alphahash_pars_fragment:YU,alphamap_fragment:KU,alphamap_pars_fragment:ZU,alphatest_fragment:JU,alphatest_pars_fragment:eF,aomap_fragment:tF,aomap_pars_fragment:nF,batching_pars_vertex:iF,batching_vertex:rF,begin_vertex:sF,beginnormal_vertex:oF,bsdfs:aF,iridescence_fragment:lF,bumpmap_pars_fragment:uF,clipping_planes_fragment:cF,clipping_planes_pars_fragment:hF,clipping_planes_pars_vertex:fF,clipping_planes_vertex:dF,color_fragment:AF,color_pars_fragment:pF,color_pars_vertex:mF,color_vertex:gF,common:_F,cube_uv_reflection_fragment:vF,defaultnormal_vertex:xF,displacementmap_pars_vertex:yF,displacementmap_vertex:bF,emissivemap_fragment:SF,emissivemap_pars_fragment:TF,colorspace_fragment:wF,colorspace_pars_fragment:MF,envmap_fragment:EF,envmap_common_pars_fragment:CF,envmap_pars_fragment:RF,envmap_pars_vertex:NF,envmap_physical_pars_fragment:GF,envmap_vertex:PF,fog_vertex:DF,fog_pars_vertex:LF,fog_fragment:IF,fog_pars_fragment:BF,gradientmap_pars_fragment:UF,lightmap_pars_fragment:FF,lights_lambert_fragment:OF,lights_lambert_pars_fragment:kF,lights_pars_begin:VF,lights_toon_fragment:qF,lights_toon_pars_fragment:zF,lights_phong_fragment:HF,lights_phong_pars_fragment:WF,lights_physical_fragment:$F,lights_physical_pars_fragment:jF,lights_fragment_begin:XF,lights_fragment_maps:QF,lights_fragment_end:YF,logdepthbuf_fragment:KF,logdepthbuf_pars_fragment:ZF,logdepthbuf_pars_vertex:JF,logdepthbuf_vertex:eO,map_fragment:tO,map_pars_fragment:nO,map_particle_fragment:iO,map_particle_pars_fragment:rO,metalnessmap_fragment:sO,metalnessmap_pars_fragment:oO,morphinstance_vertex:aO,morphcolor_vertex:lO,morphnormal_vertex:uO,morphtarget_pars_vertex:cO,morphtarget_vertex:hO,normal_fragment_begin:fO,normal_fragment_maps:dO,normal_pars_fragment:AO,normal_pars_vertex:pO,normal_vertex:mO,normalmap_pars_fragment:gO,clearcoat_normal_fragment_begin:_O,clearcoat_normal_fragment_maps:vO,clearcoat_pars_fragment:xO,iridescence_pars_fragment:yO,opaque_fragment:bO,packing:SO,premultiplied_alpha_fragment:TO,project_vertex:wO,dithering_fragment:MO,dithering_pars_fragment:EO,roughnessmap_fragment:CO,roughnessmap_pars_fragment:RO,shadowmap_pars_fragment:NO,shadowmap_pars_vertex:PO,shadowmap_vertex:DO,shadowmask_pars_fragment:LO,skinbase_vertex:IO,skinning_pars_vertex:BO,skinning_vertex:UO,skinnormal_vertex:FO,specularmap_fragment:OO,specularmap_pars_fragment:kO,tonemapping_fragment:VO,tonemapping_pars_fragment:GO,transmission_fragment:qO,transmission_pars_fragment:zO,uv_pars_fragment:HO,uv_pars_vertex:WO,uv_vertex:$O,worldpos_vertex:jO,background_vert:XO,background_frag:QO,backgroundCube_vert:YO,backgroundCube_frag:KO,cube_vert:ZO,cube_frag:JO,depth_vert:ek,depth_frag:tk,distance_vert:nk,distance_frag:ik,equirect_vert:rk,equirect_frag:sk,linedashed_vert:ok,linedashed_frag:ak,meshbasic_vert:lk,meshbasic_frag:uk,meshlambert_vert:ck,meshlambert_frag:hk,meshmatcap_vert:fk,meshmatcap_frag:dk,meshnormal_vert:Ak,meshnormal_frag:pk,meshphong_vert:mk,meshphong_frag:gk,meshphysical_vert:_k,meshphysical_frag:vk,meshtoon_vert:xk,meshtoon_frag:yk,points_vert:bk,points_frag:Sk,shadow_vert:Tk,shadow_frag:wk,sprite_vert:Mk,sprite_frag:Ek},Mt={common:{diffuse:{value:new Gt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Cn}},envmap:{envMap:{value:null},envMapRotation:{value:new Cn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Cn},normalScale:{value:new qe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Cn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Gt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Gt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0},uvTransform:{value:new Cn}},sprite:{diffuse:{value:new Gt(16777215)},opacity:{value:1},center:{value:new qe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}}},Js={basic:{uniforms:Bs([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.fog]),vertexShader:Ln.meshbasic_vert,fragmentShader:Ln.meshbasic_frag},lambert:{uniforms:Bs([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new Gt(0)}}]),vertexShader:Ln.meshlambert_vert,fragmentShader:Ln.meshlambert_frag},phong:{uniforms:Bs([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new Gt(0)},specular:{value:new Gt(1118481)},shininess:{value:30}}]),vertexShader:Ln.meshphong_vert,fragmentShader:Ln.meshphong_frag},standard:{uniforms:Bs([Mt.common,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.roughnessmap,Mt.metalnessmap,Mt.fog,Mt.lights,{emissive:{value:new Gt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ln.meshphysical_vert,fragmentShader:Ln.meshphysical_frag},toon:{uniforms:Bs([Mt.common,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.gradientmap,Mt.fog,Mt.lights,{emissive:{value:new Gt(0)}}]),vertexShader:Ln.meshtoon_vert,fragmentShader:Ln.meshtoon_frag},matcap:{uniforms:Bs([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,{matcap:{value:null}}]),vertexShader:Ln.meshmatcap_vert,fragmentShader:Ln.meshmatcap_frag},points:{uniforms:Bs([Mt.points,Mt.fog]),vertexShader:Ln.points_vert,fragmentShader:Ln.points_frag},dashed:{uniforms:Bs([Mt.common,Mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ln.linedashed_vert,fragmentShader:Ln.linedashed_frag},depth:{uniforms:Bs([Mt.common,Mt.displacementmap]),vertexShader:Ln.depth_vert,fragmentShader:Ln.depth_frag},normal:{uniforms:Bs([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,{opacity:{value:1}}]),vertexShader:Ln.meshnormal_vert,fragmentShader:Ln.meshnormal_frag},sprite:{uniforms:Bs([Mt.sprite,Mt.fog]),vertexShader:Ln.sprite_vert,fragmentShader:Ln.sprite_frag},background:{uniforms:{uvTransform:{value:new Cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ln.background_vert,fragmentShader:Ln.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Cn}},vertexShader:Ln.backgroundCube_vert,fragmentShader:Ln.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ln.cube_vert,fragmentShader:Ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ln.equirect_vert,fragmentShader:Ln.equirect_frag},distance:{uniforms:Bs([Mt.common,Mt.displacementmap,{referencePosition:{value:new te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ln.distance_vert,fragmentShader:Ln.distance_frag},shadow:{uniforms:Bs([Mt.lights,Mt.fog,{color:{value:new Gt(0)},opacity:{value:1}}]),vertexShader:Ln.shadow_vert,fragmentShader:Ln.shadow_frag}};Js.physical={uniforms:Bs([Js.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Cn},clearcoatNormalScale:{value:new qe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Cn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Cn},sheen:{value:0},sheenColor:{value:new Gt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Cn},transmissionSamplerSize:{value:new qe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Cn},attenuationDistance:{value:0},attenuationColor:{value:new Gt(0)},specularColor:{value:new Gt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Cn},anisotropyVector:{value:new qe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Cn}}]),vertexShader:Ln.meshphysical_vert,fragmentShader:Ln.meshphysical_frag};const Am={r:0,b:0,g:0},Nc=new fs,Ck=new gn;function Rk(i,e,t,n,r,s,o){const a=new Gt(0);let l=s===!0?0:1,u,d,A=null,g=0,v=null;function x(E){let N=E.isScene===!0?E.background:null;return N&&N.isTexture&&(N=(E.backgroundBlurriness>0?t:e).get(N)),N}function T(E){let N=!1;const L=x(E);L===null?w(a,l):L&&L.isColor&&(w(L,1),N=!0);const B=i.xr.getEnvironmentBlendMode();B==="additive"?n.buffers.color.setClear(0,0,0,1,o):B==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||N)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(E,N){const L=x(N);L&&(L.isCubeTexture||L.mapping===dh)?(d===void 0&&(d=new si(new lc(1,1,1),new Rs({name:"BackgroundCubeMaterial",uniforms:Ed(Js.backgroundCube.uniforms),vertexShader:Js.backgroundCube.vertexShader,fragmentShader:Js.backgroundCube.fragmentShader,side:Ai,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(B,I,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),Nc.copy(N.backgroundRotation),Nc.x*=-1,Nc.y*=-1,Nc.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(Nc.y*=-1,Nc.z*=-1),d.material.uniforms.envMap.value=L,d.material.uniforms.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=N.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Ck.makeRotationFromEuler(Nc)),d.material.toneMapped=ln.getTransfer(L.colorSpace)!==Pt,(A!==L||g!==L.version||v!==i.toneMapping)&&(d.material.needsUpdate=!0,A=L,g=L.version,v=i.toneMapping),d.layers.enableAll(),E.unshift(d,d.geometry,d.material,0,0,null)):L&&L.isTexture&&(u===void 0&&(u=new si(new dp(2,2),new Rs({name:"BackgroundMaterial",uniforms:Ed(Js.background.uniforms),vertexShader:Js.background.vertexShader,fragmentShader:Js.background.fragmentShader,side:No,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(u)),u.material.uniforms.t2D.value=L,u.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,u.material.toneMapped=ln.getTransfer(L.colorSpace)!==Pt,L.matrixAutoUpdate===!0&&L.updateMatrix(),u.material.uniforms.uvTransform.value.copy(L.matrix),(A!==L||g!==L.version||v!==i.toneMapping)&&(u.material.needsUpdate=!0,A=L,g=L.version,v=i.toneMapping),u.layers.enableAll(),E.unshift(u,u.geometry,u.material,0,0,null))}function w(E,N){E.getRGB(Am,cR(i)),n.buffers.color.setClear(Am.r,Am.g,Am.b,N,o)}function C(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,N=1){a.set(E),l=N,w(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,w(a,l)},render:T,addToRenderList:S,dispose:C}}function Nk(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=g(null);let s=r,o=!1;function a(O,G,q,j,Y){let $=!1;const Q=A(j,q,G);s!==Q&&(s=Q,u(s.object)),$=v(O,j,q,Y),$&&x(O,j,q,Y),Y!==null&&e.update(Y,i.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,N(O,G,q,j),Y!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function l(){return i.createVertexArray()}function u(O){return i.bindVertexArray(O)}function d(O){return i.deleteVertexArray(O)}function A(O,G,q){const j=q.wireframe===!0;let Y=n[O.id];Y===void 0&&(Y={},n[O.id]=Y);let $=Y[G.id];$===void 0&&($={},Y[G.id]=$);let Q=$[j];return Q===void 0&&(Q=g(l()),$[j]=Q),Q}function g(O){const G=[],q=[],j=[];for(let Y=0;Y=0){const de=Y[ue];let Te=$[ue];if(Te===void 0&&(ue==="instanceMatrix"&&O.instanceMatrix&&(Te=O.instanceMatrix),ue==="instanceColor"&&O.instanceColor&&(Te=O.instanceColor)),de===void 0||de.attribute!==Te||Te&&de.data!==Te.data)return!0;Q++}return s.attributesNum!==Q||s.index!==j}function x(O,G,q,j){const Y={},$=G.attributes;let Q=0;const ee=q.getAttributes();for(const ue in ee)if(ee[ue].location>=0){let de=$[ue];de===void 0&&(ue==="instanceMatrix"&&O.instanceMatrix&&(de=O.instanceMatrix),ue==="instanceColor"&&O.instanceColor&&(de=O.instanceColor));const Te={};Te.attribute=de,de&&de.data&&(Te.data=de.data),Y[ue]=Te,Q++}s.attributes=Y,s.attributesNum=Q,s.index=j}function T(){const O=s.newAttributes;for(let G=0,q=O.length;G=0){let le=Y[ee];if(le===void 0&&(ee==="instanceMatrix"&&O.instanceMatrix&&(le=O.instanceMatrix),ee==="instanceColor"&&O.instanceColor&&(le=O.instanceColor)),le!==void 0){const de=le.normalized,Te=le.itemSize,Qe=e.get(le);if(Qe===void 0)continue;const Ye=Qe.buffer,Et=Qe.type,at=Qe.bytesPerElement,ve=Et===i.INT||Et===i.UNSIGNED_INT||le.gpuType===jr;if(le.isInterleavedBufferAttribute){const Re=le.data,Je=Re.stride,Ct=le.offset;if(Re.isInstancedInterleavedBuffer){for(let et=0;et0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=t.precision!==void 0?t.precision:"highp";const d=l(u);d!==u&&(Ue("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const A=t.logarithmicDepthBuffer===!0,g=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),v=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_TEXTURE_SIZE),S=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),w=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),N=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=i.getParameter(i.MAX_SAMPLES),B=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:u,logarithmicDepthBuffer:A,reversedDepthBuffer:g,maxTextures:v,maxVertexTextures:x,maxTextureSize:T,maxCubemapSize:S,maxAttributes:w,maxVertexUniforms:C,maxVaryings:E,maxFragmentUniforms:N,maxSamples:L,samples:B}}function Lk(i){const e=this;let t=null,n=0,r=!1,s=!1;const o=new Ka,a=new Cn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(A,g){const v=A.length!==0||g||n!==0||r;return r=g,n=A.length,v},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(A,g){t=d(A,g,0)},this.setState=function(A,g,v){const x=A.clippingPlanes,T=A.clipIntersection,S=A.clipShadows,w=i.get(A);if(!r||x===null||x.length===0||s&&!S)s?d(null):u();else{const C=s?0:n,E=C*4;let N=w.clippingState||null;l.value=N,N=d(x,g,E,v);for(let L=0;L!==E;++L)N[L]=t[L];w.clippingState=N,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=C}};function u(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(A,g,v,x){const T=A!==null?A.length:0;let S=null;if(T!==0){if(S=l.value,x!==!0||S===null){const w=v+T*4,C=g.matrixWorldInverse;a.getNormalMatrix(C),(S===null||S.length0){const u=new gb(l.height);return u.fromEquirectangularTexture(i,o),e.set(o,u),o.addEventListener("dispose",r),t(u.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const $u=4,Ww=[.125,.215,.35,.446,.526,.582],Wc=20,Bk=256,mA=new Xd,$w=new Gt;let q2=null,z2=0,H2=0,W2=!1;const Uk=new te;let jw=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:o=256,position:a=Uk}=s;q2=this._renderer.getRenderTarget(),z2=this._renderer.getActiveCubeFace(),H2=this._renderer.getActiveMipmapLevel(),W2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,l,a),t>0&&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=Yw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Qw(),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?L:0,L,L),A.setRenderTarget(r),w&&A.render(T,l),A.render(e,l)}A.toneMapping=v,A.autoClear=g,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===ba||e.mapping===ml;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Yw()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Qw());const s=r?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;of(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,mA)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;sx-$u?n-x+$u:0),w=4*(this._cubeSize-T);l.envMap.value=e.texture,l.roughness.value=v,l.mipInt.value=x-t,of(s,S,w,3*T,2*T),r.setRenderTarget(s),r.render(a,mA),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-n,of(e,S,w,3*T,2*T),r.setRenderTarget(e),r.render(a,mA)}_blur(e,t,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,a){const l=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&He("blur direction must be either latitudinal or longitudinal!");const d=3,A=this._lodMeshes[r];A.material=u;const g=u.uniforms,v=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*v):2*Math.PI/(2*Wc-1),T=s/x,S=isFinite(s)?1+Math.floor(d*T):Wc;S>Wc&&Ue(`sigmaRadians, ${s}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${Wc}`);const w=[];let C=0;for(let I=0;IE-$u?r-E+$u:0),B=4*(this._cubeSize-N);of(t,L,B,3*N,2*N),l.setRenderTarget(t),l.render(A,mA)}};function Fk(i){const e=[],t=[],n=[];let r=i;const s=i-$u+1+Ww.length;for(let o=0;oi-$u?l=Ww[o-i+$u-1]:o===0&&(l=0),t.push(l);const u=1/(a-2),d=-u,A=1+u,g=[d,d,A,d,A,A,d,d,A,A,d,A],v=6,x=6,T=3,S=2,w=1,C=new Float32Array(T*x*v),E=new Float32Array(S*x*v),N=new Float32Array(w*x*v);for(let B=0;B2?0:-1,P=[I,F,0,I+2/3,F,0,I+2/3,F+1,0,I,F,0,I+2/3,F+1,0,I,F+1,0];C.set(P,T*x*B),E.set(g,S*x*B);const O=[B,B,B,B,B,B];N.set(O,w*x*B)}const L=new ui;L.setAttribute("position",new Ji(C,T)),L.setAttribute("uv",new Ji(E,S)),L.setAttribute("faceIndex",new Ji(N,w)),n.push(new si(L,null)),r>$u&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Xw(i,e,t){const n=new xa(i,e,t);return n.texture.mapping=dh,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function of(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Ok(i,e,t){return new Rs({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bk,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:K1(),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 3.2: Transform view direction to hemisphere configuration + vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); + + // Section 4.1: Orthonormal basis + float lensq = Vh.x * Vh.x + Vh.y * Vh.y; + vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(Vh, 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 + Vh.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)) * Vh; + + // 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:$s,depthTest:!1,depthWrite:!1})}function kk(i,e,t){const n=new Float32Array(Wc),r=new te(0,1,0);return new Rs({name:"SphericalGaussianBlur",defines:{n:Wc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:K1(),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:$s,depthTest:!1,depthWrite:!1})}function Qw(){return new Rs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:K1(),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:$s,depthTest:!1,depthWrite:!1})}function Yw(){return new Rs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:K1(),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:$s,depthTest:!1,depthWrite:!1})}function K1(){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 ); + + } + `}function Vk(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,u=l===Zf||l===Jf,d=l===ba||l===ml;if(u||d){let A=e.get(a);const g=A!==void 0?A.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==g)return t===null&&(t=new jw(i)),A=u?t.fromEquirectangular(a,A):t.fromCubemap(a,A),A.texture.pmremVersion=a.pmremVersion,e.set(a,A),A.texture;if(A!==void 0)return A.texture;{const v=a.image;return u&&v&&v.height>0||d&&v&&r(v)?(t===null&&(t=new jw(i)),A=u?t.fromEquirectangular(a):t.fromCubemap(a),A.texture.pmremVersion=a.pmremVersion,e.set(a,A),a.addEventListener("dispose",s),A.texture):null}}}return a}function r(a){let l=0;const u=6;for(let d=0;de.maxTextureSize&&(B=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);const I=new Float32Array(L*B*4*A),F=new db(I,L,B,A);F.type=dr,F.needsUpdate=!0;const P=N*4;for(let G=0;G + #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}),u=new si(a,l),d=new Xd(-1,1,1,-1,0,1);let A=null,g=null,v=!1,x,T=null,S=[],w=!1;this.setSize=function(C,E){s.setSize(C,E),o.setSize(C,E);for(let N=0;N0&&S[0].isRenderPass===!0;const E=s.width,N=s.height;for(let L=0;L0)return i;const r=e*t;let s=Kw[r];if(s===void 0&&(s=new Float32Array(r),Kw[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function Fr(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=r.concat(s))}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){const a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&n.push(o)}return n}}function iM(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const kV=37297;let VV=0;function GV(i,e){const t=i.split(` +`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o":" "} ${a}: ${t[o]}`)}return n.join(` +`)}const rM=new Cn;function qV(i){ln._getMatrix(rM,ln.workingColorSpace,i);const e=`mat3( ${rM.elements.map(t=>t.toFixed(4))} )`;switch(ln.getTransfer(i)){case Td:return[e,"LinearTransferOETF"];case Pt:return[e,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function sM(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const a=parseInt(o[1]);return t.toUpperCase()+` + +`+s+` + +`+GV(i.getShaderSource(e),a)}else return s}function zV(i,e){const t=qV(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const HV={[Yy]:"Linear",[Ky]:"Reinhard",[Zy]:"Cineon",[Jy]:"ACESFilmic",[eb]:"AgX",[tb]:"Neutral",[rR]:"Custom"};function WV(i,e){const t=HV[e];return t===void 0?(Ue("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const pm=new te;function $V(){ln.getLuminanceCoefficients(pm);const i=pm.x.toFixed(4),e=pm.y.toFixed(4),t=pm.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function jV(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zA).join(` +`)}function XV(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function QV(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function dx(i){return i.replace(YV,ZV)}const KV=new Map;function ZV(i,e){let t=Ln[e];if(t===void 0){const n=KV.get(e);if(n!==void 0)t=Ln[n],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return dx(t)}const JV=/#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 lM(i){return i.replace(JV,eG)}function eG(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(S+=` +`),w=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(zA).join(` +`),w.length>0&&(w+=` +`)):(S=[uM(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+d:"",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.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(zA).join(` +`),w=[uM(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+u:"",t.envMap?"#define "+d:"",t.envMap?"#define "+A:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.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.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||t.batchingColor?"#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.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.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!==ls?"#define TONE_MAPPING":"",t.toneMapping!==ls?Ln.tonemapping_pars_fragment:"",t.toneMapping!==ls?WV("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ln.colorspace_pars_fragment,zV("linearToOutputTexel",t.outputColorSpace),$V(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(zA).join(` +`)),o=dx(o),o=oM(o,t),o=aM(o,t),a=dx(a),a=oM(a,t),a=aM(a,t),o=lM(o),a=lM(a),t.isRawShaderMaterial!==!0&&(C=`#version 300 es +`,S=[v,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+S,w=["#define varying in",t.glslVersion===uw?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===uw?"":"#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(` +`)+` +`+w);const E=C+S+o,N=C+w+a,L=iM(r,r.VERTEX_SHADER,E),B=iM(r,r.FRAGMENT_SHADER,N);r.attachShader(T,L),r.attachShader(T,B),t.index0AttributeName!==void 0?r.bindAttribLocation(T,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(T,0,"position"),r.linkProgram(T);function I(G){if(i.debug.checkShaderErrors){const q=r.getProgramInfoLog(T)||"",j=r.getShaderInfoLog(L)||"",Y=r.getShaderInfoLog(B)||"",$=q.trim(),Q=j.trim(),ee=Y.trim();let ue=!0,le=!0;if(r.getProgramParameter(T,r.LINK_STATUS)===!1)if(ue=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,T,L,B);else{const de=sM(r,L,"vertex"),Te=sM(r,B,"fragment");He("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(T,r.VALIDATE_STATUS)+` + +Material Name: `+G.name+` +Material Type: `+G.type+` + +Program Info Log: `+$+` +`+de+` +`+Te)}else $!==""?Ue("WebGLProgram: Program Info Log:",$):(Q===""||ee==="")&&(le=!1);le&&(G.diagnostics={runnable:ue,programLog:$,vertexShader:{log:Q,prefix:S},fragmentShader:{log:ee,prefix:w}})}r.deleteShader(L),r.deleteShader(B),F=new mg(r,T),P=QV(r,T)}let F;this.getUniforms=function(){return F===void 0&&I(this),F};let P;this.getAttributes=function(){return P===void 0&&I(this),P};let O=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=r.getProgramParameter(T,kV)),O},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(T),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=VV++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=L,this.fragmentShader=B,this}let hG=0;class fG{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.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}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}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 dG(e),t.set(e,n)),n}}class dG{constructor(e){this.id=hG++,this.code=e,this.usedTimes=0}}function AG(i,e,t,n,r,s,o){const a=new Ab,l=new fG,u=new Set,d=[],A=new Map,g=r.logarithmicDepthBuffer;let v=r.precision;const x={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 T(P){return u.add(P),P===0?"uv":`uv${P}`}function S(P,O,G,q,j){const Y=q.fog,$=j.geometry,Q=P.isMeshStandardMaterial?q.environment:null,ee=(P.isMeshStandardMaterial?t:e).get(P.envMap||Q),ue=ee&&ee.mapping===dh?ee.image.height:null,le=x[P.type];P.precision!==null&&(v=r.getMaxPrecision(P.precision),v!==P.precision&&Ue("WebGLProgram.getParameters:",P.precision,"not supported, using",v,"instead."));const de=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,Te=de!==void 0?de.length:0;let Qe=0;$.morphAttributes.position!==void 0&&(Qe=1),$.morphAttributes.normal!==void 0&&(Qe=2),$.morphAttributes.color!==void 0&&(Qe=3);let Ye,Et,at,ve;if(le){const nn=Js[le];Ye=nn.vertexShader,Et=nn.fragmentShader}else Ye=P.vertexShader,Et=P.fragmentShader,l.update(P),at=l.getVertexShaderID(P),ve=l.getFragmentShaderID(P);const Re=i.getRenderTarget(),Je=i.state.buffers.depth.getReversed(),Ct=j.isInstancedMesh===!0,et=j.isBatchedMesh===!0,qt=!!P.map,en=!!P.matcap,zt=!!ee,Oe=!!P.aoMap,tt=!!P.lightMap,Ve=!!P.bumpMap,pt=!!P.normalMap,ae=!!P.displacementMap,tn=!!P.emissiveMap,St=!!P.metalnessMap,jt=!!P.roughnessMap,ft=P.anisotropy>0,ie=P.clearcoat>0,H=P.dispersion>0,_e=P.iridescence>0,Le=P.sheen>0,$e=P.transmission>0,De=ft&&!!P.anisotropyMap,Ht=ie&&!!P.clearcoatMap,mt=ie&&!!P.clearcoatNormalMap,Ot=ie&&!!P.clearcoatRoughnessMap,Qt=_e&&!!P.iridescenceMap,it=_e&&!!P.iridescenceThicknessMap,_t=Le&&!!P.sheenColorMap,kt=Le&&!!P.sheenRoughnessMap,Nt=!!P.specularMap,Tt=!!P.specularColorMap,wn=!!P.specularIntensityMap,ne=$e&&!!P.transmissionMap,vt=$e&&!!P.thicknessMap,dt=!!P.gradientMap,Rt=!!P.alphaMap,rt=P.alphaTest>0,Ge=!!P.alphaHash,xt=!!P.extensions;let hn=ls;P.toneMapped&&(Re===null||Re.isXRRenderTarget===!0)&&(hn=i.toneMapping);const ai={shaderID:le,shaderType:P.type,shaderName:P.name,vertexShader:Ye,fragmentShader:Et,defines:P.defines,customVertexShaderID:at,customFragmentShaderID:ve,isRawShaderMaterial:P.isRawShaderMaterial===!0,glslVersion:P.glslVersion,precision:v,batching:et,batchingColor:et&&j._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&j.instanceColor!==null,instancingMorph:Ct&&j.morphTexture!==null,outputColorSpace:Re===null?i.outputColorSpace:Re.isXRRenderTarget===!0?Re.texture.colorSpace:nc,alphaToCoverage:!!P.alphaToCoverage,map:qt,matcap:en,envMap:zt,envMapMode:zt&&ee.mapping,envMapCubeUVHeight:ue,aoMap:Oe,lightMap:tt,bumpMap:Ve,normalMap:pt,displacementMap:ae,emissiveMap:tn,normalMapObjectSpace:pt&&P.normalMapType===sR,normalMapTangentSpace:pt&&P.normalMapType===ol,metalnessMap:St,roughnessMap:jt,anisotropy:ft,anisotropyMap:De,clearcoat:ie,clearcoatMap:Ht,clearcoatNormalMap:mt,clearcoatRoughnessMap:Ot,dispersion:H,iridescence:_e,iridescenceMap:Qt,iridescenceThicknessMap:it,sheen:Le,sheenColorMap:_t,sheenRoughnessMap:kt,specularMap:Nt,specularColorMap:Tt,specularIntensityMap:wn,transmission:$e,transmissionMap:ne,thicknessMap:vt,gradientMap:dt,opaque:P.transparent===!1&&P.blending===js&&P.alphaToCoverage===!1,alphaMap:Rt,alphaTest:rt,alphaHash:Ge,combine:P.combine,mapUv:qt&&T(P.map.channel),aoMapUv:Oe&&T(P.aoMap.channel),lightMapUv:tt&&T(P.lightMap.channel),bumpMapUv:Ve&&T(P.bumpMap.channel),normalMapUv:pt&&T(P.normalMap.channel),displacementMapUv:ae&&T(P.displacementMap.channel),emissiveMapUv:tn&&T(P.emissiveMap.channel),metalnessMapUv:St&&T(P.metalnessMap.channel),roughnessMapUv:jt&&T(P.roughnessMap.channel),anisotropyMapUv:De&&T(P.anisotropyMap.channel),clearcoatMapUv:Ht&&T(P.clearcoatMap.channel),clearcoatNormalMapUv:mt&&T(P.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ot&&T(P.clearcoatRoughnessMap.channel),iridescenceMapUv:Qt&&T(P.iridescenceMap.channel),iridescenceThicknessMapUv:it&&T(P.iridescenceThicknessMap.channel),sheenColorMapUv:_t&&T(P.sheenColorMap.channel),sheenRoughnessMapUv:kt&&T(P.sheenRoughnessMap.channel),specularMapUv:Nt&&T(P.specularMap.channel),specularColorMapUv:Tt&&T(P.specularColorMap.channel),specularIntensityMapUv:wn&&T(P.specularIntensityMap.channel),transmissionMapUv:ne&&T(P.transmissionMap.channel),thicknessMapUv:vt&&T(P.thicknessMap.channel),alphaMapUv:Rt&&T(P.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(pt||ft),vertexColors:P.vertexColors,vertexAlphas:P.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:j.isPoints===!0&&!!$.attributes.uv&&(qt||Rt),fog:!!Y,useFog:P.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:P.flatShading===!0&&P.wireframe===!1,sizeAttenuation:P.sizeAttenuation===!0,logarithmicDepthBuffer:g,reversedDepthBuffer:Je,skinning:j.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:Te,morphTextureStride:Qe,numDirLights:O.directional.length,numPointLights:O.point.length,numSpotLights:O.spot.length,numSpotLightMaps:O.spotLightMap.length,numRectAreaLights:O.rectArea.length,numHemiLights:O.hemi.length,numDirLightShadows:O.directionalShadowMap.length,numPointLightShadows:O.pointShadowMap.length,numSpotLightShadows:O.spotShadowMap.length,numSpotLightShadowsWithMaps:O.numSpotLightShadowsWithMaps,numLightProbes:O.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:P.dithering,shadowMapEnabled:i.shadowMap.enabled&&G.length>0,shadowMapType:i.shadowMap.type,toneMapping:hn,decodeVideoTexture:qt&&P.map.isVideoTexture===!0&&ln.getTransfer(P.map.colorSpace)===Pt,decodeVideoTextureEmissive:tn&&P.emissiveMap.isVideoTexture===!0&&ln.getTransfer(P.emissiveMap.colorSpace)===Pt,premultipliedAlpha:P.premultipliedAlpha,doubleSided:P.side===xr,flipSided:P.side===Ai,useDepthPacking:P.depthPacking>=0,depthPacking:P.depthPacking||0,index0AttributeName:P.index0AttributeName,extensionClipCullDistance:xt&&P.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(xt&&P.extensions.multiDraw===!0||et)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:P.customProgramCacheKey()};return ai.vertexUv1s=u.has(1),ai.vertexUv2s=u.has(2),ai.vertexUv3s=u.has(3),u.clear(),ai}function w(P){const O=[];if(P.shaderID?O.push(P.shaderID):(O.push(P.customVertexShaderID),O.push(P.customFragmentShaderID)),P.defines!==void 0)for(const G in P.defines)O.push(G),O.push(P.defines[G]);return P.isRawShaderMaterial===!1&&(C(O,P),E(O,P),O.push(i.outputColorSpace)),O.push(P.customProgramCacheKey),O.join()}function C(P,O){P.push(O.precision),P.push(O.outputColorSpace),P.push(O.envMapMode),P.push(O.envMapCubeUVHeight),P.push(O.mapUv),P.push(O.alphaMapUv),P.push(O.lightMapUv),P.push(O.aoMapUv),P.push(O.bumpMapUv),P.push(O.normalMapUv),P.push(O.displacementMapUv),P.push(O.emissiveMapUv),P.push(O.metalnessMapUv),P.push(O.roughnessMapUv),P.push(O.anisotropyMapUv),P.push(O.clearcoatMapUv),P.push(O.clearcoatNormalMapUv),P.push(O.clearcoatRoughnessMapUv),P.push(O.iridescenceMapUv),P.push(O.iridescenceThicknessMapUv),P.push(O.sheenColorMapUv),P.push(O.sheenRoughnessMapUv),P.push(O.specularMapUv),P.push(O.specularColorMapUv),P.push(O.specularIntensityMapUv),P.push(O.transmissionMapUv),P.push(O.thicknessMapUv),P.push(O.combine),P.push(O.fogExp2),P.push(O.sizeAttenuation),P.push(O.morphTargetsCount),P.push(O.morphAttributeCount),P.push(O.numDirLights),P.push(O.numPointLights),P.push(O.numSpotLights),P.push(O.numSpotLightMaps),P.push(O.numHemiLights),P.push(O.numRectAreaLights),P.push(O.numDirLightShadows),P.push(O.numPointLightShadows),P.push(O.numSpotLightShadows),P.push(O.numSpotLightShadowsWithMaps),P.push(O.numLightProbes),P.push(O.shadowMapType),P.push(O.toneMapping),P.push(O.numClippingPlanes),P.push(O.numClipIntersection),P.push(O.depthPacking)}function E(P,O){a.disableAll(),O.instancing&&a.enable(0),O.instancingColor&&a.enable(1),O.instancingMorph&&a.enable(2),O.matcap&&a.enable(3),O.envMap&&a.enable(4),O.normalMapObjectSpace&&a.enable(5),O.normalMapTangentSpace&&a.enable(6),O.clearcoat&&a.enable(7),O.iridescence&&a.enable(8),O.alphaTest&&a.enable(9),O.vertexColors&&a.enable(10),O.vertexAlphas&&a.enable(11),O.vertexUv1s&&a.enable(12),O.vertexUv2s&&a.enable(13),O.vertexUv3s&&a.enable(14),O.vertexTangents&&a.enable(15),O.anisotropy&&a.enable(16),O.alphaHash&&a.enable(17),O.batching&&a.enable(18),O.dispersion&&a.enable(19),O.batchingColor&&a.enable(20),O.gradientMap&&a.enable(21),P.push(a.mask),a.disableAll(),O.fog&&a.enable(0),O.useFog&&a.enable(1),O.flatShading&&a.enable(2),O.logarithmicDepthBuffer&&a.enable(3),O.reversedDepthBuffer&&a.enable(4),O.skinning&&a.enable(5),O.morphTargets&&a.enable(6),O.morphNormals&&a.enable(7),O.morphColors&&a.enable(8),O.premultipliedAlpha&&a.enable(9),O.shadowMapEnabled&&a.enable(10),O.doubleSided&&a.enable(11),O.flipSided&&a.enable(12),O.useDepthPacking&&a.enable(13),O.dithering&&a.enable(14),O.transmission&&a.enable(15),O.sheen&&a.enable(16),O.opaque&&a.enable(17),O.pointsUvs&&a.enable(18),O.decodeVideoTexture&&a.enable(19),O.decodeVideoTextureEmissive&&a.enable(20),O.alphaToCoverage&&a.enable(21),P.push(a.mask)}function N(P){const O=x[P.type];let G;if(O){const q=Js[O];G=W1.clone(q.uniforms)}else G=P.uniforms;return G}function L(P,O){let G=A.get(O);return G!==void 0?++G.usedTimes:(G=new cG(i,O,P,s),d.push(G),A.set(O,G)),G}function B(P){if(--P.usedTimes===0){const O=d.indexOf(P);d[O]=d[d.length-1],d.pop(),A.delete(P.cacheKey),P.destroy()}}function I(P){l.remove(P)}function F(){l.dispose()}return{getParameters:S,getProgramCacheKey:w,getUniforms:N,acquireProgram:L,releaseProgram:B,releaseShaderCache:I,programs:d,dispose:F}}function pG(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,l){i.get(o)[a]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function mG(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function cM(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 hM(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(A,g,v,x,T,S){let w=i[e];return w===void 0?(w={id:A.id,object:A,geometry:g,material:v,groupOrder:x,renderOrder:A.renderOrder,z:T,group:S},i[e]=w):(w.id=A.id,w.object=A,w.geometry=g,w.material=v,w.groupOrder=x,w.renderOrder=A.renderOrder,w.z=T,w.group=S),e++,w}function a(A,g,v,x,T,S){const w=o(A,g,v,x,T,S);v.transmission>0?n.push(w):v.transparent===!0?r.push(w):t.push(w)}function l(A,g,v,x,T,S){const w=o(A,g,v,x,T,S);v.transmission>0?n.unshift(w):v.transparent===!0?r.unshift(w):t.unshift(w)}function u(A,g){t.length>1&&t.sort(A||mG),n.length>1&&n.sort(g||cM),r.length>1&&r.sort(g||cM)}function d(){for(let A=e,g=i.length;A=s.length?(o=new hM,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function _G(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new te,color:new Gt};break;case"SpotLight":t={position:new te,direction:new te,color:new Gt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new te,color:new Gt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new te,skyColor:new Gt,groundColor:new Gt};break;case"RectAreaLight":t={color:new Gt,position:new te,halfWidth:new te,halfHeight:new te};break}return i[e.id]=t,t}}}function vG(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let xG=0;function yG(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function bG(i){const e=new _G,t=vG(),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 u=0;u<9;u++)n.probe.push(new te);const r=new te,s=new gn,o=new gn;function a(u){let d=0,A=0,g=0;for(let P=0;P<9;P++)n.probe[P].set(0,0,0);let v=0,x=0,T=0,S=0,w=0,C=0,E=0,N=0,L=0,B=0,I=0;u.sort(yG);for(let P=0,O=u.length;P0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Mt.LTC_FLOAT_1,n.rectAreaLTC2=Mt.LTC_FLOAT_2):(n.rectAreaLTC1=Mt.LTC_HALF_1,n.rectAreaLTC2=Mt.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=A,n.ambient[2]=g;const F=n.hash;(F.directionalLength!==v||F.pointLength!==x||F.spotLength!==T||F.rectAreaLength!==S||F.hemiLength!==w||F.numDirectionalShadows!==C||F.numPointShadows!==E||F.numSpotShadows!==N||F.numSpotMaps!==L||F.numLightProbes!==I)&&(n.directional.length=v,n.spot.length=T,n.rectArea.length=S,n.point.length=x,n.hemi.length=w,n.directionalShadow.length=C,n.directionalShadowMap.length=C,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=N,n.spotShadowMap.length=N,n.directionalShadowMatrix.length=C,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=N+L-B,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=B,n.numLightProbes=I,F.directionalLength=v,F.pointLength=x,F.spotLength=T,F.rectAreaLength=S,F.hemiLength=w,F.numDirectionalShadows=C,F.numPointShadows=E,F.numSpotShadows=N,F.numSpotMaps=L,F.numLightProbes=I,n.version=xG++)}function l(u,d){let A=0,g=0,v=0,x=0,T=0;const S=d.matrixWorldInverse;for(let w=0,C=u.length;w=o.length?(a=new fM(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}const TG=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,wG=`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 ); +}`,MG=[new te(1,0,0),new te(-1,0,0),new te(0,1,0),new te(0,-1,0),new te(0,0,1),new te(0,0,-1)],EG=[new te(0,-1,0),new te(0,-1,0),new te(0,0,1),new te(0,0,-1),new te(0,-1,0),new te(0,-1,0)],dM=new gn,gA=new te,j2=new te;function CG(i,e,t){let n=new $d;const r=new qe,s=new qe,o=new dn,a=new MU,l=new EU,u={},d=t.maxTextureSize,A={[No]:Ai,[Ai]:No,[xr]:xr},g=new Rs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qe},radius:{value:4}},vertexShader:TG,fragmentShader:wG}),v=g.clone();v.defines.HORIZONTAL_PASS=1;const x=new ui;x.setAttribute("position",new Ji(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const T=new si(x,g),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=e0;let w=this.type;this.render=function(B,I,F){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||B.length===0)return;B.type===RB&&(Ue("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),B.type=e0);const P=i.getRenderTarget(),O=i.getActiveCubeFace(),G=i.getActiveMipmapLevel(),q=i.state;q.setBlending($s),q.buffers.depth.getReversed()===!0?q.buffers.color.setClear(0,0,0,0):q.buffers.color.setClear(1,1,1,1),q.buffers.depth.setTest(!0),q.setScissorTest(!1);const j=w!==this.type;j&&I.traverse(function(Y){Y.material&&(Array.isArray(Y.material)?Y.material.forEach($=>$.needsUpdate=!0):Y.material.needsUpdate=!0)});for(let Y=0,$=B.length;Y<$;Y++){const Q=B[Y],ee=Q.shadow;if(ee===void 0){Ue("WebGLShadowMap:",Q,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;r.copy(ee.mapSize);const ue=ee.getFrameExtents();if(r.multiply(ue),s.copy(ee.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(s.x=Math.floor(d/ue.x),r.x=s.x*ue.x,ee.mapSize.x=s.x),r.y>d&&(s.y=Math.floor(d/ue.y),r.y=s.y*ue.y,ee.mapSize.y=s.y)),ee.map===null||j===!0){if(ee.map!==null&&(ee.map.depthTexture!==null&&(ee.map.depthTexture.dispose(),ee.map.depthTexture=null),ee.map.dispose()),this.type===Hl){if(Q.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}ee.map=new xa(r.x,r.y,{format:Hs,type:zi,minFilter:ki,magFilter:ki,generateMipmaps:!1}),ee.map.texture.name=Q.name+".shadowMap",ee.map.depthTexture=new Ms(r.x,r.y,dr),ee.map.depthTexture.name=Q.name+".shadowMapDepth",ee.map.depthTexture.format=hs,ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=xi,ee.map.depthTexture.magFilter=xi}else{Q.isPointLight?(ee.map=new gb(r.x),ee.map.depthTexture=new dR(r.x,vi)):(ee.map=new xa(r.x,r.y),ee.map.depthTexture=new Ms(r.x,r.y,vi)),ee.map.depthTexture.name=Q.name+".shadowMap",ee.map.depthTexture.format=hs;const de=i.state.buffers.depth.getReversed();this.type===e0?(ee.map.depthTexture.compareFunction=de?up:lp,ee.map.depthTexture.minFilter=ki,ee.map.depthTexture.magFilter=ki):(ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=xi,ee.map.depthTexture.magFilter=xi)}ee.camera.updateProjectionMatrix()}const le=ee.map.isWebGLCubeRenderTarget?6:1;for(let de=0;de0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){const q=O.uuid,j=I.uuid;let Y=u[q];Y===void 0&&(Y={},u[q]=Y);let $=Y[j];$===void 0&&($=O.clone(),Y[j]=$,I.addEventListener("dispose",L)),O=$}if(O.visible=I.visible,O.wireframe=I.wireframe,P===Hl?O.side=I.shadowSide!==null?I.shadowSide:I.side:O.side=I.shadowSide!==null?I.shadowSide:A[I.side],O.alphaMap=I.alphaMap,O.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,O.map=I.map,O.clipShadows=I.clipShadows,O.clippingPlanes=I.clippingPlanes,O.clipIntersection=I.clipIntersection,O.displacementMap=I.displacementMap,O.displacementScale=I.displacementScale,O.displacementBias=I.displacementBias,O.wireframeLinewidth=I.wireframeLinewidth,O.linewidth=I.linewidth,F.isPointLight===!0&&O.isMeshDistanceMaterial===!0){const q=i.properties.get(O);q.light=F}return O}function N(B,I,F,P,O){if(B.visible===!1)return;if(B.layers.test(I.layers)&&(B.isMesh||B.isLine||B.isPoints)&&(B.castShadow||B.receiveShadow&&O===Hl)&&(!B.frustumCulled||n.intersectsObject(B))){B.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,B.matrixWorld);const j=e.update(B),Y=B.material;if(Array.isArray(Y)){const $=j.groups;for(let Q=0,ee=$.length;Q=1):ue.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(ue)[1]),Q=ee>=2);let le=null,de={};const Te=i.getParameter(i.SCISSOR_BOX),Qe=i.getParameter(i.VIEWPORT),Ye=new dn().fromArray(Te),Et=new dn().fromArray(Qe);function at(ne,vt,dt,Rt){const rt=new Uint8Array(4),Ge=i.createTexture();i.bindTexture(ne,Ge),i.texParameteri(ne,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ne,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let xt=0;xt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new qe,d=new WeakMap;let A;const g=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(ie,H){return v?new OffscreenCanvas(ie,H):N0("canvas")}function T(ie,H,_e){let Le=1;const $e=ft(ie);if(($e.width>_e||$e.height>_e)&&(Le=_e/Math.max($e.width,$e.height)),Le<1)if(typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ie instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ie instanceof ImageBitmap||typeof VideoFrame<"u"&&ie instanceof VideoFrame){const De=Math.floor(Le*$e.width),Ht=Math.floor(Le*$e.height);A===void 0&&(A=x(De,Ht));const mt=H?x(De,Ht):A;return mt.width=De,mt.height=Ht,mt.getContext("2d").drawImage(ie,0,0,De,Ht),Ue("WebGLRenderer: Texture has been resized from ("+$e.width+"x"+$e.height+") to ("+De+"x"+Ht+")."),mt}else return"data"in ie&&Ue("WebGLRenderer: Image in DataTexture is too big ("+$e.width+"x"+$e.height+")."),ie;return ie}function S(ie){return ie.generateMipmaps}function w(ie){i.generateMipmap(ie)}function C(ie){return ie.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:ie.isWebGL3DRenderTarget?i.TEXTURE_3D:ie.isWebGLArrayRenderTarget||ie.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(ie,H,_e,Le,$e=!1){if(ie!==null){if(i[ie]!==void 0)return i[ie];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ie+"'")}let De=H;if(H===i.RED&&(_e===i.FLOAT&&(De=i.R32F),_e===i.HALF_FLOAT&&(De=i.R16F),_e===i.UNSIGNED_BYTE&&(De=i.R8)),H===i.RED_INTEGER&&(_e===i.UNSIGNED_BYTE&&(De=i.R8UI),_e===i.UNSIGNED_SHORT&&(De=i.R16UI),_e===i.UNSIGNED_INT&&(De=i.R32UI),_e===i.BYTE&&(De=i.R8I),_e===i.SHORT&&(De=i.R16I),_e===i.INT&&(De=i.R32I)),H===i.RG&&(_e===i.FLOAT&&(De=i.RG32F),_e===i.HALF_FLOAT&&(De=i.RG16F),_e===i.UNSIGNED_BYTE&&(De=i.RG8)),H===i.RG_INTEGER&&(_e===i.UNSIGNED_BYTE&&(De=i.RG8UI),_e===i.UNSIGNED_SHORT&&(De=i.RG16UI),_e===i.UNSIGNED_INT&&(De=i.RG32UI),_e===i.BYTE&&(De=i.RG8I),_e===i.SHORT&&(De=i.RG16I),_e===i.INT&&(De=i.RG32I)),H===i.RGB_INTEGER&&(_e===i.UNSIGNED_BYTE&&(De=i.RGB8UI),_e===i.UNSIGNED_SHORT&&(De=i.RGB16UI),_e===i.UNSIGNED_INT&&(De=i.RGB32UI),_e===i.BYTE&&(De=i.RGB8I),_e===i.SHORT&&(De=i.RGB16I),_e===i.INT&&(De=i.RGB32I)),H===i.RGBA_INTEGER&&(_e===i.UNSIGNED_BYTE&&(De=i.RGBA8UI),_e===i.UNSIGNED_SHORT&&(De=i.RGBA16UI),_e===i.UNSIGNED_INT&&(De=i.RGBA32UI),_e===i.BYTE&&(De=i.RGBA8I),_e===i.SHORT&&(De=i.RGBA16I),_e===i.INT&&(De=i.RGBA32I)),H===i.RGB&&(_e===i.UNSIGNED_INT_5_9_9_9_REV&&(De=i.RGB9_E5),_e===i.UNSIGNED_INT_10F_11F_11F_REV&&(De=i.R11F_G11F_B10F)),H===i.RGBA){const Ht=$e?Td:ln.getTransfer(Le);_e===i.FLOAT&&(De=i.RGBA32F),_e===i.HALF_FLOAT&&(De=i.RGBA16F),_e===i.UNSIGNED_BYTE&&(De=Ht===Pt?i.SRGB8_ALPHA8:i.RGBA8),_e===i.UNSIGNED_SHORT_4_4_4_4&&(De=i.RGBA4),_e===i.UNSIGNED_SHORT_5_5_5_1&&(De=i.RGB5_A1)}return(De===i.R16F||De===i.R32F||De===i.RG16F||De===i.RG32F||De===i.RGBA16F||De===i.RGBA32F)&&e.get("EXT_color_buffer_float"),De}function N(ie,H){let _e;return ie?H===null||H===vi||H===Po?_e=i.DEPTH24_STENCIL8:H===dr?_e=i.DEPTH32F_STENCIL8:H===ga&&(_e=i.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):H===null||H===vi||H===Po?_e=i.DEPTH_COMPONENT24:H===dr?_e=i.DEPTH_COMPONENT32F:H===ga&&(_e=i.DEPTH_COMPONENT16),_e}function L(ie,H){return S(ie)===!0||ie.isFramebufferTexture&&ie.minFilter!==xi&&ie.minFilter!==ki?Math.log2(Math.max(H.width,H.height))+1:ie.mipmaps!==void 0&&ie.mipmaps.length>0?ie.mipmaps.length:ie.isCompressedTexture&&Array.isArray(ie.image)?H.mipmaps.length:1}function B(ie){const H=ie.target;H.removeEventListener("dispose",B),F(H),H.isVideoTexture&&d.delete(H)}function I(ie){const H=ie.target;H.removeEventListener("dispose",I),O(H)}function F(ie){const H=n.get(ie);if(H.__webglInit===void 0)return;const _e=ie.source,Le=g.get(_e);if(Le){const $e=Le[H.__cacheKey];$e.usedTimes--,$e.usedTimes===0&&P(ie),Object.keys(Le).length===0&&g.delete(_e)}n.remove(ie)}function P(ie){const H=n.get(ie);i.deleteTexture(H.__webglTexture);const _e=ie.source,Le=g.get(_e);delete Le[H.__cacheKey],o.memory.textures--}function O(ie){const H=n.get(ie);if(ie.depthTexture&&(ie.depthTexture.dispose(),n.remove(ie.depthTexture)),ie.isWebGLCubeRenderTarget)for(let Le=0;Le<6;Le++){if(Array.isArray(H.__webglFramebuffer[Le]))for(let $e=0;$e=r.maxTextures&&Ue("WebGLTextures: Trying to use "+ie+" texture units while this GPU supports only "+r.maxTextures),G+=1,ie}function Y(ie){const H=[];return H.push(ie.wrapS),H.push(ie.wrapT),H.push(ie.wrapR||0),H.push(ie.magFilter),H.push(ie.minFilter),H.push(ie.anisotropy),H.push(ie.internalFormat),H.push(ie.format),H.push(ie.type),H.push(ie.generateMipmaps),H.push(ie.premultiplyAlpha),H.push(ie.flipY),H.push(ie.unpackAlignment),H.push(ie.colorSpace),H.join()}function $(ie,H){const _e=n.get(ie);if(ie.isVideoTexture&&St(ie),ie.isRenderTargetTexture===!1&&ie.isExternalTexture!==!0&&ie.version>0&&_e.__version!==ie.version){const Le=ie.image;if(Le===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(Le.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{ve(_e,ie,H);return}}else ie.isExternalTexture&&(_e.__webglTexture=ie.sourceTexture?ie.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,_e.__webglTexture,i.TEXTURE0+H)}function Q(ie,H){const _e=n.get(ie);if(ie.isRenderTargetTexture===!1&&ie.version>0&&_e.__version!==ie.version){ve(_e,ie,H);return}else ie.isExternalTexture&&(_e.__webglTexture=ie.sourceTexture?ie.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,_e.__webglTexture,i.TEXTURE0+H)}function ee(ie,H){const _e=n.get(ie);if(ie.isRenderTargetTexture===!1&&ie.version>0&&_e.__version!==ie.version){ve(_e,ie,H);return}t.bindTexture(i.TEXTURE_3D,_e.__webglTexture,i.TEXTURE0+H)}function ue(ie,H){const _e=n.get(ie);if(ie.isCubeDepthTexture!==!0&&ie.version>0&&_e.__version!==ie.version){Re(_e,ie,H);return}t.bindTexture(i.TEXTURE_CUBE_MAP,_e.__webglTexture,i.TEXTURE0+H)}const le={[Ah]:i.REPEAT,[io]:i.CLAMP_TO_EDGE,[ph]:i.MIRRORED_REPEAT},de={[xi]:i.NEAREST,[ib]:i.NEAREST_MIPMAP_NEAREST,[Wl]:i.NEAREST_MIPMAP_LINEAR,[ki]:i.LINEAR,[kf]:i.LINEAR_MIPMAP_NEAREST,[ro]:i.LINEAR_MIPMAP_LINEAR},Te={[sb]:i.NEVER,[ub]:i.ALWAYS,[ap]:i.LESS,[lp]:i.LEQUAL,[ob]:i.EQUAL,[up]:i.GEQUAL,[ab]:i.GREATER,[lb]:i.NOTEQUAL};function Qe(ie,H){if(H.type===dr&&e.has("OES_texture_float_linear")===!1&&(H.magFilter===ki||H.magFilter===kf||H.magFilter===Wl||H.magFilter===ro||H.minFilter===ki||H.minFilter===kf||H.minFilter===Wl||H.minFilter===ro)&&Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(ie,i.TEXTURE_WRAP_S,le[H.wrapS]),i.texParameteri(ie,i.TEXTURE_WRAP_T,le[H.wrapT]),(ie===i.TEXTURE_3D||ie===i.TEXTURE_2D_ARRAY)&&i.texParameteri(ie,i.TEXTURE_WRAP_R,le[H.wrapR]),i.texParameteri(ie,i.TEXTURE_MAG_FILTER,de[H.magFilter]),i.texParameteri(ie,i.TEXTURE_MIN_FILTER,de[H.minFilter]),H.compareFunction&&(i.texParameteri(ie,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(ie,i.TEXTURE_COMPARE_FUNC,Te[H.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(H.magFilter===xi||H.minFilter!==Wl&&H.minFilter!==ro||H.type===dr&&e.has("OES_texture_float_linear")===!1)return;if(H.anisotropy>1||n.get(H).__currentAnisotropy){const _e=e.get("EXT_texture_filter_anisotropic");i.texParameterf(ie,_e.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(H.anisotropy,r.getMaxAnisotropy())),n.get(H).__currentAnisotropy=H.anisotropy}}}function Ye(ie,H){let _e=!1;ie.__webglInit===void 0&&(ie.__webglInit=!0,H.addEventListener("dispose",B));const Le=H.source;let $e=g.get(Le);$e===void 0&&($e={},g.set(Le,$e));const De=Y(H);if(De!==ie.__cacheKey){$e[De]===void 0&&($e[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,_e=!0),$e[De].usedTimes++;const Ht=$e[ie.__cacheKey];Ht!==void 0&&($e[ie.__cacheKey].usedTimes--,Ht.usedTimes===0&&P(H)),ie.__cacheKey=De,ie.__webglTexture=$e[De].texture}return _e}function Et(ie,H,_e){return Math.floor(Math.floor(ie/_e)/H)}function at(ie,H,_e,Le){const De=ie.updateRanges;if(De.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,H.width,H.height,_e,Le,H.data);else{De.sort((it,_t)=>it.start-_t.start);let Ht=0;for(let it=1;it0){ne&&vt&&t.texStorage2D(i.TEXTURE_2D,Rt,Nt,wn[0].width,wn[0].height);for(let rt=0,Ge=wn.length;rt0){const xt=hx(Tt.width,Tt.height,H.format,H.type);for(const hn of H.layerUpdates){const ai=Tt.data.subarray(hn*xt/Tt.data.BYTES_PER_ELEMENT,(hn+1)*xt/Tt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,hn,Tt.width,Tt.height,1,_t,ai)}H.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,0,Tt.width,Tt.height,it.depth,_t,Tt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,rt,Nt,Tt.width,Tt.height,it.depth,0,Tt.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ne?dt&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,rt,0,0,0,Tt.width,Tt.height,it.depth,_t,kt,Tt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,rt,Nt,Tt.width,Tt.height,it.depth,0,_t,kt,Tt.data)}else{ne&&vt&&t.texStorage2D(i.TEXTURE_2D,Rt,Nt,wn[0].width,wn[0].height);for(let rt=0,Ge=wn.length;rt0){const rt=hx(it.width,it.height,H.format,H.type);for(const Ge of H.layerUpdates){const xt=it.data.subarray(Ge*rt/it.data.BYTES_PER_ELEMENT,(Ge+1)*rt/it.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Ge,it.width,it.height,1,_t,kt,xt)}H.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,it.width,it.height,it.depth,_t,kt,it.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Nt,it.width,it.height,it.depth,0,_t,kt,it.data);else if(H.isData3DTexture)ne?(vt&&t.texStorage3D(i.TEXTURE_3D,Rt,Nt,it.width,it.height,it.depth),dt&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,it.width,it.height,it.depth,_t,kt,it.data)):t.texImage3D(i.TEXTURE_3D,0,Nt,it.width,it.height,it.depth,0,_t,kt,it.data);else if(H.isFramebufferTexture){if(vt)if(ne)t.texStorage2D(i.TEXTURE_2D,Rt,Nt,it.width,it.height);else{let rt=it.width,Ge=it.height;for(let xt=0;xt>=1,Ge>>=1}}else if(wn.length>0){if(ne&&vt){const rt=ft(wn[0]);t.texStorage2D(i.TEXTURE_2D,Rt,Nt,rt.width,rt.height)}for(let rt=0,Ge=wn.length;rt0&&Rt++;const Ge=ft(_t[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Rt,wn,Ge.width,Ge.height)}for(let Ge=0;Ge<6;Ge++)if(it){ne?dt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0,0,0,_t[Ge].width,_t[Ge].height,Nt,Tt,_t[Ge].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0,wn,_t[Ge].width,_t[Ge].height,0,Nt,Tt,_t[Ge].data);for(let xt=0;xt>De),kt=Math.max(1,H.height>>De);$e===i.TEXTURE_3D||$e===i.TEXTURE_2D_ARRAY?t.texImage3D($e,De,Ot,_t,kt,H.depth,0,Ht,mt,null):t.texImage2D($e,De,Ot,_t,kt,0,Ht,mt,null)}t.bindFramebuffer(i.FRAMEBUFFER,ie),tn(H)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Le,$e,it.__webglTexture,0,ae(H)):($e===i.TEXTURE_2D||$e>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&$e<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Le,$e,it.__webglTexture,De),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ct(ie,H,_e){if(i.bindRenderbuffer(i.RENDERBUFFER,ie),H.depthBuffer){const Le=H.depthTexture,$e=Le&&Le.isDepthTexture?Le.type:null,De=N(H.stencilBuffer,$e),Ht=H.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;tn(H)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ae(H),De,H.width,H.height):_e?i.renderbufferStorageMultisample(i.RENDERBUFFER,ae(H),De,H.width,H.height):i.renderbufferStorage(i.RENDERBUFFER,De,H.width,H.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ht,i.RENDERBUFFER,ie)}else{const Le=H.textures;for(let $e=0;$e{delete H.__boundDepthTexture,delete H.__depthDisposeCallback,Le.removeEventListener("dispose",$e)};Le.addEventListener("dispose",$e),H.__depthDisposeCallback=$e}H.__boundDepthTexture=Le}if(ie.depthTexture&&!H.__autoAllocateDepthBuffer)if(_e)for(let Le=0;Le<6;Le++)et(H.__webglFramebuffer[Le],ie,Le);else{const Le=ie.texture.mipmaps;Le&&Le.length>0?et(H.__webglFramebuffer[0],ie,0):et(H.__webglFramebuffer,ie,0)}else if(_e){H.__webglDepthbuffer=[];for(let Le=0;Le<6;Le++)if(t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer[Le]),H.__webglDepthbuffer[Le]===void 0)H.__webglDepthbuffer[Le]=i.createRenderbuffer(),Ct(H.__webglDepthbuffer[Le],ie,!1);else{const $e=ie.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,De=H.__webglDepthbuffer[Le];i.bindRenderbuffer(i.RENDERBUFFER,De),i.framebufferRenderbuffer(i.FRAMEBUFFER,$e,i.RENDERBUFFER,De)}}else{const Le=ie.texture.mipmaps;if(Le&&Le.length>0?t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer),H.__webglDepthbuffer===void 0)H.__webglDepthbuffer=i.createRenderbuffer(),Ct(H.__webglDepthbuffer,ie,!1);else{const $e=ie.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,De=H.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,De),i.framebufferRenderbuffer(i.FRAMEBUFFER,$e,i.RENDERBUFFER,De)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function en(ie,H,_e){const Le=n.get(ie);H!==void 0&&Je(Le.__webglFramebuffer,ie,ie.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),_e!==void 0&&qt(ie)}function zt(ie){const H=ie.texture,_e=n.get(ie),Le=n.get(H);ie.addEventListener("dispose",I);const $e=ie.textures,De=ie.isWebGLCubeRenderTarget===!0,Ht=$e.length>1;if(Ht||(Le.__webglTexture===void 0&&(Le.__webglTexture=i.createTexture()),Le.__version=H.version,o.memory.textures++),De){_e.__webglFramebuffer=[];for(let mt=0;mt<6;mt++)if(H.mipmaps&&H.mipmaps.length>0){_e.__webglFramebuffer[mt]=[];for(let Ot=0;Ot0){_e.__webglFramebuffer=[];for(let mt=0;mt0&&tn(ie)===!1){_e.__webglMultisampledFramebuffer=i.createFramebuffer(),_e.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer);for(let mt=0;mt<$e.length;mt++){const Ot=$e[mt];_e.__webglColorRenderbuffer[mt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,_e.__webglColorRenderbuffer[mt]);const Qt=s.convert(Ot.format,Ot.colorSpace),it=s.convert(Ot.type),_t=E(Ot.internalFormat,Qt,it,Ot.colorSpace,ie.isXRRenderTarget===!0),kt=ae(ie);i.renderbufferStorageMultisample(i.RENDERBUFFER,kt,_t,ie.width,ie.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.RENDERBUFFER,_e.__webglColorRenderbuffer[mt])}i.bindRenderbuffer(i.RENDERBUFFER,null),ie.depthBuffer&&(_e.__webglDepthRenderbuffer=i.createRenderbuffer(),Ct(_e.__webglDepthRenderbuffer,ie,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(De){t.bindTexture(i.TEXTURE_CUBE_MAP,Le.__webglTexture),Qe(i.TEXTURE_CUBE_MAP,H);for(let mt=0;mt<6;mt++)if(H.mipmaps&&H.mipmaps.length>0)for(let Ot=0;Ot0)for(let Ot=0;Ot0){if(tn(ie)===!1){const H=ie.textures,_e=ie.width,Le=ie.height;let $e=i.COLOR_BUFFER_BIT;const De=ie.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ht=n.get(ie),mt=H.length>1;if(mt)for(let Qt=0;Qt0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ht.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ht.__webglFramebuffer);for(let Qt=0;Qt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&H.__useRenderToTexture!==!1}function St(ie){const H=o.render.frame;d.get(ie)!==H&&(d.set(ie,H),ie.update())}function jt(ie,H){const _e=ie.colorSpace,Le=ie.format,$e=ie.type;return ie.isCompressedTexture===!0||ie.isVideoTexture===!0||_e!==nc&&_e!==to&&(ln.getTransfer(_e)===Pt?(Le!==pr||$e!==Gi)&&Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):He("WebGLTextures: Unsupported texture color space:",_e)),H}function ft(ie){return typeof HTMLImageElement<"u"&&ie instanceof HTMLImageElement?(u.width=ie.naturalWidth||ie.width,u.height=ie.naturalHeight||ie.height):typeof VideoFrame<"u"&&ie instanceof VideoFrame?(u.width=ie.displayWidth,u.height=ie.displayHeight):(u.width=ie.width,u.height=ie.height),u}this.allocateTextureUnit=j,this.resetTextureUnits=q,this.setTexture2D=$,this.setTexture2DArray=Q,this.setTexture3D=ee,this.setTextureCube=ue,this.rebindTextures=en,this.setupRenderTarget=zt,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=pt,this.setupDepthRenderbuffer=qt,this.setupFrameBufferTexture=Je,this.useMultisampledRTT=tn,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function DG(i,e){function t(n,r=to){let s;const o=ln.getTransfer(r);if(n===Gi)return i.UNSIGNED_BYTE;if(n===G1)return i.UNSIGNED_SHORT_4_4_4_4;if(n===q1)return i.UNSIGNED_SHORT_5_5_5_1;if(n===z1)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===H1)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===ah)return i.BYTE;if(n===lh)return i.SHORT;if(n===ga)return i.UNSIGNED_SHORT;if(n===jr)return i.INT;if(n===vi)return i.UNSIGNED_INT;if(n===dr)return i.FLOAT;if(n===zi)return i.HALF_FLOAT;if(n===rb)return i.ALPHA;if(n===sp)return i.RGB;if(n===pr)return i.RGBA;if(n===hs)return i.DEPTH_COMPONENT;if(n===zs)return i.DEPTH_STENCIL;if(n===op)return i.RED;if(n===zd)return i.RED_INTEGER;if(n===Hs)return i.RG;if(n===Hd)return i.RG_INTEGER;if(n===Wd)return i.RGBA_INTEGER;if(n===Qu||n===Yu||n===Ku||n===Zu)if(o===Pt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Qu)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Yu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ku)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Zu)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Qu)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Yu)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ku)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Zu)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===M0||n===E0||n===C0||n===R0)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===M0)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===E0)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===C0)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===R0)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ed||n===td||n===nd||n===id||n===rd||n===mh||n===sd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ed||n===td)return o===Pt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===nd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===id)return s.COMPRESSED_R11_EAC;if(n===rd)return s.COMPRESSED_SIGNED_R11_EAC;if(n===mh)return s.COMPRESSED_RG11_EAC;if(n===sd)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===od||n===ad||n===ld||n===ud||n===cd||n===hd||n===fd||n===dd||n===Ad||n===pd||n===md||n===gd||n===_d||n===vd)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===od)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ad)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ld)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ud)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===cd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===hd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===fd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===dd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ad)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===pd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===md)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===gd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===_d)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===vd)return o===Pt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xd||n===ix||n===rx)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===xd)return o===Pt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ix)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===rx)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===yd||n===bd||n===gh||n===Sd)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===yd)return s.COMPRESSED_RED_RGTC1_EXT;if(n===bd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===gh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Sd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Po?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const LG=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,IG=` +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 BG{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new AR(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 Rs({vertexShader:LG,fragmentShader:IG,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new si(new dp(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class UG extends La{constructor(e,t){super();const n=this;let r=null,s=1,o=null,a="local-floor",l=1,u=null,d=null,A=null,g=null,v=null,x=null;const T=typeof XRWebGLBinding<"u",S=new BG,w={},C=t.getContextAttributes();let E=null,N=null;const L=[],B=[],I=new qe;let F=null;const P=new Xr;P.viewport=new dn;const O=new Xr;O.viewport=new dn;const G=[P,O],q=new RR;let j=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ve){let Re=L[ve];return Re===void 0&&(Re=new Ag,L[ve]=Re),Re.getTargetRaySpace()},this.getControllerGrip=function(ve){let Re=L[ve];return Re===void 0&&(Re=new Ag,L[ve]=Re),Re.getGripSpace()},this.getHand=function(ve){let Re=L[ve];return Re===void 0&&(Re=new Ag,L[ve]=Re),Re.getHandSpace()};function $(ve){const Re=B.indexOf(ve.inputSource);if(Re===-1)return;const Je=L[Re];Je!==void 0&&(Je.update(ve.inputSource,ve.frame,u||o),Je.dispatchEvent({type:ve.type,data:ve.inputSource}))}function Q(){r.removeEventListener("select",$),r.removeEventListener("selectstart",$),r.removeEventListener("selectend",$),r.removeEventListener("squeeze",$),r.removeEventListener("squeezestart",$),r.removeEventListener("squeezeend",$),r.removeEventListener("end",Q),r.removeEventListener("inputsourceschange",ee);for(let ve=0;ve=0&&(B[Ct]=null,L[Ct].disconnect(Je))}for(let Re=0;Re=B.length){B.push(Je),Ct=qt;break}else if(B[qt]===null){B[qt]=Je,Ct=qt;break}if(Ct===-1)break}const et=L[Ct];et&&et.connect(Je)}}const ue=new te,le=new te;function de(ve,Re,Je){ue.setFromMatrixPosition(Re.matrixWorld),le.setFromMatrixPosition(Je.matrixWorld);const Ct=ue.distanceTo(le),et=Re.projectionMatrix.elements,qt=Je.projectionMatrix.elements,en=et[14]/(et[10]-1),zt=et[14]/(et[10]+1),Oe=(et[9]+1)/et[5],tt=(et[9]-1)/et[5],Ve=(et[8]-1)/et[0],pt=(qt[8]+1)/qt[0],ae=en*Ve,tn=en*pt,St=Ct/(-Ve+pt),jt=St*-Ve;if(Re.matrixWorld.decompose(ve.position,ve.quaternion,ve.scale),ve.translateX(jt),ve.translateZ(St),ve.matrixWorld.compose(ve.position,ve.quaternion,ve.scale),ve.matrixWorldInverse.copy(ve.matrixWorld).invert(),et[10]===-1)ve.projectionMatrix.copy(Re.projectionMatrix),ve.projectionMatrixInverse.copy(Re.projectionMatrixInverse);else{const ft=en+St,ie=zt+St,H=ae-jt,_e=tn+(Ct-jt),Le=Oe*zt/ie*ft,$e=tt*zt/ie*ft;ve.projectionMatrix.makePerspective(H,_e,Le,$e,ft,ie),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert()}}function Te(ve,Re){Re===null?ve.matrixWorld.copy(ve.matrix):ve.matrixWorld.multiplyMatrices(Re.matrixWorld,ve.matrix),ve.matrixWorldInverse.copy(ve.matrixWorld).invert()}this.updateCamera=function(ve){if(r===null)return;let Re=ve.near,Je=ve.far;S.texture!==null&&(S.depthNear>0&&(Re=S.depthNear),S.depthFar>0&&(Je=S.depthFar)),q.near=O.near=P.near=Re,q.far=O.far=P.far=Je,(j!==q.near||Y!==q.far)&&(r.updateRenderState({depthNear:q.near,depthFar:q.far}),j=q.near,Y=q.far),q.layers.mask=ve.layers.mask|6,P.layers.mask=q.layers.mask&3,O.layers.mask=q.layers.mask&5;const Ct=ve.parent,et=q.cameras;Te(q,Ct);for(let qt=0;qt0&&(S.alphaTest.value=w.alphaTest);const C=e.get(w),E=C.envMap,N=C.envMapRotation;E&&(S.envMap.value=E,Pc.copy(N),Pc.x*=-1,Pc.y*=-1,Pc.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Pc.y*=-1,Pc.z*=-1),S.envMapRotation.value.setFromMatrix4(FG.makeRotationFromEuler(Pc)),S.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=w.reflectivity,S.ior.value=w.ior,S.refractionRatio.value=w.refractionRatio),w.lightMap&&(S.lightMap.value=w.lightMap,S.lightMapIntensity.value=w.lightMapIntensity,t(w.lightMap,S.lightMapTransform)),w.aoMap&&(S.aoMap.value=w.aoMap,S.aoMapIntensity.value=w.aoMapIntensity,t(w.aoMap,S.aoMapTransform))}function o(S,w){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,w.map&&(S.map.value=w.map,t(w.map,S.mapTransform))}function a(S,w){S.dashSize.value=w.dashSize,S.totalSize.value=w.dashSize+w.gapSize,S.scale.value=w.scale}function l(S,w,C,E){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,S.size.value=w.size*C,S.scale.value=E*.5,w.map&&(S.map.value=w.map,t(w.map,S.uvTransform)),w.alphaMap&&(S.alphaMap.value=w.alphaMap,t(w.alphaMap,S.alphaMapTransform)),w.alphaTest>0&&(S.alphaTest.value=w.alphaTest)}function u(S,w){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,S.rotation.value=w.rotation,w.map&&(S.map.value=w.map,t(w.map,S.mapTransform)),w.alphaMap&&(S.alphaMap.value=w.alphaMap,t(w.alphaMap,S.alphaMapTransform)),w.alphaTest>0&&(S.alphaTest.value=w.alphaTest)}function d(S,w){S.specular.value.copy(w.specular),S.shininess.value=Math.max(w.shininess,1e-4)}function A(S,w){w.gradientMap&&(S.gradientMap.value=w.gradientMap)}function g(S,w){S.metalness.value=w.metalness,w.metalnessMap&&(S.metalnessMap.value=w.metalnessMap,t(w.metalnessMap,S.metalnessMapTransform)),S.roughness.value=w.roughness,w.roughnessMap&&(S.roughnessMap.value=w.roughnessMap,t(w.roughnessMap,S.roughnessMapTransform)),w.envMap&&(S.envMapIntensity.value=w.envMapIntensity)}function v(S,w,C){S.ior.value=w.ior,w.sheen>0&&(S.sheenColor.value.copy(w.sheenColor).multiplyScalar(w.sheen),S.sheenRoughness.value=w.sheenRoughness,w.sheenColorMap&&(S.sheenColorMap.value=w.sheenColorMap,t(w.sheenColorMap,S.sheenColorMapTransform)),w.sheenRoughnessMap&&(S.sheenRoughnessMap.value=w.sheenRoughnessMap,t(w.sheenRoughnessMap,S.sheenRoughnessMapTransform))),w.clearcoat>0&&(S.clearcoat.value=w.clearcoat,S.clearcoatRoughness.value=w.clearcoatRoughness,w.clearcoatMap&&(S.clearcoatMap.value=w.clearcoatMap,t(w.clearcoatMap,S.clearcoatMapTransform)),w.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=w.clearcoatRoughnessMap,t(w.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),w.clearcoatNormalMap&&(S.clearcoatNormalMap.value=w.clearcoatNormalMap,t(w.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(w.clearcoatNormalScale),w.side===Ai&&S.clearcoatNormalScale.value.negate())),w.dispersion>0&&(S.dispersion.value=w.dispersion),w.iridescence>0&&(S.iridescence.value=w.iridescence,S.iridescenceIOR.value=w.iridescenceIOR,S.iridescenceThicknessMinimum.value=w.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=w.iridescenceThicknessRange[1],w.iridescenceMap&&(S.iridescenceMap.value=w.iridescenceMap,t(w.iridescenceMap,S.iridescenceMapTransform)),w.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=w.iridescenceThicknessMap,t(w.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),w.transmission>0&&(S.transmission.value=w.transmission,S.transmissionSamplerMap.value=C.texture,S.transmissionSamplerSize.value.set(C.width,C.height),w.transmissionMap&&(S.transmissionMap.value=w.transmissionMap,t(w.transmissionMap,S.transmissionMapTransform)),S.thickness.value=w.thickness,w.thicknessMap&&(S.thicknessMap.value=w.thicknessMap,t(w.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=w.attenuationDistance,S.attenuationColor.value.copy(w.attenuationColor)),w.anisotropy>0&&(S.anisotropyVector.value.set(w.anisotropy*Math.cos(w.anisotropyRotation),w.anisotropy*Math.sin(w.anisotropyRotation)),w.anisotropyMap&&(S.anisotropyMap.value=w.anisotropyMap,t(w.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=w.specularIntensity,S.specularColor.value.copy(w.specularColor),w.specularColorMap&&(S.specularColorMap.value=w.specularColorMap,t(w.specularColorMap,S.specularColorMapTransform)),w.specularIntensityMap&&(S.specularIntensityMap.value=w.specularIntensityMap,t(w.specularIntensityMap,S.specularIntensityMapTransform))}function x(S,w){w.matcap&&(S.matcap.value=w.matcap)}function T(S,w){const C=e.get(w).light;S.referencePosition.value.setFromMatrixPosition(C.matrixWorld),S.nearDistance.value=C.shadow.camera.near,S.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function kG(i,e,t,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(C,E){const N=E.program;n.uniformBlockBinding(C,N)}function u(C,E){let N=r[C.id];N===void 0&&(x(C),N=d(C),r[C.id]=N,C.addEventListener("dispose",S));const L=E.program;n.updateUBOMapping(C,L);const B=e.render.frame;s[C.id]!==B&&(g(C),s[C.id]=B)}function d(C){const E=A();C.__bindingPointIndex=E;const N=i.createBuffer(),L=C.__size,B=C.usage;return i.bindBuffer(i.UNIFORM_BUFFER,N),i.bufferData(i.UNIFORM_BUFFER,L,B),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,E,N),N}function A(){for(let C=0;C0&&(N+=L-B),C.__size=N,C.__cache={},this}function T(C){const E={boundary:0,storage:0};return typeof C=="number"||typeof C=="boolean"?(E.boundary=4,E.storage=4):C.isVector2?(E.boundary=8,E.storage=8):C.isVector3||C.isColor?(E.boundary=16,E.storage=12):C.isVector4?(E.boundary=16,E.storage=16):C.isMatrix3?(E.boundary=48,E.storage=48):C.isMatrix4?(E.boundary=64,E.storage=64):C.isTexture?Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ue("WebGLRenderer: Unsupported uniform value type.",C),E}function S(C){const E=C.target;E.removeEventListener("dispose",S);const N=o.indexOf(E.__bindingPointIndex);o.splice(N,1),i.deleteBuffer(r[E.id]),delete r[E.id],delete s[E.id]}function w(){for(const C in r)i.deleteBuffer(r[C]);o=[],r={},s={}}return{bind:l,update:u,dispose:w}}const VG=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 Ga=null;function GG(){return Ga===null&&(Ga=new vb(VG,16,16,Hs,zi),Ga.name="DFG_LUT",Ga.minFilter=ki,Ga.magFilter=ki,Ga.wrapS=io,Ga.wrapT=io,Ga.generateMipmaps=!1,Ga.needsUpdate=!0),Ga}class qG{constructor(e={}){const{canvas:t=aR(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:A=!1,reversedDepthBuffer:g=!1,outputBufferType:v=Gi}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=o;const T=v,S=new Set([Wd,Hd,zd]),w=new Set([Gi,vi,ga,Po,G1,q1]),C=new Uint32Array(4),E=new Int32Array(4);let N=null,L=null;const B=[],I=[];let F=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=ls,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let O=!1;this._outputColorSpace=as;let G=0,q=0,j=null,Y=-1,$=null;const Q=new dn,ee=new dn;let ue=null;const le=new Gt(0);let de=0,Te=t.width,Qe=t.height,Ye=1,Et=null,at=null;const ve=new dn(0,0,Te,Qe),Re=new dn(0,0,Te,Qe);let Je=!1;const Ct=new $d;let et=!1,qt=!1;const en=new gn,zt=new te,Oe=new dn,tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ve=!1;function pt(){return j===null?Ye:1}let ae=n;function tn(K,Se){return t.getContext(K,Se)}try{const K={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:A};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${wh}`),t.addEventListener("webglcontextlost",hn,!1),t.addEventListener("webglcontextrestored",ai,!1),t.addEventListener("webglcontextcreationerror",nn,!1),ae===null){const Se="webgl2";if(ae=tn(Se,K),ae===null)throw tn(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(K){throw He("WebGLRenderer: "+K.message),K}let St,jt,ft,ie,H,_e,Le,$e,De,Ht,mt,Ot,Qt,it,_t,kt,Nt,Tt,wn,ne,vt,dt,Rt,rt;function Ge(){St=new Gk(ae),St.init(),dt=new DG(ae,St),jt=new Dk(ae,St,e,dt),ft=new NG(ae,St),jt.reversedDepthBuffer&&g&&ft.buffers.depth.setReversed(!0),ie=new Hk(ae),H=new pG,_e=new PG(ae,St,ft,H,jt,dt,ie),Le=new Ik(P),$e=new Vk(P),De=new XU(ae),Rt=new Nk(ae,De),Ht=new qk(ae,De,ie,Rt),mt=new $k(ae,Ht,De,ie),wn=new Wk(ae,jt,_e),kt=new Lk(H),Ot=new AG(P,Le,$e,St,jt,Rt,kt),Qt=new OG(P,H),it=new gG,_t=new SG(St),Tt=new Rk(P,Le,$e,ft,mt,x,l),Nt=new CG(P,mt,jt),rt=new kG(ae,ie,jt,ft),ne=new Pk(ae,St,ie),vt=new zk(ae,St,ie),ie.programs=Ot.programs,P.capabilities=jt,P.extensions=St,P.properties=H,P.renderLists=it,P.shadowMap=Nt,P.state=ft,P.info=ie}Ge(),T!==Gi&&(F=new Xk(T,t.width,t.height,r,s));const xt=new UG(P,ae);this.xr=xt,this.getContext=function(){return ae},this.getContextAttributes=function(){return ae.getContextAttributes()},this.forceContextLoss=function(){const K=St.get("WEBGL_lose_context");K&&K.loseContext()},this.forceContextRestore=function(){const K=St.get("WEBGL_lose_context");K&&K.restoreContext()},this.getPixelRatio=function(){return Ye},this.setPixelRatio=function(K){K!==void 0&&(Ye=K,this.setSize(Te,Qe,!1))},this.getSize=function(K){return K.set(Te,Qe)},this.setSize=function(K,Se,Ce=!0){if(xt.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}Te=K,Qe=Se,t.width=Math.floor(K*Ye),t.height=Math.floor(Se*Ye),Ce===!0&&(t.style.width=K+"px",t.style.height=Se+"px"),F!==null&&F.setSize(t.width,t.height),this.setViewport(0,0,K,Se)},this.getDrawingBufferSize=function(K){return K.set(Te*Ye,Qe*Ye).floor()},this.setDrawingBufferSize=function(K,Se,Ce){Te=K,Qe=Se,Ye=Ce,t.width=Math.floor(K*Ce),t.height=Math.floor(Se*Ce),this.setViewport(0,0,K,Se)},this.setEffects=function(K){if(T===Gi){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(K){for(let Se=0;Se{function Fe(){if(xe.forEach(function(It){H.get(It).currentProgram.isReady()&&xe.delete(It)}),xe.size===0){V(K);return}setTimeout(Fe,10)}St.get("KHR_parallel_shader_compile")!==null?Fe():setTimeout(Fe,10)})};let yt=null;function je(K){yt&&yt(K)}function f(){Nn.stop()}function W(){Nn.start()}const Nn=new PR;Nn.setAnimationLoop(je),typeof self<"u"&&Nn.setContext(self),this.setAnimationLoop=function(K){yt=K,xt.setAnimationLoop(K),K===null?Nn.stop():Nn.start()},xt.addEventListener("sessionstart",f),xt.addEventListener("sessionend",W),this.render=function(K,Se){if(Se!==void 0&&Se.isCamera!==!0){He("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(O===!0)return;const Ce=xt.enabled===!0&&xt.isPresenting===!0,xe=F!==null&&(j===null||Ce)&&F.begin(P,j);if(K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),xt.enabled===!0&&xt.isPresenting===!0&&(F===null||F.isCompositing()===!1)&&(xt.cameraAutoUpdate===!0&&xt.updateCamera(Se),Se=xt.getCamera()),K.isScene===!0&&K.onBeforeRender(P,K,Se,j),L=_t.get(K,I.length),L.init(Se),I.push(L),en.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),Ct.setFromProjectionMatrix(en,Ws,Se.reversedDepth),qt=this.localClippingEnabled,et=kt.init(this.clippingPlanes,qt),N=it.get(K,B.length),N.init(),B.push(N),xt.enabled===!0&&xt.isPresenting===!0){const It=P.xr.getDepthSensingMesh();It!==null&&qn(It,Se,-1/0,P.sortObjects)}qn(K,Se,0,P.sortObjects),N.finish(),P.sortObjects===!0&&N.sort(Et,at),Ve=xt.enabled===!1||xt.isPresenting===!1||xt.hasDepthSensing()===!1,Ve&&Tt.addToRenderList(N,K),this.info.render.frame++,et===!0&&kt.beginShadows();const V=L.state.shadowsArray;if(Nt.render(V,K,Se),et===!0&&kt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(xe&&F.hasRenderPass())===!1){const It=N.opaque,wt=N.transmissive;if(L.setupLights(),Se.isArrayCamera){const Ut=Se.cameras;if(wt.length>0)for(let Kt=0,un=Ut.length;Kt0&&bn(It,wt,K,Se),Ve&&Tt.render(K),Hi(N,K,Se)}j!==null&&q===0&&(_e.updateMultisampleRenderTarget(j),_e.updateRenderTargetMipmap(j)),xe&&F.end(P),K.isScene===!0&&K.onAfterRender(P,K,Se),Rt.resetDefaultState(),Y=-1,$=null,I.pop(),I.length>0?(L=I[I.length-1],et===!0&&kt.setGlobalState(P.clippingPlanes,L.state.camera)):L=null,B.pop(),B.length>0?N=B[B.length-1]:N=null};function qn(K,Se,Ce,xe){if(K.visible===!1)return;if(K.layers.test(Se.layers)){if(K.isGroup)Ce=K.renderOrder;else if(K.isLOD)K.autoUpdate===!0&&K.update(Se);else if(K.isLight)L.pushLight(K),K.castShadow&&L.pushShadow(K);else if(K.isSprite){if(!K.frustumCulled||Ct.intersectsSprite(K)){xe&&Oe.setFromMatrixPosition(K.matrixWorld).applyMatrix4(en);const It=mt.update(K),wt=K.material;wt.visible&&N.push(K,It,wt,Ce,Oe.z,null)}}else if((K.isMesh||K.isLine||K.isPoints)&&(!K.frustumCulled||Ct.intersectsObject(K))){const It=mt.update(K),wt=K.material;if(xe&&(K.boundingSphere!==void 0?(K.boundingSphere===null&&K.computeBoundingSphere(),Oe.copy(K.boundingSphere.center)):(It.boundingSphere===null&&It.computeBoundingSphere(),Oe.copy(It.boundingSphere.center)),Oe.applyMatrix4(K.matrixWorld).applyMatrix4(en)),Array.isArray(wt)){const Ut=It.groups;for(let Kt=0,un=Ut.length;Kt0&&Pn(V,Se,Ce),Fe.length>0&&Pn(Fe,Se,Ce),It.length>0&&Pn(It,Se,Ce),ft.buffers.depth.setTest(!0),ft.buffers.depth.setMask(!0),ft.buffers.color.setMask(!0),ft.setPolygonOffset(!1)}function bn(K,Se,Ce,xe){if((Ce.isScene===!0?Ce.overrideMaterial:null)!==null)return;if(L.state.transmissionRenderTarget[xe.id]===void 0){const Bn=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");L.state.transmissionRenderTarget[xe.id]=new xa(1,1,{generateMipmaps:!0,type:Bn?zi:Gi,minFilter:ro,samples:jt.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ln.workingColorSpace})}const Fe=L.state.transmissionRenderTarget[xe.id],It=xe.viewport||Q;Fe.setSize(It.z*P.transmissionResolutionScale,It.w*P.transmissionResolutionScale);const wt=P.getRenderTarget(),Ut=P.getActiveCubeFace(),Kt=P.getActiveMipmapLevel();P.setRenderTarget(Fe),P.getClearColor(le),de=P.getClearAlpha(),de<1&&P.setClearColor(16777215,.5),P.clear(),Ve&&Tt.render(Ce);const un=P.toneMapping;P.toneMapping=ls;const z=xe.viewport;if(xe.viewport!==void 0&&(xe.viewport=void 0),L.setupLightsView(xe),et===!0&&kt.setGlobalState(P.clippingPlanes,xe),Pn(K,Ce,xe),_e.updateMultisampleRenderTarget(Fe),_e.updateRenderTargetMipmap(Fe),St.has("WEBGL_multisampled_render_to_texture")===!1){let Bn=!1;for(let Yn=0,bi=Se.length;Yn0),z=!!Ce.morphAttributes.position,Bn=!!Ce.morphAttributes.normal,Yn=!!Ce.morphAttributes.color;let bi=ls;xe.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(bi=P.toneMapping);const Ui=Ce.morphAttributes.position||Ce.morphAttributes.normal||Ce.morphAttributes.color,ni=Ui!==void 0?Ui.length:0,rn=H.get(xe),ei=L.state.lights;if(et===!0&&(qt===!0||K!==$)){const Mr=K===$&&xe.id===Y;kt.setState(xe,K,Mr)}let On=!1;xe.version===rn.__version?(rn.needsLights&&rn.lightsStateVersion!==ei.state.version||rn.outputColorSpace!==wt||V.isBatchedMesh&&rn.batching===!1||!V.isBatchedMesh&&rn.batching===!0||V.isBatchedMesh&&rn.batchingColor===!0&&V.colorTexture===null||V.isBatchedMesh&&rn.batchingColor===!1&&V.colorTexture!==null||V.isInstancedMesh&&rn.instancing===!1||!V.isInstancedMesh&&rn.instancing===!0||V.isSkinnedMesh&&rn.skinning===!1||!V.isSkinnedMesh&&rn.skinning===!0||V.isInstancedMesh&&rn.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&rn.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&rn.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&rn.instancingMorph===!1&&V.morphTexture!==null||rn.envMap!==Ut||xe.fog===!0&&rn.fog!==Fe||rn.numClippingPlanes!==void 0&&(rn.numClippingPlanes!==kt.numPlanes||rn.numIntersection!==kt.numIntersection)||rn.vertexAlphas!==Kt||rn.vertexTangents!==un||rn.morphTargets!==z||rn.morphNormals!==Bn||rn.morphColors!==Yn||rn.toneMapping!==bi||rn.morphTargetsCount!==ni)&&(On=!0):(On=!0,rn.__version=xe.version);let _r=rn.currentProgram;On===!0&&(_r=kn(xe,Se,V));let wr=!1,Xn=!1,ra=!1;const li=_r.getUniforms(),ur=rn.uniforms;if(ft.useProgram(_r.program)&&(wr=!0,Xn=!0,ra=!0),xe.id!==Y&&(Y=xe.id,Xn=!0),wr||$!==K){ft.buffers.depth.getReversed()&&K.reversedDepth!==!0&&(K._reversedDepth=!0,K.updateProjectionMatrix()),li.setValue(ae,"projectionMatrix",K.projectionMatrix),li.setValue(ae,"viewMatrix",K.matrixWorldInverse);const cr=li.map.cameraPosition;cr!==void 0&&cr.setValue(ae,zt.setFromMatrixPosition(K.matrixWorld)),jt.logarithmicDepthBuffer&&li.setValue(ae,"logDepthBufFC",2/(Math.log(K.far+1)/Math.LN2)),(xe.isMeshPhongMaterial||xe.isMeshToonMaterial||xe.isMeshLambertMaterial||xe.isMeshBasicMaterial||xe.isMeshStandardMaterial||xe.isShaderMaterial)&&li.setValue(ae,"isOrthographic",K.isOrthographicCamera===!0),$!==K&&($=K,Xn=!0,ra=!0)}if(rn.needsLights&&(ei.state.directionalShadowMap.length>0&&li.setValue(ae,"directionalShadowMap",ei.state.directionalShadowMap,_e),ei.state.spotShadowMap.length>0&&li.setValue(ae,"spotShadowMap",ei.state.spotShadowMap,_e),ei.state.pointShadowMap.length>0&&li.setValue(ae,"pointShadowMap",ei.state.pointShadowMap,_e)),V.isSkinnedMesh){li.setOptional(ae,V,"bindMatrix"),li.setOptional(ae,V,"bindMatrixInverse");const Mr=V.skeleton;Mr&&(Mr.boneTexture===null&&Mr.computeBoneTexture(),li.setValue(ae,"boneTexture",Mr.boneTexture,_e))}V.isBatchedMesh&&(li.setOptional(ae,V,"batchingTexture"),li.setValue(ae,"batchingTexture",V._matricesTexture,_e),li.setOptional(ae,V,"batchingIdTexture"),li.setValue(ae,"batchingIdTexture",V._indirectTexture,_e),li.setOptional(ae,V,"batchingColorTexture"),V._colorsTexture!==null&&li.setValue(ae,"batchingColorTexture",V._colorsTexture,_e));const vr=Ce.morphAttributes;if((vr.position!==void 0||vr.normal!==void 0||vr.color!==void 0)&&wn.update(V,Ce,_r),(Xn||rn.receiveShadow!==V.receiveShadow)&&(rn.receiveShadow=V.receiveShadow,li.setValue(ae,"receiveShadow",V.receiveShadow)),xe.isMeshGouraudMaterial&&xe.envMap!==null&&(ur.envMap.value=Ut,ur.flipEnvMap.value=Ut.isCubeTexture&&Ut.isRenderTargetTexture===!1?-1:1),xe.isMeshStandardMaterial&&xe.envMap===null&&Se.environment!==null&&(ur.envMapIntensity.value=Se.environmentIntensity),ur.dfgLUT!==void 0&&(ur.dfgLUT.value=GG()),Xn&&(li.setValue(ae,"toneMappingExposure",P.toneMappingExposure),rn.needsLights&&Cl(ur,ra),Fe&&xe.fog===!0&&Qt.refreshFogUniforms(ur,Fe),Qt.refreshMaterialUniforms(ur,xe,Ye,Qe,L.state.transmissionRenderTarget[K.id]),mg.upload(ae,_n(rn),ur,_e)),xe.isShaderMaterial&&xe.uniformsNeedUpdate===!0&&(mg.upload(ae,_n(rn),ur,_e),xe.uniformsNeedUpdate=!1),xe.isSpriteMaterial&&li.setValue(ae,"center",V.center),li.setValue(ae,"modelViewMatrix",V.modelViewMatrix),li.setValue(ae,"normalMatrix",V.normalMatrix),li.setValue(ae,"modelMatrix",V.matrixWorld),xe.isShaderMaterial||xe.isRawShaderMaterial){const Mr=xe.uniformsGroups;for(let cr=0,Rl=Mr.length;cr0&&_e.useMultisampledRTT(K)===!1?xe=H.get(K).__webglMultisampledFramebuffer:Array.isArray(Kt)?xe=Kt[Ce]:xe=Kt,Q.copy(K.viewport),ee.copy(K.scissor),ue=K.scissorTest}else Q.copy(ve).multiplyScalar(Ye).floor(),ee.copy(Re).multiplyScalar(Ye).floor(),ue=Je;if(Ce!==0&&(xe=Zr),ft.bindFramebuffer(ae.FRAMEBUFFER,xe)&&ft.drawBuffers(K,xe),ft.viewport(Q),ft.scissor(ee),ft.setScissorTest(ue),V){const wt=H.get(K.texture);ae.framebufferTexture2D(ae.FRAMEBUFFER,ae.COLOR_ATTACHMENT0,ae.TEXTURE_CUBE_MAP_POSITIVE_X+Se,wt.__webglTexture,Ce)}else if(Fe){const wt=Se;for(let Ut=0;Ut=0&&Se<=K.width-xe&&Ce>=0&&Ce<=K.height-V&&(K.textures.length>1&&ae.readBuffer(ae.COLOR_ATTACHMENT0+wt),ae.readPixels(Se,Ce,xe,V,dt.convert(un),dt.convert(z),Fe))}finally{const Kt=j!==null?H.get(j).__webglFramebuffer:null;ft.bindFramebuffer(ae.FRAMEBUFFER,Kt)}}},this.readRenderTargetPixelsAsync=async function(K,Se,Ce,xe,V,Fe,It,wt=0){if(!(K&&K.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ut=H.get(K).__webglFramebuffer;if(K.isWebGLCubeRenderTarget&&It!==void 0&&(Ut=Ut[It]),Ut)if(Se>=0&&Se<=K.width-xe&&Ce>=0&&Ce<=K.height-V){ft.bindFramebuffer(ae.FRAMEBUFFER,Ut);const Kt=K.textures[wt],un=Kt.format,z=Kt.type;if(!jt.textureFormatReadable(un))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!jt.textureTypeReadable(z))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Bn=ae.createBuffer();ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Bn),ae.bufferData(ae.PIXEL_PACK_BUFFER,Fe.byteLength,ae.STREAM_READ),K.textures.length>1&&ae.readBuffer(ae.COLOR_ATTACHMENT0+wt),ae.readPixels(Se,Ce,xe,V,dt.convert(un),dt.convert(z),0);const Yn=j!==null?H.get(j).__webglFramebuffer:null;ft.bindFramebuffer(ae.FRAMEBUFFER,Yn);const bi=ae.fenceSync(ae.SYNC_GPU_COMMANDS_COMPLETE,0);return ae.flush(),await e9(ae,bi,4),ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Bn),ae.getBufferSubData(ae.PIXEL_PACK_BUFFER,0,Fe),ae.deleteBuffer(Bn),ae.deleteSync(bi),Fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(K,Se=null,Ce=0){const xe=Math.pow(2,-Ce),V=Math.floor(K.image.width*xe),Fe=Math.floor(K.image.height*xe),It=Se!==null?Se.x:0,wt=Se!==null?Se.y:0;_e.setTexture2D(K,0),ae.copyTexSubImage2D(ae.TEXTURE_2D,Ce,0,0,It,wt,V,Fe),ft.unbindTexture()};const go=ae.createFramebuffer(),gs=ae.createFramebuffer();this.copyTextureToTexture=function(K,Se,Ce=null,xe=null,V=0,Fe=null){Fe===null&&(V!==0?(Ci("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Fe=V,V=0):Fe=0);let It,wt,Ut,Kt,un,z,Bn,Yn,bi;const Ui=K.isCompressedTexture?K.mipmaps[Fe]:K.image;if(Ce!==null)It=Ce.max.x-Ce.min.x,wt=Ce.max.y-Ce.min.y,Ut=Ce.isBox3?Ce.max.z-Ce.min.z:1,Kt=Ce.min.x,un=Ce.min.y,z=Ce.isBox3?Ce.min.z:0;else{const vr=Math.pow(2,-V);It=Math.floor(Ui.width*vr),wt=Math.floor(Ui.height*vr),K.isDataArrayTexture?Ut=Ui.depth:K.isData3DTexture?Ut=Math.floor(Ui.depth*vr):Ut=1,Kt=0,un=0,z=0}xe!==null?(Bn=xe.x,Yn=xe.y,bi=xe.z):(Bn=0,Yn=0,bi=0);const ni=dt.convert(Se.format),rn=dt.convert(Se.type);let ei;Se.isData3DTexture?(_e.setTexture3D(Se,0),ei=ae.TEXTURE_3D):Se.isDataArrayTexture||Se.isCompressedArrayTexture?(_e.setTexture2DArray(Se,0),ei=ae.TEXTURE_2D_ARRAY):(_e.setTexture2D(Se,0),ei=ae.TEXTURE_2D),ae.pixelStorei(ae.UNPACK_FLIP_Y_WEBGL,Se.flipY),ae.pixelStorei(ae.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),ae.pixelStorei(ae.UNPACK_ALIGNMENT,Se.unpackAlignment);const On=ae.getParameter(ae.UNPACK_ROW_LENGTH),_r=ae.getParameter(ae.UNPACK_IMAGE_HEIGHT),wr=ae.getParameter(ae.UNPACK_SKIP_PIXELS),Xn=ae.getParameter(ae.UNPACK_SKIP_ROWS),ra=ae.getParameter(ae.UNPACK_SKIP_IMAGES);ae.pixelStorei(ae.UNPACK_ROW_LENGTH,Ui.width),ae.pixelStorei(ae.UNPACK_IMAGE_HEIGHT,Ui.height),ae.pixelStorei(ae.UNPACK_SKIP_PIXELS,Kt),ae.pixelStorei(ae.UNPACK_SKIP_ROWS,un),ae.pixelStorei(ae.UNPACK_SKIP_IMAGES,z);const li=K.isDataArrayTexture||K.isData3DTexture,ur=Se.isDataArrayTexture||Se.isData3DTexture;if(K.isDepthTexture){const vr=H.get(K),Mr=H.get(Se),cr=H.get(vr.__renderTarget),Rl=H.get(Mr.__renderTarget);ft.bindFramebuffer(ae.READ_FRAMEBUFFER,cr.__webglFramebuffer),ft.bindFramebuffer(ae.DRAW_FRAMEBUFFER,Rl.__webglFramebuffer);for(let Uo=0;Uo=-1&&af.z<=1&&x.layers.test(S.layers)===!0,C=x.element;C.style.display=w===!0?"":"none",w===!0&&(x.onBeforeRender(t,T,S),C.style.transform="translate("+-100*x.center.x+"%,"+-100*x.center.y+"%)translate("+(af.x*s+s)+"px,"+(-af.y*o+o)+"px)",C.parentNode!==l&&l.appendChild(C),x.onAfterRender(t,T,S));const E={distanceToCameraSquared:A(S,x)};a.objects.set(x,E)}for(let w=0,C=x.children.length;w=e||I<0||A&&F>=s}function w(){var B=X2();if(S(B))return C(B);a=setTimeout(w,T(B))}function C(B){return a=void 0,g&&n?v(B):(n=r=void 0,o)}function E(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0}function N(){return a===void 0?o:C(X2())}function L(){var B=X2(),I=S(B);if(n=arguments,r=this,l=B,I){if(a===void 0)return x(l);if(A)return clearTimeout(a),a=setTimeout(w,e),v(l)}return a===void 0&&(a=setTimeout(w,e)),o}return L.cancel=E,L.flush=N,L}function yM(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),HA=function(){return performance.now()},J1=function(){function i(){for(var e=[],t=0;t0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},OR=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),mx=new J1,Ns=function(){function i(e,t){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=Lr.Linear.None,this._interpolationFunction=px.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=OR.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=mx,mx.add(this))}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=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=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=HA()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}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||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var o in n){var a=e[o],l=Array.isArray(a),u=l?"array":typeof a,d=!l&&Array.isArray(n[o]);if(!(u==="undefined"||u==="function")){if(d){var A=n[o];if(A.length===0)continue;for(var g=[a],v=0,x=A.length;v"u"||s)&&(t[o]=a),l||(t[o]*=1),d?r[o]=n[o].slice().reverse():r[o]=t[o]||0}}},i.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},i.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},i.prototype.pause=function(e){return e===void 0&&(e=HA()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=HA()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;el)return 1;var T=Math.trunc(o/a),S=o-T*a,w=Math.min(S/n._duration,1);return w===0&&o===n._duration?1:w},d=u(),A=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,A),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var g=Math.min(Math.trunc((o-this._duration)/a)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=g);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=a*g,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var v=0,x=this._chainedTweens.length;v=(x=(l+A)/2))?l=x:A=x,(L=t>=(T=(u+g)/2))?u=T:g=T,(B=n>=(S=(d+v)/2))?d=S:v=S,s=o,!(o=o[I=B<<2|L<<1|N]))return s[I]=a,i;if(w=+i._x.call(null,o.data),C=+i._y.call(null,o.data),E=+i._z.call(null,o.data),e===w&&t===C&&n===E)return a.next=o,s?s[I]=a:i._root=a,i;do s=s?s[I]=new Array(8):i._root=new Array(8),(N=e>=(x=(l+A)/2))?l=x:A=x,(L=t>=(T=(u+g)/2))?u=T:g=T,(B=n>=(S=(d+v)/2))?d=S:v=S;while((I=B<<2|L<<1|N)===(F=(E>=S)<<2|(C>=T)<<1|w>=x));return s[F]=o,s[I]=a,i}function Mq(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,d=-1/0;for(let A=0,g,v,x,T;Al&&(l=v),xu&&(u=x),Td&&(d=T));if(s>l||o>u||a>d)return this;this.cover(s,o,a).cover(l,u,d);for(let A=0;Ai||i>=o||r>e||e>=a||s>t||t>=l;)switch(g=(tx||(u=E.y0)>T||(d=E.z0)>S||(A=E.x1)=I)<<2|(e>=B)<<1|i>=L)&&(E=w[w.length-1],w[w.length-1]=w[w.length-1-N],w[w.length-1-N]=E)}else{var F=i-+this._x.call(null,C.data),P=e-+this._y.call(null,C.data),O=t-+this._z.call(null,C.data),G=F*F+P*P+O*O;if(GMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function Dq(i,e,t,n){const r=[],s=i-n,o=e-n,a=t-n,l=i+n,u=e+n,d=t+n;return this.visit((A,g,v,x,T,S,w)=>{if(!A.length)do{const C=A.data;Pq(i,e,t,this._x(C),this._y(C),this._z(C))<=n&&r.push(C)}while(A=A.next);return g>l||v>u||x>d||T=(T=(o+u)/2))?o=T:u=T,(E=v>=(S=(a+d)/2))?a=S:d=S,(N=x>=(w=(l+A)/2))?l=w:A=w,e=t,!(t=t[L=N<<2|E<<1|C]))return this;if(!t.length)break;(e[L+1&7]||e[L+2&7]||e[L+3&7]||e[L+4&7]||e[L+5&7]||e[L+6&7]||e[L+7&7])&&(n=e,B=L)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[L]=s:delete e[L],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[B]=t:this._root=t),this):(this._root=s,this)}function Iq(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function Wq(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function GR(i){let e,t,n;i.length!==2?(e=gg,t=(a,l)=>gg(i(a),l),n=(a,l)=>i(a)-l):(e=i===gg||i===Wq?i:$q,t=i,n=i);function r(a,l,u=0,d=a.length){if(u>>1;t(a[A],l)<0?u=A+1:d=A}while(u>>1;t(a[A],l)<=0?u=A+1:d=A}while(uu&&n(a[A-1],l)>-n(a[A],l)?A-1:A}return{left:r,center:o,right:s}}function $q(){return 0}function jq(i){return i===null?NaN:+i}const Xq=GR(gg),qR=Xq.right;GR(jq).center;function Vg(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(o=e[--t];t>0&&(n=o,r=e[--t],o=n+r,s=r-(o-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=o+r,r==n-o&&(o=n))}return o}}const Qq=Math.sqrt(50),Yq=Math.sqrt(10),Kq=Math.sqrt(2);function Gg(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),o=s>=Qq?10:s>=Yq?5:s>=Kq?2:1;let a,l,u;return r<0?(u=Math.pow(10,-r)/o,a=Math.round(i*u),l=Math.round(e*u),a/ue&&--l,u=-u):(u=Math.pow(10,r)*o,a=Math.round(i/u),l=Math.round(e/u),a*ue&&--l),l0))return[];if(i===e)return[i];const n=e=r))return[];const a=s-r+1,l=new Array(a);if(n)if(o<0)for(let u=0;u=n)&&(t=n);return t}function tz(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*nz(i){for(const e of i)yield*e}function B0(i){return Array.from(nz(i))}function Pf(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?mm(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?mm(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=sz.exec(i))?new oo(e[1],e[2],e[3],1):(e=oz.exec(i))?new oo(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=az.exec(i))?mm(e[1],e[2],e[3],e[4]):(e=lz.exec(i))?mm(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=uz.exec(i))?RM(e[1],e[2]/100,e[3]/100,1):(e=cz.exec(i))?RM(e[1],e[2]/100,e[3]/100,e[4]):SM.hasOwnProperty(i)?MM(SM[i]):i==="transparent"?new oo(NaN,NaN,NaN,0):null}function MM(i){return new oo(i>>16&255,i>>8&255,i&255,1)}function mm(i,e,t,n){return n<=0&&(i=e=t=NaN),new oo(i,e,t,n)}function dz(i){return i instanceof Ap||(i=xh(i)),i?(i=i.rgb(),new oo(i.r,i.g,i.b,i.opacity)):new oo}function _x(i,e,t,n){return arguments.length===1?dz(i):new oo(i,e,t,n??1)}function oo(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}Lb(oo,_x,HR(Ap,{brighter(i){return i=i==null?qg:Math.pow(qg,i),new oo(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?U0:Math.pow(U0,i),new oo(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new oo(uh(this.r),uh(this.g),uh(this.b),zg(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:EM,formatHex:EM,formatHex8:Az,formatRgb:CM,toString:CM}));function EM(){return`#${th(this.r)}${th(this.g)}${th(this.b)}`}function Az(){return`#${th(this.r)}${th(this.g)}${th(this.b)}${th((isNaN(this.opacity)?1:this.opacity)*255)}`}function CM(){const i=zg(this.opacity);return`${i===1?"rgb(":"rgba("}${uh(this.r)}, ${uh(this.g)}, ${uh(this.b)}${i===1?")":`, ${i})`}`}function zg(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function uh(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function th(i){return i=uh(i),(i<16?"0":"")+i.toString(16)}function RM(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new pa(i,e,t,n)}function WR(i){if(i instanceof pa)return new pa(i.h,i.s,i.l,i.opacity);if(i instanceof Ap||(i=xh(i)),!i)return new pa;if(i instanceof pa)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),o=NaN,a=s-r,l=(s+r)/2;return a?(e===s?o=(t-n)/a+(t0&&l<1?0:o,new pa(o,a,l,i.opacity)}function pz(i,e,t,n){return arguments.length===1?WR(i):new pa(i,e,t,n??1)}function pa(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}Lb(pa,pz,HR(Ap,{brighter(i){return i=i==null?qg:Math.pow(qg,i),new pa(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?U0:Math.pow(U0,i),new pa(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new oo(Q2(i>=240?i-240:i+120,r,n),Q2(i,r,n),Q2(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new pa(NM(this.h),gm(this.s),gm(this.l),zg(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 i=zg(this.opacity);return`${i===1?"hsl(":"hsla("}${NM(this.h)}, ${gm(this.s)*100}%, ${gm(this.l)*100}%${i===1?")":`, ${i})`}`}}));function NM(i){return i=(i||0)%360,i<0?i+360:i}function gm(i){return Math.max(0,Math.min(1,i||0))}function Q2(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const Ib=i=>()=>i;function mz(i,e){return function(t){return i+t*e}}function gz(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function _z(i){return(i=+i)==1?$R:function(e,t){return t-e?gz(e,t,i):Ib(isNaN(e)?t:e)}}function $R(i,e){var t=e-i;return t?mz(i,t):Ib(isNaN(i)?e:i)}const PM=function i(e){var t=_z(e);function n(r,s){var o=t((r=_x(r)).r,(s=_x(s)).r),a=t(r.g,s.g),l=t(r.b,s.b),u=$R(r.opacity,s.opacity);return function(d){return r.r=o(d),r.g=a(d),r.b=l(d),r.opacity=u(d),r+""}}return n.gamma=i,n}(1);function jR(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),a[o]?a[o]+=s:a[++o]=s),(n=n[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:O0(n,r)})),t=Y2.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function Rz(i,e,t){var n=i[0],r=i[1],s=e[0],o=e[1];return r2?Nz:Rz,l=u=null,A}function A(g){return g==null||isNaN(g=+g)?s:(l||(l=a(i.map(n),e,t)))(n(o(g)))}return A.invert=function(g){return o(r((u||(u=a(e,i.map(n),O0)))(g)))},A.domain=function(g){return arguments.length?(i=Array.from(g,Ez),d()):i.slice()},A.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},A.rangeRound=function(g){return e=Array.from(g),t=wz,d()},A.clamp=function(g){return arguments.length?(o=g?!0:Df,d()):o!==Df},A.interpolate=function(g){return arguments.length?(t=g,d()):t},A.unknown=function(g){return arguments.length?(s=g,A):s},function(g,v){return n=g,r=v,d()}}function Lz(){return Dz()(Df,Df)}function Iz(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function Hg(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function Rd(i){return i=Hg(Math.abs(i)),i?i[1]:NaN}function Bz(i,e){return function(t,n){for(var r=t.length,s=[],o=0,a=i[0],l=0;r>0&&a>0&&(l+a+1>n&&(a=Math.max(1,n-l)),s.push(t.substring(r-=a,r+a)),!((l+=a+1)>n));)a=i[o=(o+1)%i.length];return s.reverse().join(e)}}function Uz(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var Fz=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Wg(i){if(!(e=Fz.exec(i)))throw new Error("invalid format: "+i);var e;return new Ub({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Wg.prototype=Ub.prototype;function Ub(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}Ub.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Oz(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var $g;function kz(i,e){var t=Hg(i,e);if(!t)return $g=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-($g=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=n.length;return s===o?n:s>o?n+new Array(s-o+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+Hg(i,Math.max(0,e+s-1))[0]}function LM(i,e){var t=Hg(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const IM={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:Iz,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>LM(i*100,e),r:LM,s:kz,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function BM(i){return i}var UM=Array.prototype.map,FM=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Vz(i){var e=i.grouping===void 0||i.thousands===void 0?BM:Bz(UM.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?BM:Uz(UM.call(i.numerals,String)),o=i.percent===void 0?"%":i.percent+"",a=i.minus===void 0?"−":i.minus+"",l=i.nan===void 0?"NaN":i.nan+"";function u(A,g){A=Wg(A);var v=A.fill,x=A.align,T=A.sign,S=A.symbol,w=A.zero,C=A.width,E=A.comma,N=A.precision,L=A.trim,B=A.type;B==="n"?(E=!0,B="g"):IM[B]||(N===void 0&&(N=12),L=!0,B="g"),(w||v==="0"&&x==="=")&&(w=!0,v="0",x="=");var I=(g&&g.prefix!==void 0?g.prefix:"")+(S==="$"?t:S==="#"&&/[boxX]/.test(B)?"0"+B.toLowerCase():""),F=(S==="$"?n:/[%p]/.test(B)?o:"")+(g&&g.suffix!==void 0?g.suffix:""),P=IM[B],O=/[defgprs%]/.test(B);N=N===void 0?6:/[gprs]/.test(B)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function G(q){var j=I,Y=F,$,Q,ee;if(B==="c")Y=P(q)+Y,q="";else{q=+q;var ue=q<0||1/q<0;if(q=isNaN(q)?l:P(Math.abs(q),N),L&&(q=Oz(q)),ue&&+q==0&&T!=="+"&&(ue=!1),j=(ue?T==="("?T:a:T==="-"||T==="("?"":T)+j,Y=(B==="s"&&!isNaN(q)&&$g!==void 0?FM[8+$g/3]:"")+Y+(ue&&T==="("?")":""),O){for($=-1,Q=q.length;++$ee||ee>57){Y=(ee===46?r+q.slice($+1):q.slice($))+Y,q=q.slice(0,$);break}}}E&&!w&&(q=e(q,1/0));var le=j.length+q.length+Y.length,de=le>1)+j+q+Y+de.slice(le);break;default:q=de+j+q+Y;break}return s(q)}return G.toString=function(){return A+""},G}function d(A,g){var v=Math.max(-8,Math.min(8,Math.floor(Rd(g)/3)))*3,x=Math.pow(10,-v),T=u((A=Wg(A),A.type="f",A),{suffix:FM[8+v/3]});return function(S){return T(x*S)}}return{format:u,formatPrefix:d}}var _m,YR,KR;Gz({thousands:",",grouping:[3],currency:["$",""]});function Gz(i){return _m=Vz(i),YR=_m.format,KR=_m.formatPrefix,_m}function qz(i){return Math.max(0,-Rd(Math.abs(i)))}function zz(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Rd(e)/3)))*3-Rd(Math.abs(i)))}function Hz(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,Rd(e)-Rd(i))+1}function Wz(i,e,t,n){var r=Jq(i,e,t),s;switch(n=Wg(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=zz(r,o))&&(n.precision=s),KR(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=Hz(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=qz(r))&&(n.precision=s-(n.type==="%")*2);break}}return YR(n)}function ZR(i){var e=i.domain;return i.ticks=function(t){var n=e();return Zq(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return Wz(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,o=n[r],a=n[s],l,u,d=10;for(a0;){if(u=gx(o,a,t),u===l)return n[r]=o,n[s]=a,e(n);if(u>0)o=Math.floor(o/u)*u,a=Math.ceil(a/u)*u;else if(u<0)o=Math.ceil(o*u)/u,a=Math.floor(a*u)/u;else break;l=u}return i},i}function tu(){var i=Lz();return i.copy=function(){return Pz(i,tu())},zR.apply(i,arguments),ZR(i)}function JR(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function o(l){return l!=null&&l<=l?r[qR(n,l,0,t)]:s}function a(){var l=-1;for(n=new Array(t);++l=t?[n[t-1],e]:[n[u-1],n[u]]},o.unknown=function(l){return arguments.length&&(s=l),o},o.thresholds=function(){return n.slice()},o.copy=function(){return JR().domain([i,e]).range(r).unknown(s)},zR.apply(ZR(o),arguments)}var $n=1e-6,jg=1e-12,ri=Math.PI,ao=ri/2,Xg=ri/4,Lo=ri*2,fr=180/ri,Rn=ri/180,Ii=Math.abs,Fb=Math.atan,Qo=Math.atan2,In=Math.cos,vm=Math.ceil,$z=Math.exp,yx=Math.hypot,jz=Math.log,Tn=Math.sin,Xz=Math.sign||function(i){return i>0?1:i<0?-1:0},nu=Math.sqrt,Qz=Math.tan;function Yz(i){return i>1?0:i<-1?ri:Math.acos(i)}function iu(i){return i>1?ao:i<-1?-ao:Math.asin(i)}function OM(i){return(i=Tn(i/2))*i}function Ss(){}function Qg(i,e){i&&VM.hasOwnProperty(i.type)&&VM[i.type](i,e)}var kM={Feature:function(i,e){Qg(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=In(e),o=Tn(e),a=wx*o,l=Tx*s+a*In(r),u=a*n*Tn(r);Yg.add(Qo(u,l)),Sx=i,Tx=s,wx=o}function Kg(i){return[Qo(i[1],i[0]),iu(i[2])]}function yh(i){var e=i[0],t=i[1],n=In(t);return[n*In(e),n*Tn(e),Tn(t)]}function xm(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function Nd(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function K2(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function ym(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function Zg(i){var e=nu(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var rr,eo,hr,Ro,zc,i8,r8,qf,s0,ku,su,kl={point:Mx,lineStart:zM,lineEnd:HM,polygonStart:function(){kl.point=o8,kl.lineStart=eH,kl.lineEnd=tH,s0=new Xl,ru.polygonStart()},polygonEnd:function(){ru.polygonEnd(),kl.point=Mx,kl.lineStart=zM,kl.lineEnd=HM,Yg<0?(rr=-(hr=180),eo=-(Ro=90)):s0>$n?Ro=90:s0<-$n&&(eo=-90),su[0]=rr,su[1]=hr},sphere:function(){rr=-(hr=180),eo=-(Ro=90)}};function Mx(i,e){ku.push(su=[rr=i,hr=i]),eRo&&(Ro=e)}function s8(i,e){var t=yh([i*Rn,e*Rn]);if(qf){var n=Nd(qf,t),r=[n[1],-n[0],0],s=Nd(r,n);Zg(s),s=Kg(s);var o=i-zc,a=o>0?1:-1,l=s[0]*fr*a,u,d=Ii(o)>180;d^(a*zcRo&&(Ro=u)):(l=(l+360)%360-180,d^(a*zcRo&&(Ro=e))),d?iMo(rr,hr)&&(hr=i):Mo(i,hr)>Mo(rr,hr)&&(rr=i):hr>=rr?(ihr&&(hr=i)):i>zc?Mo(rr,i)>Mo(rr,hr)&&(hr=i):Mo(i,hr)>Mo(rr,hr)&&(rr=i)}else ku.push(su=[rr=i,hr=i]);eRo&&(Ro=e),qf=t,zc=i}function zM(){kl.point=s8}function HM(){su[0]=rr,su[1]=hr,kl.point=Mx,qf=null}function o8(i,e){if(qf){var t=i-zc;s0.add(Ii(t)>180?t+(t>0?360:-360):t)}else i8=i,r8=e;ru.point(i,e),s8(i,e)}function eH(){ru.lineStart()}function tH(){o8(i8,r8),ru.lineEnd(),Ii(s0)>$n&&(rr=-(hr=180)),su[0]=rr,su[1]=hr,qf=null}function Mo(i,e){return(e-=i)<0?e+360:e}function nH(i,e){return i[0]-e[0]}function WM(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:eMo(n[0],n[1])&&(n[1]=r[1]),Mo(r[0],n[1])>Mo(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(o=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(a=Mo(n[1],r[0]))>o&&(o=a,rr=r[0],hr=n[1])}return ku=su=null,rr===1/0||eo===1/0?[[NaN,NaN],[NaN,NaN]]:[[rr,eo],[hr,Ro]]}var WA,Jg,e1,t1,n1,i1,r1,s1,Ex,Cx,Rx,l8,u8,Fs,Os,ks,_a={sphere:Ss,point:Ob,lineStart:$M,lineEnd:jM,polygonStart:function(){_a.lineStart=sH,_a.lineEnd=oH},polygonEnd:function(){_a.lineStart=$M,_a.lineEnd=jM}};function Ob(i,e){i*=Rn,e*=Rn;var t=In(e);pp(t*In(i),t*Tn(i),Tn(e))}function pp(i,e,t){++WA,e1+=(i-e1)/WA,t1+=(e-t1)/WA,n1+=(t-n1)/WA}function $M(){_a.point=iH}function iH(i,e){i*=Rn,e*=Rn;var t=In(e);Fs=t*In(i),Os=t*Tn(i),ks=Tn(e),_a.point=rH,pp(Fs,Os,ks)}function rH(i,e){i*=Rn,e*=Rn;var t=In(e),n=t*In(i),r=t*Tn(i),s=Tn(e),o=Qo(nu((o=Os*s-ks*r)*o+(o=ks*n-Fs*s)*o+(o=Fs*r-Os*n)*o),Fs*n+Os*r+ks*s);Jg+=o,i1+=o*(Fs+(Fs=n)),r1+=o*(Os+(Os=r)),s1+=o*(ks+(ks=s)),pp(Fs,Os,ks)}function jM(){_a.point=Ob}function sH(){_a.point=aH}function oH(){c8(l8,u8),_a.point=Ob}function aH(i,e){l8=i,u8=e,i*=Rn,e*=Rn,_a.point=c8;var t=In(e);Fs=t*In(i),Os=t*Tn(i),ks=Tn(e),pp(Fs,Os,ks)}function c8(i,e){i*=Rn,e*=Rn;var t=In(e),n=t*In(i),r=t*Tn(i),s=Tn(e),o=Os*s-ks*r,a=ks*n-Fs*s,l=Fs*r-Os*n,u=yx(o,a,l),d=iu(u),A=u&&-d/u;Ex.add(A*o),Cx.add(A*a),Rx.add(A*l),Jg+=d,i1+=d*(Fs+(Fs=n)),r1+=d*(Os+(Os=r)),s1+=d*(ks+(ks=s)),pp(Fs,Os,ks)}function XM(i){WA=Jg=e1=t1=n1=i1=r1=s1=0,Ex=new Xl,Cx=new Xl,Rx=new Xl,e_(i,_a);var e=+Ex,t=+Cx,n=+Rx,r=yx(e,t,n);return rri&&(i-=Math.round(i/Lo)*Lo),[i,e]}Px.invert=Px;function h8(i,e,t){return(i%=Lo)?e||t?Nx(YM(i),KM(e,t)):YM(i):e||t?KM(e,t):Px}function QM(i){return function(e,t){return e+=i,Ii(e)>ri&&(e-=Math.round(e/Lo)*Lo),[e,t]}}function YM(i){var e=QM(i);return e.invert=QM(-i),e}function KM(i,e){var t=In(i),n=Tn(i),r=In(e),s=Tn(e);function o(a,l){var u=In(l),d=In(a)*u,A=Tn(a)*u,g=Tn(l),v=g*t+d*n;return[Qo(A*r-v*s,d*t-g*n),iu(v*r+A*s)]}return o.invert=function(a,l){var u=In(l),d=In(a)*u,A=Tn(a)*u,g=Tn(l),v=g*r-A*s;return[Qo(A*r+g*s,d*t+v*n),iu(v*t-d*n)]},o}function lH(i){i=h8(i[0]*Rn,i[1]*Rn,i.length>2?i[2]*Rn:0);function e(t){return t=i(t[0]*Rn,t[1]*Rn),t[0]*=fr,t[1]*=fr,t}return e.invert=function(t){return t=i.invert(t[0]*Rn,t[1]*Rn),t[0]*=fr,t[1]*=fr,t},e}function uH(i,e,t,n,r,s){if(t){var o=In(e),a=Tn(e),l=n*t;r==null?(r=e+n*Lo,s=e-l/2):(r=ZM(o,r),s=ZM(o,s),(n>0?rs)&&(r+=n*Lo));for(var u,d=r;n>0?d>s:d1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function _g(i,e){return Ii(i[0]-e[0])<$n&&Ii(i[1]-e[1])<$n}function bm(i,e,t,n){this.x=i,this.z=e,this.o=t,this.e=n,this.v=!1,this.n=this.p=null}function d8(i,e,t,n,r){var s=[],o=[],a,l;if(i.forEach(function(x){if(!((T=x.length-1)<=0)){var T,S=x[0],w=x[T],C;if(_g(S,w)){if(!S[2]&&!w[2]){for(r.lineStart(),a=0;a=0;--a)r.point((A=d[a])[0],A[1]);else n(g.x,g.p.x,-1,r);g=g.p}g=g.o,d=g.z,v=!v}while(!g.v);r.lineEnd()}}}function JM(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,O=P*F,G=O>ri,q=S*B;if(l.add(Qo(q*P*Tn(O),w*I+q*In(O))),o+=G?F+P*Lo:F,G^x>=t^N>=t){var j=Nd(yh(v),yh(E));Zg(j);var Y=Nd(s,j);Zg(Y);var $=(G^F>=0?-1:1)*iu(Y[2]);(n>$||n===$&&(j[0]||j[1]))&&(a+=G^F>=0?1:-1)}}return(o<-$n||o<$n&&l<-jg)^a&1}function p8(i,e,t,n){return function(r){var s=e(r),o=f8(),a=e(o),l=!1,u,d,A,g={point:v,lineStart:T,lineEnd:S,polygonStart:function(){g.point=w,g.lineStart=C,g.lineEnd=E,d=[],u=[]},polygonEnd:function(){g.point=v,g.lineStart=T,g.lineEnd=S,d=B0(d);var N=A8(u,n);d.length?(l||(r.polygonStart(),l=!0),d8(d,hH,N,t,r)):N&&(l||(r.polygonStart(),l=!0),r.lineStart(),t(null,null,1,r),r.lineEnd()),l&&(r.polygonEnd(),l=!1),d=u=null},sphere:function(){r.polygonStart(),r.lineStart(),t(null,null,1,r),r.lineEnd(),r.polygonEnd()}};function v(N,L){i(N,L)&&r.point(N,L)}function x(N,L){s.point(N,L)}function T(){g.point=x,s.lineStart()}function S(){g.point=v,s.lineEnd()}function w(N,L){A.push([N,L]),a.point(N,L)}function C(){a.lineStart(),A=[]}function E(){w(A[0][0],A[0][1]),a.lineEnd();var N=a.clean(),L=o.result(),B,I=L.length,F,P,O;if(A.pop(),u.push(A),A=null,!!I){if(N&1){if(P=L[0],(F=P.length-1)>0){for(l||(r.polygonStart(),l=!0),r.lineStart(),B=0;B1&&N&2&&L.push(L.pop().concat(L.shift())),d.push(L.filter(cH))}}return g}}function cH(i){return i.length>1}function hH(i,e){return((i=i.x)[0]<0?i[1]-ao-$n:ao-i[1])-((e=e.x)[0]<0?e[1]-ao-$n:ao-e[1])}const eE=p8(function(){return!0},fH,AH,[-ri,-ao]);function fH(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,o){var a=s>0?ri:-ri,l=Ii(s-e);Ii(l-ri)<$n?(i.point(e,t=(t+o)/2>0?ao:-ao),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(a,t),i.point(s,t),r=0):n!==a&&l>=ri&&(Ii(e-n)<$n&&(e-=n*$n),Ii(s-a)<$n&&(s-=a*$n),t=dH(e,t,s,o),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(a,t),r=0),i.point(e=s,t=o),n=a},lineEnd:function(){i.lineEnd(),e=t=NaN},clean:function(){return 2-r}}}function dH(i,e,t,n){var r,s,o=Tn(i-t);return Ii(o)>$n?Fb((Tn(e)*(s=In(n))*Tn(t)-Tn(n)*(r=In(e))*Tn(i))/(r*s*o)):(e+n)/2}function AH(i,e,t,n){var r;if(i==null)r=t*ao,n.point(-ri,r),n.point(0,r),n.point(ri,r),n.point(ri,0),n.point(ri,-r),n.point(0,-r),n.point(-ri,-r),n.point(-ri,0),n.point(-ri,r);else if(Ii(i[0]-e[0])>$n){var s=i[0]0,r=Ii(e)>$n;function s(d,A,g,v){uH(v,i,t,g,d,A)}function o(d,A){return In(d)*In(A)>e}function a(d){var A,g,v,x,T;return{lineStart:function(){x=v=!1,T=1},point:function(S,w){var C=[S,w],E,N=o(S,w),L=n?N?0:u(S,w):N?u(S+(S<0?ri:-ri),w):0;if(!A&&(x=v=N)&&d.lineStart(),N!==v&&(E=l(A,C),(!E||_g(A,E)||_g(C,E))&&(C[2]=1)),N!==v)T=0,N?(d.lineStart(),E=l(C,A),d.point(E[0],E[1])):(E=l(A,C),d.point(E[0],E[1],2),d.lineEnd()),A=E;else if(r&&A&&n^N){var B;!(L&g)&&(B=l(C,A,!0))&&(T=0,n?(d.lineStart(),d.point(B[0][0],B[0][1]),d.point(B[1][0],B[1][1]),d.lineEnd()):(d.point(B[1][0],B[1][1]),d.lineEnd(),d.lineStart(),d.point(B[0][0],B[0][1],3)))}N&&(!A||!_g(A,C))&&d.point(C[0],C[1]),A=C,v=N,g=L},lineEnd:function(){v&&d.lineEnd(),A=null},clean:function(){return T|(x&&v)<<1}}}function l(d,A,g){var v=yh(d),x=yh(A),T=[1,0,0],S=Nd(v,x),w=xm(S,S),C=S[0],E=w-C*C;if(!E)return!g&&d;var N=e*w/E,L=-e*C/E,B=Nd(T,S),I=ym(T,N),F=ym(S,L);K2(I,F);var P=B,O=xm(I,P),G=xm(P,P),q=O*O-G*(xm(I,I)-1);if(!(q<0)){var j=nu(q),Y=ym(P,(-O-j)/G);if(K2(Y,I),Y=Kg(Y),!g)return Y;var $=d[0],Q=A[0],ee=d[1],ue=A[1],le;Q<$&&(le=$,$=Q,Q=le);var de=Q-$,Te=Ii(de-ri)<$n,Qe=Te||de<$n;if(!Te&&ue0^Y[1]<(Ii(Y[0]-$)<$n?ee:ue):ee<=Y[1]&&Y[1]<=ue:de>ri^($<=Y[0]&&Y[0]<=Q)){var Ye=ym(P,(-O+j)/G);return K2(Ye,I),[Y,Kg(Ye)]}}}function u(d,A){var g=n?i:ri-i,v=0;return d<-g?v|=1:d>g&&(v|=2),A<-g?v|=4:A>g&&(v|=8),v}return p8(o,a,s,n?[0,-i]:[-ri,i-ri])}function mH(i,e,t,n,r,s){var o=i[0],a=i[1],l=e[0],u=e[1],d=0,A=1,g=l-o,v=u-a,x;if(x=t-o,!(!g&&x>0)){if(x/=g,g<0){if(x0){if(x>A)return;x>d&&(d=x)}if(x=r-o,!(!g&&x<0)){if(x/=g,g<0){if(x>A)return;x>d&&(d=x)}else if(g>0){if(x0)){if(x/=v,v<0){if(x0){if(x>A)return;x>d&&(d=x)}if(x=s-a,!(!v&&x<0)){if(x/=v,v<0){if(x>A)return;x>d&&(d=x)}else if(v>0){if(x0&&(i[0]=o+d*g,i[1]=a+d*v),A<1&&(e[0]=o+A*g,e[1]=a+A*v),!0}}}}}var $A=1e9,Sm=-$A;function gH(i,e,t,n){function r(u,d){return i<=u&&u<=t&&e<=d&&d<=n}function s(u,d,A,g){var v=0,x=0;if(u==null||(v=o(u,A))!==(x=o(d,A))||l(u,d)<0^A>0)do g.point(v===0||v===3?i:t,v>1?n:e);while((v=(v+A+4)%4)!==x);else g.point(d[0],d[1])}function o(u,d){return Ii(u[0]-i)<$n?d>0?0:3:Ii(u[0]-t)<$n?d>0?2:1:Ii(u[1]-e)<$n?d>0?1:0:d>0?3:2}function a(u,d){return l(u.x,d.x)}function l(u,d){var A=o(u,1),g=o(d,1);return A!==g?A-g:A===0?d[1]-u[1]:A===1?u[0]-d[0]:A===2?u[1]-d[1]:d[0]-u[0]}return function(u){var d=u,A=f8(),g,v,x,T,S,w,C,E,N,L,B,I={point:F,lineStart:q,lineEnd:j,polygonStart:O,polygonEnd:G};function F($,Q){r($,Q)&&d.point($,Q)}function P(){for(var $=0,Q=0,ee=v.length;Qn&&(Et-Qe)*(n-Ye)>(at-Ye)*(i-Qe)&&++$:at<=n&&(Et-Qe)*(n-Ye)<(at-Ye)*(i-Qe)&&--$;return $}function O(){d=A,g=[],v=[],B=!0}function G(){var $=P(),Q=B&&$,ee=(g=B0(g)).length;(Q||ee)&&(u.polygonStart(),Q&&(u.lineStart(),s(null,null,1,u),u.lineEnd()),ee&&d8(g,a,$,s,u),u.polygonEnd()),d=u,g=v=x=null}function q(){I.point=Y,v&&v.push(x=[]),L=!0,N=!1,C=E=NaN}function j(){g&&(Y(T,S),w&&N&&A.rejoin(),g.push(A.result())),I.point=F,N&&d.lineEnd()}function Y($,Q){var ee=r($,Q);if(v&&x.push([$,Q]),L)T=$,S=Q,w=ee,L=!1,ee&&(d.lineStart(),d.point($,Q));else if(ee&&N)d.point($,Q);else{var ue=[C=Math.max(Sm,Math.min($A,C)),E=Math.max(Sm,Math.min($A,E))],le=[$=Math.max(Sm,Math.min($A,$)),Q=Math.max(Sm,Math.min($A,Q))];mH(ue,le,i,e,t,n)?(N||(d.lineStart(),d.point(ue[0],ue[1])),d.point(le[0],le[1]),ee||d.lineEnd(),B=!1):ee&&(d.lineStart(),d.point($,Q),B=!1)}C=$,E=Q,N=ee}return I}}var Dx,Lx,vg,xg,Pd={sphere:Ss,point:Ss,lineStart:_H,lineEnd:Ss,polygonStart:Ss,polygonEnd:Ss};function _H(){Pd.point=xH,Pd.lineEnd=vH}function vH(){Pd.point=Pd.lineEnd=Ss}function xH(i,e){i*=Rn,e*=Rn,Lx=i,vg=Tn(e),xg=In(e),Pd.point=yH}function yH(i,e){i*=Rn,e*=Rn;var t=Tn(e),n=In(e),r=Ii(i-Lx),s=In(r),o=Tn(r),a=n*o,l=xg*t-vg*n*s,u=vg*t+xg*n*s;Dx.add(Qo(nu(a*a+l*l),u)),Lx=i,vg=t,xg=n}function bH(i){return Dx=new Xl,e_(i,Pd),+Dx}var Ix=[null,null],SH={type:"LineString",coordinates:Ix};function ic(i,e){return Ix[0]=i,Ix[1]=e,bH(SH)}var tE={Feature:function(i,e){return o1(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=ic(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))$n}).map(g)).concat(Pf(vm(s/u)*u,r,u).filter(function(E){return Ii(E%A)>$n}).map(v))}return w.lines=function(){return C().map(function(E){return{type:"LineString",coordinates:E}})},w.outline=function(){return{type:"Polygon",coordinates:[x(n).concat(T(o).slice(1),x(t).reverse().slice(1),T(a).reverse().slice(1))]}},w.extent=function(E){return arguments.length?w.extentMajor(E).extentMinor(E):w.extentMinor()},w.extentMajor=function(E){return arguments.length?(n=+E[0][0],t=+E[1][0],a=+E[0][1],o=+E[1][1],n>t&&(E=n,n=t,t=E),a>o&&(E=a,a=o,o=E),w.precision(S)):[[n,a],[t,o]]},w.extentMinor=function(E){return arguments.length?(e=+E[0][0],i=+E[1][0],s=+E[0][1],r=+E[1][1],e>i&&(E=e,e=i,i=E),s>r&&(E=s,s=r,r=E),w.precision(S)):[[e,s],[i,r]]},w.step=function(E){return arguments.length?w.stepMajor(E).stepMinor(E):w.stepMinor()},w.stepMajor=function(E){return arguments.length?(d=+E[0],A=+E[1],w):[d,A]},w.stepMinor=function(E){return arguments.length?(l=+E[0],u=+E[1],w):[l,u]},w.precision=function(E){return arguments.length?(S=+E,g=oE(s,r,90),v=aE(e,i,S),x=oE(a,o,90),T=aE(n,t,S),w):S},w.extentMajor([[-180,-90+$n],[180,90-$n]]).extentMinor([[-180,-80-$n],[180,80+$n]])}function EH(){return MH()()}function kb(i,e){var t=i[0]*Rn,n=i[1]*Rn,r=e[0]*Rn,s=e[1]*Rn,o=In(n),a=Tn(n),l=In(s),u=Tn(s),d=o*In(t),A=o*Tn(t),g=l*In(r),v=l*Tn(r),x=2*iu(nu(OM(s-n)+o*l*OM(r-t))),T=Tn(x),S=x?function(w){var C=Tn(w*=x)/T,E=Tn(x-w)/T,N=E*d+C*g,L=E*A+C*v,B=E*a+C*u;return[Qo(L,N)*fr,Qo(B,nu(N*N+L*L))*fr]}:function(){return[t*fr,n*fr]};return S.distance=x,S}const lE=i=>i;var Dd=1/0,a1=Dd,k0=-Dd,l1=k0,uE={point:CH,lineStart:Ss,lineEnd:Ss,polygonStart:Ss,polygonEnd:Ss,result:function(){var i=[[Dd,a1],[k0,l1]];return k0=l1=-(a1=Dd=1/0),i}};function CH(i,e){ik0&&(k0=i),el1&&(l1=e)}function Vb(i){return function(e){var t=new Bx;for(var n in i)t[n]=i[n];return t.stream=e,t}}function Bx(){}Bx.prototype={constructor:Bx,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Gb(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),e_(t,i.stream(uE)),e(uE.result()),n!=null&&i.clipExtent(n),i}function g8(i,e,t){return Gb(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],o=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),a=+e[0][0]+(r-o*(n[1][0]+n[0][0]))/2,l=+e[0][1]+(s-o*(n[1][1]+n[0][1]))/2;i.scale(150*o).translate([a,l])},t)}function RH(i,e,t){return g8(i,[[0,0],e],t)}function NH(i,e,t){return Gb(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),o=(r-s*(n[1][0]+n[0][0]))/2,a=-s*n[0][1];i.scale(150*s).translate([o,a])},t)}function PH(i,e,t){return Gb(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),o=-s*n[0][0],a=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([o,a])},t)}var cE=16,DH=In(30*Rn);function hE(i,e){return+e?IH(i,e):LH(i)}function LH(i){return Vb({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function IH(i,e){function t(n,r,s,o,a,l,u,d,A,g,v,x,T,S){var w=u-n,C=d-r,E=w*w+C*C;if(E>4*e&&T--){var N=o+g,L=a+v,B=l+x,I=nu(N*N+L*L+B*B),F=iu(B/=I),P=Ii(Ii(B)-1)<$n||Ii(s-A)<$n?(s+A)/2:Qo(L,N),O=i(P,F),G=O[0],q=O[1],j=G-n,Y=q-r,$=C*j-w*Y;($*$/E>e||Ii((w*j+C*Y)/E-.5)>.3||o*g+a*v+l*x2?$[2]%360*Rn:0,j()):[a*fr,l*fr,u*fr]},G.angle=function($){return arguments.length?(A=$%360*Rn,j()):A*fr},G.reflectX=function($){return arguments.length?(g=$?-1:1,j()):g<0},G.reflectY=function($){return arguments.length?(v=$?-1:1,j()):v<0},G.precision=function($){return arguments.length?(B=hE(I,L=$*$),Y()):nu(L)},G.fitExtent=function($,Q){return g8(G,$,Q)},G.fitSize=function($,Q){return RH(G,$,Q)},G.fitWidth=function($,Q){return NH(G,$,Q)},G.fitHeight=function($,Q){return PH(G,$,Q)};function j(){var $=fE(t,0,0,g,v,A).apply(null,e(s,o)),Q=fE(t,n-$[0],r-$[1],g,v,A);return d=h8(a,l,u),I=Nx(e,Q),F=Nx(d,I),B=hE(I,L),Y()}function Y(){return P=O=null,G}return function(){return e=i.apply(this,arguments),G.invert=e.invert&&q,j()}}function VH(i){return function(e,t){var n=nu(e*e+t*t),r=i(n),s=Tn(r),o=In(r);return[Qo(e*s,n*o),iu(n&&t*s/n)]}}function qb(i,e){return[i,jz(Qz((ao+e)/2))]}qb.invert=function(i,e){return[i,2*Fb($z(e))-ao]};function _8(i,e){var t=In(e),n=1+In(i)*t;return[t*Tn(i)/n,Tn(e)/n]}_8.invert=VH(function(i){return 2*Fb(i)});function GH(){return OH(_8).scale(250).clipAngle(142)}function Ux(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=tu().domain([1,0]).range([t,n]).clamp(!0),s=tu().domain([J2(t),J2(n)]).range([1,0]).clamp(!0),o=function(A){return s(J2(r(A)))},a=e.array,l=0,u=a.length;l2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,a=[],l=Math.pow(2,e),u=360/l,d=180/l,A=s===void 0?l-1:s,g=o===void 0?l-1:o,v=n,x=Math.min(l-1,A);v<=x;v++)for(var T=r,S=Math.min(l-1,g);T<=S;T++){var w=T,C=d;if(t){w=T===0?T:AE(T/l)*l;var E=T+1===l?T+1:AE((T+1)/l)*l;C=(E-w)*180/l}var N=-180+(v+.5)*u,L=90-(w*180/l+C/2),B=C;a.push({x:v,y:T,lng:N,lat:L,latLen:B})}return a},sW=6,oW=7,aW=3,lW=90,Za=new WeakMap,Gu=new WeakMap,ev=new WeakMap,Tm=new WeakMap,Vo=new WeakMap,c1=new WeakMap,zf=new WeakMap,Lc=new WeakMap,wm=new WeakSet,uW=function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,o=r.minLevel,a=o===void 0?0:o,l=r.maxLevel,u=l===void 0?17:l,d=r.mercatorProjection,A=d===void 0?!0:d;return $H(this,e),n=WH(this,e),jH(n,wm),Nu(n,Za,void 0),Nu(n,Gu,void 0),Nu(n,ev,void 0),Nu(n,Tm,void 0),Nu(n,Vo,{}),Nu(n,c1,void 0),Nu(n,zf,void 0),Nu(n,Lc,void 0),lf(n,"minLevel",void 0),lf(n,"maxLevel",void 0),lf(n,"thresholds",y8(new Array(30)).map(function(g,v){return 8/Math.pow(2,v)})),lf(n,"curvatureResolution",5),lf(n,"tileMargin",0),lf(n,"clearTiles",function(){Object.values(zn(Vo,n)).forEach(function(g){g.forEach(function(v){v.obj&&(n.remove(v.obj),dE(v.obj),delete v.obj)})}),Pu(Vo,n,{})}),Pu(Za,n,t),n.tileUrl=s,Pu(Gu,n,A),n.minLevel=a,n.maxLevel=u,n.level=0,n.add(Pu(Lc,n,new si(new Tl(zn(Za,n)*.99,180,90),new no({color:0})))),zn(Lc,n).visible=!1,zn(Lc,n).material.polygonOffset=!0,zn(Lc,n).material.polygonOffsetUnits=3,zn(Lc,n).material.polygonOffsetFactor=1,n}return YH(e,i),QH(e,[{key:"tileUrl",get:function(){return zn(ev,this)},set:function(n){Pu(ev,this,n),this.updatePov(zn(zf,this))}},{key:"level",get:function(){return zn(Tm,this)},set:function(n){var r,s=this;zn(Vo,this)[n]||o0(wm,this,cW).call(this,n);var o=zn(Tm,this);if(Pu(Tm,this,n),!(n===o||o===void 0)){if(zn(Lc,this).visible=n>0,zn(Vo,this)[n].forEach(function(l){return l.obj&&(l.obj.material.depthWrite=!0)}),on)for(var a=n+1;a<=o;a++)zn(Vo,this)[a]&&zn(Vo,this)[a].forEach(function(l){l.obj&&(s.remove(l.obj),dE(l.obj),delete l.obj)});o0(wm,this,mE).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof hp))){Pu(zf,this,n);var s;if(Pu(c1,this,function(d){if(!d.hullPnts){var A=360/Math.pow(2,r.level),g=d.lng,v=d.lat,x=d.latLen,T=g-A/2,S=g+A/2,w=v-x/2,C=v+x/2;d.hullPnts=[[v,g],[w,T],[C,T],[w,S],[C,S]].map(function(E){var N=yg(E,2),L=N[0],B=N[1];return M8(L,B,zn(Za,r))}).map(function(E){var N=E.x,L=E.y,B=E.z;return new te(N,L,B)})}return s||(s=new $d,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new gn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),d.hullPnts.some(function(E){return s.containsPoint(E.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var o=n.position.clone(),a=o.distanceTo(this.getWorldPosition(new te)),l=(a-zn(Za,this))/zn(Za,this),u=this.thresholds.findIndex(function(d){return d&&d<=l});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,u<0?this.thresholds.length:u)),o0(wm,this,mE).call(this)}}}}])}(so);function cW(i){var e=this;if(i>oW){zn(Vo,this)[i]=[];return}var t=zn(Vo,this)[i]=Ox(i,zn(Gu,this));t.forEach(function(n){return n.centroid=M8(n.lat,n.lng,zn(Za,e))}),t.octree=VR().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function mE(){var i=this;if(!(!this.tileUrl||this.level===void 0||!zn(Vo,this).hasOwnProperty(this.level))&&!(!zn(c1,this)&&this.level>sW)){var e=zn(Vo,this)[this.level];if(zn(zf,this)){var t=this.worldToLocal(zn(zf,this).position.clone());if(e.octree){var n,r=this.worldToLocal(zn(zf,this).position.clone()),s=(r.length()-zn(Za,this))*aW;e=(n=e.octree).findAllWithinRadius.apply(n,y8(r).concat([s]))}else{var o=iW(t),a=(o.r/zn(Za,this)-1)*lW,l=a/Math.cos(Dc(o.lat)),u=[o.lng-l,o.lng+l],d=[o.lat+a,o.lat-a],A=pE(this.level,zn(Gu,this),u[0],d[0]),g=yg(A,2),v=g[0],x=g[1],T=pE(this.level,zn(Gu,this),u[1],d[1]),S=yg(T,2),w=S[0],C=S[1];!e.record&&(e.record={});var E=e.record;if(!E.hasOwnProperty("".concat(Math.round((v+w)/2),"_").concat(Math.round((x+C)/2))))e=Ox(this.level,zn(Gu,this),v,x,w,C).map(function(F){var P="".concat(F.x,"_").concat(F.y);return E.hasOwnProperty(P)?E[P]:(E[P]=F,e.push(F),F)});else{for(var N=[],L=v;L<=w;L++)for(var B=x;B<=C;B++){var I="".concat(L,"_").concat(B);E.hasOwnProperty(I)||(E[I]=Ox(this.level,zn(Gu,this),L,B,L,B)[0],e.push(E[I])),N.push(E[I])}e=N}}}e.filter(function(F){return!F.obj}).filter(zn(c1,this)||function(){return!0}).forEach(function(F){var P=F.x,O=F.y,G=F.lng,q=F.lat,j=F.latLen,Y=360/Math.pow(2,i.level);if(!F.obj){var $=Y*(1-i.tileMargin),Q=j*(1-i.tileMargin),ee=Dc(G),ue=Dc(-q),le=new si(new Tl(zn(Za,i),Math.ceil($/i.curvatureResolution),Math.ceil(Q/i.curvatureResolution),Dc(90-$/2)+ee,Dc($),Dc(90-Q/2)+ue,Dc(Q)),new du);if(zn(Gu,i)){var de=[q+j/2,q-j/2].map(function(Et){return .5-Et/180}),Te=yg(de,2),Qe=Te[0],Ye=Te[1];rW(le.geometry.attributes.uv,Qe,Ye)}F.obj=le}F.loading||(F.loading=!0,new Cb().load(i.tileUrl(P,O,i.level),function(Et){var at=F.obj;at&&(Et.colorSpace=as,at.material.map=Et,at.material.color=null,at.material.needsUpdate=!0,i.add(at)),F.loading=!1}))})}}function hW(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=C8(i,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,u;if(n&&(s=mW(i,e,s,t)),i.length>80*t){a=i[0],l=i[1];let d=a,A=l;for(let g=t;gd&&(d=v),x>A&&(A=x)}u=Math.max(d-a,A-l),u=u!==0?32767/u:0}return V0(s,o,t,a,l,u,0),o}function C8(i,e,t,n,r){let s;if(r===EW(i,e,t,n)>0)for(let o=e;o=e;o-=n)s=gE(o/n|0,i[o],i[o+1],s);return s&&Ld(s,s.next)&&(q0(s),s=s.next),s}function bh(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Ld(t,t.next)||ar(t.prev,t,t.next)===0)){if(q0(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function V0(i,e,t,n,r,s,o){if(!i)return;!o&&s&&yW(i,n,r,s);let a=i;for(;i.prev!==i.next;){const l=i.prev,u=i.next;if(s?dW(i,n,r,s):fW(i)){e.push(l.i,i.i,u.i),q0(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=AW(bh(i),e),V0(i,e,t,n,r,s,2)):o===2&&pW(i,e,t,n,r,s):V0(bh(i),e,t,n,r,s,1);break}}}function fW(i){const e=i.prev,t=i,n=i.next;if(ar(e,t,n)>=0)return!1;const r=e.x,s=t.x,o=n.x,a=e.y,l=t.y,u=n.y,d=Math.min(r,s,o),A=Math.min(a,l,u),g=Math.max(r,s,o),v=Math.max(a,l,u);let x=n.next;for(;x!==e;){if(x.x>=d&&x.x<=g&&x.y>=A&&x.y<=v&&jA(r,a,s,l,o,u,x.x,x.y)&&ar(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function dW(i,e,t,n){const r=i.prev,s=i,o=i.next;if(ar(r,s,o)>=0)return!1;const a=r.x,l=s.x,u=o.x,d=r.y,A=s.y,g=o.y,v=Math.min(a,l,u),x=Math.min(d,A,g),T=Math.max(a,l,u),S=Math.max(d,A,g),w=kx(v,x,e,t,n),C=kx(T,S,e,t,n);let E=i.prevZ,N=i.nextZ;for(;E&&E.z>=w&&N&&N.z<=C;){if(E.x>=v&&E.x<=T&&E.y>=x&&E.y<=S&&E!==r&&E!==o&&jA(a,d,l,A,u,g,E.x,E.y)&&ar(E.prev,E,E.next)>=0||(E=E.prevZ,N.x>=v&&N.x<=T&&N.y>=x&&N.y<=S&&N!==r&&N!==o&&jA(a,d,l,A,u,g,N.x,N.y)&&ar(N.prev,N,N.next)>=0))return!1;N=N.nextZ}for(;E&&E.z>=w;){if(E.x>=v&&E.x<=T&&E.y>=x&&E.y<=S&&E!==r&&E!==o&&jA(a,d,l,A,u,g,E.x,E.y)&&ar(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;N&&N.z<=C;){if(N.x>=v&&N.x<=T&&N.y>=x&&N.y<=S&&N!==r&&N!==o&&jA(a,d,l,A,u,g,N.x,N.y)&&ar(N.prev,N,N.next)>=0)return!1;N=N.nextZ}return!0}function AW(i,e){let t=i;do{const n=t.prev,r=t.next.next;!Ld(n,r)&&N8(n,t,t.next,r)&&G0(n,r)&&G0(r,n)&&(e.push(n.i,t.i,r.i),q0(t),q0(t.next),t=i=r),t=t.next}while(t!==i);return bh(t)}function pW(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&TW(o,a)){let l=P8(o,a);o=bh(o,o.next),l=bh(l,l.next),V0(o,e,t,n,r,s,0),V0(l,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function mW(i,e,t,n){const r=[];for(let s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const A=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(A<=n&&A>s&&(s=A,o=t.x=t.x&&t.x>=l&&n!==t.x&&R8(ro.x||t.x===o.x&&xW(o,t)))&&(o=t,d=A)}t=t.next}while(t!==a);return o}function xW(i,e){return ar(i.prev,i,e.prev)<0&&ar(e.next,i,i.next)<0}function yW(i,e,t,n){let r=i;do r.z===0&&(r.z=kx(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,bW(r)}function bW(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let u=0;u0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=o}s.nextZ=null,t*=2}while(e>1);return i}function kx(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function SW(i){let e=i,t=i;do(e.x=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function jA(i,e,t,n,r,s,o,a){return!(i===o&&e===a)&&R8(i,e,t,n,r,s,o,a)}function TW(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!wW(i,e)&&(G0(i,e)&&G0(e,i)&&MW(i,e)&&(ar(i.prev,i,e.prev)||ar(i,e.prev,e))||Ld(i,e)&&ar(i.prev,i,i.next)>0&&ar(e.prev,e,e.next)>0)}function ar(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Ld(i,e){return i.x===e.x&&i.y===e.y}function N8(i,e,t,n){const r=Em(ar(i,e,t)),s=Em(ar(i,e,n)),o=Em(ar(t,n,i)),a=Em(ar(t,n,e));return!!(r!==s&&o!==a||r===0&&Mm(i,t,e)||s===0&&Mm(i,n,e)||o===0&&Mm(t,i,n)||a===0&&Mm(t,e,n))}function Mm(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Em(i){return i>0?1:i<0?-1:0}function wW(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&N8(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function G0(i,e){return ar(i.prev,i,i.next)<0?ar(i,e,i.next)>=0&&ar(i,i.prev,e)>=0:ar(i,e,i.prev)<0||ar(i,i.next,e)<0}function MW(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function P8(i,e){const t=Vx(i.i,i.x,i.y),n=Vx(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function gE(i,e,t,n){const r=Vx(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function q0(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Vx(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function EW(i,e,t,n){let r=0;for(let s=e,o=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(l){throw l},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){t=t.call(i)},n:function(){var l=t.next();return o=l.done,l},e:function(l){a=!0,s=l},f:function(){try{o||t.return==null||t.return()}finally{if(a)throw s}}}}function f1(i){return f1=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f1(i)}function BW(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&qx(i,e)}function D8(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(D8=function(){return!!i})()}function UW(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function FW(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,a=[],l=!0,u=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=s.call(t)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(d){u=!0,r=d}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(u)throw r}}return a}}function OW(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kW(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VW(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return NW(i)}function qx(i,e){return qx=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},qx(i,e)}function vA(i,e){return CW(i)||FW(i,e)||zb(i,e)||OW()}function GW(i){return RW(i)||UW(i)||zb(i)||kW()}function zb(i,e){if(i){if(typeof i=="string")return Gx(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Gx(i,e):void 0}}var _E=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var o=ic(s,r)*180/Math.PI;if(o>t)for(var a=kb(r,s),l=r.length>2||s.length>2?O0(r[2]||0,s[2]||0):null,u=l?function(g){return[].concat(GW(a(g)),[l(g)])}:a,d=1/Math.ceil(o/t),A=d;A<1;)n.push(u(A)),A+=d}n.push(r=s)}),n},zx=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:ui,Float32BufferAttribute:Jn},qW=new zx.BufferGeometry().setAttribute?"setAttribute":"addAttribute",L8=function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;DW(this,e),n=PW(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var o=({Point:d,MultiPoint:A,LineString:g,MultiLineString:v,Polygon:x,MultiPolygon:T}[t.type]||function(){return[]})(t.coordinates,r),a=[],l=[],u=0;o.forEach(function(S){var w=a.length;xA({indices:a,vertices:l},S),n.addGroup(w,a.length-w,u++)}),a.length&&n.setIndex(a),l.length&&n[qW]("position",new zx.Float32BufferAttribute(l,3));function d(S,w){var C=tv(S[1],S[0],w+(S[2]||0)),E=[];return[{vertices:C,indices:E}]}function A(S,w){var C={vertices:[],indices:[]};return S.map(function(E){return d(E,w)}).forEach(function(E){var N=vA(E,1),L=N[0];xA(C,L)}),[C]}function g(S,w){for(var C=_E(S,s).map(function(F){var P=vA(F,3),O=P[0],G=P[1],q=P[2],j=q===void 0?0:q;return tv(G,O,w+j)}),E=h1([C]),N=E.vertices,L=Math.round(N.length/3),B=[],I=1;I2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function zW(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(o){if(o.normalized||o.isInterleavedBufferAttribute){const a=new Float32Array(o.count*o.itemSize);for(let l=0,u=0;l2&&(a[u++]=o.getZ(l));return a}return o.array instanceof Float32Array?o.array:new Float32Array(o.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let o=3;o=2&&o.setY(a,i.getY(a)),n>=3&&o.setZ(a,i.getZ(a)),n>=4&&o.setW(a,i.getW(a));return o}function jW(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,d1(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,d1(s)),t[r]=n.get(s))}}function XW(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function QW(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let o=0;const a=Object.keys(i.attributes),l={},u={},d=[],A=["getX","getY","getZ","getW"],g=["setX","setY","setZ","setW"];for(let C=0,E=a.length;C{const P=new I.array.constructor(I.count*I.itemSize);u[N][F]=new I.constructor(P,I.itemSize,I.normalized)}))}const v=e*.5,x=Math.log10(1/e),T=Math.pow(10,x),S=v*T;for(let C=0;Co.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),i.getIndex()===null){const o=i.getAttribute("position"),a=[];for(let l=0;lt&&l.add(G)}l.normalize(),x.setXYZ(w+L,l.x,l.y,l.z)}}return d.setAttribute("normal",x),d}const Hb=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:zW,computeMorphedAttributes:KW,deepCloneAttribute:WW,deinterleaveAttribute:d1,deinterleaveGeometry:jW,estimateBytesUsed:XW,interleaveAttributes:$W,mergeAttributes:Hx,mergeGeometries:HW,mergeGroups:ZW,mergeVertices:QW,toCreasedNormals:JW,toTrianglesDrawMode:YW},Symbol.toStringTag,{value:"Module"}));var Ke=function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}};function A1(i){"@babel/helpers - typeof";return A1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},A1(i)}var e$=/^\s+/,t$=/\s+$/;function an(i,e){if(i=i||"",e=e||{},i instanceof an)return i;if(!(this instanceof an))return new an(i,e);var t=n$(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}an.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,o,a;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?o=n/12.92:o=Math.pow((n+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*o+.0722*a},setAlpha:function(e){return this._a=I8(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=yE(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=yE(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=xE(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=xE(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return bE(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return o$(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Yi(this._r,255)*100)+"%",g:Math.round(Yi(this._g,255)*100)+"%",b:Math.round(Yi(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Yi(this._r,255)*100)+"%, "+Math.round(Yi(this._g,255)*100)+"%, "+Math.round(Yi(this._b,255)*100)+"%)":"rgba("+Math.round(Yi(this._r,255)*100)+"%, "+Math.round(Yi(this._g,255)*100)+"%, "+Math.round(Yi(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:_$[bE(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+SE(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=an(e);n="#"+SE(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return an(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(c$,arguments)},brighten:function(){return this._applyModification(h$,arguments)},darken:function(){return this._applyModification(f$,arguments)},desaturate:function(){return this._applyModification(a$,arguments)},saturate:function(){return this._applyModification(l$,arguments)},greyscale:function(){return this._applyModification(u$,arguments)},spin:function(){return this._applyModification(d$,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(m$,arguments)},complement:function(){return this._applyCombination(A$,arguments)},monochromatic:function(){return this._applyCombination(g$,arguments)},splitcomplement:function(){return this._applyCombination(p$,arguments)},triad:function(){return this._applyCombination(TE,[3])},tetrad:function(){return this._applyCombination(TE,[4])}};an.fromRatio=function(i,e){if(A1(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=XA(i[n]));i=t}return an(i,e)};function n$(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,o=!1,a=!1;return typeof i=="string"&&(i=b$(i)),A1(i)=="object"&&(Ul(i.r)&&Ul(i.g)&&Ul(i.b)?(e=i$(i.r,i.g,i.b),o=!0,a=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Ul(i.h)&&Ul(i.s)&&Ul(i.v)?(n=XA(i.s),r=XA(i.v),e=s$(i.h,n,r),o=!0,a="hsv"):Ul(i.h)&&Ul(i.s)&&Ul(i.l)&&(n=XA(i.s),s=XA(i.l),e=r$(i.h,n,s),o=!0,a="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=I8(t),{ok:o,format:i.format||a,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:t}}function i$(i,e,t){return{r:Yi(i,255)*255,g:Yi(e,255)*255,b:Yi(t,255)*255}}function xE(i,e,t){i=Yi(i,255),e=Yi(e,255),t=Yi(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,o,a=(n+r)/2;if(n==r)s=o=0;else{var l=n-r;switch(o=a>.5?l/(2-n-r):l/(n+r),n){case i:s=(e-t)/l+(e1&&(A-=1),A<1/6?u+(d-u)*6*A:A<1/2?d:A<2/3?u+(d-u)*(2/3-A)*6:u}if(e===0)n=r=s=t;else{var a=t<.5?t*(1+e):t+e-t*e,l=2*t-a;n=o(l,a,i+1/3),r=o(l,a,i),s=o(l,a,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function yE(i,e,t){i=Yi(i,255),e=Yi(e,255),t=Yi(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,o,a=n,l=n-r;if(o=n===0?0:l/n,n==r)s=0;else{switch(n){case i:s=(e-t)/l+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(an(n));return s}function g$(i,e){e=e||6;for(var t=an(i).toHsv(),n=t.h,r=t.s,s=t.v,o=[],a=1/e;e--;)o.push(an({h:n,s:r,v:s})),s=(s+a)%1;return o}an.mix=function(i,e,t){t=t===0?0:t||50;var n=an(i).toRgb(),r=an(e).toRgb(),s=t/100,o={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return an(o)};an.readability=function(i,e){var t=an(i),n=an(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};an.isReadable=function(i,e,t){var n=an.readability(i,e),r,s;switch(s=!1,r=S$(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};an.mostReadable=function(i,e,t){var n=null,r=0,s,o,a,l;t=t||{},o=t.includeFallbackColors,a=t.level,l=t.size;for(var u=0;ur&&(r=s,n=an(e[u]));return an.isReadable(i,n,{level:a,size:l})||!o?n:(t.includeFallbackColors=!1,an.mostReadable(i,["#fff","#000"],t))};var Wx=an.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"},_$=an.hexNames=v$(Wx);function v$(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function I8(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Yi(i,e){x$(i)&&(i="100%");var t=y$(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function t_(i){return Math.min(1,Math.max(0,i))}function So(i){return parseInt(i,16)}function x$(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function y$(i){return typeof i=="string"&&i.indexOf("%")!=-1}function va(i){return i.length==1?"0"+i:""+i}function XA(i){return i<=1&&(i=i*100+"%"),i}function B8(i){return Math.round(parseFloat(i)*255).toString(16)}function wE(i){return So(i)/255}var fa=function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),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 Ul(i){return!!fa.CSS_UNIT.exec(i)}function b$(i){i=i.replace(e$,"").replace(t$,"").toLowerCase();var e=!1;if(Wx[i])i=Wx[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=fa.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=fa.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=fa.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=fa.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=fa.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=fa.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=fa.hex8.exec(i))?{r:So(t[1]),g:So(t[2]),b:So(t[3]),a:wE(t[4]),format:e?"name":"hex8"}:(t=fa.hex6.exec(i))?{r:So(t[1]),g:So(t[2]),b:So(t[3]),format:e?"name":"hex"}:(t=fa.hex4.exec(i))?{r:So(t[1]+""+t[1]),g:So(t[2]+""+t[2]),b:So(t[3]+""+t[3]),a:wE(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=fa.hex3.exec(i))?{r:So(t[1]+""+t[1]),g:So(t[2]+""+t[2]),b:So(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function S$(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function $x(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},a.prototype.update=function(l,u){u===void 0&&(u=!0),this._currentTick++,this._currentTime+=l,this._tickDeltaTime=l,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),u&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},a.prototype.getTimer=function(){return Date.now()},a}();Object.defineProperty(n,"__esModule",{value:!0}),n.default=o},function(t,n,r){(function(s,o){t.exports=o()})(this,function(){return function(s){function o(l){if(a[l])return a[l].exports;var u=a[l]={exports:{},id:l,loaded:!1};return s[l].call(u.exports,u,u.exports,o),u.loaded=!0,u.exports}var a={};return o.m=s,o.c=a,o.p="",o(0)}([function(s,o){var a=function(){function l(){this.functions=[]}return l.prototype.add=function(u){return this.functions.indexOf(u)===-1&&(this.functions.push(u),!0)},l.prototype.remove=function(u){var d=this.functions.indexOf(u);return d>-1&&(this.functions.splice(d,1),!0)},l.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},l.prototype.dispatch=function(){for(var u=[],d=0;du==d>-u?(s=u,u=e[++A]):(s=d,d=n[++g]);let v=0;if(Au==d>-u?(o=u+s,a=s-(o-u),u=e[++A]):(o=d+s,a=s-(o-d),d=n[++g]),s=o,a!==0&&(r[v++]=a);Au==d>-u?(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=e[++A]):(o=s+d,l=o-s,a=s-(o-l)+(d-l),d=n[++g]),s=o,a!==0&&(r[v++]=a);for(;A=Y||-j>=Y||(A=i-P,a=i-(P+A)+(A-r),A=t-O,u=t-(O+A)+(A-r),A=e-G,l=e-(G+A)+(A-s),A=n-q,d=n-(q+A)+(A-s),a===0&&l===0&&u===0&&d===0)||(Y=$$*o+q$*Math.abs(j),j+=P*d+q*a-(G*u+O*l),j>=Y||-j>=Y))return j;N=a*q,g=ys*a,v=g-(g-a),x=a-v,g=ys*q,T=g-(g-q),S=q-T,L=x*S-(N-v*T-x*T-v*S),B=l*O,g=ys*l,v=g-(g-l),x=l-v,g=ys*O,T=g-(g-O),S=O-T,I=x*S-(B-v*T-x*T-v*S),w=L-I,A=L-w,Is[0]=L-(w+A)+(A-I),C=N+w,A=C-N,E=N-(C-A)+(w-A),w=E-B,A=E-w,Is[1]=E-(w+A)+(A-B),F=C+w,A=F-C,Is[2]=C-(F-A)+(w-A),Is[3]=F;const $=sv(4,ff,4,Is,ME);N=P*d,g=ys*P,v=g-(g-P),x=P-v,g=ys*d,T=g-(g-d),S=d-T,L=x*S-(N-v*T-x*T-v*S),B=G*u,g=ys*G,v=g-(g-G),x=G-v,g=ys*u,T=g-(g-u),S=u-T,I=x*S-(B-v*T-x*T-v*S),w=L-I,A=L-w,Is[0]=L-(w+A)+(A-I),C=N+w,A=C-N,E=N-(C-A)+(w-A),w=E-B,A=E-w,Is[1]=E-(w+A)+(A-B),F=C+w,A=F-C,Is[2]=C-(F-A)+(w-A),Is[3]=F;const Q=sv($,ME,4,Is,EE);N=a*d,g=ys*a,v=g-(g-a),x=a-v,g=ys*d,T=g-(g-d),S=d-T,L=x*S-(N-v*T-x*T-v*S),B=l*u,g=ys*l,v=g-(g-l),x=l-v,g=ys*u,T=g-(g-u),S=u-T,I=x*S-(B-v*T-x*T-v*S),w=L-I,A=L-w,Is[0]=L-(w+A)+(A-I),C=N+w,A=C-N,E=N-(C-A)+(w-A),w=E-B,A=E-w,Is[1]=E-(w+A)+(A-B),F=C+w,A=F-C,Is[2]=C-(F-A)+(w-A),Is[3]=F;const ee=sv(Q,EE,4,Is,CE);return CE[ee-1]}function QA(i,e,t,n,r,s){const o=(e-s)*(t-r),a=(i-r)*(n-s),l=o-a,u=Math.abs(o+a);return Math.abs(l)>=H$*u?l:-j$(i,e,t,n,r,s,u)}const RE=Math.pow(2,-52),Rm=new Uint32Array(512);class z0{static from(e,t=Z$,n=J$){const r=e.length,s=new Float64Array(r*2);for(let o=0;o>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,o=e.length>>1;let a=1/0,l=1/0,u=-1/0,d=-1/0;for(let P=0;Pu&&(u=O),G>d&&(d=G),this._ids[P]=P}const A=(a+u)/2,g=(l+d)/2;let v,x,T;for(let P=0,O=1/0;P0&&(x=P,O=G)}let C=e[2*x],E=e[2*x+1],N=1/0;for(let P=0;Pq&&(P[O++]=j,q=Y)}this.hull=P.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(QA(S,w,C,E,L,B)<0){const P=x,O=C,G=E;x=T,C=L,E=B,T=P,L=O,B=G}const I=K$(S,w,C,E,L,B);this._cx=I.x,this._cy=I.y;for(let P=0;P0&&Math.abs(j-O)<=RE&&Math.abs(Y-G)<=RE||(O=j,G=Y,q===v||q===x||q===T))continue;let $=0;for(let de=0,Te=this._hashKey(j,Y);de=0;)if(Q=ee,Q===$){Q=-1;break}if(Q===-1)continue;let ue=this._addTriangle(Q,q,n[Q],-1,-1,r[Q]);r[q]=this._legalize(ue+2),r[Q]=ue,F++;let le=n[Q];for(;ee=n[le],QA(j,Y,e[2*le],e[2*le+1],e[2*ee],e[2*ee+1])<0;)ue=this._addTriangle(le,q,ee,r[q],-1,r[le]),r[q]=this._legalize(ue+2),n[le]=le,F--,le=ee;if(Q===$)for(;ee=t[Q],QA(j,Y,e[2*ee],e[2*ee+1],e[2*Q],e[2*Q+1])<0;)ue=this._addTriangle(ee,q,Q,-1,r[Q],r[ee]),this._legalize(ue+2),r[ee]=ue,n[Q]=Q,F--,Q=ee;this._hullStart=t[q]=Q,n[Q]=t[le]=q,n[q]=le,s[this._hashKey(j,Y)]=q,s[this._hashKey(e[2*Q],e[2*Q+1])]=Q}this.hull=new Uint32Array(F);for(let P=0,O=this._hullStart;P0?3-t:1+t)/4}function ov(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function Q$(i,e,t,n,r,s,o,a){const l=i-o,u=e-a,d=t-o,A=n-a,g=r-o,v=s-a,x=l*l+u*u,T=d*d+A*A,S=g*g+v*v;return l*(A*S-T*v)-u*(d*S-T*g)+x*(d*v-A*g)<0}function Y$(i,e,t,n,r,s){const o=t-i,a=n-e,l=r-i,u=s-e,d=o*o+a*a,A=l*l+u*u,g=.5/(o*u-a*l),v=(u*d-a*A)*g,x=(o*A-l*d)*g;return v*v+x*x}function K$(i,e,t,n,r,s){const o=t-i,a=n-e,l=r-i,u=s-e,d=o*o+a*a,A=l*l+u*u,g=.5/(o*u-a*l),v=i+(u*d-a*A)*g,x=e+(o*A-l*d)*g;return{x:v,y:x}}function Lf(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],o=e[s];let a=r-1;for(;a>=t&&e[i[a]]>o;)i[a+1]=i[a--];i[a+1]=s}else{const r=t+n>>1;let s=t+1,o=n;bA(i,r,s),e[i[t]]>e[i[n]]&&bA(i,t,n),e[i[s]]>e[i[n]]&&bA(i,s,n),e[i[t]]>e[i[s]]&&bA(i,t,s);const a=i[s],l=e[a];for(;;){do s++;while(e[i[s]]l);if(o=o-t?(Lf(i,e,s,n),Lf(i,e,t,o-1)):(Lf(i,e,t,o-1),Lf(i,e,s,n))}}function bA(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function Z$(i){return i[0]}function J$(i){return i[1]}function ej(i,e){var t,n,r=0,s,o,a,l,u,d,A,g=i[0],v=i[1],x=e.length;for(t=0;t=0||o<=0&&l>=0)return 0}else if(u>=0&&a<=0||u<=0&&a>=0){if(s=QA(o,l,a,u,0,0),s===0)return 0;(s>0&&u>0&&a<=0||s<0&&u<=0&&a>0)&&r++}d=A,a=u,o=l}}return r%2!==0}function tj(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function nj(i){return i.type==="Feature"?i.geometry:i}function ij(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=tj(i),r=nj(e),s=r.type,o=e.bbox;let a=r.coordinates;if(o&&rj(n,o)===!1)return!1;s==="Polygon"&&(a=[a]);let l=!1;for(var u=0;u=i[0]&&e[3]>=i[1]}var sj=ij;const NE=1e-6;class nh{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>NE||Math.abs(this._y1-s)>NE)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class jx{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class oj{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,o;const a=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let T=0,S=0,w=n.length,C,E;T1;)s-=2;for(let o=2;o0){if(t>=this.ymax)return null;(o=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(o=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function hj(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class Wb{static from(e,t=lj,n=uj,r){return new Wb("length"in e?fj(e,t,n,r):Float64Array.from(dj(e,t,n,r)))}constructor(e){this._delaunator=new z0(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&cj(e)){this.collinear=Int32Array.from({length:t.length/2},(g,v)=>v).sort((g,v)=>t[2*g]-t[2*v]||t[2*g+1]-t[2*v+1]);const l=this.collinear[0],u=this.collinear[this.collinear.length-1],d=[t[2*l],t[2*l+1],t[2*u],t[2*u+1]],A=1e-8*Math.hypot(d[3]-d[1],d[2]-d[0]);for(let g=0,v=t.length/2;g0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],o[r[0]]=1,r.length===2&&(o[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new oj(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:o,collinear:a}=this;if(a){const A=a.indexOf(e);A>0&&(yield a[A-1]),A=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:o,halfedges:a,triangles:l,points:u}=this;if(r[e]===-1||!u.length)return(e+1)%(u.length>>1);let d=e,A=df(t-u[e*2],2)+df(n-u[e*2+1],2);const g=r[e];let v=g;do{let x=l[v];const T=df(t-u[x*2],2)+df(n-u[x*2+1],2);if(T0?1:i<0?-1:0},k8=Math.sqrt;function _j(i){return i>1?PE:i<-1?-PE:Math.asin(i)}function V8(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function Eo(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function p1(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function m1(i){var e=k8(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function jb(i){return[Aj(i[1],i[0])*DE,_j(pj(-1,mj(1,i[2])))*DE]}function ul(i){const e=i[0]*LE,t=i[1]*LE,n=IE(t);return[n*IE(e),n*BE(e),BE(t)]}function Xb(i){return i=i.map(e=>ul(e)),V8(i[0],Eo(i[2],i[1]))}function vj(i){const e=yj(i),t=Sj(e),n=bj(t,i),r=wj(t,i.length),s=xj(r,i),o=Tj(t,i),{polygons:a,centers:l}=Mj(o,t,i),u=Ej(a),d=Rj(t,i),A=Cj(n,t);return{delaunay:e,edges:n,triangles:t,centers:l,neighbors:r,polygons:a,mesh:u,hull:d,urquhart:A,find:s}}function xj(i,e){function t(n,r){let s=n[0]-r[0],o=n[1]-r[1],a=n[2]-r[2];return s*s+o*o+a*a}return function(r,s,o){o===void 0&&(o=0);let a,l,u=o;const d=ul([r,s]);do a=o,o=null,l=t(d,ul(e[a])),i[a].forEach(A=>{let g=t(d,ul(e[A]));if(g1e32?r.push(A):v>s&&(s=v)}const o=1e6*k8(s);r.forEach(A=>i[A]=[o,0]),i.push([0,o]),i.push([-o,0]),i.push([0,-o]);const a=Wb.from(i);a.projection=n;const{triangles:l,halfedges:u,inedges:d}=a;for(let A=0,g=u.length;Ai.length-3-1&&(l[A]=e);return a}function bj(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(Xb(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(Vg([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function Sj(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(ul),r=p1(p1(Eo(n[1],n[0]),Eo(n[2],n[1])),Eo(n[0],n[2]));return jb(m1(r))})}function wj(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],o=n[(r+1)%3];t[s]=t[s]||[],t[s].push(o)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function Mj(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const a=ul(t[0]),l=ul(t[1]),u=m1(p1(a,l)),d=m1(Eo(a,l)),A=Eo(u,d),g=[u,Eo(u,A),Eo(Eo(u,A),A),Eo(Eo(Eo(u,A),A),A)].map(jb).map(o);return n.push(g),n.push(g.slice().reverse()),{polygons:n,centers:r}}}e.forEach((a,l)=>{for(let u=0;u<3;u++){const d=a[u],A=a[(u+1)%3],g=a[(u+2)%3];n[d]=n[d]||[],n[d].push([A,g,l,[d,A,g]])}});const s=n.map(a=>{const l=[a[0][2]];let u=a[0][1];for(let d=1;d2)return l;if(l.length==2){const d=UE(t[a[0][3][0]],t[a[0][3][1]],r[l[0]]),A=UE(t[a[0][3][2]],t[a[0][3][0]],r[l[0]]),g=o(d),v=o(A);return[l[0],v,l[1],g]}});function o(a){let l=-1;return r.slice(e.length,1/0).forEach((u,d)=>{u[0]===a[0]&&u[1]===a[1]&&(l=d+e.length)}),l<0&&(l=r.length,r.push(a)),l}return{polygons:s,centers:r}}function UE(i,e,t){i=ul(i),e=ul(e),t=ul(t);const n=gj(V8(Eo(e,i),t));return jb(m1(p1(i,e)).map(r=>n*r))}function Ej(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function Cj(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,o)=>{const a=s.join("-");n.set(a,t[o]),r.set(a,!0)}),e.forEach(s=>{let o=0,a=-1;for(let l=0;l<3;l++){let u=Vg([s[l],s[(l+1)%3]]).join("-");n.get(u)>o&&(o=n.get(u),a=u)}r.set(a,!1)}),i.map(s=>r.get(s.join("-")))}}function Rj(i,e){const t=new Set,n=[];i.map(a=>{if(!(Xb(a.map(l=>e[l>e.length?0:l]))>1e-12))for(let l=0;l<3;l++){let u=[a[l],a[(l+1)%3]],d=`${u[0]}-${u[1]}`;t.has(d)?t.delete(d):t.add(`${u[1]}-${u[0]}`)}});const r=new Map;let s;if(t.forEach(a=>{a=a.split("-").map(Number),r.set(a[0],a[1]),s=a[0]}),s===void 0)return n;let o=s;do{n.push(o);let a=r.get(o);r.set(o,-1),o=a}while(o>-1&&o!==s);return n}function Nj(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=vj(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return XM(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return XM(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(o=>e.delaunay.centers[o])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>Xb(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>ic(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,o)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[o],urquhart:!!r[o]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const o of r)if(o)for(let a=o.length,l=o[a-1],u=o[0],d=0;dl&&s.push([n[l],n[u]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||ic([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function Xx(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=Hj(i,n),s=B0(r),o=Wj(i,n),a=[].concat(av(s),av(o)),l={type:"Polygon",coordinates:i},u=a8(l),d=Ja(u,2),A=Ja(d[0],2),g=A[0],v=A[1],x=Ja(d[1],2),T=x[0],S=x[1],w=g>T||S>=89||v<=-89,C=[];if(w){var E=Nj(a).triangles(),N=new Map(a.map(function(ee,ue){var le=Ja(ee,2),de=le[0],Te=le[1];return["".concat(de,"-").concat(Te),ue]}));E.features.forEach(function(ee){var ue,le=ee.geometry.coordinates[0].slice(0,3).reverse(),de=[];if(le.forEach(function(Qe){var Ye=Ja(Qe,2),Et=Ye[0],at=Ye[1],ve="".concat(Et,"-").concat(at);N.has(ve)&&de.push(N.get(ve))}),de.length===3){if(de.some(function(Qe){return Qee)for(var a=kb(r,s),l=1/Math.ceil(o/e),u=l;u<1;)n.push(a(u)),u+=l}n.push(r=s)}),n})}function Wj(i,e){var t={type:"Polygon",coordinates:i},n=a8(t),r=Ja(n,2),s=Ja(r[0],2),o=s[0],a=s[1],l=Ja(r[1],2),u=l[0],d=l[1];if(Math.min(Math.abs(u-o),Math.abs(d-a))u||d>=89||a<=-89;return $j(e,{minLng:o,maxLng:u,minLat:a,maxLat:d}).filter(function(g){return Yx(g,t,A)})}function $j(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,o=Math.round(Math.pow(360/i,2)/Math.PI),a=(1+Math.sqrt(5))/2,l=function(w){return w/a*360%360-180},u=function(w){return Math.acos(2*w/o-1)/Math.PI*180-90},d=function(w){return o*(Math.cos((w+90)*Math.PI/180)+1)/2},A=[s!==void 0?Math.ceil(d(s)):0,r!==void 0?Math.floor(d(r)):o-1],g=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(S){return S<=n}:n===void 0?function(S){return S>=t}:n>=t?function(S){return S>=t&&S<=n}:function(S){return S>=t||S<=n},v=[],x=A[0];x<=A[1];x++){var T=l(x);g(T)&&v.push([T,u(x)])}return v}function Yx(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?wH(e,i):sj(i,e)}var bg=window.THREE?window.THREE:{BufferGeometry:ui,Float32BufferAttribute:Jn},FE=new bg.BufferGeometry().setAttribute?"setAttribute":"addAttribute",Qb=function(i){function e(t,n,r,s,o,a,l){var u;Bj(this,e),u=Ij(this,e),u.type="ConicPolygonGeometry",u.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:o,includeSides:a,curvatureResolution:l},n=n||0,r=r||1,s=s!==void 0?s:!0,o=o!==void 0?o:!0,a=a!==void 0?a:!0,l=l||5;var d=zj(t,{resolution:l}),A=d.contour,g=d.triangles,v=B0(g.uvs),x=[],T=[],S=[],w=0,C=function(I){var F=Math.round(x.length/3),P=S.length;x=x.concat(I.vertices),T=T.concat(I.uvs),S=S.concat(F?I.indices.map(function(O){return O+F}):I.indices),u.addGroup(P,S.length-P,w++)};a&&C(N()),s&&C(L(n,!1)),o&&C(L(r,!0)),u.setIndex(S),u[FE]("position",new bg.Float32BufferAttribute(x,3)),u[FE]("uv",new bg.Float32BufferAttribute(T,2)),u.computeVertexNormals();function E(B,I){var F=typeof I=="function"?I:function(){return I},P=B.map(function(O){return O.map(function(G){var q=Ja(G,2),j=q[0],Y=q[1];return jj(Y,j,F(j,Y))})});return h1(P)}function N(){for(var B=E(A,n),I=B.vertices,F=B.holes,P=E(A,r),O=P.vertices,G=B0([O,I]),q=Math.round(O.length/3),j=new Set(F),Y=0,$=[],Q=0;Q=0;de--)for(var Te=0;Te1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:I?g.indices:g.indices.slice().reverse(),vertices:E([g.points],B).vertices,uvs:v}}return u}return Fj(e,i),Uj(e)}(bg.BufferGeometry);function jj(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function Kx(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(a){return{keyAccessor:a,isProp:!(a instanceof Function)}}),s=i.reduce(function(a,l){var u=a,d=l;return r.forEach(function(A,g){var v=A.keyAccessor,x=A.isProp,T;if(x){var S=d,w=S[v],C=eX(S,[v].map(sX));T=w,d=C}else T=v(d,g);g+11&&arguments[1]!==void 0?arguments[1]:1;u===r.length?Object.keys(l).forEach(function(d){return l[d]=t(l[d])}):Object.values(l).forEach(function(d){return a(d,u+1)})}(s);var o=s;return n&&(o=[],function a(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];u.length===r.length?o.push({keys:u,vals:l}):Object.entries(l).forEach(function(d){var A=nX(d,2),g=A[0],v=A[1];return a(v,[].concat(iX(u),[g]))})}(s),e instanceof Array&&e.length===0&&o.length===1&&(o[0].keys=[])),o},Zn=function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Pe){return e.locateFile?e.locateFile(Pe,r):r+Pe}var o;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",o=function(ze,yt,je){var f=new XMLHttpRequest;f.open("GET",ze,!0),f.responseType="arraybuffer",f.onload=function(){if(f.status==200||f.status==0&&f.response){yt(f.response);return}var Nn=Nt(ze);if(Nn){yt(Nn.buffer);return}je()},f.onerror=je,f.send(null)};var a=e.print||console.log.bind(console),l=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var u=0,d=function(Pe){u=Pe},A=function(){return u},g=8;function v(Pe,ze,yt,je){switch(yt=yt||"i8",yt.charAt(yt.length-1)==="*"&&(yt="i32"),yt){case"i1":q[Pe>>0]=ze;break;case"i8":q[Pe>>0]=ze;break;case"i16":Y[Pe>>1]=ze;break;case"i32":$[Pe>>2]=ze;break;case"i64":_e=[ze>>>0,(H=ze,+zt(H)>=1?H>0?(Ve(+tt(H/4294967296),4294967295)|0)>>>0:~~+Oe((H-+(~~H>>>0))/4294967296)>>>0:0)],$[Pe>>2]=_e[0],$[Pe+4>>2]=_e[1];break;case"float":Q[Pe>>2]=ze;break;case"double":ee[Pe>>3]=ze;break;default:gr("invalid type for setValue: "+yt)}}function x(Pe,ze,yt){switch(ze=ze||"i8",ze.charAt(ze.length-1)==="*"&&(ze="i32"),ze){case"i1":return q[Pe>>0];case"i8":return q[Pe>>0];case"i16":return Y[Pe>>1];case"i32":return $[Pe>>2];case"i64":return $[Pe>>2];case"float":return Q[Pe>>2];case"double":return ee[Pe>>3];default:gr("invalid type for getValue: "+ze)}return null}var T=!1;function S(Pe,ze){Pe||gr("Assertion failed: "+ze)}function w(Pe){var ze=e["_"+Pe];return S(ze,"Cannot call unknown function "+Pe+", make sure it is exported"),ze}function C(Pe,ze,yt,je,f){var W={string:function(_n){var Br=0;if(_n!=null&&_n!==0){var El=(_n.length<<2)+1;Br=dt(El),F(_n,Br,El)}return Br},array:function(_n){var Br=dt(_n.length);return P(_n,Br),Br}};function Nn(_n){return ze==="string"?B(_n):ze==="boolean"?!!_n:_n}var qn=w(Pe),Hi=[],bn=0;if(je)for(var Pn=0;Pn=je);)++f;if(f-ze>16&&Pe.subarray&&N)return N.decode(Pe.subarray(ze,f));for(var W="";ze>10,56320|bn&1023)}}return W}function B(Pe,ze){return Pe?L(j,Pe,ze):""}function I(Pe,ze,yt,je){if(!(je>0))return 0;for(var f=yt,W=yt+je-1,Nn=0;Nn=55296&&qn<=57343){var Hi=Pe.charCodeAt(++Nn);qn=65536+((qn&1023)<<10)|Hi&1023}if(qn<=127){if(yt>=W)break;ze[yt++]=qn}else if(qn<=2047){if(yt+1>=W)break;ze[yt++]=192|qn>>6,ze[yt++]=128|qn&63}else if(qn<=65535){if(yt+2>=W)break;ze[yt++]=224|qn>>12,ze[yt++]=128|qn>>6&63,ze[yt++]=128|qn&63}else{if(yt+3>=W)break;ze[yt++]=240|qn>>18,ze[yt++]=128|qn>>12&63,ze[yt++]=128|qn>>6&63,ze[yt++]=128|qn&63}}return ze[yt]=0,yt-f}function F(Pe,ze,yt){return I(Pe,j,ze,yt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function P(Pe,ze){q.set(Pe,ze)}function O(Pe,ze){return Pe%ze>0&&(Pe+=ze-Pe%ze),Pe}var G,q,j,Y,$,Q,ee;function ue(Pe){G=Pe,e.HEAP8=q=new Int8Array(Pe),e.HEAP16=Y=new Int16Array(Pe),e.HEAP32=$=new Int32Array(Pe),e.HEAPU8=j=new Uint8Array(Pe),e.HEAPU16=new Uint16Array(Pe),e.HEAPU32=new Uint32Array(Pe),e.HEAPF32=Q=new Float32Array(Pe),e.HEAPF64=ee=new Float64Array(Pe)}var le=5271536,de=28624,Te=e.TOTAL_MEMORY||33554432;e.buffer?G=e.buffer:G=new ArrayBuffer(Te),Te=G.byteLength,ue(G),$[de>>2]=le;function Qe(Pe){for(;Pe.length>0;){var ze=Pe.shift();if(typeof ze=="function"){ze();continue}var yt=ze.func;typeof yt=="number"?ze.arg===void 0?e.dynCall_v(yt):e.dynCall_vi(yt,ze.arg):yt(ze.arg===void 0?null:ze.arg)}}var Ye=[],Et=[],at=[],ve=[];function Re(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)qt(e.preRun.shift());Qe(Ye)}function Je(){Qe(Et)}function Ct(){Qe(at)}function et(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)en(e.postRun.shift());Qe(ve)}function qt(Pe){Ye.unshift(Pe)}function en(Pe){ve.unshift(Pe)}var zt=Math.abs,Oe=Math.ceil,tt=Math.floor,Ve=Math.min,pt=0,ae=null;function tn(Pe){pt++,e.monitorRunDependencies&&e.monitorRunDependencies(pt)}function St(Pe){if(pt--,e.monitorRunDependencies&&e.monitorRunDependencies(pt),pt==0&&ae){var ze=ae;ae=null,ze()}}e.preloadedImages={},e.preloadedAudios={};var jt=null,ft="data:application/octet-stream;base64,";function ie(Pe){return String.prototype.startsWith?Pe.startsWith(ft):Pe.indexOf(ft)===0}var H,_e;jt="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var Le=28640;function $e(Pe,ze,yt,je){gr("Assertion failed: "+B(Pe)+", at: "+[ze?B(ze):"unknown filename",yt,je?B(je):"unknown function"])}function De(){return q.length}function Ht(Pe,ze,yt){j.set(j.subarray(ze,ze+yt),Pe)}function mt(Pe){return e.___errno_location&&($[e.___errno_location()>>2]=Pe),Pe}function Ot(Pe){gr("OOM")}function Qt(Pe){try{var ze=new ArrayBuffer(Pe);return ze.byteLength!=Pe?void 0:(new Int8Array(ze).set(q),vt(ze),ue(ze),1)}catch{}}function it(Pe){var ze=De(),yt=16777216,je=2147483648-yt;if(Pe>je)return!1;for(var f=16777216,W=Math.max(ze,f);W>4,f=(qn&15)<<4|Hi>>2,W=(Hi&3)<<6|bn,yt=yt+String.fromCharCode(je),Hi!==64&&(yt=yt+String.fromCharCode(f)),bn!==64&&(yt=yt+String.fromCharCode(W));while(Pn13780509?(c=Fp(15,c)|0,c|0):(p=((h|0)<0)<<31>>31,_=qr(h|0,p|0,3,0)|0,m=V()|0,p=sn(h|0,p|0,1,0)|0,p=qr(_|0,m|0,p|0,V()|0)|0,p=sn(p|0,V()|0,1,0)|0,h=V()|0,f[c>>2]=p,f[c+4>>2]=h,c=0,c|0)}function ei(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,On(h,c,p,m,0)|0}function On(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0;if(R=z,z=z+16|0,b=R,!(_r(h,c,p,m,_)|0))return m=0,z=R,m|0;do if((p|0)>=0){if((p|0)>13780509){if(y=Fp(15,b)|0,y|0)break;M=b,b=f[M>>2]|0,M=f[M+4>>2]|0}else y=((p|0)<0)<<31>>31,D=qr(p|0,y|0,3,0)|0,M=V()|0,y=sn(p|0,y|0,1,0)|0,y=qr(D|0,M|0,y|0,V()|0)|0,y=sn(y|0,V()|0,1,0)|0,M=V()|0,f[b>>2]=y,f[b+4>>2]=M,b=y;if(bu(m|0,0,b<<3|0)|0,_|0){bu(_|0,0,b<<2|0)|0,y=wr(h,c,p,m,_,b,M,0)|0;break}y=Ks(b,4)|0,y?(D=wr(h,c,p,m,y,b,M,0)|0,on(y),y=D):y=13}else y=2;while(!1);return D=y,z=R,D|0}function _r(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0;if(Ae=z,z=z+16|0,se=Ae,oe=Ae+8|0,re=se,f[re>>2]=h,f[re+4>>2]=c,(p|0)<0)return oe=2,z=Ae,oe|0;if(y=m,f[y>>2]=h,f[y+4>>2]=c,y=(_|0)!=0,y&&(f[_>>2]=0),Ni(h,c)|0)return oe=9,z=Ae,oe|0;f[oe>>2]=0;e:do if((p|0)>=1)if(y)for(k=1,D=0,X=0,re=1,y=h;;){if(!(D|X)){if(y=Xn(y,c,4,oe,se)|0,y|0)break e;if(c=se,y=f[c>>2]|0,c=f[c+4>>2]|0,Ni(y,c)|0){y=9;break e}}if(y=Xn(y,c,f[26800+(X<<2)>>2]|0,oe,se)|0,y|0)break e;if(c=se,y=f[c>>2]|0,c=f[c+4>>2]|0,h=m+(k<<3)|0,f[h>>2]=y,f[h+4>>2]=c,f[_+(k<<2)>>2]=re,h=D+1|0,b=(h|0)==(re|0),M=X+1|0,R=(M|0)==6,Ni(y,c)|0){y=9;break e}if(re=re+(R&b&1)|0,(re|0)>(p|0)){y=0;break}else k=k+1|0,D=b?0:h,X=b?R?0:M:X}else for(k=1,D=0,X=0,re=1,y=h;;){if(!(D|X)){if(y=Xn(y,c,4,oe,se)|0,y|0)break e;if(c=se,y=f[c>>2]|0,c=f[c+4>>2]|0,Ni(y,c)|0){y=9;break e}}if(y=Xn(y,c,f[26800+(X<<2)>>2]|0,oe,se)|0,y|0)break e;if(c=se,y=f[c>>2]|0,c=f[c+4>>2]|0,h=m+(k<<3)|0,f[h>>2]=y,f[h+4>>2]=c,h=D+1|0,b=(h|0)==(re|0),M=X+1|0,R=(M|0)==6,Ni(y,c)|0){y=9;break e}if(re=re+(R&b&1)|0,(re|0)>(p|0)){y=0;break}else k=k+1|0,D=b?0:h,X=b?R?0:M:X}else y=0;while(!1);return oe=y,z=Ae,oe|0}function wr(h,c,p,m,_,y,b,M){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0,b=b|0,M=M|0;var R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0;if(Ae=z,z=z+16|0,se=Ae+8|0,oe=Ae,R=Gh(h|0,c|0,y|0,b|0)|0,k=V()|0,X=m+(R<<3)|0,be=X,Ne=f[be>>2]|0,be=f[be+4>>2]|0,D=(Ne|0)==(h|0)&(be|0)==(c|0),!((Ne|0)==0&(be|0)==0|D))do R=sn(R|0,k|0,1,0)|0,R=Vh(R|0,V()|0,y|0,b|0)|0,k=V()|0,X=m+(R<<3)|0,Ne=X,be=f[Ne>>2]|0,Ne=f[Ne+4>>2]|0,D=(be|0)==(h|0)&(Ne|0)==(c|0);while(!((be|0)==0&(Ne|0)==0|D));if(R=_+(R<<2)|0,D&&(f[R>>2]|0)<=(M|0)||(Ne=X,f[Ne>>2]=h,f[Ne+4>>2]=c,f[R>>2]=M,(M|0)>=(p|0)))return Ne=0,z=Ae,Ne|0;switch(D=M+1|0,f[se>>2]=0,R=Xn(h,c,2,se,oe)|0,R|0){case 9:{re=9;break}case 0:{R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R||(re=9);break}}e:do if((re|0)==9){switch(f[se>>2]=0,R=Xn(h,c,3,se,oe)|0,R|0){case 9:break;case 0:{if(R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R|0)break e;break}default:break e}switch(f[se>>2]=0,R=Xn(h,c,1,se,oe)|0,R|0){case 9:break;case 0:{if(R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R|0)break e;break}default:break e}switch(f[se>>2]=0,R=Xn(h,c,5,se,oe)|0,R|0){case 9:break;case 0:{if(R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R|0)break e;break}default:break e}switch(f[se>>2]=0,R=Xn(h,c,4,se,oe)|0,R|0){case 9:break;case 0:{if(R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R|0)break e;break}default:break e}switch(f[se>>2]=0,R=Xn(h,c,6,se,oe)|0,R|0){case 9:break;case 0:{if(R=oe,R=wr(f[R>>2]|0,f[R+4>>2]|0,p,m,_,y,b,D)|0,R|0)break e;break}default:break e}return Ne=0,z=Ae,Ne|0}while(!1);return Ne=R,z=Ae,Ne|0}function Xn(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0;if(p>>>0>6)return _=1,_|0;if(X=(f[m>>2]|0)%6|0,f[m>>2]=X,(X|0)>0){y=0;do p=Sc(p)|0,y=y+1|0;while((y|0)<(f[m>>2]|0))}if(X=Xe(h|0,c|0,45)|0,V()|0,k=X&127,k>>>0>121)return _=5,_|0;R=Ys(h,c)|0,y=Xe(h|0,c|0,52)|0,V()|0,y=y&15;e:do if(!y)D=8;else{for(;;){if(b=(15-y|0)*3|0,M=Xe(h|0,c|0,b|0)|0,V()|0,M=M&7,(M|0)==7){c=5;break}if(oe=(Fo(y)|0)==0,y=y+-1|0,re=st(7,0,b|0)|0,c=c&~(V()|0),se=st(f[(oe?432:16)+(M*28|0)+(p<<2)>>2]|0,0,b|0)|0,b=V()|0,p=f[(oe?640:224)+(M*28|0)+(p<<2)>>2]|0,h=se|h&~re,c=b|c,!p){p=0;break e}if(!y){D=8;break e}}return c|0}while(!1);(D|0)==8&&(oe=f[848+(k*28|0)+(p<<2)>>2]|0,se=st(oe|0,0,45)|0,h=se|h,c=V()|0|c&-1040385,p=f[4272+(k*28|0)+(p<<2)>>2]|0,(oe&127|0)==127&&(oe=st(f[848+(k*28|0)+20>>2]|0,0,45)|0,c=V()|0|c&-1040385,p=f[4272+(k*28|0)+20>>2]|0,h=Tc(oe|h,c)|0,c=V()|0,f[m>>2]=(f[m>>2]|0)+1)),M=Xe(h|0,c|0,45)|0,V()|0,M=M&127;e:do if(pi(M)|0){t:do if((Ys(h,c)|0)==1){if((k|0)!=(M|0))if(vc(M,f[7696+(k*28|0)>>2]|0)|0){h=J_(h,c)|0,b=1,c=V()|0;break}else Fe(27795,26864,533,26872);switch(R|0){case 3:{h=Tc(h,c)|0,c=V()|0,f[m>>2]=(f[m>>2]|0)+1,b=0;break t}case 5:{h=J_(h,c)|0,c=V()|0,f[m>>2]=(f[m>>2]|0)+5,b=0;break t}case 0:return oe=9,oe|0;default:return oe=1,oe|0}}else b=0;while(!1);if((p|0)>0){y=0;do h=Z_(h,c)|0,c=V()|0,y=y+1|0;while((y|0)!=(p|0))}if((k|0)!=(M|0)){if(!(Dh(M)|0)){if((b|0)!=0|(Ys(h,c)|0)!=5)break;f[m>>2]=(f[m>>2]|0)+1;break}switch(X&127){case 8:case 118:break e}(Ys(h,c)|0)!=3&&(f[m>>2]=(f[m>>2]|0)+1)}}else if((p|0)>0){y=0;do h=Tc(h,c)|0,c=V()|0,y=y+1|0;while((y|0)!=(p|0))}while(!1);return f[m>>2]=((f[m>>2]|0)+p|0)%6|0,oe=_,f[oe>>2]=h,f[oe+4>>2]=c,oe=0,oe|0}function ra(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,li(h,c,p,m)|0?(bu(m|0,0,p*48|0)|0,m=ur(h,c,p,m)|0,m|0):(m=0,m|0)}function li(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0;if(oe=z,z=z+16|0,re=oe,se=oe+8|0,X=re,f[X>>2]=h,f[X+4>>2]=c,(p|0)<0)return se=2,z=oe,se|0;if(!p)return se=m,f[se>>2]=h,f[se+4>>2]=c,se=0,z=oe,se|0;f[se>>2]=0;e:do if(Ni(h,c)|0)h=9;else{_=0,X=h;do{if(h=Xn(X,c,4,se,re)|0,h|0)break e;if(c=re,X=f[c>>2]|0,c=f[c+4>>2]|0,_=_+1|0,Ni(X,c)|0){h=9;break e}}while((_|0)<(p|0));k=m,f[k>>2]=X,f[k+4>>2]=c,k=p+-1|0,D=0,h=1;do{if(_=26800+(D<<2)|0,(D|0)==5)for(b=f[_>>2]|0,y=0,_=h;;){if(h=re,h=Xn(f[h>>2]|0,f[h+4>>2]|0,b,se,re)|0,h|0)break e;if((y|0)!=(k|0))if(R=re,M=f[R>>2]|0,R=f[R+4>>2]|0,h=m+(_<<3)|0,f[h>>2]=M,f[h+4>>2]=R,!(Ni(M,R)|0))h=_+1|0;else{h=9;break e}else h=_;if(y=y+1|0,(y|0)>=(p|0))break;_=h}else for(b=re,R=f[_>>2]|0,M=0,_=h,y=f[b>>2]|0,b=f[b+4>>2]|0;;){if(h=Xn(y,b,R,se,re)|0,h|0)break e;if(b=re,y=f[b>>2]|0,b=f[b+4>>2]|0,h=m+(_<<3)|0,f[h>>2]=y,f[h+4>>2]=b,h=_+1|0,Ni(y,b)|0){h=9;break e}if(M=M+1|0,(M|0)>=(p|0))break;_=h}D=D+1|0}while(D>>>0<6);h=re,h=(X|0)==(f[h>>2]|0)&&(c|0)==(f[h+4>>2]|0)?0:9}while(!1);return se=h,z=oe,se|0}function ur(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;if(X=z,z=z+16|0,b=X,!p)return f[m>>2]=h,f[m+4>>2]=c,m=0,z=X,m|0;do if((p|0)>=0){if((p|0)>13780509){if(_=Fp(15,b)|0,_|0)break;y=b,_=f[y>>2]|0,y=f[y+4>>2]|0}else _=((p|0)<0)<<31>>31,k=qr(p|0,_|0,3,0)|0,y=V()|0,_=sn(p|0,_|0,1,0)|0,_=qr(k|0,y|0,_|0,V()|0)|0,_=sn(_|0,V()|0,1,0)|0,y=V()|0,k=b,f[k>>2]=_,f[k+4>>2]=y;if(D=Ks(_,8)|0,!D)_=13;else{if(k=Ks(_,4)|0,!k){on(D),_=13;break}if(_=wr(h,c,p,D,k,_,y,0)|0,_|0){on(D),on(k);break}if(c=f[b>>2]|0,b=f[b+4>>2]|0,(b|0)>0|(b|0)==0&c>>>0>0){_=0,M=0,R=0;do h=D+(M<<3)|0,y=f[h>>2]|0,h=f[h+4>>2]|0,!((y|0)==0&(h|0)==0)&&(f[k+(M<<2)>>2]|0)==(p|0)&&(re=m+(_<<3)|0,f[re>>2]=y,f[re+4>>2]=h,_=_+1|0),M=sn(M|0,R|0,1,0)|0,R=V()|0;while((R|0)<(b|0)|(R|0)==(b|0)&M>>>0>>0)}on(D),on(k),_=0}}else _=2;while(!1);return re=_,z=X,re|0}function vr(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0;for(M=z,z=z+16|0,y=M,b=M+8|0,_=(Ni(h,c)|0)==0,_=_?1:2;;){if(f[b>>2]=0,D=(Xn(h,c,_,b,y)|0)==0,R=y,D&((f[R>>2]|0)==(p|0)?(f[R+4>>2]|0)==(m|0):0)){h=4;break}if(_=_+1|0,_>>>0>=7){_=7,h=4;break}}return(h|0)==4?(z=M,_|0):0}function Mr(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0;if(M=z,z=z+48|0,_=M+16|0,y=M+8|0,b=M,p=uA(p)|0,p|0)return b=p,z=M,b|0;if(D=h,R=f[D+4>>2]|0,p=y,f[p>>2]=f[D>>2],f[p+4>>2]=R,aT(y,_),p=ts(_,c,b)|0,!p){if(c=f[y>>2]|0,y=f[h+8>>2]|0,(y|0)>0){_=f[h+12>>2]|0,p=0;do c=(f[_+(p<<3)>>2]|0)+c|0,p=p+1|0;while((p|0)<(y|0))}p=b,_=f[p>>2]|0,p=f[p+4>>2]|0,y=((c|0)<0)<<31>>31,(p|0)<(y|0)|(p|0)==(y|0)&_>>>0>>0?(p=b,f[p>>2]=c,f[p+4>>2]=y,p=y):c=_,R=sn(c|0,p|0,12,0)|0,D=V()|0,p=b,f[p>>2]=R,f[p+4>>2]=D,p=m,f[p>>2]=R,f[p+4>>2]=D,p=0}return D=p,z=M,D|0}function cr(h,c,p,m,_,y,b){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0,b=b|0;var M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0,Jt=0,ot=0,Un=0,Si=0,Dn=0,Ti=0,Ds=0,yT=0;if(Si=z,z=z+64|0,mn=Si+48|0,Jt=Si+32|0,ot=Si+24|0,lt=Si+8|0,Zt=Si,R=f[h>>2]|0,(R|0)<=0)return Un=0,z=Si,Un|0;for(Ft=h+4|0,Mn=mn+8|0,En=Jt+8|0,Gn=lt+8|0,M=0,we=0;;){D=f[Ft>>2]|0,Ee=D+(we<<4)|0,f[mn>>2]=f[Ee>>2],f[mn+4>>2]=f[Ee+4>>2],f[mn+8>>2]=f[Ee+8>>2],f[mn+12>>2]=f[Ee+12>>2],(we|0)==(R+-1|0)?(f[Jt>>2]=f[D>>2],f[Jt+4>>2]=f[D+4>>2],f[Jt+8>>2]=f[D+8>>2],f[Jt+12>>2]=f[D+12>>2]):(Ee=D+(we+1<<4)|0,f[Jt>>2]=f[Ee>>2],f[Jt+4>>2]=f[Ee+4>>2],f[Jt+8>>2]=f[Ee+8>>2],f[Jt+12>>2]=f[Ee+12>>2]),R=gu(mn,Jt,m,ot)|0;e:do if(R)D=0,M=R;else if(R=ot,D=f[R>>2]|0,R=f[R+4>>2]|0,(R|0)>0|(R|0)==0&D>>>0>0){Ne=0,Ee=0;t:for(;;){if(Ti=1/(+(D>>>0)+4294967296*+(R|0)),yT=+W[mn>>3],R=Gr(D|0,R|0,Ne|0,Ee|0)|0,Ds=+(R>>>0)+4294967296*+(V()|0),Dn=+(Ne>>>0)+4294967296*+(Ee|0),W[lt>>3]=Ti*(yT*Ds)+Ti*(+W[Jt>>3]*Dn),W[Gn>>3]=Ti*(+W[Mn>>3]*Ds)+Ti*(+W[En>>3]*Dn),R=e2(lt,m,Zt)|0,R|0){M=R;break}be=Zt,Ae=f[be>>2]|0,be=f[be+4>>2]|0,re=Gh(Ae|0,be|0,c|0,p|0)|0,k=V()|0,R=b+(re<<3)|0,X=R,D=f[X>>2]|0,X=f[X+4>>2]|0;n:do if((D|0)==0&(X|0)==0)me=R,Un=16;else for(se=0,oe=0;;){if((se|0)>(p|0)|(se|0)==(p|0)&oe>>>0>c>>>0){M=1;break t}if((D|0)==(Ae|0)&(X|0)==(be|0))break n;if(R=sn(re|0,k|0,1,0)|0,re=Vh(R|0,V()|0,c|0,p|0)|0,k=V()|0,oe=sn(oe|0,se|0,1,0)|0,se=V()|0,R=b+(re<<3)|0,X=R,D=f[X>>2]|0,X=f[X+4>>2]|0,(D|0)==0&(X|0)==0){me=R,Un=16;break}}while(!1);if((Un|0)==16&&(Un=0,!((Ae|0)==0&(be|0)==0))&&(oe=me,f[oe>>2]=Ae,f[oe+4>>2]=be,oe=y+(f[_>>2]<<3)|0,f[oe>>2]=Ae,f[oe+4>>2]=be,oe=_,oe=sn(f[oe>>2]|0,f[oe+4>>2]|0,1,0)|0,Ae=V()|0,be=_,f[be>>2]=oe,f[be+4>>2]=Ae),Ne=sn(Ne|0,Ee|0,1,0)|0,Ee=V()|0,R=ot,D=f[R>>2]|0,R=f[R+4>>2]|0,!((R|0)>(Ee|0)|(R|0)==(Ee|0)&D>>>0>Ne>>>0)){D=1;break e}}D=0}else D=1;while(!1);if(we=we+1|0,!D){Un=21;break}if(R=f[h>>2]|0,(we|0)>=(R|0)){M=0,Un=21;break}}return(Un|0)==21?(z=Si,M|0):0}function Rl(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0,Jt=0,ot=0,Un=0,Si=0,Dn=0,Ti=0,Ds=0;if(Ds=z,z=z+112|0,Un=Ds+80|0,R=Ds+72|0,Si=Ds,Dn=Ds+56|0,_=uA(p)|0,_|0)return Ti=_,z=Ds,Ti|0;if(D=h+8|0,Ti=Oa((f[D>>2]<<5)+32|0)|0,!Ti)return Ti=13,z=Ds,Ti|0;if(a2(h,Ti),_=uA(p)|0,!_){if(Jt=h,ot=f[Jt+4>>2]|0,_=R,f[_>>2]=f[Jt>>2],f[_+4>>2]=ot,aT(R,Un),_=ts(Un,c,Si)|0,_)Jt=0,ot=0;else{if(_=f[R>>2]|0,y=f[D>>2]|0,(y|0)>0){b=f[h+12>>2]|0,p=0;do _=(f[b+(p<<3)>>2]|0)+_|0,p=p+1|0;while((p|0)!=(y|0));p=_}else p=_;_=Si,y=f[_>>2]|0,_=f[_+4>>2]|0,b=((p|0)<0)<<31>>31,(_|0)<(b|0)|(_|0)==(b|0)&y>>>0

>>0?(_=Si,f[_>>2]=p,f[_+4>>2]=b,_=b):p=y,Jt=sn(p|0,_|0,12,0)|0,ot=V()|0,_=Si,f[_>>2]=Jt,f[_+4>>2]=ot,_=0}if(!_){if(p=Ks(Jt,8)|0,!p)return on(Ti),Ti=13,z=Ds,Ti|0;if(M=Ks(Jt,8)|0,!M)return on(Ti),on(p),Ti=13,z=Ds,Ti|0;Gn=Un,f[Gn>>2]=0,f[Gn+4>>2]=0,Gn=h,mn=f[Gn+4>>2]|0,_=R,f[_>>2]=f[Gn>>2],f[_+4>>2]=mn,_=cr(R,Jt,ot,c,Un,p,M)|0;e:do if(_)on(p),on(M),on(Ti);else{t:do if((f[D>>2]|0)>0){for(b=h+12|0,y=0;_=cr((f[b>>2]|0)+(y<<3)|0,Jt,ot,c,Un,p,M)|0,y=y+1|0,!(_|0);)if((y|0)>=(f[D>>2]|0))break t;on(p),on(M),on(Ti);break e}while(!1);(ot|0)>0|(ot|0)==0&Jt>>>0>0&&bu(M|0,0,Jt<<3|0)|0,mn=Un,Gn=f[mn+4>>2]|0;t:do if((Gn|0)>0|(Gn|0)==0&(f[mn>>2]|0)>>>0>0){Ft=p,Mn=M,En=p,Gn=M,mn=p,_=p,me=p,lt=M,Zt=M,p=M;n:for(;;){for(be=0,Ne=0,Ee=0,we=0,y=0,b=0;;){M=Si,R=M+56|0;do f[M>>2]=0,M=M+4|0;while((M|0)<(R|0));if(c=Ft+(be<<3)|0,D=f[c>>2]|0,c=f[c+4>>2]|0,_r(D,c,1,Si,0)|0){M=Si,R=M+56|0;do f[M>>2]=0,M=M+4|0;while((M|0)<(R|0));M=Ks(7,4)|0,M|0&&(wr(D,c,1,Si,M,7,0,0)|0,on(M))}for(Ae=0;;){oe=Si+(Ae<<3)|0,se=f[oe>>2]|0,oe=f[oe+4>>2]|0;i:do if((se|0)==0&(oe|0)==0)M=y,R=b;else{if(k=Gh(se|0,oe|0,Jt|0,ot|0)|0,D=V()|0,M=m+(k<<3)|0,c=M,R=f[c>>2]|0,c=f[c+4>>2]|0,!((R|0)==0&(c|0)==0)){X=0,re=0;do{if((X|0)>(ot|0)|(X|0)==(ot|0)&re>>>0>Jt>>>0)break n;if((R|0)==(se|0)&(c|0)==(oe|0)){M=y,R=b;break i}M=sn(k|0,D|0,1,0)|0,k=Vh(M|0,V()|0,Jt|0,ot|0)|0,D=V()|0,re=sn(re|0,X|0,1,0)|0,X=V()|0,M=m+(k<<3)|0,c=M,R=f[c>>2]|0,c=f[c+4>>2]|0}while(!((R|0)==0&(c|0)==0))}if((se|0)==0&(oe|0)==0){M=y,R=b;break}wc(se,oe,Dn)|0,l2(h,Ti,Dn)|0&&(re=sn(y|0,b|0,1,0)|0,b=V()|0,X=M,f[X>>2]=se,f[X+4>>2]=oe,y=Mn+(y<<3)|0,f[y>>2]=se,f[y+4>>2]=oe,y=re),M=y,R=b}while(!1);if(Ae=Ae+1|0,Ae>>>0>=7)break;y=M,b=R}if(be=sn(be|0,Ne|0,1,0)|0,Ne=V()|0,Ee=sn(Ee|0,we|0,1,0)|0,we=V()|0,b=Un,y=f[b>>2]|0,b=f[b+4>>2]|0,(we|0)<(b|0)|(we|0)==(b|0)&Ee>>>0>>0)y=M,b=R;else break}if((b|0)>0|(b|0)==0&y>>>0>0){y=0,b=0;do we=Ft+(y<<3)|0,f[we>>2]=0,f[we+4>>2]=0,y=sn(y|0,b|0,1,0)|0,b=V()|0,we=Un,Ee=f[we+4>>2]|0;while((b|0)<(Ee|0)|((b|0)==(Ee|0)?y>>>0<(f[we>>2]|0)>>>0:0))}if(we=Un,f[we>>2]=M,f[we+4>>2]=R,(R|0)>0|(R|0)==0&M>>>0>0)Ae=p,be=Zt,Ne=mn,Ee=lt,we=Mn,p=me,Zt=_,lt=En,me=Ae,_=be,mn=Gn,Gn=Ne,En=Ee,Mn=Ft,Ft=we;else break t}on(En),on(Gn),on(Ti),_=1;break e}else _=M;while(!1);on(Ti),on(p),on(_),_=0}while(!1);return Ti=_,z=Ds,Ti|0}}return on(Ti),Ti=_,z=Ds,Ti|0}function Uo(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(k=z,z=z+176|0,R=k,(c|0)<1)return dT(p,0,0),D=0,z=k,D|0;for(M=h,M=Xe(f[M>>2]|0,f[M+4>>2]|0,52)|0,V()|0,dT(p,(c|0)>6?c:6,M&15),M=0;m=h+(M<<3)|0,m=Oh(f[m>>2]|0,f[m+4>>2]|0,R)|0,!(m|0);){if(m=f[R>>2]|0,(m|0)>0){b=0;do y=R+8+(b<<4)|0,b=b+1|0,m=R+8+(((b|0)%(m|0)|0)<<4)|0,_=hI(p,m,y)|0,_?mT(p,_)|0:cI(p,y,m)|0,m=f[R>>2]|0;while((b|0)<(m|0))}if(M=M+1|0,(M|0)>=(c|0)){m=0,D=13;break}}return(D|0)==13?(z=k,m|0):(AT(p),D=m,z=k,D|0)}function mc(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;if(y=z,z=z+32|0,m=y,_=y+16|0,h=Uo(h,c,_)|0,h|0)return p=h,z=y,p|0;if(f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,h=pT(_)|0,h|0)do{c=VL(p)|0;do GL(c,h)|0,b=h+16|0,f[m>>2]=f[b>>2],f[m+4>>2]=f[b+4>>2],f[m+8>>2]=f[b+8>>2],f[m+12>>2]=f[b+12>>2],mT(_,h)|0,h=fI(_,m)|0;while(h|0);h=pT(_)|0}while(h|0);return AT(_),h=qL(p)|0,h?(iT(p),b=h,z=y,b|0):(b=0,z=y,b|0)}function pi(h){return h=h|0,h>>>0>121?(h=0,h|0):(h=f[7696+(h*28|0)+16>>2]|0,h|0)}function Dh(h){return h=h|0,(h|0)==4|(h|0)==117|0}function gc(h){return h=h|0,f[11120+((f[h>>2]|0)*216|0)+((f[h+4>>2]|0)*72|0)+((f[h+8>>2]|0)*24|0)+(f[h+12>>2]<<3)>>2]|0}function nA(h){return h=h|0,f[11120+((f[h>>2]|0)*216|0)+((f[h+4>>2]|0)*72|0)+((f[h+8>>2]|0)*24|0)+(f[h+12>>2]<<3)+4>>2]|0}function Np(h,c){h=h|0,c=c|0,h=7696+(h*28|0)|0,f[c>>2]=f[h>>2],f[c+4>>2]=f[h+4>>2],f[c+8>>2]=f[h+8>>2],f[c+12>>2]=f[h+12>>2]}function _c(h,c){h=h|0,c=c|0;var p=0,m=0;if(c>>>0>20)return c=-1,c|0;do if((f[11120+(c*216|0)>>2]|0)!=(h|0))if((f[11120+(c*216|0)+8>>2]|0)!=(h|0))if((f[11120+(c*216|0)+16>>2]|0)!=(h|0))if((f[11120+(c*216|0)+24>>2]|0)!=(h|0))if((f[11120+(c*216|0)+32>>2]|0)!=(h|0))if((f[11120+(c*216|0)+40>>2]|0)!=(h|0))if((f[11120+(c*216|0)+48>>2]|0)!=(h|0))if((f[11120+(c*216|0)+56>>2]|0)!=(h|0))if((f[11120+(c*216|0)+64>>2]|0)!=(h|0))if((f[11120+(c*216|0)+72>>2]|0)!=(h|0))if((f[11120+(c*216|0)+80>>2]|0)!=(h|0))if((f[11120+(c*216|0)+88>>2]|0)!=(h|0))if((f[11120+(c*216|0)+96>>2]|0)!=(h|0))if((f[11120+(c*216|0)+104>>2]|0)!=(h|0))if((f[11120+(c*216|0)+112>>2]|0)!=(h|0))if((f[11120+(c*216|0)+120>>2]|0)!=(h|0))if((f[11120+(c*216|0)+128>>2]|0)!=(h|0))if((f[11120+(c*216|0)+136>>2]|0)==(h|0))h=2,p=1,m=2;else{if((f[11120+(c*216|0)+144>>2]|0)==(h|0)){h=0,p=2,m=0;break}if((f[11120+(c*216|0)+152>>2]|0)==(h|0)){h=0,p=2,m=1;break}if((f[11120+(c*216|0)+160>>2]|0)==(h|0)){h=0,p=2,m=2;break}if((f[11120+(c*216|0)+168>>2]|0)==(h|0)){h=1,p=2,m=0;break}if((f[11120+(c*216|0)+176>>2]|0)==(h|0)){h=1,p=2,m=1;break}if((f[11120+(c*216|0)+184>>2]|0)==(h|0)){h=1,p=2,m=2;break}if((f[11120+(c*216|0)+192>>2]|0)==(h|0)){h=2,p=2,m=0;break}if((f[11120+(c*216|0)+200>>2]|0)==(h|0)){h=2,p=2,m=1;break}if((f[11120+(c*216|0)+208>>2]|0)==(h|0)){h=2,p=2,m=2;break}else h=-1;return h|0}else h=2,p=1,m=1;else h=2,p=1,m=0;else h=1,p=1,m=2;else h=1,p=1,m=1;else h=1,p=1,m=0;else h=0,p=1,m=2;else h=0,p=1,m=1;else h=0,p=1,m=0;else h=2,p=0,m=2;else h=2,p=0,m=1;else h=2,p=0,m=0;else h=1,p=0,m=2;else h=1,p=0,m=1;else h=1,p=0,m=0;else h=0,p=0,m=2;else h=0,p=0,m=1;else h=0,p=0,m=0;while(!1);return c=f[11120+(c*216|0)+(p*72|0)+(h*24|0)+(m<<3)+4>>2]|0,c|0}function vc(h,c){return h=h|0,c=c|0,(f[7696+(h*28|0)+20>>2]|0)==(c|0)?(c=1,c|0):(c=(f[7696+(h*28|0)+24>>2]|0)==(c|0),c|0)}function Lh(h,c){return h=h|0,c=c|0,f[848+(h*28|0)+(c<<2)>>2]|0}function mu(h,c){return h=h|0,c=c|0,(f[848+(h*28|0)>>2]|0)==(c|0)?(c=0,c|0):(f[848+(h*28|0)+4>>2]|0)==(c|0)?(c=1,c|0):(f[848+(h*28|0)+8>>2]|0)==(c|0)?(c=2,c|0):(f[848+(h*28|0)+12>>2]|0)==(c|0)?(c=3,c|0):(f[848+(h*28|0)+16>>2]|0)==(c|0)?(c=4,c|0):(f[848+(h*28|0)+20>>2]|0)==(c|0)?(c=5,c|0):((f[848+(h*28|0)+24>>2]|0)==(c|0)?6:7)|0}function iA(){return 122}function Pp(h){h=h|0;var c=0,p=0,m=0;c=0;do st(c|0,0,45)|0,m=V()|0|134225919,p=h+(c<<3)|0,f[p>>2]=-1,f[p+4>>2]=m,c=c+1|0;while((c|0)!=122);return 0}function Ih(h){h=h|0;var c=0,p=0,m=0;return m=+W[h+16>>3],p=+W[h+24>>3],c=m-p,+(m>3]<+W[h+24>>3]|0}function Bh(h){return h=h|0,+(+W[h>>3]-+W[h+8>>3])}function xc(h,c){h=h|0,c=c|0;var p=0,m=0,_=0;return p=+W[c>>3],!(p>=+W[h+8>>3])||!(p<=+W[h>>3])?(c=0,c|0):(m=+W[h+16>>3],p=+W[h+24>>3],_=+W[c+8>>3],c=_>=p,h=_<=m&1,m>3]<+W[c+8>>3]||+W[h+8>>3]>+W[c>>3]?(m=0,m|0):(y=+W[h+16>>3],p=h+24|0,k=+W[p>>3],b=y>3],_=c+24|0,R=+W[_>>3],M=D>3],c)||(k=+_o(+W[p>>3],h),k>+_o(+W[m>>3],c))?(M=0,M|0):(M=1,M|0))}function Dp(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0;y=+W[h+16>>3],R=+W[h+24>>3],h=y>3],b=+W[c+24>>3],_=M>2]=h?_|c?1:2:0,f[m>>2]=_?h?1:c?2:1:0}function Jr(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;return+W[h>>3]<+W[c>>3]||+W[h+8>>3]>+W[c+8>>3]?(m=0,m|0):(m=h+16|0,R=+W[m>>3],y=+W[h+24>>3],b=R>3],_=c+24|0,D=+W[_>>3],M=k>3],c)?(k=+_o(+W[m>>3],h),M=k>=+_o(+W[p>>3],c),M|0):(M=0,M|0))}function es(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0;_=z,z=z+176|0,m=_,f[m>>2]=4,M=+W[c>>3],W[m+8>>3]=M,y=+W[c+16>>3],W[m+16>>3]=y,W[m+24>>3]=M,M=+W[c+24>>3],W[m+32>>3]=M,b=+W[c+8>>3],W[m+40>>3]=b,W[m+48>>3]=M,W[m+56>>3]=b,W[m+64>>3]=y,c=m+72|0,p=c+96|0;do f[c>>2]=0,c=c+4|0;while((c|0)<(p|0));qh(h|0,m|0,168)|0,z=_}function ts(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0;oe=z,z=z+288|0,k=oe+264|0,X=oe+96|0,D=oe,M=D,R=M+96|0;do f[M>>2]=0,M=M+4|0;while((M|0)<(R|0));return c=n2(c,D)|0,c|0?(se=c,z=oe,se|0):(R=D,D=f[R>>2]|0,R=f[R+4>>2]|0,wc(D,R,k)|0,Oh(D,R,X)|0,b=+aA(k,X+8|0),W[k>>3]=+W[h>>3],R=k+8|0,W[R>>3]=+W[h+16>>3],W[X>>3]=+W[h+8>>3],D=X+8|0,W[D>>3]=+W[h+24>>3],_=+aA(k,X),be=+W[R>>3]-+W[D>>3],y=+bn(+be),Ae=+W[k>>3]-+W[X>>3],m=+bn(+Ae),!(be==0|Ae==0)&&(be=+vT(+y,+m),be=+go(+(_*_/+Vp(+(be/+Vp(+y,+m)),3)/(b*(b*2.59807621135)*.8))),W[Nn>>3]=be,re=~~be>>>0,se=+bn(be)>=1?be>0?~~+K(+Hi(be/4294967296),4294967295)>>>0:~~+go((be-+(~~be>>>0))/4294967296)>>>0:0,(f[Nn+4>>2]&2146435072|0)!=2146435072)?(X=(re|0)==0&(se|0)==0,c=p,f[c>>2]=X?1:re,f[c+4>>2]=X?0:se,c=0):c=1,se=c,z=oe,se|0)}function gu(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0;D=z,z=z+288|0,b=D+264|0,M=D+96|0,R=D,_=R,y=_+96|0;do f[_>>2]=0,_=_+4|0;while((_|0)<(y|0));return p=n2(p,R)|0,p|0?(m=p,z=D,m|0):(p=R,_=f[p>>2]|0,p=f[p+4>>2]|0,wc(_,p,b)|0,Oh(_,p,M)|0,k=+aA(b,M+8|0),k=+go(+(+aA(h,c)/(k*2))),W[Nn>>3]=k,p=~~k>>>0,_=+bn(k)>=1?k>0?~~+K(+Hi(k/4294967296),4294967295)>>>0:~~+go((k-+(~~k>>>0))/4294967296)>>>0:0,(f[Nn+4>>2]&2146435072|0)==2146435072?(m=1,z=D,m|0):(R=(p|0)==0&(_|0)==0,f[m>>2]=R?1:p,f[m+4>>2]=R?0:_,m=0,z=D,m|0))}function ns(h,c){h=h|0,c=+c;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;y=h+16|0,b=+W[y>>3],p=h+24|0,_=+W[p>>3],m=b-_,m=b<_?m+6.283185307179586:m,D=+W[h>>3],M=h+8|0,R=+W[M>>3],k=D-R,m=(m*c-m)*.5,c=(k*c-k)*.5,D=D+c,W[h>>3]=D>1.5707963267948966?1.5707963267948966:D,c=R-c,W[M>>3]=c<-1.5707963267948966?-1.5707963267948966:c,c=b+m,c=c>3.141592653589793?c+-6.283185307179586:c,W[y>>3]=c<-3.141592653589793?c+6.283185307179586:c,c=_-m,c=c>3.141592653589793?c+-6.283185307179586:c,W[p>>3]=c<-3.141592653589793?c+6.283185307179586:c}function Vt(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0,f[h>>2]=c,f[h+4>>2]=p,f[h+8>>2]=m}function Vn(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;X=c+8|0,f[X>>2]=0,R=+W[h>>3],b=+bn(+R),D=+W[h+8>>3],M=+bn(+D)*1.1547005383792515,b=b+M*.5,p=~~b,h=~~M,b=b-+(p|0),M=M-+(h|0);do if(b<.5)if(b<.3333333333333333)if(f[c>>2]=p,M<(b+1)*.5){f[c+4>>2]=h;break}else{h=h+1|0,f[c+4>>2]=h;break}else if(re=1-b,h=(!(M>2]=h,re<=M&M>2]=p;break}else{f[c>>2]=p;break}else{if(!(b<.6666666666666666))if(p=p+1|0,f[c>>2]=p,M>2]=h;break}else{h=h+1|0,f[c+4>>2]=h;break}if(M<1-b){if(f[c+4>>2]=h,b*2+-1>2]=p;break}}else h=h+1|0,f[c+4>>2]=h;p=p+1|0,f[c>>2]=p}while(!1);do if(R<0)if(h&1){k=(h+1|0)/2|0,k=Gr(p|0,((p|0)<0)<<31>>31|0,k|0,((k|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(k>>>0)+4294967296*+(V()|0))*2+1)),f[c>>2]=p;break}else{k=(h|0)/2|0,k=Gr(p|0,((p|0)<0)<<31>>31|0,k|0,((k|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(k>>>0)+4294967296*+(V()|0))*2),f[c>>2]=p;break}while(!1);k=c+4|0,D<0&&(p=p-((h<<1|1|0)/2|0)|0,f[c>>2]=p,h=0-h|0,f[k>>2]=h),m=h-p|0,(p|0)<0?(_=0-p|0,f[k>>2]=m,f[X>>2]=_,f[c>>2]=0,h=m,p=0):_=0,(h|0)<0&&(p=p-h|0,f[c>>2]=p,_=_-h|0,f[X>>2]=_,f[k>>2]=0,h=0),y=p-_|0,m=h-_|0,(_|0)<0&&(f[c>>2]=y,f[k>>2]=m,f[X>>2]=0,h=m,p=y,_=0),m=(h|0)<(p|0)?h:p,m=(_|0)<(m|0)?_:m,!((m|0)<=0)&&(f[c>>2]=p-m,f[k>>2]=h-m,f[X>>2]=_-m)}function ii(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0;c=f[h>>2]|0,b=h+4|0,p=f[b>>2]|0,(c|0)<0&&(p=p-c|0,f[b>>2]=p,y=h+8|0,f[y>>2]=(f[y>>2]|0)-c,f[h>>2]=0,c=0),(p|0)<0?(c=c-p|0,f[h>>2]=c,y=h+8|0,_=(f[y>>2]|0)-p|0,f[y>>2]=_,f[b>>2]=0,p=0):(_=h+8|0,y=_,_=f[_>>2]|0),(_|0)<0&&(c=c-_|0,f[h>>2]=c,p=p-_|0,f[b>>2]=p,f[y>>2]=0,_=0),m=(p|0)<(c|0)?p:c,m=(_|0)<(m|0)?_:m,!((m|0)<=0)&&(f[h>>2]=c-m,f[b>>2]=p-m,f[y>>2]=_-m)}function Fa(h,c){h=h|0,c=c|0;var p=0,m=0;m=f[h+8>>2]|0,p=+((f[h+4>>2]|0)-m|0),W[c>>3]=+((f[h>>2]|0)-m|0)-p*.5,W[c+8>>3]=p*.8660254037844386}function Ps(h,c,p){h=h|0,c=c|0,p=p|0,f[p>>2]=(f[c>>2]|0)+(f[h>>2]|0),f[p+4>>2]=(f[c+4>>2]|0)+(f[h+4>>2]|0),f[p+8>>2]=(f[c+8>>2]|0)+(f[h+8>>2]|0)}function W_(h,c,p){h=h|0,c=c|0,p=p|0,f[p>>2]=(f[h>>2]|0)-(f[c>>2]|0),f[p+4>>2]=(f[h+4>>2]|0)-(f[c+4>>2]|0),f[p+8>>2]=(f[h+8>>2]|0)-(f[c+8>>2]|0)}function VS(h,c){h=h|0,c=c|0;var p=0,m=0;p=gs(f[h>>2]|0,c)|0,f[h>>2]=p,p=h+4|0,m=gs(f[p>>2]|0,c)|0,f[p>>2]=m,h=h+8|0,c=gs(f[h>>2]|0,c)|0,f[h>>2]=c}function Lp(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;b=f[h>>2]|0,M=(b|0)<0,m=(f[h+4>>2]|0)-(M?b:0)|0,y=(m|0)<0,_=(y?0-m|0:0)+((f[h+8>>2]|0)-(M?b:0))|0,p=(_|0)<0,h=p?0:_,c=(y?0:m)-(p?_:0)|0,_=(M?0:b)-(y?m:0)-(p?_:0)|0,p=(c|0)<(_|0)?c:_,p=(h|0)<(p|0)?h:p,m=(p|0)>0,h=h-(m?p:0)|0,c=c-(m?p:0)|0;e:do switch(_-(m?p:0)|0){case 0:switch(c|0){case 0:return M=h|0?(h|0)==1?1:7:0,M|0;case 1:return M=h|0?(h|0)==1?3:7:2,M|0;default:break e}case 1:switch(c|0){case 0:return M=h|0?(h|0)==1?5:7:4,M|0;case 1:{if(!h)h=6;else break e;return h|0}default:break e}}while(!1);return M=7,M|0}function YD(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0;if(R=h+8|0,b=f[R>>2]|0,M=(f[h>>2]|0)-b|0,D=h+4|0,b=(f[D>>2]|0)-b|0,M>>>0>715827881|b>>>0>715827881){if(m=(M|0)>0,_=2147483647-M|0,y=-2147483648-M|0,(m?(_|0)<(M|0):(y|0)>(M|0))||(p=M<<1,m?(2147483647-p|0)<(M|0):(-2147483648-p|0)>(M|0))||((b|0)>0?(2147483647-b|0)<(b|0):(-2147483648-b|0)>(b|0))||(c=M*3|0,p=b<<1,(m?(_|0)<(p|0):(y|0)>(p|0))||((M|0)>-1?(c|-2147483648|0)>=(b|0):(c^-2147483648|0)<(b|0))))return D=1,D|0}else p=b<<1,c=M*3|0;return m=xu(+(c-b|0)*.14285714285714285)|0,f[h>>2]=m,_=xu(+(p+M|0)*.14285714285714285)|0,f[D>>2]=_,f[R>>2]=0,p=(_|0)<(m|0),c=p?m:_,p=p?_:m,(p|0)<0&&(((p|0)==-2147483648||((c|0)>0?(2147483647-c|0)<(p|0):(-2147483648-c|0)>(p|0)))&&Fe(27795,26892,354,26903),((c|0)>-1?(c|-2147483648|0)>=(p|0):(c^-2147483648|0)<(p|0))&&Fe(27795,26892,354,26903)),c=_-m|0,(m|0)<0?(p=0-m|0,f[D>>2]=c,f[R>>2]=p,f[h>>2]=0,m=0):(c=_,p=0),(c|0)<0&&(m=m-c|0,f[h>>2]=m,p=p-c|0,f[R>>2]=p,f[D>>2]=0,c=0),y=m-p|0,_=c-p|0,(p|0)<0?(f[h>>2]=y,f[D>>2]=_,f[R>>2]=0,c=_,_=y,p=0):_=m,m=(c|0)<(_|0)?c:_,m=(p|0)<(m|0)?p:m,(m|0)<=0?(D=0,D|0):(f[h>>2]=_-m,f[D>>2]=c-m,f[R>>2]=p-m,D=0,D|0)}function KD(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0;if(b=h+8|0,_=f[b>>2]|0,y=(f[h>>2]|0)-_|0,M=h+4|0,_=(f[M>>2]|0)-_|0,y>>>0>715827881|_>>>0>715827881){if(p=(y|0)>0,(p?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0))||(c=y<<1,m=(_|0)>0,m?(2147483647-_|0)<(_|0):(-2147483648-_|0)>(_|0)))return M=1,M|0;if(R=_<<1,(m?(2147483647-R|0)<(_|0):(-2147483648-R|0)>(_|0))||(p?(2147483647-c|0)<(_|0):(-2147483648-c|0)>(_|0))||(p=_*3|0,(_|0)>-1?(p|-2147483648|0)>=(y|0):(p^-2147483648|0)<(y|0)))return R=1,R|0}else p=_*3|0,c=y<<1;return m=xu(+(c+_|0)*.14285714285714285)|0,f[h>>2]=m,_=xu(+(p-y|0)*.14285714285714285)|0,f[M>>2]=_,f[b>>2]=0,p=(_|0)<(m|0),c=p?m:_,p=p?_:m,(p|0)<0&&(((p|0)==-2147483648||((c|0)>0?(2147483647-c|0)<(p|0):(-2147483648-c|0)>(p|0)))&&Fe(27795,26892,402,26917),((c|0)>-1?(c|-2147483648|0)>=(p|0):(c^-2147483648|0)<(p|0))&&Fe(27795,26892,402,26917)),c=_-m|0,(m|0)<0?(p=0-m|0,f[M>>2]=c,f[b>>2]=p,f[h>>2]=0,m=0):(c=_,p=0),(c|0)<0&&(m=m-c|0,f[h>>2]=m,p=p-c|0,f[b>>2]=p,f[M>>2]=0,c=0),y=m-p|0,_=c-p|0,(p|0)<0?(f[h>>2]=y,f[M>>2]=_,f[b>>2]=0,c=_,_=y,p=0):_=m,m=(c|0)<(_|0)?c:_,m=(p|0)<(m|0)?p:m,(m|0)<=0?(R=0,R|0):(f[h>>2]=_-m,f[M>>2]=c-m,f[b>>2]=p-m,R=0,R|0)}function ZD(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;b=h+8|0,p=f[b>>2]|0,c=(f[h>>2]|0)-p|0,M=h+4|0,p=(f[M>>2]|0)-p|0,m=xu(+((c*3|0)-p|0)*.14285714285714285)|0,f[h>>2]=m,c=xu(+((p<<1)+c|0)*.14285714285714285)|0,f[M>>2]=c,f[b>>2]=0,p=c-m|0,(m|0)<0?(y=0-m|0,f[M>>2]=p,f[b>>2]=y,f[h>>2]=0,c=p,m=0,p=y):p=0,(c|0)<0&&(m=m-c|0,f[h>>2]=m,p=p-c|0,f[b>>2]=p,f[M>>2]=0,c=0),y=m-p|0,_=c-p|0,(p|0)<0?(f[h>>2]=y,f[M>>2]=_,f[b>>2]=0,c=_,_=y,p=0):_=m,m=(c|0)<(_|0)?c:_,m=(p|0)<(m|0)?p:m,!((m|0)<=0)&&(f[h>>2]=_-m,f[M>>2]=c-m,f[b>>2]=p-m)}function GS(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;b=h+8|0,p=f[b>>2]|0,c=(f[h>>2]|0)-p|0,M=h+4|0,p=(f[M>>2]|0)-p|0,m=xu(+((c<<1)+p|0)*.14285714285714285)|0,f[h>>2]=m,c=xu(+((p*3|0)-c|0)*.14285714285714285)|0,f[M>>2]=c,f[b>>2]=0,p=c-m|0,(m|0)<0?(y=0-m|0,f[M>>2]=p,f[b>>2]=y,f[h>>2]=0,c=p,m=0,p=y):p=0,(c|0)<0&&(m=m-c|0,f[h>>2]=m,p=p-c|0,f[b>>2]=p,f[M>>2]=0,c=0),y=m-p|0,_=c-p|0,(p|0)<0?(f[h>>2]=y,f[M>>2]=_,f[b>>2]=0,c=_,_=y,p=0):_=m,m=(c|0)<(_|0)?c:_,m=(p|0)<(m|0)?p:m,!((m|0)<=0)&&(f[h>>2]=_-m,f[M>>2]=c-m,f[b>>2]=p-m)}function Ip(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;c=f[h>>2]|0,b=h+4|0,p=f[b>>2]|0,M=h+8|0,m=f[M>>2]|0,_=p+(c*3|0)|0,f[h>>2]=_,p=m+(p*3|0)|0,f[b>>2]=p,c=(m*3|0)+c|0,f[M>>2]=c,m=p-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=m,f[M>>2]=c,f[h>>2]=0,p=m,m=0):m=_,(p|0)<0&&(m=m-p|0,f[h>>2]=m,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=m-c|0,_=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=_,f[M>>2]=0,m=y,c=0):_=p,p=(_|0)<(m|0)?_:m,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=m-p,f[b>>2]=_-p,f[M>>2]=c-p)}function bc(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;_=f[h>>2]|0,b=h+4|0,c=f[b>>2]|0,M=h+8|0,p=f[M>>2]|0,m=(c*3|0)+_|0,_=p+(_*3|0)|0,f[h>>2]=_,f[b>>2]=m,c=(p*3|0)+c|0,f[M>>2]=c,p=m-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=p,f[M>>2]=c,f[h>>2]=0,_=0):p=m,(p|0)<0&&(_=_-p|0,f[h>>2]=_,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=_-c|0,m=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=m,f[M>>2]=0,_=y,c=0):m=p,p=(m|0)<(_|0)?m:_,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=_-p,f[b>>2]=m-p,f[M>>2]=c-p)}function qS(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0;(c+-1|0)>>>0>=6||(_=(f[15440+(c*12|0)>>2]|0)+(f[h>>2]|0)|0,f[h>>2]=_,M=h+4|0,m=(f[15440+(c*12|0)+4>>2]|0)+(f[M>>2]|0)|0,f[M>>2]=m,b=h+8|0,c=(f[15440+(c*12|0)+8>>2]|0)+(f[b>>2]|0)|0,f[b>>2]=c,p=m-_|0,(_|0)<0?(c=c-_|0,f[M>>2]=p,f[b>>2]=c,f[h>>2]=0,m=0):(p=m,m=_),(p|0)<0&&(m=m-p|0,f[h>>2]=m,c=c-p|0,f[b>>2]=c,f[M>>2]=0,p=0),y=m-c|0,_=p-c|0,(c|0)<0?(f[h>>2]=y,f[M>>2]=_,f[b>>2]=0,m=y,c=0):_=p,p=(_|0)<(m|0)?_:m,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=m-p,f[M>>2]=_-p,f[b>>2]=c-p))}function zS(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;_=f[h>>2]|0,b=h+4|0,c=f[b>>2]|0,M=h+8|0,p=f[M>>2]|0,m=c+_|0,_=p+_|0,f[h>>2]=_,f[b>>2]=m,c=p+c|0,f[M>>2]=c,p=m-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=p,f[M>>2]=c,f[h>>2]=0,m=0):(p=m,m=_),(p|0)<0&&(m=m-p|0,f[h>>2]=m,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=m-c|0,_=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=_,f[M>>2]=0,m=y,c=0):_=p,p=(_|0)<(m|0)?_:m,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=m-p,f[b>>2]=_-p,f[M>>2]=c-p)}function Bp(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;c=f[h>>2]|0,b=h+4|0,m=f[b>>2]|0,M=h+8|0,p=f[M>>2]|0,_=m+c|0,f[h>>2]=_,m=p+m|0,f[b>>2]=m,c=p+c|0,f[M>>2]=c,p=m-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=p,f[M>>2]=c,f[h>>2]=0,m=0):(p=m,m=_),(p|0)<0&&(m=m-p|0,f[h>>2]=m,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=m-c|0,_=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=_,f[M>>2]=0,m=y,c=0):_=p,p=(_|0)<(m|0)?_:m,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=m-p,f[b>>2]=_-p,f[M>>2]=c-p)}function Sc(h){switch(h=h|0,h|0){case 1:{h=5;break}case 5:{h=4;break}case 4:{h=6;break}case 6:{h=2;break}case 2:{h=3;break}case 3:{h=1;break}}return h|0}function _u(h){switch(h=h|0,h|0){case 1:{h=3;break}case 3:{h=2;break}case 2:{h=6;break}case 6:{h=4;break}case 4:{h=5;break}case 5:{h=1;break}}return h|0}function HS(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;c=f[h>>2]|0,b=h+4|0,p=f[b>>2]|0,M=h+8|0,m=f[M>>2]|0,_=p+(c<<1)|0,f[h>>2]=_,p=m+(p<<1)|0,f[b>>2]=p,c=(m<<1)+c|0,f[M>>2]=c,m=p-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=m,f[M>>2]=c,f[h>>2]=0,p=m,m=0):m=_,(p|0)<0&&(m=m-p|0,f[h>>2]=m,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=m-c|0,_=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=_,f[M>>2]=0,m=y,c=0):_=p,p=(_|0)<(m|0)?_:m,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=m-p,f[b>>2]=_-p,f[M>>2]=c-p)}function WS(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;_=f[h>>2]|0,b=h+4|0,c=f[b>>2]|0,M=h+8|0,p=f[M>>2]|0,m=(c<<1)+_|0,_=p+(_<<1)|0,f[h>>2]=_,f[b>>2]=m,c=(p<<1)+c|0,f[M>>2]=c,p=m-_|0,(_|0)<0?(c=c-_|0,f[b>>2]=p,f[M>>2]=c,f[h>>2]=0,_=0):p=m,(p|0)<0&&(_=_-p|0,f[h>>2]=_,c=c-p|0,f[M>>2]=c,f[b>>2]=0,p=0),y=_-c|0,m=p-c|0,(c|0)<0?(f[h>>2]=y,f[b>>2]=m,f[M>>2]=0,_=y,c=0):m=p,p=(m|0)<(_|0)?m:_,p=(c|0)<(p|0)?c:p,!((p|0)<=0)&&(f[h>>2]=_-p,f[b>>2]=m-p,f[M>>2]=c-p)}function $_(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0;return b=(f[h>>2]|0)-(f[c>>2]|0)|0,M=(b|0)<0,m=(f[h+4>>2]|0)-(f[c+4>>2]|0)-(M?b:0)|0,y=(m|0)<0,_=(M?0-b|0:0)+(f[h+8>>2]|0)-(f[c+8>>2]|0)+(y?0-m|0:0)|0,h=(_|0)<0,c=h?0:_,p=(y?0:m)-(h?_:0)|0,_=(M?0:b)-(y?m:0)-(h?_:0)|0,h=(p|0)<(_|0)?p:_,h=(c|0)<(h|0)?c:h,m=(h|0)>0,c=c-(m?h:0)|0,p=p-(m?h:0)|0,h=_-(m?h:0)|0,h=(h|0)>-1?h:0-h|0,p=(p|0)>-1?p:0-p|0,c=(c|0)>-1?c:0-c|0,c=(p|0)>(c|0)?p:c,((h|0)>(c|0)?h:c)|0}function JD(h,c){h=h|0,c=c|0;var p=0;p=f[h+8>>2]|0,f[c>>2]=(f[h>>2]|0)-p,f[c+4>>2]=(f[h+4>>2]|0)-p}function eL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0;return m=f[h>>2]|0,f[c>>2]=m,_=f[h+4>>2]|0,b=c+4|0,f[b>>2]=_,M=c+8|0,f[M>>2]=0,p=(_|0)<(m|0),h=p?m:_,p=p?_:m,(p|0)<0&&((p|0)==-2147483648||((h|0)>0?(2147483647-h|0)<(p|0):(-2147483648-h|0)>(p|0))||((h|0)>-1?(h|-2147483648|0)>=(p|0):(h^-2147483648|0)<(p|0)))?(c=1,c|0):(h=_-m|0,(m|0)<0?(p=0-m|0,f[b>>2]=h,f[M>>2]=p,f[c>>2]=0,m=0):(h=_,p=0),(h|0)<0&&(m=m-h|0,f[c>>2]=m,p=p-h|0,f[M>>2]=p,f[b>>2]=0,h=0),y=m-p|0,_=h-p|0,(p|0)<0?(f[c>>2]=y,f[b>>2]=_,f[M>>2]=0,h=_,_=y,p=0):_=m,m=(h|0)<(_|0)?h:_,m=(p|0)<(m|0)?p:m,(m|0)<=0?(c=0,c|0):(f[c>>2]=_-m,f[b>>2]=h-m,f[M>>2]=p-m,c=0,c|0))}function $S(h){h=h|0;var c=0,p=0,m=0,_=0;c=h+8|0,_=f[c>>2]|0,p=_-(f[h>>2]|0)|0,f[h>>2]=p,m=h+4|0,h=(f[m>>2]|0)-_|0,f[m>>2]=h,f[c>>2]=0-(h+p)}function tL(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;p=f[h>>2]|0,c=0-p|0,f[h>>2]=c,b=h+8|0,f[b>>2]=0,M=h+4|0,m=f[M>>2]|0,_=m+p|0,(p|0)>0?(f[M>>2]=_,f[b>>2]=p,f[h>>2]=0,c=0,m=_):p=0,(m|0)<0?(y=c-m|0,f[h>>2]=y,p=p-m|0,f[b>>2]=p,f[M>>2]=0,_=y-p|0,c=0-p|0,(p|0)<0?(f[h>>2]=_,f[M>>2]=c,f[b>>2]=0,m=c,p=0):(m=0,_=y)):_=c,c=(m|0)<(_|0)?m:_,c=(p|0)<(c|0)?p:c,!((c|0)<=0)&&(f[h>>2]=_-c,f[M>>2]=m-c,f[b>>2]=p-c)}function nL(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0;if(X=z,z=z+64|0,k=X,M=X+56|0,!(!0&(c&2013265920|0)==134217728&(!0&(m&2013265920|0)==134217728)))return _=5,z=X,_|0;if((h|0)==(p|0)&(c|0)==(m|0))return f[_>>2]=0,_=0,z=X,_|0;if(b=Xe(h|0,c|0,52)|0,V()|0,b=b&15,D=Xe(p|0,m|0,52)|0,V()|0,(b|0)!=(D&15|0))return _=12,z=X,_|0;if(y=b+-1|0,b>>>0>1){K_(h,c,y,k)|0,K_(p,m,y,M)|0,D=k,R=f[D>>2]|0,D=f[D+4>>2]|0;e:do if((R|0)==(f[M>>2]|0)&&(D|0)==(f[M+4>>2]|0)){b=(b^15)*3|0,y=Xe(h|0,c|0,b|0)|0,V()|0,y=y&7,b=Xe(p|0,m|0,b|0)|0,V()|0,b=b&7;do if((y|0)==0|(b|0)==0)f[_>>2]=1,y=0;else if((y|0)==7)y=5;else{if((y|0)==1|(b|0)==1&&Ni(R,D)|0){y=5;break}if((f[15536+(y<<2)>>2]|0)!=(b|0)&&(f[15568+(y<<2)>>2]|0)!=(b|0))break e;f[_>>2]=1,y=0}while(!1);return _=y,z=X,_|0}while(!1)}y=k,b=y+56|0;do f[y>>2]=0,y=y+4|0;while((y|0)<(b|0));return ei(h,c,1,k)|0,c=k,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0))&&(c=k+8|0,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0)))&&(c=k+16|0,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0)))&&(c=k+24|0,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0)))&&(c=k+32|0,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0)))&&(c=k+40|0,!((f[c>>2]|0)==(p|0)&&(f[c+4>>2]|0)==(m|0)))?(y=k+48|0,y=((f[y>>2]|0)==(p|0)?(f[y+4>>2]|0)==(m|0):0)&1):y=1,f[_>>2]=y,_=0,z=X,_|0}function iL(h,c,p,m,_){return h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,p=vr(h,c,p,m)|0,(p|0)==7?(_=11,_|0):(m=st(p|0,0,56)|0,c=c&-2130706433|(V()|0)|268435456,f[_>>2]=h|m,f[_+4>>2]=c,_=0,_|0)}function rL(h,c,p){return h=h|0,c=c|0,p=p|0,!0&(c&2013265920|0)==268435456?(f[p>>2]=h,f[p+4>>2]=c&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function sL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;return _=z,z=z+16|0,m=_,f[m>>2]=0,!0&(c&2013265920|0)==268435456?(y=Xe(h|0,c|0,56)|0,V()|0,m=Xn(h,c&-2130706433|134217728,y&7,m,p)|0,z=_,m|0):(m=6,z=_,m|0)}function jS(h,c){h=h|0,c=c|0;var p=0;switch(p=Xe(h|0,c|0,56)|0,V()|0,p&7){case 0:case 7:return p=0,p|0}return p=c&-2130706433|134217728,!(!0&(c&2013265920|0)==268435456)||!0&(c&117440512|0)==16777216&(Ni(h,p)|0)!=0?(p=0,p|0):(p=Q_(h,p)|0,p|0)}function oL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;return _=z,z=z+16|0,m=_,!0&(c&2013265920|0)==268435456?(y=c&-2130706433|134217728,b=p,f[b>>2]=h,f[b+4>>2]=y,f[m>>2]=0,c=Xe(h|0,c|0,56)|0,V()|0,m=Xn(h,y,c&7,m,p+8|0)|0,z=_,m|0):(m=6,z=_,m|0)}function aL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0;return _=(Ni(h,c)|0)==0,c=c&-2130706433,m=p,f[m>>2]=_?h:0,f[m+4>>2]=_?c|285212672:0,m=p+8|0,f[m>>2]=h,f[m+4>>2]=c|301989888,m=p+16|0,f[m>>2]=h,f[m+4>>2]=c|318767104,m=p+24|0,f[m>>2]=h,f[m+4>>2]=c|335544320,m=p+32|0,f[m>>2]=h,f[m+4>>2]=c|352321536,p=p+40|0,f[p>>2]=h,f[p+4>>2]=c|369098752,0}function Up(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;return b=z,z=z+16|0,_=b,y=c&-2130706433|134217728,!0&(c&2013265920|0)==268435456?(m=Xe(h|0,c|0,56)|0,V()|0,m=aI(h,y,m&7)|0,(m|0)==-1?(f[p>>2]=0,y=6,z=b,y|0):(Fh(h,y,_)|0&&Fe(27795,26932,282,26947),c=Xe(h|0,c|0,52)|0,V()|0,c=c&15,Ni(h,y)|0?j_(_,c,m,2,p):X_(_,c,m,2,p),y=0,z=b,y|0)):(y=6,z=b,y|0)}function lL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0;m=z,z=z+16|0,_=m,uL(h,c,p,_),Vn(_,p+4|0),z=m}function uL(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0;if(M=z,z=z+16|0,R=M,cL(h,p,R),y=+El(+(1-+W[R>>3]*.5)),y<1e-16){f[m>>2]=0,f[m+4>>2]=0,f[m+8>>2]=0,f[m+12>>2]=0,z=M;return}if(R=f[p>>2]|0,_=+W[15920+(R*24|0)>>3],_=+oA(_-+oA(+NL(15600+(R<<4)|0,h))),Fo(c)|0?b=+oA(_+-.3334731722518321):b=_,_=+Br(+y)*2.618033988749896,(c|0)>0){h=0;do _=_*2.6457513110645907,h=h+1|0;while((h|0)!=(c|0))}y=+kn(+b)*_,W[m>>3]=y,b=+_n(+b)*_,W[m+8>>3]=b,z=M}function cL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;if(y=z,z=z+32|0,_=y,oI(h,_),f[c>>2]=0,W[p>>3]=5,m=+Er(16400,_),m<+W[p>>3]&&(f[c>>2]=0,W[p>>3]=m),m=+Er(16424,_),m<+W[p>>3]&&(f[c>>2]=1,W[p>>3]=m),m=+Er(16448,_),m<+W[p>>3]&&(f[c>>2]=2,W[p>>3]=m),m=+Er(16472,_),m<+W[p>>3]&&(f[c>>2]=3,W[p>>3]=m),m=+Er(16496,_),m<+W[p>>3]&&(f[c>>2]=4,W[p>>3]=m),m=+Er(16520,_),m<+W[p>>3]&&(f[c>>2]=5,W[p>>3]=m),m=+Er(16544,_),m<+W[p>>3]&&(f[c>>2]=6,W[p>>3]=m),m=+Er(16568,_),m<+W[p>>3]&&(f[c>>2]=7,W[p>>3]=m),m=+Er(16592,_),m<+W[p>>3]&&(f[c>>2]=8,W[p>>3]=m),m=+Er(16616,_),m<+W[p>>3]&&(f[c>>2]=9,W[p>>3]=m),m=+Er(16640,_),m<+W[p>>3]&&(f[c>>2]=10,W[p>>3]=m),m=+Er(16664,_),m<+W[p>>3]&&(f[c>>2]=11,W[p>>3]=m),m=+Er(16688,_),m<+W[p>>3]&&(f[c>>2]=12,W[p>>3]=m),m=+Er(16712,_),m<+W[p>>3]&&(f[c>>2]=13,W[p>>3]=m),m=+Er(16736,_),m<+W[p>>3]&&(f[c>>2]=14,W[p>>3]=m),m=+Er(16760,_),m<+W[p>>3]&&(f[c>>2]=15,W[p>>3]=m),m=+Er(16784,_),m<+W[p>>3]&&(f[c>>2]=16,W[p>>3]=m),m=+Er(16808,_),m<+W[p>>3]&&(f[c>>2]=17,W[p>>3]=m),m=+Er(16832,_),m<+W[p>>3]&&(f[c>>2]=18,W[p>>3]=m),m=+Er(16856,_),!(m<+W[p>>3])){z=y;return}f[c>>2]=19,W[p>>3]=m,z=y}function rA(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0;if(y=+sI(h),y<1e-16){c=15600+(c<<4)|0,f[_>>2]=f[c>>2],f[_+4>>2]=f[c+4>>2],f[_+8>>2]=f[c+8>>2],f[_+12>>2]=f[c+12>>2];return}if(b=+Zr(+ +W[h+8>>3],+ +W[h>>3]),(p|0)>0){h=0;do y=y*.37796447300922725,h=h+1|0;while((h|0)!=(p|0))}M=y*.3333333333333333,m?(p=(Fo(p)|0)==0,y=+Ba(+((p?M:M*.37796447300922725)*.381966011250105))):(y=+Ba(+(y*.381966011250105)),Fo(p)|0&&(b=+oA(b+.3334731722518321))),PL(15600+(c<<4)|0,+oA(+W[15920+(c*24|0)>>3]-b),y,_)}function hL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0;m=z,z=z+16|0,_=m,Fa(h+4|0,_),rA(_,f[h>>2]|0,c,0,p),z=m}function j_(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0,Jt=0,ot=0,Un=0,Si=0,Dn=0;if(Un=z,z=z+272|0,y=Un+256|0,Ee=Un+240|0,mn=Un,Jt=Un+224|0,ot=Un+208|0,we=Un+176|0,me=Un+160|0,lt=Un+192|0,Zt=Un+144|0,Ft=Un+128|0,Mn=Un+112|0,En=Un+96|0,Gn=Un+80|0,f[y>>2]=c,f[Ee>>2]=f[h>>2],f[Ee+4>>2]=f[h+4>>2],f[Ee+8>>2]=f[h+8>>2],f[Ee+12>>2]=f[h+12>>2],XS(Ee,y,mn),f[_>>2]=0,Ee=m+p+((m|0)==5&1)|0,(Ee|0)<=(p|0)){z=Un;return}R=f[y>>2]|0,D=Jt+4|0,k=we+4|0,X=p+5|0,re=16880+(R<<2)|0,se=16960+(R<<2)|0,oe=Ft+8|0,Ae=Mn+8|0,be=En+8|0,Ne=ot+4|0,M=p;e:for(;;){b=mn+(((M|0)%5|0)<<4)|0,f[ot>>2]=f[b>>2],f[ot+4>>2]=f[b+4>>2],f[ot+8>>2]=f[b+8>>2],f[ot+12>>2]=f[b+12>>2];do;while((Uh(ot,R,0,1)|0)==2);if((M|0)>(p|0)&(Fo(c)|0)!=0){if(f[we>>2]=f[ot>>2],f[we+4>>2]=f[ot+4>>2],f[we+8>>2]=f[ot+8>>2],f[we+12>>2]=f[ot+12>>2],Fa(D,me),m=f[we>>2]|0,y=f[17040+(m*80|0)+(f[Jt>>2]<<2)>>2]|0,f[we>>2]=f[18640+(m*80|0)+(y*20|0)>>2],b=f[18640+(m*80|0)+(y*20|0)+16>>2]|0,(b|0)>0){h=0;do zS(k),h=h+1|0;while((h|0)<(b|0))}switch(b=18640+(m*80|0)+(y*20|0)+4|0,f[lt>>2]=f[b>>2],f[lt+4>>2]=f[b+4>>2],f[lt+8>>2]=f[b+8>>2],VS(lt,(f[re>>2]|0)*3|0),Ps(k,lt,k),ii(k),Fa(k,Zt),Si=+(f[se>>2]|0),W[Ft>>3]=Si*3,W[oe>>3]=0,Dn=Si*-1.5,W[Mn>>3]=Dn,W[Ae>>3]=Si*2.598076211353316,W[En>>3]=Dn,W[be>>3]=Si*-2.598076211353316,f[17040+((f[we>>2]|0)*80|0)+(f[ot>>2]<<2)>>2]|0){case 1:{h=Mn,m=Ft;break}case 3:{h=En,m=Mn;break}case 2:{h=Ft,m=En;break}default:{h=12;break e}}cT(me,Zt,m,h,Gn),rA(Gn,f[we>>2]|0,R,1,_+8+(f[_>>2]<<4)|0),f[_>>2]=(f[_>>2]|0)+1}if((M|0)<(X|0)&&(Fa(Ne,we),rA(we,f[ot>>2]|0,R,1,_+8+(f[_>>2]<<4)|0),f[_>>2]=(f[_>>2]|0)+1),f[Jt>>2]=f[ot>>2],f[Jt+4>>2]=f[ot+4>>2],f[Jt+8>>2]=f[ot+8>>2],f[Jt+12>>2]=f[ot+12>>2],M=M+1|0,(M|0)>=(Ee|0)){h=3;break}}if((h|0)==3){z=Un;return}else(h|0)==12&&Fe(26970,27017,572,27027)}function XS(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0;R=z,z=z+128|0,m=R+64|0,_=R,y=m,b=20240,M=y+60|0;do f[y>>2]=f[b>>2],y=y+4|0,b=b+4|0;while((y|0)<(M|0));y=_,b=20304,M=y+60|0;do f[y>>2]=f[b>>2],y=y+4|0,b=b+4|0;while((y|0)<(M|0));M=(Fo(f[c>>2]|0)|0)==0,m=M?m:_,_=h+4|0,HS(_),WS(_),Fo(f[c>>2]|0)|0&&(bc(_),f[c>>2]=(f[c>>2]|0)+1),f[p>>2]=f[h>>2],c=p+4|0,Ps(_,m,c),ii(c),f[p+16>>2]=f[h>>2],c=p+20|0,Ps(_,m+12|0,c),ii(c),f[p+32>>2]=f[h>>2],c=p+36|0,Ps(_,m+24|0,c),ii(c),f[p+48>>2]=f[h>>2],c=p+52|0,Ps(_,m+36|0,c),ii(c),f[p+64>>2]=f[h>>2],p=p+68|0,Ps(_,m+48|0,p),ii(p),z=R}function Uh(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0;if(oe=z,z=z+32|0,re=oe+12|0,M=oe,se=h+4|0,X=f[16960+(c<<2)>>2]|0,k=(m|0)!=0,X=k?X*3|0:X,_=f[se>>2]|0,D=h+8|0,b=f[D>>2]|0,k){if(y=h+12|0,m=f[y>>2]|0,_=b+_+m|0,(_|0)==(X|0))return se=1,z=oe,se|0;R=y}else R=h+12|0,m=f[R>>2]|0,_=b+_+m|0;if((_|0)<=(X|0))return se=0,z=oe,se|0;do if((m|0)>0){if(m=f[h>>2]|0,(b|0)>0){y=18640+(m*80|0)+60|0,m=h;break}m=18640+(m*80|0)+40|0,p?(Vt(re,X,0,0),W_(se,re,M),Bp(M),Ps(M,re,se),y=m,m=h):(y=m,m=h)}else y=18640+((f[h>>2]|0)*80|0)+20|0,m=h;while(!1);if(f[m>>2]=f[y>>2],_=y+16|0,(f[_>>2]|0)>0){m=0;do zS(se),m=m+1|0;while((m|0)<(f[_>>2]|0))}return h=y+4|0,f[re>>2]=f[h>>2],f[re+4>>2]=f[h+4>>2],f[re+8>>2]=f[h+8>>2],c=f[16880+(c<<2)>>2]|0,VS(re,k?c*3|0:c),Ps(se,re,se),ii(se),k?m=((f[D>>2]|0)+(f[se>>2]|0)+(f[R>>2]|0)|0)==(X|0)?1:2:m=2,se=m,z=oe,se|0}function fL(h,c){h=h|0,c=c|0;var p=0;do p=Uh(h,c,0,1)|0;while((p|0)==2);return p|0}function X_(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0;if(En=z,z=z+240|0,y=En+224|0,lt=En+208|0,Zt=En,Ft=En+192|0,Mn=En+176|0,be=En+160|0,Ne=En+144|0,Ee=En+128|0,we=En+112|0,me=En+96|0,f[y>>2]=c,f[lt>>2]=f[h>>2],f[lt+4>>2]=f[h+4>>2],f[lt+8>>2]=f[h+8>>2],f[lt+12>>2]=f[h+12>>2],QS(lt,y,Zt),f[_>>2]=0,Ae=m+p+((m|0)==6&1)|0,(Ae|0)<=(p|0)){z=En;return}R=f[y>>2]|0,D=p+6|0,k=16960+(R<<2)|0,X=Ne+8|0,re=Ee+8|0,se=we+8|0,oe=Ft+4|0,b=0,M=p,m=-1;e:for(;;){if(y=(M|0)%6|0,h=Zt+(y<<4)|0,f[Ft>>2]=f[h>>2],f[Ft+4>>2]=f[h+4>>2],f[Ft+8>>2]=f[h+8>>2],f[Ft+12>>2]=f[h+12>>2],h=b,b=Uh(Ft,R,0,1)|0,(M|0)>(p|0)&(Fo(c)|0)!=0&&(h|0)!=1&&(f[Ft>>2]|0)!=(m|0)){switch(Fa(Zt+(((y+5|0)%6|0)<<4)+4|0,Mn),Fa(Zt+(y<<4)+4|0,be),Gn=+(f[k>>2]|0),W[Ne>>3]=Gn*3,W[X>>3]=0,mn=Gn*-1.5,W[Ee>>3]=mn,W[re>>3]=Gn*2.598076211353316,W[we>>3]=mn,W[se>>3]=Gn*-2.598076211353316,y=f[lt>>2]|0,f[17040+(y*80|0)+(((m|0)==(y|0)?f[Ft>>2]|0:m)<<2)>>2]|0){case 1:{h=Ee,m=Ne;break}case 3:{h=we,m=Ee;break}case 2:{h=Ne,m=we;break}default:{h=8;break e}}cT(Mn,be,m,h,me),!(hT(Mn,me)|0)&&!(hT(be,me)|0)&&(rA(me,f[lt>>2]|0,R,1,_+8+(f[_>>2]<<4)|0),f[_>>2]=(f[_>>2]|0)+1)}if((M|0)<(D|0)&&(Fa(oe,Mn),rA(Mn,f[Ft>>2]|0,R,1,_+8+(f[_>>2]<<4)|0),f[_>>2]=(f[_>>2]|0)+1),M=M+1|0,(M|0)>=(Ae|0)){h=3;break}else m=f[Ft>>2]|0}if((h|0)==3){z=En;return}else(h|0)==8&&Fe(27054,27017,737,27099)}function QS(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0;R=z,z=z+160|0,m=R+80|0,_=R,y=m,b=20368,M=y+72|0;do f[y>>2]=f[b>>2],y=y+4|0,b=b+4|0;while((y|0)<(M|0));y=_,b=20448,M=y+72|0;do f[y>>2]=f[b>>2],y=y+4|0,b=b+4|0;while((y|0)<(M|0));M=(Fo(f[c>>2]|0)|0)==0,m=M?m:_,_=h+4|0,HS(_),WS(_),Fo(f[c>>2]|0)|0&&(bc(_),f[c>>2]=(f[c>>2]|0)+1),f[p>>2]=f[h>>2],c=p+4|0,Ps(_,m,c),ii(c),f[p+16>>2]=f[h>>2],c=p+20|0,Ps(_,m+12|0,c),ii(c),f[p+32>>2]=f[h>>2],c=p+36|0,Ps(_,m+24|0,c),ii(c),f[p+48>>2]=f[h>>2],c=p+52|0,Ps(_,m+36|0,c),ii(c),f[p+64>>2]=f[h>>2],c=p+68|0,Ps(_,m+48|0,c),ii(c),f[p+80>>2]=f[h>>2],p=p+84|0,Ps(_,m+60|0,p),ii(p),z=R}function dL(h,c){return h=h|0,c=c|0,c=Xe(h|0,c|0,52)|0,V()|0,c&15|0}function YS(h,c){return h=h|0,c=c|0,c=Xe(h|0,c|0,45)|0,V()|0,c&127|0}function AL(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,(p+-1|0)>>>0>14?(m=4,m|0):(p=Xe(h|0,c|0,(15-p|0)*3|0)|0,V()|0,f[m>>2]=p&7,m=0,m|0)}function pL(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0;if(h>>>0>15)return m=4,m|0;if(c>>>0>121)return m=17,m|0;b=st(h|0,0,52)|0,_=V()|0,M=st(c|0,0,45)|0,_=_|(V()|0)|134225919;e:do if((h|0)>=1){for(M=1,b=(je[20528+c>>0]|0)!=0,y=-1;;){if(c=f[p+(M+-1<<2)>>2]|0,c>>>0>6){_=18,c=10;break}if(!((c|0)==0|b^1))if((c|0)==1){_=19,c=10;break}else b=0;if(D=(15-M|0)*3|0,R=st(7,0,D|0)|0,_=_&~(V()|0),c=st(c|0,((c|0)<0)<<31>>31|0,D|0)|0,y=c|y&~R,_=V()|0|_,(M|0)<(h|0))M=M+1|0;else break e}if((c|0)==10)return _|0}else y=-1;while(!1);return D=m,f[D>>2]=y,f[D+4>>2]=_,D=0,D|0}function Q_(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0;return!(!0&(c&-16777216|0)==134217728)||(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,p=Xe(h|0,c|0,45)|0,V()|0,p=p&127,p>>>0>121)?(h=0,h|0):(b=(m^15)*3|0,_=Xe(h|0,c|0,b|0)|0,b=st(_|0,V()|0,b|0)|0,_=V()|0,y=Gr(-1227133514,-1171,b|0,_|0)|0,!((b&613566756&y|0)==0&(_&4681&(V()|0)|0)==0)||(b=(m*3|0)+19|0,y=st(~h|0,~c|0,b|0)|0,b=Xe(y|0,V()|0,b|0)|0,!((m|0)==15|(b|0)==0&(V()|0)==0))?(b=0,b|0):!(je[20528+p>>0]|0)||(c=c&8191,(h|0)==0&(c|0)==0)?(b=1,b|0):(b=c2(h|0,c|0)|0,V()|0,((63-b|0)%3|0|0)!=0|0))}function mL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0;return!0&(c&-16777216|0)==134217728&&(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,p=Xe(h|0,c|0,45)|0,V()|0,p=p&127,p>>>0<=121)&&(b=(m^15)*3|0,_=Xe(h|0,c|0,b|0)|0,b=st(_|0,V()|0,b|0)|0,_=V()|0,y=Gr(-1227133514,-1171,b|0,_|0)|0,(b&613566756&y|0)==0&(_&4681&(V()|0)|0)==0)&&(b=(m*3|0)+19|0,y=st(~h|0,~c|0,b|0)|0,b=Xe(y|0,V()|0,b|0)|0,(m|0)==15|(b|0)==0&(V()|0)==0)&&(!(je[20528+p>>0]|0)||(p=c&8191,(h|0)==0&(p|0)==0)||(b=c2(h|0,p|0)|0,V()|0,(63-b|0)%3|0|0))||jS(h,c)|0?(b=1,b|0):(b=(fT(h,c)|0)!=0&1,b|0)}function Y_(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0;if(_=st(c|0,0,52)|0,y=V()|0,p=st(p|0,0,45)|0,p=y|(V()|0)|134225919,(c|0)<1){y=-1,m=p,c=h,f[c>>2]=y,h=h+4|0,f[h>>2]=m;return}for(y=1,_=-1;b=(15-y|0)*3|0,M=st(7,0,b|0)|0,p=p&~(V()|0),b=st(m|0,0,b|0)|0,_=_&~M|b,p=p|(V()|0),(y|0)!=(c|0);)y=y+1|0;M=h,b=M,f[b>>2]=_,M=M+4|0,f[M>>2]=p}function K_(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0;if(y=Xe(h|0,c|0,52)|0,V()|0,y=y&15,p>>>0>15)return m=4,m|0;if((y|0)<(p|0))return m=12,m|0;if((y|0)==(p|0))return f[m>>2]=h,f[m+4>>2]=c,m=0,m|0;if(_=st(p|0,0,52)|0,_=_|h,h=V()|0|c&-15728641,(y|0)>(p|0))do c=st(7,0,(14-p|0)*3|0)|0,p=p+1|0,_=c|_,h=V()|0|h;while((p|0)<(y|0));return f[m>>2]=_,f[m+4>>2]=h,m=0,m|0}function sA(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0;if(y=Xe(h|0,c|0,52)|0,V()|0,y=y&15,!((p|0)<16&(y|0)<=(p|0)))return m=4,m|0;_=p-y|0,p=Xe(h|0,c|0,45)|0,V()|0;e:do if(!(pi(p&127)|0))p=vu(7,0,_,((_|0)<0)<<31>>31)|0,_=V()|0;else{t:do if(y|0){for(p=1;b=st(7,0,(15-p|0)*3|0)|0,!!((b&h|0)==0&((V()|0)&c|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=vu(7,0,_,((_|0)<0)<<31>>31)|0,_=V()|0;break e}while(!1);p=vu(7,0,_,((_|0)<0)<<31>>31)|0,p=qr(p|0,V()|0,5,0)|0,p=sn(p|0,V()|0,-5,-1)|0,p=yu(p|0,V()|0,6,0)|0,p=sn(p|0,V()|0,1,0)|0,_=V()|0}while(!1);return b=m,f[b>>2]=p,f[b+4>>2]=_,b=0,b|0}function Ni(h,c){h=h|0,c=c|0;var p=0,m=0,_=0;if(_=Xe(h|0,c|0,45)|0,V()|0,!(pi(_&127)|0))return _=0,_|0;_=Xe(h|0,c|0,52)|0,V()|0,_=_&15;e:do if(!_)p=0;else for(m=1;;){if(p=Xe(h|0,c|0,(15-m|0)*3|0)|0,V()|0,p=p&7,p|0)break e;if(m>>>0<_>>>0)m=m+1|0;else{p=0;break}}while(!1);return _=(p|0)==0&1,_|0}function gL(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0;if(b=z,z=z+16|0,y=b,i2(y,h,c,p),c=y,h=f[c>>2]|0,c=f[c+4>>2]|0,(h|0)==0&(c|0)==0)return z=b,0;_=0,p=0;do M=m+(_<<3)|0,f[M>>2]=h,f[M+4>>2]=c,_=sn(_|0,p|0,1,0)|0,p=V()|0,r2(y),M=y,h=f[M>>2]|0,c=f[M+4>>2]|0;while(!((h|0)==0&(c|0)==0));return z=b,0}function KS(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,(m|0)<(p|0)?(p=c,m=h,xe(p|0),m|0):(p=st(-1,-1,((m-p|0)*3|0)+3|0)|0,m=st(~p|0,~(V()|0)|0,(15-m|0)*3|0)|0,p=~(V()|0)&c,m=~m&h,xe(p|0),m|0)}function ZS(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0;return _=Xe(h|0,c|0,52)|0,V()|0,_=_&15,(p|0)<16&(_|0)<=(p|0)?((_|0)<(p|0)&&(_=st(-1,-1,((p+-1-_|0)*3|0)+3|0)|0,_=st(~_|0,~(V()|0)|0,(15-p|0)*3|0)|0,c=~(V()|0)&c,h=~_&h),_=st(p|0,0,52)|0,p=c&-15728641|(V()|0),f[m>>2]=h|_,f[m+4>>2]=p,m=0,m|0):(m=4,m|0)}function _L(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0,Jt=0,ot=0;if((p|0)==0&(m|0)==0)return ot=0,ot|0;if(_=h,y=f[_>>2]|0,_=f[_+4>>2]|0,!0&(_&15728640|0)==0){if(!((m|0)>0|(m|0)==0&p>>>0>0)||(ot=c,f[ot>>2]=y,f[ot+4>>2]=_,(p|0)==1&(m|0)==0))return ot=0,ot|0;_=1,y=0;do mn=h+(_<<3)|0,Jt=f[mn+4>>2]|0,ot=c+(_<<3)|0,f[ot>>2]=f[mn>>2],f[ot+4>>2]=Jt,_=sn(_|0,y|0,1,0)|0,y=V()|0;while((y|0)<(m|0)|(y|0)==(m|0)&_>>>0

>>0);return _=0,_|0}if(Gn=p<<3,Jt=Oa(Gn)|0,!Jt)return ot=13,ot|0;if(qh(Jt|0,h|0,Gn|0)|0,mn=Ks(p,8)|0,!mn)return on(Jt),ot=13,ot|0;e:for(;;){_=Jt,D=f[_>>2]|0,_=f[_+4>>2]|0,Mn=Xe(D|0,_|0,52)|0,V()|0,Mn=Mn&15,En=Mn+-1|0,Ft=(Mn|0)!=0,Zt=(m|0)>0|(m|0)==0&p>>>0>0;t:do if(Ft&Zt){if(Ee=st(En|0,0,52)|0,we=V()|0,En>>>0>15){if(!((D|0)==0&(_|0)==0)){ot=16;break e}for(y=0,h=0;;){if(y=sn(y|0,h|0,1,0)|0,h=V()|0,!((h|0)<(m|0)|(h|0)==(m|0)&y>>>0

>>0))break t;if(b=Jt+(y<<3)|0,lt=f[b>>2]|0,b=f[b+4>>2]|0,!((lt|0)==0&(b|0)==0)){_=b,ot=16;break e}}}for(M=D,h=_,y=0,b=0;;){if(!((M|0)==0&(h|0)==0)){if(!(!0&(h&117440512|0)==0)){ot=21;break e}if(k=Xe(M|0,h|0,52)|0,V()|0,k=k&15,(k|0)<(En|0)){_=12,ot=27;break e}if((k|0)!=(En|0)&&(M=M|Ee,h=h&-15728641|we,k>>>0>=Mn>>>0)){R=En;do lt=st(7,0,(14-R|0)*3|0)|0,R=R+1|0,M=lt|M,h=V()|0|h;while(R>>>0>>0)}if(re=Gh(M|0,h|0,p|0,m|0)|0,se=V()|0,R=mn+(re<<3)|0,k=R,X=f[k>>2]|0,k=f[k+4>>2]|0,!((X|0)==0&(k|0)==0)){be=0,Ne=0;do{if((be|0)>(m|0)|(be|0)==(m|0)&Ne>>>0>p>>>0){ot=31;break e}if((X|0)==(M|0)&(k&-117440513|0)==(h|0)){oe=Xe(X|0,k|0,56)|0,V()|0,oe=oe&7,Ae=oe+1|0,lt=Xe(X|0,k|0,45)|0,V()|0;n:do if(!(pi(lt&127)|0))k=7;else{if(X=Xe(X|0,k|0,52)|0,V()|0,X=X&15,!X){k=6;break}for(k=1;;){if(lt=st(7,0,(15-k|0)*3|0)|0,!((lt&M|0)==0&((V()|0)&h|0)==0)){k=7;break n}if(k>>>0>>0)k=k+1|0;else{k=6;break}}}while(!1);if((oe+2|0)>>>0>k>>>0){ot=41;break e}lt=st(Ae|0,0,56)|0,h=V()|0|h&-117440513,me=R,f[me>>2]=0,f[me+4>>2]=0,M=lt|M}else re=sn(re|0,se|0,1,0)|0,re=Vh(re|0,V()|0,p|0,m|0)|0,se=V()|0;Ne=sn(Ne|0,be|0,1,0)|0,be=V()|0,R=mn+(re<<3)|0,k=R,X=f[k>>2]|0,k=f[k+4>>2]|0}while(!((X|0)==0&(k|0)==0))}lt=R,f[lt>>2]=M,f[lt+4>>2]=h}if(y=sn(y|0,b|0,1,0)|0,b=V()|0,!((b|0)<(m|0)|(b|0)==(m|0)&y>>>0

>>0))break t;h=Jt+(y<<3)|0,M=f[h>>2]|0,h=f[h+4>>2]|0}}while(!1);if(lt=sn(p|0,m|0,5,0)|0,me=V()|0,me>>>0<0|(me|0)==0<>>>0<11){ot=85;break}if(lt=yu(p|0,m|0,6,0)|0,V()|0,lt=Ks(lt,8)|0,!lt){ot=48;break}do if(Zt){for(Ae=0,h=0,oe=0,be=0;;){if(k=mn+(Ae<<3)|0,b=k,y=f[b>>2]|0,b=f[b+4>>2]|0,(y|0)==0&(b|0)==0)me=oe;else{X=Xe(y|0,b|0,56)|0,V()|0,X=X&7,M=X+1|0,re=b&-117440513,me=Xe(y|0,b|0,45)|0,V()|0;t:do if(pi(me&127)|0){if(se=Xe(y|0,b|0,52)|0,V()|0,se=se&15,se|0)for(R=1;;){if(me=st(7,0,(15-R|0)*3|0)|0,!((y&me|0)==0&(re&(V()|0)|0)==0))break t;if(R>>>0>>0)R=R+1|0;else break}b=st(M|0,0,56)|0,y=b|y,b=V()|0|re,M=k,f[M>>2]=y,f[M+4>>2]=b,M=X+2|0}while(!1);(M|0)==7?(me=lt+(h<<3)|0,f[me>>2]=y,f[me+4>>2]=b&-117440513,h=sn(h|0,oe|0,1,0)|0,me=V()|0):me=oe}if(Ae=sn(Ae|0,be|0,1,0)|0,be=V()|0,(be|0)<(m|0)|(be|0)==(m|0)&Ae>>>0

>>0)oe=me;else break}if(Zt){if(Ne=En>>>0>15,Ee=st(En|0,0,52)|0,we=V()|0,!Ft){for(y=0,R=0,M=0,b=0;(D|0)==0&(_|0)==0||(En=c+(y<<3)|0,f[En>>2]=D,f[En+4>>2]=_,y=sn(y|0,R|0,1,0)|0,R=V()|0),M=sn(M|0,b|0,1,0)|0,b=V()|0,!!((b|0)<(m|0)|(b|0)==(m|0)&M>>>0

>>0);)_=Jt+(M<<3)|0,D=f[_>>2]|0,_=f[_+4>>2]|0;_=me;break}for(y=0,R=0,b=0,M=0;;){do if(!((D|0)==0&(_|0)==0)){if(se=Xe(D|0,_|0,52)|0,V()|0,se=se&15,Ne|(se|0)<(En|0)){ot=80;break e}if((se|0)!=(En|0)){if(k=D|Ee,X=_&-15728641|we,se>>>0>=Mn>>>0){re=En;do Ft=st(7,0,(14-re|0)*3|0)|0,re=re+1|0,k=Ft|k,X=V()|0|X;while(re>>>0>>0)}}else k=D,X=_;oe=Gh(k|0,X|0,p|0,m|0)|0,re=0,se=0,be=V()|0;do{if((re|0)>(m|0)|(re|0)==(m|0)&se>>>0>p>>>0){ot=81;break e}if(Ft=mn+(oe<<3)|0,Ae=f[Ft+4>>2]|0,(Ae&-117440513|0)==(X|0)&&(f[Ft>>2]|0)==(k|0)){ot=65;break}Ft=sn(oe|0,be|0,1,0)|0,oe=Vh(Ft|0,V()|0,p|0,m|0)|0,be=V()|0,se=sn(se|0,re|0,1,0)|0,re=V()|0,Ft=mn+(oe<<3)|0}while(!((f[Ft>>2]|0)==(k|0)&&(f[Ft+4>>2]|0)==(X|0)));if((ot|0)==65&&(ot=0,!0&(Ae&117440512|0)==100663296))break;Ft=c+(y<<3)|0,f[Ft>>2]=D,f[Ft+4>>2]=_,y=sn(y|0,R|0,1,0)|0,R=V()|0}while(!1);if(b=sn(b|0,M|0,1,0)|0,M=V()|0,!((M|0)<(m|0)|(M|0)==(m|0)&b>>>0

>>0))break;_=Jt+(b<<3)|0,D=f[_>>2]|0,_=f[_+4>>2]|0}_=me}else y=0,_=me}else y=0,h=0,_=0;while(!1);if(bu(mn|0,0,Gn|0)|0,qh(Jt|0,lt|0,h<<3|0)|0,on(lt),(h|0)==0&(_|0)==0){ot=89;break}else c=c+(y<<3)|0,m=_,p=h}if((ot|0)==16)!0&(_&117440512|0)==0?(_=4,ot=27):ot=21;else if((ot|0)==31)Fe(27795,27122,620,27132);else{if((ot|0)==41)return on(Jt),on(mn),ot=10,ot|0;if((ot|0)==48)return on(Jt),on(mn),ot=13,ot|0;(ot|0)==80?Fe(27795,27122,711,27132):(ot|0)==81?Fe(27795,27122,723,27132):(ot|0)==85&&(qh(c|0,Jt|0,p<<3|0)|0,ot=89)}return(ot|0)==21?(on(Jt),on(mn),ot=5,ot|0):(ot|0)==27?(on(Jt),on(mn),ot=_,ot|0):(ot|0)==89?(on(Jt),on(mn),ot=0,ot|0):0}function vL(h,c,p,m,_,y,b){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0,b=b|0;var M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0;if(Ae=z,z=z+16|0,oe=Ae,!((p|0)>0|(p|0)==0&c>>>0>0))return oe=0,z=Ae,oe|0;if((b|0)>=16)return oe=12,z=Ae,oe|0;re=0,se=0,X=0,M=0;e:for(;;){if(D=h+(re<<3)|0,R=f[D>>2]|0,D=f[D+4>>2]|0,k=Xe(R|0,D|0,52)|0,V()|0,(k&15|0)>(b|0)){M=12,R=11;break}if(i2(oe,R,D,b),k=oe,D=f[k>>2]|0,k=f[k+4>>2]|0,(D|0)==0&(k|0)==0)R=X;else{R=X;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){R=10;break e}X=m+(R<<3)|0,f[X>>2]=D,f[X+4>>2]=k,R=sn(R|0,M|0,1,0)|0,M=V()|0,r2(oe),X=oe,D=f[X>>2]|0,k=f[X+4>>2]|0}while(!((D|0)==0&(k|0)==0))}if(re=sn(re|0,se|0,1,0)|0,se=V()|0,(se|0)<(p|0)|(se|0)==(p|0)&re>>>0>>0)X=R;else{M=0,R=11;break}}return(R|0)==10?(oe=14,z=Ae,oe|0):(R|0)==11?(z=Ae,M|0):0}function xL(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;re=z,z=z+16|0,X=re;e:do if((p|0)>0|(p|0)==0&c>>>0>0){for(D=0,b=0,y=0,k=0;;){if(R=h+(D<<3)|0,M=f[R>>2]|0,R=f[R+4>>2]|0,!((M|0)==0&(R|0)==0)&&(R=(sA(M,R,m,X)|0)==0,M=X,b=sn(f[M>>2]|0,f[M+4>>2]|0,b|0,y|0)|0,y=V()|0,!R)){y=12;break}if(D=sn(D|0,k|0,1,0)|0,k=V()|0,!((k|0)<(p|0)|(k|0)==(p|0)&D>>>0>>0))break e}return z=re,y|0}else b=0,y=0;while(!1);return f[_>>2]=b,f[_+4>>2]=y,_=0,z=re,_|0}function yL(h,c){return h=h|0,c=c|0,c=Xe(h|0,c|0,52)|0,V()|0,c&1|0}function Ys(h,c){h=h|0,c=c|0;var p=0,m=0,_=0;if(_=Xe(h|0,c|0,52)|0,V()|0,_=_&15,!_)return _=0,_|0;for(m=1;;){if(p=Xe(h|0,c|0,(15-m|0)*3|0)|0,V()|0,p=p&7,p|0){m=5;break}if(m>>>0<_>>>0)m=m+1|0;else{p=0,m=5;break}}return(m|0)==5?p|0:0}function Z_(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0;if(R=Xe(h|0,c|0,52)|0,V()|0,R=R&15,!R)return M=c,R=h,xe(M|0),R|0;for(M=1,p=0;;){y=(15-M|0)*3|0,m=st(7,0,y|0)|0,_=V()|0,b=Xe(h|0,c|0,y|0)|0,V()|0,y=st(Sc(b&7)|0,0,y|0)|0,b=V()|0,h=y|h&~m,c=b|c&~_;e:do if(!p)if((y&m|0)==0&(b&_|0)==0)p=0;else if(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,!m)p=1;else{p=1;t:for(;;){switch(b=Xe(h|0,c|0,(15-p|0)*3|0)|0,V()|0,b&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(b=(15-p|0)*3|0,_=Xe(h|0,c|0,b|0)|0,V()|0,y=st(7,0,b|0)|0,c=c&~(V()|0),b=st(Sc(_&7)|0,0,b|0)|0,h=h&~y|b,c=c|(V()|0),p>>>0>>0)p=p+1|0;else{p=1;break}}while(!1);if(M>>>0>>0)M=M+1|0;else break}return xe(c|0),h|0}function Tc(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0;if(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,!m)return p=c,m=h,xe(p|0),m|0;for(p=1;y=(15-p|0)*3|0,b=Xe(h|0,c|0,y|0)|0,V()|0,_=st(7,0,y|0)|0,c=c&~(V()|0),y=st(Sc(b&7)|0,0,y|0)|0,h=y|h&~_,c=V()|0|c,p>>>0>>0;)p=p+1|0;return xe(c|0),h|0}function bL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0;if(R=Xe(h|0,c|0,52)|0,V()|0,R=R&15,!R)return M=c,R=h,xe(M|0),R|0;for(M=1,p=0;;){y=(15-M|0)*3|0,m=st(7,0,y|0)|0,_=V()|0,b=Xe(h|0,c|0,y|0)|0,V()|0,y=st(_u(b&7)|0,0,y|0)|0,b=V()|0,h=y|h&~m,c=b|c&~_;e:do if(!p)if((y&m|0)==0&(b&_|0)==0)p=0;else if(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,!m)p=1;else{p=1;t:for(;;){switch(b=Xe(h|0,c|0,(15-p|0)*3|0)|0,V()|0,b&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(_=(15-p|0)*3|0,y=st(7,0,_|0)|0,b=c&~(V()|0),c=Xe(h|0,c|0,_|0)|0,V()|0,c=st(_u(c&7)|0,0,_|0)|0,h=h&~y|c,c=b|(V()|0),p>>>0>>0)p=p+1|0;else{p=1;break}}while(!1);if(M>>>0>>0)M=M+1|0;else break}return xe(c|0),h|0}function J_(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0;if(m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,!m)return p=c,m=h,xe(p|0),m|0;for(p=1;b=(15-p|0)*3|0,y=st(7,0,b|0)|0,_=c&~(V()|0),c=Xe(h|0,c|0,b|0)|0,V()|0,c=st(_u(c&7)|0,0,b|0)|0,h=c|h&~y,c=V()|0|_,p>>>0>>0;)p=p+1|0;return xe(c|0),h|0}function SL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(R=z,z=z+64|0,M=R+40|0,m=R+24|0,_=R+12|0,y=R,st(c|0,0,52)|0,p=V()|0|134225919,!c)return(f[h+4>>2]|0)>2||(f[h+8>>2]|0)>2||(f[h+12>>2]|0)>2?(b=0,M=0,xe(b|0),z=R,M|0):(st(gc(h)|0,0,45)|0,b=V()|0|p,M=-1,xe(b|0),z=R,M|0);if(f[M>>2]=f[h>>2],f[M+4>>2]=f[h+4>>2],f[M+8>>2]=f[h+8>>2],f[M+12>>2]=f[h+12>>2],b=M+4|0,(c|0)>0)for(h=-1;f[m>>2]=f[b>>2],f[m+4>>2]=f[b+4>>2],f[m+8>>2]=f[b+8>>2],c&1?(ZD(b),f[_>>2]=f[b>>2],f[_+4>>2]=f[b+4>>2],f[_+8>>2]=f[b+8>>2],Ip(_)):(GS(b),f[_>>2]=f[b>>2],f[_+4>>2]=f[b+4>>2],f[_+8>>2]=f[b+8>>2],bc(_)),W_(m,_,y),ii(y),k=(15-c|0)*3|0,D=st(7,0,k|0)|0,p=p&~(V()|0),k=st(Lp(y)|0,0,k|0)|0,h=k|h&~D,p=V()|0|p,(c|0)>1;)c=c+-1|0;else h=-1;e:do if((f[b>>2]|0)<=2&&(f[M+8>>2]|0)<=2&&(f[M+12>>2]|0)<=2){if(m=gc(M)|0,c=st(m|0,0,45)|0,c=c|h,h=V()|0|p&-1040385,y=nA(M)|0,!(pi(m)|0)){if((y|0)<=0)break;for(_=0;;){if(m=Xe(c|0,h|0,52)|0,V()|0,m=m&15,m)for(p=1;k=(15-p|0)*3|0,M=Xe(c|0,h|0,k|0)|0,V()|0,D=st(7,0,k|0)|0,h=h&~(V()|0),k=st(Sc(M&7)|0,0,k|0)|0,c=c&~D|k,h=h|(V()|0),p>>>0>>0;)p=p+1|0;if(_=_+1|0,(_|0)==(y|0))break e}}_=Xe(c|0,h|0,52)|0,V()|0,_=_&15;t:do if(_){p=1;n:for(;;){switch(k=Xe(c|0,h|0,(15-p|0)*3|0)|0,V()|0,k&7){case 1:break n;case 0:break;default:break t}if(p>>>0<_>>>0)p=p+1|0;else break t}if(vc(m,f[M>>2]|0)|0)for(p=1;M=(15-p|0)*3|0,D=st(7,0,M|0)|0,k=h&~(V()|0),h=Xe(c|0,h|0,M|0)|0,V()|0,h=st(_u(h&7)|0,0,M|0)|0,c=c&~D|h,h=k|(V()|0),p>>>0<_>>>0;)p=p+1|0;else for(p=1;k=(15-p|0)*3|0,M=Xe(c|0,h|0,k|0)|0,V()|0,D=st(7,0,k|0)|0,h=h&~(V()|0),k=st(Sc(M&7)|0,0,k|0)|0,c=c&~D|k,h=h|(V()|0),p>>>0<_>>>0;)p=p+1|0}while(!1);if((y|0)>0){p=0;do c=Z_(c,h)|0,h=V()|0,p=p+1|0;while((p|0)!=(y|0))}}else c=0,h=0;while(!1);return D=h,k=c,xe(D|0),z=R,k|0}function Fo(h){return h=h|0,(h|0)%2|0|0}function e2(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0;return _=z,z=z+16|0,m=_,c>>>0>15?(m=4,z=_,m|0):(f[h+4>>2]&2146435072|0)==2146435072||(f[h+8+4>>2]&2146435072|0)==2146435072?(m=3,z=_,m|0):(lL(h,c,m),c=SL(m,c)|0,m=V()|0,f[p>>2]=c,f[p+4>>2]=m,(c|0)==0&(m|0)==0&&Fe(27795,27122,1050,27145),m=0,z=_,m|0)}function t2(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;if(_=p+4|0,y=Xe(h|0,c|0,52)|0,V()|0,y=y&15,b=Xe(h|0,c|0,45)|0,V()|0,m=(y|0)==0,pi(b&127)|0){if(m)return b=1,b|0;m=1}else{if(m)return b=0,b|0;!(f[_>>2]|0)&&!(f[p+8>>2]|0)?m=(f[p+12>>2]|0)!=0&1:m=1}for(p=1;p&1?Ip(_):bc(_),b=Xe(h|0,c|0,(15-p|0)*3|0)|0,V()|0,qS(_,b&7),p>>>0>>0;)p=p+1|0;return m|0}function Fh(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(k=z,z=z+16|0,R=k,D=Xe(h|0,c|0,45)|0,V()|0,D=D&127,D>>>0>121)return f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,f[p+12>>2]=0,D=5,z=k,D|0;e:do if(pi(D)|0&&(y=Xe(h|0,c|0,52)|0,V()|0,y=y&15,(y|0)!=0)){m=1;t:for(;;){switch(M=Xe(h|0,c|0,(15-m|0)*3|0)|0,V()|0,M&7){case 5:break t;case 0:break;default:{m=c;break e}}if(m>>>0>>0)m=m+1|0;else{m=c;break e}}for(_=1,m=c;c=(15-_|0)*3|0,b=st(7,0,c|0)|0,M=m&~(V()|0),m=Xe(h|0,m|0,c|0)|0,V()|0,m=st(_u(m&7)|0,0,c|0)|0,h=h&~b|m,m=M|(V()|0),_>>>0>>0;)_=_+1|0}else m=c;while(!1);if(M=7696+(D*28|0)|0,f[p>>2]=f[M>>2],f[p+4>>2]=f[M+4>>2],f[p+8>>2]=f[M+8>>2],f[p+12>>2]=f[M+12>>2],!(t2(h,m,p)|0))return D=0,z=k,D|0;if(b=p+4|0,f[R>>2]=f[b>>2],f[R+4>>2]=f[b+4>>2],f[R+8>>2]=f[b+8>>2],y=Xe(h|0,m|0,52)|0,V()|0,M=y&15,y&1?(bc(b),y=M+1|0):y=M,!(pi(D)|0))m=0;else{e:do if(!M)m=0;else for(c=1;;){if(_=Xe(h|0,m|0,(15-c|0)*3|0)|0,V()|0,_=_&7,_|0){m=_;break e}if(c>>>0>>0)c=c+1|0;else{m=0;break}}while(!1);m=(m|0)==4&1}if(!(Uh(p,y,m,0)|0))(y|0)!=(M|0)&&(f[b>>2]=f[R>>2],f[b+4>>2]=f[R+4>>2],f[b+8>>2]=f[R+8>>2]);else{if(pi(D)|0)do;while(Uh(p,y,0,0)|0);(y|0)!=(M|0)&&GS(b)}return D=0,z=k,D|0}function wc(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;return y=z,z=z+16|0,m=y,_=Fh(h,c,m)|0,_|0?(z=y,_|0):(_=Xe(h|0,c|0,52)|0,V()|0,hL(m,_&15,p),_=0,z=y,_|0)}function Oh(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0;if(b=z,z=z+16|0,y=b,m=Fh(h,c,y)|0,m|0)return y=m,z=b,y|0;m=Xe(h|0,c|0,45)|0,V()|0,m=(pi(m&127)|0)==0,_=Xe(h|0,c|0,52)|0,V()|0,_=_&15;e:do if(!m){if(_|0)for(m=1;;){if(M=st(7,0,(15-m|0)*3|0)|0,!((M&h|0)==0&((V()|0)&c|0)==0))break e;if(m>>>0<_>>>0)m=m+1|0;else break}return j_(y,_,0,5,p),M=0,z=b,M|0}while(!1);return X_(y,_,0,6,p),M=0,z=b,M|0}function TL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;if(_=Xe(h|0,c|0,45)|0,V()|0,!(pi(_&127)|0))return _=2,f[p>>2]=_,0;if(_=Xe(h|0,c|0,52)|0,V()|0,_=_&15,!_)return _=5,f[p>>2]=_,0;for(m=1;;){if(y=st(7,0,(15-m|0)*3|0)|0,!((y&h|0)==0&((V()|0)&c|0)==0)){m=2,h=6;break}if(m>>>0<_>>>0)m=m+1|0;else{m=5,h=6;break}}return(h|0)==6&&(f[p>>2]=m),0}function JS(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0;X=z,z=z+128|0,D=X+112|0,y=X+96|0,k=X,_=Xe(h|0,c|0,52)|0,V()|0,M=_&15,f[D>>2]=M,b=Xe(h|0,c|0,45)|0,V()|0,b=b&127;e:do if(pi(b)|0){if(M|0)for(m=1;;){if(R=st(7,0,(15-m|0)*3|0)|0,!((R&h|0)==0&((V()|0)&c|0)==0)){_=0;break e}if(m>>>0>>0)m=m+1|0;else break}if(_&1)_=1;else return R=st(M+1|0,0,52)|0,k=V()|0|c&-15728641,D=st(7,0,(14-M|0)*3|0)|0,k=JS((R|h)&~D,k&~(V()|0),p)|0,z=X,k|0}else _=0;while(!1);if(m=Fh(h,c,y)|0,!m){_?(XS(y,D,k),R=5):(QS(y,D,k),R=6);e:do if(pi(b)|0)if(!M)h=5;else for(m=1;;){if(b=st(7,0,(15-m|0)*3|0)|0,!((b&h|0)==0&((V()|0)&c|0)==0)){h=2;break e}if(m>>>0>>0)m=m+1|0;else{h=5;break}}else h=2;while(!1);bu(p|0,-1,h<<2|0)|0;e:do if(_)for(y=0;;){if(b=k+(y<<4)|0,fL(b,f[D>>2]|0)|0,b=f[b>>2]|0,M=f[p>>2]|0,(M|0)==-1|(M|0)==(b|0))m=p;else{_=0;do{if(_=_+1|0,_>>>0>=h>>>0){m=1;break e}m=p+(_<<2)|0,M=f[m>>2]|0}while(!((M|0)==-1|(M|0)==(b|0)))}if(f[m>>2]=b,y=y+1|0,y>>>0>=R>>>0){m=0;break}}else for(y=0;;){if(b=k+(y<<4)|0,Uh(b,f[D>>2]|0,0,1)|0,b=f[b>>2]|0,M=f[p>>2]|0,(M|0)==-1|(M|0)==(b|0))m=p;else{_=0;do{if(_=_+1|0,_>>>0>=h>>>0){m=1;break e}m=p+(_<<2)|0,M=f[m>>2]|0}while(!((M|0)==-1|(M|0)==(b|0)))}if(f[m>>2]=b,y=y+1|0,y>>>0>=R>>>0){m=0;break}}while(!1)}return k=m,z=X,k|0}function wL(){return 12}function n2(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0;if(h>>>0>15)return M=4,M|0;if(st(h|0,0,52)|0,M=V()|0|134225919,!h){p=0,m=0;do pi(m)|0&&(st(m|0,0,45)|0,b=M|(V()|0),h=c+(p<<3)|0,f[h>>2]=-1,f[h+4>>2]=b,p=p+1|0),m=m+1|0;while((m|0)!=122);return p=0,p|0}p=0,b=0;do{if(pi(b)|0){for(st(b|0,0,45)|0,m=1,_=-1,y=M|(V()|0);R=st(7,0,(15-m|0)*3|0)|0,_=_&~R,y=y&~(V()|0),(m|0)!=(h|0);)m=m+1|0;R=c+(p<<3)|0,f[R>>2]=_,f[R+4>>2]=y,p=p+1|0}b=b+1|0}while((b|0)!=122);return p=0,p|0}function ML(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0;if(Ee=z,z=z+16|0,be=Ee,Ne=Xe(h|0,c|0,52)|0,V()|0,Ne=Ne&15,p>>>0>15)return Ne=4,z=Ee,Ne|0;if((Ne|0)<(p|0))return Ne=12,z=Ee,Ne|0;if((Ne|0)!=(p|0))if(y=st(p|0,0,52)|0,y=y|h,M=V()|0|c&-15728641,(Ne|0)>(p|0)){R=p;do Ae=st(7,0,(14-R|0)*3|0)|0,R=R+1|0,y=Ae|y,M=V()|0|M;while((R|0)<(Ne|0));Ae=y}else Ae=y;else Ae=h,M=c;oe=Xe(Ae|0,M|0,45)|0,V()|0;e:do if(pi(oe&127)|0){if(R=Xe(Ae|0,M|0,52)|0,V()|0,R=R&15,R|0)for(y=1;;){if(oe=st(7,0,(15-y|0)*3|0)|0,!((oe&Ae|0)==0&((V()|0)&M|0)==0)){D=33;break e}if(y>>>0>>0)y=y+1|0;else break}if(oe=m,f[oe>>2]=0,f[oe+4>>2]=0,(Ne|0)>(p|0)){for(oe=c&-15728641,se=Ne;;){if(re=se,se=se+-1|0,se>>>0>15|(Ne|0)<(se|0)){D=19;break}if((Ne|0)!=(se|0))if(y=st(se|0,0,52)|0,y=y|h,R=V()|0|oe,(Ne|0)<(re|0))X=y;else{D=se;do X=st(7,0,(14-D|0)*3|0)|0,D=D+1|0,y=X|y,R=V()|0|R;while((D|0)<(Ne|0));X=y}else X=h,R=c;if(k=Xe(X|0,R|0,45)|0,V()|0,!(pi(k&127)|0))y=0;else{k=Xe(X|0,R|0,52)|0,V()|0,k=k&15;t:do if(!k)y=0;else for(D=1;;){if(y=Xe(X|0,R|0,(15-D|0)*3|0)|0,V()|0,y=y&7,y|0)break t;if(D>>>0>>0)D=D+1|0;else{y=0;break}}while(!1);y=(y|0)==0&1}if(R=Xe(h|0,c|0,(15-re|0)*3|0)|0,V()|0,R=R&7,(R|0)==7){_=5,D=42;break}if(y=(y|0)!=0,(R|0)==1&y){_=5,D=42;break}if(X=R+(((R|0)!=0&y)<<31>>31)|0,X|0&&(D=Ne-re|0,D=vu(7,0,D,((D|0)<0)<<31>>31)|0,k=V()|0,y?(y=qr(D|0,k|0,5,0)|0,y=sn(y|0,V()|0,-5,-1)|0,y=yu(y|0,V()|0,6,0)|0,y=sn(y|0,V()|0,1,0)|0,R=V()|0):(y=D,R=k),re=X+-1|0,re=qr(D|0,k|0,re|0,((re|0)<0)<<31>>31|0)|0,re=sn(y|0,R|0,re|0,V()|0)|0,X=V()|0,k=m,k=sn(re|0,X|0,f[k>>2]|0,f[k+4>>2]|0)|0,X=V()|0,re=m,f[re>>2]=k,f[re+4>>2]=X),(se|0)<=(p|0)){D=37;break}}if((D|0)==19)Fe(27795,27122,1367,27158);else if((D|0)==37){b=m,_=f[b+4>>2]|0,b=f[b>>2]|0;break}else if((D|0)==42)return z=Ee,_|0}else _=0,b=0}else D=33;while(!1);e:do if((D|0)==33)if(oe=m,f[oe>>2]=0,f[oe+4>>2]=0,(Ne|0)>(p|0)){for(y=Ne;;){if(_=Xe(h|0,c|0,(15-y|0)*3|0)|0,V()|0,_=_&7,(_|0)==7){_=5;break}if(b=Ne-y|0,b=vu(7,0,b,((b|0)<0)<<31>>31)|0,_=qr(b|0,V()|0,_|0,0)|0,b=V()|0,oe=m,b=sn(f[oe>>2]|0,f[oe+4>>2]|0,_|0,b|0)|0,_=V()|0,oe=m,f[oe>>2]=b,f[oe+4>>2]=_,y=y+-1|0,(y|0)<=(p|0))break e}return z=Ee,_|0}else _=0,b=0;while(!1);return sA(Ae,M,Ne,be)|0&&Fe(27795,27122,1327,27173),Ne=be,be=f[Ne+4>>2]|0,((_|0)>-1|(_|0)==-1&b>>>0>4294967295)&((be|0)>(_|0)|((be|0)==(_|0)?(f[Ne>>2]|0)>>>0>b>>>0:0))?(Ne=0,z=Ee,Ne|0):(Fe(27795,27122,1407,27158),0)}function EL(h,c,p,m,_,y){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0;var b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0;if(X=z,z=z+16|0,b=X,_>>>0>15)return y=4,z=X,y|0;if(M=Xe(p|0,m|0,52)|0,V()|0,M=M&15,(M|0)>(_|0))return y=12,z=X,y|0;if(sA(p,m,_,b)|0&&Fe(27795,27122,1327,27173),k=b,D=f[k+4>>2]|0,!(((c|0)>-1|(c|0)==-1&h>>>0>4294967295)&((D|0)>(c|0)|((D|0)==(c|0)?(f[k>>2]|0)>>>0>h>>>0:0))))return y=2,z=X,y|0;k=_-M|0,_=st(_|0,0,52)|0,R=V()|0|m&-15728641,D=y,f[D>>2]=_|p,f[D+4>>2]=R,D=Xe(p|0,m|0,45)|0,V()|0;e:do if(pi(D&127)|0){if(M|0)for(b=1;;){if(D=st(7,0,(15-b|0)*3|0)|0,!((D&p|0)==0&((V()|0)&m|0)==0))break e;if(b>>>0>>0)b=b+1|0;else break}if((k|0)<1)return y=0,z=X,y|0;for(D=M^15,m=-1,R=1,b=1;;){M=k-R|0,M=vu(7,0,M,((M|0)<0)<<31>>31)|0,p=V()|0;do if(b)if(b=qr(M|0,p|0,5,0)|0,b=sn(b|0,V()|0,-5,-1)|0,b=yu(b|0,V()|0,6,0)|0,_=V()|0,(c|0)>(_|0)|(c|0)==(_|0)&h>>>0>b>>>0){c=sn(h|0,c|0,-1,-1)|0,c=Gr(c|0,V()|0,b|0,_|0)|0,b=V()|0,re=y,oe=f[re>>2]|0,re=f[re+4>>2]|0,Ae=(D+m|0)*3|0,se=st(7,0,Ae|0)|0,re=re&~(V()|0),m=yu(c|0,b|0,M|0,p|0)|0,h=V()|0,_=sn(m|0,h|0,2,0)|0,Ae=st(_|0,V()|0,Ae|0)|0,re=V()|0|re,_=y,f[_>>2]=Ae|oe&~se,f[_+4>>2]=re,h=qr(m|0,h|0,M|0,p|0)|0,h=Gr(c|0,b|0,h|0,V()|0)|0,b=0,c=V()|0;break}else{Ae=y,se=f[Ae>>2]|0,Ae=f[Ae+4>>2]|0,oe=st(7,0,(D+m|0)*3|0)|0,Ae=Ae&~(V()|0),b=y,f[b>>2]=se&~oe,f[b+4>>2]=Ae,b=1;break}else se=y,_=f[se>>2]|0,se=f[se+4>>2]|0,m=(D+m|0)*3|0,re=st(7,0,m|0)|0,se=se&~(V()|0),Ae=yu(h|0,c|0,M|0,p|0)|0,b=V()|0,m=st(Ae|0,b|0,m|0)|0,se=V()|0|se,oe=y,f[oe>>2]=m|_&~re,f[oe+4>>2]=se,b=qr(Ae|0,b|0,M|0,p|0)|0,h=Gr(h|0,c|0,b|0,V()|0)|0,b=0,c=V()|0;while(!1);if((k|0)>(R|0))m=~R,R=R+1|0;else{c=0;break}}return z=X,c|0}while(!1);if((k|0)<1)return Ae=0,z=X,Ae|0;for(_=M^15,b=1;;)if(oe=k-b|0,oe=vu(7,0,oe,((oe|0)<0)<<31>>31)|0,Ae=V()|0,R=y,p=f[R>>2]|0,R=f[R+4>>2]|0,M=(_-b|0)*3|0,m=st(7,0,M|0)|0,R=R&~(V()|0),re=yu(h|0,c|0,oe|0,Ae|0)|0,se=V()|0,M=st(re|0,se|0,M|0)|0,R=V()|0|R,D=y,f[D>>2]=M|p&~m,f[D+4>>2]=R,Ae=qr(re|0,se|0,oe|0,Ae|0)|0,h=Gr(h|0,c|0,Ae|0,V()|0)|0,c=V()|0,(k|0)<=(b|0)){c=0;break}else b=b+1|0;return z=X,c|0}function i2(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0;_=Xe(c|0,p|0,52)|0,V()|0,_=_&15,(c|0)==0&(p|0)==0|((m|0)>15|(_|0)>(m|0))?(y=-1,c=-1,p=0,_=0):(c=KS(c,p,_+1|0,m)|0,b=(V()|0)&-15728641,p=st(m|0,0,52)|0,p=c|p,b=b|(V()|0),c=(Ni(p,b)|0)==0,y=_,c=c?-1:m,_=b),b=h,f[b>>2]=p,f[b+4>>2]=_,f[h+8>>2]=y,f[h+12>>2]=c}function eT(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0;if(_=Xe(h|0,c|0,52)|0,V()|0,_=_&15,y=m+8|0,f[y>>2]=_,(h|0)==0&(c|0)==0|((p|0)>15|(_|0)>(p|0))){p=m,f[p>>2]=0,f[p+4>>2]=0,f[y>>2]=-1,f[m+12>>2]=-1;return}if(h=KS(h,c,_+1|0,p)|0,y=(V()|0)&-15728641,_=st(p|0,0,52)|0,_=h|_,y=y|(V()|0),h=m,f[h>>2]=_,f[h+4>>2]=y,h=m+12|0,Ni(_,y)|0){f[h>>2]=p;return}else{f[h>>2]=-1;return}}function r2(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0;if(p=h,c=f[p>>2]|0,p=f[p+4>>2]|0,!((c|0)==0&(p|0)==0)&&(m=Xe(c|0,p|0,52)|0,V()|0,m=m&15,M=st(1,0,(m^15)*3|0)|0,c=sn(M|0,V()|0,c|0,p|0)|0,p=V()|0,M=h,f[M>>2]=c,f[M+4>>2]=p,M=h+8|0,b=f[M>>2]|0,!((m|0)<(b|0)))){for(R=h+12|0,y=m;;){if((y|0)==(b|0)){m=5;break}if(D=(y|0)==(f[R>>2]|0),_=(15-y|0)*3|0,m=Xe(c|0,p|0,_|0)|0,V()|0,m=m&7,D&((m|0)==1&!0)){m=7;break}if(!((m|0)==7&!0)){m=10;break}if(D=st(1,0,_|0)|0,c=sn(c|0,p|0,D|0,V()|0)|0,p=V()|0,D=h,f[D>>2]=c,f[D+4>>2]=p,(y|0)>(b|0))y=y+-1|0;else{m=10;break}}if((m|0)==5){D=h,f[D>>2]=0,f[D+4>>2]=0,f[M>>2]=-1,f[R>>2]=-1;return}else if((m|0)==7){b=st(1,0,_|0)|0,b=sn(c|0,p|0,b|0,V()|0)|0,M=V()|0,D=h,f[D>>2]=b,f[D+4>>2]=M,f[R>>2]=y+-1;return}else if((m|0)==10)return}}function oA(h){h=+h;var c=0;return c=h<0?h+6.283185307179586:h,+(h>=6.283185307179586?c+-6.283185307179586:c)}function kh(h,c){return h=h|0,c=c|0,+bn(+(+W[h>>3]-+W[c>>3]))<17453292519943298e-27?(c=+bn(+(+W[h+8>>3]-+W[c+8>>3]))<17453292519943298e-27,c|0):(c=0,c|0)}function _o(h,c){switch(h=+h,c=c|0,c|0){case 1:{h=h<0?h+6.283185307179586:h;break}case 2:{h=h>0?h+-6.283185307179586:h;break}}return+h}function CL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;return _=+W[c>>3],m=+W[h>>3],y=+_n(+((_-m)*.5)),p=+_n(+((+W[c+8>>3]-+W[h+8>>3])*.5)),p=y*y+p*(+kn(+_)*+kn(+m)*p),+(+Zr(+ +Pn(+p),+ +Pn(+(1-p)))*2)}function aA(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;return _=+W[c>>3],m=+W[h>>3],y=+_n(+((_-m)*.5)),p=+_n(+((+W[c+8>>3]-+W[h+8>>3])*.5)),p=y*y+p*(+kn(+_)*+kn(+m)*p),+(+Zr(+ +Pn(+p),+ +Pn(+(1-p)))*2*6371.007180918475)}function RL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;return _=+W[c>>3],m=+W[h>>3],y=+_n(+((_-m)*.5)),p=+_n(+((+W[c+8>>3]-+W[h+8>>3])*.5)),p=y*y+p*(+kn(+_)*+kn(+m)*p),+(+Zr(+ +Pn(+p),+ +Pn(+(1-p)))*2*6371.007180918475*1e3)}function NL(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0;return y=+W[c>>3],m=+kn(+y),_=+W[c+8>>3]-+W[h+8>>3],b=m*+_n(+_),p=+W[h>>3],+ +Zr(+b,+(+_n(+y)*+kn(+p)-+kn(+_)*(m*+_n(+p))))}function PL(h,c,p,m){h=h|0,c=+c,p=+p,m=m|0;var _=0,y=0,b=0,M=0;if(p<1e-16){f[m>>2]=f[h>>2],f[m+4>>2]=f[h+4>>2],f[m+8>>2]=f[h+8>>2],f[m+12>>2]=f[h+12>>2];return}y=c<0?c+6.283185307179586:c,y=c>=6.283185307179586?y+-6.283185307179586:y;do if(y<1e-16)c=+W[h>>3]+p,W[m>>3]=c,_=m;else{if(_=+bn(+(y+-3.141592653589793))<1e-16,c=+W[h>>3],_){c=c-p,W[m>>3]=c,_=m;break}if(b=+kn(+p),p=+_n(+p),c=b*+_n(+c)+ +kn(+y)*(p*+kn(+c)),c=c>1?1:c,c=+Cl(+(c<-1?-1:c)),W[m>>3]=c,+bn(+(c+-1.5707963267948966))<1e-16){W[m>>3]=1.5707963267948966,W[m+8>>3]=0;return}if(+bn(+(c+1.5707963267948966))<1e-16){W[m>>3]=-1.5707963267948966,W[m+8>>3]=0;return}if(M=1/+kn(+c),y=p*+_n(+y)*M,p=+W[h>>3],c=M*((b-+_n(+c)*+_n(+p))/+kn(+p)),b=y>1?1:y,c=c>1?1:c,c=+W[h+8>>3]+ +Zr(+(b<-1?-1:b),+(c<-1?-1:c)),c>3.141592653589793)do c=c+-6.283185307179586;while(c>3.141592653589793);if(c<-3.141592653589793)do c=c+6.283185307179586;while(c<-3.141592653589793);W[m+8>>3]=c;return}while(!1);if(+bn(+(c+-1.5707963267948966))<1e-16){W[_>>3]=1.5707963267948966,W[m+8>>3]=0;return}if(+bn(+(c+1.5707963267948966))<1e-16){W[_>>3]=-1.5707963267948966,W[m+8>>3]=0;return}if(c=+W[h+8>>3],c>3.141592653589793)do c=c+-6.283185307179586;while(c>3.141592653589793);if(c<-3.141592653589793)do c=c+6.283185307179586;while(c<-3.141592653589793);W[m+8>>3]=c}function tT(h,c){return h=h|0,c=c|0,h>>>0>15?(c=4,c|0):(W[c>>3]=+W[20656+(h<<3)>>3],c=0,c|0)}function DL(h,c){return h=h|0,c=c|0,h>>>0>15?(c=4,c|0):(W[c>>3]=+W[20784+(h<<3)>>3],c=0,c|0)}function LL(h,c){return h=h|0,c=c|0,h>>>0>15?(c=4,c|0):(W[c>>3]=+W[20912+(h<<3)>>3],c=0,c|0)}function IL(h,c){return h=h|0,c=c|0,h>>>0>15?(c=4,c|0):(W[c>>3]=+W[21040+(h<<3)>>3],c=0,c|0)}function Fp(h,c){h=h|0,c=c|0;var p=0;return h>>>0>15?(c=4,c|0):(p=vu(7,0,h,((h|0)<0)<<31>>31)|0,p=qr(p|0,V()|0,120,0)|0,h=V()|0,f[c>>2]=p|2,f[c+4>>2]=h,c=0,c|0)}function nT(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;return re=+W[c>>3],k=+W[h>>3],R=+_n(+((re-k)*.5)),y=+W[c+8>>3],D=+W[h+8>>3],b=+_n(+((y-D)*.5)),M=+kn(+k),X=+kn(+re),b=R*R+b*(X*M*b),b=+Zr(+ +Pn(+b),+ +Pn(+(1-b)))*2,R=+W[p>>3],re=+_n(+((R-re)*.5)),m=+W[p+8>>3],y=+_n(+((m-y)*.5)),_=+kn(+R),y=re*re+y*(X*_*y),y=+Zr(+ +Pn(+y),+ +Pn(+(1-y)))*2,R=+_n(+((k-R)*.5)),m=+_n(+((D-m)*.5)),m=R*R+m*(M*_*m),m=+Zr(+ +Pn(+m),+ +Pn(+(1-m)))*2,_=(b+y+m)*.5,+(+Ba(+ +Pn(+(+Br(+(_*.5))*+Br(+((_-b)*.5))*+Br(+((_-y)*.5))*+Br(+((_-m)*.5)))))*4)}function s2(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0;if(M=z,z=z+192|0,y=M+168|0,b=M,_=wc(h,c,y)|0,_|0)return p=_,z=M,p|0;if(Oh(h,c,b)|0&&Fe(27795,27190,415,27199),c=f[b>>2]|0,(c|0)>0){if(m=+nT(b+8|0,b+8+(((c|0)!=1&1)<<4)|0,y)+0,(c|0)!=1){h=1;do _=h,h=h+1|0,m=m+ +nT(b+8+(_<<4)|0,b+8+(((h|0)%(c|0)|0)<<4)|0,y);while((h|0)<(c|0))}}else m=0;return W[p>>3]=m,p=0,z=M,p|0}function BL(h,c,p){return h=h|0,c=c|0,p=p|0,h=s2(h,c,p)|0,h|0||(W[p>>3]=+W[p>>3]*6371.007180918475*6371.007180918475),h|0}function UL(h,c,p){return h=h|0,c=c|0,p=p|0,h=s2(h,c,p)|0,h|0||(W[p>>3]=+W[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),h|0}function FL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(M=z,z=z+176|0,b=M,h=Up(h,c,b)|0,h|0)return b=h,z=M,b|0;if(W[p>>3]=0,h=f[b>>2]|0,(h|0)<=1)return b=0,z=M,b|0;c=h+-1|0,h=0,m=+W[b+8>>3],_=+W[b+16>>3],y=0;do h=h+1|0,D=m,m=+W[b+8+(h<<4)>>3],k=+_n(+((m-D)*.5)),R=_,_=+W[b+8+(h<<4)+8>>3],R=+_n(+((_-R)*.5)),R=k*k+R*(+kn(+m)*+kn(+D)*R),y=y+ +Zr(+ +Pn(+R),+ +Pn(+(1-R)))*2;while((h|0)<(c|0));return W[p>>3]=y,b=0,z=M,b|0}function OL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(M=z,z=z+176|0,b=M,h=Up(h,c,b)|0,h|0)return b=h,y=+W[p>>3],y=y*6371.007180918475,W[p>>3]=y,z=M,b|0;if(W[p>>3]=0,h=f[b>>2]|0,(h|0)<=1)return b=0,y=0,y=y*6371.007180918475,W[p>>3]=y,z=M,b|0;c=h+-1|0,h=0,m=+W[b+8>>3],_=+W[b+16>>3],y=0;do h=h+1|0,D=m,m=+W[b+8+(h<<4)>>3],k=+_n(+((m-D)*.5)),R=_,_=+W[b+8+(h<<4)+8>>3],R=+_n(+((_-R)*.5)),R=k*k+R*(+kn(+D)*+kn(+m)*R),y=y+ +Zr(+ +Pn(+R),+ +Pn(+(1-R)))*2;while((h|0)!=(c|0));return W[p>>3]=y,b=0,k=y,k=k*6371.007180918475,W[p>>3]=k,z=M,b|0}function kL(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(M=z,z=z+176|0,b=M,h=Up(h,c,b)|0,h|0)return b=h,y=+W[p>>3],y=y*6371.007180918475,y=y*1e3,W[p>>3]=y,z=M,b|0;if(W[p>>3]=0,h=f[b>>2]|0,(h|0)<=1)return b=0,y=0,y=y*6371.007180918475,y=y*1e3,W[p>>3]=y,z=M,b|0;c=h+-1|0,h=0,m=+W[b+8>>3],_=+W[b+16>>3],y=0;do h=h+1|0,D=m,m=+W[b+8+(h<<4)>>3],k=+_n(+((m-D)*.5)),R=_,_=+W[b+8+(h<<4)+8>>3],R=+_n(+((_-R)*.5)),R=k*k+R*(+kn(+D)*+kn(+m)*R),y=y+ +Zr(+ +Pn(+R),+ +Pn(+(1-R)))*2;while((h|0)!=(c|0));return W[p>>3]=y,b=0,k=y,k=k*6371.007180918475,k=k*1e3,W[p>>3]=k,z=M,b|0}function VL(h){h=h|0;var c=0,p=0,m=0;return c=Ks(1,12)|0,c||Fe(27280,27235,49,27293),p=h+4|0,m=f[p>>2]|0,m|0?(m=m+8|0,f[m>>2]=c,f[p>>2]=c,c|0):(f[h>>2]|0&&Fe(27310,27235,61,27333),m=h,f[m>>2]=c,f[p>>2]=c,c|0)}function GL(h,c){h=h|0,c=c|0;var p=0,m=0;return m=Oa(24)|0,m||Fe(27347,27235,78,27361),f[m>>2]=f[c>>2],f[m+4>>2]=f[c+4>>2],f[m+8>>2]=f[c+8>>2],f[m+12>>2]=f[c+12>>2],f[m+16>>2]=0,c=h+4|0,p=f[c>>2]|0,p|0?(f[p+16>>2]=m,f[c>>2]=m,m|0):(f[h>>2]|0&&Fe(27376,27235,82,27361),f[h>>2]=m,f[c>>2]=m,m|0)}function iT(h){h=h|0;var c=0,p=0,m=0,_=0;if(h)for(m=1;;){if(c=f[h>>2]|0,c|0)do{if(p=f[c>>2]|0,p|0)do _=p,p=f[p+16>>2]|0,on(_);while(p|0);_=c,c=f[c+8>>2]|0,on(_)}while(c|0);if(c=h,h=f[h+8>>2]|0,m||on(c),h)m=0;else break}}function qL(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0,En=0,Gn=0,mn=0,Jt=0,ot=0,Un=0,Si=0,Dn=0;if(_=h+8|0,f[_>>2]|0)return Dn=1,Dn|0;if(m=f[h>>2]|0,!m)return Dn=0,Dn|0;c=m,p=0;do p=p+1|0,c=f[c+8>>2]|0;while(c|0);if(p>>>0<2)return Dn=0,Dn|0;Un=Oa(p<<2)|0,Un||Fe(27396,27235,317,27415),ot=Oa(p<<5)|0,ot||Fe(27437,27235,321,27415),f[h>>2]=0,Zt=h+4|0,f[Zt>>2]=0,f[_>>2]=0,p=0,Jt=0,lt=0,X=0;e:for(;;){if(k=f[m>>2]|0,k){y=0,b=k;do{if(R=+W[b+8>>3],c=b,b=f[b+16>>2]|0,D=(b|0)==0,_=D?k:b,M=+W[_+8>>3],+bn(+(R-M))>3.141592653589793){Dn=14;break}y=y+(M-R)*(+W[c>>3]+ +W[_>>3])}while(!D);if((Dn|0)==14){Dn=0,y=0,c=k;do me=+W[c+8>>3],mn=c+16|0,Gn=f[mn>>2]|0,Gn=Gn|0?Gn:k,we=+W[Gn+8>>3],y=y+(+W[c>>3]+ +W[Gn>>3])*((we<0?we+6.283185307179586:we)-(me<0?me+6.283185307179586:me)),c=f[(c|0?mn:m)>>2]|0;while(c|0)}y>0?(f[Un+(Jt<<2)>>2]=m,Jt=Jt+1|0,_=lt,c=X):Dn=19}else Dn=19;if((Dn|0)==19){Dn=0;do if(p){if(c=p+8|0,f[c>>2]|0){Dn=21;break e}if(p=Ks(1,12)|0,!p){Dn=23;break e}f[c>>2]=p,_=p+4|0,b=p,c=X}else if(X){_=Zt,b=X+8|0,c=m,p=h;break}else if(f[h>>2]|0){Dn=27;break e}else{_=Zt,b=h,c=m,p=h;break}while(!1);if(f[b>>2]=m,f[_>>2]=m,b=ot+(lt<<5)|0,D=f[m>>2]|0,D){for(k=ot+(lt<<5)+8|0,W[k>>3]=17976931348623157e292,X=ot+(lt<<5)+24|0,W[X>>3]=17976931348623157e292,W[b>>3]=-17976931348623157e292,re=ot+(lt<<5)+16|0,W[re>>3]=-17976931348623157e292,Ne=17976931348623157e292,Ee=-17976931348623157e292,_=0,se=D,R=17976931348623157e292,Ae=17976931348623157e292,be=-17976931348623157e292,M=-17976931348623157e292;y=+W[se>>3],me=+W[se+8>>3],se=f[se+16>>2]|0,oe=(se|0)==0,we=+W[(oe?D:se)+8>>3],y>3]=y,R=y),me>3]=me,Ae=me),y>be?W[b>>3]=y:y=be,me>M&&(W[re>>3]=me,M=me),Ne=me>0&meEe?me:Ee,_=_|+bn(+(me-we))>3.141592653589793,!oe;)be=y;_&&(W[re>>3]=Ee,W[X>>3]=Ne)}else f[b>>2]=0,f[b+4>>2]=0,f[b+8>>2]=0,f[b+12>>2]=0,f[b+16>>2]=0,f[b+20>>2]=0,f[b+24>>2]=0,f[b+28>>2]=0;_=lt+1|0}if(mn=m+8|0,m=f[mn>>2]|0,f[mn>>2]=0,m)lt=_,X=c;else{Dn=45;break}}if((Dn|0)==21)Fe(27213,27235,35,27247);else if((Dn|0)==23)Fe(27267,27235,37,27247);else if((Dn|0)==27)Fe(27310,27235,61,27333);else if((Dn|0)==45){e:do if((Jt|0)>0){for(mn=(_|0)==0,En=_<<2,Gn=(h|0)==0,Mn=0,c=0;;){if(Ft=f[Un+(Mn<<2)>>2]|0,mn)Dn=73;else{if(lt=Oa(En)|0,!lt){Dn=50;break}if(Zt=Oa(En)|0,!Zt){Dn=52;break}t:do if(Gn)p=0;else{for(_=0,p=0,b=h;m=ot+(_<<5)|0,rT(f[b>>2]|0,m,f[Ft>>2]|0)|0?(f[lt+(p<<2)>>2]=b,f[Zt+(p<<2)>>2]=m,oe=p+1|0):oe=p,b=f[b+8>>2]|0,b;)_=_+1|0,p=oe;if((oe|0)>0)if(m=f[lt>>2]|0,(oe|0)==1)p=m;else for(re=0,se=-1,p=m,X=m;;){for(D=f[X>>2]|0,m=0,b=0;_=f[f[lt+(b<<2)>>2]>>2]|0,(_|0)==(D|0)?k=m:k=m+((rT(_,f[Zt+(b<<2)>>2]|0,f[D>>2]|0)|0)&1)|0,b=b+1|0,(b|0)!=(oe|0);)m=k;if(_=(k|0)>(se|0),p=_?X:p,m=re+1|0,(m|0)==(oe|0))break t;re=m,se=_?k:se,X=f[lt+(m<<2)>>2]|0}else p=0}while(!1);if(on(lt),on(Zt),p){if(_=p+4|0,m=f[_>>2]|0,m)p=m+8|0;else if(f[p>>2]|0){Dn=70;break}f[p>>2]=Ft,f[_>>2]=Ft}else Dn=73}if((Dn|0)==73){if(Dn=0,c=f[Ft>>2]|0,c|0)do Zt=c,c=f[c+16>>2]|0,on(Zt);while(c|0);on(Ft),c=1}if(Mn=Mn+1|0,(Mn|0)>=(Jt|0)){Si=c;break e}}(Dn|0)==50?Fe(27452,27235,249,27471):(Dn|0)==52?Fe(27490,27235,252,27471):(Dn|0)==70&&Fe(27310,27235,61,27333)}else Si=0;while(!1);return on(Un),on(ot),Dn=Si,Dn|0}return 0}function rT(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(!(xc(c,p)|0)||(c=Ua(c)|0,m=+W[p>>3],_=+W[p+8>>3],_=c&_<0?_+6.283185307179586:_,h=f[h>>2]|0,!h))return h=0,h|0;if(c){c=0,D=_,p=h;e:for(;;){for(;b=+W[p>>3],_=+W[p+8>>3],p=p+16|0,k=f[p>>2]|0,k=k|0?k:h,y=+W[k>>3],M=+W[k+8>>3],b>y?(R=b,b=M):(R=y,y=b,b=_,_=M),m=m==y|m==R?m+2220446049250313e-31:m,!!(mR);)if(p=f[p>>2]|0,!p){p=22;break e}if(M=b<0?b+6.283185307179586:b,b=_<0?_+6.283185307179586:_,D=M==D|b==D?D+-2220446049250313e-31:D,R=M+(b-M)*((m-y)/(R-y)),(R<0?R+6.283185307179586:R)>D&&(c=c^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return c|0}else{c=0,D=_,p=h;e:for(;;){for(;b=+W[p>>3],_=+W[p+8>>3],p=p+16|0,k=f[p>>2]|0,k=k|0?k:h,y=+W[k>>3],M=+W[k+8>>3],b>y?(R=b,b=M):(R=y,y=b,b=_,_=M),m=m==y|m==R?m+2220446049250313e-31:m,!!(mR);)if(p=f[p>>2]|0,!p){p=22;break e}if(D=b==D|_==D?D+-2220446049250313e-31:D,b+(_-b)*((m-y)/(R-y))>D&&(c=c^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return c|0}return 0}function Nl(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0;if(Ee=z,z=z+32|0,Ne=Ee+16|0,be=Ee,y=Xe(h|0,c|0,52)|0,V()|0,y=y&15,se=Xe(p|0,m|0,52)|0,V()|0,(y|0)!=(se&15|0))return Ne=12,z=Ee,Ne|0;if(D=Xe(h|0,c|0,45)|0,V()|0,D=D&127,k=Xe(p|0,m|0,45)|0,V()|0,k=k&127,D>>>0>121|k>>>0>121)return Ne=5,z=Ee,Ne|0;if(se=(D|0)!=(k|0),se){if(M=mu(D,k)|0,(M|0)==7)return Ne=1,z=Ee,Ne|0;R=mu(k,D)|0,(R|0)==7?Fe(27514,27538,161,27548):(oe=M,b=R)}else oe=0,b=0;X=pi(D)|0,re=pi(k)|0,f[Ne>>2]=0,f[Ne+4>>2]=0,f[Ne+8>>2]=0,f[Ne+12>>2]=0;do if(oe){if(k=f[4272+(D*28|0)+(oe<<2)>>2]|0,M=(k|0)>0,re)if(M){D=0,R=p,M=m;do R=bL(R,M)|0,M=V()|0,b=_u(b)|0,(b|0)==1&&(b=_u(1)|0),D=D+1|0;while((D|0)!=(k|0));k=b,D=R,R=M}else k=b,D=p,R=m;else if(M){D=0,R=p,M=m;do R=J_(R,M)|0,M=V()|0,b=_u(b)|0,D=D+1|0;while((D|0)!=(k|0));k=b,D=R,R=M}else k=b,D=p,R=m;if(t2(D,R,Ne)|0,se||Fe(27563,27538,191,27548),M=(X|0)!=0,b=(re|0)!=0,M&b&&Fe(27590,27538,192,27548),M){if(b=Ys(h,c)|0,(b|0)==7){y=5;break}if(je[22e3+(b*7|0)+oe>>0]|0){y=1;break}R=f[21168+(b*28|0)+(oe<<2)>>2]|0,D=R}else if(b){if(b=Ys(D,R)|0,(b|0)==7){y=5;break}if(je[22e3+(b*7|0)+k>>0]|0){y=1;break}D=0,R=f[21168+(k*28|0)+(b<<2)>>2]|0}else D=0,R=0;if((D|R|0)<0)y=5;else{if((R|0)>0){M=Ne+4|0,b=0;do Bp(M),b=b+1|0;while((b|0)!=(R|0))}if(f[be>>2]=0,f[be+4>>2]=0,f[be+8>>2]=0,qS(be,oe),y|0)for(;Fo(y)|0?Ip(be):bc(be),(y|0)>1;)y=y+-1|0;if((D|0)>0){y=0;do Bp(be),y=y+1|0;while((y|0)!=(D|0))}Ae=Ne+4|0,Ps(Ae,be,Ae),ii(Ae),Ae=51}}else if(t2(p,m,Ne)|0,(X|0)!=0&(re|0)!=0)if((k|0)!=(D|0)&&Fe(27621,27538,261,27548),b=Ys(h,c)|0,y=Ys(p,m)|0,(b|0)==7|(y|0)==7)y=5;else if(je[22e3+(b*7|0)+y>>0]|0)y=1;else if(b=f[21168+(b*28|0)+(y<<2)>>2]|0,(b|0)>0){M=Ne+4|0,y=0;do Bp(M),y=y+1|0;while((y|0)!=(b|0));Ae=51}else Ae=51;else Ae=51;while(!1);return(Ae|0)==51&&(y=Ne+4|0,f[_>>2]=f[y>>2],f[_+4>>2]=f[y+4>>2],f[_+8>>2]=f[y+8>>2],y=0),Ne=y,z=Ee,Ne|0}function sT(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0;if(Ae=z,z=z+48|0,D=Ae+36|0,b=Ae+24|0,M=Ae+12|0,R=Ae,_=Xe(h|0,c|0,52)|0,V()|0,_=_&15,re=Xe(h|0,c|0,45)|0,V()|0,re=re&127,re>>>0>121)return m=5,z=Ae,m|0;if(k=pi(re)|0,st(_|0,0,52)|0,be=V()|0|134225919,y=m,f[y>>2]=-1,f[y+4>>2]=be,!_)return _=Lp(p)|0,(_|0)==7||(_=Lh(re,_)|0,(_|0)==127)?(be=1,z=Ae,be|0):(se=st(_|0,0,45)|0,oe=V()|0,re=m,oe=f[re+4>>2]&-1040385|oe,be=m,f[be>>2]=f[re>>2]|se,f[be+4>>2]=oe,be=0,z=Ae,be|0);for(f[D>>2]=f[p>>2],f[D+4>>2]=f[p+4>>2],f[D+8>>2]=f[p+8>>2],p=_;;){if(y=p,p=p+-1|0,f[b>>2]=f[D>>2],f[b+4>>2]=f[D+4>>2],f[b+8>>2]=f[D+8>>2],Fo(y)|0){if(_=YD(D)|0,_|0){p=13;break}f[M>>2]=f[D>>2],f[M+4>>2]=f[D+4>>2],f[M+8>>2]=f[D+8>>2],Ip(M)}else{if(_=KD(D)|0,_|0){p=13;break}f[M>>2]=f[D>>2],f[M+4>>2]=f[D+4>>2],f[M+8>>2]=f[D+8>>2],bc(M)}if(W_(b,M,R),ii(R),_=m,Ee=f[_>>2]|0,_=f[_+4>>2]|0,we=(15-y|0)*3|0,Ne=st(7,0,we|0)|0,_=_&~(V()|0),we=st(Lp(R)|0,0,we|0)|0,_=V()|0|_,be=m,f[be>>2]=we|Ee&~Ne,f[be+4>>2]=_,(y|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((f[D>>2]|0)<=1&&(f[D+4>>2]|0)<=1&&(f[D+8>>2]|0)<=1){p=Lp(D)|0,_=Lh(re,p)|0,(_|0)==127?R=0:R=pi(_)|0;t:do if(p){if(k){if(_=Ys(h,c)|0,(_|0)==7){_=5;break e}if(y=f[21376+(_*28|0)+(p<<2)>>2]|0,(y|0)>0){_=p,p=0;do _=Sc(_)|0,p=p+1|0;while((p|0)!=(y|0))}else _=p;if((_|0)==1){_=9;break e}p=Lh(re,_)|0,(p|0)==127&&Fe(27648,27538,411,27678),pi(p)|0?Fe(27693,27538,412,27678):(oe=p,se=y,X=_)}else oe=_,se=0,X=p;if(M=f[4272+(re*28|0)+(X<<2)>>2]|0,(M|0)<=-1&&Fe(27724,27538,419,27678),!R){if((se|0)<0){_=5;break e}if(se|0){y=m,_=0,p=f[y>>2]|0,y=f[y+4>>2]|0;do p=Tc(p,y)|0,y=V()|0,we=m,f[we>>2]=p,f[we+4>>2]=y,_=_+1|0;while((_|0)<(se|0))}if((M|0)<=0){_=oe,p=58;break}for(y=m,_=0,p=f[y>>2]|0,y=f[y+4>>2]|0;;)if(p=Tc(p,y)|0,y=V()|0,we=m,f[we>>2]=p,f[we+4>>2]=y,_=_+1|0,(_|0)==(M|0)){_=oe,p=58;break t}}if(b=mu(oe,re)|0,(b|0)==7&&Fe(27514,27538,428,27678),_=m,p=f[_>>2]|0,_=f[_+4>>2]|0,(M|0)>0){y=0;do p=Tc(p,_)|0,_=V()|0,we=m,f[we>>2]=p,f[we+4>>2]=_,y=y+1|0;while((y|0)!=(M|0))}if(_=Ys(p,_)|0,(_|0)==7&&Fe(27795,27538,440,27678),p=Dh(oe)|0,p=f[(p?21792:21584)+(b*28|0)+(_<<2)>>2]|0,(p|0)<0&&Fe(27795,27538,454,27678),!p)_=oe,p=58;else{b=m,_=0,y=f[b>>2]|0,b=f[b+4>>2]|0;do y=Z_(y,b)|0,b=V()|0,we=m,f[we>>2]=y,f[we+4>>2]=b,_=_+1|0;while((_|0)<(p|0));_=oe,p=58}}else if((k|0)!=0&(R|0)!=0){if(p=Ys(h,c)|0,y=m,y=Ys(f[y>>2]|0,f[y+4>>2]|0)|0,(p|0)==7|(y|0)==7){_=5;break e}if(y=f[21376+(p*28|0)+(y<<2)>>2]|0,(y|0)<0){_=5;break e}if(!y)p=59;else{M=m,p=0,b=f[M>>2]|0,M=f[M+4>>2]|0;do b=Tc(b,M)|0,M=V()|0,we=m,f[we>>2]=b,f[we+4>>2]=M,p=p+1|0;while((p|0)<(y|0));p=58}}else p=58;while(!1);if((p|0)==58&&R&&(p=59),(p|0)==59&&(we=m,(Ys(f[we>>2]|0,f[we+4>>2]|0)|0)==1)){_=9;break}we=m,Ne=f[we>>2]|0,we=f[we+4>>2]&-1040385,Ee=st(_|0,0,45)|0,we=we|(V()|0),_=m,f[_>>2]=Ne|Ee,f[_+4>>2]=we,_=0}else _=1;while(!1);return we=_,z=Ae,we|0}function zL(h,c,p,m,_,y){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0;var b=0,M=0;return M=z,z=z+16|0,b=M,_?h=15:(h=Nl(h,c,p,m,b)|0,h||(JD(b,y),h=0)),z=M,h|0}function HL(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0;return b=z,z=z+16|0,y=b,m?p=15:(p=eL(p,y)|0,p||(p=sT(h,c,y,_)|0)),z=b,p|0}function WL(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0;return R=z,z=z+32|0,b=R+12|0,M=R,y=Nl(h,c,h,c,b)|0,y|0?(M=y,z=R,M|0):(h=Nl(h,c,p,m,M)|0,h|0?(M=h,z=R,M|0):(b=$_(b,M)|0,M=_,f[M>>2]=b,f[M+4>>2]=((b|0)<0)<<31>>31,M=0,z=R,M|0))}function $L(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0;return R=z,z=z+32|0,b=R+12|0,M=R,y=Nl(h,c,h,c,b)|0,!y&&(y=Nl(h,c,p,m,M)|0,!y)?(m=$_(b,M)|0,m=sn(m|0,((m|0)<0)<<31>>31|0,1,0)|0,b=V()|0,M=_,f[M>>2]=m,f[M+4>>2]=b,M=0,z=R,M|0):(M=y,z=R,M|0)}function jL(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0;if(Ft=z,z=z+48|0,lt=Ft+24|0,b=Ft+12|0,Zt=Ft,y=Nl(h,c,h,c,lt)|0,!y&&(y=Nl(h,c,p,m,b)|0,!y)){we=$_(lt,b)|0,me=((we|0)<0)<<31>>31,f[lt>>2]=0,f[lt+4>>2]=0,f[lt+8>>2]=0,f[b>>2]=0,f[b+4>>2]=0,f[b+8>>2]=0,Nl(h,c,h,c,lt)|0&&Fe(27795,27538,692,27747),Nl(h,c,p,m,b)|0&&Fe(27795,27538,697,27747),$S(lt),$S(b),k=we|0?1/+(we|0):0,p=f[lt>>2]|0,Ae=k*+((f[b>>2]|0)-p|0),be=lt+4|0,m=f[be>>2]|0,Ne=k*+((f[b+4>>2]|0)-m|0),Ee=lt+8|0,y=f[Ee>>2]|0,k=k*+((f[b+8>>2]|0)-y|0),f[Zt>>2]=p,X=Zt+4|0,f[X>>2]=m,re=Zt+8|0,f[re>>2]=y;e:do if((we|0)<0)y=0;else for(se=0,oe=0;;){R=+(oe>>>0)+4294967296*+(se|0),Mn=Ae*R+ +(p|0),M=Ne*R+ +(m|0),R=k*R+ +(y|0),p=~~+Gp(+Mn),b=~~+Gp(+M),y=~~+Gp(+R),Mn=+bn(+(+(p|0)-Mn)),M=+bn(+(+(b|0)-M)),R=+bn(+(+(y|0)-R));do if(Mn>M&Mn>R)p=0-(b+y)|0,m=b;else if(D=0-p|0,M>R){m=D-y|0;break}else{m=b,y=D-b|0;break}while(!1);if(f[Zt>>2]=p,f[X>>2]=m,f[re>>2]=y,tL(Zt),y=sT(h,c,Zt,_+(oe<<3)|0)|0,y|0)break e;if(!((se|0)<(me|0)|(se|0)==(me|0)&oe>>>0>>0)){y=0;break e}p=sn(oe|0,se|0,1,0)|0,m=V()|0,se=m,oe=p,p=f[lt>>2]|0,m=f[be>>2]|0,y=f[Ee>>2]|0}while(!1);return Zt=y,z=Ft,Zt|0}return Zt=y,z=Ft,Zt|0}function vu(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0;if((p|0)==0&(m|0)==0)return _=0,y=1,xe(_|0),y|0;y=h,_=c,h=1,c=0;do b=(p&1|0)==0&!0,h=qr((b?1:y)|0,(b?0:_)|0,h|0,c|0)|0,c=V()|0,p=_T(p|0,m|0,1)|0,m=V()|0,y=qr(y|0,_|0,y|0,_|0)|0,_=V()|0;while(!((p|0)==0&(m|0)==0));return xe(c|0),h|0}function o2(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0;M=z,z=z+16|0,y=M,b=Xe(h|0,c|0,52)|0,V()|0,b=b&15;do if(b){if(_=wc(h,c,y)|0,!_){D=+W[y>>3],R=1/+kn(+D),k=+W[25968+(b<<3)>>3],W[p>>3]=D+k,W[p+8>>3]=D-k,D=+W[y+8>>3],R=k*R,W[p+16>>3]=R+D,W[p+24>>3]=D-R;break}return b=_,z=M,b|0}else{if(_=Xe(h|0,c|0,45)|0,V()|0,_=_&127,_>>>0>121)return b=5,z=M,b|0;y=22064+(_<<5)|0,f[p>>2]=f[y>>2],f[p+4>>2]=f[y+4>>2],f[p+8>>2]=f[y+8>>2],f[p+12>>2]=f[y+12>>2],f[p+16>>2]=f[y+16>>2],f[p+20>>2]=f[y+20>>2],f[p+24>>2]=f[y+24>>2],f[p+28>>2]=f[y+28>>2];break}while(!1);return ns(p,m?1.4:1.1),m=26096+(b<<3)|0,(f[m>>2]|0)==(h|0)&&(f[m+4>>2]|0)==(c|0)&&(W[p>>3]=1.5707963267948966),b=26224+(b<<3)|0,(f[b>>2]|0)==(h|0)&&(f[b+4>>2]|0)==(c|0)&&(W[p+8>>3]=-1.5707963267948966),+W[p>>3]!=1.5707963267948966&&+W[p+8>>3]!=-1.5707963267948966?(b=0,z=M,b|0):(W[p+16>>3]=3.141592653589793,W[p+24>>3]=-3.141592653589793,b=0,z=M,b|0)}function XL(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0;D=z,z=z+48|0,b=D+32|0,y=D+40|0,M=D,Y_(b,0,0,0),R=f[b>>2]|0,b=f[b+4>>2]|0;do if(p>>>0<=15){if(_=uA(m)|0,_|0){m=M,f[m>>2]=0,f[m+4>>2]=0,f[M+8>>2]=_,f[M+12>>2]=-1,m=M+16|0,R=M+29|0,f[m>>2]=0,f[m+4>>2]=0,f[m+8>>2]=0,je[m+12>>0]=0,je[R>>0]=je[y>>0]|0,je[R+1>>0]=je[y+1>>0]|0,je[R+2>>0]=je[y+2>>0]|0;break}if(_=Ks((f[c+8>>2]|0)+1|0,32)|0,_){a2(c,_),k=M,f[k>>2]=R,f[k+4>>2]=b,f[M+8>>2]=0,f[M+12>>2]=p,f[M+16>>2]=m,f[M+20>>2]=c,f[M+24>>2]=_,je[M+28>>0]=0,R=M+29|0,je[R>>0]=je[y>>0]|0,je[R+1>>0]=je[y+1>>0]|0,je[R+2>>0]=je[y+2>>0]|0;break}else{m=M,f[m>>2]=0,f[m+4>>2]=0,f[M+8>>2]=13,f[M+12>>2]=-1,m=M+16|0,R=M+29|0,f[m>>2]=0,f[m+4>>2]=0,f[m+8>>2]=0,je[m+12>>0]=0,je[R>>0]=je[y>>0]|0,je[R+1>>0]=je[y+1>>0]|0,je[R+2>>0]=je[y+2>>0]|0;break}}else R=M,f[R>>2]=0,f[R+4>>2]=0,f[M+8>>2]=4,f[M+12>>2]=-1,R=M+16|0,k=M+29|0,f[R>>2]=0,f[R+4>>2]=0,f[R+8>>2]=0,je[R+12>>0]=0,je[k>>0]=je[y>>0]|0,je[k+1>>0]=je[y+1>>0]|0,je[k+2>>0]=je[y+2>>0]|0;while(!1);Op(M),f[h>>2]=f[M>>2],f[h+4>>2]=f[M+4>>2],f[h+8>>2]=f[M+8>>2],f[h+12>>2]=f[M+12>>2],f[h+16>>2]=f[M+16>>2],f[h+20>>2]=f[M+20>>2],f[h+24>>2]=f[M+24>>2],f[h+28>>2]=f[M+28>>2],z=D}function Op(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0;if(me=z,z=z+336|0,se=me+168|0,oe=me,m=h,p=f[m>>2]|0,m=f[m+4>>2]|0,(p|0)==0&(m|0)==0){z=me;return}if(c=h+28|0,je[c>>0]|0?(p=oT(p,m)|0,m=V()|0):je[c>>0]=1,we=h+20|0,!(f[f[we>>2]>>2]|0)){c=h+24|0,p=f[c>>2]|0,p|0&&on(p),Ee=h,f[Ee>>2]=0,f[Ee+4>>2]=0,f[h+8>>2]=0,f[we>>2]=0,f[h+12>>2]=-1,f[h+16>>2]=0,f[c>>2]=0,z=me;return}Ee=h+16|0,c=f[Ee>>2]|0,_=c&15;e:do if((p|0)==0&(m|0)==0)Ne=h+24|0;else{Ae=h+12|0,X=(_|0)==3,k=c&255,R=(_|1|0)==3,re=h+24|0,D=(_+-1|0)>>>0<3,b=(_|2|0)==3,M=oe+8|0;t:for(;;){if(y=Xe(p|0,m|0,52)|0,V()|0,y=y&15,(y|0)==(f[Ae>>2]|0)){switch(k&15){case 0:case 2:case 3:{if(_=wc(p,m,se)|0,_|0){be=15;break t}if(l2(f[we>>2]|0,f[re>>2]|0,se)|0){be=19;break t}break}}if(R&&(_=f[(f[we>>2]|0)+4>>2]|0,f[se>>2]=f[_>>2],f[se+4>>2]=f[_+4>>2],f[se+8>>2]=f[_+8>>2],f[se+12>>2]=f[_+12>>2],xc(26832,se)|0)){if(e2(f[(f[we>>2]|0)+4>>2]|0,y,oe)|0){be=25;break}if(_=oe,(f[_>>2]|0)==(p|0)&&(f[_+4>>2]|0)==(m|0)){be=29;break}}if(D){if(_=Oh(p,m,se)|0,_|0){be=32;break}if(o2(p,m,oe,0)|0){be=36;break}if(b&&lT(f[we>>2]|0,f[re>>2]|0,se,oe)|0){be=42;break}if(R&&uT(f[we>>2]|0,f[re>>2]|0,se,oe)|0){be=42;break}}if(X){if(c=o2(p,m,se,1)|0,_=f[re>>2]|0,c|0){be=45;break}if(yc(_,se)|0){if(es(oe,se),Jr(se,f[re>>2]|0)|0){be=53;break}if(l2(f[we>>2]|0,f[re>>2]|0,M)|0){be=53;break}if(uT(f[we>>2]|0,f[re>>2]|0,oe,se)|0){be=53;break}}}}do if((y|0)<(f[Ae>>2]|0)){if(c=o2(p,m,se,1)|0,_=f[re>>2]|0,c|0){be=58;break t}if(!(yc(_,se)|0)){be=73;break}if(Jr(f[re>>2]|0,se)|0&&(es(oe,se),lT(f[we>>2]|0,f[re>>2]|0,oe,se)|0)){be=65;break t}if(p=ZS(p,m,y+1|0,oe)|0,p|0){be=67;break t}m=oe,p=f[m>>2]|0,m=f[m+4>>2]|0}else be=73;while(!1);if((be|0)==73&&(be=0,p=oT(p,m)|0,m=V()|0),(p|0)==0&(m|0)==0){Ne=re;break e}}switch(be|0){case 15:{c=f[re>>2]|0,c|0&&on(c),be=h,f[be>>2]=0,f[be+4>>2]=0,f[we>>2]=0,f[Ae>>2]=-1,f[Ee>>2]=0,f[re>>2]=0,f[h+8>>2]=_,be=20;break}case 19:{f[h>>2]=p,f[h+4>>2]=m,be=20;break}case 25:{Fe(27795,27761,470,27772);break}case 29:{f[h>>2]=p,f[h+4>>2]=m,z=me;return}case 32:{c=f[re>>2]|0,c|0&&on(c),Ne=h,f[Ne>>2]=0,f[Ne+4>>2]=0,f[we>>2]=0,f[Ae>>2]=-1,f[Ee>>2]=0,f[re>>2]=0,f[h+8>>2]=_,z=me;return}case 36:{Fe(27795,27761,493,27772);break}case 42:{f[h>>2]=p,f[h+4>>2]=m,z=me;return}case 45:{_|0&&on(_),be=h,f[be>>2]=0,f[be+4>>2]=0,f[we>>2]=0,f[Ae>>2]=-1,f[Ee>>2]=0,f[re>>2]=0,f[h+8>>2]=c,be=55;break}case 53:{f[h>>2]=p,f[h+4>>2]=m,be=55;break}case 58:{_|0&&on(_),be=h,f[be>>2]=0,f[be+4>>2]=0,f[we>>2]=0,f[Ae>>2]=-1,f[Ee>>2]=0,f[re>>2]=0,f[h+8>>2]=c,be=71;break}case 65:{f[h>>2]=p,f[h+4>>2]=m,be=71;break}case 67:{c=f[re>>2]|0,c|0&&on(c),Ne=h,f[Ne>>2]=0,f[Ne+4>>2]=0,f[we>>2]=0,f[Ae>>2]=-1,f[Ee>>2]=0,f[re>>2]=0,f[h+8>>2]=p,z=me;return}}if((be|0)==20){z=me;return}else if((be|0)==55){z=me;return}else if((be|0)==71){z=me;return}}while(!1);c=f[Ne>>2]|0,c|0&&on(c),be=h,f[be>>2]=0,f[be+4>>2]=0,f[h+8>>2]=0,f[we>>2]=0,f[h+12>>2]=-1,f[Ee>>2]=0,f[Ne>>2]=0,z=me}function oT(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0;X=z,z=z+16|0,k=X,m=Xe(h|0,c|0,52)|0,V()|0,m=m&15,p=Xe(h|0,c|0,45)|0,V()|0;do if(m){for(;p=st(m+4095|0,0,52)|0,_=V()|0|c&-15728641,y=(15-m|0)*3|0,b=st(7,0,y|0)|0,M=V()|0,p=p|h|b,_=_|M,R=Xe(h|0,c|0,y|0)|0,V()|0,R=R&7,m=m+-1|0,!(R>>>0<6);)if(m)c=_,h=p;else{D=4;break}if((D|0)==4){p=Xe(p|0,_|0,45)|0,V()|0;break}return k=(R|0)==0&(Ni(p,_)|0)!=0,k=st((k?2:1)+R|0,0,y|0)|0,D=V()|0|c&~M,k=k|h&~b,xe(D|0),z=X,k|0}while(!1);return p=p&127,p>>>0>120?(D=0,k=0,xe(D|0),z=X,k|0):(Y_(k,0,p+1|0,0),D=f[k+4>>2]|0,k=f[k>>2]|0,xe(D|0),z=X,k|0)}function QL(h,c,p,m,_,y){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0,y=y|0;var b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0;be=z,z=z+160|0,X=be+80|0,M=be+64|0,re=be+112|0,Ae=be,XL(X,h,c,p),D=X,i2(M,f[D>>2]|0,f[D+4>>2]|0,c),D=M,R=f[D>>2]|0,D=f[D+4>>2]|0,b=f[X+8>>2]|0,se=re+4|0,f[se>>2]=f[X>>2],f[se+4>>2]=f[X+4>>2],f[se+8>>2]=f[X+8>>2],f[se+12>>2]=f[X+12>>2],f[se+16>>2]=f[X+16>>2],f[se+20>>2]=f[X+20>>2],f[se+24>>2]=f[X+24>>2],f[se+28>>2]=f[X+28>>2],se=Ae,f[se>>2]=R,f[se+4>>2]=D,se=Ae+8|0,f[se>>2]=b,h=Ae+12|0,c=re,p=h+36|0;do f[h>>2]=f[c>>2],h=h+4|0,c=c+4|0;while((h|0)<(p|0));if(re=Ae+48|0,f[re>>2]=f[M>>2],f[re+4>>2]=f[M+4>>2],f[re+8>>2]=f[M+8>>2],f[re+12>>2]=f[M+12>>2],(R|0)==0&(D|0)==0)return Ae=b,z=be,Ae|0;p=Ae+16|0,k=Ae+24|0,X=Ae+28|0,b=0,M=0,c=R,h=D;do{if(!((b|0)<(_|0)|(b|0)==(_|0)&M>>>0>>0)){oe=4;break}if(D=M,M=sn(M|0,b|0,1,0)|0,b=V()|0,D=y+(D<<3)|0,f[D>>2]=c,f[D+4>>2]=h,r2(re),h=re,c=f[h>>2]|0,h=f[h+4>>2]|0,(c|0)==0&(h|0)==0){if(Op(p),c=p,h=f[c>>2]|0,c=f[c+4>>2]|0,(h|0)==0&(c|0)==0){oe=10;break}eT(h,c,f[X>>2]|0,re),h=re,c=f[h>>2]|0,h=f[h+4>>2]|0}D=Ae,f[D>>2]=c,f[D+4>>2]=h}while(!((c|0)==0&(h|0)==0));return(oe|0)==4?(h=Ae+40|0,c=f[h>>2]|0,c|0&&on(c),oe=Ae+16|0,f[oe>>2]=0,f[oe+4>>2]=0,f[k>>2]=0,f[Ae+36>>2]=0,f[X>>2]=-1,f[Ae+32>>2]=0,f[h>>2]=0,eT(0,0,0,re),f[Ae>>2]=0,f[Ae+4>>2]=0,f[se>>2]=0,Ae=14,z=be,Ae|0):((oe|0)==10&&(f[Ae>>2]=0,f[Ae+4>>2]=0,f[se>>2]=f[k>>2]),Ae=f[se>>2]|0,z=be,Ae|0)}function YL(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0;if(X=z,z=z+48|0,R=X+32|0,M=X+40|0,D=X,!(f[h>>2]|0))return k=m,f[k>>2]=0,f[k+4>>2]=0,k=0,z=X,k|0;Y_(R,0,0,0),b=R,_=f[b>>2]|0,b=f[b+4>>2]|0;do if(c>>>0>15)k=D,f[k>>2]=0,f[k+4>>2]=0,f[D+8>>2]=4,f[D+12>>2]=-1,k=D+16|0,p=D+29|0,f[k>>2]=0,f[k+4>>2]=0,f[k+8>>2]=0,je[k+12>>0]=0,je[p>>0]=je[M>>0]|0,je[p+1>>0]=je[M+1>>0]|0,je[p+2>>0]=je[M+2>>0]|0,p=4,k=9;else{if(p=uA(p)|0,p|0){R=D,f[R>>2]=0,f[R+4>>2]=0,f[D+8>>2]=p,f[D+12>>2]=-1,R=D+16|0,k=D+29|0,f[R>>2]=0,f[R+4>>2]=0,f[R+8>>2]=0,je[R+12>>0]=0,je[k>>0]=je[M>>0]|0,je[k+1>>0]=je[M+1>>0]|0,je[k+2>>0]=je[M+2>>0]|0,k=9;break}if(p=Ks((f[h+8>>2]|0)+1|0,32)|0,!p){k=D,f[k>>2]=0,f[k+4>>2]=0,f[D+8>>2]=13,f[D+12>>2]=-1,k=D+16|0,p=D+29|0,f[k>>2]=0,f[k+4>>2]=0,f[k+8>>2]=0,je[k+12>>0]=0,je[p>>0]=je[M>>0]|0,je[p+1>>0]=je[M+1>>0]|0,je[p+2>>0]=je[M+2>>0]|0,p=13,k=9;break}a2(h,p),se=D,f[se>>2]=_,f[se+4>>2]=b,b=D+8|0,f[b>>2]=0,f[D+12>>2]=c,f[D+20>>2]=h,f[D+24>>2]=p,je[D+28>>0]=0,_=D+29|0,je[_>>0]=je[M>>0]|0,je[_+1>>0]=je[M+1>>0]|0,je[_+2>>0]=je[M+2>>0]|0,f[D+16>>2]=3,re=+Bh(p),re=re*+Ih(p),y=+bn(+ +W[p>>3]),y=re/+kn(+ +Vp(+y,+ +bn(+ +W[p+8>>3])))*6371.007180918475*6371.007180918475,_=D+12|0,p=f[_>>2]|0;e:do if((p|0)>0)do{if(tT(p+-1|0,R)|0,!(y/+W[R>>3]>10))break e;se=f[_>>2]|0,p=se+-1|0,f[_>>2]=p}while((se|0)>1);while(!1);if(Op(D),_=m,f[_>>2]=0,f[_+4>>2]=0,_=D,p=f[_>>2]|0,_=f[_+4>>2]|0,!((p|0)==0&(_|0)==0))do sA(p,_,c,R)|0,M=R,h=m,M=sn(f[h>>2]|0,f[h+4>>2]|0,f[M>>2]|0,f[M+4>>2]|0)|0,h=V()|0,se=m,f[se>>2]=M,f[se+4>>2]=h,Op(D),se=D,p=f[se>>2]|0,_=f[se+4>>2]|0;while(!((p|0)==0&(_|0)==0));p=f[b>>2]|0}while(!1);return se=p,z=X,se|0}function lA(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;if(!(xc(c,p)|0)||(c=Ua(c)|0,m=+W[p>>3],_=+W[p+8>>3],_=c&_<0?_+6.283185307179586:_,re=f[h>>2]|0,(re|0)<=0))return re=0,re|0;if(X=f[h+4>>2]|0,c){c=0,k=_,p=-1,h=0;e:for(;;){for(D=h;b=+W[X+(D<<4)>>3],_=+W[X+(D<<4)+8>>3],h=(p+2|0)%(re|0)|0,y=+W[X+(h<<4)>>3],M=+W[X+(h<<4)+8>>3],b>y?(R=b,b=M):(R=y,y=b,b=_,_=M),m=m==y|m==R?m+2220446049250313e-31:m,!!(mR);)if(p=D+1|0,(p|0)>=(re|0)){p=22;break e}else h=D,D=p,p=h;if(M=b<0?b+6.283185307179586:b,b=_<0?_+6.283185307179586:_,k=M==k|b==k?k+-2220446049250313e-31:k,R=M+(b-M)*((m-y)/(R-y)),(R<0?R+6.283185307179586:R)>k&&(c=c^1),h=D+1|0,(h|0)>=(re|0)){p=22;break}else p=D}if((p|0)==22)return c|0}else{c=0,k=_,p=-1,h=0;e:for(;;){for(D=h;b=+W[X+(D<<4)>>3],_=+W[X+(D<<4)+8>>3],h=(p+2|0)%(re|0)|0,y=+W[X+(h<<4)>>3],M=+W[X+(h<<4)+8>>3],b>y?(R=b,b=M):(R=y,y=b,b=_,_=M),m=m==y|m==R?m+2220446049250313e-31:m,!!(mR);)if(p=D+1|0,(p|0)>=(re|0)){p=22;break e}else h=D,D=p,p=h;if(k=b==k|_==k?k+-2220446049250313e-31:k,b+(_-b)*((m-y)/(R-y))>k&&(c=c^1),h=D+1|0,(h|0)>=(re|0)){p=22;break}else p=D}if((p|0)==22)return c|0}return 0}function aT(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0;if(oe=f[h>>2]|0,!oe){f[c>>2]=0,f[c+4>>2]=0,f[c+8>>2]=0,f[c+12>>2]=0,f[c+16>>2]=0,f[c+20>>2]=0,f[c+24>>2]=0,f[c+28>>2]=0;return}if(Ae=c+8|0,W[Ae>>3]=17976931348623157e292,be=c+24|0,W[be>>3]=17976931348623157e292,W[c>>3]=-17976931348623157e292,Ne=c+16|0,W[Ne>>3]=-17976931348623157e292,!((oe|0)<=0)){for(re=f[h+4>>2]|0,D=17976931348623157e292,k=-17976931348623157e292,X=0,h=-1,y=17976931348623157e292,b=17976931348623157e292,R=-17976931348623157e292,m=-17976931348623157e292,se=0;p=+W[re+(se<<4)>>3],M=+W[re+(se<<4)+8>>3],h=h+2|0,_=+W[re+(((h|0)==(oe|0)?0:h)<<4)+8>>3],p>3]=p,y=p),M>3]=M,b=M),p>R?W[c>>3]=p:p=R,M>m&&(W[Ne>>3]=M,m=M),D=M>0&Mk?M:k,X=X|+bn(+(M-_))>3.141592653589793,h=se+1|0,(h|0)!=(oe|0);)Ee=se,R=p,se=h,h=Ee;X&&(W[Ne>>3]=k,W[be>>3]=D)}}function uA(h){return h=h|0,(h>>>0<4?0:15)|0}function a2(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0;if(oe=f[h>>2]|0,oe){if(Ae=c+8|0,W[Ae>>3]=17976931348623157e292,be=c+24|0,W[be>>3]=17976931348623157e292,W[c>>3]=-17976931348623157e292,Ne=c+16|0,W[Ne>>3]=-17976931348623157e292,(oe|0)>0){for(_=f[h+4>>2]|0,re=17976931348623157e292,se=-17976931348623157e292,m=0,p=-1,R=17976931348623157e292,D=17976931348623157e292,X=-17976931348623157e292,b=-17976931348623157e292,Ee=0;y=+W[_+(Ee<<4)>>3],k=+W[_+(Ee<<4)+8>>3],Zt=p+2|0,M=+W[_+(((Zt|0)==(oe|0)?0:Zt)<<4)+8>>3],y>3]=y,R=y),k>3]=k,D=k),y>X?W[c>>3]=y:y=X,k>b&&(W[Ne>>3]=k,b=k),re=k>0&kse?k:se,m=m|+bn(+(k-M))>3.141592653589793,p=Ee+1|0,(p|0)!=(oe|0);)Zt=Ee,X=y,Ee=p,p=Zt;m&&(W[Ne>>3]=se,W[be>>3]=re)}}else f[c>>2]=0,f[c+4>>2]=0,f[c+8>>2]=0,f[c+12>>2]=0,f[c+16>>2]=0,f[c+20>>2]=0,f[c+24>>2]=0,f[c+28>>2]=0;if(Zt=h+8|0,p=f[Zt>>2]|0,!((p|0)<=0)){lt=h+12|0,me=0;do if(_=f[lt>>2]|0,m=me,me=me+1|0,be=c+(me<<5)|0,Ne=f[_+(m<<3)>>2]|0,Ne){if(Ee=c+(me<<5)+8|0,W[Ee>>3]=17976931348623157e292,h=c+(me<<5)+24|0,W[h>>3]=17976931348623157e292,W[be>>3]=-17976931348623157e292,we=c+(me<<5)+16|0,W[we>>3]=-17976931348623157e292,(Ne|0)>0){for(oe=f[_+(m<<3)+4>>2]|0,re=17976931348623157e292,se=-17976931348623157e292,_=0,m=-1,Ae=0,R=17976931348623157e292,D=17976931348623157e292,k=-17976931348623157e292,b=-17976931348623157e292;y=+W[oe+(Ae<<4)>>3],X=+W[oe+(Ae<<4)+8>>3],m=m+2|0,M=+W[oe+(((m|0)==(Ne|0)?0:m)<<4)+8>>3],y>3]=y,R=y),X>3]=X,D=X),y>k?W[be>>3]=y:y=k,X>b&&(W[we>>3]=X,b=X),re=X>0&Xse?X:se,_=_|+bn(+(X-M))>3.141592653589793,m=Ae+1|0,(m|0)!=(Ne|0);)Ft=Ae,Ae=m,k=y,m=Ft;_&&(W[we>>3]=se,W[h>>3]=re)}}else f[be>>2]=0,f[be+4>>2]=0,f[be+8>>2]=0,f[be+12>>2]=0,f[be+16>>2]=0,f[be+20>>2]=0,f[be+24>>2]=0,f[be+28>>2]=0,p=f[Zt>>2]|0;while((me|0)<(p|0))}}function l2(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;if(!(lA(h,c,p)|0))return _=0,_|0;if(_=h+8|0,(f[_>>2]|0)<=0)return _=1,_|0;for(m=h+12|0,h=0;;){if(y=h,h=h+1|0,lA((f[m>>2]|0)+(y<<3)|0,c+(h<<5)|0,p)|0){h=0,m=6;break}if((h|0)>=(f[_>>2]|0)){h=1,m=6;break}}return(m|0)==6?h|0:0}function lT(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0;if(D=z,z=z+16|0,M=D,b=p+8|0,!(lA(h,c,b)|0))return R=0,z=D,R|0;R=h+8|0;e:do if((f[R>>2]|0)>0){for(y=h+12|0,_=0;;){if(k=_,_=_+1|0,lA((f[y>>2]|0)+(k<<3)|0,c+(_<<5)|0,b)|0){_=0;break}if((_|0)>=(f[R>>2]|0))break e}return z=D,_|0}while(!1);if(kp(h,c,p,m)|0)return k=0,z=D,k|0;f[M>>2]=f[p>>2],f[M+4>>2]=b,_=f[R>>2]|0;e:do if((_|0)>0)for(h=h+12|0,b=0,y=_;;){if(_=f[h>>2]|0,(f[_+(b<<3)>>2]|0)>0){if(lA(M,m,f[_+(b<<3)+4>>2]|0)|0){_=0;break e}if(_=b+1|0,kp((f[h>>2]|0)+(b<<3)|0,c+(_<<5)|0,p,m)|0){_=0;break e}y=f[R>>2]|0}else _=b+1|0;if((_|0)<(y|0))b=_;else{_=1;break}}else _=1;while(!1);return k=_,z=D,k|0}function kp(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0,Zt=0,Ft=0,Mn=0;if(Zt=z,z=z+176|0,Ee=Zt+172|0,_=Zt+168|0,we=Zt,!(yc(c,m)|0))return h=0,z=Zt,h|0;if(Dp(c,m,Ee,_),qh(we|0,p|0,168)|0,(f[p>>2]|0)>0){c=0;do Ft=we+8+(c<<4)+8|0,Ne=+_o(+W[Ft>>3],f[_>>2]|0),W[Ft>>3]=Ne,c=c+1|0;while((c|0)<(f[p>>2]|0))}Ae=+W[m>>3],be=+W[m+8>>3],Ne=+_o(+W[m+16>>3],f[_>>2]|0),se=+_o(+W[m+24>>3],f[_>>2]|0);e:do if((f[h>>2]|0)>0){if(m=h+4|0,_=f[we>>2]|0,(_|0)<=0){for(c=0;;)if(c=c+1|0,(c|0)>=(f[h>>2]|0)){c=0;break e}}for(p=0;;){if(c=f[m>>2]|0,re=+W[c+(p<<4)>>3],oe=+_o(+W[c+(p<<4)+8>>3],f[Ee>>2]|0),c=f[m>>2]|0,p=p+1|0,Ft=(p|0)%(f[h>>2]|0)|0,y=+W[c+(Ft<<4)>>3],b=+_o(+W[c+(Ft<<4)+8>>3],f[Ee>>2]|0),!(re>=Ae)|!(y>=Ae)&&!(re<=be)|!(y<=be)&&!(oe<=se)|!(b<=se)&&!(oe>=Ne)|!(b>=Ne)){X=y-re,D=b-oe,c=0;do if(Mn=c,c=c+1|0,Ft=(c|0)==(_|0)?0:c,y=+W[we+8+(Mn<<4)+8>>3],b=+W[we+8+(Ft<<4)+8>>3]-y,M=+W[we+8+(Mn<<4)>>3],R=+W[we+8+(Ft<<4)>>3]-M,k=X*b-D*R,k!=0&&(me=oe-y,lt=re-M,R=(me*R-b*lt)/k,!(R<0|R>1))&&(k=(X*me-D*lt)/k,k>=0&k<=1)){c=1;break e}while((c|0)<(_|0))}if((p|0)>=(f[h>>2]|0)){c=0;break}}}else c=0;while(!1);return Mn=c,z=Zt,Mn|0}function uT(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0;if(kp(h,c,p,m)|0)return y=1,y|0;if(y=h+8|0,(f[y>>2]|0)<=0)return y=0,y|0;for(_=h+12|0,h=0;;){if(b=h,h=h+1|0,kp((f[_>>2]|0)+(b<<3)|0,c+(h<<5)|0,p,m)|0){h=1,_=6;break}if((h|0)>=(f[y>>2]|0)){h=0,_=6;break}}return(_|0)==6?h|0:0}function KL(){return 8}function ZL(){return 16}function JL(){return 168}function eI(){return 8}function tI(){return 16}function nI(){return 12}function iI(){return 8}function rI(h){return h=h|0,+(+((f[h>>2]|0)>>>0)+4294967296*+(f[h+4>>2]|0))}function sI(h){h=h|0;var c=0,p=0;return p=+W[h>>3],c=+W[h+8>>3],+ +Pn(+(p*p+c*c))}function cT(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0;D=+W[h>>3],R=+W[c>>3]-D,M=+W[h+8>>3],b=+W[c+8>>3]-M,X=+W[p>>3],y=+W[m>>3]-X,re=+W[p+8>>3],k=+W[m+8>>3]-re,y=(y*(M-re)-(D-X)*k)/(R*k-b*y),W[_>>3]=D+R*y,W[_+8>>3]=M+b*y}function hT(h,c){return h=h|0,c=c|0,+bn(+(+W[h>>3]-+W[c>>3]))<11920928955078125e-23?(c=+bn(+(+W[h+8>>3]-+W[c+8>>3]))<11920928955078125e-23,c|0):(c=0,c|0)}function Er(h,c){h=h|0,c=c|0;var p=0,m=0,_=0;return _=+W[h>>3]-+W[c>>3],m=+W[h+8>>3]-+W[c+8>>3],p=+W[h+16>>3]-+W[c+16>>3],+(_*_+m*m+p*p)}function oI(h,c){h=h|0,c=c|0;var p=0,m=0,_=0;p=+W[h>>3],m=+kn(+p),p=+_n(+p),W[c+16>>3]=p,p=+W[h+8>>3],_=m*+kn(+p),W[c>>3]=_,p=m*+_n(+p),W[c+8>>3]=p}function aI(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;if(y=z,z=z+16|0,_=y,m=Ni(h,c)|0,(p+-1|0)>>>0>5||(m=(m|0)!=0,(p|0)==1&m))return _=-1,z=y,_|0;do if(cA(h,c,_)|0)m=-1;else if(m){m=((f[26352+(p<<2)>>2]|0)+5-(f[_>>2]|0)|0)%5|0;break}else{m=((f[26384+(p<<2)>>2]|0)+6-(f[_>>2]|0)|0)%6|0;break}while(!1);return _=m,z=y,_|0}function cA(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0;if(k=z,z=z+32|0,M=k+16|0,R=k,m=Fh(h,c,M)|0,m|0)return p=m,z=k,p|0;y=YS(h,c)|0,D=Ys(h,c)|0,Np(y,R),m=_c(y,f[M>>2]|0)|0;do if(pi(y)|0){do switch(y|0){case 4:{_=0;break}case 14:{_=1;break}case 24:{_=2;break}case 38:{_=3;break}case 49:{_=4;break}case 58:{_=5;break}case 63:{_=6;break}case 72:{_=7;break}case 83:{_=8;break}case 97:{_=9;break}case 107:{_=10;break}case 117:{_=11;break}default:Fe(27795,27797,75,27806)}while(!1);if(b=f[26416+(_*24|0)+8>>2]|0,c=f[26416+(_*24|0)+16>>2]|0,h=f[M>>2]|0,(h|0)!=(f[R>>2]|0)&&(R=Dh(y)|0,h=f[M>>2]|0,R|(h|0)==(c|0)&&(m=(m+1|0)%6|0)),(D|0)==3&(h|0)==(c|0)){m=(m+5|0)%6|0;break}(D|0)==5&(h|0)==(b|0)&&(m=(m+1|0)%6|0)}while(!1);return f[p>>2]=m,p=0,z=k,p|0}function Oo(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0;if(we=z,z=z+32|0,Ee=we+24|0,be=we+20|0,oe=we+8|0,se=we+16|0,re=we,R=(Ni(h,c)|0)==0,R=R?6:5,k=Xe(h|0,c|0,52)|0,V()|0,k=k&15,R>>>0<=p>>>0)return m=2,z=we,m|0;X=(k|0)==0,!X&&(Ae=st(7,0,(k^15)*3|0)|0,(Ae&h|0)==0&((V()|0)&c|0)==0)?_=p:y=4;e:do if((y|0)==4){if(_=(Ni(h,c)|0)!=0,((_?4:5)|0)<(p|0)||cA(h,c,Ee)|0||(y=(f[Ee>>2]|0)+p|0,_?_=26704+(((y|0)%5|0)<<2)|0:_=26736+(((y|0)%6|0)<<2)|0,Ae=f[_>>2]|0,(Ae|0)==7))return m=1,z=we,m|0;f[be>>2]=0,_=Xn(h,c,Ae,be,oe)|0;do if(!_){if(M=oe,D=f[M>>2]|0,M=f[M+4>>2]|0,b=M>>>0>>0|(M|0)==(c|0)&D>>>0>>0,y=b?D:h,b=b?M:c,!X&&(X=st(7,0,(k^15)*3|0)|0,(D&X|0)==0&(M&(V()|0)|0)==0))_=p;else{if(M=(p+-1+R|0)%(R|0)|0,_=Ni(h,c)|0,(M|0)<0&&Fe(27795,27797,248,27822),R=(_|0)!=0,((R?4:5)|0)<(M|0)&&Fe(27795,27797,248,27822),cA(h,c,Ee)|0&&Fe(27795,27797,248,27822),_=(f[Ee>>2]|0)+M|0,R?_=26704+(((_|0)%5|0)<<2)|0:_=26736+(((_|0)%6|0)<<2)|0,M=f[_>>2]|0,(M|0)==7&&Fe(27795,27797,248,27822),f[se>>2]=0,_=Xn(h,c,M,se,re)|0,_|0)break;D=re,R=f[D>>2]|0,D=f[D+4>>2]|0;do if(D>>>0>>0|(D|0)==(b|0)&R>>>0>>0){if(Ni(R,D)|0?y=vr(R,D,h,c)|0:y=f[26800+((((f[se>>2]|0)+(f[26768+(M<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,_=Ni(R,D)|0,(y+-1|0)>>>0>5){_=-1,y=R,b=D;break}if(_=(_|0)!=0,(y|0)==1&_){_=-1,y=R,b=D;break}do if(cA(R,D,Ee)|0)_=-1;else if(_){_=((f[26352+(y<<2)>>2]|0)+5-(f[Ee>>2]|0)|0)%5|0;break}else{_=((f[26384+(y<<2)>>2]|0)+6-(f[Ee>>2]|0)|0)%6|0;break}while(!1);y=R,b=D}else _=p;while(!1);M=oe,D=f[M>>2]|0,M=f[M+4>>2]|0}if((y|0)==(D|0)&(b|0)==(M|0)){if(R=(Ni(D,M)|0)!=0,R?h=vr(D,M,h,c)|0:h=f[26800+((((f[be>>2]|0)+(f[26768+(Ae<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,_=Ni(D,M)|0,(h+-1|0)>>>0<=5&&(Ne=(_|0)!=0,!((h|0)==1&Ne)))do if(cA(D,M,Ee)|0)_=-1;else if(Ne){_=((f[26352+(h<<2)>>2]|0)+5-(f[Ee>>2]|0)|0)%5|0;break}else{_=((f[26384+(h<<2)>>2]|0)+6-(f[Ee>>2]|0)|0)%6|0;break}while(!1);else _=-1;_=_+1|0,_=(_|0)==6|R&(_|0)==5?0:_}c=b,h=y;break e}while(!1);return m=_,z=we,m|0}while(!1);return Ne=st(_|0,0,56)|0,Ee=V()|0|c&-2130706433|536870912,f[m>>2]=Ne|h,f[m+4>>2]=Ee,m=0,z=we,m|0}function lI(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;return y=(Ni(h,c)|0)==0,m=Oo(h,c,0,p)|0,_=(m|0)==0,y?!_||(m=Oo(h,c,1,p+8|0)|0,m|0)||(m=Oo(h,c,2,p+16|0)|0,m|0)||(m=Oo(h,c,3,p+24|0)|0,m|0)||(m=Oo(h,c,4,p+32|0)|0,m)?(y=m,y|0):Oo(h,c,5,p+40|0)|0:!_||(m=Oo(h,c,1,p+8|0)|0,m|0)||(m=Oo(h,c,2,p+16|0)|0,m|0)||(m=Oo(h,c,3,p+24|0)|0,m|0)||(m=Oo(h,c,4,p+32|0)|0,m|0)?(y=m,y|0):(y=p+40|0,f[y>>2]=0,f[y+4>>2]=0,y=0,y|0)}function uI(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0,M=0,R=0;return R=z,z=z+192|0,_=R,y=R+168|0,b=Xe(h|0,c|0,56)|0,V()|0,b=b&7,M=c&-2130706433|134217728,m=Fh(h,M,y)|0,m|0?(M=m,z=R,M|0):(c=Xe(h|0,c|0,52)|0,V()|0,c=c&15,Ni(h,M)|0?j_(y,c,b,1,_):X_(y,c,b,1,_),M=_+8|0,f[p>>2]=f[M>>2],f[p+4>>2]=f[M+4>>2],f[p+8>>2]=f[M+8>>2],f[p+12>>2]=f[M+12>>2],M=0,z=R,M|0)}function fT(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;return _=z,z=z+16|0,p=_,!(!0&(c&2013265920|0)==536870912)||(m=c&-2130706433|134217728,!(Q_(h,m)|0))?(m=0,z=_,m|0):(y=Xe(h|0,c|0,56)|0,V()|0,y=(Oo(h,m,y&7,p)|0)==0,m=p,m=y&((f[m>>2]|0)==(h|0)?(f[m+4>>2]|0)==(c|0):0)&1,z=_,m|0)}function dT(h,c,p){h=h|0,c=c|0,p=p|0;var m=0;(c|0)>0?(m=Ks(c,4)|0,f[h>>2]=m,m||Fe(27835,27858,40,27872)):f[h>>2]=0,f[h+4>>2]=c,f[h+8>>2]=0,f[h+12>>2]=p}function AT(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0;_=h+4|0,y=h+12|0,b=h+8|0;e:for(;;){for(p=f[_>>2]|0,c=0;;){if((c|0)>=(p|0))break e;if(m=f[h>>2]|0,M=f[m+(c<<2)>>2]|0,!M)c=c+1|0;else break}c=m+(~~(+bn(+(+ms(10,+ +(15-(f[y>>2]|0)|0))*(+W[M>>3]+ +W[M+8>>3])))%+(p|0))>>>0<<2)|0,p=f[c>>2]|0;t:do if(p|0){if(m=M+32|0,(p|0)==(M|0))f[c>>2]=f[m>>2];else{if(p=p+32|0,c=f[p>>2]|0,!c)break;for(;(c|0)!=(M|0);)if(p=c+32|0,c=f[p>>2]|0,!c)break t;f[p>>2]=f[m>>2]}on(M),f[b>>2]=(f[b>>2]|0)+-1}while(!1)}on(f[h>>2]|0)}function pT(h){h=h|0;var c=0,p=0,m=0;for(m=f[h+4>>2]|0,p=0;;){if((p|0)>=(m|0)){c=0,p=4;break}if(c=f[(f[h>>2]|0)+(p<<2)>>2]|0,!c)p=p+1|0;else{p=4;break}}return(p|0)==4?c|0:0}function mT(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;if(p=~~(+bn(+(+ms(10,+ +(15-(f[h+12>>2]|0)|0))*(+W[c>>3]+ +W[c+8>>3])))%+(f[h+4>>2]|0))>>>0,p=(f[h>>2]|0)+(p<<2)|0,m=f[p>>2]|0,!m)return y=1,y|0;y=c+32|0;do if((m|0)!=(c|0)){if(p=f[m+32>>2]|0,!p)return y=1,y|0;for(_=p;;){if((_|0)==(c|0)){_=8;break}if(p=f[_+32>>2]|0,p)m=_,_=p;else{p=1,_=10;break}}if((_|0)==8){f[m+32>>2]=f[y>>2];break}else if((_|0)==10)return p|0}else f[p>>2]=f[y>>2];while(!1);return on(c),y=h+8|0,f[y>>2]=(f[y>>2]|0)+-1,y=0,y|0}function cI(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;y=Oa(40)|0,y||Fe(27888,27858,98,27901),f[y>>2]=f[c>>2],f[y+4>>2]=f[c+4>>2],f[y+8>>2]=f[c+8>>2],f[y+12>>2]=f[c+12>>2],_=y+16|0,f[_>>2]=f[p>>2],f[_+4>>2]=f[p+4>>2],f[_+8>>2]=f[p+8>>2],f[_+12>>2]=f[p+12>>2],f[y+32>>2]=0,_=~~(+bn(+(+ms(10,+ +(15-(f[h+12>>2]|0)|0))*(+W[c>>3]+ +W[c+8>>3])))%+(f[h+4>>2]|0))>>>0,_=(f[h>>2]|0)+(_<<2)|0,m=f[_>>2]|0;do if(!m)f[_>>2]=y;else{for(;!(kh(m,c)|0&&kh(m+16|0,p)|0);)if(_=f[m+32>>2]|0,m=_|0?_:m,!(f[m+32>>2]|0)){b=10;break}if((b|0)==10){f[m+32>>2]=y;break}return on(y),b=m,b|0}while(!1);return b=h+8|0,f[b>>2]=(f[b>>2]|0)+1,b=y,b|0}function hI(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0;if(_=~~(+bn(+(+ms(10,+ +(15-(f[h+12>>2]|0)|0))*(+W[c>>3]+ +W[c+8>>3])))%+(f[h+4>>2]|0))>>>0,_=f[(f[h>>2]|0)+(_<<2)>>2]|0,!_)return p=0,p|0;if(!p){for(h=_;;){if(kh(h,c)|0){m=10;break}if(h=f[h+32>>2]|0,!h){h=0,m=10;break}}if((m|0)==10)return h|0}for(h=_;;){if(kh(h,c)|0&&kh(h+16|0,p)|0){m=10;break}if(h=f[h+32>>2]|0,!h){h=0,m=10;break}}return(m|0)==10?h|0:0}function fI(h,c){h=h|0,c=c|0;var p=0;if(p=~~(+bn(+(+ms(10,+ +(15-(f[h+12>>2]|0)|0))*(+W[c>>3]+ +W[c+8>>3])))%+(f[h+4>>2]|0))>>>0,h=f[(f[h>>2]|0)+(p<<2)>>2]|0,!h)return p=0,p|0;for(;;){if(kh(h,c)|0){c=5;break}if(h=f[h+32>>2]|0,!h){h=0,c=5;break}}return(c|0)==5?h|0:0}function dI(){return 27920}function xu(h){return h=+h,~~+xT(+h)|0}function Oa(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0,Ae=0,be=0,Ne=0,Ee=0,we=0,me=0,lt=0;lt=z,z=z+16|0,re=lt;do if(h>>>0<245){if(D=h>>>0<11?16:h+11&-8,h=D>>>3,X=f[6981]|0,p=X>>>h,p&3|0)return c=(p&1^1)+h|0,h=27964+(c<<1<<2)|0,p=h+8|0,m=f[p>>2]|0,_=m+8|0,y=f[_>>2]|0,(y|0)==(h|0)?f[6981]=X&~(1<>2]=h,f[p>>2]=y),me=c<<3,f[m+4>>2]=me|3,me=m+me+4|0,f[me>>2]=f[me>>2]|1,me=_,z=lt,me|0;if(k=f[6983]|0,D>>>0>k>>>0){if(p|0)return c=2<>>12&16,c=c>>>M,p=c>>>5&8,c=c>>>p,y=c>>>2&4,c=c>>>y,h=c>>>1&2,c=c>>>h,m=c>>>1&1,m=(p|M|y|h|m)+(c>>>m)|0,c=27964+(m<<1<<2)|0,h=c+8|0,y=f[h>>2]|0,M=y+8|0,p=f[M>>2]|0,(p|0)==(c|0)?(h=X&~(1<>2]=c,f[h>>2]=p,h=X),me=m<<3,b=me-D|0,f[y+4>>2]=D|3,_=y+D|0,f[_+4>>2]=b|1,f[y+me>>2]=b,k|0&&(m=f[6986]|0,c=k>>>3,p=27964+(c<<1<<2)|0,c=1<>2]|0):(f[6981]=h|c,c=p,h=p+8|0),f[h>>2]=m,f[c+12>>2]=m,f[m+8>>2]=c,f[m+12>>2]=p),f[6983]=b,f[6986]=_,me=M,z=lt,me|0;if(y=f[6982]|0,y){for(p=(y&0-y)+-1|0,_=p>>>12&16,p=p>>>_,m=p>>>5&8,p=p>>>m,b=p>>>2&4,p=p>>>b,M=p>>>1&2,p=p>>>M,R=p>>>1&1,R=f[28228+((m|_|b|M|R)+(p>>>R)<<2)>>2]|0,p=R,M=R,R=(f[R+4>>2]&-8)-D|0;h=f[p+16>>2]|0,!(!h&&(h=f[p+20>>2]|0,!h));)b=(f[h+4>>2]&-8)-D|0,_=b>>>0>>0,p=h,M=_?h:M,R=_?b:R;if(b=M+D|0,b>>>0>M>>>0){_=f[M+24>>2]|0,c=f[M+12>>2]|0;do if((c|0)==(M|0)){if(h=M+20|0,c=f[h>>2]|0,!c&&(h=M+16|0,c=f[h>>2]|0,!c)){p=0;break}for(;;)if(m=c+20|0,p=f[m>>2]|0,p)c=p,h=m;else if(m=c+16|0,p=f[m>>2]|0,p)c=p,h=m;else break;f[h>>2]=0,p=c}else p=f[M+8>>2]|0,f[p+12>>2]=c,f[c+8>>2]=p,p=c;while(!1);do if(_|0){if(c=f[M+28>>2]|0,h=28228+(c<<2)|0,(M|0)==(f[h>>2]|0)){if(f[h>>2]=p,!p){f[6982]=y&~(1<>2]|0)==(M|0)?me:_+20|0)>>2]=p,!p)break;f[p+24>>2]=_,c=f[M+16>>2]|0,c|0&&(f[p+16>>2]=c,f[c+24>>2]=p),c=f[M+20>>2]|0,c|0&&(f[p+20>>2]=c,f[c+24>>2]=p)}while(!1);return R>>>0<16?(me=R+D|0,f[M+4>>2]=me|3,me=M+me+4|0,f[me>>2]=f[me>>2]|1):(f[M+4>>2]=D|3,f[b+4>>2]=R|1,f[b+R>>2]=R,k|0&&(m=f[6986]|0,c=k>>>3,p=27964+(c<<1<<2)|0,c=1<>2]|0):(f[6981]=c|X,c=p,h=p+8|0),f[h>>2]=m,f[c+12>>2]=m,f[m+8>>2]=c,f[m+12>>2]=p),f[6983]=R,f[6986]=b),me=M+8|0,z=lt,me|0}else X=D}else X=D}else X=D}else if(h>>>0<=4294967231)if(h=h+11|0,D=h&-8,m=f[6982]|0,m){_=0-D|0,h=h>>>8,h?D>>>0>16777215?R=31:(X=(h+1048320|0)>>>16&8,Ae=h<>>16&4,Ae=Ae<>>16&2,R=14-(M|X|R)+(Ae<>>15)|0,R=D>>>(R+7|0)&1|R<<1):R=0,p=f[28228+(R<<2)>>2]|0;e:do if(!p)p=0,h=0,Ae=61;else for(h=0,M=D<<((R|0)==31?0:25-(R>>>1)|0),y=0;;){if(b=(f[p+4>>2]&-8)-D|0,b>>>0<_>>>0)if(b)h=p,_=b;else{h=p,_=0,Ae=65;break e}if(Ae=f[p+20>>2]|0,p=f[p+16+(M>>>31<<2)>>2]|0,y=(Ae|0)==0|(Ae|0)==(p|0)?y:Ae,p)M=M<<1;else{p=y,Ae=61;break}}while(!1);if((Ae|0)==61){if((p|0)==0&(h|0)==0){if(h=2<>>12&16,X=X>>>b,y=X>>>5&8,X=X>>>y,M=X>>>2&4,X=X>>>M,R=X>>>1&2,X=X>>>R,p=X>>>1&1,h=0,p=f[28228+((y|b|M|R|p)+(X>>>p)<<2)>>2]|0}p?Ae=65:(M=h,b=_)}if((Ae|0)==65)for(y=p;;)if(X=(f[y+4>>2]&-8)-D|0,p=X>>>0<_>>>0,_=p?X:_,h=p?y:h,p=f[y+16>>2]|0,p||(p=f[y+20>>2]|0),p)y=p;else{M=h,b=_;break}if(M|0&&b>>>0<((f[6983]|0)-D|0)>>>0&&(k=M+D|0,k>>>0>M>>>0)){y=f[M+24>>2]|0,c=f[M+12>>2]|0;do if((c|0)==(M|0)){if(h=M+20|0,c=f[h>>2]|0,!c&&(h=M+16|0,c=f[h>>2]|0,!c)){c=0;break}for(;;)if(_=c+20|0,p=f[_>>2]|0,p)c=p,h=_;else if(_=c+16|0,p=f[_>>2]|0,p)c=p,h=_;else break;f[h>>2]=0}else me=f[M+8>>2]|0,f[me+12>>2]=c,f[c+8>>2]=me;while(!1);do if(y){if(h=f[M+28>>2]|0,p=28228+(h<<2)|0,(M|0)==(f[p>>2]|0)){if(f[p>>2]=c,!c){m=m&~(1<>2]|0)==(M|0)?me:y+20|0)>>2]=c,!c)break;f[c+24>>2]=y,h=f[M+16>>2]|0,h|0&&(f[c+16>>2]=h,f[h+24>>2]=c),h=f[M+20>>2]|0,h&&(f[c+20>>2]=h,f[h+24>>2]=c)}while(!1);e:do if(b>>>0<16)me=b+D|0,f[M+4>>2]=me|3,me=M+me+4|0,f[me>>2]=f[me>>2]|1;else{if(f[M+4>>2]=D|3,f[k+4>>2]=b|1,f[k+b>>2]=b,c=b>>>3,b>>>0<256){p=27964+(c<<1<<2)|0,h=f[6981]|0,c=1<>2]|0):(f[6981]=h|c,c=p,h=p+8|0),f[h>>2]=k,f[c+12>>2]=k,f[k+8>>2]=c,f[k+12>>2]=p;break}if(c=b>>>8,c?b>>>0>16777215?p=31:(we=(c+1048320|0)>>>16&8,me=c<>>16&4,me=me<>>16&2,p=14-(Ee|we|p)+(me<

>>15)|0,p=b>>>(p+7|0)&1|p<<1):p=0,c=28228+(p<<2)|0,f[k+28>>2]=p,h=k+16|0,f[h+4>>2]=0,f[h>>2]=0,h=1<>2]=k,f[k+24>>2]=c,f[k+12>>2]=k,f[k+8>>2]=k;break}c=f[c>>2]|0;t:do if((f[c+4>>2]&-8|0)!=(b|0)){for(m=b<<((p|0)==31?0:25-(p>>>1)|0);p=c+16+(m>>>31<<2)|0,h=f[p>>2]|0,!!h;)if((f[h+4>>2]&-8|0)==(b|0)){c=h;break t}else m=m<<1,c=h;f[p>>2]=k,f[k+24>>2]=c,f[k+12>>2]=k,f[k+8>>2]=k;break e}while(!1);we=c+8|0,me=f[we>>2]|0,f[me+12>>2]=k,f[we>>2]=k,f[k+8>>2]=me,f[k+12>>2]=c,f[k+24>>2]=0}while(!1);return me=M+8|0,z=lt,me|0}else X=D}else X=D;else X=-1;while(!1);if(p=f[6983]|0,p>>>0>=X>>>0)return c=p-X|0,h=f[6986]|0,c>>>0>15?(me=h+X|0,f[6986]=me,f[6983]=c,f[me+4>>2]=c|1,f[h+p>>2]=c,f[h+4>>2]=X|3):(f[6983]=0,f[6986]=0,f[h+4>>2]=p|3,me=h+p+4|0,f[me>>2]=f[me>>2]|1),me=h+8|0,z=lt,me|0;if(b=f[6984]|0,b>>>0>X>>>0)return Ee=b-X|0,f[6984]=Ee,me=f[6987]|0,we=me+X|0,f[6987]=we,f[we+4>>2]=Ee|1,f[me+4>>2]=X|3,me=me+8|0,z=lt,me|0;if(f[7099]|0?h=f[7101]|0:(f[7101]=4096,f[7100]=4096,f[7102]=-1,f[7103]=-1,f[7104]=0,f[7092]=0,f[7099]=re&-16^1431655768,h=4096),M=X+48|0,R=X+47|0,y=h+R|0,_=0-h|0,D=y&_,D>>>0<=X>>>0||(h=f[7091]|0,h|0&&(k=f[7089]|0,re=k+D|0,re>>>0<=k>>>0|re>>>0>h>>>0)))return me=0,z=lt,me|0;e:do if(f[7092]&4)c=0,Ae=143;else{p=f[6987]|0;t:do if(p){for(m=28372;re=f[m>>2]|0,!(re>>>0<=p>>>0&&(re+(f[m+4>>2]|0)|0)>>>0>p>>>0);)if(h=f[m+8>>2]|0,h)m=h;else{Ae=128;break t}if(c=y-b&_,c>>>0<2147483647)if(h=Su(c|0)|0,(h|0)==((f[m>>2]|0)+(f[m+4>>2]|0)|0)){if((h|0)!=-1){b=c,y=h,Ae=145;break e}}else m=h,Ae=136;else c=0}else Ae=128;while(!1);do if((Ae|0)==128)if(p=Su(0)|0,(p|0)!=-1&&(c=p,se=f[7100]|0,oe=se+-1|0,c=(oe&c|0?(oe+c&0-se)-c|0:0)+D|0,se=f[7089]|0,oe=c+se|0,c>>>0>X>>>0&c>>>0<2147483647)){if(re=f[7091]|0,re|0&&oe>>>0<=se>>>0|oe>>>0>re>>>0){c=0;break}if(h=Su(c|0)|0,(h|0)==(p|0)){b=c,y=p,Ae=145;break e}else m=h,Ae=136}else c=0;while(!1);do if((Ae|0)==136){if(p=0-c|0,!(M>>>0>c>>>0&(c>>>0<2147483647&(m|0)!=-1)))if((m|0)==-1){c=0;break}else{b=c,y=m,Ae=145;break e}if(h=f[7101]|0,h=R-c+h&0-h,h>>>0>=2147483647){b=c,y=m,Ae=145;break e}if((Su(h|0)|0)==-1){Su(p|0)|0,c=0;break}else{b=h+c|0,y=m,Ae=145;break e}}while(!1);f[7092]=f[7092]|4,Ae=143}while(!1);if((Ae|0)==143&&D>>>0<2147483647&&(Ee=Su(D|0)|0,oe=Su(0)|0,be=oe-Ee|0,Ne=be>>>0>(X+40|0)>>>0,!((Ee|0)==-1|Ne^1|Ee>>>0>>0&((Ee|0)!=-1&(oe|0)!=-1)^1))&&(b=Ne?be:c,y=Ee,Ae=145),(Ae|0)==145){c=(f[7089]|0)+b|0,f[7089]=c,c>>>0>(f[7090]|0)>>>0&&(f[7090]=c),R=f[6987]|0;e:do if(R){for(c=28372;;){if(h=f[c>>2]|0,p=f[c+4>>2]|0,(y|0)==(h+p|0)){Ae=154;break}if(m=f[c+8>>2]|0,m)c=m;else break}if((Ae|0)==154&&(we=c+4|0,(f[c+12>>2]&8|0)==0)&&y>>>0>R>>>0&h>>>0<=R>>>0){f[we>>2]=p+b,me=(f[6984]|0)+b|0,Ee=R+8|0,Ee=Ee&7|0?0-Ee&7:0,we=R+Ee|0,Ee=me-Ee|0,f[6987]=we,f[6984]=Ee,f[we+4>>2]=Ee|1,f[R+me+4>>2]=40,f[6988]=f[7103];break}for(y>>>0<(f[6985]|0)>>>0&&(f[6985]=y),p=y+b|0,c=28372;;){if((f[c>>2]|0)==(p|0)){Ae=162;break}if(h=f[c+8>>2]|0,h)c=h;else break}if((Ae|0)==162&&!(f[c+12>>2]&8|0)){f[c>>2]=y,k=c+4|0,f[k>>2]=(f[k>>2]|0)+b,k=y+8|0,k=y+(k&7|0?0-k&7:0)|0,c=p+8|0,c=p+(c&7|0?0-c&7:0)|0,D=k+X|0,M=c-k-X|0,f[k+4>>2]=X|3;t:do if((R|0)==(c|0))me=(f[6984]|0)+M|0,f[6984]=me,f[6987]=D,f[D+4>>2]=me|1;else{if((f[6986]|0)==(c|0)){me=(f[6983]|0)+M|0,f[6983]=me,f[6986]=D,f[D+4>>2]=me|1,f[D+me>>2]=me;break}if(h=f[c+4>>2]|0,(h&3|0)==1){b=h&-8,m=h>>>3;n:do if(h>>>0<256)if(h=f[c+8>>2]|0,p=f[c+12>>2]|0,(p|0)==(h|0)){f[6981]=f[6981]&~(1<>2]=p,f[p+8>>2]=h;break}else{y=f[c+24>>2]|0,h=f[c+12>>2]|0;do if((h|0)==(c|0)){if(p=c+16|0,m=p+4|0,h=f[m>>2]|0,h)p=m;else if(h=f[p>>2]|0,!h){h=0;break}for(;;)if(_=h+20|0,m=f[_>>2]|0,m)h=m,p=_;else if(_=h+16|0,m=f[_>>2]|0,m)h=m,p=_;else break;f[p>>2]=0}else me=f[c+8>>2]|0,f[me+12>>2]=h,f[h+8>>2]=me;while(!1);if(!y)break;p=f[c+28>>2]|0,m=28228+(p<<2)|0;do if((f[m>>2]|0)!=(c|0)){if(me=y+16|0,f[((f[me>>2]|0)==(c|0)?me:y+20|0)>>2]=h,!h)break n}else{if(f[m>>2]=h,h|0)break;f[6982]=f[6982]&~(1<>2]=y,p=c+16|0,m=f[p>>2]|0,m|0&&(f[h+16>>2]=m,f[m+24>>2]=h),p=f[p+4>>2]|0,!p)break;f[h+20>>2]=p,f[p+24>>2]=h}while(!1);c=c+b|0,_=b+M|0}else _=M;if(c=c+4|0,f[c>>2]=f[c>>2]&-2,f[D+4>>2]=_|1,f[D+_>>2]=_,c=_>>>3,_>>>0<256){p=27964+(c<<1<<2)|0,h=f[6981]|0,c=1<>2]|0):(f[6981]=h|c,c=p,h=p+8|0),f[h>>2]=D,f[c+12>>2]=D,f[D+8>>2]=c,f[D+12>>2]=p;break}c=_>>>8;do if(!c)m=0;else{if(_>>>0>16777215){m=31;break}we=(c+1048320|0)>>>16&8,me=c<>>16&4,me=me<>>16&2,m=14-(Ee|we|m)+(me<>>15)|0,m=_>>>(m+7|0)&1|m<<1}while(!1);if(c=28228+(m<<2)|0,f[D+28>>2]=m,h=D+16|0,f[h+4>>2]=0,f[h>>2]=0,h=f[6982]|0,p=1<>2]=D,f[D+24>>2]=c,f[D+12>>2]=D,f[D+8>>2]=D;break}c=f[c>>2]|0;n:do if((f[c+4>>2]&-8|0)!=(_|0)){for(m=_<<((m|0)==31?0:25-(m>>>1)|0);p=c+16+(m>>>31<<2)|0,h=f[p>>2]|0,!!h;)if((f[h+4>>2]&-8|0)==(_|0)){c=h;break n}else m=m<<1,c=h;f[p>>2]=D,f[D+24>>2]=c,f[D+12>>2]=D,f[D+8>>2]=D;break t}while(!1);we=c+8|0,me=f[we>>2]|0,f[me+12>>2]=D,f[we>>2]=D,f[D+8>>2]=me,f[D+12>>2]=c,f[D+24>>2]=0}while(!1);return me=k+8|0,z=lt,me|0}for(c=28372;h=f[c>>2]|0,!(h>>>0<=R>>>0&&(me=h+(f[c+4>>2]|0)|0,me>>>0>R>>>0));)c=f[c+8>>2]|0;_=me+-47|0,h=_+8|0,h=_+(h&7|0?0-h&7:0)|0,_=R+16|0,h=h>>>0<_>>>0?R:h,c=h+8|0,p=b+-40|0,Ee=y+8|0,Ee=Ee&7|0?0-Ee&7:0,we=y+Ee|0,Ee=p-Ee|0,f[6987]=we,f[6984]=Ee,f[we+4>>2]=Ee|1,f[y+p+4>>2]=40,f[6988]=f[7103],p=h+4|0,f[p>>2]=27,f[c>>2]=f[7093],f[c+4>>2]=f[7094],f[c+8>>2]=f[7095],f[c+12>>2]=f[7096],f[7093]=y,f[7094]=b,f[7096]=0,f[7095]=c,c=h+24|0;do we=c,c=c+4|0,f[c>>2]=7;while((we+8|0)>>>0>>0);if((h|0)!=(R|0)){if(y=h-R|0,f[p>>2]=f[p>>2]&-2,f[R+4>>2]=y|1,f[h>>2]=y,c=y>>>3,y>>>0<256){p=27964+(c<<1<<2)|0,h=f[6981]|0,c=1<>2]|0):(f[6981]=h|c,c=p,h=p+8|0),f[h>>2]=R,f[c+12>>2]=R,f[R+8>>2]=c,f[R+12>>2]=p;break}if(c=y>>>8,c?y>>>0>16777215?m=31:(we=(c+1048320|0)>>>16&8,me=c<>>16&4,me=me<>>16&2,m=14-(Ee|we|m)+(me<>>15)|0,m=y>>>(m+7|0)&1|m<<1):m=0,p=28228+(m<<2)|0,f[R+28>>2]=m,f[R+20>>2]=0,f[_>>2]=0,c=f[6982]|0,h=1<>2]=R,f[R+24>>2]=p,f[R+12>>2]=R,f[R+8>>2]=R;break}c=f[p>>2]|0;t:do if((f[c+4>>2]&-8|0)!=(y|0)){for(m=y<<((m|0)==31?0:25-(m>>>1)|0);p=c+16+(m>>>31<<2)|0,h=f[p>>2]|0,!!h;)if((f[h+4>>2]&-8|0)==(y|0)){c=h;break t}else m=m<<1,c=h;f[p>>2]=R,f[R+24>>2]=c,f[R+12>>2]=R,f[R+8>>2]=R;break e}while(!1);we=c+8|0,me=f[we>>2]|0,f[me+12>>2]=R,f[we>>2]=R,f[R+8>>2]=me,f[R+12>>2]=c,f[R+24>>2]=0}}else me=f[6985]|0,(me|0)==0|y>>>0>>0&&(f[6985]=y),f[7093]=y,f[7094]=b,f[7096]=0,f[6990]=f[7099],f[6989]=-1,f[6994]=27964,f[6993]=27964,f[6996]=27972,f[6995]=27972,f[6998]=27980,f[6997]=27980,f[7e3]=27988,f[6999]=27988,f[7002]=27996,f[7001]=27996,f[7004]=28004,f[7003]=28004,f[7006]=28012,f[7005]=28012,f[7008]=28020,f[7007]=28020,f[7010]=28028,f[7009]=28028,f[7012]=28036,f[7011]=28036,f[7014]=28044,f[7013]=28044,f[7016]=28052,f[7015]=28052,f[7018]=28060,f[7017]=28060,f[7020]=28068,f[7019]=28068,f[7022]=28076,f[7021]=28076,f[7024]=28084,f[7023]=28084,f[7026]=28092,f[7025]=28092,f[7028]=28100,f[7027]=28100,f[7030]=28108,f[7029]=28108,f[7032]=28116,f[7031]=28116,f[7034]=28124,f[7033]=28124,f[7036]=28132,f[7035]=28132,f[7038]=28140,f[7037]=28140,f[7040]=28148,f[7039]=28148,f[7042]=28156,f[7041]=28156,f[7044]=28164,f[7043]=28164,f[7046]=28172,f[7045]=28172,f[7048]=28180,f[7047]=28180,f[7050]=28188,f[7049]=28188,f[7052]=28196,f[7051]=28196,f[7054]=28204,f[7053]=28204,f[7056]=28212,f[7055]=28212,me=b+-40|0,Ee=y+8|0,Ee=Ee&7|0?0-Ee&7:0,we=y+Ee|0,Ee=me-Ee|0,f[6987]=we,f[6984]=Ee,f[we+4>>2]=Ee|1,f[y+me+4>>2]=40,f[6988]=f[7103];while(!1);if(c=f[6984]|0,c>>>0>X>>>0)return Ee=c-X|0,f[6984]=Ee,me=f[6987]|0,we=me+X|0,f[6987]=we,f[we+4>>2]=Ee|1,f[me+4>>2]=X|3,me=me+8|0,z=lt,me|0}return me=dI()|0,f[me>>2]=12,me=0,z=lt,me|0}function on(h){h=h|0;var c=0,p=0,m=0,_=0,y=0,b=0,M=0,R=0;if(h){p=h+-8|0,_=f[6985]|0,h=f[h+-4>>2]|0,c=h&-8,R=p+c|0;do if(h&1)M=p,b=p;else{if(m=f[p>>2]|0,!(h&3)||(b=p+(0-m)|0,y=m+c|0,b>>>0<_>>>0))return;if((f[6986]|0)==(b|0)){if(h=R+4|0,c=f[h>>2]|0,(c&3|0)!=3){M=b,c=y;break}f[6983]=y,f[h>>2]=c&-2,f[b+4>>2]=y|1,f[b+y>>2]=y;return}if(p=m>>>3,m>>>0<256)if(h=f[b+8>>2]|0,c=f[b+12>>2]|0,(c|0)==(h|0)){f[6981]=f[6981]&~(1<>2]=c,f[c+8>>2]=h,M=b,c=y;break}_=f[b+24>>2]|0,h=f[b+12>>2]|0;do if((h|0)==(b|0)){if(c=b+16|0,p=c+4|0,h=f[p>>2]|0,h)c=p;else if(h=f[c>>2]|0,!h){h=0;break}for(;;)if(m=h+20|0,p=f[m>>2]|0,p)h=p,c=m;else if(m=h+16|0,p=f[m>>2]|0,p)h=p,c=m;else break;f[c>>2]=0}else M=f[b+8>>2]|0,f[M+12>>2]=h,f[h+8>>2]=M;while(!1);if(_){if(c=f[b+28>>2]|0,p=28228+(c<<2)|0,(f[p>>2]|0)==(b|0)){if(f[p>>2]=h,!h){f[6982]=f[6982]&~(1<>2]|0)==(b|0)?M:_+20|0)>>2]=h,!h){M=b,c=y;break}f[h+24>>2]=_,c=b+16|0,p=f[c>>2]|0,p|0&&(f[h+16>>2]=p,f[p+24>>2]=h),c=f[c+4>>2]|0,c?(f[h+20>>2]=c,f[c+24>>2]=h,M=b,c=y):(M=b,c=y)}else M=b,c=y}while(!1);if(!(b>>>0>=R>>>0)&&(h=R+4|0,m=f[h>>2]|0,!!(m&1))){if(m&2)f[h>>2]=m&-2,f[M+4>>2]=c|1,f[b+c>>2]=c,_=c;else{if((f[6987]|0)==(R|0)){if(R=(f[6984]|0)+c|0,f[6984]=R,f[6987]=M,f[M+4>>2]=R|1,(M|0)!=(f[6986]|0))return;f[6986]=0,f[6983]=0;return}if((f[6986]|0)==(R|0)){R=(f[6983]|0)+c|0,f[6983]=R,f[6986]=b,f[M+4>>2]=R|1,f[b+R>>2]=R;return}_=(m&-8)+c|0,p=m>>>3;do if(m>>>0<256)if(c=f[R+8>>2]|0,h=f[R+12>>2]|0,(h|0)==(c|0)){f[6981]=f[6981]&~(1<>2]=h,f[h+8>>2]=c;break}else{y=f[R+24>>2]|0,h=f[R+12>>2]|0;do if((h|0)==(R|0)){if(c=R+16|0,p=c+4|0,h=f[p>>2]|0,h)c=p;else if(h=f[c>>2]|0,!h){p=0;break}for(;;)if(m=h+20|0,p=f[m>>2]|0,p)h=p,c=m;else if(m=h+16|0,p=f[m>>2]|0,p)h=p,c=m;else break;f[c>>2]=0,p=h}else p=f[R+8>>2]|0,f[p+12>>2]=h,f[h+8>>2]=p,p=h;while(!1);if(y|0){if(h=f[R+28>>2]|0,c=28228+(h<<2)|0,(f[c>>2]|0)==(R|0)){if(f[c>>2]=p,!p){f[6982]=f[6982]&~(1<>2]|0)==(R|0)?m:y+20|0)>>2]=p,!p)break;f[p+24>>2]=y,h=R+16|0,c=f[h>>2]|0,c|0&&(f[p+16>>2]=c,f[c+24>>2]=p),h=f[h+4>>2]|0,h|0&&(f[p+20>>2]=h,f[h+24>>2]=p)}}while(!1);if(f[M+4>>2]=_|1,f[b+_>>2]=_,(M|0)==(f[6986]|0)){f[6983]=_;return}}if(h=_>>>3,_>>>0<256){p=27964+(h<<1<<2)|0,c=f[6981]|0,h=1<>2]|0):(f[6981]=c|h,h=p,c=p+8|0),f[c>>2]=M,f[h+12>>2]=M,f[M+8>>2]=h,f[M+12>>2]=p;return}h=_>>>8,h?_>>>0>16777215?m=31:(b=(h+1048320|0)>>>16&8,R=h<>>16&4,R=R<>>16&2,m=14-(y|b|m)+(R<>>15)|0,m=_>>>(m+7|0)&1|m<<1):m=0,h=28228+(m<<2)|0,f[M+28>>2]=m,f[M+20>>2]=0,f[M+16>>2]=0,c=f[6982]|0,p=1<>2]=M,f[M+24>>2]=h,f[M+12>>2]=M,f[M+8>>2]=M;else{h=f[h>>2]|0;t:do if((f[h+4>>2]&-8|0)!=(_|0)){for(m=_<<((m|0)==31?0:25-(m>>>1)|0);p=h+16+(m>>>31<<2)|0,c=f[p>>2]|0,!!c;)if((f[c+4>>2]&-8|0)==(_|0)){h=c;break t}else m=m<<1,h=c;f[p>>2]=M,f[M+24>>2]=h,f[M+12>>2]=M,f[M+8>>2]=M;break e}while(!1);b=h+8|0,R=f[b>>2]|0,f[R+12>>2]=M,f[b>>2]=M,f[M+8>>2]=R,f[M+12>>2]=h,f[M+24>>2]=0}while(!1);if(R=(f[6989]|0)+-1|0,f[6989]=R,!(R|0)){for(h=28380;h=f[h>>2]|0,h;)h=h+8|0;f[6989]=-1}}}}function Ks(h,c){h=h|0,c=c|0;var p=0;return h?(p=gs(c,h)|0,(c|h)>>>0>65535&&(p=((p>>>0)/(h>>>0)|0|0)==(c|0)?p:-1)):p=0,h=Oa(p)|0,!h||!(f[h+-4>>2]&3)||bu(h|0,0,p|0)|0,h|0}function sn(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,p=h+p>>>0,xe(c+m+(p>>>0>>0|0)>>>0|0),p|0|0}function Gr(h,c,p,m){return h=h|0,c=c|0,p=p|0,m=m|0,m=c-m-(p>>>0>h>>>0|0)>>>0,xe(m|0),h-p>>>0|0|0}function gT(h){return h=h|0,(h?31-(Ce(h^h-1)|0)|0:32)|0}function u2(h,c,p,m,_){h=h|0,c=c|0,p=p|0,m=m|0,_=_|0;var y=0,b=0,M=0,R=0,D=0,k=0,X=0,re=0,se=0,oe=0;if(k=h,R=c,D=R,b=p,re=m,M=re,!D)return y=(_|0)!=0,M?y?(f[_>>2]=h|0,f[_+4>>2]=c&0,re=0,_=0,xe(re|0),_|0):(re=0,_=0,xe(re|0),_|0):(y&&(f[_>>2]=(k>>>0)%(b>>>0),f[_+4>>2]=0),re=0,_=(k>>>0)/(b>>>0)>>>0,xe(re|0),_|0);y=(M|0)==0;do if(b){if(!y){if(y=(Ce(M|0)|0)-(Ce(D|0)|0)|0,y>>>0<=31){X=y+1|0,M=31-y|0,c=y-31>>31,b=X,h=k>>>(X>>>0)&c|D<>>(X>>>0)&c,y=0,M=k<>2]=h|0,f[_+4>>2]=R|c&0,re=0,_=0,xe(re|0),_|0):(re=0,_=0,xe(re|0),_|0)}if(y=b-1|0,y&b|0){M=(Ce(b|0)|0)+33-(Ce(D|0)|0)|0,oe=64-M|0,X=32-M|0,R=X>>31,se=M-32|0,c=se>>31,b=M,h=X-1>>31&D>>>(se>>>0)|(D<>>(M>>>0))&c,c=c&D>>>(M>>>0),y=k<>>(se>>>0))&R|k<>31;break}return _|0&&(f[_>>2]=y&k,f[_+4>>2]=0),(b|0)==1?(se=R|c&0,oe=h|0|0,xe(se|0),oe|0):(oe=gT(b|0)|0,se=D>>>(oe>>>0)|0,oe=D<<32-oe|k>>>(oe>>>0)|0,xe(se|0),oe|0)}else{if(y)return _|0&&(f[_>>2]=(D>>>0)%(b>>>0),f[_+4>>2]=0),se=0,oe=(D>>>0)/(b>>>0)>>>0,xe(se|0),oe|0;if(!k)return _|0&&(f[_>>2]=0,f[_+4>>2]=(D>>>0)%(M>>>0)),se=0,oe=(D>>>0)/(M>>>0)>>>0,xe(se|0),oe|0;if(y=M-1|0,!(y&M))return _|0&&(f[_>>2]=h|0,f[_+4>>2]=y&D|c&0),se=0,oe=D>>>((gT(M|0)|0)>>>0),xe(se|0),oe|0;if(y=(Ce(M|0)|0)-(Ce(D|0)|0)|0,y>>>0<=30){c=y+1|0,M=31-y|0,b=c,h=D<>>(c>>>0),c=D>>>(c>>>0),y=0,M=k<>2]=h|0,f[_+4>>2]=R|c&0,se=0,oe=0,xe(se|0),oe|0):(se=0,oe=0,xe(se|0),oe|0)}while(!1);if(!b)D=M,R=0,M=0;else{X=p|0|0,k=re|m&0,D=sn(X|0,k|0,-1,-1)|0,p=V()|0,R=M,M=0;do m=R,R=y>>>31|R<<1,y=M|y<<1,m=h<<1|m>>>31|0,re=h>>>31|c<<1|0,Gr(D|0,p|0,m|0,re|0)|0,oe=V()|0,se=oe>>31|((oe|0)<0?-1:0)<<1,M=se&1,h=Gr(m|0,re|0,se&X|0,(((oe|0)<0?-1:0)>>31|((oe|0)<0?-1:0)<<1)&k|0)|0,c=V()|0,b=b-1|0;while(b|0);D=R,R=0}return b=0,_|0&&(f[_>>2]=h,f[_+4>>2]=c),se=(y|0)>>>31|(D|b)<<1|(b<<1|y>>>31)&0|R,oe=(y<<1|0)&-2|M,xe(se|0),oe|0}function yu(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0;return D=c>>31|((c|0)<0?-1:0)<<1,R=((c|0)<0?-1:0)>>31|((c|0)<0?-1:0)<<1,y=m>>31|((m|0)<0?-1:0)<<1,_=((m|0)<0?-1:0)>>31|((m|0)<0?-1:0)<<1,M=Gr(D^h|0,R^c|0,D|0,R|0)|0,b=V()|0,h=y^D,c=_^R,Gr((u2(M,b,Gr(y^p|0,_^m|0,y|0,_|0)|0,V()|0,0)|0)^h|0,(V()|0)^c|0,h|0,c|0)|0}function AI(h,c){h=h|0,c=c|0;var p=0,m=0,_=0,y=0;return y=h&65535,_=c&65535,p=gs(_,y)|0,m=h>>>16,h=(p>>>16)+(gs(_,m)|0)|0,_=c>>>16,c=gs(_,y)|0,xe((h>>>16)+(gs(_,m)|0)+(((h&65535)+c|0)>>>16)|0),h+c<<16|p&65535|0|0}function qr(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0;return _=h,y=p,p=AI(_,y)|0,h=V()|0,xe((gs(c,y)|0)+(gs(m,_)|0)+h|h&0|0),p|0|0|0}function Vh(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0,b=0,M=0,R=0,D=0;return _=z,z=z+16|0,M=_|0,b=c>>31|((c|0)<0?-1:0)<<1,y=((c|0)<0?-1:0)>>31|((c|0)<0?-1:0)<<1,D=m>>31|((m|0)<0?-1:0)<<1,R=((m|0)<0?-1:0)>>31|((m|0)<0?-1:0)<<1,h=Gr(b^h|0,y^c|0,b|0,y|0)|0,c=V()|0,u2(h,c,Gr(D^p|0,R^m|0,D|0,R|0)|0,V()|0,M)|0,m=Gr(f[M>>2]^b|0,f[M+4>>2]^y|0,b|0,y|0)|0,p=V()|0,z=_,xe(p|0),m|0}function Gh(h,c,p,m){h=h|0,c=c|0,p=p|0,m=m|0;var _=0,y=0;return y=z,z=z+16|0,_=y|0,u2(h,c,p,m,_)|0,z=y,xe(f[_+4>>2]|0),f[_>>2]|0|0}function _T(h,c,p){return h=h|0,c=c|0,p=p|0,(p|0)<32?(xe(c>>p|0),h>>>p|(c&(1<>p-32|0)}function Xe(h,c,p){return h=h|0,c=c|0,p=p|0,(p|0)<32?(xe(c>>>p|0),h>>>p|(c&(1<>>p-32|0)}function st(h,c,p){return h=h|0,c=c|0,p=p|0,(p|0)<32?(xe(c<>>32-p|0),h<=0?+Hi(h+.5):+go(h-.5)}function qh(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0;if((p|0)>=8192)return Ut(h|0,c|0,p|0)|0,h|0;if(y=h|0,_=h+p|0,(h&3)==(c&3)){for(;h&3;){if(!p)return y|0;je[h>>0]=je[c>>0]|0,h=h+1|0,c=c+1|0,p=p-1|0}for(p=_&-4|0,m=p-64|0;(h|0)<=(m|0);)f[h>>2]=f[c>>2],f[h+4>>2]=f[c+4>>2],f[h+8>>2]=f[c+8>>2],f[h+12>>2]=f[c+12>>2],f[h+16>>2]=f[c+16>>2],f[h+20>>2]=f[c+20>>2],f[h+24>>2]=f[c+24>>2],f[h+28>>2]=f[c+28>>2],f[h+32>>2]=f[c+32>>2],f[h+36>>2]=f[c+36>>2],f[h+40>>2]=f[c+40>>2],f[h+44>>2]=f[c+44>>2],f[h+48>>2]=f[c+48>>2],f[h+52>>2]=f[c+52>>2],f[h+56>>2]=f[c+56>>2],f[h+60>>2]=f[c+60>>2],h=h+64|0,c=c+64|0;for(;(h|0)<(p|0);)f[h>>2]=f[c>>2],h=h+4|0,c=c+4|0}else for(p=_-4|0;(h|0)<(p|0);)je[h>>0]=je[c>>0]|0,je[h+1>>0]=je[c+1>>0]|0,je[h+2>>0]=je[c+2>>0]|0,je[h+3>>0]=je[c+3>>0]|0,h=h+4|0,c=c+4|0;for(;(h|0)<(_|0);)je[h>>0]=je[c>>0]|0,h=h+1|0,c=c+1|0;return y|0}function bu(h,c,p){h=h|0,c=c|0,p=p|0;var m=0,_=0,y=0,b=0;if(y=h+p|0,c=c&255,(p|0)>=67){for(;h&3;)je[h>>0]=c,h=h+1|0;for(m=y&-4|0,b=c|c<<8|c<<16|c<<24,_=m-64|0;(h|0)<=(_|0);)f[h>>2]=b,f[h+4>>2]=b,f[h+8>>2]=b,f[h+12>>2]=b,f[h+16>>2]=b,f[h+20>>2]=b,f[h+24>>2]=b,f[h+28>>2]=b,f[h+32>>2]=b,f[h+36>>2]=b,f[h+40>>2]=b,f[h+44>>2]=b,f[h+48>>2]=b,f[h+52>>2]=b,f[h+56>>2]=b,f[h+60>>2]=b,h=h+64|0;for(;(h|0)<(m|0);)f[h>>2]=b,h=h+4|0}for(;(h|0)<(y|0);)je[h>>0]=c,h=h+1|0;return y-p|0}function xT(h){return h=+h,h>=0?+Hi(h+.5):+go(h-.5)}function Su(h){h=h|0;var c=0,p=0,m=0;return m=wt()|0,p=f[qn>>2]|0,c=p+h|0,(h|0)>0&(c|0)<(p|0)|(c|0)<0?(un(c|0)|0,It(12),-1):(c|0)>(m|0)&&!(Kt(c|0)|0)?(It(12),-1):(f[qn>>2]=c,p|0)}return{___divdi3:yu,___muldi3:qr,___remdi3:Vh,___uremdi3:Gh,_areNeighborCells:nL,_bitshift64Ashr:_T,_bitshift64Lshr:Xe,_bitshift64Shl:st,_calloc:Ks,_cellAreaKm2:BL,_cellAreaM2:UL,_cellAreaRads2:s2,_cellToBoundary:Oh,_cellToCenterChild:ZS,_cellToChildPos:ML,_cellToChildren:gL,_cellToChildrenSize:sA,_cellToLatLng:wc,_cellToLocalIj:zL,_cellToParent:K_,_cellToVertex:Oo,_cellToVertexes:lI,_cellsToDirectedEdge:iL,_cellsToLinkedMultiPolygon:mc,_childPosToCell:EL,_compactCells:_L,_constructCell:pL,_destroyLinkedMultiPolygon:iT,_directedEdgeToBoundary:Up,_directedEdgeToCells:oL,_edgeLengthKm:OL,_edgeLengthM:kL,_edgeLengthRads:FL,_emscripten_replace_memory:Bn,_free:on,_getBaseCellNumber:YS,_getDirectedEdgeDestination:sL,_getDirectedEdgeOrigin:rL,_getHexagonAreaAvgKm2:tT,_getHexagonAreaAvgM2:DL,_getHexagonEdgeLengthAvgKm:LL,_getHexagonEdgeLengthAvgM:IL,_getIcosahedronFaces:JS,_getIndexDigit:AL,_getNumCells:Fp,_getPentagons:n2,_getRes0Cells:Pp,_getResolution:dL,_greatCircleDistanceKm:aA,_greatCircleDistanceM:RL,_greatCircleDistanceRads:CL,_gridDisk:ei,_gridDiskDistances:On,_gridDistance:WL,_gridPathCells:jL,_gridPathCellsSize:$L,_gridRing:ra,_gridRingUnsafe:li,_i64Add:sn,_i64Subtract:Gr,_isPentagon:Ni,_isResClassIII:yL,_isValidCell:Q_,_isValidDirectedEdge:jS,_isValidIndex:mL,_isValidVertex:fT,_latLngToCell:e2,_llvm_ctlz_i64:c2,_llvm_maxnum_f64:vT,_llvm_minnum_f64:Vp,_llvm_round_f64:Gp,_localIjToCell:HL,_malloc:Oa,_maxFaceCount:TL,_maxGridDiskSize:rn,_maxPolygonToCellsSize:Mr,_maxPolygonToCellsSizeExperimental:YL,_memcpy:qh,_memset:bu,_originToDirectedEdges:aL,_pentagonCount:wL,_polygonToCells:Rl,_polygonToCellsExperimental:QL,_readInt64AsDoubleFromPointer:rI,_res0CellCount:iA,_round:xT,_sbrk:Su,_sizeOfCellBoundary:JL,_sizeOfCoordIJ:iI,_sizeOfGeoLoop:eI,_sizeOfGeoPolygon:tI,_sizeOfH3Index:KL,_sizeOfLatLng:ZL,_sizeOfLinkedGeoPolygon:nI,_uncompactCells:vL,_uncompactCellsSize:xL,_vertexToLatLng:uI,establishStackSpace:ni,stackAlloc:Yn,stackRestore:Ui,stackSave:bi}}(Tt,wn,G);e.___divdi3=ne.___divdi3,e.___muldi3=ne.___muldi3,e.___remdi3=ne.___remdi3,e.___uremdi3=ne.___uremdi3,e._areNeighborCells=ne._areNeighborCells,e._bitshift64Ashr=ne._bitshift64Ashr,e._bitshift64Lshr=ne._bitshift64Lshr,e._bitshift64Shl=ne._bitshift64Shl,e._calloc=ne._calloc,e._cellAreaKm2=ne._cellAreaKm2,e._cellAreaM2=ne._cellAreaM2,e._cellAreaRads2=ne._cellAreaRads2,e._cellToBoundary=ne._cellToBoundary,e._cellToCenterChild=ne._cellToCenterChild,e._cellToChildPos=ne._cellToChildPos,e._cellToChildren=ne._cellToChildren,e._cellToChildrenSize=ne._cellToChildrenSize,e._cellToLatLng=ne._cellToLatLng,e._cellToLocalIj=ne._cellToLocalIj,e._cellToParent=ne._cellToParent,e._cellToVertex=ne._cellToVertex,e._cellToVertexes=ne._cellToVertexes,e._cellsToDirectedEdge=ne._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=ne._cellsToLinkedMultiPolygon,e._childPosToCell=ne._childPosToCell,e._compactCells=ne._compactCells,e._constructCell=ne._constructCell,e._destroyLinkedMultiPolygon=ne._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=ne._directedEdgeToBoundary,e._directedEdgeToCells=ne._directedEdgeToCells,e._edgeLengthKm=ne._edgeLengthKm,e._edgeLengthM=ne._edgeLengthM,e._edgeLengthRads=ne._edgeLengthRads;var vt=e._emscripten_replace_memory=ne._emscripten_replace_memory;e._free=ne._free,e._getBaseCellNumber=ne._getBaseCellNumber,e._getDirectedEdgeDestination=ne._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=ne._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=ne._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=ne._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=ne._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=ne._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=ne._getIcosahedronFaces,e._getIndexDigit=ne._getIndexDigit,e._getNumCells=ne._getNumCells,e._getPentagons=ne._getPentagons,e._getRes0Cells=ne._getRes0Cells,e._getResolution=ne._getResolution,e._greatCircleDistanceKm=ne._greatCircleDistanceKm,e._greatCircleDistanceM=ne._greatCircleDistanceM,e._greatCircleDistanceRads=ne._greatCircleDistanceRads,e._gridDisk=ne._gridDisk,e._gridDiskDistances=ne._gridDiskDistances,e._gridDistance=ne._gridDistance,e._gridPathCells=ne._gridPathCells,e._gridPathCellsSize=ne._gridPathCellsSize,e._gridRing=ne._gridRing,e._gridRingUnsafe=ne._gridRingUnsafe,e._i64Add=ne._i64Add,e._i64Subtract=ne._i64Subtract,e._isPentagon=ne._isPentagon,e._isResClassIII=ne._isResClassIII,e._isValidCell=ne._isValidCell,e._isValidDirectedEdge=ne._isValidDirectedEdge,e._isValidIndex=ne._isValidIndex,e._isValidVertex=ne._isValidVertex,e._latLngToCell=ne._latLngToCell,e._llvm_ctlz_i64=ne._llvm_ctlz_i64,e._llvm_maxnum_f64=ne._llvm_maxnum_f64,e._llvm_minnum_f64=ne._llvm_minnum_f64,e._llvm_round_f64=ne._llvm_round_f64,e._localIjToCell=ne._localIjToCell,e._malloc=ne._malloc,e._maxFaceCount=ne._maxFaceCount,e._maxGridDiskSize=ne._maxGridDiskSize,e._maxPolygonToCellsSize=ne._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=ne._maxPolygonToCellsSizeExperimental,e._memcpy=ne._memcpy,e._memset=ne._memset,e._originToDirectedEdges=ne._originToDirectedEdges,e._pentagonCount=ne._pentagonCount,e._polygonToCells=ne._polygonToCells,e._polygonToCellsExperimental=ne._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=ne._readInt64AsDoubleFromPointer,e._res0CellCount=ne._res0CellCount,e._round=ne._round,e._sbrk=ne._sbrk,e._sizeOfCellBoundary=ne._sizeOfCellBoundary,e._sizeOfCoordIJ=ne._sizeOfCoordIJ,e._sizeOfGeoLoop=ne._sizeOfGeoLoop,e._sizeOfGeoPolygon=ne._sizeOfGeoPolygon,e._sizeOfH3Index=ne._sizeOfH3Index,e._sizeOfLatLng=ne._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=ne._sizeOfLinkedGeoPolygon,e._uncompactCells=ne._uncompactCells,e._uncompactCellsSize=ne._uncompactCellsSize,e._vertexToLatLng=ne._vertexToLatLng,e.establishStackSpace=ne.establishStackSpace;var dt=e.stackAlloc=ne.stackAlloc,Rt=e.stackRestore=ne.stackRestore,rt=e.stackSave=ne.stackSave;if(e.asm=ne,e.cwrap=E,e.setValue=v,e.getValue=x,jt){ie(jt)||(jt=s(jt));{tn();var Ge=function(Pe){Pe.byteLength&&(Pe=new Uint8Array(Pe)),j.set(Pe,g),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,St()},xt=function(){o(jt,Ge,function(){throw"could not load memory initializer "+jt})},hn=Nt(jt);if(hn)Ge(hn.buffer);else if(e.memoryInitializerRequest){var ai=function(){var Pe=e.memoryInitializerRequest,ze=Pe.response;if(Pe.status!==200&&Pe.status!==0){var yt=Nt(e.memoryInitializerRequestURL);if(yt)ze=yt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Pe.status+", retrying "+jt),xt();return}}Ge(ze)};e.memoryInitializerRequest.response?setTimeout(ai,0):e.memoryInitializerRequest.addEventListener("load",ai)}else xt()}}var nn;ae=function Pe(){nn||Tr(),nn||(ae=Pe)};function Tr(Pe){if(pt>0||(Re(),pt>0))return;function ze(){nn||(nn=!0,!T&&(Je(),Ct(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),et()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),ze()},1)):ze()}e.run=Tr;function gr(Pe){throw e.onAbort&&e.onAbort(Pe),Pe+="",a(Pe),l(Pe),T=!0,"abort("+Pe+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=gr,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return Tr(),i}(typeof Zn=="object"?Zn:{}),fn="number",cn=fn,Af=fn,vn=fn,xn=fn,Hr=fn,Bt=fn,aX=[["sizeOfH3Index",fn],["sizeOfLatLng",fn],["sizeOfCellBoundary",fn],["sizeOfGeoLoop",fn],["sizeOfGeoPolygon",fn],["sizeOfLinkedGeoPolygon",fn],["sizeOfCoordIJ",fn],["readInt64AsDoubleFromPointer",fn],["isValidCell",Af,[vn,xn]],["isValidIndex",Af,[vn,xn]],["latLngToCell",cn,[fn,fn,Hr,Bt]],["cellToLatLng",cn,[vn,xn,Bt]],["cellToBoundary",cn,[vn,xn,Bt]],["maxGridDiskSize",cn,[fn,Bt]],["gridDisk",cn,[vn,xn,fn,Bt]],["gridDiskDistances",cn,[vn,xn,fn,Bt,Bt]],["gridRing",cn,[vn,xn,fn,Bt]],["gridRingUnsafe",cn,[vn,xn,fn,Bt]],["maxPolygonToCellsSize",cn,[Bt,Hr,fn,Bt]],["polygonToCells",cn,[Bt,Hr,fn,Bt]],["maxPolygonToCellsSizeExperimental",cn,[Bt,Hr,fn,Bt]],["polygonToCellsExperimental",cn,[Bt,Hr,fn,fn,fn,Bt]],["cellsToLinkedMultiPolygon",cn,[Bt,fn,Bt]],["destroyLinkedMultiPolygon",null,[Bt]],["compactCells",cn,[Bt,Bt,fn,fn]],["uncompactCells",cn,[Bt,fn,fn,Bt,fn,Hr]],["uncompactCellsSize",cn,[Bt,fn,fn,Hr,Bt]],["isPentagon",Af,[vn,xn]],["isResClassIII",Af,[vn,xn]],["getBaseCellNumber",fn,[vn,xn]],["getResolution",fn,[vn,xn]],["getIndexDigit",fn,[vn,xn,fn]],["constructCell",cn,[fn,fn,Bt,Bt]],["maxFaceCount",cn,[vn,xn,Bt]],["getIcosahedronFaces",cn,[vn,xn,Bt]],["cellToParent",cn,[vn,xn,Hr,Bt]],["cellToChildren",cn,[vn,xn,Hr,Bt]],["cellToCenterChild",cn,[vn,xn,Hr,Bt]],["cellToChildrenSize",cn,[vn,xn,Hr,Bt]],["cellToChildPos",cn,[vn,xn,Hr,Bt]],["childPosToCell",cn,[fn,fn,vn,xn,Hr,Bt]],["areNeighborCells",cn,[vn,xn,vn,xn,Bt]],["cellsToDirectedEdge",cn,[vn,xn,vn,xn,Bt]],["getDirectedEdgeOrigin",cn,[vn,xn,Bt]],["getDirectedEdgeDestination",cn,[vn,xn,Bt]],["isValidDirectedEdge",Af,[vn,xn]],["directedEdgeToCells",cn,[vn,xn,Bt]],["originToDirectedEdges",cn,[vn,xn,Bt]],["directedEdgeToBoundary",cn,[vn,xn,Bt]],["gridDistance",cn,[vn,xn,vn,xn,Bt]],["gridPathCells",cn,[vn,xn,vn,xn,Bt]],["gridPathCellsSize",cn,[vn,xn,vn,xn,Bt]],["cellToLocalIj",cn,[vn,xn,vn,xn,fn,Bt]],["localIjToCell",cn,[vn,xn,Bt,fn,Bt]],["getHexagonAreaAvgM2",cn,[Hr,Bt]],["getHexagonAreaAvgKm2",cn,[Hr,Bt]],["getHexagonEdgeLengthAvgM",cn,[Hr,Bt]],["getHexagonEdgeLengthAvgKm",cn,[Hr,Bt]],["greatCircleDistanceM",fn,[Bt,Bt]],["greatCircleDistanceKm",fn,[Bt,Bt]],["greatCircleDistanceRads",fn,[Bt,Bt]],["cellAreaM2",cn,[vn,xn,Bt]],["cellAreaKm2",cn,[vn,xn,Bt]],["cellAreaRads2",cn,[vn,xn,Bt]],["edgeLengthM",cn,[vn,xn,Bt]],["edgeLengthKm",cn,[vn,xn,Bt]],["edgeLengthRads",cn,[vn,xn,Bt]],["getNumCells",cn,[Hr,Bt]],["getRes0Cells",cn,[Bt]],["res0CellCount",fn],["getPentagons",cn,[fn,Bt]],["pentagonCount",fn],["cellToVertex",cn,[vn,xn,fn,Bt]],["cellToVertexes",cn,[vn,xn,Bt]],["vertexToLatLng",cn,[vn,xn,Bt]],["isValidVertex",Af,[vn,xn]]],lX=0,uX=1,cX=2,hX=3,H8=4,fX=5,dX=6,AX=7,pX=8,mX=9,gX=10,_X=11,vX=12,xX=13,yX=14,bX=15,SX=16,TX=17,wX=18,MX=19,Sr={};Sr[lX]="Success";Sr[uX]="The operation failed but a more specific error is not available";Sr[cX]="Argument was outside of acceptable range";Sr[hX]="Latitude or longitude arguments were outside of acceptable range";Sr[H8]="Resolution argument was outside of acceptable range";Sr[fX]="Cell argument was not valid";Sr[dX]="Directed edge argument was not valid";Sr[AX]="Undirected edge argument was not valid";Sr[pX]="Vertex argument was not valid";Sr[mX]="Pentagon distortion was encountered";Sr[gX]="Duplicate input";Sr[_X]="Cell arguments were not neighbors";Sr[vX]="Cell arguments had incompatible resolutions";Sr[xX]="Memory allocation failed";Sr[yX]="Bounds of provided memory were insufficient";Sr[bX]="Mode or flags argument was not valid";Sr[SX]="Index argument was not valid";Sr[TX]="Base cell number was outside of acceptable range";Sr[wX]="Child indexing digits invalid";Sr[MX]="Child indexing digits refer to a deleted subsequence";var EX=1e3,W8=1001,$8=1002,n_={};n_[EX]="Unknown unit";n_[W8]="Array length out of bounds";n_[$8]="Got unexpected null value for H3 index";var CX="Unknown error";function j8(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||CX)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function X8(i,e){var t=arguments.length===2?{value:e}:{};return j8(Sr,i,t)}function Q8(i,e){var t=arguments.length===2?{value:e}:{};return j8(n_,i,t)}function H0(i){if(i!==0)throw X8(i)}var ho={};aX.forEach(function(e){ho[e[0]]=Zn.cwrap.apply(Zn,e)});var If=16,W0=4,Bd=8,RX=8,_1=ho.sizeOfH3Index(),Yb=ho.sizeOfLatLng(),NX=ho.sizeOfCellBoundary(),PX=ho.sizeOfGeoPolygon(),a0=ho.sizeOfGeoLoop();ho.sizeOfLinkedGeoPolygon();ho.sizeOfCoordIJ();function DX(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw X8(H8,i);return i}function LX(i){if(!i)throw Q8($8);return i}var IX=Math.pow(2,32)-1;function BX(i){if(i>IX)throw Q8(W8,i);return i}var UX=/[^0-9a-fA-F]/;function Y8(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||UX.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),If),t=parseInt(i.substring(i.length-8),If);return[t,e]}function OE(i){if(i>=0)return i.toString(If);i=i&2147483647;var e=K8(8,i.toString(If)),t=(parseInt(e[0],If)+8).toString(If);return e=t+e.substring(1),e}function FX(i,e){return OE(e)+K8(8,OE(i))}function K8(i,e){for(var t=i-e.length,n="",r=0;r0){a=Zn._calloc(t,a0);for(var l=0;l0){for(var o=Zn.getValue(i+n,"i32"),a=0;a0){const{width:o,height:a}=e.context;t.bufferWidth=o,t.bufferHeight=a}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){const{object:n,material:r,geometry:s}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(n.matrixWorld)!==!0)return o.worldMatrix.copy(n.matrixWorld),!1;const a=o.material;for(const S in a){const w=a[S],C=r[S];if(w.equals!==void 0){if(w.equals(C)===!1)return w.copy(C),!1}else if(C.isTexture===!0){if(w.id!==C.id||w.version!==C.version)return w.id=C.id,w.version=C.version,!1}else if(w!==C)return a[S]=C,!1}if(a.transmission>0){const{width:S,height:w}=e.context;if(o.bufferWidth!==S||o.bufferHeight!==w)return o.bufferWidth=S,o.bufferHeight=w,!1}const l=o.geometry,u=s.attributes,d=l.attributes,A=Object.keys(d),g=Object.keys(u);if(l.id!==s.id)return l.id=s.id,!1;if(A.length!==g.length)return o.geometry.attributes=this.getAttributesData(u),!1;for(const S of A){const w=d[S],C=u[S];if(C===void 0)return delete d[S],!1;if(w.version!==C.version)return w.version=C.version,!1}const v=s.index,x=l.indexVersion,T=v?v.version:null;if(x!==T)return l.indexVersion=T,!1;if(l.drawRange.start!==s.drawRange.start||l.drawRange.count!==s.drawRange.count)return l.drawRange.start=s.drawRange.start,l.drawRange.count=s.drawRange.count,!1;if(o.morphTargetInfluences){let S=!1;for(let w=0;w>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const gp=i=>Kb(i),Yd=i=>Kb(i),l0=(...i)=>Kb(i),YX=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),GE=new WeakMap;function n5(i){return YX.get(i)}function x1(i){if(/[iu]?vec\d/.test(i))return i.startsWith("ivec")?Int32Array:i.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(i)||/float/.test(i))return Float32Array;if(/uint/.test(i))return Uint32Array;if(/int/.test(i))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${i}`)}function i5(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 9;if(/mat4/.test(i))return 16;He("TSL: Unsupported type:",i)}function KX(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 12;if(/mat4/.test(i))return 16;He("TSL: Unsupported type:",i)}function ZX(i){if(/float|int|uint/.test(i))return 4;if(/vec2/.test(i))return 8;if(/vec3/.test(i)||/vec4/.test(i))return 16;if(/mat2/.test(i))return 8;if(/mat3/.test(i)||/mat4/.test(i))return 16;He("TSL: Unsupported type:",i)}function ju(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 Zb(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 Gt(...e):t==="vec2"?new qe(...e):t==="vec3"?new te(...e):t==="vec4"?new dn(...e):t==="mat2"?new Y1(...e):t==="mat3"?new Cn(...e):t==="mat4"?new gn(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?o5(e[0]):null}function r5(i){let e=GE.get(i);return e===void 0&&(e={},GE.set(i,e)),e}function s5(i){let e="";const t=new Uint8Array(i);for(let n=0;ne.charCodeAt(0)).buffer}const YA={VERTEX:"vertex",FRAGMENT:"fragment"},yn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},JX={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},us={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},a5=["fragment","vertex"],Zx=["setup","analyze","generate"],Jx=[...a5,"compute"],Eh=["x","y","z","w"],eQ={analyze:"setup",generate:"analyze"};let tQ=0;class Lt extends La{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=yn.NONE,this.updateBeforeType=yn.NONE,this.updateAfterType=yn.NONE,this.uuid=Md.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:tQ++})}set needsUpdate(e){e===!0&&this.version++}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,yn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,yn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,yn.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 n of Object.getOwnPropertyNames(this)){const r=this[n];if(!(n.startsWith("_")===!0||e.has(r))){if(Array.isArray(r)===!0)for(let s=0;s0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const o=e.inputNodes[n][s];r[s]=t[o]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function o(a){const l=[];for(const u in a){const d=a[u];delete d.metadata,l.push(d)}return l}if(r){const a=o(e.textures),l=o(e.images),u=o(e.nodes);a.length>0&&(s.textures=a),l.length>0&&(s.images=l),u.length>0&&(s.nodes=u)}return s}}class Ch extends Lt{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class l5 extends Lt{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class ir extends Lt{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 r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,r),a=e.getVarFromNode(this,null,r),l=e.getPropertyName(a);return e.addLineFlowCode(`${l} = ${o}`,this),s.snippet=o,s.propertyName=l,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class nQ extends ir{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=e.getTypeLength(n),s=this.nodes,o=e.getComponentType(n),a=[];let l=0;for(const d of s){if(l>=r){He(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let A=d.getNodeType(e),g=e.getTypeLength(A),v;if(l+g>r&&(He(`TSL: Length of '${n}()' data exceeds maximum length of output type.`),g=r-l,A=e.getTypeFromLength(g)),l+=g,v=d.build(e,A),e.getComponentType(A)!==o){const T=e.getTypeFromLength(g,o);v=e.format(v,A,T)}a.push(v)}const u=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(u,n,t)}}const iQ=Eh.join("");class u5 extends Lt{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(Eh.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let o=null;this.getVectorLength()>=r&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const l=n.build(e,o);this.components.length===r&&this.components===iQ.slice(0,this.components.length)?s=e.format(l,o,t):s=e.format(`${l}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class rQ extends ir{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),o=e.getComponentType(r.getNodeType(e)),a=e.getTypeFromLength(n.length,o),l=r.build(e,a),u=t.build(e,s),d=e.getTypeLength(s),A=[];for(let g=0;gi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),zE=i=>aQ(i).split("").sort().join("");Lt.prototype.assign=function(...i){if(this.isStackNode!==!0)return rc!==null?rc.assign(this,...i):He("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=ey.get("assign");return this.addToStack(e(...i))}};Lt.prototype.toVarIntent=function(){return this};Lt.prototype.get=function(i){return new oQ(this,i)};const u0={};function Nm(i,e,t){u0[i]=u0[e]=u0[t]={get(){this._cache=this._cache||{};let o=this._cache[i];return o===void 0&&(o=new u5(this,i),this._cache[i]=o),o},set(o){this[i].assign(gt(o))}};const n=i.toUpperCase(),r=e.toUpperCase(),s=t.toUpperCase();Lt.prototype["set"+n]=Lt.prototype["set"+r]=Lt.prototype["set"+s]=function(o){const a=zE(i);return new rQ(this,a,gt(o))},Lt.prototype["flip"+n]=Lt.prototype["flip"+r]=Lt.prototype["flip"+s]=function(){const o=zE(i);return new sQ(this,o)}}const qa=["x","y","z","w"],za=["r","g","b","a"],Ha=["s","t","p","q"];for(let i=0;i<4;i++){let e=qa[i],t=za[i],n=Ha[i];Nm(e,t,n);for(let r=0;r<4;r++){e=qa[i]+qa[r],t=za[i]+za[r],n=Ha[i]+Ha[r],Nm(e,t,n);for(let s=0;s<4;s++){e=qa[i]+qa[r]+qa[s],t=za[i]+za[r]+za[s],n=Ha[i]+Ha[r]+Ha[s],Nm(e,t,n);for(let o=0;o<4;o++)e=qa[i]+qa[r]+qa[s]+qa[o],t=za[i]+za[r]+za[s]+za[o],n=Ha[i]+Ha[r]+Ha[s]+Ha[o],Nm(e,t,n)}}}for(let i=0;i<32;i++)u0[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new Ch(this,new na(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(gt(e))}};Object.defineProperties(Lt.prototype,u0);const HE=new WeakMap,lQ=function(i,e=null){const t=ju(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?gt(ty(i,e)):t==="shader"?i.isFn?i:pe(i):i},uQ=function(i,e=null){for(const t in i)i[t]=gt(i[t],e);return i},cQ=function(i,e=null){const t=i.length;for(let n=0;nl?(He(`TSL: "${A}" parameter length exceeds limit.`),d.slice(0,l)):d}return e===null?s=(...d)=>r(new i(...ch(u(d)))):t!==null?(t=gt(t),s=(...d)=>r(new i(e,...ch(u(d)),t))):s=(...d)=>r(new i(e,...ch(u(d)))),s.setParameterLength=(...d)=>(d.length===1?a=l=d[0]:d.length===2&&([a,l]=d),s),s.setName=d=>(o=d,s),s},hQ=function(i,...e){return new i(...ch(e))};class fQ extends Lt{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(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:n}=this,r=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",o=s||"default";if(r[o])return r[o];const a=e.subBuildFn,l=e.fnCall;e.subBuildFn=s,e.fnCall=this;let u=null;if(t.layout){let d=HE.get(e.constructor);d===void 0&&(d=new WeakMap,HE.set(e.constructor,d));let A=d.get(t);A===void 0&&(A=gt(e.buildFunctionNode(t)),d.set(t,A)),e.addInclude(A);const g=n?dQ(n):null;u=gt(A.call(g))}else{const d=new Proxy(e,{get:(T,S,w)=>{let C;return Symbol.iterator===S?C=function*(){yield void 0}:C=Reflect.get(T,S,w),C}}),A=n?AQ(n):null,g=Array.isArray(n)?n.length>0:n!==null,v=t.jsFunc,x=g||v.length>1?v(A,d):v(d);u=gt(x)}return e.subBuildFn=a,e.fnCall=l,t.once&&(r[o]=u),u}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null;const r=e.getBuildStage(),s=e.getNodeProperties(this),o=e.getSubBuildOutput(this),a=this.getOutputNode(e),l=e.fnCall;if(e.fnCall=this,r==="setup"){const u=e.getSubBuildProperty("initialized",this);if(s[u]!==!0&&(s[u]=!0,s[o]=this.getOutputNode(e),s[o].build(e),this.shaderNode.subBuilds))for(const d of e.chaining){const A=e.getDataFromNode(d,"any");A.subBuilds=A.subBuilds||new Set;for(const g of this.shaderNode.subBuilds)A.subBuilds.add(g)}n=s[o]}else r==="analyze"?a.build(e,t):r==="generate"&&(n=a.build(e,t)||"");return e.fnCall=l,n}}function dQ(i){let e;return s_(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function AQ(i){let e=0;return s_(i),new Proxy(i,{get:(t,n,r)=>{let s;if(n==="length")return s=i.length,s;if(Symbol.iterator===n)s=function*(){for(const o of i)yield gt(o)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const o=i[0];o[n]===void 0?s=o[e++]:s=Reflect.get(o,n,r)}else i[0]instanceof Lt&&(i[n]===void 0?s=i[e++]:s=Reflect.get(i,n,r));else s=Reflect.get(t,n,r);s=gt(s)}return s}})}class pQ extends Lt{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 fQ(this,e)}setup(){return this.call()}}const mQ=[!1,!0],gQ=[0,1,2,3],_Q=[-1,-2],h5=[.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],e3=new Map;for(const i of mQ)e3.set(i,new na(i));const t3=new Map;for(const i of gQ)t3.set(i,new na(i,"uint"));const n3=new Map([...t3].map(i=>new na(i.value,"int")));for(const i of _Q)n3.set(i,new na(i,"int"));const i_=new Map([...n3].map(i=>new na(i.value)));for(const i of h5)i_.set(i,new na(i));for(const i of h5)i_.set(-i,new na(-i));const r_={bool:e3,uint:t3,ints:n3,float:i_},WE=new Map([...e3,...i_]),ty=(i,e)=>WE.has(i)?WE.get(i):i.isNode===!0?i:new na(i,e),Ir=function(i,e=null){return(...t)=>{for(const r of t)if(r===void 0)return He(`TSL: Invalid parameter for the type "${i}".`),new na(0,i);if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>{const s=typeof r;return s!=="object"&&s!=="function"}))&&(t=[Zb(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return KA(e.get(t[0]));if(t.length===1){const r=ty(t[0],i);return r.nodeType===i?KA(r):KA(new l5(r,i))}const n=t.map(r=>ty(r));return KA(new nQ(n,i))}},$0=i=>typeof i=="object"&&i!==null?i.value:i,f5=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Bf(i,e){return new pQ(i,e)}const gt=(i,e=null)=>lQ(i,e),KA=(i,e=null)=>gt(i,e).toVarIntent(),s_=(i,e=null)=>new uQ(i,e),ch=(i,e=null)=>new cQ(i,e),pn=(i,e=null,t=null,n=null)=>new c5(i,e,t,n),At=(i,...e)=>new hQ(i,...e),nt=(i,e=null,t=null,n={})=>new c5(i,e,t,{...n,intent:!0});let vQ=0;class xQ extends Lt{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:He("TSL: Invalid layout type."),t=null)),this.shaderNode=new Bf(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+vQ++,type:t,inputs:[]};for(const r in e)r!=="return"&&n.inputs.push({name:r,type:e[r]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(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 He('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function pe(i,e=null){const t=new xQ(i,e);return new Proxy(()=>{},{apply(n,r,s){return t.call(...s)},get(n,r,s){return Reflect.get(t,r,s)},set(n,r,s,o){return Reflect.set(t,r,s,o)}})}const j0=i=>{rc=i},i3=()=>rc,Xt=(...i)=>rc.If(...i),yQ=(...i)=>rc.Switch(...i);function o_(i){return rc&&rc.addToStack(i),i}Ie("toStack",o_);const d5=new Ir("color"),Z=new Ir("float",r_.float),ce=new Ir("int",r_.ints),We=new Ir("uint",r_.uint),Yo=new Ir("bool",r_.bool),Ze=new Ir("vec2"),Rr=new Ir("ivec2"),r3=new Ir("uvec2"),A5=new Ir("bvec2"),he=new Ir("vec3"),s3=new Ir("ivec3"),Rh=new Ir("uvec3"),o3=new Ir("bvec3"),Yt=new Ir("vec4"),a3=new Ir("ivec4"),l3=new Ir("uvec4"),p5=new Ir("bvec4"),a_=new Ir("mat2"),ds=new Ir("mat3"),ec=new Ir("mat4"),bQ=(i="")=>new na(i,"string"),SQ=i=>new na(i,"ArrayBuffer");Ie("toColor",d5);Ie("toFloat",Z);Ie("toInt",ce);Ie("toUint",We);Ie("toBool",Yo);Ie("toVec2",Ze);Ie("toIVec2",Rr);Ie("toUVec2",r3);Ie("toBVec2",A5);Ie("toVec3",he);Ie("toIVec3",s3);Ie("toUVec3",Rh);Ie("toBVec3",o3);Ie("toVec4",Yt);Ie("toIVec4",a3);Ie("toUVec4",l3);Ie("toBVec4",p5);Ie("toMat2",a_);Ie("toMat3",ds);Ie("toMat4",ec);const m5=pn(Ch).setParameterLength(2),g5=(i,e)=>gt(new l5(gt(i),e)),TQ=(i,e)=>gt(new u5(gt(i),e));Ie("element",m5);Ie("convert",g5);const wQ=i=>(Ue("TSL: append() has been renamed to Stack()."),o_(i));Ie("append",i=>(Ue("TSL: .append() has been renamed to .toStack()."),o_(i)));class oi extends Lt{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return gp(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Yl=(i,e)=>new oi(i,e),X0=(i,e)=>new oi(i,e,!0),hi=At(oi,"vec4","DiffuseColor"),$c=At(oi,"vec3","DiffuseContribution"),ny=At(oi,"vec3","EmissiveColor"),el=At(oi,"float","Roughness"),$l=At(oi,"float","Metalness"),y1=At(oi,"float","Clearcoat"),Q0=At(oi,"float","ClearcoatRoughness"),To=At(oi,"vec3","Sheen"),qu=At(oi,"float","SheenRoughness"),l_=At(oi,"float","Iridescence"),b1=At(oi,"float","IridescenceIOR"),S1=At(oi,"float","IridescenceThickness"),T1=At(oi,"float","AlphaT"),Vu=At(oi,"float","Anisotropy"),c0=At(oi,"vec3","AnisotropyT"),hh=At(oi,"vec3","AnisotropyB"),sc=At(oi,"color","SpecularColor"),ih=At(oi,"color","SpecularColorBlended"),Hf=At(oi,"float","SpecularF90"),w1=At(oi,"float","Shininess"),Wf=At(oi,"vec4","Output"),Sg=At(oi,"float","dashSize"),iy=At(oi,"float","gapSize"),MQ=At(oi,"float","pointWidth"),h0=At(oi,"float","IOR"),M1=At(oi,"float","Transmission"),u3=At(oi,"float","Thickness"),c3=At(oi,"float","AttenuationDistance"),h3=At(oi,"color","AttenuationColor"),f3=At(oi,"float","Dispersion");class _5 extends Lt{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!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 v5=i=>new _5(i),u_=(i,e=0)=>new _5(i,!0,e),x5=u_("frame"),Wt=u_("render"),d3=v5("object");class _p extends Jb{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d3}setName(e){return this.name=e,this}label(e){return Ue('TSL: "label()" has been deprecated. Use "setName()" instead.'),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(n=>{const r=e(n,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const o=s.getInputType(e),a=e.getUniformFromNode(s,o,e.shaderStage,this.name||e.context.nodeName),l=e.getPropertyName(a);e.context.nodeName!==void 0&&delete e.context.nodeName;let u=l;if(n==="bool"){const d=e.getDataFromNode(this);let A=d.propertyName;if(A===void 0){const g=e.getVarFromNode(this,null,"bool");A=e.getPropertyName(g),d.propertyName=A,u=e.format(l,o,n),e.addLineFlowCode(`${A} = ${u}`,this)}u=A}return e.format(u,n,t)}}const $t=(i,e)=>{const t=f5(e||i);if(t===i&&(i=Zb(t)),i&&i.isNode===!0){let n=i.value;i.traverse(r=>{r.isConstNode===!0&&(n=r.value)}),i=n}return new _p(i,t)};class $E extends ir{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(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 y5=(...i)=>{let e;if(i.length===1){const t=i[0];e=new $E(null,t.length,t)}else{const t=i[0],n=i[1];e=new $E(t,n)}return gt(e)};Ie("toArray",(i,e)=>y5(Array(e).fill(i)));class EQ extends ir{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(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 n=e.getTypeLength(t.node.getNodeType(e));return Eh.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=t.getScope(),s=e.getDataFromNode(r);s.assign=!0;const o=e.getNodeProperties(this);o.sourceNode=n,o.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:r}=e.getNodeProperties(this),s=this.needsSplitAssign(e),o=n.build(e),a=n.getNodeType(e),l=r.build(e,a),u=r.getNodeType(e),d=e.getDataFromNode(this);let A;if(d.initialized===!0)t!=="void"&&(A=o);else if(s){const g=e.getVarFromNode(this,null,a),v=e.getPropertyName(g);e.addLineFlowCode(`${v} = ${l}`,this);const x=n.node,S=x.node.context({assign:!0}).build(e);for(let w=0;w{const d=u.type,A=d==="pointer";let g;return A?g="&"+l.build(e):g=l.build(e,d),g};if(Array.isArray(s)){if(s.length>r.length)He("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length(e=e.length>1||e[0]&&e[0].isNode===!0?ch(e):s_(e[0]),new CQ(gt(i),e));Ie("call",S5);const RQ={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class tr extends ir{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new tr(e,t,n);for(let o=0;o>"||n==="<<")return e.getIntegerType(o);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const l=Math.max(e.getTypeLength(o),e.getTypeLength(a));return l>1?`bvec${l}`:"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 n=this.op,{aNode:r,bNode:s}=this,o=this.getNodeType(e,t);let a=null,l=null;o!=="void"?(a=r.getNodeType(e),l=s?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(a)?l=a:e.isVector(l)?a=l:a!==l&&(a=l="float"):n===">>"||n==="<<"?(a=o,l=e.changeComponentType(l,"uint")):n==="%"?(a=o,l=e.isInteger(a)&&e.isInteger(l)?l:a):e.isMatrix(a)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(a):e.isMatrix(l)||(a=l=o):e.isMatrix(l)?a==="float"?a="float":e.isVector(a)?a=e.getVectorFromMatrix(l):a=l=o:a=l=o):a=l=o;const u=r.build(e,a),d=s?s.build(e,l):null,A=e.getFunctionOperator(n);if(t!=="void"){const g=e.renderer.coordinateSystem===Ws;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return g?e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,o,t):e.format(`( ${u} ${n} ${d} )`,o,t):e.format(`( ${u} ${n} ${d} )`,o,t);if(n==="%")return e.isInteger(l)?e.format(`( ${u} % ${d} )`,o,t):e.format(`${this.getOperatorMethod(e,o)}( ${u}, ${d} )`,o,t);if(n==="!"||n==="~")return e.format(`(${n}${u})`,a,t);if(A)return e.format(`${A}( ${u}, ${d} )`,o,t);if(e.isMatrix(a)&&l==="float")return e.format(`( ${d} ${n} ${u} )`,o,t);if(a==="float"&&e.isMatrix(l))return e.format(`${u} ${n} ${d}`,o,t);{let v=`( ${u} ${n} ${d} )`;return!g&&o==="bool"&&e.isVector(a)&&e.isVector(l)&&(v=`all${v}`),e.format(v,o,t)}}else if(a!=="void")return A?e.format(`${A}( ${u}, ${d} )`,o,t):e.isMatrix(a)&&l==="float"?e.format(`${d} ${n} ${u}`,o,t):e.format(`${u} ${n} ${d}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const br=nt(tr,"+").setParameterLength(2,1/0).setName("add"),jn=nt(tr,"-").setParameterLength(2,1/0).setName("sub"),An=nt(tr,"*").setParameterLength(2,1/0).setName("mul"),Io=nt(tr,"/").setParameterLength(2,1/0).setName("div"),vp=nt(tr,"%").setParameterLength(2).setName("mod"),A3=nt(tr,"==").setParameterLength(2).setName("equal"),T5=nt(tr,"!=").setParameterLength(2).setName("notEqual"),w5=nt(tr,"<").setParameterLength(2).setName("lessThan"),p3=nt(tr,">").setParameterLength(2).setName("greaterThan"),M5=nt(tr,"<=").setParameterLength(2).setName("lessThanEqual"),E5=nt(tr,">=").setParameterLength(2).setName("greaterThanEqual"),C5=nt(tr,"&&").setParameterLength(2,1/0).setName("and"),R5=nt(tr,"||").setParameterLength(2,1/0).setName("or"),N5=nt(tr,"!").setParameterLength(1).setName("not"),P5=nt(tr,"^^").setParameterLength(2).setName("xor"),D5=nt(tr,"&").setParameterLength(2).setName("bitAnd"),L5=nt(tr,"~").setParameterLength(1).setName("bitNot"),I5=nt(tr,"|").setParameterLength(2).setName("bitOr"),B5=nt(tr,"^").setParameterLength(2).setName("bitXor"),U5=nt(tr,"<<").setParameterLength(2).setName("shiftLeft"),F5=nt(tr,">>").setParameterLength(2).setName("shiftRight"),O5=pe(([i])=>(i.addAssign(1),i)),k5=pe(([i])=>(i.subAssign(1),i)),V5=pe(([i])=>{const e=ce(i).toConst();return i.addAssign(1),e}),G5=pe(([i])=>{const e=ce(i).toConst();return i.subAssign(1),e});Ie("add",br);Ie("sub",jn);Ie("mul",An);Ie("div",Io);Ie("mod",vp);Ie("equal",A3);Ie("notEqual",T5);Ie("lessThan",w5);Ie("greaterThan",p3);Ie("lessThanEqual",M5);Ie("greaterThanEqual",E5);Ie("and",C5);Ie("or",R5);Ie("not",N5);Ie("xor",P5);Ie("bitAnd",D5);Ie("bitNot",L5);Ie("bitOr",I5);Ie("bitXor",B5);Ie("shiftLeft",U5);Ie("shiftRight",F5);Ie("incrementBefore",O5);Ie("decrementBefore",k5);Ie("increment",V5);Ie("decrement",G5);const q5=(i,e)=>(Ue('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),vp(ce(i),ce(e)));Ie("modInt",q5);class Me extends ir{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===Me.MAX||e===Me.MIN)&&arguments.length>3){let s=new Me(e,t,n);for(let o=2;oo&&s>a?t:o>a?n:a>s?r:t}getNodeType(e){const t=this.method;return t===Me.LENGTH||t===Me.DISTANCE||t===Me.DOT?"float":t===Me.CROSS?"vec3":t===Me.ALL||t===Me.ANY?"bool":t===Me.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:r}=this;let s=null;if(r===Me.ONE_MINUS)s=jn(1,t);else if(r===Me.RECIPROCAL)s=Io(1,t);else if(r===Me.DIFFERENCE)s=Di(jn(t,n));else if(r===Me.TRANSFORM_DIRECTION){let o=t,a=n;e.isMatrix(o.getNodeType(e))?a=Yt(he(a),0):o=Yt(he(o),0);const l=An(o,a).xyz;s=Xs(l)}return s!==null?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,d=e.renderer.coordinateSystem;if(r===Me.NEGATE)return e.format("( - "+a.build(e,o)+" )",s,t);{const A=[];return r===Me.CROSS?A.push(a.build(e,s),l.build(e,s)):d===Ws&&r===Me.STEP?A.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":o),l.build(e,o)):d===Ws&&(r===Me.MIN||r===Me.MAX)?A.push(a.build(e,o),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":o)):r===Me.REFRACT?A.push(a.build(e,o),l.build(e,o),u.build(e,"float")):r===Me.MIX?A.push(a.build(e,o),l.build(e,o),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":o)):(d===Xo&&r===Me.ATAN&&l!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===Me.DFDX||r===Me.DFDY)&&(Ue(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),A.push(a.build(e,o)),l!==null&&A.push(l.build(e,o)),u!==null&&A.push(u.build(e,o))),e.format(`${e.getMethod(r,s)}( ${A.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Me.ALL="all";Me.ANY="any";Me.RADIANS="radians";Me.DEGREES="degrees";Me.EXP="exp";Me.EXP2="exp2";Me.LOG="log";Me.LOG2="log2";Me.SQRT="sqrt";Me.INVERSE_SQRT="inversesqrt";Me.FLOOR="floor";Me.CEIL="ceil";Me.NORMALIZE="normalize";Me.FRACT="fract";Me.SIN="sin";Me.COS="cos";Me.TAN="tan";Me.ASIN="asin";Me.ACOS="acos";Me.ATAN="atan";Me.ABS="abs";Me.SIGN="sign";Me.LENGTH="length";Me.NEGATE="negate";Me.ONE_MINUS="oneMinus";Me.DFDX="dFdx";Me.DFDY="dFdy";Me.ROUND="round";Me.RECIPROCAL="reciprocal";Me.TRUNC="trunc";Me.FWIDTH="fwidth";Me.TRANSPOSE="transpose";Me.DETERMINANT="determinant";Me.INVERSE="inverse";Me.EQUALS="equals";Me.MIN="min";Me.MAX="max";Me.STEP="step";Me.REFLECT="reflect";Me.DISTANCE="distance";Me.DIFFERENCE="difference";Me.DOT="dot";Me.CROSS="cross";Me.POW="pow";Me.TRANSFORM_DIRECTION="transformDirection";Me.MIX="mix";Me.CLAMP="clamp";Me.REFRACT="refract";Me.SMOOTHSTEP="smoothstep";Me.FACEFORWARD="faceforward";const m3=Z(1e-6),NQ=Z(1e6),E1=Z(Math.PI),PQ=Z(Math.PI*2),DQ=Z(Math.PI*2),LQ=Z(Math.PI*.5),z5=nt(Me,Me.ALL).setParameterLength(1),H5=nt(Me,Me.ANY).setParameterLength(1),W5=nt(Me,Me.RADIANS).setParameterLength(1),$5=nt(Me,Me.DEGREES).setParameterLength(1),g3=nt(Me,Me.EXP).setParameterLength(1),Ud=nt(Me,Me.EXP2).setParameterLength(1),c_=nt(Me,Me.LOG).setParameterLength(1),cl=nt(Me,Me.LOG2).setParameterLength(1),ws=nt(Me,Me.SQRT).setParameterLength(1),_3=nt(Me,Me.INVERSE_SQRT).setParameterLength(1),hl=nt(Me,Me.FLOOR).setParameterLength(1),h_=nt(Me,Me.CEIL).setParameterLength(1),Xs=nt(Me,Me.NORMALIZE).setParameterLength(1),Ta=nt(Me,Me.FRACT).setParameterLength(1),Vs=nt(Me,Me.SIN).setParameterLength(1),da=nt(Me,Me.COS).setParameterLength(1),j5=nt(Me,Me.TAN).setParameterLength(1),X5=nt(Me,Me.ASIN).setParameterLength(1),v3=nt(Me,Me.ACOS).setParameterLength(1),f_=nt(Me,Me.ATAN).setParameterLength(1,2),Di=nt(Me,Me.ABS).setParameterLength(1),x3=nt(Me,Me.SIGN).setParameterLength(1),fl=nt(Me,Me.LENGTH).setParameterLength(1),y3=nt(Me,Me.NEGATE).setParameterLength(1),Q5=nt(Me,Me.ONE_MINUS).setParameterLength(1),b3=nt(Me,Me.DFDX).setParameterLength(1),S3=nt(Me,Me.DFDY).setParameterLength(1),Y5=nt(Me,Me.ROUND).setParameterLength(1),K5=nt(Me,Me.RECIPROCAL).setParameterLength(1),T3=nt(Me,Me.TRUNC).setParameterLength(1),w3=nt(Me,Me.FWIDTH).setParameterLength(1),Z5=nt(Me,Me.TRANSPOSE).setParameterLength(1),J5=nt(Me,Me.DETERMINANT).setParameterLength(1),e6=nt(Me,Me.INVERSE).setParameterLength(1),t6=(i,e)=>(Ue('TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),A3(i,e)),fo=nt(Me,Me.MIN).setParameterLength(2,1/0),nr=nt(Me,Me.MAX).setParameterLength(2,1/0),d_=nt(Me,Me.STEP).setParameterLength(2),n6=nt(Me,Me.REFLECT).setParameterLength(2),i6=nt(Me,Me.DISTANCE).setParameterLength(2),r6=nt(Me,Me.DIFFERENCE).setParameterLength(2),Ko=nt(Me,Me.DOT).setParameterLength(2),ou=nt(Me,Me.CROSS).setParameterLength(2),zo=nt(Me,Me.POW).setParameterLength(2),M3=i=>An(i,i),s6=i=>An(i,i,i),E3=i=>An(i,i,i,i),o6=nt(Me,Me.TRANSFORM_DIRECTION).setParameterLength(2),a6=i=>An(x3(i),zo(Di(i),1/3)),C3=i=>Ko(i,i),Wn=nt(Me,Me.MIX).setParameterLength(3),wa=(i,e=0,t=1)=>gt(new Me(Me.CLAMP,gt(i),gt(e),gt(t))),A_=i=>wa(i),R3=nt(Me,Me.REFRACT).setParameterLength(3),Ma=nt(Me,Me.SMOOTHSTEP).setParameterLength(3),N3=nt(Me,Me.FACEFORWARD).setParameterLength(3),l6=pe(([i])=>{const n=43758.5453,r=Ko(i.xy,Ze(12.9898,78.233)),s=vp(r,E1);return Ta(Vs(s).mul(n))}),u6=(i,e,t)=>Wn(e,t,i),c6=(i,e,t)=>Ma(e,t,i),h6=(i,e)=>d_(e,i),f6=(i,e)=>(Ue('TSL: "atan2" is overloaded. Use "atan" instead.'),f_(i,e)),IQ=N3,BQ=_3;Ie("all",z5);Ie("any",H5);Ie("equals",t6);Ie("radians",W5);Ie("degrees",$5);Ie("exp",g3);Ie("exp2",Ud);Ie("log",c_);Ie("log2",cl);Ie("sqrt",ws);Ie("inverseSqrt",_3);Ie("floor",hl);Ie("ceil",h_);Ie("normalize",Xs);Ie("fract",Ta);Ie("sin",Vs);Ie("cos",da);Ie("tan",j5);Ie("asin",X5);Ie("acos",v3);Ie("atan",f_);Ie("abs",Di);Ie("sign",x3);Ie("length",fl);Ie("lengthSq",C3);Ie("negate",y3);Ie("oneMinus",Q5);Ie("dFdx",b3);Ie("dFdy",S3);Ie("round",Y5);Ie("reciprocal",K5);Ie("trunc",T3);Ie("fwidth",w3);Ie("atan2",f6);Ie("min",fo);Ie("max",nr);Ie("step",h6);Ie("reflect",n6);Ie("distance",i6);Ie("dot",Ko);Ie("cross",ou);Ie("pow",zo);Ie("pow2",M3);Ie("pow3",s6);Ie("pow4",E3);Ie("transformDirection",o6);Ie("mix",u6);Ie("clamp",wa);Ie("refract",R3);Ie("smoothstep",c6);Ie("faceForward",N3);Ie("difference",r6);Ie("saturate",A_);Ie("cbrt",a6);Ie("transpose",Z5);Ie("determinant",J5);Ie("inverse",e6);Ie("rand",l6);class UQ extends Lt{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const o=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=o?n:n.context({nodeBlock:n}),a.elseNode=r?o?r:r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:o,elseNode:a}=e.getNodeProperties(this),l=e.currentFunctionNode,u=t!=="void",d=u?Yl(n).build(e):"";r.nodeProperty=d;const A=s.build(e,"bool");if(e.context.uniformFlow&&a!==null){const x=o.build(e,n),T=a.build(e,n),S=e.getTernary(A,x,T);return e.format(S,n,t)}e.addFlowCode(` +${e.tab}if ( ${A} ) { + +`).addFlowTab();let v=o.build(e,n);if(v&&(u?v=d+" = "+v+";":(v="return "+v+";",l===null&&(Ue("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),v="// "+v))),e.removeFlowTab().addFlowCode(e.tab+" "+v+` + +`+e.tab+"}"),a!==null){e.addFlowCode(` else { + +`).addFlowTab();let x=a.build(e,n);x&&(u?x=d+" = "+x+";":(x="return "+x+";",l===null&&(Ue("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),x="// "+x))),e.removeFlowTab().addFlowCode(e.tab+" "+x+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(d,n,t)}}const cs=pn(UQ).setParameterLength(2,3);Ie("select",cs);class d6 extends Lt{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(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 n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}}const Au=(i=null,e={})=>{let t=i;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new d6(t,e)},A6=i=>Au(i,{uniformFlow:!0}),P3=(i,e)=>Au(i,{nodeName:e});function p6(i,e,t=null){return Au(t,{getShadow:({light:n,shadowColorNode:r})=>e===n?r.mul(i):r})}function m6(i,e=null){return Au(e,{getAO:(t,{material:n})=>n.transparent===!0?t:t!==null?t.mul(i):i})}function g6(i,e){return Ue('TSL: "label()" has been deprecated. Use "setName()" instead.'),P3(i,e)}Ie("context",Au);Ie("label",g6);Ie("uniformFlow",A6);Ie("setName",P3);Ie("builtinShadowContext",(i,e,t)=>p6(e,t,i));Ie("builtinAOContext",(i,e)=>m6(e,i));class Tg extends Lt{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,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)}getNodeType(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];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const o=t.getDataFromNode(this);o.forceDeclaration=!0,n=!0}const r=t.getBaseStack();n?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:n,readOnly:r}=this,{renderer:s}=e,o=s.backend.isWebGPUBackend===!0;let a=!1,l=!1;r&&(a=e.isDeterministic(t),l=o?r:a);const u=this.getNodeType(e);if(u=="void")return this.isIntent(e)!==!0&&He('TSL: ".toVar()" can not be used with void type.'),t.build(e);const d=e.getVectorType(u),A=t.build(e,d),g=e.getVarFromNode(this,n,d,void 0,l),v=e.getPropertyName(g);let x=v;if(l)if(o)x=a?`const ${v}`:`let ${v}`;else{const T=t.getArrayCount(e);x=`const ${e.getVar(g.type,v,T)}`}return e.addLineFlowCode(`${x} = ${A}`,this),v}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const D3=pn(Tg),_6=(i,e=null)=>D3(i,e).toStack(),v6=(i,e=null)=>D3(i,e,!0).toStack(),x6=i=>D3(i).setIntent(!0).toStack();Ie("toVar",_6);Ie("toConst",v6);Ie("toVarIntent",x6);class FQ extends Lt{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(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 n=this.node.build(e,...t);return e.removeSubBuild(),n}}const $f=(i,e,t=null)=>gt(new FQ(gt(i),e,t));class OQ extends Lt{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,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)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e),o=this.interpolationType,a=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,s,o,a),t.node=$f(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(YA.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(YA.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){const s=this.getNodeType(e),o=e.getPropertyName(r,YA.VERTEX);e.flowNodeFromShaderStage(YA.VERTEX,n.node,s,o),n[t]=o}return e.getPropertyName(r)}}const wl=pn(OQ).setParameterLength(1,2),y6=i=>wl(i);Ie("toVarying",wl);Ie("toVertexStage",y6);Ie("varying",(...i)=>(Ue("TSL: .varying() has been renamed to .toVarying()."),wl(...i)));Ie("vertexStage",(...i)=>(Ue("TSL: .vertexStage() has been renamed to .toVertexStage()."),wl(...i)));const b6=pe(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Wn(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),S6=pe(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Wn(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),L3="WorkingColorSpace",kQ="OutputColorSpace";class I3 extends ir{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===L3?ln.workingColorSpace:t===kQ?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return ln.enabled===!1||n===r||!n||!r||(ln.getTransfer(n)===Pt&&(s=Yt(b6(s.rgb),s.a)),ln.getPrimaries(n)!==ln.getPrimaries(r)&&(s=Yt(ds(ln._getMatrix(new Cn,n,r)).mul(s.rgb),s.a)),ln.getTransfer(r)===Pt&&(s=Yt(S6(s.rgb),s.a))),s}}const T6=(i,e)=>gt(new I3(gt(i),L3,e)),p_=(i,e)=>gt(new I3(gt(i),e,L3)),VQ=(i,e,t)=>gt(new I3(gt(i),e,t));Ie("workingToColorSpace",T6);Ie("colorSpaceToWorking",p_);let GQ=class extends Ch{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class w6 extends Lt{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=yn.OBJECT}setGroup(e){return this.group=e,this}element(e){return new GQ(this,gt(e))}setNodeType(e){const t=$t(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rnew w6(i,e,t);class zQ extends w6{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Wt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const M6=(i,e,t=null)=>new zQ(i,e,t);class HQ extends ir{static get type(){return"ToneMappingNode"}constructor(e,t=C6,n=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return l0(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,n=this._toneMapping;if(n===ls)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=Yt(s(t.rgb,this.exposureNode),t.a):(He("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const E6=(i,e,t)=>gt(new HQ(i,gt(e),gt(t))),C6=M6("toneMappingExposure","float");Ie("toneMapping",(i,e,t)=>E6(e,t,i));const jE=new WeakMap;function XE(i,e){let t=jE.get(i);return t===void 0&&(t=new _b(i,e),jE.set(i,t)),t}class Du extends Jb{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=wd,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){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(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),n=e.getTypeLength(t),r=this.value,s=this.bufferStride||n,o=this.bufferOffset;let a;r.isInterleavedBuffer===!0?a=r:r.isBufferAttribute===!0?a=XE(r.array,s):a=XE(r,s);const l=new il(a,n,o);a.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=wl(this).build(e,t),s}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 m_(i,e=null,t=0,n=0,r=wd,s=!1){return e==="mat3"||e===null&&i.itemSize===9?ds(new Du(i,"vec3",9,0).setUsage(r).setInstanced(s),new Du(i,"vec3",9,3).setUsage(r).setInstanced(s),new Du(i,"vec3",9,6).setUsage(r).setInstanced(s)):e==="mat4"||e===null&&i.itemSize===16?ec(new Du(i,"vec4",16,0).setUsage(r).setInstanced(s),new Du(i,"vec4",16,4).setUsage(r).setInstanced(s),new Du(i,"vec4",16,8).setUsage(r).setInstanced(s),new Du(i,"vec4",16,12).setUsage(r).setInstanced(s)):new Du(i,e,t,n)}const B3=(i,e=null,t=0,n=0)=>m_(i,e,t,n),WQ=(i,e=null,t=0,n=0)=>m_(i,e,t,n,Jc),C1=(i,e=null,t=0,n=0)=>m_(i,e,t,n,wd,!0),ry=(i,e=null,t=0,n=0)=>m_(i,e,t,n,Jc,!0);Ie("toAttribute",i=>B3(i.value));class $Q extends Lt{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=yn.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return Ue('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const s=e.getNodeProperties(this).outputComputeNode;if(s)return s.build(e,t)}}}const U3=(i,e=[64])=>{(e.length===0||e.length>3)&&He("TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;tU3(i,t).setCount(e);Ie("compute",R6);Ie("computeKernel",U3);class jQ extends Lt{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const jf=i=>new jQ(gt(i));function N6(i,e=!0){return Ue('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),jf(i).setParent(e)}Ie("cache",N6);Ie("isolate",jf);class XQ extends Lt{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(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 P6=pn(XQ).setParameterLength(2);Ie("bypass",P6);class D6 extends Lt{static get type(){return"RemapNode"}constructor(e,t,n,r=Z(0),s=Z(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:o}=this;let a=e.sub(t).div(n.sub(t));return o===!0&&(a=a.clamp()),a.mul(s.sub(r)).add(r)}}const L6=pn(D6,null,null,{doClamp:!1}).setParameterLength(3,5),I6=pn(D6).setParameterLength(3,5);Ie("remap",L6);Ie("remapClamp",I6);class wg extends Lt{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(r,n,t)}}const au=pn(wg).setParameterLength(1,2),B6=i=>(i?cs(i,au("discard")):au("discard")).toStack(),QQ=()=>au("return").toStack();Ie("discard",B6);class YQ extends ir{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const n=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||ls,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||to;return n!==ls&&(t=t.toneMapping(n)),r!==to&&r!==ln.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const U6=(i,e=null,t=null)=>gt(new YQ(gt(i),e,t));Ie("renderOutput",U6);class KQ extends ir{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(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,n=this.node.build(e),r="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(r.length);let o="";return o+="// #"+r+`# +`,o+=e.flow.code.replace(/^\t/mg,"")+` +`,o+="/* ... */ "+n+` /* ... */ +`,o+="// #"+s+`# +`,t!==null?t(e,o):P0(o),n}}const F6=(i,e=null)=>gt(new KQ(gt(i),e)).toStack();Ie("debug",F6);class O6{constructor(){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 ZQ extends Lt{static get type(){return"InspectorNode"}constructor(e,t="",n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=yn.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(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!==O6&&Ci('TSL: ".toInspector()" is only available with WebGPU.'),t}}function k6(i,e="",t=null){return i=gt(i),i.before(new ZQ(i,e,t))}Ie("toInspector",k6);function JQ(i){Ue("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class V6 extends Lt{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(s),a=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(a.name,o,n):wl(this).build(e,n)}else return Ue(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}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 lu=(i,e=null)=>new V6(i,e),yi=(i=0)=>lu("uv"+(i>0?i:""),"vec2");class eY extends Lt{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const Kl=pn(eY).setParameterLength(1,2);class tY extends _p{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=yn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const F3=pn(tY).setParameterLength(1),O3=new Dr;class _l extends _p{static get type(){return"TextureNode"}constructor(e=O3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=yn.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}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===vi?"uvec4":this.value.type===jr?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return yi(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=$t(this.value.matrix)),this._matrixUniform.mul(he(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=$t(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(ce(Kl(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");const r=pe(()=>{let o=this.uvNode;return(o===null||e.context.forceUVContext===!0)&&e.context.getUV&&(o=e.context.getUV(this,e)),o||(o=this.getDefaultUV()),this.updateMatrix===!0&&(o=this.getTransformedUV(o)),o=this.setupUV(e,o),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?yn.OBJECT:yn.NONE,o})();let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,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,n,r,s,o,a,l,u){const d=this.value;let A;return s?A=e.generateTextureBias(d,t,n,s,o,u):l?A=e.generateTextureGrad(d,t,n,l,o,u):a?A=e.generateTextureCompare(d,t,n,a,o,u):this.sampler===!1?A=e.generateTextureLoad(d,t,n,r,o,u):r?A=e.generateTextureLevel(d,t,n,r,o,u):A=e.generateTexture(d,t,n,o,u),A}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{const o=e.getDataFromNode(this);let a=o.propertyName;if(a===void 0){const{uvNode:d,levelNode:A,biasNode:g,compareNode:v,depthNode:x,gradNode:T,offsetNode:S}=r,w=this.generateUV(e,d),C=A?A.build(e,"float"):null,E=g?g.build(e,"float"):null,N=x?x.build(e,"int"):null,L=v?v.build(e,"float"):null,B=T?[T[0].build(e,"vec2"),T[1].build(e,"vec2")]:null,I=S?this.generateOffset(e,S):null,F=e.getVarFromNode(this);a=e.getPropertyName(F);const P=this.generateSnippet(e,s,w,C,E,N,L,B,I);e.addLineFlowCode(`${a} = ${P}`,this),o.snippet=P,o.propertyName=a}let l=a;const u=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(l=p_(au(l,u),n.colorSpace).setup(e).build(e,u)),e.format(l,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return Ue("TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=gt(e),t.referenceNode=this.getBase(),gt(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=gt(e).mul(F3(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===xi||n.magFilter===xi)&&(Ue("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),gt(t)}level(e){const t=this.clone();return t.levelNode=gt(e),t.referenceNode=this.getBase(),gt(t)}size(e){return Kl(this,e)}bias(e){const t=this.clone();return t.biasNode=gt(e),t.referenceNode=this.getBase(),gt(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=gt(e),t.referenceNode=this.getBase(),gt(t)}grad(e,t){const n=this.clone();return n.gradNode=[gt(e),gt(t)],n.referenceNode=this.getBase(),gt(n)}depth(e){const t=this.clone();return t.depthNode=gt(e),t.referenceNode=this.getBase(),gt(t)}offset(e){const t=this.clone();return t.offsetNode=gt(e),t.referenceNode=this.getBase(),gt(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 n=this._flipYUniform;n!==null&&(n.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.offsetNode=this.offsetNode,e}}const nY=pn(_l).setParameterLength(1,4).setName("texture"),ti=(i=O3,e=null,t=null,n=null)=>{let r;return i&&i.isTextureNode===!0?(r=gt(i.clone()),r.referenceNode=i.getBase(),e!==null&&(r.uvNode=gt(e)),t!==null&&(r.levelNode=gt(t)),n!==null&&(r.biasNode=gt(n))):r=nY(i,e,t,n),r},iY=(i=O3)=>ti(i),sr=(...i)=>ti(...i).setSampler(!1),rY=(i,e,t)=>ti(i,e).level(t),sY=i=>(i.isNode===!0?i:ti(i)).convert("sampler"),oY=i=>(i.isNode===!0?i:ti(i)).convert("samplerComparison");class k3 extends _p{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,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 xp=(i,e,t)=>new k3(i,e,t);class aY extends Ch{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class lY extends k3{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?ju(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=yn.RENDER,this.isArrayBufferNode=!0}getNodeType(){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,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rnew lY(i,e);class uY extends Lt{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const pu=pn(uY).setParameterLength(1);let SA,TA;class Fi extends Lt{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Fi.DPR?"float":this.scope===Fi.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=yn.NONE;return(this.scope===Fi.SIZE||this.scope===Fi.VIEWPORT||this.scope===Fi.DPR)&&(e=yn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Fi.VIEWPORT?t!==null?TA.copy(t.viewport):(e.getViewport(TA),TA.multiplyScalar(e.getPixelRatio())):this.scope===Fi.DPR?this._output.value=e.getPixelRatio():t!==null?(SA.width=t.width,SA.height=t.height):e.getDrawingBufferSize(SA)}setup(){const e=this.scope;let t=null;return e===Fi.SIZE?t=$t(SA||(SA=new qe)):e===Fi.VIEWPORT?t=$t(TA||(TA=new dn)):e===Fi.DPR?t=$t(1):t=Ze(Nh.div(Sh)),this._output=t,t}generate(e){if(this.scope===Fi.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Sh).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Fi.COORDINATE="coordinate";Fi.VIEWPORT="viewport";Fi.SIZE="size";Fi.UV="uv";Fi.DPR="dpr";const G6=At(Fi,Fi.DPR),Zl=At(Fi,Fi.UV),Sh=At(Fi,Fi.SIZE),Nh=At(Fi,Fi.COORDINATE),V3=At(Fi,Fi.VIEWPORT),G3=V3.zw,q6=Nh.sub(V3.xy),cY=q6.div(G3),hY=pe(()=>(Ue('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Sh),"vec2").once()(),uc=$t(0,"uint").setName("u_cameraIndex").setGroup(u_("cameraIndex")).toVarying("v_cameraIndex"),zu=$t("float").setName("cameraNear").setGroup(Wt).onRenderUpdate(({camera:i})=>i.near),Hu=$t("float").setName("cameraFar").setGroup(Wt).onRenderUpdate(({camera:i})=>i.far),Jl=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrix);e=Ts(t).setGroup(Wt).setName("cameraProjectionMatrices").element(i.isMultiViewCamera?pu("gl_ViewID_OVR"):uc).toConst("cameraProjectionMatrix")}else e=$t("mat4").setName("cameraProjectionMatrix").setGroup(Wt).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),fY=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrixInverse);e=Ts(t).setGroup(Wt).setName("cameraProjectionMatricesInverse").element(i.isMultiViewCamera?pu("gl_ViewID_OVR"):uc).toConst("cameraProjectionMatrixInverse")}else e=$t("mat4").setName("cameraProjectionMatrixInverse").setGroup(Wt).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),ia=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorldInverse);e=Ts(t).setGroup(Wt).setName("cameraViewMatrices").element(i.isMultiViewCamera?pu("gl_ViewID_OVR"):uc).toConst("cameraViewMatrix")}else e=$t("mat4").setName("cameraViewMatrix").setGroup(Wt).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),dY=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorld);e=Ts(t).setGroup(Wt).setName("cameraWorldMatrices").element(i.isMultiViewCamera?pu("gl_ViewID_OVR"):uc).toConst("cameraWorldMatrix")}else e=$t("mat4").setName("cameraWorldMatrix").setGroup(Wt).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),AY=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.normalMatrix);e=Ts(t).setGroup(Wt).setName("cameraNormalMatrices").element(i.isMultiViewCamera?pu("gl_ViewID_OVR"):uc).toConst("cameraNormalMatrix")}else e=$t("mat3").setName("cameraNormalMatrix").setGroup(Wt).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),z6=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let r=0,s=i.cameras.length;r{const o=r.cameras,a=s.array;for(let l=0,u=o.length;ln.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),pY=pe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.viewport);e=Ts(t,"vec4").setGroup(Wt).setName("cameraViewports").element(uc).toConst("cameraViewport")}else e=Yt(0,0,Sh.x,Sh.y).toConst("cameraViewport");return e}).once()(),QE=new ac;class Hn extends Lt{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=yn.OBJECT,this.uniformNode=new _p(null)}getNodeType(){const e=this.scope;if(e===Hn.WORLD_MATRIX)return"mat4";if(e===Hn.POSITION||e===Hn.VIEW_POSITION||e===Hn.DIRECTION||e===Hn.SCALE)return"vec3";if(e===Hn.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,r=this.scope;if(r===Hn.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Hn.POSITION)n.value=n.value||new te,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Hn.SCALE)n.value=n.value||new te,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Hn.DIRECTION)n.value=n.value||new te,t.getWorldDirection(n.value);else if(r===Hn.VIEW_POSITION){const s=e.camera;n.value=n.value||new te,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}else if(r===Hn.RADIUS){const s=e.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),QE.copy(s.boundingSphere).applyMatrix4(t.matrixWorld),n.value=QE.radius}}generate(e){const t=this.scope;return t===Hn.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Hn.POSITION||t===Hn.VIEW_POSITION||t===Hn.DIRECTION||t===Hn.SCALE?this.uniformNode.nodeType="vec3":t===Hn.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}}Hn.WORLD_MATRIX="worldMatrix";Hn.POSITION="position";Hn.SCALE="scale";Hn.VIEW_POSITION="viewPosition";Hn.DIRECTION="direction";Hn.RADIUS="radius";const mY=pn(Hn,Hn.DIRECTION).setParameterLength(1),gY=pn(Hn,Hn.WORLD_MATRIX).setParameterLength(1),H6=pn(Hn,Hn.POSITION).setParameterLength(1),_Y=pn(Hn,Hn.SCALE).setParameterLength(1),vY=pn(Hn,Hn.VIEW_POSITION).setParameterLength(1),xY=pn(Hn,Hn.RADIUS).setParameterLength(1);class Zo extends Hn{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const yY=At(Zo,Zo.DIRECTION),Ho=At(Zo,Zo.WORLD_MATRIX),bY=At(Zo,Zo.POSITION),SY=At(Zo,Zo.SCALE),TY=At(Zo,Zo.VIEW_POSITION),wY=At(Zo,Zo.RADIUS),W6=$t(new Cn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),MY=$t(new gn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),cc=pe(i=>i.context.modelViewMatrix||$6).once()().toVar("modelViewMatrix"),$6=ia.mul(Ho),sy=pe(i=>(i.context.isHighPrecisionModelViewMatrix=!0,$t("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),oy=pe(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return $t("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),yp=lu("position","vec3"),Ki=yp.toVarying("positionLocal"),R1=yp.toVarying("positionPrevious"),dl=pe(i=>Ho.mul(Ki).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),q3=pe(()=>Ki.transformDirection(Ho).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Ar=pe(i=>i.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Ei=pe(i=>{let e;return i.camera.isOrthographicCamera?e=he(0,0,1):e=Ar.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class EY extends Lt{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===Ai?"false":e.getFrontFacing()}}const j6=At(EY),z3=Z(j6).mul(2).sub(1),Kd=pe(([i],{material:e})=>{const t=e.side;return t===Ai?i=i.mul(-1):t===xr&&(i=i.mul(z3)),i}),g_=lu("normal","vec3"),Ao=pe(i=>i.geometry.hasAttribute("normal")===!1?(Ue('TSL: Vertex attribute "normal" not found on geometry.'),he(0,1,0)):g_,"vec3").once()().toVar("normalLocal"),X6=Ar.dFdx().cross(Ar.dFdy()).normalize().toVar("normalFlat"),Fd=pe(i=>{let e;return i.material.flatShading===!0?e=X6:e=H3(Ao).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),Q6=pe(i=>{let e=Fd.transformDirection(ia);return i.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Kn=pe(({subBuildFn:i,material:e,context:t})=>{let n;return i==="NORMAL"||i==="VERTEX"?(n=Fd,e.flatShading!==!0&&(n=Kd(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),hc=Kn.transformDirection(ia).toVar("normalWorld"),rh=pe(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=Kn:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Y6=pe(([i,e=Ho])=>{const t=ds(e),n=i.div(he(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),H3=pe(([i],e)=>{const t=e.context.modelNormalViewMatrix;if(t)return t.transformDirection(i);const n=W6.mul(i);return ia.transformDirection(n)}),CY=pe(()=>(Ue('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Kn)).once(["NORMAL","VERTEX"])(),RY=pe(()=>(Ue('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),hc)).once(["NORMAL","VERTEX"])(),NY=pe(()=>(Ue('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),rh)).once(["NORMAL","VERTEX"])(),YE=new fs,uv=new gn,K6=$t(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),Mg=$t(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),W3=$t(new gn).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const t=e.environment!==null&&i.envMap===null?e.environmentRotation:i.envMapRotation;return t?(YE.copy(t),uv.makeRotationFromEuler(YE)):uv.identity(),uv}),Z6=Ei.negate().reflect(Kn),J6=Ei.negate().refract(Kn,K6),eN=Z6.transformDirection(ia).toVar("reflectVector"),tN=J6.transformDirection(ia).toVar("reflectVector"),nN=new fp;class PY extends _l{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===ba?eN:e.mapping===ml?tN:(He('CubeTextureNode: Mapping "%s" not supported.',e.mapping),he(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===Xo?he(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===Xo||!n.isRenderTargetTexture)&&(t=he(t.x.negate(),t.yz)),W3.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const $3=pn(PY).setParameterLength(1,4).setName("cubeTexture"),qs=(i=nN,e=null,t=null,n=null)=>{let r;return i&&i.isCubeTextureNode===!0?(r=gt(i.clone()),r.referenceNode=i,e!==null&&(r.uvNode=gt(e)),t!==null&&(r.levelNode=gt(t)),n!==null&&(r.biasNode=gt(n))):r=$3(i,e,t,n),r},DY=(i=nN)=>$3(i);class LY extends Ch{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class __ extends Lt{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=yn.OBJECT}element(e){return new LY(this,gt(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return Ue('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=xp(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Ts(null,e):e==="texture"?t=ti(null):e==="cubeTexture"?t=qs(null):t=$t(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rnew __(i,e,t),ay=(i,e,t,n)=>new __(i,e,n,t);class IY extends __{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const ql=(i,e,t=null)=>new IY(i,e,t),iN=yi(),BY=Ar.dFdx(),UY=Ar.dFdy(),rN=iN.dFdx(),sN=iN.dFdy(),oN=Kn,aN=UY.cross(oN),lN=oN.cross(BY),ly=aN.mul(rN.x).add(lN.mul(sN.x)),uy=aN.mul(rN.y).add(lN.mul(sN.y)),KE=ly.dot(ly).max(uy.dot(uy)),uN=KE.equal(0).select(0,KE.inverseSqrt()),FY=ly.mul(uN).toVar("tangentViewFrame"),OY=uy.mul(uN).toVar("bitangentViewFrame"),v_=lu("tangent","vec4"),bp=v_.xyz.toVar("tangentLocal"),x_=pe(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=cc.mul(Yt(bp,0)).xyz.toVarying("v_tangentView").normalize():n=FY,t.flatShading!==!0&&(n=Kd(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),cN=x_.transformDirection(ia).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),y_=pe(([i,e],{subBuildFn:t,material:n})=>{let r=i.mul(v_.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),kY=y_(g_.cross(v_),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),VY=y_(Ao.cross(bp),"v_bitangentLocal").normalize().toVar("bitangentLocal"),hN=pe(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=y_(Kn.cross(x_),"v_bitangentView").normalize():n=OY,t.flatShading!==!0&&(n=Kd(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),GY=y_(hc.cross(cN),"v_bitangentWorld").normalize().toVar("bitangentWorld"),sh=ds(x_,hN,Kn).toVar("TBNViewMatrix"),fN=Ei.mul(sh),qY=(i,e)=>i.sub(fN.mul(e)),dN=pe(()=>{let i=hh.cross(Ei);return i=i.cross(hh).normalize(),i=Wn(i,Kn,Vu.mul(el.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()(),AN=i=>gt(i).mul(.5).add(.5),zY=i=>gt(i).mul(2).sub(1),cy=i=>he(i,ws(A_(Z(1).sub(Ko(i,i)))));class HY extends ir{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=ol,this.unpackNormalMode=d2}setup({material:e}){const{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this;let s=this.node.mul(2).sub(1);if(t===ol?r===oR?s=cy(s.xy):r===kB?s=cy(s.yw):r!==d2&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==d2&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let a=n;e.flatShading===!0&&(a=Kd(a)),s=he(s.xy.mul(a),s.z)}let o=null;return t===sR?o=H3(s):t===ol?o=sh.mul(s).normalize():(He(`NodeMaterial: Unsupported normal map type: ${t}`),o=Kn),o}}const hy=pn(HY).setParameterLength(1,2),WY=pe(({textureNode:i,bumpScale:e})=>{const t=r=>i.isolate().context({getUV:s=>r(s.uvNode||yi()),forceUVContext:!0}),n=Z(t(r=>r));return Ze(Z(t(r=>r.add(r.dFdx()))).sub(n),Z(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),$Y=pe(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),o=t,a=s.cross(o),l=o.cross(r),u=r.dot(a).mul(z3),d=u.sign().mul(n.x.mul(a).add(n.y.mul(l)));return u.abs().mul(t).sub(d).normalize()});class jY extends ir{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=WY({textureNode:this.textureNode,bumpScale:e});return $Y({surf_pos:Ar,surf_norm:Kn,dHdxy:t})}}const j3=pn(jY).setParameterLength(1,2),ZE=new Map;class Be extends Lt{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=ZE.get(e);return n===void 0&&(n=ql(e,t),ZE.set(e,n)),n}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,n=this.scope;let r=null;if(n===Be.COLOR){const s=t.color!==void 0?this.getColor(n):he();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===Be.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===Be.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=Z(1);else if(n===Be.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===Be.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===Be.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===Be.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===Be.EMISSIVE){const s=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=o.mul(this.getTexture(n)):r=o}else if(n===Be.NORMAL)t.normalMap?(r=hy(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==Hs||t.normalMap.format==gh||t.normalMap.format==mh)&&(r.unpackNormalMode=oR)):t.bumpMap?r=j3(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Kn;else if(n===Be.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===Be.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===Be.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=hy(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Kn;else if(n===Be.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===Be.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(1e-4,1)}else if(n===Be.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=a_(Cf.x,Cf.y,Cf.y.negate(),Cf.x).mul(s.rg.mul(2).sub(Ze(1)).normalize().mul(s.b))}else r=Cf;else if(n===Be.IRIDESCENCE_THICKNESS){const s=gi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=gi("0","float",t.iridescenceThicknessRange);r=s.sub(o).mul(this.getTexture(n).g).add(o)}else r=s}else if(n===Be.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===Be.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===Be.IOR)r=this.getFloat(n);else if(n===Be.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===Be.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===Be.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(n):Z(0);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}Be.ALPHA_TEST="alphaTest";Be.COLOR="color";Be.OPACITY="opacity";Be.SHININESS="shininess";Be.SPECULAR="specular";Be.SPECULAR_STRENGTH="specularStrength";Be.SPECULAR_INTENSITY="specularIntensity";Be.SPECULAR_COLOR="specularColor";Be.REFLECTIVITY="reflectivity";Be.ROUGHNESS="roughness";Be.METALNESS="metalness";Be.NORMAL="normal";Be.CLEARCOAT="clearcoat";Be.CLEARCOAT_ROUGHNESS="clearcoatRoughness";Be.CLEARCOAT_NORMAL="clearcoatNormal";Be.EMISSIVE="emissive";Be.ROTATION="rotation";Be.SHEEN="sheen";Be.SHEEN_ROUGHNESS="sheenRoughness";Be.ANISOTROPY="anisotropy";Be.IRIDESCENCE="iridescence";Be.IRIDESCENCE_IOR="iridescenceIOR";Be.IRIDESCENCE_THICKNESS="iridescenceThickness";Be.IOR="ior";Be.TRANSMISSION="transmission";Be.THICKNESS="thickness";Be.ATTENUATION_DISTANCE="attenuationDistance";Be.ATTENUATION_COLOR="attenuationColor";Be.LINE_SCALE="scale";Be.LINE_DASH_SIZE="dashSize";Be.LINE_GAP_SIZE="gapSize";Be.LINE_WIDTH="linewidth";Be.LINE_DASH_OFFSET="dashOffset";Be.POINT_SIZE="size";Be.DISPERSION="dispersion";Be.LIGHT_MAP="light";Be.AO="ao";const pN=At(Be,Be.ALPHA_TEST),mN=At(Be,Be.COLOR),gN=At(Be,Be.SHININESS),_N=At(Be,Be.EMISSIVE),X3=At(Be,Be.OPACITY),vN=At(Be,Be.SPECULAR),fy=At(Be,Be.SPECULAR_INTENSITY),xN=At(Be,Be.SPECULAR_COLOR),f0=At(Be,Be.SPECULAR_STRENGTH),Eg=At(Be,Be.REFLECTIVITY),yN=At(Be,Be.ROUGHNESS),bN=At(Be,Be.METALNESS),SN=At(Be,Be.NORMAL),TN=At(Be,Be.CLEARCOAT),wN=At(Be,Be.CLEARCOAT_ROUGHNESS),MN=At(Be,Be.CLEARCOAT_NORMAL),EN=At(Be,Be.ROTATION),CN=At(Be,Be.SHEEN),RN=At(Be,Be.SHEEN_ROUGHNESS),NN=At(Be,Be.ANISOTROPY),PN=At(Be,Be.IRIDESCENCE),DN=At(Be,Be.IRIDESCENCE_IOR),LN=At(Be,Be.IRIDESCENCE_THICKNESS),IN=At(Be,Be.TRANSMISSION),BN=At(Be,Be.THICKNESS),UN=At(Be,Be.IOR),FN=At(Be,Be.ATTENUATION_DISTANCE),ON=At(Be,Be.ATTENUATION_COLOR),kN=At(Be,Be.LINE_SCALE),VN=At(Be,Be.LINE_DASH_SIZE),GN=At(Be,Be.LINE_GAP_SIZE),XY=At(Be,Be.LINE_WIDTH),qN=At(Be,Be.LINE_DASH_OFFSET),zN=At(Be,Be.POINT_SIZE),HN=At(Be,Be.DISPERSION),Q3=At(Be,Be.LIGHT_MAP),WN=At(Be,Be.AO),Cf=$t(new qe).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))}),$N=pe(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class QY extends Ch{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 n=this.storageBufferNode.structTypeNode;return n?n.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 n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const YY=pn(QY).setParameterLength(2);class KY extends k3{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let r,s=null;t&&t.isStruct?(r="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=n5(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=us.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){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return YY(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(us.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=B3(this.value),this._varying=wl(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(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:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const eu=(i,e=null,t=0)=>new KY(i,e,t),ZY=(i,e,t)=>(Ue('TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),eu(i,e,t).setPBO(!0));class Wi extends Lt{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===Wi.VERTEX)r=e.getVertexIndex();else if(n===Wi.INSTANCE)r=e.getInstanceIndex();else if(n===Wi.DRAW)r=e.getDrawIndex();else if(n===Wi.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===Wi.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===Wi.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=wl(this).build(e,t),s}}Wi.VERTEX="vertex";Wi.INSTANCE="instance";Wi.SUBGROUP="subgroup";Wi.INVOCATION_LOCAL="invocationLocal";Wi.INVOCATION_SUBGROUP="invocationSubgroup";Wi.DRAW="draw";const jN=At(Wi,Wi.VERTEX),Al=At(Wi,Wi.INSTANCE),JY=At(Wi,Wi.SUBGROUP),eK=At(Wi,Wi.INVOCATION_SUBGROUP),tK=At(Wi,Wi.INVOCATION_LOCAL),XN=At(Wi,Wi.DRAW);class QN extends Lt{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=yn.FRAME,this.buffer=null,this.bufferColor=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){const{instanceMatrix:t,instanceColor:n,isStorageMatrix:r,isStorageColor:s}=this,{count:o}=t;let{instanceMatrixNode:a,instanceColorNode:l}=this;if(a===null){if(r)a=eu(t,"mat4",Math.max(o,1)).element(Al);else if(o<=1e3)a=xp(t.array,"mat4",Math.max(o,1)).element(Al);else{const d=new Og(t.array,16,1);this.buffer=d;const A=t.usage===Jc?ry:C1,g=[A(d,"vec4",16,0),A(d,"vec4",16,4),A(d,"vec4",16,8),A(d,"vec4",16,12)];a=ec(...g)}this.instanceMatrixNode=a}if(n&&l===null){if(s)l=eu(n,"vec3",Math.max(n.count,1)).element(Al);else{const d=new Ju(n.array,3),A=n.usage===Jc?ry:C1;this.bufferColor=d,l=he(A(d,"vec3",3,0))}this.instanceColorNode=l}const u=a.mul(Ki).xyz;if(Ki.assign(u),e.hasGeometryAttribute("normal")){const d=Y6(Ao,a);Ao.assign(d)}this.instanceColorNode!==null&&X0("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.usage!==Jc&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.usage!==Jc&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}}const nK=pn(QN).setParameterLength(2,3);class iK extends QN{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const YN=pn(iK).setParameterLength(1);class rK extends Lt{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Al:this.batchingIdNode=XN);const n=pe(([x])=>{const T=ce(Kl(sr(this.batchMesh._indirectTexture),0).x).toConst(),S=ce(x).mod(T).toConst(),w=ce(x).div(T).toConst();return sr(this.batchMesh._indirectTexture,Rr(S,w)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(ce(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=ce(Kl(sr(r),0).x).toConst(),o=Z(n).mul(4).toInt().toConst(),a=o.mod(s).toConst(),l=o.div(s).toConst(),u=ec(sr(r,Rr(a,l)),sr(r,Rr(a.add(1),l)),sr(r,Rr(a.add(2),l)),sr(r,Rr(a.add(3),l))),d=this.batchMesh._colorsTexture;if(d!==null){const T=pe(([S])=>{const w=ce(Kl(sr(d),0).x).toConst(),C=S,E=C.mod(w).toConst(),N=C.div(w).toConst();return sr(d,Rr(E,N)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);X0("vec3","vBatchColor").assign(T)}const A=ds(u);Ki.assign(u.mul(Ki));const g=Ao.div(he(A[0].dot(A[0]),A[1].dot(A[1]),A[2].dot(A[2]))),v=A.mul(g).xyz;Ao.assign(v),e.hasGeometryAttribute("tangent")&&bp.mulAssign(A)}}const KN=pn(rK).setParameterLength(1),JE=new WeakMap;class ZN extends Lt{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=yn.OBJECT,this.skinIndexNode=lu("skinIndex","uvec4"),this.skinWeightNode=lu("skinWeight","vec4"),this.bindMatrixNode=gi("bindMatrix","mat4"),this.bindMatrixInverseNode=gi("bindMatrixInverse","mat4"),this.boneMatricesNode=ay("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Ki,this.toPositionNode=Ki,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:o}=this,a=e.element(n.x),l=e.element(n.y),u=e.element(n.z),d=e.element(n.w),A=s.mul(t),g=br(a.mul(r.x).mul(A),l.mul(r.y).mul(A),u.mul(r.z).mul(A),d.mul(r.w).mul(A));return o.mul(g).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ao){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:o}=this,a=e.element(n.x),l=e.element(n.y),u=e.element(n.z),d=e.element(n.w);let A=br(r.x.mul(a),r.y.mul(l),r.z.mul(u),r.w.mul(d));return A=o.mul(A).mul(s),A.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=ay("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,R1)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||r5(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&R1.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Ao.assign(n),e.hasGeometryAttribute("tangent")&&bp.assign(n)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;JE.get(t)!==e.frameId&&(JE.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const JN=i=>new ZN(i),sK=(i,e=null)=>{const t=new ZN(i);return t.positionNode=eu(new Ju(i.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Al).toVar(),t.skinIndexNode=eu(new Ju(new Uint32Array(i.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Al).toVar(),t.skinWeightNode=eu(new Ju(i.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Al).toVar(),t.bindMatrixNode=$t(i.bindMatrix,"mat4"),t.bindMatrixInverseNode=$t(i.bindMatrixInverse,"mat4"),t.boneMatricesNode=xp(i.skeleton.boneMatrices,"mat4",i.skeleton.bones.length),t.toPositionNode=e,gt(t)};class oK extends Lt{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 n={};for(let a=0,l=this.params.length-1;aNumber(A)?x=">=":x="<"));let S;if(u)S=`while ( ${A} )`;else{const w={start:d,end:A},C=w.start,E=w.end;let N;const L=()=>x.includes("<")?"+=":"-=";if(T!=null)switch(typeof T){case"function":N=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":N=g+" "+L()+" "+e.generateConst(v,T);break;case"string":N=g+" "+T;break;default:T.isNode?N=g+" "+L()+" "+T.build(e):(He("TSL: 'Loop( { update: ... } )' is not a function, string or number."),N="break /* invalid update */")}else v==="int"||v==="uint"?T=x.includes("<")?"++":"--":T=L()+" 1.",N=g+" "+T;const B=e.getVar(v,g)+" = "+C,I=g+" "+x+" "+E;S=`for ( ${B}; ${I}; ${N} )`}e.addFlowCode((o===0?` +`:"")+e.tab+S+` { + +`).addFlowTab()}const s=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(` +`+e.tab+s);for(let o=0,a=this.params.length-1;onew oK(ch(i,"int")).toStack(),aK=()=>au("continue").toStack(),eP=()=>au("break").toStack(),cv=new WeakMap,bo=new dn,e4=pe(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const o=ce(jN).mul(t).add(s),a=o.div(n),l=o.sub(a.mul(n));return sr(i,Rr(l,a)).depth(r).xyz.mul(e)});function lK(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let o=cv.get(i);if(o===void 0||o.count!==s){let C=function(){S.dispose(),cv.delete(i),i.removeEventListener("dispose",C)};var a=C;o!==void 0&&o.texture.dispose();const l=i.morphAttributes.position||[],u=i.morphAttributes.normal||[],d=i.morphAttributes.color||[];let A=0;e===!0&&(A=1),t===!0&&(A=2),n===!0&&(A=3);let g=i.attributes.position.count*A,v=1;const x=4096;g>x&&(v=Math.ceil(g/x),g=x);const T=new Float32Array(g*v*4*s),S=new db(T,g,v,s);S.type=dr,S.needsUpdate=!0;const w=A*4;for(let E=0;E{const g=Z(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?g.assign(sr(this.mesh.morphTexture,Rr(ce(A).add(1),ce(Al))).r):g.assign(gi("morphTargetInfluences","float").element(A).toVar()),Xt(g.notEqual(0),()=>{n===!0&&Ki.addAssign(e4({bufferMap:a,influence:g,stride:l,width:d,depth:A,offset:ce(0)})),r===!0&&Ao.addAssign(e4({bufferMap:a,influence:g,stride:l,width:d,depth:A,offset:ce(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const tP=pn(uK).setParameterLength(1);class Zd extends Lt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class cK extends Zd{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class hK extends d6{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=he().toVar("directDiffuse"),r=he().toVar("directSpecular"),s=he().toVar("indirectDiffuse"),o=he().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:o};return{radiance:he().toVar("radiance"),irradiance:he().toVar("irradiance"),iblIrradiance:he().toVar("iblIrradiance"),ambientOcclusion:Z(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const nP=pn(hK);class fK extends Zd{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const pf=new qe;class b_ extends _l{static get type(){return"ViewportTextureNode"}constructor(e=Zl,t=null,n=null){let r=null;n===null?(r=new bb,r.minFilter=ro,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=yn.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){const r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(pf):pf.set(n.width,n.height);const r=this.getTextureForReference(n);(r.image.width!==pf.width||r.image.height!==pf.height)&&(r.image.width=pf.width,r.image.height=pf.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const dK=pn(b_).setParameterLength(0,3),Y3=pn(b_,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Pm=null;class AK extends b_{static get type(){return"ViewportDepthTextureNode"}constructor(e=Zl,t=null){Pm===null&&(Pm=new Ms),super(e,t,Pm)}getTextureForReference(){return Pm}}const K3=pn(AK).setParameterLength(0,2);class lo extends Lt{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===lo.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===lo.DEPTH_BASE)n!==null&&(r=rP().assign(n));else if(t===lo.DEPTH)e.isPerspectiveCamera?r=iP(Ar.z,zu,Hu):r=Xf(Ar.z,zu,Hu);else if(t===lo.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=Z3(n,zu,Hu);r=Xf(s,zu,Hu)}else r=n;else r=Xf(Ar.z,zu,Hu);return r}}lo.DEPTH_BASE="depthBase";lo.DEPTH="depth";lo.LINEAR_DEPTH="linearDepth";const Xf=(i,e,t)=>i.add(e).div(e.sub(t)),pK=(i,e,t)=>e.sub(t).mul(i).sub(e),iP=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),Z3=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),J3=(i,e,t)=>{e=e.max(1e-6).toVar();const n=cl(i.negate().div(e)),r=cl(t.div(e));return n.div(r)},mK=(i,e,t)=>{const n=i.mul(c_(t.div(e)));return Z(Math.E).pow(n).mul(e).negate()},rP=pn(lo,lo.DEPTH_BASE),eS=At(lo,lo.DEPTH),N1=pn(lo,lo.LINEAR_DEPTH).setParameterLength(0,1),gK=N1(K3());eS.assign=i=>rP(i);class jo extends Lt{static get type(){return"ClippingNode"}constructor(e=jo.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===jo.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===jo.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return pe(()=>{const n=Z().toVar("distanceToPlane"),r=Z().toVar("distanceToGradient"),s=Z(1).toVar("clipOpacity"),o=t.length;if(this.hardwareClipping===!1&&o>0){const l=Ts(t).setGroup(Wt);di(o,({i:u})=>{const d=l.element(u);n.assign(Ar.dot(d.xyz).negate().add(d.w)),r.assign(n.fwidth().div(2)),s.mulAssign(Ma(r.negate(),r,n))})}const a=e.length;if(a>0){const l=Ts(e).setGroup(Wt),u=Z(1).toVar("intersectionClipOpacity");di(a,({i:d})=>{const A=l.element(d);n.assign(Ar.dot(A.xyz).negate().add(A.w)),r.assign(n.fwidth().div(2)),u.mulAssign(Ma(r.negate(),r,n).oneMinus())}),s.mulAssign(u.oneMinus())}hi.a.mulAssign(s),hi.a.equal(0).discard()})()}setupDefault(e,t){return pe(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=Ts(t).setGroup(Wt);di(n,({i:o})=>{const a=s.element(o);Ar.dot(a.xyz).greaterThan(a.w).discard()})}const r=e.length;if(r>0){const s=Ts(e).setGroup(Wt),o=Yo(!0).toVar("clipped");di(r,({i:a})=>{const l=s.element(a);o.assign(Ar.dot(l.xyz).greaterThan(l.w).and(o))}),o.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),pe(()=>{const r=Ts(e).setGroup(Wt),s=pu(t.getClipDistance());di(n,({i:o})=>{const a=r.element(o),l=Ar.dot(a.xyz).sub(a.w).negate();s.element(o).assign(l)})})()}}jo.ALPHA_TO_COVERAGE="alphaToCoverage";jo.DEFAULT="default";jo.HARDWARE="hardware";const _K=()=>new jo,vK=()=>new jo(jo.ALPHA_TO_COVERAGE),xK=()=>new jo(jo.HARDWARE),yK=.05,t4=pe(([i])=>Ta(An(1e4,Vs(An(17,i.x).add(An(.1,i.y)))).mul(br(.1,Di(Vs(An(13,i.y).add(i.x))))))),n4=pe(([i])=>t4(Ze(t4(i.xy),i.z))),bK=pe(([i])=>{const e=nr(fl(b3(i.xyz)),fl(S3(i.xyz))),t=Z(1).div(Z(yK).mul(e)).toVar("pixScale"),n=Ze(Ud(hl(cl(t))),Ud(h_(cl(t)))),r=Ze(n4(hl(n.x.mul(i.xyz))),n4(hl(n.y.mul(i.xyz)))),s=Ta(cl(t)),o=br(An(s.oneMinus(),r.x),An(s,r.y)),a=fo(s,s.oneMinus()),l=he(o.mul(o).div(An(2,a).mul(jn(1,a))),o.sub(An(.5,a)).div(jn(1,a)),jn(1,jn(1,o).mul(jn(1,o)).div(An(2,a).mul(jn(1,a))))),u=o.lessThan(a.oneMinus()).select(o.lessThan(a).select(l.x,l.y),l.z);return wa(u,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class SK extends V6{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),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new dn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const sP=(i=0)=>new SK(i),oP=pe(([i,e])=>fo(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),aP=pe(([i,e])=>fo(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),lP=pe(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),uP=pe(([i,e])=>Wn(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),d_(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),TK=pe(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return Yt(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),cP=pe(([i])=>Yt(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),wK=pe(([i])=>(Xt(i.a.equal(0),()=>Yt(0)),Yt(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"}),MK=(...i)=>(Ue('TSL: "burn" has been renamed. Use "blendBurn" instead.'),oP(i)),EK=(...i)=>(Ue('TSL: "dodge" has been renamed. Use "blendDodge" instead.'),aP(i)),CK=(...i)=>(Ue('TSL: "screen" has been renamed. Use "blendScreen" instead.'),lP(i)),RK=(...i)=>(Ue('TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),uP(i));class lr extends Cs{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.hardwareClipping=!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.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,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{Ue('NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:n}of this._getNodeChildren())e.push(gp(t.slice(0,-4)),n.getCacheKey());return this.type+Yd(e)}build(e){this.setup(e)}setupObserver(e){return new QX(e)}setup(e){e.context.setupNormal=()=>$f(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:He('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:He('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const r=$f(this.setupVertex(e),"VERTEX"),s=this.vertexNode||r;e.stack.outputNode=s,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)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.addToStack(a);const u=Yt(l,hi.a).max(0);o=this.setupOutput(e,u),Wf.assign(o);const d=this.outputNode!==null;if(d&&(o=this.outputNode),e.context.getOutput&&(o=e.context.getOutput(o,e)),n!==null){const A=t.getMRT(),g=this.mrtNode;A!==null?(d&&Wf.assign(o),o=A,g!==null&&(o=A.merge(g))):g!==null&&(o=g)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Yt(l)),o=this.setupOutput(e,l)}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:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.currentSamples;this.alphaToCoverage&&s>1?r=vK():e.stack.addToStack(_K())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(xK()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=J3(Ar.z,zu,Hu):r=Xf(Ar.z,zu,Hu))}r!==null&&eS.assign(r).toStack()}setupPositionView(){return cc.mul(Ki).xyz}setupModelViewProjection(){return Jl.mul(Ar)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),$N}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&tP(t).toStack(),t.isSkinnedMesh===!0&&JN(t).toStack(),this.displacementMap){const r=ql("displacementMap","texture"),s=ql("displacementScale","float"),o=ql("displacementBias","float");Ki.addAssign(Ao.normalize().mul(r.x.mul(s).add(o)))}return t.isBatchedMesh&&KN(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&YN(t).toStack(),this.positionNode!==null&&Ki.assign($f(this.positionNode,"POSITION","vec3")),Ki}setupDiffuseColor(e){const{object:t,geometry:n}=e;this.maskNode!==null&&Yo(this.maskNode).not().discard();let r=this.colorNode?Yt(this.colorNode):mN;this.vertexColors===!0&&n.hasAttribute("color")&&(r=r.mul(sP())),t.instanceColor&&(r=X0("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=X0("vec3","vBatchColor").mul(r)),hi.assign(r);const s=this.opacityNode?Z(this.opacityNode):X3;hi.a.assign(hi.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?Z(this.alphaTestNode):pN,this.alphaToCoverage===!0?(hi.a=Ma(o,o.add(w3(hi.a)),hi.a),hi.a.lessThanEqual(0).discard()):hi.a.lessThanEqual(o).discard()),this.alphaHash===!0&&hi.a.lessThan(bK(Ki)).discard(),e.isOpaque()&&hi.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?he(0):hi.rgb}setupNormal(){return this.normalNode?he(this.normalNode):SN}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ql("envMap","cubeTexture"):ql("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new fK(Q3)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let s=this.aoNode;s===null&&e.material.aoMap&&(s=WN),e.context.getAO&&(s=e.context.getAO(s,e)),s&&t.push(new cK(s));let o=this.lightsNode||e.lightsNode;return t.length>0&&(o=e.renderer.lighting.createNode([...o.getLights(),...t])),o}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let l=this.setupOutgoingLight(e);if(a&&a.getScope().hasLights){const u=this.setupLightingModel(e)||null;l=nP(a,u,n,r)}else n!==null&&(l=he(r!==null?Wn(l,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(ny.assign(he(s||_N)),l=l.add(ny)),l}setupFog(e,t){const n=e.fogNode;return n&&(Wf.assign(t),t=Yt(n.toVar())),t}setupPremultipliedAlpha(e,t){return cP(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 n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=Cs.prototype.toJSON.call(this,e);n.inputNodes={};for(const{property:s,childNode:o}of this._getNodeChildren())n.inputNodes[s]=o.toJSON(e).uuid;function r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=r(e.textures),o=r(e.images),a=r(e.nodes);s.length>0&&(n.textures=s),o.length>0&&(n.images=o),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const NK=new jd;class PK extends lr{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(NK),this.setValues(e)}}const DK=new RU;class LK extends lr{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(DK),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Z(this.offsetNode):qN,t=this.dashScaleNode?Z(this.dashScaleNode):kN,n=this.dashSizeNode?Z(this.dashSizeNode):VN,r=this.gapSizeNode?Z(this.gapSizeNode):GN;Sg.assign(n),iy.assign(r);const s=wl(lu("lineDistance").mul(t));(e?s.add(e):s).mod(Sg.add(iy)).greaterThan(Sg).discard()}}let Dm=null;class IK extends b_{static get type(){return"ViewportSharedTextureNode"}constructor(e=Zl,t=null){Dm===null&&(Dm=new bb),super(e,t,Dm)}getTextureForReference(){return Dm}updateReference(){return this}}const BK=pn(IK).setParameterLength(0,2),UK=new wU;class FK extends lr{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(UK),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Z(this.opacityNode):X3;hi.assign(p_(Yt(AN(Kn),e),as))}}const tS=pe(([i=q3])=>{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 Ze(e,t)});class hP extends gb{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=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 s=new lc(5,5,5),o=tS(q3),a=new lr;a.colorNode=ti(t,o,0),a.side=Ai,a.blending=$s;const l=new si(s,a),u=new $1;u.add(l),t.minFilter===ro&&(t.minFilter=ki);const d=new hR(1,10,this),A=e.getMRT();return e.setMRT(null),d.update(e,u),e.setMRT(A),t.minFilter=n,t.currentGenerateMipmaps=r,l.geometry.dispose(),l.material.dispose(),this}}const d0=new WeakMap;class OK extends ir{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=qs(null);const t=new fp;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=yn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const o=s.mapping;if(o===Zf||o===Jf){if(d0.has(s)){const a=d0.get(s);i4(a,s.mapping),this._cubeTexture=a}else{const a=s.image;if(kK(a)){const l=new hP(a.height);l.fromEquirectangularTexture(t,s),i4(l.texture,s.mapping),this._cubeTexture=l.texture,d0.set(s,l.texture),s.addEventListener("dispose",fP)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function kK(i){return i==null?!1:i.height>0}function fP(i){const e=i.target;e.removeEventListener("dispose",fP);const t=d0.get(e);t!==void 0&&(d0.delete(e),t.dispose())}function i4(i,e){e===Zf?i.mapping=ba:e===Jf&&(i.mapping=ml)}const dP=pn(OK).setParameterLength(1);class nS extends Zd{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=dP(this.envNode)}}class VK extends Zd{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Z(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class S_{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class AP extends S_{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(Yt(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(Yt(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(hi.rgb)}finish(e){const{material:t,context:n}=e,r=n.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case rp:r.rgb.assign(Wn(r.rgb,r.rgb.mul(s.rgb),f0.mul(Eg)));break;case nR:r.rgb.assign(Wn(r.rgb,s.rgb,f0.mul(Eg)));break;case iR:r.rgb.addAssign(s.rgb.mul(f0.mul(Eg)));break;default:Ue("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const GK=new no;class qK extends lr{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(GK),this.setValues(e)}setupNormal(){return Kd(Fd)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new nS(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new VK(Q3)),t}setupOutgoingLight(){return hi.rgb}setupLightingModel(){return new AP}}const Od=pe(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),Th=pe(i=>i.diffuseColor.mul(1/Math.PI)),zK=()=>Z(.25),HK=pe(({dotNH:i})=>w1.mul(Z(.5)).add(1).mul(Z(1/Math.PI)).mul(i.pow(w1))),WK=pe(({lightDirection:i})=>{const e=i.add(Ei).normalize(),t=Kn.dot(e).clamp(),n=Ei.dot(e).clamp(),r=Od({f0:sc,f90:1,dotVH:n}),s=zK(),o=HK({dotNH:t});return r.mul(s).mul(o)});class pP extends AP{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kn.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(Th({diffuseColor:hi.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(WK({lightDirection:e})).mul(f0))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Th({diffuseColor:hi}))),r.indirectDiffuse.mulAssign(t)}}const $K=new du;class jK extends lr{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues($K),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new nS(t):null}setupLightingModel(){return new pP(!1)}}const XK=new MR;class QK extends lr{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(XK),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new nS(t):null}setupLightingModel(){return new pP}setupVariants(){const e=(this.shininessNode?Z(this.shininessNode):gN).max(1e-4);w1.assign(e);const t=this.specularNode||vN;sc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const mP=pe(i=>{if(i.geometry.hasAttribute("normal")===!1)return Z(0);const e=Fd.dFdx().abs().max(Fd.dFdy().abs());return e.x.max(e.y).max(e.z)}),iS=pe(i=>{const{roughness:e}=i,t=mP();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),gP=pe(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Io(.5,r.add(s).max(m3))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),YK=pe(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:o,dotNL:a})=>{const l=a.mul(he(i.mul(t),e.mul(n),o).length()),u=o.mul(he(i.mul(r),e.mul(s),a).length());return Io(.5,l.add(u))}).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"}]}),_P=pe(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),KK=Z(1/Math.PI),ZK=pe(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),o=he(e.mul(n),i.mul(r),s.mul(t)),a=o.dot(o),l=s.div(a);return KK.mul(s.mul(l.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"}]}),rS=pe(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,normalView:s=Kn,USE_IRIDESCENCE:o,USE_ANISOTROPY:a})=>{const l=n.pow2(),u=i.add(Ei).normalize(),d=s.dot(i).clamp(),A=s.dot(Ei).clamp(),g=s.dot(u).clamp(),v=Ei.dot(u).clamp();let x=Od({f0:e,f90:t,dotVH:v}),T,S;if($0(o)&&(x=l_.mix(x,r)),$0(a)){const w=c0.dot(i),C=c0.dot(Ei),E=c0.dot(u),N=hh.dot(i),L=hh.dot(Ei),B=hh.dot(u);T=YK({alphaT:T1,alphaB:l,dotTV:C,dotBV:L,dotTL:w,dotBL:N,dotNV:A,dotNL:d}),S=ZK({alphaT:T1,alphaB:l,dotNH:g,dotTH:E,dotBH:B})}else T=gP({alpha:l,dotNL:d,dotNV:A}),S=_P({alpha:l,dotNH:g});return x.mul(T).mul(S)}),JK=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 Wa=null;const Y0=pe(({roughness:i,dotNV:e})=>{Wa===null&&(Wa=new vb(JK,16,16,Hs,zi),Wa.name="DFG_LUT",Wa.minFilter=ki,Wa.magFilter=ki,Wa.wrapS=io,Wa.wrapT=io,Wa.generateMipmaps=!1,Wa.needsUpdate=!0);const t=Ze(i,e);return ti(Wa,t).rg}),eZ=pe(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:s,USE_ANISOTROPY:o})=>{const a=rS({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:s,USE_ANISOTROPY:o}),l=Kn.dot(i).clamp(),u=Kn.dot(Ei).clamp(),d=Y0({roughness:n,dotNV:u}),A=Y0({roughness:n,dotNV:l}),g=e.mul(d.x).add(t.mul(d.y)),v=e.mul(A.x).add(t.mul(A.y)),x=d.x.add(d.y),T=A.x.add(A.y),S=Z(1).sub(x),w=Z(1).sub(T),C=e.add(e.oneMinus().mul(.047619)),E=g.mul(v).mul(C).div(Z(1).sub(S.mul(w).mul(C).mul(C)).add(m3)),N=S.mul(w),L=E.mul(N);return a.add(L)}),vP=pe(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=Y0({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),dy=pe(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(he(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),tZ=pe(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=Z(1).div(t),s=e.pow2().oneMinus().max(.0078125);return Z(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),nZ=pe(({dotNV:i,dotNL:e})=>Z(1).div(Z(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),iZ=pe(({lightDirection:i})=>{const e=i.add(Ei).normalize(),t=Kn.dot(i).clamp(),n=Kn.dot(Ei).clamp(),r=Kn.dot(e).clamp(),s=tZ({roughness:qu,dotNH:r}),o=nZ({dotNV:n,dotNL:t});return To.mul(s).mul(o)}),rZ=pe(({N:i,V:e,roughness:t})=>{const s=.0078125,o=i.dot(e).saturate(),a=Ze(t,o.oneMinus().sqrt());return a.assign(a.mul(.984375).add(s)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),sZ=pe(({f:i})=>{const e=i.length();return nr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Lm=pe(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),o=r.div(s),a=t.greaterThan(0).select(o,nr(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"}]}),r4=pe(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:o,p3:a})=>{const l=s.sub(r).toVar(),u=a.sub(r).toVar(),d=l.cross(u),A=he().toVar();return Xt(d.dot(t.sub(r)).greaterThanEqual(0),()=>{const g=e.sub(i.mul(e.dot(i))).normalize(),v=i.cross(g).negate(),x=n.mul(ds(g,v,i).transpose()).toVar(),T=x.mul(r.sub(t)).normalize().toVar(),S=x.mul(s.sub(t)).normalize().toVar(),w=x.mul(o.sub(t)).normalize().toVar(),C=x.mul(a.sub(t)).normalize().toVar(),E=he(0).toVar();E.addAssign(Lm({v1:T,v2:S})),E.addAssign(Lm({v1:S,v2:w})),E.addAssign(Lm({v1:w,v2:C})),E.addAssign(Lm({v1:C,v2:T})),A.assign(he(sZ({f:E})))}),A}).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"}]}),T_=1/6,xP=i=>An(T_,An(i,An(i,i.negate().add(3)).sub(3)).add(1)),Ay=i=>An(T_,An(i,An(i,An(3,i).sub(6))).add(4)),yP=i=>An(T_,An(i,An(i,An(-3,i).add(3)).add(3)).add(1)),py=i=>An(T_,zo(i,3)),s4=i=>xP(i).add(Ay(i)),o4=i=>yP(i).add(py(i)),a4=i=>br(-1,Ay(i).div(xP(i).add(Ay(i)))),l4=i=>br(1,py(i).div(yP(i).add(py(i)))),u4=(i,e,t)=>{const n=i.uvNode,r=An(n,e.zw).add(.5),s=hl(r),o=Ta(r),a=s4(o.x),l=o4(o.x),u=a4(o.x),d=l4(o.x),A=a4(o.y),g=l4(o.y),v=Ze(s.x.add(u),s.y.add(A)).sub(.5).mul(e.xy),x=Ze(s.x.add(d),s.y.add(A)).sub(.5).mul(e.xy),T=Ze(s.x.add(u),s.y.add(g)).sub(.5).mul(e.xy),S=Ze(s.x.add(d),s.y.add(g)).sub(.5).mul(e.xy),w=s4(o.y).mul(br(a.mul(i.sample(v).level(t)),l.mul(i.sample(x).level(t)))),C=o4(o.y).mul(br(a.mul(i.sample(T).level(t)),l.mul(i.sample(S).level(t))));return w.add(C)},sS=pe(([i,e])=>{const t=Ze(i.size(ce(e))),n=Ze(i.size(ce(e.add(1)))),r=Io(1,t),s=Io(1,n),o=u4(i,Yt(r,t),hl(e)),a=u4(i,Yt(s,n),h_(e));return Ta(e).mix(o,a)}),oZ=pe(([i,e])=>{const t=e.mul(F3(i));return sS(i,t)}),c4=pe(([i,e,t,n,r])=>{const s=he(R3(e.negate(),Xs(i),Io(1,n))),o=he(fl(r[0].xyz),fl(r[1].xyz),fl(r[2].xyz));return Xs(s).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"}]}),aZ=pe(([i,e])=>i.mul(wa(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),lZ=Y3(),uZ=Y3(),h4=pe(([i,e,t],{material:n})=>{const s=(n.side===Ai?lZ:uZ).sample(i),o=cl(Sh.x).mul(aZ(e,t));return sS(s,o)}),f4=pe(([i,e,t])=>(Xt(t.notEqual(0),()=>{const n=c_(e).negate().div(t);return g3(n.negate().mul(i))}),he(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),cZ=pe(([i,e,t,n,r,s,o,a,l,u,d,A,g,v,x])=>{let T,S;if(x){T=Yt().toVar(),S=he().toVar();const L=d.sub(1).mul(x.mul(.025)),B=he(d.sub(L),d,d.add(L));di({start:0,end:3},({i:I})=>{const F=B.element(I),P=c4(i,e,A,F,a),O=o.add(P),G=u.mul(l.mul(Yt(O,1))),q=Ze(G.xy.div(G.w)).toVar();q.addAssign(1),q.divAssign(2),q.assign(Ze(q.x,q.y.oneMinus()));const j=h4(q,t,F);T.element(I).assign(j.element(I)),T.a.addAssign(j.a),S.element(I).assign(n.element(I).mul(f4(fl(P),g,v).element(I)))}),T.a.divAssign(3)}else{const L=c4(i,e,A,d,a),B=o.add(L),I=u.mul(l.mul(Yt(B,1))),F=Ze(I.xy.div(I.w)).toVar();F.addAssign(1),F.divAssign(2),F.assign(Ze(F.x,F.y.oneMinus())),T=h4(F,t,d),S=n.mul(f4(fl(L),g,v))}const w=S.rgb.mul(T.rgb),C=i.dot(e).clamp(),E=he(vP({dotNV:C,specularColor:r,specularF90:s,roughness:t})),N=S.r.add(S.g,S.b).div(3);return Yt(E.oneMinus().mul(w),T.a.oneMinus().mul(N).oneMinus())}),hZ=ds(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),fZ=i=>{const e=i.sqrt();return he(1).add(e).div(he(1).sub(e))},d4=(i,e)=>i.sub(e).div(i.add(e)).pow2(),dZ=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=he(54856e-17,44201e-17,52481e-17),r=he(1681e3,1795300,2208400),s=he(43278e5,93046e5,66121e5),o=Z(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return a=he(a.x.add(o),a.y,a.z).div(10685e-11),hZ.mul(a)},A4=pe(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Wn(i,e,Ma(0,.03,n)),a=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();Xt(a.lessThan(0),()=>he(1));const l=a.sqrt(),u=d4(s,i),d=Od({f0:u,f90:1,dotVH:t}),A=d.oneMinus(),g=s.lessThan(i).select(Math.PI,0),v=Z(Math.PI).sub(g),x=fZ(r.clamp(0,.9999)),T=d4(x,s.toVec3()),S=Od({f0:T,f90:1,dotVH:l}),w=he(x.x.lessThan(s).select(Math.PI,0),x.y.lessThan(s).select(Math.PI,0),x.z.lessThan(s).select(Math.PI,0)),C=s.mul(n,l,2),E=he(v).add(w),N=d.mul(S).clamp(1e-5,.9999),L=N.sqrt(),B=A.pow2().mul(S).div(he(1).sub(N)),F=d.add(B).toVar(),P=B.sub(A).toVar();return di({start:1,end:2,condition:"<=",name:"m"},({m:O})=>{P.mulAssign(L);const G=dZ(Z(O).mul(C),Z(O).mul(E)).mul(2);F.addAssign(P.mul(G))}),F.max(he(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"}]}),wA=pe(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.mul(t),s=t.add(.1).reciprocal(),o=Z(-1.9362).add(t.mul(1.0678)).add(r.mul(.4573)).sub(s.mul(.8469)),a=Z(-.6014).add(t.mul(.5538)).sub(r.mul(.467)).sub(s.mul(.1255));return o.mul(n).add(a).exp().saturate()}),hv=he(.04),fv=Z(1);class bP extends S_{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,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=he().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=he().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=he().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=he().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=he().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Kn.dot(Ei).clamp(),n=A4({outsideIOR:Z(1),eta2:b1,cosTheta1:t,thinFilmThickness:S1,baseF0:sc}),r=A4({outsideIOR:Z(1),eta2:b1,cosTheta1:t,thinFilmThickness:S1,baseF0:hi.rgb});this.iridescenceFresnel=Wn(n,r,$l),this.iridescenceF0Dielectric=dy({f:n,f90:1,dotVH:t}),this.iridescenceF0Metallic=dy({f:r,f90:1,dotVH:t}),this.iridescenceF0=Wn(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,$l)}if(this.transmission===!0){const t=dl,n=z6.sub(dl).normalize(),r=hc,s=e.context;s.backdrop=cZ(r,n,el,$c,ih,Hf,t,Ho,ia,Jl,h0,u3,h3,c3,this.dispersion?f3:null),s.backdropAlpha=M1,hi.a.mulAssign(Wn(1,s.backdrop.a,M1))}super.start(e)}computeMultiscattering(e,t,n,r,s=null){const o=Kn.dot(Ei).clamp(),a=Y0({roughness:el,dotNV:o}),l=s?l_.mix(r,s):r,u=l.mul(a.x).add(n.mul(a.y)),A=a.x.add(a.y).oneMinus(),g=l.add(l.oneMinus().mul(.047619)),v=u.mul(g).div(A.mul(g).oneMinus());e.addAssign(u),t.addAssign(v.mul(A))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kn.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(s.mul(iZ({lightDirection:e})));const o=wA({normal:Kn,viewDir:Ei,roughness:qu}),a=wA({normal:Kn,viewDir:e,roughness:qu}),l=To.r.max(To.g).max(To.b).mul(o.max(a)).oneMinus();s.mulAssign(l)}if(this.clearcoat===!0){const a=rh.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(rS({lightDirection:e,f0:hv,f90:fv,roughness:Q0,normalView:rh})))}n.directDiffuse.addAssign(s.mul(Th({diffuseColor:$c}))),n.directSpecular.addAssign(s.mul(eZ({lightDirection:e,f0:ih,f90:1,roughness:el,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:o,ltc_2:a}){const l=t.add(n).sub(r),u=t.sub(n).sub(r),d=t.sub(n).add(r),A=t.add(n).add(r),g=Kn,v=Ei,x=Ar.toVar(),T=rZ({N:g,V:v,roughness:el}),S=o.sample(T).toVar(),w=a.sample(T).toVar(),C=ds(he(S.x,0,S.y),he(0,1,0),he(S.z,0,S.w)).toVar(),E=ih.mul(w.x).add(ih.oneMinus().mul(w.y)).toVar();s.directSpecular.addAssign(e.mul(E).mul(r4({N:g,V:v,P:x,mInv:C,p0:l,p1:u,p2:d,p3:A}))),s.directDiffuse.addAssign(e.mul($c).mul(r4({N:g,V:v,P:x,mInv:ds(1,0,0,0,1,0,0,0,1),p0:l,p1:u,p2:d,p3:A})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:n}=e.context,r=t.mul(Th({diffuseColor:$c})).toVar();if(this.sheen===!0){const s=wA({normal:Kn,viewDir:Ei,roughness:qu}),o=To.r.max(To.g).max(To.b).mul(s).oneMinus();r.mulAssign(o)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(To,wA({normal:Kn,viewDir:Ei,roughness:qu}))),this.clearcoat===!0){const S=rh.dot(Ei).clamp(),w=vP({dotNV:S,specularColor:hv,specularF90:fv,roughness:Q0});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(w))}const s=he().toVar("singleScatteringDielectric"),o=he().toVar("multiScatteringDielectric"),a=he().toVar("singleScatteringMetallic"),l=he().toVar("multiScatteringMetallic");this.computeMultiscattering(s,o,Hf,sc,this.iridescenceF0Dielectric),this.computeMultiscattering(a,l,Hf,hi.rgb,this.iridescenceF0Metallic);const u=Wn(s,a,$l),d=Wn(o,l,$l),A=s.add(o),g=$c.mul(A.oneMinus()),v=n.mul(1/Math.PI),x=t.mul(u).add(d.mul(v)).toVar(),T=g.mul(v).toVar();if(this.sheen===!0){const S=wA({normal:Kn,viewDir:Ei,roughness:qu}),w=To.r.max(To.g).max(To.b).mul(S).oneMinus();x.mulAssign(w),T.mulAssign(w)}r.indirectSpecular.addAssign(x),r.indirectDiffuse.addAssign(T)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,s=Kn.dot(Ei).clamp().add(t),o=el.mul(-16).oneMinus().negate().exp2(),a=t.sub(s.pow(o).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(a)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=rh.dot(Ei).clamp(),r=Od({dotVH:n,f0:hv,f90:fv}),s=t.mul(y1.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(y1));t.assign(s)}if(this.sheen===!0){const n=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(n)}}}const p4=Z(1),my=Z(-2),Im=Z(.8),dv=Z(-1),Bm=Z(.4),Av=Z(2),Um=Z(.305),pv=Z(3),m4=Z(.21),AZ=Z(4),g4=Z(4),pZ=Z(16),mZ=pe(([i])=>{const e=he(Di(i)).toVar(),t=Z(-1).toVar();return Xt(e.x.greaterThan(e.z),()=>{Xt(e.x.greaterThan(e.y),()=>{t.assign(cs(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(cs(i.y.greaterThan(0),1,4))})}).Else(()=>{Xt(e.z.greaterThan(e.y),()=>{t.assign(cs(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(cs(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),gZ=pe(([i,e])=>{const t=Ze().toVar();return Xt(e.equal(0),()=>{t.assign(Ze(i.z,i.y).div(Di(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Ze(i.x.negate(),i.z.negate()).div(Di(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Ze(i.x.negate(),i.y).div(Di(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Ze(i.z.negate(),i.y).div(Di(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Ze(i.x.negate(),i.z).div(Di(i.y)))}).Else(()=>{t.assign(Ze(i.x,i.y).div(Di(i.z)))}),An(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),_Z=pe(([i])=>{const e=Z(0).toVar();return Xt(i.greaterThanEqual(Im),()=>{e.assign(p4.sub(i).mul(dv.sub(my)).div(p4.sub(Im)).add(my))}).ElseIf(i.greaterThanEqual(Bm),()=>{e.assign(Im.sub(i).mul(Av.sub(dv)).div(Im.sub(Bm)).add(dv))}).ElseIf(i.greaterThanEqual(Um),()=>{e.assign(Bm.sub(i).mul(pv.sub(Av)).div(Bm.sub(Um)).add(Av))}).ElseIf(i.greaterThanEqual(m4),()=>{e.assign(Um.sub(i).mul(AZ.sub(pv)).div(Um.sub(m4)).add(pv))}).Else(()=>{e.assign(Z(-2).mul(cl(An(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),SP=pe(([i,e])=>{const t=i.toVar();t.assign(An(2,t).sub(1));const n=he(t,1).toVar();return Xt(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),TP=pe(([i,e,t,n,r,s])=>{const o=Z(t),a=he(e),l=wa(_Z(o),my,s),u=Ta(l),d=hl(l),A=he(K0(i,a,d,n,r,s)).toVar();return Xt(u.notEqual(0),()=>{const g=he(K0(i,a,d.add(1),n,r,s)).toVar();A.assign(Wn(A,g,u))}),A}),K0=pe(([i,e,t,n,r,s])=>{const o=Z(t).toVar(),a=he(e),l=Z(mZ(a)).toVar(),u=Z(nr(g4.sub(o),0)).toVar();o.assign(nr(o,g4));const d=Z(Ud(o)).toVar(),A=Ze(gZ(a,l).mul(d.sub(2)).add(1)).toVar();return Xt(l.greaterThan(2),()=>{A.y.addAssign(d),l.subAssign(3)}),A.x.addAssign(l.mul(d)),A.x.addAssign(u.mul(An(3,pZ))),A.y.addAssign(An(4,Ud(s).sub(d))),A.x.mulAssign(n),A.y.mulAssign(r),i.sample(A).grad(Ze(),Ze())}),mv=pe(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const l=da(n),u=t.mul(l).add(r.cross(t).mul(Vs(n))).add(r.mul(r.dot(t).mul(l.oneMinus())));return K0(i,u,e,s,o,a)}),wP=pe(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:o,mipInt:a,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:A})=>{const g=he(cs(e,t,ou(t,n))).toVar();Xt(g.equal(he(0)),()=>{g.assign(he(n.z,0,n.x.negate()))}),g.assign(Xs(g));const v=he().toVar();return v.addAssign(r.element(0).mul(mv({theta:0,axis:g,outputDirection:n,mipInt:a,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:A}))),di({start:ce(1),end:i},({i:x})=>{Xt(x.greaterThanEqual(s),()=>{eP()});const T=Z(o.mul(Z(x))).toVar();v.addAssign(r.element(x).mul(mv({theta:T.mul(-1),axis:g,outputDirection:n,mipInt:a,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:A}))),v.addAssign(r.element(x).mul(mv({theta:T,axis:g,outputDirection:n,mipInt:a,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:A})))}),Yt(v,1)}),vZ=pe(([i])=>{const e=We(i).toVar();return e.assign(e.shiftLeft(We(16)).bitOr(e.shiftRight(We(16)))),e.assign(e.bitAnd(We(1431655765)).shiftLeft(We(1)).bitOr(e.bitAnd(We(2863311530)).shiftRight(We(1)))),e.assign(e.bitAnd(We(858993459)).shiftLeft(We(2)).bitOr(e.bitAnd(We(3435973836)).shiftRight(We(2)))),e.assign(e.bitAnd(We(252645135)).shiftLeft(We(4)).bitOr(e.bitAnd(We(4042322160)).shiftRight(We(4)))),e.assign(e.bitAnd(We(16711935)).shiftLeft(We(8)).bitOr(e.bitAnd(We(4278255360)).shiftRight(We(8)))),Z(e).mul(23283064365386963e-26)}),xZ=pe(([i,e])=>Ze(Z(i).div(Z(e)),vZ(i))),yZ=pe(([i,e,t])=>{const n=he(e).toVar(),r=Z(t),s=r.mul(r).toVar(),o=Xs(he(s.mul(n.x),s.mul(n.y),n.z)).toVar(),a=o.x.mul(o.x).add(o.y.mul(o.y)),l=cs(a.greaterThan(0),he(o.y.negate(),o.x,0).div(ws(a)),he(1,0,0)).toVar(),u=ou(o,l).toVar(),d=ws(i.x),A=An(2,3.14159265359).mul(i.y),g=d.mul(da(A)).toVar(),v=d.mul(Vs(A)).toVar(),x=An(.5,o.z.add(1));v.assign(x.oneMinus().mul(ws(g.mul(g).oneMinus())).add(x.mul(v)));const T=l.mul(g).add(u.mul(v)).add(o.mul(ws(nr(0,g.mul(g).add(v.mul(v)).oneMinus()))));return Xs(he(s.mul(T.x),s.mul(T.y),nr(0,T.z)))}),MP=pe(({roughness:i,mipInt:e,envMap:t,N_immutable:n,GGX_SAMPLES:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const l=he(n).toVar(),u=he(0).toVar(),d=Z(0).toVar();return Xt(i.lessThan(.001),()=>{u.assign(K0(t,l,e,s,o,a))}).Else(()=>{const A=cs(Di(l.z).lessThan(.999),he(0,0,1),he(1,0,0)),g=Xs(ou(A,l)).toVar(),v=ou(l,g).toVar();di({start:We(0),end:r},({i:x})=>{const T=xZ(x,r),S=yZ(T,he(0,0,1),i),w=Xs(g.mul(S.x).add(v.mul(S.y)).add(l.mul(S.z))),C=Xs(w.mul(Ko(l,w).mul(2)).sub(l)),E=nr(Ko(l,C),0);Xt(E.greaterThan(0),()=>{const N=K0(t,C,e,s,o,a);u.addAssign(N.mul(E)),d.addAssign(E)})}),Xt(d.greaterThan(0),()=>{u.assign(u.div(d))})}),Yt(u,1)}),Xu=4,_4=[.125,.215,.35,.446,.526,.582],jc=20,bZ=512,MA=new Xd(-1,1,1,-1,0,1),SZ=new Xr(90,1),v4=new Gt;let gv=null,_v=0,vv=0;const TZ=new te,P1=new WeakMap,wZ=[3,1,5,0,4,2],xv=SP(yi(),lu("faceIndex")).normalize(),w_=he(xv.x,xv.y,xv.z);class MZ{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,n=.1,r=100,s={}){const{size:o=256,position:a=TZ,renderTarget:l=null}=s;if(this._setSize(o),this._hasInitialized===!1){Ue('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const d=l||this._allocateTarget();return s.renderTarget=d,this.fromSceneAsync(e,t,n,r,s),d}gv=this._renderer.getRenderTarget(),_v=this._renderer.getActiveCubeFace(),vv=this._renderer.getActiveMipmapLevel();const u=l||this._allocateTarget();return u.depthBuffer=!0,this._init(u),this._sceneToCubeUV(e,n,r,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,n=.1,r=100,s={}){return Ci('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){Ue('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Ci('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){Ue("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Ci('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=y4(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=b4(),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===ba||e.mapping===ml?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?w:0,w,w),u.render(e,o)}u.autoClear=d,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===ba||e.mapping===ml;r?this._cubemapMaterial===null&&(this._cubemapMaterial=y4(e)):this._equirectMaterial===null&&(this._equirectMaterial=b4(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=s;const a=this._cubeSize;mf(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,MA)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;sx-Xu?n-x+Xu:0),w=4*(this._cubeSize-T);e.texture.frame=(e.texture.frame||0)+1,l.envMap.value=e.texture,l.roughness.value=v,l.mipInt.value=x-t,mf(s,S,w,3*T,2*T),r.setRenderTarget(s),r.render(a,MA),s.texture.frame=(s.texture.frame||0)+1,l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-n,mf(e,S,w,3*T,2*T),r.setRenderTarget(e),r.render(a,MA)}_blur(e,t,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,a){const l=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&He("blur direction must be either latitudinal or longitudinal!");const d=3,A=this._lodMeshes[r];A.material=u;const g=P1.get(u),v=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*v):2*Math.PI/(2*jc-1),T=s/x,S=isFinite(s)?1+Math.floor(d*T):jc;S>jc&&Ue(`sigmaRadians, ${s}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${jc}`);const w=[];let C=0;for(let I=0;IE-Xu?r-E+Xu:0),B=4*(this._cubeSize-N);mf(t,L,B,3*N,2*N),l.setRenderTarget(t),l.render(A,MA)}}function EZ(i){const e=[],t=[],n=[];let r=i;const s=i-Xu+1+_4.length;for(let o=0;oi-Xu?l=_4[o-i+Xu-1]:o===0&&(l=0),t.push(l);const u=1/(a-2),d=-u,A=1+u,g=[d,d,A,d,A,A,d,d,A,A,d,A],v=6,x=6,T=3,S=2,w=1,C=new Float32Array(T*x*v),E=new Float32Array(S*x*v),N=new Float32Array(w*x*v);for(let B=0;B2?0:-1,P=[I,F,0,I+2/3,F,0,I+2/3,F+1,0,I,F,0,I+2/3,F+1,0,I,F+1,0],O=wZ[B];C.set(P,T*x*O),E.set(g,S*x*O);const G=[O,O,O,O,O,O];N.set(G,w*x*O)}const L=new ui;L.setAttribute("position",new Ji(C,T)),L.setAttribute("uv",new Ji(E,S)),L.setAttribute("faceIndex",new Ji(N,w)),n.push(new si(L,null)),r>Xu&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function x4(i,e){const t={magFilter:ki,minFilter:ki,generateMipmaps:!1,type:zi,format:pr,colorSpace:nc},n=new hu(i,e,t);return n.texture.mapping=dh,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function mf(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function M_(i){const e=new lr;return e.depthTest=!1,e.depthWrite=!1,e.blending=$s,e.name=`PMREM_${i}`,e}function CZ(i,e,t){const n=Ts(new Array(jc).fill(0)),r=$t(new te(0,1,0)),s=$t(0),o=Z(jc),a=$t(0),l=$t(1),u=ti(),d=$t(0),A=Z(1/e),g=Z(1/t),v=Z(i),x={n:o,latitudinal:a,weights:n,poleAxis:r,outputDirection:w_,dTheta:s,samples:l,envMap:u,mipInt:d,CUBEUV_TEXEL_WIDTH:A,CUBEUV_TEXEL_HEIGHT:g,CUBEUV_MAX_MIP:v},T=M_("blur");return T.fragmentNode=wP({...x,latitudinal:a.equal(1)}),P1.set(T,x),T}function RZ(i,e,t){const n=ti(),r=$t(0),s=$t(0),o=Z(1/e),a=Z(1/t),l=Z(i),u={envMap:n,roughness:r,mipInt:s,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l},d=M_("ggx");return d.fragmentNode=MP({...u,N_immutable:w_,GGX_SAMPLES:We(bZ)}),P1.set(d,u),d}function y4(i){const e=M_("cubemap");return e.fragmentNode=qs(i,w_),e}function b4(i){const e=M_("equirect");return e.fragmentNode=ti(i,tS(w_),0),e}const S4=new WeakMap;function NZ(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function PZ(i,e,t){const n=DZ(e);let r=n.get(i);if((r!==void 0?r.pmremVersion:-1)!==i.pmremVersion){const o=i.image;if(i.isCubeTexture)if(IZ(o))r=t.fromCubemap(i,r);else return null;else if(BZ(o))r=t.fromEquirectangular(i,r);else return null;r.pmremVersion=i.pmremVersion,n.set(i,r)}return r.texture}function DZ(i){let e=S4.get(i);return e===void 0&&(e=new WeakMap,S4.set(i,e)),e}class LZ extends ir{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new Dr;r.isRenderTargetTexture=!0,this._texture=ti(r),this._width=$t(0),this._height=$t(0),this._maxMip=$t(0),this.updateBeforeType=yn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=NZ(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 n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(r.isPMREMTexture===!0?t=r:t=PZ(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new MZ(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=W3.mul(he(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),TP(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function IZ(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const oS=pn(LZ).setParameterLength(1,3),T4=new WeakMap;class UZ extends Zd{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const A=n.isTextureNode?n.value:t[n.property];let g=T4.get(A);g===void 0&&(g=oS(A),T4.set(A,g)),n=g}const s=t.useAnisotropy===!0||t.anisotropy>0?dN:Kn,o=n.context(w4(el,s)).mul(Mg),a=n.context(FZ(hc)).mul(Math.PI).mul(Mg),l=jf(o),u=jf(a);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(u);const d=e.context.lightingModel.clearcoatRadiance;if(d){const A=n.context(w4(Q0,rh)).mul(Mg),g=jf(A);d.addAssign(g)}}}const w4=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Ei.negate().reflect(e),t=E3(i).mix(t,e).normalize(),t=t.transformDirection(ia)),t),getTextureLevel:()=>i}},FZ=i=>({getUV:()=>i,getTextureLevel:()=>Z(1)}),OZ=new wR;class EP extends lr{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(OZ),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new UZ(t):null}setupLightingModel(){return new bP}setupSpecular(){const e=Wn(he(.04),hi.rgb,$l);sc.assign(he(.04)),ih.assign(e),Hf.assign(1)}setupVariants(){const e=this.metalnessNode?Z(this.metalnessNode):bN;$l.assign(e);let t=this.roughnessNode?Z(this.roughnessNode):yN;t=iS({roughness:t}),el.assign(t),this.setupSpecular(),$c.assign(hi.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const kZ=new SU;class VZ extends EP{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(kZ),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?Z(this.iorNode):UN;h0.assign(e),sc.assign(fo(M3(h0.sub(1).div(h0.add(1))).mul(xN),he(1)).mul(fy)),ih.assign(Wn(sc,hi.rgb,$l)),Hf.assign(Wn(fy,1,$l))}setupLightingModel(){return new bP(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?Z(this.clearcoatNode):TN,n=this.clearcoatRoughnessNode?Z(this.clearcoatRoughnessNode):wN;y1.assign(t),Q0.assign(iS({roughness:n}))}if(this.useSheen){const t=this.sheenNode?he(this.sheenNode):CN,n=this.sheenRoughnessNode?Z(this.sheenRoughnessNode):RN;To.assign(t),qu.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?Z(this.iridescenceNode):PN,n=this.iridescenceIORNode?Z(this.iridescenceIORNode):DN,r=this.iridescenceThicknessNode?Z(this.iridescenceThicknessNode):LN;l_.assign(t),b1.assign(n),S1.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Ze(this.anisotropyNode):NN).toVar();Vu.assign(t.length()),Xt(Vu.equal(0),()=>{t.assign(Ze(1,0))}).Else(()=>{t.divAssign(Ze(Vu)),Vu.assign(Vu.saturate())}),T1.assign(Vu.pow2().mix(el.pow2(),1)),c0.assign(sh[0].mul(t.x).add(sh[1].mul(t.y))),hh.assign(sh[1].mul(t.x).sub(sh[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?Z(this.transmissionNode):IN,n=this.thicknessNode?Z(this.thicknessNode):BN,r=this.attenuationDistanceNode?Z(this.attenuationDistanceNode):FN,s=this.attenuationColorNode?he(this.attenuationColorNode):ON;if(M1.assign(t),u3.assign(n),c3.assign(r),h3.assign(s),this.useDispersion){const o=this.dispersionNode?Z(this.dispersionNode):HN;f3.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?he(this.clearcoatNormalNode):MN}setup(e){e.context.setupClearcoatNormal=()=>$f(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const GZ=pe(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Ze(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=ql("gradientMap","texture").context({getUV:()=>r});return he(s.r)}else{const s=r.fwidth().mul(.5);return Wn(he(.7),he(1),Ma(Z(.7).sub(s.x),Z(.7).add(s.x),r.x))}});class qZ extends S_{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){const s=GZ({normal:g_,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(s.mul(Th({diffuseColor:hi.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Th({diffuseColor:hi}))),r.indirectDiffuse.mulAssign(t)}}const zZ=new TU;class HZ extends lr{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(zZ),this.setValues(e)}setupLightingModel(){return new qZ}}const CP=pe(()=>{const i=he(Ei.z,0,Ei.x.negate()).normalize(),e=Ei.cross(i);return Ze(i.dot(Kn),e.dot(Kn)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),WZ=new CU;class $Z extends lr{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(WZ),this.setValues(e)}setupVariants(e){const t=CP;let n;e.material.matcap?n=ql("matcap","texture").context({getUV:()=>t}):n=he(Wn(.2,.8,t.y)),hi.rgb.mulAssign(n.rgb)}}class jZ extends ir{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),o=t.sin();return a_(s,o,o.negate(),s).mul(n)}else{const s=t,o=ec(Yt(1,0,0,0),Yt(0,da(s.x),Vs(s.x).negate(),0),Yt(0,Vs(s.x),da(s.x),0),Yt(0,0,0,1)),a=ec(Yt(da(s.y),0,Vs(s.y),0),Yt(0,1,0,0),Yt(Vs(s.y).negate(),0,da(s.y),0),Yt(0,0,0,1)),l=ec(Yt(da(s.z),Vs(s.z).negate(),0,0),Yt(Vs(s.z),da(s.z),0,0),Yt(0,0,1,0),Yt(0,0,0,1));return o.mul(a).mul(l).mul(Yt(n,1)).xyz}}}const Sp=pn(jZ).setParameterLength(2),XZ=new O9;class RP extends lr{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(XZ),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:r,rotationNode:s,scaleNode:o,sizeAttenuation:a}=this,l=cc.mul(he(r||0));let u=Ze(Ho[0].xyz.length(),Ho[1].xyz.length());o!==null&&(u=u.mul(Ze(o))),n.isPerspectiveCamera&&a===!1&&(u=u.mul(l.z.negate()));let d=yp.xy;if(t.center&&t.center.isVector2===!0){const v=qQ("center","vec2",t);d=d.sub(v.sub(.5))}d=d.mul(u);const A=Z(s||EN),g=Sp(d,A);return Yt(l.xy.add(g),l.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const QZ=new yb,YZ=new qe;class KZ extends RP{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(QZ),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return cc.mul(he(e||Ki)).xyz}setupVertexSprite(e){const{material:t,camera:n}=e,{rotationNode:r,scaleNode:s,sizeNode:o,sizeAttenuation:a}=this;let l=super.setupVertex(e);if(t.isNodeMaterial!==!0)return l;let u=o!==null?Ze(o):zN;u=u.mul(G6),n.isPerspectiveCamera&&a===!0&&(u=u.mul(ZZ.div(Ar.z.negate()))),s&&s.isNode&&(u=u.mul(Ze(s)));let d=yp.xy;if(r&&r.isNode){const A=Z(r);d=Sp(d,A)}return d=d.mul(u),d=d.div(G3.div(2)),d=d.mul(l.w),l=l.add(Yt(d,0,0)),l}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 ZZ=$t(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(YZ);this.value=.5*e.y});class JZ extends S_{constructor(){super(),this.shadowNode=Z(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){hi.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(hi.rgb)}}const eJ=new yU;class tJ extends lr{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(eJ),this.setValues(e)}setupLightingModel(){return new JZ}}Yl("vec3");Yl("vec3");Yl("vec3");class nJ{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{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,n),this.renderer._inspector.finish()};e()}stop(){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 Ea{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}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.material.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,n=[],r=new Set,s={};for(const o of e){let a;if(o.node&&o.node.attribute?a=o.node.attribute:(a=t.getAttribute(o.name),s[o.name]=a.version),a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.attributesId=s,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,o=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),l=a!==null;let u=1;if(n.isInstancedBufferGeometry===!0?u=n.instanceCount:e.count!==void 0&&(u=Math.max(0,e.count)),u===0)return null;if(o.instanceCount=u,e.isBatchedMesh===!0)return o;let d=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(d=2);let A=s.start*d,g=(s.start+s.count)*d;r!==null&&(A=Math.max(A,r.start*d),g=Math.min(g,(r.start+r.count)*d));const v=n.attributes.position;let x=1/0;l?x=a.count:v!=null&&(x=v.count),A=Math.max(A,0),g=Math.min(g,x);const T=g-A;return T<0||T===1/0?null:(o.vertexCount=T,o.firstVertex=A,o)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[n];t+="morph-"+n+",";for(let s=0,o=r.length;s1||Array.isArray(e.morphTargetInfluences))&&(r+=e.uuid+","),r+=this.context.id+",",r+=e.receiveShadow+",",gp(r)}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 n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)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=l0(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=l0(e,1)),e=l0(e,this.camera.id,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.onDispose()}}const Ic=[];class oJ{constructor(e,t,n,r,s,o){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=o,this.chainMaps={}}get(e,t,n,r,s,o,a,l){const u=this.getChainMap(l);Ic[0]=e,Ic[1]=t,Ic[2]=o,Ic[3]=s;let d=u.get(Ic);return d===void 0?(d=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,o,a,l),u.set(Ic,d)):(d.updateClipping(a),d.needsGeometryUpdate&&d.setGeometry(e.geometry),(d.version!==t.version||d.needsUpdate)&&(d.initialCacheKey!==d.getCacheKey()?(d.dispose(),d=this.get(e,t,n,r,s,o,a,l)):d.version=t.version)),Ic.length=0,d}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Ea)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,o,a,l,u,d,A){const g=this.getChainMap(A),v=new sJ(e,t,n,r,s,o,a,l,u,d);return v.onDispose=()=>{this.pipelines.delete(v),this.bindings.deleteForRender(v),this.nodes.delete(v),g.delete(v.getChainArray())},v}}class fc{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 Wo={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Wu=16,aJ=211,lJ=212;class uJ extends fc{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Wo.VERTEX?this.backend.createAttribute(e):t===Wo.INDEX?this.backend.createIndexAttribute(e):t===Wo.STORAGE?this.backend.createStorageAttribute(e):t===Wo.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version{this.info.memory.geometries--;const s=t.index,o=e.getAttributes();s!==null&&this.attributes.delete(s);for(const l of o)this.attributes.delete(l);const a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,Wo.STORAGE):this.updateAttribute(s,Wo.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Wo.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Wo.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let o=s.get(t);o===void 0?(o=M4(t),s.set(t,o)):o.version!==NP(t)&&(this.attributes.delete(o),o=M4(t),s.set(t,o)),r=o}return r}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class hJ{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={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):He("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,this.memory.geometries=0,this.memory.textures=0}}class PP{constructor(e){this.cacheKey=e,this.usedTimes=0}}class fJ extends PP{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class dJ extends PP{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let AJ=0;class yv{constructor(e,t,n,r=null,s=null){this.id=AJ++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class pJ extends fc{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const o=this.nodes.getForCompute(e);let a=this.programs.compute.get(o.computeShader);a===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),a=new yv(o.computeShader,"compute",e.name,o.transforms,o.nodeAttributes),this.programs.compute.set(o.computeShader,a),n.createProgram(a));const l=this._getComputeCacheKey(e,a);let u=this.caches.get(l);u===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),u=this._getComputePipeline(e,a,l,t)),u.usedTimes++,a.usedTimes++,r.version=e.version,r.pipeline=u}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const o=e.getNodeBuilderState(),a=e.material?e.material.name:"";let l=this.programs.vertex.get(o.vertexShader);l===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),l=new yv(o.vertexShader,"vertex",a),this.programs.vertex.set(o.vertexShader,l),n.createProgram(l));let u=this.programs.fragment.get(o.fragmentShader);u===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),u=new yv(o.fragmentShader,"fragment",a),this.programs.fragment.set(o.fragmentShader,u),n.createProgram(u));const d=this._getRenderCacheKey(e,l,u);let A=this.caches.get(d);A===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),A=this._getRenderPipeline(e,l,u,d,t)):e.pipeline=A,A.usedTimes++,l.usedTimes++,u.usedTimes++,r.pipeline=A}return r.pipeline}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,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new dJ(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let o=this.caches.get(r);return o===void 0&&(o=new fJ(r,t,n),this.caches.set(r,o),e.pipeline=o,this.backend.createRenderPipeline(e,s)),o}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_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 mJ extends fc{constructor(e,t,n,r,s,o){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=o,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t)this.backend.deleteBindGroupData(n),this.delete(n)}deleteForRender(e){const t=e.getBindings();for(const n of t)this.backend.deleteBindGroupData(n),this.delete(n)}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?Wo.INDIRECT:Wo.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,o=0,a=0;for(const l of e.bindings)if(this.nodes.updateGroup(l)!==!1){if(l.isStorageBuffer){const d=l.attribute,A=d.isIndirectStorageBufferAttribute?Wo.INDIRECT:Wo.STORAGE;this.attributes.update(d,A)}if(l.isUniformBuffer)l.update()&&n.updateBinding(l);else if(l.isSampledTexture){const d=l.update(),A=l.texture,g=this.textures.get(A);if(d&&(this.textures.updateTexture(A),l.generation!==g.generation&&(l.generation=g.generation,r=!0,s=!1)),n.get(A).externalTexture!==void 0||g.isDefaultTexture?s=!1:(o=o*10+A.id,a+=A.version),A.isStorageTexture===!0&&A.mipmapsAutoUpdate===!0){const x=this.get(A);l.store===!0?x.needsMipmap=!0:this.textures.needsMipmaps(A)&&x.needsMipmap===!0&&(this.backend.generateMipmaps(A),x.needsMipmap=!1)}}else if(l.isSampler&&l.update()){const A=this.textures.updateSampler(l.texture);l.samplerKey!==A&&(l.samplerKey=A,r=!0,s=!1)}}r===!0&&this.backend.updateBindings(e,t,s?o:0,a)}}function gJ(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 E4(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 C4(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===xr&&i.forceSinglePass===!1}class _J{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}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,n,r,s,o,a){let l=this.renderItems[this.renderItemsIndex];return l===void 0?(l={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:o,clippingContext:a},this.renderItems[this.renderItemsIndex]=l):(l.id=e.id,l.object=e,l.geometry=t,l.material=n,l.groupOrder=r,l.renderOrder=e.renderOrder,l.z=s,l.group=o,l.clippingContext=a),this.renderItemsIndex++,l}push(e,t,n,r,s,o,a){const l=this.getNextRenderItem(e,t,n,r,s,o,a);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(C4(n)&&this.transparentDoublePass.push(l),this.transparent.push(l)):this.opaque.push(l)}unshift(e,t,n,r,s,o,a){const l=this.getNextRenderItem(e,t,n,r,s,o,a);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(C4(n)&&this.transparentDoublePass.unshift(l),this.transparent.unshift(l)):this.opaque.unshift(l)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||gJ),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||E4),this.transparent.length>1&&this.transparent.sort(t||E4)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let d=e.depthTexture||s[t];const A=e.depthBuffer===!0||e.stencilBuffer===!0;let g=!1;d===void 0&&A&&(d=new Ms,d.format=e.stencilBuffer?zs:hs,d.type=e.stencilBuffer?Po:vi,d.image.width=l,d.image.height=u,d.image.depth=a.depth,d.renderTarget=e,d.isArrayTexture=e.multiview===!0&&a.depth>1,s[t]=d),(n.width!==a.width||a.height!==n.height)&&(g=!0,d&&(d.needsUpdate=!0,d.image.width=l,d.image.height=u,d.image.depth=d.isArrayTexture?d.image.depth:1)),n.width=a.width,n.height=a.height,n.textures=o,n.depthTexture=d||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(g=!0,d&&(d.needsUpdate=!0),n.sampleCount=r);const v={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let x=0;x{this._destroyRenderTarget(e)},e.addEventListener("dispose",n.onDispose))}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(r&&n.initialized===!0&&s.destroyTexture(e),e.isFramebufferTexture){const u=this.renderer.getRenderTarget();u?e.type=u.texture.type:e.type=Gi}const{width:o,height:a,depth:l}=this.getSize(e);if(t.width=o,t.height=a,t.depth=l,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,o,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createTexture(e,t),n.generation=e.version;else if(e.version>0){const u=e.image;if(u===void 0)Ue("Renderer: Texture marked for update but image is undefined.");else if(u.complete===!1)Ue("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const A=[];for(const g of e.images)A.push(g);t.images=A}else t.image=u;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t);const d=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!d&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&ln.enabled===!0&&ln.getTransfer(e.colorSpace)!==Pt&&Ue("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=wJ){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.mipmaps.length>0?r=e.mipmaps.length:e.isCompressedTexture===!0?r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let s=0;snew LP(i,e);class CJ extends Lt{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.isStackNode=!0}getElementType(e){return this.hasOutput?this.outputNode.getElementType(e):"void"}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=this.nodes.length){return e.isNode!==!0?(He("TSL: Invalid node added to stack."),this):(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 n=new Bf(t);return this._currentCond=cs(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){const n=new Bf(t),r=cs(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Bf(e),this}Switch(e){return this._expressionNode=gt(e),this}Case(...e){const t=[];if(e.length>=2)for(let a=0;a{if(this._currentNode=u,!(u.isVarNode&&u.isIntent(e)&&u.isAssign(e)!==!0)){if(r==="setup")u.build(e);else if(r==="analyze")u.build(e,this);else if(r==="generate"){const d=e.getDataFromNode(u,"any").stages,A=d&&d[e.shaderStage];if(u.isVarNode&&A&&A.length===1&&A[0]&&A[0].isStackNode)return;u.build(e,"void")}}},o=[...this.nodes];for(const u of o)s(u);this._currentNode=null;const a=this.nodes.filter(u=>o.indexOf(u)===-1);for(const u of a)s(u);let l;return this.hasOutput?l=this.outputNode.build(e,...t):l=super.build(e,...t),j0(n),e.removeActiveStack(this),l}}const Cg=pn(CJ).setParameterLength(0,1);function RJ(i){return Object.entries(i).map(([e,t])=>typeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class NJ extends Lt{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=RJ(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=1,n=0;for(const r of this.membersLayout){const s=r.type,o=KX(s),a=ZX(s)/e;t=Math.max(t,a);const u=n%t%a;u!==0&&(n+=a-u),n+=o}return Math.ceil(n/t)*t}getMemberType(e,t){const n=this.membersLayout.find(r=>r.name===t);return n?n.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class PJ extends Lt{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const DJ=(i,e=null)=>{const t=new NJ(i,e),n=(...r)=>{let s=null;if(r.length>0)if(r[0].isNode){s={};const o=Object.keys(i);for(let a=0;anew Tp(i,"int","float"),OP=i=>new Tp(i,"uint","float"),UJ=i=>new Tp(i,"float","int"),FJ=i=>new Tp(i,"float","uint"),Fm={};class Do extends Me{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n==="int"?t.assign(FP(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return We;case"int":return ce;case"uvec2":return r3;case"uvec3":return Rh;case"uvec4":return l3;case"ivec2":return Rr;case"ivec3":return s3;case"ivec4":return a3}}_createTrailingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return pe(([s])=>{const o=We(0);this._resolveElementType(s,o,t);const a=Z(o.bitAnd(y3(o))),u=OP(a).shiftRight(23).sub(127);return n(u)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return pe(([s])=>{Xt(s.equal(We(0)),()=>We(32));const o=We(0),a=We(0);return this._resolveElementType(s,o,t),Xt(o.shiftRight(16).equal(0),()=>{a.addAssign(16),o.shiftLeftAssign(16)}),Xt(o.shiftRight(24).equal(0),()=>{a.addAssign(8),o.shiftLeftAssign(8)}),Xt(o.shiftRight(28).equal(0),()=>{a.addAssign(4),o.shiftLeftAssign(4)}),Xt(o.shiftRight(30).equal(0),()=>{a.addAssign(2),o.shiftLeftAssign(2)}),Xt(o.shiftRight(31).equal(0),()=>{a.addAssign(1)}),n(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const n=this._returnDataNode(t);return pe(([s])=>{const o=We(0);this._resolveElementType(s,o,t),o.assign(o.sub(o.shiftRight(We(1)).bitAnd(We(1431655765)))),o.assign(o.bitAnd(We(858993459)).add(o.shiftRight(We(2)).bitAnd(We(858993459))));const a=o.add(o.shiftRight(We(4))).bitAnd(We(252645135)).mul(We(16843009)).shiftRight(We(24));return n(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,n,r){const s=this._returnDataNode(t);return pe(([a])=>{if(n===1)return s(r(a));{const l=s(0),u=["x","y","z","w"];for(let d=0;dA(n))()}}Do.COUNT_TRAILING_ZEROS="countTrailingZeros";Do.COUNT_LEADING_ZEROS="countLeadingZeros";Do.COUNT_ONE_BITS="countOneBits";const OJ=nt(Do,Do.COUNT_TRAILING_ZEROS).setParameterLength(1),kJ=nt(Do,Do.COUNT_LEADING_ZEROS).setParameterLength(1),VJ=nt(Do,Do.COUNT_ONE_BITS).setParameterLength(1),GJ=pe(([i])=>{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),gy=(i,e)=>zo(An(4,i.mul(jn(1,i))),e),qJ=(i,e)=>i.lessThan(.5)?gy(i.mul(2),e).div(2):jn(1,gy(An(jn(1,i),2),e).div(2)),zJ=(i,e,t)=>zo(Io(zo(i,e),br(zo(i,e),zo(jn(1,i),t))),1/e),HJ=(i,e)=>Vs(E1.mul(e.mul(i).sub(1))).div(E1.mul(e.mul(i).sub(1)));class lS extends ir{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}getNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const WJ=nt(lS,"snorm").setParameterLength(1),$J=nt(lS,"unorm").setParameterLength(1),jJ=nt(lS,"float16").setParameterLength(1);class uS extends ir{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}getNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const XJ=nt(uS,"snorm").setParameterLength(1),QJ=nt(uS,"unorm").setParameterLength(1),YJ=nt(uS,"float16").setParameterLength(1),Vl=pe(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),KJ=pe(([i])=>he(Vl(i.z.add(Vl(i.y.mul(1)))),Vl(i.z.add(Vl(i.x.mul(1)))),Vl(i.y.add(Vl(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ZJ=pe(([i,e,t])=>{const n=he(i).toVar(),r=Z(1.4).toVar(),s=Z(0).toVar(),o=he(n).toVar();return di({start:Z(0),end:Z(3),type:"float",condition:"<="},()=>{const a=he(KJ(o.mul(2))).toVar();n.addAssign(a.add(t.mul(Z(.1).mul(e)))),o.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const l=Z(Vl(n.z.add(Vl(n.x.add(Vl(n.y)))))).toVar();s.addAssign(l.div(r)),o.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class JJ extends Lt{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}getNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let n=this._candidateFn;if(n===null){let r=null,s=-1;for(const o of this.functionNodes){const l=o.shaderNode.layout;if(l===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const u=l.inputs;if(t.length===u.length){let d=0;for(let A=0;As&&(r=o,s=d)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const eee=pn(JJ),ps=i=>(...e)=>eee(i,...e),Jd=$t(0).setGroup(Wt).onRenderUpdate(i=>i.time),tee=$t(0).setGroup(Wt).onRenderUpdate(i=>i.deltaTime),kP=$t(0,"uint").setGroup(Wt).onRenderUpdate(i=>i.frameId),nee=(i=Jd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),iee=(i=Jd)=>i.fract().round(),ree=(i=Jd)=>i.add(.5).fract().mul(2).sub(1).abs(),see=(i=Jd)=>i.fract();function oee(i,e=null){return Au(e,{getUV:i})}const aee=pe(([i,e,t=Ze(.5)])=>Sp(i.sub(t),e).add(t)),lee=pe(([i,e,t=Ze(.5)])=>{const n=i.sub(t),r=n.dot(n),o=r.mul(r).mul(e);return i.add(n.mul(o))}),uee=pe(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ho.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ho;const r=ia.mul(n);return $0(e)&&(r[0][0]=Ho[0].length(),r[0][1]=0,r[0][2]=0),$0(t)&&(r[1][0]=0,r[1][1]=Ho[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Jl.mul(r).mul(Ki)}),cee=pe(([i=null])=>{const e=N1();return N1(K3(i)).sub(e).lessThan(0).select(Zl,i)});class hee extends Lt{static get type(){return"SpriteSheetUVNode"}constructor(e,t=yi(),n=Z(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,o=e.mod(r.mul(s)).floor(),a=o.mod(r),l=s.sub(o.add(1).div(r).ceil()),u=n.reciprocal(),d=Ze(a,l);return t.add(d).mul(u)}}const fee=pn(hee).setParameterLength(3),VP=pe(([i,e=null,t=null,n=Z(1),r=Ki,s=Ao])=>{let o=s.abs().normalize();o=o.div(o.dot(he(1)));const a=r.yz.mul(n),l=r.zx.mul(n),u=r.xy.mul(n),d=i.value,A=e!==null?e.value:d,g=t!==null?t.value:d,v=ti(d,a).mul(o.x),x=ti(A,l).mul(o.y),T=ti(g,u).mul(o.z);return br(v,x,T)}),dee=(...i)=>VP(...i),_f=new Ka,Bc=new te,vf=new te,bv=new te,CA=new gn,Om=new te(0,0,-1),$a=new dn,RA=new te,km=new te,NA=new dn,Vm=new qe,D1=new hu,Aee=Zl.flipX();D1.depthTexture=new Ms(1,1);let Gm=!1;class cS extends _l{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||D1.texture,Aee),this._reflectorBaseNode=e.reflector||new pee(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=gt(new cS({defaultTexture:D1.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);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.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class pee extends Lt{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new ji,resolutionScale:r=1,generateMipmaps:s=!1,bounces:o=!0,depth:a=!1,samples:l=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(Ci('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=o,this.depth=a,this.samples=l,this.updateBeforeType=o?yn.RENDER:yn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(Vm),e.setSize(Math.round(Vm.width*n),Math.round(Vm.height*n))}setup(e){return this._updateResolution(D1,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new hu(0,0,{type:zi,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=IB,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ms),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Gm)return!1;Gm=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:o}=this,a=this.getVirtualCamera(n),l=this.getRenderTarget(a);r.getDrawingBufferSize(Vm),this._updateResolution(l,r),vf.setFromMatrixPosition(o.matrixWorld),bv.setFromMatrixPosition(n.matrixWorld),CA.extractRotation(o.matrixWorld),Bc.set(0,0,1),Bc.applyMatrix4(CA),RA.subVectors(vf,bv);const u=RA.dot(Bc)>0;let d=!1;if(u===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Gm=!1;return}d=!0}RA.reflect(Bc).negate(),RA.add(vf),CA.extractRotation(n.matrixWorld),Om.set(0,0,-1),Om.applyMatrix4(CA),Om.add(bv),km.subVectors(vf,Om),km.reflect(Bc).negate(),km.add(vf),a.coordinateSystem=n.coordinateSystem,a.position.copy(RA),a.up.set(0,1,0),a.up.applyMatrix4(CA),a.up.reflect(Bc),a.lookAt(km),a.near=n.near,a.far=n.far,a.updateMatrixWorld(),a.projectionMatrix.copy(n.projectionMatrix),_f.setFromNormalAndCoplanarPoint(Bc,vf),_f.applyMatrix4(a.matrixWorldInverse),$a.set(_f.normal.x,_f.normal.y,_f.normal.z,_f.constant);const A=a.projectionMatrix;NA.x=(Math.sign($a.x)+A.elements[8])/A.elements[0],NA.y=(Math.sign($a.y)+A.elements[9])/A.elements[5],NA.z=-1,NA.w=(1+A.elements[10])/A.elements[14],$a.multiplyScalar(1/$a.dot(NA));const g=0;A.elements[2]=$a.x,A.elements[6]=$a.y,A.elements[10]=r.coordinateSystem===Xo?$a.z-g:$a.z+1-g,A.elements[14]=$a.w,this.textureNode.value=l.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=l.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),T=r.autoClear;r.setMRT(null),r.setRenderTarget(l),r.autoClear=!0;const S=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",d?(r.clear(),this.hasOutput=!1):(r.render(t,a),this.hasOutput=!0),t.name=S,r.setMRT(x),r.setRenderTarget(v),r.autoClear=T,s.visible=!0,Gm=!1,this.forceUpdate=!1}get resolution(){return Ci('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){Ci('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const mee=i=>new cS(i),Sv=new Xd(-1,1,1,-1,0,1);class gee extends ui{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Jn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Jn(t,2))}}const _ee=new gee;class E_ extends si{constructor(e=null){super(_ee,e),this.camera=Sv,this.isQuadMesh=!0}async renderAsync(e){Ci('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,Sv)}render(e){e.render(this,Sv)}}const vee=new qe;class xee extends _l{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:zi}){const s=new hu(t,n,r);super(s.texture,yi()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new E_(new lr),this.updateBeforeType=yn.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){const r=e.getPixelRatio(),s=e.getSize(vee),o=Math.floor(s.width*r),a=Math.floor(s.height*r);(o!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(o,a),this.textureNeedsUpdate=!0)}let t="RTT";this.node.name&&(t=this.node.name+" [ "+t+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;const n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(n)}clone(){const e=new _l(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const GP=(i,...e)=>gt(new xee(gt(i),...e)),yee=(i,...e)=>i.isSampleNode||i.isTextureNode?i:i.isPassNode?i.getTextureNode():GP(i,...e),Rf=pe(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===Xo?(i=Ze(i.x,i.y.oneMinus()).mul(2).sub(1),r=Yt(he(i,e),1)):r=Yt(he(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=Yt(t.mul(r));return s.xyz.div(s.w)}),bee=pe(([i,e])=>{const t=e.mul(Yt(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Ze(n.x,n.y.oneMinus())}),See=pe(([i,e,t])=>{const n=Kl(sr(e)),r=Rr(i.mul(n)).toVar(),s=sr(e,r).toVar(),o=sr(e,r.sub(Rr(2,0))).toVar(),a=sr(e,r.sub(Rr(1,0))).toVar(),l=sr(e,r.add(Rr(1,0))).toVar(),u=sr(e,r.add(Rr(2,0))).toVar(),d=sr(e,r.add(Rr(0,2))).toVar(),A=sr(e,r.add(Rr(0,1))).toVar(),g=sr(e,r.sub(Rr(0,1))).toVar(),v=sr(e,r.sub(Rr(0,2))).toVar(),x=Di(jn(Z(2).mul(a).sub(o),s)).toVar(),T=Di(jn(Z(2).mul(l).sub(u),s)).toVar(),S=Di(jn(Z(2).mul(A).sub(d),s)).toVar(),w=Di(jn(Z(2).mul(g).sub(v),s)).toVar(),C=Rf(i,s,t).toVar(),E=x.lessThan(T).select(C.sub(Rf(i.sub(Ze(Z(1).div(n.x),0)),a,t)),C.negate().add(Rf(i.add(Ze(Z(1).div(n.x),0)),l,t))),N=S.lessThan(w).select(C.sub(Rf(i.add(Ze(0,Z(1).div(n.y))),A,t)),C.negate().add(Rf(i.sub(Ze(0,Z(1).div(n.y))),g,t)));return Xs(ou(E,N))}),hS=pe(([i])=>Ta(Z(52.9829189).mul(Ta(Ko(i,Ze(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),ma=pe(([i,e,t])=>{const n=Z(2.399963229728653),r=ws(Z(i).add(.5).div(Z(e))),s=Z(i).mul(n).add(t);return Ze(da(s),Vs(s)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class Tee extends Lt{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(yi())}sample(e){return this.callback(e)}}const wee=(i,e=null)=>new Tee(i,gt(e));class uo extends Lt{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===uo.OBJECT?this.updateType=yn.OBJECT:e===uo.MATERIAL?this.updateType=yn.RENDER:e===uo.BEFORE_OBJECT?this.updateBeforeType=yn.OBJECT:e===uo.BEFORE_MATERIAL&&(this.updateBeforeType=yn.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}uo.OBJECT="object";uo.MATERIAL="material";uo.BEFORE_OBJECT="beforeObject";uo.BEFORE_MATERIAL="beforeMaterial";const C_=(i,e)=>new uo(i,e).toStack(),Mee=i=>C_(uo.OBJECT,i),Eee=i=>C_(uo.MATERIAL,i),Cee=i=>C_(uo.BEFORE_OBJECT,i),Ree=i=>C_(uo.BEFORE_MATERIAL,i);class Rg extends Ju{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class Nee extends Ji{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}const Pee=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=x1("float")):(t=i5(e),n=x1(e));const r=new Nee(i,t,n);return eu(r,e,i)},Dee=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=x1("float")):(t=i5(e),n=x1(e));const r=new Rg(i,t,n);return eu(r,e,i)};class Lee extends Lt{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Iee=At(Lee),PA=new fs,Tv=new gn;class co extends Lt{static get type(){return"SceneNode"}constructor(e=co.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===co.BACKGROUND_BLURRINESS?r=gi("backgroundBlurriness","float",n):t===co.BACKGROUND_INTENSITY?r=gi("backgroundIntensity","float",n):t===co.BACKGROUND_ROTATION?r=$t("mat4").setName("backgroundRotation").setGroup(Wt).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==nb?(PA.copy(n.backgroundRotation),PA.x*=-1,PA.y*=-1,PA.z*=-1,Tv.makeRotationFromEuler(PA)):Tv.identity(),Tv}):He("SceneNode: Unknown scope:",t),r}}co.BACKGROUND_BLURRINESS="backgroundBlurriness";co.BACKGROUND_INTENSITY="backgroundIntensity";co.BACKGROUND_ROTATION="backgroundRotation";const qP=At(co,co.BACKGROUND_BLURRINESS),_y=At(co,co.BACKGROUND_INTENSITY),zP=At(co,co.BACKGROUND_ROTATION);class Bee extends _l{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=us.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(us.READ_WRITE)}toReadOnly(){return this.setAccess(us.READ_ONLY)}toWriteOnly(){return this.setAccess(us.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:s}=t,o=super.generate(e,"property"),a=n.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),l=r.build(e,"vec4"),u=s?s.build(e,"int"):null,d=e.generateTextureStore(e,o,a,u,l);e.addLineFlowCode(d,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e}}const HP=pn(Bee).setParameterLength(1,3),Uee=(i,e,t)=>{const n=HP(i,e,t);return t!==null&&n.toStack(),n},Fee=pe(({texture:i,uv:e})=>{const n=he().toVar();return Xt(e.x.lessThan(1e-4),()=>{n.assign(he(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(he(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(he(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(he(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(he(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(he(0,0,-1))}).Else(()=>{const s=i.sample(e.add(he(-.01,0,0))).r.sub(i.sample(e.add(he(.01,0,0))).r),o=i.sample(e.add(he(0,-.01,0))).r.sub(i.sample(e.add(he(0,.01,0))).r),a=i.sample(e.add(he(0,0,-.01))).r.sub(i.sample(e.add(he(0,0,.01))).r);n.assign(he(s,o,a))}),n.normalize()});class Oee extends _l{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return he(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(ce(Kl(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Fee({texture:this,uv:e})}}const R_=pn(Oee).setParameterLength(1,3),kee=(...i)=>R_(...i).setSampler(!1),Vee=(i,e,t)=>R_(i,e).level(t);class Gee extends __{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const qee=(i,e,t)=>new Gee(i,e,t),R4=new WeakMap;class zee extends ir{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=yn.OBJECT,this.updateAfterType=yn.OBJECT,this.previousModelWorldMatrix=$t(new gn),this.previousProjectionMatrix=$t(new gn).setGroup(Wt),this.previousCameraViewMatrix=$t(new gn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=N4(n);this.previousModelWorldMatrix.value.copy(r);const s=WP(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new gn,s.previousCameraViewMatrix=new gn,s.currentProjectionMatrix=new gn,s.currentCameraViewMatrix=new gn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){N4(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Jl:$t(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(cc).mul(Ki),r=this.previousProjectionMatrix.mul(t).mul(R1),s=n.xy.div(n.w),o=r.xy.div(r.w);return jn(s,o)}}function WP(i){let e=R4.get(i);return e===void 0&&(e={},R4.set(i,e)),e}function N4(i,e=0){const t=WP(i);let n=t[e];return n===void 0&&(t[e]=n=new gn,t[e].copy(i.matrixWorld)),n}const Hee=At(zee),Wee=pe(([i])=>fS(i.rgb)),$ee=pe(([i,e=Z(1)])=>e.mix(fS(i.rgb),i.rgb)),jee=pe(([i,e=Z(1)])=>{const t=br(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return Wn(i.rgb,n,r)}),Xee=pe(([i,e=Z(1)])=>{const t=he(.57735,.57735,.57735),n=e.cos();return he(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(Ko(t,i.rgb).mul(n.oneMinus())))))}),fS=(i,e=he(ln.getLuminanceCoefficients(new te)))=>Ko(i,e),Qee=pe(([i,e=he(1),t=he(0),n=he(1),r=Z(1),s=he(ln.getLuminanceCoefficients(new te,nc))])=>{const o=i.rgb.dot(he(s)),a=nr(i.rgb.mul(e).add(t),0).toVar(),l=a.pow(n).toVar();return Xt(a.r.greaterThan(0),()=>{a.r.assign(l.r)}),Xt(a.g.greaterThan(0),()=>{a.g.assign(l.g)}),Xt(a.b.greaterThan(0),()=>{a.b.assign(l.b)}),a.assign(o.add(a.sub(o).mul(r))),Yt(a.rgb,i.a)});class Yee extends ir{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Kee=pn(Yee).setParameterLength(2),qm=new qe;class $P extends _l{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class P4 extends $P{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}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.offsetNode=this.offsetNode,e}}class vl extends ir{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Ms;s.isRenderTargetTexture=!0,s.name="depth";const o=new hu(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:zi,...r});o.texture.name="output",o.depthTexture=s,this.renderTarget=o,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:o.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=$t(0),this._cameraFar=$t(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=yn.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return Ue("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return Ue("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];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),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 n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new P4(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 P4(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=Z3(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=Xf(s,n,r)}return t}async compileAsync(e){const t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===vl.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n}=this;let r,s;const o=t.getOutputRenderTarget();o&&o.isXRRenderTarget===!0?(s=1,r=t.xr.getCamera(),t.xr.updateCamera(r),qm.set(o.width,o.height)):(r=this.camera,s=t.getPixelRatio(),t.getSize(qm)),this._pixelRatio=s,this.setSize(qm.width,qm.height);const a=t.getRenderTarget(),l=t.getMRT(),u=t.autoClear,d=t.transparent,A=t.opaque,g=r.layers.mask,v=t.contextNode,x=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const S in this._previousTextures)this.toggleTexture(S);this.overrideMaterial!==null&&(n.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:Au({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const T=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=T,n.overrideMaterial=x,t.setRenderTarget(a),t.setMRT(l),t.autoClear=u,t.transparent=d,t.opaque=A,t.contextNode=v,r.layers.mask=g}setSize(e,t){this._width=e,this._height=t;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new dn),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new dn),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}vl.COLOR="color";vl.DEPTH="depth";const Zee=(i,e,t)=>new vl(vl.COLOR,i,e,t),Jee=(i,e)=>new $P(i,e),ete=(i,e,t)=>new vl(vl.DEPTH,i,e,t);class tte extends vl{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(vl.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,o,a,l,u,d,A)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const g=this._getOutlineMaterial(l);t.renderObject(r,s,o,a,g,u,d,A)}t.renderObject(r,s,o,a,l,u,d,A)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new lr;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Ai;const t=Ao.negate(),n=Jl.mul(cc),r=Z(1),s=n.mul(Yt(Ki,1)),o=n.mul(Yt(Ki.add(t),1)),a=Xs(s.sub(o));return e.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=Yt(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const nte=(i,e,t=new Gt(0,0,0),n=.003,r=1)=>gt(new tte(i,e,gt(t),gt(n),gt(r))),jP=pe(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),XP=pe(([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"}]}),QP=pe(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ite=pe(([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)}),YP=pe(([i,e])=>{const t=ds(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=ds(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=ite(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),rte=ds(he(1.6605,-.1246,-.0182),he(-.5876,1.1329,-.1006),he(-.0728,-.0083,1.1187)),ste=ds(he(.6274,.0691,.0164),he(.3293,.9195,.088),he(.0433,.0113,.8956)),ote=pe(([i])=>{const e=he(i).toVar(),t=he(e.mul(e)).toVar(),n=he(t.mul(t)).toVar();return Z(15.5).mul(n.mul(t)).sub(An(40.14,n.mul(e))).add(An(31.96,n).sub(An(6.868,t.mul(e))).add(An(.4298,t).add(An(.1191,e).sub(.00232))))}),KP=pe(([i,e])=>{const t=he(i).toVar(),n=ds(he(.856627153315983,.137318972929847,.11189821299995),he(.0951212405381588,.761241990602591,.0767994186031903),he(.0482516061458583,.101439036467562,.811302368396859)),r=ds(he(1.1271005818144368,-.1413297634984383,-.14132976349843826),he(-.11060664309660323,1.157823702216272,-.11060664309660294),he(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=Z(-12.47393),o=Z(4.026069);return t.mulAssign(e),t.assign(ste.mul(t)),t.assign(n.mul(t)),t.assign(nr(t,1e-10)),t.assign(cl(t)),t.assign(t.sub(s).div(o.sub(s))),t.assign(wa(t,0,1)),t.assign(ote(t)),t.assign(r.mul(t)),t.assign(zo(nr(he(0),t),he(2.2))),t.assign(rte.mul(t)),t.assign(wa(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ZP=pe(([i,e])=>{const t=Z(.76),n=Z(.15);i=i.mul(e);const r=fo(i.r,fo(i.g,i.b)),s=cs(r.lessThan(.08),r.sub(An(6.25,r.mul(r))),.04);i.subAssign(s);const o=nr(i.r,nr(i.g,i.b));Xt(o.lessThan(t),()=>i);const a=jn(1,t),l=jn(1,a.mul(a).div(o.add(a.sub(t))));i.mulAssign(l.div(o));const u=jn(1,Io(1,n.mul(o.sub(l)).add(1)));return Wn(i,he(l),u)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Wr extends Lt{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.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}}const N_=pn(Wr).setParameterLength(1,3),ate=(i,e)=>N_(i,e,"js"),lte=(i,e)=>N_(i,e,"wgsl"),ute=(i,e)=>N_(i,e,"glsl");class JP extends Wr{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,o=e.getCodeFromNode(this,s);r!==""&&(o.name=r);const a=e.getPropertyName(o),l=this.getNodeFunction(e).getCode(a);return o.code=l+` +`,t==="property"?a:e.format(`${a}()`,s,t)}}const e7=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},cte=(i,e)=>e7(i,e,"glsl"),hte=(i,e)=>e7(i,e,"wgsl");class fte extends Lt{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new La,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:Z()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=s5(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=o5(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Ng=pn(fte).setParameterLength(1);class t7 extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class dte{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Pg=new t7;class Ate extends Lt{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new t7,this._output=Ng(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=Ng(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=Ng(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(u,d)=>this.setOutput(u,d),n=new dte(this),r=Pg.get("THREE"),s=Pg.get("TSL"),o=this.getMethod(),a=[n,this._local,Pg,e,t,r,s];this._object=o(...a);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const u of l.elements){const d=u.id||u.name;u.inputType&&(this.getParameter(d)===void 0&&this.setParameter(d,null),this.getParameter(d).inputType=u.inputType),u.outputType&&(this.getOutput(d)===void 0&&this.setOutput(d,null),this.getOutput(d).outputType=u.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:Z()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; +`,s=` +return { ...output, `+n+" };",o=r+this.codeNode.code+s;return this._method=new Function(...e,o),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[gp(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Yd(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const pte=pn(Ate).setParameterLength(1,2);function n7(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Ar.z).negate()}const dS=pe(([i,e],t)=>{const n=n7(t);return Ma(i,e,n)}),AS=pe(([i],e)=>{const t=n7(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Z0=pe(([i,e])=>Yt(e.toFloat().mix(Wf.rgb,i.toVec3()),Wf.a));function mte(i,e,t){return Ue('TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Z0(i,dS(e,t))}function gte(i,e){return Ue('TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Z0(i,AS(e))}let Uc=null,Fc=null;class _te extends Lt{static get type(){return"RangeNode"}constructor(e=Z(),t=Z()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(ju(t.value)),s=e.getTypeLength(ju(n.value));return r>s?r:s}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(n=>{n.isConstNode===!0&&(t=n)}),t===null)throw new Error('THREE.TSL: No "ConstNode" found in node graph.');return t}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),o=r.value,a=s.value,l=e.getTypeLength(ju(o)),u=e.getTypeLength(ju(a));Uc=Uc||new dn,Fc=Fc||new dn,Uc.setScalar(0),Fc.setScalar(0),l===1?Uc.setScalar(o):o.isColor?Uc.set(o.r,o.g,o.b,1):Uc.set(o.x,o.y,o.z||0,o.w||0),u===1?Fc.setScalar(a):a.isColor?Fc.set(a.r,a.g,a.b,1):Fc.set(a.x,a.y,a.z||0,a.w||0);const d=4,A=d*t.count,g=new Float32Array(A);for(let x=0;xnew xte(i,e),yte=wp("numWorkgroups","uvec3"),bte=wp("workgroupId","uvec3"),Ste=wp("globalId","uvec3"),Tte=wp("localId","uvec3"),wte=wp("subgroupSize","uint");class Mte extends Lt{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}const pS=pn(Mte),Ete=()=>pS("workgroup").toStack(),Cte=()=>pS("storage").toStack(),Rte=()=>pS("texture").toStack();class Nte extends Ch{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Pte extends Lt{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return Ue('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new Nte(this,e)}generate(e){const t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Dte=(i,e)=>new Pte("Workgroup",i,e);class Vr extends Lt{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),n=t.parents,r=this.method,s=this.getNodeType(e),o=this.getInputType(e),a=this.pointerNode,l=this.valueNode,u=[];u.push(`&${a.build(e,o)}`),l!==null&&u.push(l.build(e,o));const d=`${e.getMethod(r,s)}( ${u.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(d,this);else return t.constNode===void 0&&(t.constNode=au(d,s).toConst()),t.constNode.build(e)}}Vr.ATOMIC_LOAD="atomicLoad";Vr.ATOMIC_STORE="atomicStore";Vr.ATOMIC_ADD="atomicAdd";Vr.ATOMIC_SUB="atomicSub";Vr.ATOMIC_MAX="atomicMax";Vr.ATOMIC_MIN="atomicMin";Vr.ATOMIC_AND="atomicAnd";Vr.ATOMIC_OR="atomicOr";Vr.ATOMIC_XOR="atomicXor";const Lte=pn(Vr),Ml=(i,e,t)=>Lte(i,e,t).toStack(),Ite=i=>Ml(Vr.ATOMIC_LOAD,i,null),Bte=(i,e)=>Ml(Vr.ATOMIC_STORE,i,e),Ute=(i,e)=>Ml(Vr.ATOMIC_ADD,i,e),Fte=(i,e)=>Ml(Vr.ATOMIC_SUB,i,e),Ote=(i,e)=>Ml(Vr.ATOMIC_MAX,i,e),kte=(i,e)=>Ml(Vr.ATOMIC_MIN,i,e),Vte=(i,e)=>Ml(Vr.ATOMIC_AND,i,e),Gte=(i,e)=>Ml(Vr.ATOMIC_OR,i,e),qte=(i,e)=>Ml(Vr.ATOMIC_XOR,i,e);class bt extends ir{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(n)?0:e.getTypeLength(n);return r>s?t:n}getNodeType(e){const t=this.method;return t===bt.SUBGROUP_ELECT?"bool":t===bt.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,r=this.getNodeType(e),s=this.getInputType(e),o=this.aNode,a=this.bNode,l=[];if(n===bt.SUBGROUP_BROADCAST||n===bt.SUBGROUP_SHUFFLE||n===bt.QUAD_BROADCAST){const d=a.getNodeType(e);l.push(o.build(e,r),a.build(e,d==="float"?"int":r))}else n===bt.SUBGROUP_SHUFFLE_XOR||n===bt.SUBGROUP_SHUFFLE_DOWN||n===bt.SUBGROUP_SHUFFLE_UP?l.push(o.build(e,r),a.build(e,"uint")):(o!==null&&l.push(o.build(e,s)),a!==null&&l.push(a.build(e,s)));const u=l.length===0?"()":`( ${l.join(", ")} )`;return e.format(`${e.getMethod(n,r)}${u}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}bt.SUBGROUP_ELECT="subgroupElect";bt.SUBGROUP_BALLOT="subgroupBallot";bt.SUBGROUP_ADD="subgroupAdd";bt.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";bt.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";bt.SUBGROUP_MUL="subgroupMul";bt.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";bt.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";bt.SUBGROUP_AND="subgroupAnd";bt.SUBGROUP_OR="subgroupOr";bt.SUBGROUP_XOR="subgroupXor";bt.SUBGROUP_MIN="subgroupMin";bt.SUBGROUP_MAX="subgroupMax";bt.SUBGROUP_ALL="subgroupAll";bt.SUBGROUP_ANY="subgroupAny";bt.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";bt.QUAD_SWAP_X="quadSwapX";bt.QUAD_SWAP_Y="quadSwapY";bt.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";bt.SUBGROUP_BROADCAST="subgroupBroadcast";bt.SUBGROUP_SHUFFLE="subgroupShuffle";bt.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";bt.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";bt.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";bt.QUAD_BROADCAST="quadBroadcast";const zte=nt(bt,bt.SUBGROUP_ELECT).setParameterLength(0),Hte=nt(bt,bt.SUBGROUP_BALLOT).setParameterLength(1),Wte=nt(bt,bt.SUBGROUP_ADD).setParameterLength(1),$te=nt(bt,bt.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),jte=nt(bt,bt.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),Xte=nt(bt,bt.SUBGROUP_MUL).setParameterLength(1),Qte=nt(bt,bt.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Yte=nt(bt,bt.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),Kte=nt(bt,bt.SUBGROUP_AND).setParameterLength(1),Zte=nt(bt,bt.SUBGROUP_OR).setParameterLength(1),Jte=nt(bt,bt.SUBGROUP_XOR).setParameterLength(1),ene=nt(bt,bt.SUBGROUP_MIN).setParameterLength(1),tne=nt(bt,bt.SUBGROUP_MAX).setParameterLength(1),nne=nt(bt,bt.SUBGROUP_ALL).setParameterLength(0),ine=nt(bt,bt.SUBGROUP_ANY).setParameterLength(0),rne=nt(bt,bt.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),sne=nt(bt,bt.QUAD_SWAP_X).setParameterLength(1),one=nt(bt,bt.QUAD_SWAP_Y).setParameterLength(1),ane=nt(bt,bt.QUAD_SWAP_DIAGONAL).setParameterLength(1),lne=nt(bt,bt.SUBGROUP_BROADCAST).setParameterLength(2),une=nt(bt,bt.SUBGROUP_SHUFFLE).setParameterLength(2),cne=nt(bt,bt.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),hne=nt(bt,bt.SUBGROUP_SHUFFLE_UP).setParameterLength(2),fne=nt(bt,bt.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),dne=nt(bt,bt.QUAD_BROADCAST).setParameterLength(1);let zm;function P_(i){zm=zm||new WeakMap;let e=zm.get(i);return e===void 0&&zm.set(i,e={}),e}function D_(i){const e=P_(i);return e.shadowMatrix||(e.shadowMatrix=$t("mat4").setGroup(Wt).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 i7(i,e=dl){const t=D_(i).mul(e);return t.xyz.div(t.w)}function mS(i){const e=P_(i);return e.position||(e.position=$t(new te).setGroup(Wt).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function r7(i){const e=P_(i);return e.targetPosition||(e.targetPosition=$t(new te).setGroup(Wt).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function gS(i){const e=P_(i);return e.viewPosition||(e.viewPosition=$t(new te).setGroup(Wt).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new te,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const _S=i=>ia.transformDirection(mS(i).sub(r7(i))),Ane=i=>i.sort((e,t)=>e.id-t.id),pne=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},wv=new WeakMap,DA=[];class vS extends Lt{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Yl("vec3","totalDiffuse"),this.totalSpecularNode=Yl("vec3","totalSpecular"),this.outgoingLightNode=Yl("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n0}}const mne=(i=[])=>new vS().setLights(i);class gne extends Lt{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=yn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){xS.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||dl)}}const xS=Yl("vec3","shadowPositionWorld");function _ne(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 Gt),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function vne(i,e){return e=_ne(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function xne(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 yne(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function bne(i,e){return e=yne(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Sne(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Tne(i,e,t){return t=vne(i,t),t=bne(e,t),t}function wne(i,e,t){xne(i,t),Sne(e,t)}const L1=new WeakMap,s7=pe(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=ti(i,e.xy).setName("t_basic");return i.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),o7=pe(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(d,A)=>{let g=ti(i,d);return i.isArrayTexture&&(g=g.depth(n)),g.compare(A)},s=gi("mapSize","vec2",t).setGroup(Wt),o=gi("radius","float",t).setGroup(Wt),a=Ze(1).div(s),l=o.mul(a.x),u=hS(Nh.xy).mul(6.28318530718);return br(r(e.xy.add(ma(0,5,u).mul(l)),e.z),r(e.xy.add(ma(1,5,u).mul(l)),e.z),r(e.xy.add(ma(2,5,u).mul(l)),e.z),r(e.xy.add(ma(3,5,u).mul(l)),e.z),r(e.xy.add(ma(4,5,u).mul(l)),e.z)).mul(1/5)}),a7=pe(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(A,g)=>{let v=ti(i,A);return i.isArrayTexture&&(v=v.depth(n)),v.compare(g)},s=gi("mapSize","vec2",t).setGroup(Wt),o=Ze(1).div(s),a=o.x,l=o.y,u=e.xy,d=Ta(u.mul(s).add(.5));return u.subAssign(d.mul(o)),br(r(u,e.z),r(u.add(Ze(a,0)),e.z),r(u.add(Ze(0,l)),e.z),r(u.add(o),e.z),Wn(r(u.add(Ze(a.negate(),0)),e.z),r(u.add(Ze(a.mul(2),0)),e.z),d.x),Wn(r(u.add(Ze(a.negate(),l)),e.z),r(u.add(Ze(a.mul(2),l)),e.z),d.x),Wn(r(u.add(Ze(0,l.negate())),e.z),r(u.add(Ze(0,l.mul(2))),e.z),d.y),Wn(r(u.add(Ze(a,l.negate())),e.z),r(u.add(Ze(a,l.mul(2))),e.z),d.y),Wn(Wn(r(u.add(Ze(a.negate(),l.negate())),e.z),r(u.add(Ze(a.mul(2),l.negate())),e.z),d.x),Wn(r(u.add(Ze(a.negate(),l.mul(2))),e.z),r(u.add(Ze(a.mul(2),l.mul(2))),e.z),d.x),d.y)).mul(1/9)}),l7=pe(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=ti(i).sample(e.xy);i.isArrayTexture&&(n=n.depth(t)),n=n.rg;const r=n.x,s=nr(1e-7,n.y.mul(n.y)),o=d_(e.z,r);Xt(o.equal(1),()=>Z(1));const a=e.z.sub(r);let l=s.div(s.add(a.mul(a)));return l=wa(jn(l,.3).div(.65)),nr(o,l)}),Mne=pe(([i,e,t])=>{let n=dl.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Ene=i=>{const e=i.shadow.camera,t=gi("near","float",e).setGroup(Wt),n=gi("far","float",e).setGroup(Wt),r=H6(i);return Mne(r,t,n)},u7=i=>{let e=L1.get(i);if(e===void 0){const t=i.isPointLight?Ene(i):null;e=new lr,e.colorNode=Yt(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,L1.set(i,e)}return e},c7=i=>{const e=L1.get(i);e!==void 0&&(e.dispose(),L1.delete(i))},D4=new Ea,xf=[],h7=(i,e,t,n)=>{xf[0]=i,xf[1]=e;let r=D4.get(xf);return(r===void 0||r.shadowType!==t||r.useVelocity!==n)&&(r=(s,o,a,l,u,d,...A)=>{(s.castShadow===!0||s.receiveShadow&&t===Hl)&&(n&&(r5(s).useVelocity=!0),s.onBeforeShadow(i,s,a,e.camera,l,o.overrideMaterial,d),i.renderObject(s,o,a,l,u,d,...A),s.onAfterShadow(i,s,a,e.camera,l,o.overrideMaterial,d))},r.shadowType=t,r.useVelocity=n,D4.set(xf,r)),xf[0]=null,xf[1]=null,r},Cne=pe(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const s=Z(0).toVar("meanVertical"),o=Z(0).toVar("squareMeanVertical"),a=i.lessThanEqual(Z(1)).select(Z(0),Z(2).div(i.sub(1))),l=i.lessThanEqual(Z(1)).select(Z(0),Z(-1));di({start:ce(0),end:ce(i),type:"int",condition:"<"},({i:d})=>{const A=l.add(Z(d).mul(a));let g=n.sample(br(Nh.xy,Ze(0,A).mul(e)).div(t));n.value.isArrayTexture&&(g=g.depth(r)),g=g.x,s.addAssign(g),o.addAssign(g.mul(g))}),s.divAssign(i),o.divAssign(i);const u=ws(o.sub(s.mul(s)).max(0));return Ze(s,u)}),Rne=pe(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const s=Z(0).toVar("meanHorizontal"),o=Z(0).toVar("squareMeanHorizontal"),a=i.lessThanEqual(Z(1)).select(Z(0),Z(2).div(i.sub(1))),l=i.lessThanEqual(Z(1)).select(Z(0),Z(-1));di({start:ce(0),end:ce(i),type:"int",condition:"<"},({i:d})=>{const A=l.add(Z(d).mul(a));let g=n.sample(br(Nh.xy,Ze(A,0).mul(e)).div(t));n.value.isArrayTexture&&(g=g.depth(r)),s.addAssign(g.x),o.addAssign(br(g.y.mul(g.y),g.x.mul(g.x)))}),s.divAssign(i),o.divAssign(i);const u=ws(o.sub(s.mul(s)).max(0));return Ze(s,u)}),Nne=[s7,o7,a7,l7];let Mv;const Hm=new E_;class f7 extends gne{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:n,shadowCoord:r,shadow:s,depthLayer:o}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s,depthLayer:o});return a.select(l,Z(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=gi("bias","float",n).setGroup(Wt);let o=t,a;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),a=o.z,r.coordinateSystem===Xo&&(a=a.mul(2).sub(1));else{const l=o.w;o=o.xy.div(l);const u=gi("near","float",n.camera).setGroup(Wt),d=gi("far","float",n.camera).setGroup(Wt);a=J3(l.negate(),u,d)}return o=he(o.x,o.y.oneMinus(),a.add(s)),o}getShadowFilterFn(e){return Nne[e]}setupRenderTarget(e,t){const n=new Ms(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=ap;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){const{renderer:t,camera:n}=e,{light:r,shadow:s}=this,o=t.shadowMap.type,{depthTexture:a,shadowMap:l}=this.setupRenderTarget(s,e);if(s.camera.coordinateSystem=n.coordinateSystem,s.camera.updateProjectionMatrix(),o===Hl&&s.isPointLightShadow!==!0){a.compareFunction=null,l.depth>1?(l._vsmShadowMapVertical||(l._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Hs,type:zi,depth:l.depth,depthBuffer:!1}),l._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=l._vsmShadowMapVertical,l._vsmShadowMapHorizontal||(l._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Hs,type:zi,depth:l.depth,depthBuffer:!1}),l._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=l._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Hs,type:zi,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:Hs,type:zi,depthBuffer:!1}));let E=ti(a);a.isArrayTexture&&(E=E.depth(this.depthLayer));let N=ti(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(N=N.depth(this.depthLayer));const L=gi("blurSamples","float",s).setGroup(Wt),B=gi("radius","float",s).setGroup(Wt),I=gi("mapSize","vec2",s).setGroup(Wt);let F=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lr);F.fragmentNode=Cne({samples:L,radius:B,size:I,shadowPass:E,depthLayer:this.depthLayer}).context(e.getSharedContext()),F.name="VSMVertical",F=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lr),F.fragmentNode=Rne({samples:L,radius:B,size:I,shadowPass:N,depthLayer:this.depthLayer}).context(e.getSharedContext()),F.name="VSMHorizontal"}const u=gi("intensity","float",s).setGroup(Wt),d=gi("normalBias","float",s).setGroup(Wt),A=D_(r).mul(xS.add(hc.mul(d))),g=this.setupShadowCoord(e,A),v=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(v===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const x=o===Hl&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:v,shadowTexture:l.texture,depthTexture:x,shadowCoord:g,shadow:s,depthLayer:this.depthLayer});let S;l.texture.isCubeTexture?S=qs(l.texture,g.xyz):(S=ti(l.texture,g),a.isArrayTexture&&(S=S.depth(this.depthLayer)));const w=Wn(1,T.rgb.mix(S,1),u.mul(S.a)).toVar();this.shadowMap=l,this.shadow.map=l;const C=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return w.toInspector(`${C} / Color`,()=>this.shadowMap.texture.isCubeTexture?qs(this.shadowMap.texture):ti(this.shadowMap.texture)).toInspector(`${C} / Depth`,()=>this.shadowMap.texture.isCubeTexture?qs(this.shadowMap.texture).r.oneMinus():sr(this.shadowMap.depthTexture,yi().mul(Kl(ti(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return pe(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.shadowNode&&Ue('NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:o}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);const a=o.name;o.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,s.render(o,t.camera),o.name=a}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:o,camera:a}=e,l=s.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const d=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=a.layers.mask);const A=s.getRenderObjectFunction(),g=s.getMRT(),v=g?g.has("velocity"):!1;Mv=Tne(s,o,Mv),o.overrideMaterial=u7(n),s.setRenderObjectFunction(h7(s,r,l,v)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(A),l===Hl&&r.isPointLightShadow!==!0&&this.vsmPass(s),r.camera.layers.mask=d,wne(s,o,Mv)}vsmPass(e){const{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),Hm.material=this.vsmMaterialVertical,Hm.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Hm.material=this.vsmMaterialHorizontal,Hm.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,c7(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 n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const d7=(i,e)=>new f7(i,e),Pne=new Gt,L4=new gn,LA=new te,Ev=new te,Dne=[new te(1,0,0),new te(-1,0,0),new te(0,-1,0),new te(0,1,0),new te(0,0,1),new te(0,0,-1)],Lne=[new te(0,-1,0),new te(0,-1,0),new te(0,0,-1),new te(0,0,1),new te(0,-1,0),new te(0,-1,0)],Ine=[new te(1,0,0),new te(-1,0,0),new te(0,1,0),new te(0,-1,0),new te(0,0,1),new te(0,0,-1)],Bne=[new te(0,-1,0),new te(0,-1,0),new te(0,0,1),new te(0,0,-1),new te(0,-1,0),new te(0,-1,0)],A7=pe(({depthTexture:i,bd3D:e,dp:t})=>qs(i,e).compare(t)),p7=pe(({depthTexture:i,bd3D:e,dp:t,shadow:n})=>{const r=gi("radius","float",n).setGroup(Wt),s=gi("mapSize","vec2",n).setGroup(Wt),o=r.div(s.x),a=Di(e),l=Xs(ou(e,a.x.greaterThan(a.z).select(he(0,1,0),he(1,0,0)))),u=ou(e,l),d=hS(Nh.xy).mul(6.28318530718),A=ma(0,5,d),g=ma(1,5,d),v=ma(2,5,d),x=ma(3,5,d),T=ma(4,5,d);return qs(i,e.add(l.mul(A.x).add(u.mul(A.y)).mul(o))).compare(t).add(qs(i,e.add(l.mul(g.x).add(u.mul(g.y)).mul(o))).compare(t)).add(qs(i,e.add(l.mul(v.x).add(u.mul(v.y)).mul(o))).compare(t)).add(qs(i,e.add(l.mul(x.x).add(u.mul(x.y)).mul(o))).compare(t)).add(qs(i,e.add(l.mul(T.x).add(u.mul(T.y)).mul(o))).compare(t)).mul(1/5)}),Une=pe(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),o=$t("float").setGroup(Wt).onRenderUpdate(()=>n.camera.near),a=$t("float").setGroup(Wt).onRenderUpdate(()=>n.camera.far),l=gi("bias","float",n).setGroup(Wt),u=Z(1).toVar();return Xt(s.sub(a).lessThanEqual(0).and(s.sub(o).greaterThanEqual(0)),()=>{const d=s.sub(o).div(a.sub(o)).toVar();d.addAssign(l);const A=r.normalize();u.assign(i({depthTexture:e,bd3D:A,dp:d,shadow:n}))}),u});class Fne extends f7{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===CB?A7:p7}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){return Une({filterFn:t,depthTexture:n,shadowCoord:r,shadow:s})}setupRenderTarget(e,t){const n=new dR(e.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=ap;const r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:o}=e,a=t.camera,l=t.matrix,u=s.coordinateSystem===Xo,d=u?Dne:Ine,A=u?Lne:Bne;n.setSize(t.mapSize.width,t.mapSize.width);const g=s.autoClear,v=s.getClearColor(Pne),x=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let T=0;T<6;T++){s.setRenderTarget(n,T),s.clear();const S=r.distance||a.far;S!==a.far&&(a.far=S,a.updateProjectionMatrix()),LA.setFromMatrixPosition(r.matrixWorld),a.position.copy(LA),Ev.copy(a.position),Ev.add(d[T]),a.up.copy(A[T]),a.lookAt(Ev),a.updateMatrixWorld(),l.makeTranslation(-LA.x,-LA.y,-LA.z),L4.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(L4,a.coordinateSystem,a.reversedDepth);const w=o.name;o.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${T+1}`,s.render(o,a),o.name=w}s.autoClear=g,s.setClearColor(v,x)}}const m7=(i,e)=>new Fne(i,e);class Ph extends Zd{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Gt,this.colorNode=e&&e.colorNode||$t(this.color).setGroup(Wt),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=yn.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 gS(this.light).sub(e.context.positionView||Ar)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return d7(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=gt(r):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}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),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const yS=pe(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const n=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(i.div(e).pow4().oneMinus().clamp().pow2()),n)}),g7=({color:i,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const r=e.normalize(),s=e.length(),o=yS({lightDistance:s,cutoffDistance:t,decayExponent:n}),a=i.mul(o);return{lightDirection:r,lightColor:a}};class One extends Ph{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=$t(0).setGroup(Wt),this.decayExponentNode=$t(2).setGroup(Wt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return m7(this.light)}setupDirect(e){return g7({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const kne=pe(([i=yi()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),Vne=pe(([i=yi()],{renderer:e,material:t})=>{const n=C3(i.mul(2).sub(1));let r;if(t.alphaToCoverage&&e.currentSamples>0){const s=Z(n.fwidth()).toVar();r=Ma(s.oneMinus(),s.add(1),n).oneMinus()}else r=cs(n.greaterThan(1),0,1);return r}),A0=pe(([i,e,t])=>{const n=Z(t).toVar(),r=Z(e).toVar(),s=Yo(i).toVar();return cs(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),I1=pe(([i,e])=>{const t=Yo(e).toVar(),n=Z(i).toVar();return cs(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),yr=pe(([i])=>{const e=Z(i).toVar();return ce(hl(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Xi=pe(([i,e])=>{const t=Z(i).toVar();return e.assign(yr(t)),t.sub(Z(e))}),Gne=pe(([i,e,t,n,r,s])=>{const o=Z(s).toVar(),a=Z(r).toVar(),l=Z(n).toVar(),u=Z(t).toVar(),d=Z(e).toVar(),A=Z(i).toVar(),g=Z(jn(1,a)).toVar();return jn(1,o).mul(A.mul(g).add(d.mul(a))).add(o.mul(u.mul(g).add(l.mul(a))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),qne=pe(([i,e,t,n,r,s])=>{const o=Z(s).toVar(),a=Z(r).toVar(),l=he(n).toVar(),u=he(t).toVar(),d=he(e).toVar(),A=he(i).toVar(),g=Z(jn(1,a)).toVar();return jn(1,o).mul(A.mul(g).add(d.mul(a))).add(o.mul(u.mul(g).add(l.mul(a))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),_7=ps([Gne,qne]),zne=pe(([i,e,t,n,r,s,o,a,l,u,d])=>{const A=Z(d).toVar(),g=Z(u).toVar(),v=Z(l).toVar(),x=Z(a).toVar(),T=Z(o).toVar(),S=Z(s).toVar(),w=Z(r).toVar(),C=Z(n).toVar(),E=Z(t).toVar(),N=Z(e).toVar(),L=Z(i).toVar(),B=Z(jn(1,v)).toVar(),I=Z(jn(1,g)).toVar();return Z(jn(1,A)).toVar().mul(I.mul(L.mul(B).add(N.mul(v))).add(g.mul(E.mul(B).add(C.mul(v))))).add(A.mul(I.mul(w.mul(B).add(S.mul(v))).add(g.mul(T.mul(B).add(x.mul(v))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Hne=pe(([i,e,t,n,r,s,o,a,l,u,d])=>{const A=Z(d).toVar(),g=Z(u).toVar(),v=Z(l).toVar(),x=he(a).toVar(),T=he(o).toVar(),S=he(s).toVar(),w=he(r).toVar(),C=he(n).toVar(),E=he(t).toVar(),N=he(e).toVar(),L=he(i).toVar(),B=Z(jn(1,v)).toVar(),I=Z(jn(1,g)).toVar();return Z(jn(1,A)).toVar().mul(I.mul(L.mul(B).add(N.mul(v))).add(g.mul(E.mul(B).add(C.mul(v))))).add(A.mul(I.mul(w.mul(B).add(S.mul(v))).add(g.mul(T.mul(B).add(x.mul(v))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),v7=ps([zne,Hne]),Wne=pe(([i,e,t])=>{const n=Z(t).toVar(),r=Z(e).toVar(),s=We(i).toVar(),o=We(s.bitAnd(We(7))).toVar(),a=Z(A0(o.lessThan(We(4)),r,n)).toVar(),l=Z(An(2,A0(o.lessThan(We(4)),n,r))).toVar();return I1(a,Yo(o.bitAnd(We(1)))).add(I1(l,Yo(o.bitAnd(We(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),$ne=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=Z(e).toVar(),a=We(i).toVar(),l=We(a.bitAnd(We(15))).toVar(),u=Z(A0(l.lessThan(We(8)),o,s)).toVar(),d=Z(A0(l.lessThan(We(4)),s,A0(l.equal(We(12)).or(l.equal(We(14))),o,r))).toVar();return I1(u,Yo(l.bitAnd(We(1)))).add(I1(d,Yo(l.bitAnd(We(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),$r=ps([Wne,$ne]),jne=pe(([i,e,t])=>{const n=Z(t).toVar(),r=Z(e).toVar(),s=Rh(i).toVar();return he($r(s.x,r,n),$r(s.y,r,n),$r(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Xne=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=Z(e).toVar(),a=Rh(i).toVar();return he($r(a.x,o,s,r),$r(a.y,o,s,r),$r(a.z,o,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Go=ps([jne,Xne]),Qne=pe(([i])=>{const e=Z(i).toVar();return An(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Yne=pe(([i])=>{const e=Z(i).toVar();return An(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Kne=pe(([i])=>{const e=he(i).toVar();return An(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),x7=ps([Qne,Kne]),Zne=pe(([i])=>{const e=he(i).toVar();return An(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),y7=ps([Yne,Zne]),Co=pe(([i,e])=>{const t=ce(e).toVar(),n=We(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(ce(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),b7=pe(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(Co(t,ce(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Co(i,ce(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Co(e,ce(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Co(t,ce(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Co(i,ce(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Co(e,ce(4))),e.addAssign(i)}),Mp=pe(([i,e,t])=>{const n=We(t).toVar(),r=We(e).toVar(),s=We(i).toVar();return n.bitXorAssign(r),n.subAssign(Co(r,ce(14))),s.bitXorAssign(n),s.subAssign(Co(n,ce(11))),r.bitXorAssign(s),r.subAssign(Co(s,ce(25))),n.bitXorAssign(r),n.subAssign(Co(r,ce(16))),s.bitXorAssign(n),s.subAssign(Co(n,ce(4))),r.bitXorAssign(s),r.subAssign(Co(s,ce(14))),n.bitXorAssign(r),n.subAssign(Co(r,ce(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Es=pe(([i])=>{const e=We(i).toVar();return Z(e).div(Z(We(ce(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),pl=pe(([i])=>{const e=Z(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Jne=pe(([i])=>{const e=ce(i).toVar(),t=We(We(1)).toVar(),n=We(We(ce(3735928559)).add(t.shiftLeft(We(2))).add(We(13))).toVar();return Mp(n.add(We(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),eie=pe(([i,e])=>{const t=ce(e).toVar(),n=ce(i).toVar(),r=We(We(2)).toVar(),s=We().toVar(),o=We().toVar(),a=We().toVar();return s.assign(o.assign(a.assign(We(ce(3735928559)).add(r.shiftLeft(We(2))).add(We(13))))),s.addAssign(We(n)),o.addAssign(We(t)),Mp(s,o,a)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),tie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=ce(e).toVar(),s=ce(i).toVar(),o=We(We(3)).toVar(),a=We().toVar(),l=We().toVar(),u=We().toVar();return a.assign(l.assign(u.assign(We(ce(3735928559)).add(o.shiftLeft(We(2))).add(We(13))))),a.addAssign(We(s)),l.addAssign(We(r)),u.addAssign(We(n)),Mp(a,l,u)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),nie=pe(([i,e,t,n])=>{const r=ce(n).toVar(),s=ce(t).toVar(),o=ce(e).toVar(),a=ce(i).toVar(),l=We(We(4)).toVar(),u=We().toVar(),d=We().toVar(),A=We().toVar();return u.assign(d.assign(A.assign(We(ce(3735928559)).add(l.shiftLeft(We(2))).add(We(13))))),u.addAssign(We(a)),d.addAssign(We(o)),A.addAssign(We(s)),b7(u,d,A),u.addAssign(We(r)),Mp(u,d,A)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),iie=pe(([i,e,t,n,r])=>{const s=ce(r).toVar(),o=ce(n).toVar(),a=ce(t).toVar(),l=ce(e).toVar(),u=ce(i).toVar(),d=We(We(5)).toVar(),A=We().toVar(),g=We().toVar(),v=We().toVar();return A.assign(g.assign(v.assign(We(ce(3735928559)).add(d.shiftLeft(We(2))).add(We(13))))),A.addAssign(We(u)),g.addAssign(We(l)),v.addAssign(We(a)),b7(A,g,v),A.addAssign(We(o)),g.addAssign(We(s)),Mp(A,g,v)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),_i=ps([Jne,eie,tie,nie,iie]),rie=pe(([i,e])=>{const t=ce(e).toVar(),n=ce(i).toVar(),r=We(_i(n,t)).toVar(),s=Rh().toVar();return s.x.assign(r.bitAnd(ce(255))),s.y.assign(r.shiftRight(ce(8)).bitAnd(ce(255))),s.z.assign(r.shiftRight(ce(16)).bitAnd(ce(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),sie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=ce(e).toVar(),s=ce(i).toVar(),o=We(_i(s,r,n)).toVar(),a=Rh().toVar();return a.x.assign(o.bitAnd(ce(255))),a.y.assign(o.shiftRight(ce(8)).bitAnd(ce(255))),a.z.assign(o.shiftRight(ce(16)).bitAnd(ce(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),qo=ps([rie,sie]),oie=pe(([i])=>{const e=Ze(i).toVar(),t=ce().toVar(),n=ce().toVar(),r=Z(Xi(e.x,t)).toVar(),s=Z(Xi(e.y,n)).toVar(),o=Z(pl(r)).toVar(),a=Z(pl(s)).toVar(),l=Z(_7($r(_i(t,n),r,s),$r(_i(t.add(ce(1)),n),r.sub(1),s),$r(_i(t,n.add(ce(1))),r,s.sub(1)),$r(_i(t.add(ce(1)),n.add(ce(1))),r.sub(1),s.sub(1)),o,a)).toVar();return x7(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),aie=pe(([i])=>{const e=he(i).toVar(),t=ce().toVar(),n=ce().toVar(),r=ce().toVar(),s=Z(Xi(e.x,t)).toVar(),o=Z(Xi(e.y,n)).toVar(),a=Z(Xi(e.z,r)).toVar(),l=Z(pl(s)).toVar(),u=Z(pl(o)).toVar(),d=Z(pl(a)).toVar(),A=Z(v7($r(_i(t,n,r),s,o,a),$r(_i(t.add(ce(1)),n,r),s.sub(1),o,a),$r(_i(t,n.add(ce(1)),r),s,o.sub(1),a),$r(_i(t.add(ce(1)),n.add(ce(1)),r),s.sub(1),o.sub(1),a),$r(_i(t,n,r.add(ce(1))),s,o,a.sub(1)),$r(_i(t.add(ce(1)),n,r.add(ce(1))),s.sub(1),o,a.sub(1)),$r(_i(t,n.add(ce(1)),r.add(ce(1))),s,o.sub(1),a.sub(1)),$r(_i(t.add(ce(1)),n.add(ce(1)),r.add(ce(1))),s.sub(1),o.sub(1),a.sub(1)),l,u,d)).toVar();return y7(A)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),bS=ps([oie,aie]),lie=pe(([i])=>{const e=Ze(i).toVar(),t=ce().toVar(),n=ce().toVar(),r=Z(Xi(e.x,t)).toVar(),s=Z(Xi(e.y,n)).toVar(),o=Z(pl(r)).toVar(),a=Z(pl(s)).toVar(),l=he(_7(Go(qo(t,n),r,s),Go(qo(t.add(ce(1)),n),r.sub(1),s),Go(qo(t,n.add(ce(1))),r,s.sub(1)),Go(qo(t.add(ce(1)),n.add(ce(1))),r.sub(1),s.sub(1)),o,a)).toVar();return x7(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),uie=pe(([i])=>{const e=he(i).toVar(),t=ce().toVar(),n=ce().toVar(),r=ce().toVar(),s=Z(Xi(e.x,t)).toVar(),o=Z(Xi(e.y,n)).toVar(),a=Z(Xi(e.z,r)).toVar(),l=Z(pl(s)).toVar(),u=Z(pl(o)).toVar(),d=Z(pl(a)).toVar(),A=he(v7(Go(qo(t,n,r),s,o,a),Go(qo(t.add(ce(1)),n,r),s.sub(1),o,a),Go(qo(t,n.add(ce(1)),r),s,o.sub(1),a),Go(qo(t.add(ce(1)),n.add(ce(1)),r),s.sub(1),o.sub(1),a),Go(qo(t,n,r.add(ce(1))),s,o,a.sub(1)),Go(qo(t.add(ce(1)),n,r.add(ce(1))),s.sub(1),o,a.sub(1)),Go(qo(t,n.add(ce(1)),r.add(ce(1))),s,o.sub(1),a.sub(1)),Go(qo(t.add(ce(1)),n.add(ce(1)),r.add(ce(1))),s.sub(1),o.sub(1),a.sub(1)),l,u,d)).toVar();return y7(A)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Ep=ps([lie,uie]),cie=pe(([i])=>{const e=Z(i).toVar(),t=ce(yr(e)).toVar();return Es(_i(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),hie=pe(([i])=>{const e=Ze(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar();return Es(_i(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),fie=pe(([i])=>{const e=he(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar(),r=ce(yr(e.z)).toVar();return Es(_i(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),die=pe(([i])=>{const e=Yt(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar(),r=ce(yr(e.z)).toVar(),s=ce(yr(e.w)).toVar();return Es(_i(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),Aie=ps([cie,hie,fie,die]),pie=pe(([i])=>{const e=Z(i).toVar(),t=ce(yr(e)).toVar();return he(Es(_i(t,ce(0))),Es(_i(t,ce(1))),Es(_i(t,ce(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),mie=pe(([i])=>{const e=Ze(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar();return he(Es(_i(t,n,ce(0))),Es(_i(t,n,ce(1))),Es(_i(t,n,ce(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gie=pe(([i])=>{const e=he(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar(),r=ce(yr(e.z)).toVar();return he(Es(_i(t,n,r,ce(0))),Es(_i(t,n,r,ce(1))),Es(_i(t,n,r,ce(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),_ie=pe(([i])=>{const e=Yt(i).toVar(),t=ce(yr(e.x)).toVar(),n=ce(yr(e.y)).toVar(),r=ce(yr(e.z)).toVar(),s=ce(yr(e.w)).toVar();return he(Es(_i(t,n,r,s,ce(0))),Es(_i(t,n,r,s,ce(1))),Es(_i(t,n,r,s,ce(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),L_=ps([pie,mie,gie,_ie]),B1=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=ce(e).toVar(),a=he(i).toVar(),l=Z(0).toVar(),u=Z(1).toVar();return di(o,()=>{l.addAssign(u.mul(bS(a))),u.mulAssign(r),a.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),I_=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=ce(e).toVar(),a=he(i).toVar(),l=he(0).toVar(),u=Z(1).toVar();return di(o,()=>{l.addAssign(u.mul(Ep(a))),u.mulAssign(r),a.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),vie=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=ce(e).toVar(),a=he(i).toVar();return Ze(B1(a,o,s,r),B1(a.add(he(ce(19),ce(193),ce(17))),o,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),xie=pe(([i,e,t,n])=>{const r=Z(n).toVar(),s=Z(t).toVar(),o=ce(e).toVar(),a=he(i).toVar(),l=he(I_(a,o,s,r)).toVar(),u=Z(B1(a.add(he(ce(19),ce(193),ce(17))),o,s,r)).toVar();return Yt(l,u)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),yie=pe(([i,e,t,n,r,s,o])=>{const a=ce(o).toVar(),l=Z(s).toVar(),u=ce(r).toVar(),d=ce(n).toVar(),A=ce(t).toVar(),g=ce(e).toVar(),v=Ze(i).toVar(),x=he(L_(Ze(g.add(d),A.add(u)))).toVar(),T=Ze(x.x,x.y).toVar();T.subAssign(.5),T.mulAssign(l),T.addAssign(.5);const S=Ze(Ze(Z(g),Z(A)).add(T)).toVar(),w=Ze(S.sub(v)).toVar();return Xt(a.equal(ce(2)),()=>Di(w.x).add(Di(w.y))),Xt(a.equal(ce(3)),()=>nr(Di(w.x),Di(w.y))),Ko(w,w)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),bie=pe(([i,e,t,n,r,s,o,a,l])=>{const u=ce(l).toVar(),d=Z(a).toVar(),A=ce(o).toVar(),g=ce(s).toVar(),v=ce(r).toVar(),x=ce(n).toVar(),T=ce(t).toVar(),S=ce(e).toVar(),w=he(i).toVar(),C=he(L_(he(S.add(v),T.add(g),x.add(A)))).toVar();C.subAssign(.5),C.mulAssign(d),C.addAssign(.5);const E=he(he(Z(S),Z(T),Z(x)).add(C)).toVar(),N=he(E.sub(w)).toVar();return Xt(u.equal(ce(2)),()=>Di(N.x).add(Di(N.y)).add(Di(N.z))),Xt(u.equal(ce(3)),()=>nr(Di(N.x),Di(N.y),Di(N.z))),Ko(N,N)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eA=ps([yie,bie]),Sie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=Ze(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=Ze(Xi(s.x,o),Xi(s.y,a)).toVar(),u=Z(1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:d})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:A})=>{const g=Z(eA(l,d,A,o,a,r,n)).toVar();u.assign(fo(u,g))})}),Xt(n.equal(ce(0)),()=>{u.assign(ws(u))}),u}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Tie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=Ze(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=Ze(Xi(s.x,o),Xi(s.y,a)).toVar(),u=Ze(1e6,1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:d})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:A})=>{const g=Z(eA(l,d,A,o,a,r,n)).toVar();Xt(g.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(g)}).ElseIf(g.lessThan(u.y),()=>{u.y.assign(g)})})}),Xt(n.equal(ce(0)),()=>{u.assign(ws(u))}),u}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),wie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=Ze(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=Ze(Xi(s.x,o),Xi(s.y,a)).toVar(),u=he(1e6,1e6,1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:d})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:A})=>{const g=Z(eA(l,d,A,o,a,r,n)).toVar();Xt(g.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(g)}).ElseIf(g.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(g)}).ElseIf(g.lessThan(u.z),()=>{u.z.assign(g)})})}),Xt(n.equal(ce(0)),()=>{u.assign(ws(u))}),u}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Mie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=he(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=ce().toVar(),u=he(Xi(s.x,o),Xi(s.y,a),Xi(s.z,l)).toVar(),d=Z(1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:A})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:g})=>{di({start:-1,end:ce(1),name:"z",condition:"<="},({z:v})=>{const x=Z(eA(u,A,g,v,o,a,l,r,n)).toVar();d.assign(fo(d,x))})})}),Xt(n.equal(ce(0)),()=>{d.assign(ws(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Eie=ps([Sie,Mie]),Cie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=he(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=ce().toVar(),u=he(Xi(s.x,o),Xi(s.y,a),Xi(s.z,l)).toVar(),d=Ze(1e6,1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:A})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:g})=>{di({start:-1,end:ce(1),name:"z",condition:"<="},({z:v})=>{const x=Z(eA(u,A,g,v,o,a,l,r,n)).toVar();Xt(x.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(x)}).ElseIf(x.lessThan(d.y),()=>{d.y.assign(x)})})})}),Xt(n.equal(ce(0)),()=>{d.assign(ws(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Rie=ps([Tie,Cie]),Nie=pe(([i,e,t])=>{const n=ce(t).toVar(),r=Z(e).toVar(),s=he(i).toVar(),o=ce().toVar(),a=ce().toVar(),l=ce().toVar(),u=he(Xi(s.x,o),Xi(s.y,a),Xi(s.z,l)).toVar(),d=he(1e6,1e6,1e6).toVar();return di({start:-1,end:ce(1),name:"x",condition:"<="},({x:A})=>{di({start:-1,end:ce(1),name:"y",condition:"<="},({y:g})=>{di({start:-1,end:ce(1),name:"z",condition:"<="},({z:v})=>{const x=Z(eA(u,A,g,v,o,a,l,r,n)).toVar();Xt(x.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(x)}).ElseIf(x.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(x)}).ElseIf(x.lessThan(d.z),()=>{d.z.assign(x)})})})}),Xt(n.equal(ce(0)),()=>{d.assign(ws(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),SS=ps([wie,Nie]),Pie=pe(([i,e,t,n,r,s,o,a,l,u,d])=>{const A=ce(i).toVar(),g=Ze(e).toVar(),v=Ze(t).toVar(),x=Ze(n).toVar(),T=Z(r).toVar(),S=Z(s).toVar(),w=Z(o).toVar(),C=Yo(a).toVar(),E=ce(l).toVar(),N=Z(u).toVar(),L=Z(d).toVar(),B=g.mul(v).add(x),I=Z(0).toVar();return Xt(A.equal(ce(0)),()=>{I.assign(Ep(B))}),Xt(A.equal(ce(1)),()=>{I.assign(L_(B))}),Xt(A.equal(ce(2)),()=>{I.assign(SS(B,T,ce(0)))}),Xt(A.equal(ce(3)),()=>{I.assign(I_(he(B,0),E,N,L))}),I.assign(I.mul(w.sub(S)).add(S)),Xt(C,()=>{I.assign(wa(I,S,w))}),I}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Die=pe(([i,e,t,n,r,s,o,a,l,u,d])=>{const A=ce(i).toVar(),g=he(e).toVar(),v=he(t).toVar(),x=he(n).toVar(),T=Z(r).toVar(),S=Z(s).toVar(),w=Z(o).toVar(),C=Yo(a).toVar(),E=ce(l).toVar(),N=Z(u).toVar(),L=Z(d).toVar(),B=g.mul(v).add(x),I=Z(0).toVar();return Xt(A.equal(ce(0)),()=>{I.assign(Ep(B))}),Xt(A.equal(ce(1)),()=>{I.assign(L_(B))}),Xt(A.equal(ce(2)),()=>{I.assign(SS(B,T,ce(0)))}),Xt(A.equal(ce(3)),()=>{I.assign(I_(B,E,N,L))}),I.assign(I.mul(w.sub(S)).add(S)),Xt(C,()=>{I.assign(wa(I,S,w))}),I}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Lie=pe(([i])=>{const e=i.y,t=i.z,n=he().toVar();return Xt(e.lessThan(1e-4),()=>{n.assign(he(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(hl(r)).mul(6).toVar();const s=ce(T3(r)),o=r.sub(Z(s)),a=t.mul(e.oneMinus()),l=t.mul(e.mul(o).oneMinus()),u=t.mul(e.mul(o.oneMinus()).oneMinus());Xt(s.equal(ce(0)),()=>{n.assign(he(t,u,a))}).ElseIf(s.equal(ce(1)),()=>{n.assign(he(l,t,a))}).ElseIf(s.equal(ce(2)),()=>{n.assign(he(a,t,u))}).ElseIf(s.equal(ce(3)),()=>{n.assign(he(a,l,t))}).ElseIf(s.equal(ce(4)),()=>{n.assign(he(u,a,t))}).Else(()=>{n.assign(he(t,a,l))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),Iie=pe(([i])=>{const e=he(i).toVar(),t=Z(e.x).toVar(),n=Z(e.y).toVar(),r=Z(e.z).toVar(),s=Z(fo(t,fo(n,r))).toVar(),o=Z(nr(t,nr(n,r))).toVar(),a=Z(o.sub(s)).toVar(),l=Z().toVar(),u=Z().toVar(),d=Z().toVar();return d.assign(o),Xt(o.greaterThan(0),()=>{u.assign(a.div(o))}).Else(()=>{u.assign(0)}),Xt(u.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{Xt(t.greaterThanEqual(o),()=>{l.assign(n.sub(r).div(a))}).ElseIf(n.greaterThanEqual(o),()=>{l.assign(br(2,r.sub(t).div(a)))}).Else(()=>{l.assign(br(4,t.sub(n).div(a)))}),l.mulAssign(1/6),Xt(l.lessThan(0),()=>{l.addAssign(1)})}),he(l,u,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),Bie=pe(([i])=>{const e=he(i).toVar(),t=o3(p3(e,he(.04045))).toVar(),n=he(e.div(12.92)).toVar(),r=he(zo(nr(e.add(he(.055)),he(0)).div(1.055),he(2.4))).toVar();return Wn(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),S7=(i,e)=>{i=Z(i),e=Z(e);const t=Ze(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ma(i.sub(t),i.add(t),e)},T7=(i,e,t,n)=>Wn(i,e,t[n].clamp()),Uie=(i,e,t=yi())=>T7(i,e,t,"x"),Fie=(i,e,t=yi())=>T7(i,e,t,"y"),Oie=(i,e,t,n,r=yi())=>{const s=r.x.clamp(),o=r.y.clamp(),a=Wn(i,e,s),l=Wn(t,n,s);return Wn(a,l,o)},w7=(i,e,t,n,r)=>Wn(i,e,S7(t,n[r])),kie=(i,e,t,n=yi())=>w7(i,e,t,n,"x"),Vie=(i,e,t,n=yi())=>w7(i,e,t,n,"y"),Gie=(i=1,e=0,t=yi())=>t.mul(i).add(e),qie=(i,e=1)=>(i=Z(i),i.abs().pow(e).mul(i.sign())),zie=(i,e=1,t=.5)=>Z(i).sub(t).mul(e).add(t),Hie=(i=yi(),e=1,t=0)=>bS(i.convert("vec2|vec3")).mul(e).add(t),Wie=(i=yi(),e=1,t=0)=>Ep(i.convert("vec2|vec3")).mul(e).add(t),$ie=(i=yi(),e=1,t=0)=>(i=i.convert("vec2|vec3"),Yt(Ep(i),bS(i.add(Ze(19,73)))).mul(e).add(t)),jie=(i,e=yi(),t=Ze(1,1),n=Ze(0,0),r=1,s=0,o=1,a=!1,l=1,u=2,d=.5)=>Pie(i,e.convert("vec2|vec3"),t,n,r,s,o,a,l,u,d),Xie=(i,e=yi(),t=Ze(1,1),n=Ze(0,0),r=1,s=0,o=1,a=!1,l=1,u=2,d=.5)=>Die(i,e.convert("vec2|vec3"),t,n,r,s,o,a,l,u,d),Qie=(i=yi(),e=1)=>Eie(i.convert("vec2|vec3"),e,ce(1)),Yie=(i=yi(),e=1)=>Rie(i.convert("vec2|vec3"),e,ce(1)),Kie=(i=yi(),e=1)=>SS(i.convert("vec2|vec3"),e,ce(1)),Zie=(i=yi())=>Aie(i.convert("vec2|vec3")),Jie=(i=yi(),e=3,t=2,n=.5,r=1)=>B1(i,ce(e),t,n).mul(r),ere=(i=yi(),e=3,t=2,n=.5,r=1)=>vie(i,ce(e),t,n).mul(r),tre=(i=yi(),e=3,t=2,n=.5,r=1)=>I_(i,ce(e),t,n).mul(r),nre=(i=yi(),e=3,t=2,n=.5,r=1)=>xie(i,ce(e),t,n).mul(r),ire=(i,e=Z(0))=>br(i,e),rre=(i,e=Z(0))=>jn(i,e),sre=(i,e=Z(1))=>An(i,e),ore=(i,e=Z(1))=>Io(i,e),are=(i,e=Z(1))=>vp(i,e),lre=(i,e=Z(1))=>zo(i,e),ure=(i=Z(0),e=Z(1))=>f_(i,e),cre=()=>Jd,hre=()=>kP,fre=(i,e=Z(1))=>jn(e,i),dre=(i,e,t,n)=>i.greaterThan(e).mix(t,n),Are=(i,e,t,n)=>i.greaterThanEqual(e).mix(t,n),pre=(i,e,t,n)=>i.equal(e).mix(t,n),mre=(i,e=null)=>{if(typeof e=="string"){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},n=e.replace(/^out/,"").toLowerCase();if(t[n]!==void 0)return i.element(t[n])}if(typeof e=="number")return i.element(e);if(typeof e=="string"&&e.length===1){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return i.element(t[e])}return i},gre=(i,e=Ze(.5,.5),t=Ze(1,1),n=Z(0),r=Ze(0,0))=>{let s=i;if(e&&(s=s.sub(e)),t&&(s=s.mul(t)),n){const o=n.mul(Math.PI/180),a=o.cos(),l=o.sin();s=Ze(s.x.mul(a).sub(s.y.mul(l)),s.x.mul(l).add(s.y.mul(a)))}return e&&(s=s.add(e)),r&&(s=s.add(r)),s},_re=(i,e)=>{i=Ze(i),e=Z(e);const t=e.mul(Math.PI/180);return Sp(i,t)},vre=(i,e,t)=>{i=he(i),e=Z(e),t=he(t);const n=e.mul(Math.PI/180),r=t.normalize(),s=n.cos(),o=n.sin(),a=Z(1).sub(s);return i.mul(s).add(r.cross(i).mul(o)).add(r.mul(r.dot(i)).mul(a))},xre=(i,e)=>(i=he(i),e=Z(e),j3(i,e)),yre=pe(([i,e,t])=>{const n=Xs(i).toVar(),r=jn(Z(.5).mul(e.sub(t)),dl).div(n).toVar(),s=jn(Z(-.5).mul(e.sub(t)),dl).div(n).toVar(),o=he().toVar();o.x=n.x.greaterThan(Z(0)).select(r.x,s.x),o.y=n.y.greaterThan(Z(0)).select(r.y,s.y),o.z=n.z.greaterThan(Z(0)).select(r.z,s.z);const a=fo(o.x,o.y,o.z).toVar();return dl.add(n.mul(a)).toVar().sub(t)}),M7=pe(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(An(t,t).sub(An(n,n)))),s});var U=Object.freeze({__proto__:null,BRDF_GGX:rS,BRDF_Lambert:Th,BasicPointShadowFilter:A7,BasicShadowFilter:s7,Break:eP,Const:v6,Continue:aK,DFGLUT:Y0,D_GGX:_P,Discard:B6,EPSILON:m3,F_Schlick:Od,Fn:pe,HALF_PI:LQ,INFINITY:NQ,If:Xt,Loop:di,NodeAccess:us,NodeShaderStage:YA,NodeType:JX,NodeUpdateType:yn,OnBeforeMaterialUpdate:Ree,OnBeforeObjectUpdate:Cee,OnMaterialUpdate:Eee,OnObjectUpdate:Mee,PCFShadowFilter:o7,PCFSoftShadowFilter:a7,PI:E1,PI2:PQ,PointShadowFilter:p7,Return:QQ,Schlick_to_F0:dy,ScriptableNodeResources:Pg,ShaderNode:Bf,Stack:o_,Switch:yQ,TBNViewMatrix:sh,TWO_PI:DQ,VSMShadowFilter:l7,V_GGX_SmithCorrelated:gP,Var:_6,VarIntent:x6,abs:Di,acesFilmicToneMapping:YP,acos:v3,add:br,addMethodChaining:Ie,addNodeElement:JQ,agxToneMapping:KP,all:z5,alphaT:T1,and:C5,anisotropy:Vu,anisotropyB:hh,anisotropyT:c0,any:H5,append:wQ,array:y5,arrayBuffer:SQ,asin:X5,assign:b5,atan:f_,atan2:f6,atomicAdd:Ute,atomicAnd:Vte,atomicFunc:Ml,atomicLoad:Ite,atomicMax:Ote,atomicMin:kte,atomicOr:Gte,atomicStore:Bte,atomicSub:Fte,atomicXor:qte,attenuationColor:h3,attenuationDistance:c3,attribute:lu,attributeArray:Pee,backgroundBlurriness:qP,backgroundIntensity:_y,backgroundRotation:zP,batch:KN,bentNormalView:dN,billboarding:uee,bitAnd:D5,bitNot:L5,bitOr:I5,bitXor:B5,bitangentGeometry:kY,bitangentLocal:VY,bitangentView:hN,bitangentWorld:GY,bitcast:FP,blendBurn:oP,blendColor:TK,blendDodge:aP,blendOverlay:uP,blendScreen:lP,blur:wP,bool:Yo,buffer:xp,bufferAttribute:B3,builtin:pu,builtinAOContext:m6,builtinShadowContext:p6,bumpMap:j3,burn:MK,bvec2:A5,bvec3:o3,bvec4:p5,bypass:P6,cache:N6,call:S5,cameraFar:Hu,cameraIndex:uc,cameraNear:zu,cameraNormalMatrix:AY,cameraPosition:z6,cameraProjectionMatrix:Jl,cameraProjectionMatrixInverse:fY,cameraViewMatrix:ia,cameraViewport:pY,cameraWorldMatrix:dY,cbrt:a6,cdl:Qee,ceil:h_,checker:kne,cineonToneMapping:QP,clamp:wa,clearcoat:y1,clearcoatNormalView:rh,clearcoatRoughness:Q0,code:N_,color:d5,colorSpaceToWorking:p_,colorToDirection:zY,compute:R6,computeKernel:U3,computeSkinning:sK,context:Au,convert:g5,convertColorSpace:VQ,convertToTexture:yee,cos:da,countLeadingZeros:kJ,countOneBits:VJ,countTrailingZeros:OJ,cross:ou,cubeTexture:qs,cubeTextureBase:$3,dFdx:b3,dFdy:S3,dashSize:Sg,debug:F6,decrement:G5,decrementBefore:k5,defaultBuildStages:Zx,defaultShaderStages:a5,defined:$0,degrees:$5,deltaTime:tee,densityFog:gte,densityFogFactor:AS,depth:eS,depthPass:ete,determinant:J5,difference:r6,diffuseColor:hi,diffuseContribution:$c,directPointLight:g7,directionToColor:AN,directionToFaceDirection:Kd,dispersion:f3,disposeShadowMaterial:c7,distance:i6,div:Io,dodge:EK,dot:Ko,drawIndex:XN,dynamicBufferAttribute:WQ,element:m5,emissive:ny,equal:A3,equals:t6,equirectUV:tS,exp:g3,exp2:Ud,expression:au,faceDirection:z3,faceForward:N3,faceforward:IQ,float:Z,floatBitsToInt:BJ,floatBitsToUint:OP,floor:hl,fog:Z0,fract:Ta,frameGroup:x5,frameId:kP,frontFacing:j6,fwidth:w3,gain:qJ,gapSize:iy,getConstNodeType:f5,getCurrentStack:i3,getDirection:SP,getDistanceAttenuation:yS,getGeometryRoughness:mP,getNormalFromDepth:See,getParallaxCorrectNormal:yre,getRoughness:iS,getScreenPosition:bee,getShIrradianceAt:M7,getShadowMaterial:u7,getShadowRenderObjectFunction:h7,getTextureIndex:BP,getViewPosition:Rf,ggxConvolution:MP,globalId:Ste,glsl:ute,glslFn:cte,grayscale:Wee,greaterThan:p3,greaterThanEqual:E5,hash:GJ,highpModelNormalViewMatrix:oy,highpModelViewMatrix:sy,hue:Xee,increment:V5,incrementBefore:O5,inspector:k6,instance:nK,instanceIndex:Al,instancedArray:Dee,instancedBufferAttribute:C1,instancedDynamicBufferAttribute:ry,instancedMesh:YN,int:ce,intBitsToFloat:UJ,interleavedGradientNoise:hS,inverse:e6,inverseSqrt:_3,inversesqrt:BQ,invocationLocalIndex:tK,invocationSubgroupIndex:eK,ior:h0,iridescence:l_,iridescenceIOR:b1,iridescenceThickness:S1,isolate:jf,ivec2:Rr,ivec3:s3,ivec4:a3,js:ate,label:g6,length:fl,lengthSq:C3,lessThan:w5,lessThanEqual:M5,lightPosition:mS,lightProjectionUV:i7,lightShadowMatrix:D_,lightTargetDirection:_S,lightTargetPosition:r7,lightViewPosition:gS,lightingContext:nP,lights:mne,linearDepth:N1,linearToneMapping:jP,localId:Tte,log:c_,log2:cl,logarithmicDepthToViewZ:mK,luminance:fS,mat2:a_,mat3:ds,mat4:ec,matcapUV:CP,materialAO:WN,materialAlphaTest:pN,materialAnisotropy:NN,materialAnisotropyVector:Cf,materialAttenuationColor:ON,materialAttenuationDistance:FN,materialClearcoat:TN,materialClearcoatNormal:MN,materialClearcoatRoughness:wN,materialColor:mN,materialDispersion:HN,materialEmissive:_N,materialEnvIntensity:Mg,materialEnvRotation:W3,materialIOR:UN,materialIridescence:PN,materialIridescenceIOR:DN,materialIridescenceThickness:LN,materialLightMap:Q3,materialLineDashOffset:qN,materialLineDashSize:VN,materialLineGapSize:GN,materialLineScale:kN,materialLineWidth:XY,materialMetalness:bN,materialNormal:SN,materialOpacity:X3,materialPointSize:zN,materialReference:ql,materialReflectivity:Eg,materialRefractionRatio:K6,materialRotation:EN,materialRoughness:yN,materialSheen:CN,materialSheenRoughness:RN,materialShininess:gN,materialSpecular:vN,materialSpecularColor:xN,materialSpecularIntensity:fy,materialSpecularStrength:f0,materialThickness:BN,materialTransmission:IN,max:nr,maxMipLevel:F3,mediumpModelViewMatrix:$6,metalness:$l,min:fo,mix:Wn,mixElement:u6,mod:vp,modInt:q5,modelDirection:yY,modelNormalMatrix:W6,modelPosition:bY,modelRadius:wY,modelScale:SY,modelViewMatrix:cc,modelViewPosition:TY,modelViewProjection:$N,modelWorldMatrix:Ho,modelWorldMatrixInverse:MY,morphReference:tP,mrt:UP,mul:An,mx_aastep:S7,mx_add:ire,mx_atan2:ure,mx_cell_noise_float:Zie,mx_contrast:zie,mx_divide:ore,mx_fractal_noise_float:Jie,mx_fractal_noise_vec2:ere,mx_fractal_noise_vec3:tre,mx_fractal_noise_vec4:nre,mx_frame:hre,mx_heighttonormal:xre,mx_hsvtorgb:Lie,mx_ifequal:pre,mx_ifgreater:dre,mx_ifgreatereq:Are,mx_invert:fre,mx_modulo:are,mx_multiply:sre,mx_noise_float:Hie,mx_noise_vec3:Wie,mx_noise_vec4:$ie,mx_place2d:gre,mx_power:lre,mx_ramp4:Oie,mx_ramplr:Uie,mx_ramptb:Fie,mx_rgbtohsv:Iie,mx_rotate2d:_re,mx_rotate3d:vre,mx_safepower:qie,mx_separate:mre,mx_splitlr:kie,mx_splittb:Vie,mx_srgb_texture_to_lin_rec709:Bie,mx_subtract:rre,mx_timer:cre,mx_transform_uv:Gie,mx_unifiednoise2d:jie,mx_unifiednoise3d:Xie,mx_worley_noise_float:Qie,mx_worley_noise_vec2:Yie,mx_worley_noise_vec3:Kie,negate:y3,neutralToneMapping:ZP,nodeArray:ch,nodeImmutable:At,nodeObject:gt,nodeObjectIntent:KA,nodeObjects:s_,nodeProxy:pn,nodeProxyIntent:nt,normalFlat:X6,normalGeometry:g_,normalLocal:Ao,normalMap:hy,normalView:Kn,normalViewGeometry:Fd,normalWorld:hc,normalWorldGeometry:Q6,normalize:Xs,not:N5,notEqual:T5,numWorkgroups:yte,objectDirection:mY,objectGroup:d3,objectPosition:H6,objectRadius:xY,objectScale:_Y,objectViewPosition:vY,objectWorldMatrix:gY,oneMinus:Q5,or:R5,orthographicDepthToViewZ:pK,oscSawtooth:see,oscSine:nee,oscSquare:iee,oscTriangle:ree,output:Wf,outputStruct:LJ,overlay:RK,overloadingFn:ps,packHalf2x16:jJ,packSnorm2x16:WJ,packUnorm2x16:$J,parabola:gy,parallaxDirection:fN,parallaxUV:qY,parameter:EJ,pass:Zee,passTexture:Jee,pcurve:zJ,perspectiveDepthToViewZ:Z3,pmremTexture:oS,pointShadow:m7,pointUV:Iee,pointWidth:MQ,positionGeometry:yp,positionLocal:Ki,positionPrevious:R1,positionView:Ar,positionViewDirection:Ei,positionWorld:dl,positionWorldDirection:q3,posterize:Kee,pow:zo,pow2:M3,pow3:s6,pow4:E3,premultiplyAlpha:cP,property:Yl,quadBroadcast:dne,quadSwapDiagonal:ane,quadSwapX:sne,quadSwapY:one,radians:W5,rand:l6,range:vte,rangeFog:mte,rangeFogFactor:dS,reciprocal:K5,reference:gi,referenceBuffer:ay,reflect:n6,reflectVector:eN,reflectView:Z6,reflector:mee,refract:R3,refractVector:tN,refractView:J6,reinhardToneMapping:XP,remap:L6,remapClamp:I6,renderGroup:Wt,renderOutput:U6,rendererReference:M6,replaceDefaultUV:oee,rotate:Sp,rotateUV:aee,roughness:el,round:Y5,rtt:GP,sRGBTransferEOTF:b6,sRGBTransferOETF:S6,sample:wee,sampler:sY,samplerComparison:oY,saturate:A_,saturation:$ee,screen:CK,screenCoordinate:Nh,screenDPR:G6,screenSize:Sh,screenUV:Zl,scriptable:pte,scriptableValue:Ng,select:cs,setCurrentStack:j0,setName:P3,shaderStages:Jx,shadow:d7,shadowPositionWorld:xS,shapeCircle:Vne,sharedUniformGroup:u_,sheen:To,sheenRoughness:qu,shiftLeft:U5,shiftRight:F5,shininess:w1,sign:x3,sin:Vs,sinc:HJ,skinning:JN,smoothstep:Ma,smoothstepElement:c6,specularColor:sc,specularColorBlended:ih,specularF90:Hf,spherizeUV:lee,split:TQ,spritesheetUV:fee,sqrt:ws,stack:Cg,step:d_,stepElement:h6,storage:eu,storageBarrier:Cte,storageObject:ZY,storageTexture:HP,string:bQ,struct:DJ,sub:jn,subBuild:$f,subgroupAdd:Wte,subgroupAll:nne,subgroupAnd:Kte,subgroupAny:ine,subgroupBallot:Hte,subgroupBroadcast:lne,subgroupBroadcastFirst:rne,subgroupElect:zte,subgroupExclusiveAdd:jte,subgroupExclusiveMul:Yte,subgroupInclusiveAdd:$te,subgroupInclusiveMul:Qte,subgroupIndex:JY,subgroupMax:tne,subgroupMin:ene,subgroupMul:Xte,subgroupOr:Zte,subgroupShuffle:une,subgroupShuffleDown:fne,subgroupShuffleUp:hne,subgroupShuffleXor:cne,subgroupSize:wte,subgroupXor:Jte,tan:j5,tangentGeometry:v_,tangentLocal:bp,tangentView:x_,tangentWorld:cN,texture:ti,texture3D:R_,texture3DLevel:Vee,texture3DLoad:kee,textureBarrier:Rte,textureBicubic:oZ,textureBicubicLevel:sS,textureCubeUV:TP,textureLevel:rY,textureLoad:sr,textureSize:Kl,textureStore:Uee,thickness:u3,time:Jd,toneMapping:E6,toneMappingExposure:C6,toonOutlinePass:nte,transformDirection:o6,transformNormal:Y6,transformNormalToView:H3,transformedClearcoatNormalView:NY,transformedNormalView:CY,transformedNormalWorld:RY,transmission:M1,transpose:Z5,triNoise3D:ZJ,triplanarTexture:dee,triplanarTextures:VP,trunc:T3,uint:We,uintBitsToFloat:FJ,uniform:$t,uniformArray:Ts,uniformCubeTexture:DY,uniformFlow:A6,uniformGroup:v5,uniformTexture:iY,unpackHalf2x16:YJ,unpackNormal:cy,unpackSnorm2x16:XJ,unpackUnorm2x16:QJ,unpremultiplyAlpha:wK,userData:qee,uv:yi,uvec2:r3,uvec3:Rh,uvec4:l3,varying:wl,varyingProperty:X0,vec2:Ze,vec3:he,vec4:Yt,vectorComponents:Eh,velocity:Hee,vertexColor:sP,vertexIndex:jN,vertexStage:y6,vibrance:jee,viewZToLogarithmicDepth:J3,viewZToOrthographicDepth:Xf,viewZToPerspectiveDepth:iP,viewport:V3,viewportCoordinate:q6,viewportDepthTexture:K3,viewportLinearDepth:gK,viewportMipTexture:Y3,viewportResolution:hY,viewportSafeUV:cee,viewportSharedTexture:BK,viewportSize:G3,viewportTexture:dK,viewportUV:cY,vogelDiskSample:ma,wgsl:lte,wgslFn:hte,workgroupArray:Dte,workgroupBarrier:Ete,workgroupId:bte,workingToColorSpace:T6,xor:P5});const la=new aS;class bre extends fc{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let o=!1;if(s===null)r._clearColor.getRGB(la),la.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(la),la.a=1,o=!0;else if(s.isNode===!0){const u=this.get(e),d=s;la.copy(r._clearColor);let A=u.backgroundMesh;if(A===void 0){let E=function(){s.removeEventListener("dispose",E),A.material.dispose(),A.geometry.dispose()};var l=E;const v=Yt(d).mul(_y).context({getUV:()=>zP.mul(Q6),getTextureLevel:()=>qP}),x=Jl.element(3).element(3).equal(1),T=Io(1,Jl.element(1).element(1)).mul(3),S=x.select(Ki.mul(T),Ki);let w=Jl.mul(cc.mul(Yt(S,0)));w=w.setZ(w.w);const C=new lr;C.name="Background.material",C.side=Ai,C.depthTest=!1,C.depthWrite=!1,C.allowOverride=!1,C.fog=!1,C.lights=!1,C.vertexNode=w,C.colorNode=v,u.backgroundMeshNode=v,u.backgroundMesh=A=new si(new Tl(1,32,32),C),A.frustumCulled=!1,A.name="Background.mesh",s.addEventListener("dispose",E)}const g=d.getCacheKey();u.backgroundCacheKey!==g&&(u.backgroundMeshNode.node=Yt(d).mul(_y),u.backgroundMeshNode.needsUpdate=!0,A.material.needsUpdate=!0,u.backgroundCacheKey=g),t.unshift(A,A.geometry,A.material,0,0,null,null)}else He("Renderer: Unsupported background configuration.",s);const a=r.xr.getEnvironmentBlendMode();if(a==="additive"?la.set(0,0,0,1):a==="alpha-blend"&&la.set(0,0,0,0),r.autoClear===!0||o===!0){const u=n.clearColorValue;u.r=la.r,u.g=la.g,u.b=la.b,u.a=la.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Sre=0;class vy{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Sre++}}class Tre{constructor(e,t,n,r,s,o,a,l,u,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=d,this.nodeAttributes=r,this.bindings=s,this.updateNodes=o,this.updateBeforeNodes=a,this.updateAfterNodes=l,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new vy(t.name,[],t.index,t.bindingsReference);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class I4{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class wre{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}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 E7{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}}class Mre extends E7{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}}class Ere{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Cre=0;class Cv{constructor(e=null){this.id=Cre++,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 Rre{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class dc{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Nre extends dc{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Pre extends dc{constructor(e,t=new qe){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Dre extends dc{constructor(e,t=new te){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Lre extends dc{constructor(e,t=new dn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Ire extends dc{constructor(e,t=new Gt){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Bre extends dc{constructor(e,t=new Y1){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class Ure extends dc{constructor(e,t=new Cn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class Fre extends dc{constructor(e,t=new gn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class Ore extends Nre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kre extends Pre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vre extends Dre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gre extends Lre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qre extends Ire{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zre extends Bre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hre extends Ure{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wre extends Fre{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let $re=0;const jre=new WeakMap,B4=new WeakMap,Xre=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Wm=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class C7{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,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=Cg(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Cv,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:$re++})}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===js&&e.alphaToCoverage===!1}getBindGroupsCache(){let e=B4.get(this.renderer);return e===void 0&&(e=new Ea,B4.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new hu(e,t,n)}createCubeRenderTarget(e,t){return new hP(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const a of t)r.push(a),s=s&&a.groupNode.shared!==!0;let o;return s?(o=n.get(r),o===void 0&&(o=new vy(e,r,this.bindingsIndexes[e].group,r),n.set(r,o))):o=new vy(e,r,this.bindingsIndexes[e].group,r),o}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of Jx)for(const s in n[r]){const o=n[r][s];(t[s]||(t[s]=[])).push(...o)}e=[];for(const r in t){const s=t[r],o=this._getBindGroup(r,s);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.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")}( ${Wm(t.r)}, ${Wm(t.g)}, ${Wm(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=o=>this.generateConst(r,o);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`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 n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new I4(e,t);return this.registerDeclaration(r),n.push(r),r}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;if(e.isDataTexture){if(t===jr)return"int";if(t===vi)return"uint"}return"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 n=n5(e);const r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),r+n}getTypeFromArray(e){return Xre.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let o;return!(e instanceof uR)&&s!==!0&&(o=this.getTypeFromArray(n)),this.getTypeFromLength(r,o)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[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("NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=Cg(this.stack);const e=i3();return this.stacks.push(e),j0(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,j0(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let s=r[t];const o=r.any?r.any.subBuilds:null,a=this.getClosestSubBuild(o);return a&&(s.subBuildsCache===void 0&&(s.subBuildsCache={}),s=s.subBuildsCache[a]||(s.subBuildsCache[a]={}),s.subBuilds=o),s}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e,"vertex");let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new I4("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){const s=this.getDataFromNode(e,r,this.globalCache);let o=s.structType;if(o===void 0){const a=this.structs.index++;n===null&&(n="StructType"+a),o=new Rre(n,t),this.structs[r].push(o),this.types[r][n]=e,s.structType=o}return o}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let o=s.uniform;if(o===void 0){const a=this.uniforms.index++;o=new wre(r||"nodeUniform"+a,t,e),this.uniforms[n].push(o),this.registerDeclaration(o),s.uniform=o}return o}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,s=!1){const o=this.getDataFromNode(e,r),a=this.getSubBuildProperty("variable",o.subBuilds);let l=o[a];if(l===void 0){const u=s?"_const":"_var",d=this.vars[r]||(this.vars[r]=[]),A=this.vars[u]||(this.vars[u]=0);t===null&&(t=(s?"nodeConst":"nodeVar")+A,this.vars[u]++),a!=="variable"&&(t=this.getSubBuildProperty(t,o.subBuilds));const g=e.getArrayCount(this);l=new E7(t,n,s,g),s||d.push(l),this.registerDeclaration(l),o[a]=l}return l}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,n=e.getNodeType(this),r=null,s=null){const o=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",o.subBuilds);let l=o[a];if(l===void 0){const u=this.varyings,d=u.length;t===null&&(t="nodeVarying"+d),a!=="varying"&&(t=this.getSubBuildProperty(t,o.subBuilds)),l=new Mre(t,n,r,s),u.push(l),this.registerDeclaration(l),o[a]=l}return l}registerDeclaration(e){const t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e);let s=1,o=r;for(;n[o]!==void 0;)o=r+"_"+s++;s>1&&(e.name=o,Ue(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${o}'.`)),n[o]=e}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const o=this.codes[n]||(this.codes[n]=[]),a=o.length;s=new Ere("nodeCode"+a,t),o.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,o=t;for(;o;){if(r.get(o)===!0){s=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(s)for(const a of n)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),o=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),o.set(n,!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),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new JP,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[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)n[o.name]=new LP(o.type,o.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowBuildStage(e,t,n=null){const r=this.getBuildStage();this.setBuildStage(t);const s=e.build(this,n);return this.setBuildStage(r),s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.declarations,o=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new Cv,this.stack=Cg();for(const d of Zx)this.setBuildStage(d),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=s,this.cache=o,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){Ue("Abstract function.")}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.tab,o=this.cache,a=this.shaderStage,l=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=u;let d=null;if(this.buildStage==="generate"){const A=this.flowChildNode(t,n);r!==null&&(A.code+=`${this.tab+r} = ${A.result}; +`),this.flowCode[e]=this.flowCode[e]+A.code,d=A}else d=t.build(this);return this.setShaderStage(a),this.cache=o,this.tab=s,this.context=l,d}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){Ue("Abstract function.")}getVaryings(){Ue("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){Ue("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` +`;return n}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(){Ue("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 n=this.subBuildLayers;for(let r=t.length-1;r>=0;r--){const s=t[r];if(n.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let r;return n?r=e?n+"_"+e:n:r=e,r}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(He(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new lr),r.build(this)}else this.addFlow("compute",e);for(const r of Zx){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of Jx){this.setShaderStage(s);const o=this.flowNodes[s];for(const a of o)r==="generate"?this.flowNode(a):a.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=jre.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const n=this.getSharedDataFromNode(e);let r=n.cache;if(r===void 0){if(t==="float"||t==="int"||t==="uint")r=new Ore(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")r=new kre(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")r=new Vre(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")r=new Gre(e);else if(t==="color")r=new qre(e);else if(t==="mat2")r=new zre(e);else if(t==="mat3")r=new Hre(e);else if(t==="mat4")r=new Wre(e);else throw new Error(`Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&s===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),n)):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${wh} - Node System +`}}class U4{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 n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===yn.FRAME){const r=this._getMaps(this.updateBeforeMap,n);if(r.frameId!==this.frameId){const s=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=s)}}else if(t===yn.RENDER){const r=this._getMaps(this.updateBeforeMap,n);if(r.renderId!==this.renderId){const s=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=s)}}else t===yn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===yn.FRAME){const r=this._getMaps(this.updateAfterMap,n);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===yn.RENDER){const r=this._getMaps(this.updateAfterMap,n);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===yn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===yn.FRAME){const r=this._getMaps(this.updateMap,n);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===yn.RENDER){const r=this._getMaps(this.updateMap,n);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.renderId=this.renderId)}else t===yn.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 TS{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}TS.isNodeFunctionInput=!0;class Qre extends Ph{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:_S(this.light),lightColor:e}}}const Rv=new gn,$m=new gn;let IA=null;class Yre extends Ph{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=$t(new te).setGroup(Wt),this.halfWidth=$t(new te).setGroup(Wt),this.updateType=yn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;$m.identity(),Rv.copy(t.matrixWorld),Rv.premultiply(n),$m.extractRotation(Rv),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4($m),this.halfHeight.value.applyMatrix4($m)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=ti(IA.LTC_FLOAT_1),n=ti(IA.LTC_FLOAT_2)):(t=ti(IA.LTC_HALF_1),n=ti(IA.LTC_HALF_2));const{colorNode:r,light:s}=this,o=gS(s);return{lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){IA=e}}class wS extends Ph{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=$t(0).setGroup(Wt),this.penumbraCosNode=$t(0).setGroup(Wt),this.cutoffDistanceNode=$t(0).setGroup(Wt),this.decayExponentNode=$t(0).setGroup(Wt),this.colorNode=$t(this.color).setGroup(Wt)}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:n,penumbraCosNode:r}=this;return Ma(n,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=i7(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:s}=this,o=this.getLightVector(e),a=o.normalize(),l=a.dot(_S(s)),u=this.getSpotAttenuation(e,l),d=o.length(),A=yS({lightDistance:d,cutoffDistance:n,decayExponent:r});let g=t.mul(u).mul(A),v,x;return s.colorNode?(x=this.getLightCoord(e),v=s.colorNode(x)):s.map&&(x=this.getLightCoord(e),v=ti(s.map,x.xy).onRenderUpdate(()=>s.map)),v&&(g=x.mul(2).sub(1).abs().lessThan(1).all().select(g.mul(v),g)),{lightColor:g,lightDirection:a}}}class Kre extends wS{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let r=null;if(n&&n.isTexture===!0){const s=t.acos().mul(1/Math.PI);r=ti(n,Ze(s,0),0).r}else r=super.getSpotAttenuation(t);return r}}const Zre=pe(([i,e])=>{const t=i.abs().sub(e);return fl(nr(t,0)).add(fo(nr(t.x,t.y),0))});class Jre extends wS{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 n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Z(0),n=this.penumbraCosNode,r=D_(this.light).mul(e.context.positionWorld||dl);return Xt(r.w.greaterThan(0),()=>{const s=r.xyz.div(r.w),o=Zre(s.xy.sub(Ze(.5)),Ze(.5)),a=Io(-1,jn(1,v3(n)).sub(1));t.assign(A_(o.mul(-2).mul(a)))}),t}}class ese extends Ph{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class tse extends Ph{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=mS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=$t(new Gt).setGroup(Wt)}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:n,lightDirectionNode:r}=this,o=hc.dot(r).mul(.5).add(.5),a=Wn(n,t,o);e.context.irradiance.addAssign(a)}}class nse extends Ph{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new te);this.lightProbe=Ts(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=M7(hc,this.lightProbe);e.context.irradiance.addAssign(t)}}class R7{parseFunction(){Ue("Abstract function.")}}class MS{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){Ue("Abstract function.")}}MS.isNodeFunction=!0;const ise=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,rse=/[a-z_0-9]+/ig,F4="#pragma main",sse=i=>{i=i.trim();const e=i.indexOf(F4),t=e!==-1?i.slice(e+F4.length):i,n=t.match(ise);if(n!==null&&n.length===5){const r=n[4],s=[];let o=null;for(;(o=rse.exec(r))!==null;)s.push(o);const a=[];let l=0;for(;l{const u=this.backend.createNodeBuilder(e.object,this.renderer);return u.scene=e.scene,u.material=l,u.camera=e.camera,u.context.material=l,u.lightsNode=e.lightsNode,u.environmentNode=this.getEnvironmentNode(e.scene),u.fogNode=this.getFogNode(e.scene),u.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&u.enableMultiview(),u};let a=o(e.material);try{a.build()}catch(l){a=o(new lr),a.build(),He("TSL: "+l)}n=this._createNodeBuilderState(a),r.set(s,n)}n.usedTimes++,t.nodeBuilderState=n}return n}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new Tre(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){ja[0]=e,ja[1]=t;const n=this.renderer.info.calls,r=this.callHashCache.get(ja)||{};if(r.callId!==n){const s=this.getEnvironmentNode(e),o=this.getFogNode(e);t&&Lu.push(t.getCacheKey(!0)),s&&Lu.push(s.getCacheKey()),o&&Lu.push(o.getCacheKey()),Lu.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Lu.push(this.renderer.shadowMap.enabled?1:0),Lu.push(this.renderer.shadowMap.type),r.callId=n,r.cacheKey=Yd(Lu),this.callHashCache.set(ja,r),Lu.length=0}return ja.length=0,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),n=e.background;if(n){const r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Zf||n.mapping===Jf||n.mapping===dh){if(e.backgroundBlurriness>0||n.mapping===dh)return oS(n);{let o;return n.isCubeTexture===!0?o=qs(n):o=ti(n),dP(o)}}else{if(n.isTexture===!0)return ti(n,Zl.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&He("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let o=s.get(t);return(o===void 0||r)&&(o=n(),s.set(t,o)),o}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=gi("color","color",n).setGroup(Wt),o=gi("density","float",n).setGroup(Wt);return Z0(s,AS(o))}else if(n.isFog){const s=gi("color","color",n).setGroup(Wt),o=gi("near","float",n).setGroup(Wt),a=gi("far","float",n).setGroup(Wt);return Z0(s,dS(o,a))}else He("Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return qs(n);if(n.isTexture===!0)return ti(n);He("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const o=this.nodeFrame;return o.renderer=e,o.scene=t,o.object=n,o.camera=r,o.material=s,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}hasOutputChange(e){return O4.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?R_(e,he(Zl,pu("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):ti(e,Zl).renderOutput(t.toneMapping,t.currentColorSpace);return O4.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new U4,this.nodeBuilderCache=new Map,this.cacheLib={}}}const Nv=new Ka;class U1{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Cn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},a=new XRWebGLLayer(e,r,o);this._glBaseLayer=a,e.updateRenderState({baseLayer:a}),t.setPixelRatio(1),t._setXRLayerSize(a.framebufferWidth,a.framebufferHeight),this._xrRenderTarget=new ZA(a.framebufferWidth,a.framebufferHeight,{format:pr,type:Gi,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:a.ignoreDepthValues===!1,resolveStencilBuffer:a.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),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 n=e.near,r=e.far,s=this._cameraXR,o=this._cameraL,a=this._cameraR;s.near=a.near=o.near=n,s.far=a.far=o.far=r,s.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==s.near||this._currentDepthFar!==s.far)&&(t.updateRenderState({depthNear:s.near,depthFar:s.far}),this._currentDepthNear=s.near,this._currentDepthFar=s.far),s.layers.mask=e.layers.mask|6,o.layers.mask=s.layers.mask&3,a.layers.mask=s.layers.mask&5;const l=e.parent,u=s.cameras;G4(s,l);for(let d=0;d=0&&(t[s]=null,e[s].disconnect(r))}for(let n=0;n=t.length){t.push(r),s=a;break}else if(t[a]===null){t[a]=r,s=a;break}if(s===-1)break}const o=e[s];o&&o.connect(r)}}function vse(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 xse(i,e){if(e===void 0)return;const t=this._cameraXR,n=this._renderer,r=n.backend,s=this._glBaseLayer,o=this.getReferenceSpace(),a=e.getViewerPose(o);if(this._xrFrame=e,a!==null){const l=a.views;this._glBaseLayer!==null&&r.setXRTarget(s.framebuffer);let u=!1;l.length!==t.cameras.length&&(t.cameras.length=0,u=!0);for(let d=0;d{await this.compileAsync(v,x);const S=this._renderLists.get(v,x),w=this._renderContexts.get(v,x,this._renderTarget,this._mrt),C=v.overrideMaterial||T.material,E=this._objects.get(T,C,v,x,S.lightsNode,w,w.clippingContext),{fragmentShader:N,vertexShader:L}=E.getNodeBuilderState();return{fragmentShader:N,vertexShader:L}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new lse(this,n),this._animation=new nJ(this,this._nodes,this.info),this._attributes=new uJ(n),this._background=new bre(this,this._nodes),this._geometries=new cJ(this._attributes,this.info),this._textures=new MJ(this,n,this.info),this._pipelines=new pJ(n,this._nodes),this._bindings=new mJ(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new oJ(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new vJ(this.lighting),this._bundles=new cse,this._renderContexts=new TJ,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,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,o=this._currentRenderContext,a=this._currentRenderObjectFunction,l=this._compilationPromises,u=e.isScene===!0?e:q4;n===null&&(n=e);const d=this._renderTarget,A=this._renderContexts.get(n,t,d,this._mrt),g=this._activeMipmapLevel,v=[];this._currentRenderContext=A,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=v,r.renderId++,r.update(),A.depth=this.depth,A.stencil=this.stencil,A.clippingContext||(A.clippingContext=new U1),A.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,d);const x=this._renderLists.get(e,t);if(x.begin(),this._projectObject(e,t,0,x,A.clippingContext),n!==e&&n.traverseVisible(function(E){E.isLight&&E.layers.test(t.layers)&&x.pushLight(E)}),x.finish(),d!==null){this._textures.updateRenderTarget(d,g);const E=this._textures.get(d);A.textures=E.textures,A.depthTexture=E.depthTexture}else A.textures=null,A.depthTexture=null;this._background.update(u,x,A);const T=x.opaque,S=x.transparent,w=x.transparentDoublePass,C=x.lightsNode;this.opaque===!0&&T.length>0&&this._renderObjects(T,t,u,C),this.transparent===!0&&S.length>0&&this._renderTransparents(S,w,t,u,C),r.renderId=s,this._currentRenderContext=o,this._currentRenderObjectFunction=a,this._compilationPromises=l,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(v)}async renderAsync(e,t){Ci('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){He("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=sy,t.modelNormalViewMatrix=oy):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===sy&&e.modelNormalViewMatrix===oy}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Ci('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}`),He(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:o}=e,a=this._currentRenderContext,l=this._bundles.get(r,s),u=this.backend.get(l);u.renderContexts===void 0&&(u.renderContexts=new Set);const d=r.version!==u.version,A=u.renderContexts.has(a)===!1||d;if(u.renderContexts.add(a),A){this.backend.beginBundle(a),(u.renderObjects===void 0||d)&&(u.renderObjects=[]),this._currentRenderBundle=l;const{transparentDoublePass:g,transparent:v,opaque:x}=o;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this.transparent===!0&&v.length>0&&this._renderTransparents(v,g,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(a,l),u.version=r.version}else{const{renderObjects:g}=u;for(let v=0,x=g.length;v>=g,x.viewportValue.height>>=g,x.viewportValue.minDepth=L,x.viewportValue.maxDepth=B,x.viewport=x.viewportValue.equals(Pv)===!1,x.scissorValue.copy(E).multiplyScalar(N).floor(),x.scissor=w._scissorTest&&x.scissorValue.equals(Pv)===!1,x.scissorValue.width>>=g,x.scissorValue.height>>=g,x.clippingContext||(x.clippingContext=new U1),x.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,v);const I=t.isArrayCamera?Lv:Dv;t.isArrayCamera||(jm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),I.setFromProjectionMatrix(jm,t.coordinateSystem,t.reversedDepth));const F=this._renderLists.get(e,t);if(F.begin(),this._projectObject(e,t,0,F,x.clippingContext),F.finish(),this.sortObjects===!0&&F.sort(this._opaqueSort,this._transparentSort),v!==null){this._textures.updateRenderTarget(v,g);const Y=this._textures.get(v);x.textures=Y.textures,x.depthTexture=Y.depthTexture,x.width=Y.width,x.height=Y.height,x.renderTarget=v,x.depth=v.depthBuffer,x.stencil=v.stencilBuffer}else x.textures=null,x.depthTexture=null,x.width=yf.width,x.height=yf.height,x.depth=this.depth,x.stencil=this.stencil;x.width>>=g,x.height>>=g,x.activeCubeFace=A,x.activeMipmapLevel=g,x.occlusionQueryCount=F.occlusionQueryCount,x.scissorValue.max(Fl.set(0,0,0,0)),x.scissorValue.x+x.scissorValue.width>x.width&&(x.scissorValue.width=Math.max(x.width-x.scissorValue.x,0)),x.scissorValue.y+x.scissorValue.height>x.height&&(x.scissorValue.height=Math.max(x.height-x.scissorValue.y,0)),this._background.update(u,F,x),x.camera=t,this.backend.beginRender(x);const{bundles:P,lightsNode:O,transparentDoublePass:G,transparent:q,opaque:j}=F;return P.length>0&&this._renderBundles(P,u,O),this.opaque===!0&&j.length>0&&this._renderObjects(j,t,u,O),this.transparent===!0&&q.length>0&&this._renderTransparents(q,G,t,u,O),this.backend.finishRender(x),s.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=l,r!==null&&(this.setRenderTarget(d,A,g),this._renderOutput(v)),u.onAfterRender(this,e,t,v),this.inspector.finishRender(this.backend.getTimestampUID(x)),x}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const n=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.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){return await this.backend.getArrayBufferAsync(e)}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,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}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,n,r,s=0,o=1){this._canvasTarget.setViewport(e,t,n,r,s,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._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,n=!0){if(this._initialized===!1)throw new Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const o=this._textures.get(r);s=this._renderContexts.getForClear(r),s.textures=o.textures,s.depthTexture=o.depthTexture,s.width=o.width,s.height=o.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer,s.clearColorValue=this.backend.getClearColor(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){Ci('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,n)}async clearColorAsync(){Ci('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){Ci('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){Ci('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!==ls,t=this.currentColorSpace!==ln.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:ls}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:ln.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){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(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}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),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return Ue("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const s=this.backend,o=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const d of u){if(o.has(d)===!1){const v=()=>{d.removeEventListener("dispose",v),o.delete(d),a.deleteForCompute(d),l.delete(d)};d.addEventListener("dispose",v);const x=d.onInitFunction;x!==null&&x.call(d,{renderer:this})}l.updateForCompute(d),a.updateForCompute(d);const A=a.getForCompute(d),g=o.getForCompute(d,A);s.compute(e,d,A,g,t)}s.finishCompute(e),n.renderId=r,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 Ci('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('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Ci('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('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Fl.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Fl.copy(t).floor();else{He("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Fl.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,s=0,o=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s,o),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,s,o=0,a=0){return this.backend.copyTextureToBuffer(e.textures[o],t,n,r,s,a)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){const l=t.isArrayCamera?Lv:Dv;if(!e.frustumCulled||l.intersectsSprite(e,t)){this.sortObjects===!0&&Fl.setFromMatrixPosition(e.matrixWorld).applyMatrix4(jm);const{geometry:u,material:d}=e;d.visible&&r.push(e,u,d,n,Fl.z,null,s)}}else if(e.isLineLoop)He("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 l=t.isArrayCamera?Lv:Dv;if(!e.frustumCulled||l.intersectsObject(e,t)){const{geometry:u,material:d}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),Fl.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(jm)),Array.isArray(d)){const A=u.groups;for(let g=0,v=A.length;g0){for(const{material:o}of t)o.side=Ai;this._renderObjects(t,n,r,s,"backSide");for(const{material:o}of t)o.side=No;this._renderObjects(e,n,r,s);for(const{material:o}of t)o.side=xr}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let o=0,a=e.length;o0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,T.isShadowPassMaterial){const{colorNode:S,depthNode:w,positionNode:C}=this._getShadowNodes(s);T.side=s.shadowSide===null?s.side:s.shadowSide,S!==null&&(T.colorNode=S),w!==null&&(T.depthNode=w),C!==null&&(T.positionNode=C)}s=T}s.transparent===!0&&s.side===xr&&s.forceSinglePass===!1?(s.side=Ai,this._handleObjectFunction(e,s,t,n,a,o,l,"backSide"),s.side=No,this._handleObjectFunction(e,s,t,n,a,o,l,u),s.side=xr):this._handleObjectFunction(e,s,t,n,a,o,l,u),d&&(t.overrideMaterial.colorNode=A,t.overrideMaterial.depthNode=g,t.overrideMaterial.positionNode=v,t.overrideMaterial.side=x),e.onAfterRender(this,t,n,r,s,o)}_renderObjectDirect(e,t,n,r,s,o,a,l){const u=this._objects.get(e,t,n,r,s,this._currentRenderContext,a,l);u.drawRange=e.geometry.drawRange,u.group=o;const d=this._nodes.needsRefresh(u);d&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(u,this.info),d&&this._nodes.updateAfter(u)}_createObjectPipeline(e,t,n,r,s,o,a,l){const u=this._objects.get(e,t,n,r,s,this._currentRenderContext,a,l);u.drawRange=e.geometry.drawRange,u.group=o,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class P7{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 Sse(i){return i+(Wu-i%Wu)%Wu}class D7 extends P7{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 Sse(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class L7 extends D7{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Tse=0;class I7 extends L7{constructor(e,t){super("UniformBuffer_"+Tse++,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 buffer(){return this.nodeUniform.value}}class wse extends L7{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}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 n=0,r=this.uniforms.length;n{this.generation=null,this.version=0},this.texture=t,this.version=t?t.version:0,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose))}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){const e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=0},e.texture=this.texture,e}}let Rse=0;class Nse extends U7{constructor(e,t){super(e,t),this.id=Rse++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class B_ extends Nse{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class F7 extends B_{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}}class xy extends B_{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}}const z4={bitcast_int_uint:new Wr("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new Wr("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},Pse={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},Dse={low:"lowp",medium:"mediump",high:"highp"},H4={swizzleAssign:!0,storageBuffer:!1},W4={perspective:"smooth",linear:"noperspective"},$4={centroid:"centroid"},j4=` +precision highp float; +precision highp int; +precision highp sampler2D; +precision highp sampler3D; +precision highp samplerCube; +precision highp sampler2DArray; + +precision highp usampler2D; +precision highp usampler3D; +precision highp usamplerCube; +precision highp usampler2DArray; + +precision highp isampler2D; +precision highp isampler3D; +precision highp isamplerCube; +precision highp isampler2DArray; + +precision lowp sampler2DShadow; +precision lowp sampler2DArrayShadow; +precision lowp samplerCubeShadow; +`;class Lse extends C7{constructor(e,t){super(e,t,new ase),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==to}_include(e){const t=z4[e];return t.build(this),this.addInclude(t),t}getMethod(e){return z4[e]!==void 0&&this._include(e),Pse[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const o of t.inputs)r.push(this.getType(o.type)+" "+o.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) { + + ${n.vars} + +${n.code} + return ${n.result}; + +}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,r=t.count*t.itemSize,{itemSize:s}=t,o=t.array.constructor.name.toLowerCase().includes("int");let a=o?zd:op;s===2?a=o?Hd:Hs:s===3?a=o?BB:sp:s===4&&(a=o?Wd:pr);const l={Float32Array:dr,Uint8Array:Gi,Uint16Array:ga,Uint32Array:vi,Int8Array:ah,Int16Array:lh,Int32Array:jr,Uint8ClampedArray:Gi},u=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/s))));let d=Math.ceil(r/s/u);u*d*s0?g:"";a=`${d.name} { + ${A} ${o.name}[${v}]; +}; +`}else a=`${this.getVectorType(o.type)} ${this.getPropertyName(o,e)};`,l=!0;const u=o.node.precision;if(u!==null&&(a=Dse[u]+" "+a),l){a=" "+a;const d=o.groupNode.name;(r[d]||(r[d]=[])).push(a)}else a="uniform "+a,n.push(a)}let s="";for(const o in r){const a=r[o];s+=this._getGLSLUniformStruct(e+"_"+o,a.join(` +`))+` +`}return s+=n.join(` +`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==jr){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name}; +`}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(` +`)}getStructs(e){const t=[],n=this.structs[e],r=[];for(const s of n)if(s.output)for(const o of s.members)r.push(`layout( location = ${o.index} ) out ${o.type} ${o.name};`);else{let o="struct "+s.name+` { +`;o+=this.getStructMembers(s),o+=` +}; +`,t.push(o)}return r.length===0&&r.push("layout( location = 0 ) out vec4 fragColor;"),` +`+r.join(` +`)+` + +`+t.join(` +`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const r of n){e==="compute"&&(r.needsInterpolation=!0);const s=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){const o=W4[r.interpolationType]||r.interpolationType,a=$4[r.interpolationSampling]||"";t+=`${o} ${a} out ${s} ${r.name}; +`}else{const o=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${o}out ${s} ${r.name}; +`}else t+=`${s} ${r.name}; +`}else if(e==="fragment"){for(const r of n)if(r.needsInterpolation){const s=this.getType(r.type);if(r.interpolationType){const o=W4[r.interpolationType]||r.interpolationType,a=$4[r.interpolationSampling]||"";t+=`${o} ${a} in ${s} ${r.name}; +`}else{const o=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${o}in ${s} ${r.name}; +`}}}for(const r of this.builtins[e])t+=`${r}; +`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,r)=>n*r,1)}u`}getSubgroupSize(){He("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){He("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){He("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(` +`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=H4[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}H4[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 n=0;n0&&(n+=` +`),n+=` // flow -> ${u} + `),n+=`${l.code} + `,a===s&&t!=="compute"&&(n+=`// result + `,t==="vertex"?(n+="gl_Position = ",n+=`${l.result};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${l.result};`)))}const o=e[t];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),o.structs=this.getStructs(t),o.codes=this.getCodes(t),o.transforms=this.getTransforms(t),o.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),o=this.getDataFromNode(e,n,this.globalCache);let a=o.uniformGPU;if(a===void 0){const l=e.groupNode,u=l.name,d=this.getBindGroupArray(u,n);if(t==="texture")a=new B_(s.name,s.node,l),d.push(a);else if(t==="cubeTexture"||t==="cubeDepthTexture")a=new F7(s.name,s.node,l),d.push(a);else if(t==="texture3D")a=new xy(s.name,s.node,l),d.push(a);else if(t==="buffer"){s.name=`buffer${e.id}`;const A=this.getSharedDataFromNode(e);let g=A.buffer;g===void 0&&(e.name=`NodeBuffer_${e.id}`,g=new I7(e,l),g.name=e.name,A.buffer=g),d.push(g),a=g}else{const A=this.uniformGroups[n]||(this.uniformGroups[n]={});let g=A[u];g===void 0&&(g=new B7(n+"_"+u,l),A[u]=g,d.push(g)),a=this.getNodeUniform(s,t),g.addUniform(a)}o.uniformGPU=a}return s}}let Iv=null,bf=null;class O7{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[nl.RENDER]:null,[nl.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),n=this.renderer.info.frame;let r;e.isComputeNode===!0?r="c:"+this.renderer.info.compute.frameCalls:r="r:"+this.renderer.info.render.frameCalls,t.timestampUID=r+":"+e.id+":f"+n}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:")?nl.COMPUTE:nl.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){Ci("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return Iv=Iv||new qe,this.renderer.getDrawingBufferSize(Iv)}setScissorTest(){}getClearColor(){const e=this.renderer;return bf=bf||new aS,e.getClearColor(bf),bf.getRGB(bf),bf}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:aR(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${wh} webgpu`),this.domElement=e),e}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 Ise=0;class Bse{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 Use{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,o=e.usage||r.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,l=n.get(a);let u=l.bufferGPU;u===void 0&&(u=this._createBuffer(r,t,s,o),l.bufferGPU=u,l.bufferType=t,l.version=a.version);let d;if(s instanceof Float32Array)d=r.FLOAT;else if(typeof Float16Array<"u"&&s instanceof Float16Array)d=r.HALF_FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?d=r.HALF_FLOAT:d=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)d=r.SHORT;else if(s instanceof Uint32Array)d=r.UNSIGNED_INT;else if(s instanceof Int32Array)d=r.INT;else if(s instanceof Int8Array)d=r.BYTE;else if(s instanceof Uint8Array)d=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)d=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let A={bufferGPU:u,bufferType:t,type:d,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:d===r.INT||d===r.UNSIGNED_INT||e.gpuType===jr,id:Ise++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const g=this._createBuffer(r,t,s,o);A=new Bse(A,g)}n.set(e,A)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,o=t.get(s),a=o.bufferType,l=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(a,o.bufferGPU),l.length===0)n.bufferSubData(a,0,r);else{for(let u=0,d=l.length;u0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let l=0;l<8;l++)l{function s(){const o=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(o===e.WAIT_FAILED){e.deleteSync(t),r();return}if(o===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let X4=!1,Xm,Uv,Q4;class kse{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,X4===!1&&(this._init(),X4=!0)}_init(){const e=this.gl;Xm={[Ah]:e.REPEAT,[io]:e.CLAMP_TO_EDGE,[ph]:e.MIRRORED_REPEAT},Uv={[xi]:e.NEAREST,[ib]:e.NEAREST_MIPMAP_NEAREST,[Wl]:e.NEAREST_MIPMAP_LINEAR,[ki]:e.LINEAR,[kf]:e.LINEAR_MIPMAP_NEAREST,[ro]:e.LINEAR_MIPMAP_LINEAR},Q4={[sb]:e.NEVER,[ub]:e.ALWAYS,[ap]:e.LESS,[lp]:e.LEQUAL,[ob]:e.EQUAL,[up]:e.GEQUAL,[ab]:e.GREATER,[lb]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:o,extensions:a}=this;if(e!==null){if(o[e]!==void 0)return o[e];Ue("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=t;if(t===o.RED&&(n===o.FLOAT&&(l=o.R32F),n===o.HALF_FLOAT&&(l=o.R16F),n===o.UNSIGNED_BYTE&&(l=o.R8),n===o.UNSIGNED_SHORT&&(l=o.R16),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.R8UI),n===o.UNSIGNED_SHORT&&(l=o.R16UI),n===o.UNSIGNED_INT&&(l=o.R32UI),n===o.BYTE&&(l=o.R8I),n===o.SHORT&&(l=o.R16I),n===o.INT&&(l=o.R32I)),t===o.RG&&(n===o.FLOAT&&(l=o.RG32F),n===o.HALF_FLOAT&&(l=o.RG16F),n===o.UNSIGNED_BYTE&&(l=o.RG8),n===o.UNSIGNED_SHORT&&(l=o.RG16),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RG8UI),n===o.UNSIGNED_SHORT&&(l=o.RG16UI),n===o.UNSIGNED_INT&&(l=o.RG32UI),n===o.BYTE&&(l=o.RG8I),n===o.SHORT&&(l=o.RG16I),n===o.INT&&(l=o.RG32I)),t===o.RGB){const u=s?Td:ln.getTransfer(r);n===o.FLOAT&&(l=o.RGB32F),n===o.HALF_FLOAT&&(l=o.RGB16F),n===o.UNSIGNED_BYTE&&(l=o.RGB8),n===o.UNSIGNED_SHORT&&(l=o.RGB16),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I),n===o.UNSIGNED_BYTE&&(l=u===Pt?o.SRGB8:o.RGB8),n===o.UNSIGNED_SHORT_5_6_5&&(l=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(l=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(l=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGB8UI),n===o.UNSIGNED_SHORT&&(l=o.RGB16UI),n===o.UNSIGNED_INT&&(l=o.RGB32UI),n===o.BYTE&&(l=o.RGB8I),n===o.SHORT&&(l=o.RGB16I),n===o.INT&&(l=o.RGB32I)),t===o.RGBA){const u=s?Td:ln.getTransfer(r);n===o.FLOAT&&(l=o.RGBA32F),n===o.HALF_FLOAT&&(l=o.RGBA16F),n===o.UNSIGNED_BYTE&&(l=o.RGBA8),n===o.UNSIGNED_SHORT&&(l=o.RGBA16),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I),n===o.UNSIGNED_BYTE&&(l=u===Pt?o.SRGB8_ALPHA8:o.RGBA8),n===o.UNSIGNED_SHORT_4_4_4_4&&(l=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(l=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(l=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(l=o.RGBA16UI),n===o.UNSIGNED_INT&&(l=o.RGBA32UI),n===o.BYTE&&(l=o.RGBA8I),n===o.SHORT&&(l=o.RGBA16I),n===o.INT&&(l=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(l=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(l=o.DEPTH_COMPONENT24),n===o.FLOAT&&(l=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(l=o.DEPTH24_STENCIL8),(l===o.R16F||l===o.R32F||l===o.RG16F||l===o.RG32F||l===o.RGBA16F||l===o.RGBA32F)&&a.get("EXT_color_buffer_float"),l}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this,o=ln.getPrimaries(ln.workingColorSpace),a=t.colorSpace===to?null:ln.getPrimaries(t.colorSpace),l=t.colorSpace===to||o===a?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,l),n.texParameteri(e,n.TEXTURE_WRAP_S,Xm[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Xm[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Xm[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,Uv[t.magFilter]);const u=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===ki&&u?ro:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,Uv[d]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,Q4[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===xi||t.minFilter!==Wl&&t.minFilter!==ro||t.type===dr&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const A=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,A.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let o=r[s];o===void 0&&(o=t.createTexture(),n.state.bindTexture(s,o),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=o),n.set(e,{textureGPU:o,glTextureType:s})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:o,height:a,depth:l}=t,u=r.utils.convert(e.format,e.colorSpace),d=r.utils.convert(e.type),A=this.getInternalFormat(e.internalFormat,u,d,e.colorSpace,e.isVideoTexture),g=n.createTexture(),v=this.getGLTextureType(e);r.state.bindTexture(v,g),this.setTextureParameters(v,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,A,o,a,l):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,A,o,a,l):e.isVideoTexture||n.texStorage2D(v,s,A,o,a),r.set(e,{textureGPU:g,glTextureType:v,glFormat:u,glType:d,glInternalFormat:A})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:o,glFormat:a,glType:l}=r.get(t),{width:u,height:d}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,u,d,a,l,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:o,glTextureType:a,glFormat:l,glType:u,glInternalFormat:d}=this.backend.get(e);if(!(e.isRenderTargetTexture||o===void 0))if(this.backend.state.bindTexture(a,o),this.setTextureParameters(a,e),e.isCompressedTexture){const A=e.mipmaps,g=t.image;for(let v=0;v0){const g=hx(A.width,A.height,e.format,e.type);for(const v of e.layerUpdates){const x=A.data.subarray(v*g/A.data.BYTES_PER_ELEMENT,(v+1)*g/A.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,v,A.width,A.height,1,l,u,x)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,A.width,A.height,A.depth,l,u,A.data)}else if(e.isData3DTexture){const A=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,A.width,A.height,A.depth,l,u,A.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(a,0,d,l,u,t.image);else{const A=e.mipmaps;if(A.length>0)for(let g=0,v=A.length;g0,g=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(A){const v=a!==0||l!==0;let x,T;if(e.isDepthTexture===!0?(x=r.DEPTH_BUFFER_BIT,T=r.DEPTH_ATTACHMENT,t.stencil&&(x|=r.STENCIL_BUFFER_BIT)):(x=r.COLOR_BUFFER_BIT,T=r.COLOR_ATTACHMENT0),v){const S=this.backend.get(t.renderTarget),w=S.framebuffers[t.getCacheKey()],C=S.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,w),s.bindFramebuffer(r.READ_FRAMEBUFFER,C);const E=g-l-d;r.blitFramebuffer(a,E,a+u,E+d,a,E,a+u,E+d,x,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,w),s.bindTexture(r.TEXTURE_2D,o),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,E,u,d),s.unbindTexture()}else{const S=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,S),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,T,r.TEXTURE_2D,o,0),r.blitFramebuffer(0,0,u,d,0,0,u,d,x,r.NEAREST),r.deleteFramebuffer(S)}}else s.bindTexture(r.TEXTURE_2D,o),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,a,g-d-l,u,d),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){const{gl:s}=this,o=t.renderTarget,{depthTexture:a,depthBuffer:l,stencilBuffer:u,width:d,height:A}=o;if(s.bindRenderbuffer(s.RENDERBUFFER,e),l&&!u){let g=s.DEPTH_COMPONENT24;r===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,o.samples,g,d,A):n>0?(a&&a.isDepthTexture&&a.type===s.FLOAT&&(g=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,n,g,d,A)):s.renderbufferStorage(s.RENDERBUFFER,g,d,A),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else l&&u&&(n>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,d,A):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,d,A),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,s,o){const{backend:a,gl:l}=this,{textureGPU:u,glFormat:d,glType:A}=this.backend.get(e),g=l.createFramebuffer();a.state.bindFramebuffer(l.READ_FRAMEBUFFER,g);const v=e.isCubeTexture?l.TEXTURE_CUBE_MAP_POSITIVE_X+o:l.TEXTURE_2D;l.framebufferTexture2D(l.READ_FRAMEBUFFER,l.COLOR_ATTACHMENT0,v,u,0);const x=this._getTypedArrayType(A),T=this._getBytesPerTexel(A,d),w=r*s*T,C=l.createBuffer();l.bindBuffer(l.PIXEL_PACK_BUFFER,C),l.bufferData(l.PIXEL_PACK_BUFFER,w,l.STREAM_READ),l.readPixels(t,n,r,s,d,A,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const E=new x(w/x.BYTES_PER_ELEMENT);return l.bindBuffer(l.PIXEL_PACK_BUFFER,C),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,E),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(l.READ_FRAMEBUFFER,null),l.deleteFramebuffer(g),E}_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(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function Qm(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 Vse{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 Gse{constructor(e){this.backend=e,this.maxAnisotropy=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 n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const Y4={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 qse{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:n,mode:r,object:s,type:o,info:a,index:l}=this;l!==0?n.drawElements(r,t,o,e):n.drawArrays(r,e,t),a.update(s,t,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:o,index:a,object:l,info:u}=this;n!==0&&(a!==0?r.drawElementsInstanced(s,t,o,e,n):r.drawArraysInstanced(s,e,t,n),u.update(l,t,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:o,info:a}=this;if(n===0)return;const l=r.get("WEBGL_multi_draw");if(l===null)for(let u=0;uthis.maxQueries)return Ci(`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.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 n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(r){He("Error in beginQuery:",r),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(n){He("Error in endQuery:",n),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[s,o]of this.queryOffsets)if(this.queryStates.get(o)==="ended"){const l=this.queries[o];e.set(s,this.resolveQuery(l))}if(e.size===0)return this.lastValue;const t={},n=[];for(const[s,o]of e){const a=s.match(/^(.*):f(\d+)$/),l=parseInt(a[2]);n.includes(l)===!1&&n.push(l),t[l]===void 0&&(t[l]=0);const u=await o;this.timestamps.set(s,u),t[l]+=u}const r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return He("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 n,r=!1;const s=()=>{n&&(clearTimeout(n),n=null)},o=l=>{r||(r=!0,s(),t(l))},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)){n=setTimeout(a,1);return}const d=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(d)/1e6)}catch(l){He("Error checking query:",l),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 K4 extends O7{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,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function s(o){o.preventDefault();const a={api:"WebGL",message:o.statusMessage||"Unknown reason",reason:null,originalEvent:o};e.onDeviceLost(a)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=r,this.extensions=new Vse(this),this.capabilities=new Gse(this),this.attributeUtils=new Use(this),this.textureUtils=new kse(this),this.bufferRenderer=new qse(this),this.state=new Fse(this),this.utils=new Ose(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.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")}get coordinateSystem(){return Ws}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){const s=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:s}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&Ue("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 zse(this.gl,e,2048));const n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.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,n=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:s,height:o}=this.getDrawingBufferSize();t.viewport(0,0,s,o)}if(e.scissor){const{x:s,y:o,width:a,height:l}=e.scissorValue;t.scissor(s,e.height-l-o,a,l)}this.initTimestampQuery(nl.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext;n.resetVertexState();const o=e.occlusionQueryCount;o>0&&(o>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(a!==null)for(let l=0;l{let l=0;for(let u=0;u1&&u.setMRTBlending(s.textures),u.useProgram(a);const v=e.getAttributes(),x=this.get(v);let T=x.vaoGPU;if(T===void 0){const F=this._getVaoKey(v);T=this.vaoCache[F],T===void 0&&(T=this._createVao(v),this.vaoCache[F]=T,x.vaoGPU=T)}const S=e.getIndex(),w=S!==null?this.get(S).bufferGPU:null;u.setVertexState(T,w);const C=d.lastOcclusionObject;if(C!==t&&C!==void 0){if(C!==null&&C.occlusionTest===!0&&(l.endQuery(l.ANY_SAMPLES_PASSED),d.occlusionQueryIndex++),t.occlusionTest===!0){const F=l.createQuery();l.beginQuery(l.ANY_SAMPLES_PASSED,F),d.occlusionQueries[d.occlusionQueryIndex]=F,d.occlusionQueryObjects[d.occlusionQueryIndex]=t}d.lastOcclusionObject=t}const E=this.bufferRenderer;t.isPoints?E.mode=l.POINTS:t.isLineSegments?E.mode=l.LINES:t.isLine?E.mode=l.LINE_STRIP:t.isLineLoop?E.mode=l.LINE_LOOP:r.wireframe===!0?(u.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),E.mode=l.LINES):E.mode=l.TRIANGLES;const{vertexCount:N,instanceCount:L}=A;let{firstVertex:B}=A;if(E.object=t,S!==null){B*=S.array.BYTES_PER_ELEMENT;const F=this.get(S);E.index=S.count,E.type=F.type}else E.index=0;const I=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(Ci("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),E.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?E.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):Ci("WebGLBackend: WEBGL_multi_draw not supported."):L>1?E.renderInstances(B,N,L):E.render(B,N)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const F=this.get(e.camera),P=e.camera.cameras,O=e.getBindingGroup("cameraIndex").bindings[0];if(F.indexesGPU===void 0||F.indexesGPU.length!==P.length){const Q=new Uint32Array([0,0,0,0]),ee=[];for(let ue=0,le=P.length;ue{const g=this.parallel,v=()=>{n.getProgramParameter(a,g.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),A()):requestAnimationFrame(v)};v()});t.push(d);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` +`),r=[],s=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let a=s;a":" "} ${l}: ${n[a]}`)}return r.join(` +`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),o=(e.getShaderInfoLog(t)||"").trim();if(r&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` + +`+o+` + +`+this._handleSource(e.getShaderSource(t),l)}else return o}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,o=(r.getProgramInfoLog(e)||"").trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");He("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+` + +Program Info Log: `+o+` +`+a+` +`+l)}else o!==""&&Ue("WebGLProgram: Program Info Log:",o)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:o,fragmentShader:a,vertexShader:l}=s;r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,a,l),n.useProgram(o);const u=e.getBindings();this._setupBindings(u,o),this.set(t,{programGPU:o})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(s);const{computeProgram:o}=e,a=r.createProgram(),l=this.get(s).shaderGPU,u=this.get(o).shaderGPU,d=o.transforms,A=[],g=[];for(let S=0;SY4[r]===e),n=this.extensions;for(let r=0;r1,v=s.isXRRenderTarget===!0,x=v===!0&&s._hasExternalTextures===!0;let T=o.msaaFrameBuffer,S=o.depthRenderbuffer;const w=this.extensions.get("WEBGL_multisampled_render_to_texture"),C=this.extensions.get("OVR_multiview2"),E=this._useMultisampledExtension(s),N=DP(e);let L;if(d?(o.cubeFramebuffers||(o.cubeFramebuffers={}),L=o.cubeFramebuffers[N]):v&&x===!1?L=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),L=o.framebuffers[N]),L===void 0){L=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,L);const B=e.textures,I=[];if(d){o.cubeFramebuffers[N]=L;const{textureGPU:P}=this.get(B[0]),O=this.renderer._activeCubeFace,G=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+O,P,G)}else{o.framebuffers[N]=L;for(let P=0;P0&&E===!1&&!s.multiview){if(T===void 0){const B=[];T=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,T);const I=[],F=e.textures;for(let P=0;P0&&this._useMultisampledExtension(r)===!1){const o=s.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const l=s.msaaFrameBuffer,u=s.msaaRenderbuffers,d=e.textures,A=d.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,l),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,o),A)for(let g=0;g0&&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 Uf={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},oh=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},is={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},Us={Store:"store"},ci={Load:"load",Clear:"clear"},Z4={CCW:"ccw",CW:"cw"},J4={None:"none",Back:"back"},kd={Uint16:"uint16",Uint32:"uint32"},fe={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",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",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",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"},Fv={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Xc={Linear:"linear",Nearest:"nearest"},Qn={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"},Oc={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},eC={None:0,All:15},Iu={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},Ov={Storage:"storage",ReadOnlyStorage:"read-only-storage"},kv={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},tC={NonFiltering:"non-filtering",Comparison:"comparison"},kc={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},nC={TwoD:"2d",ThreeD:"3d"},Nr={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},Hse={All:"all"},Ym={Vertex:"vertex",Instance:"instance"},yy={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"},iC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class Wse extends U7{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class $se extends D7{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let jse=0;class Xse extends $se{constructor(e,t){super("StorageBuffer_"+jse++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:us.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class Qse extends fc{constructor(e){super(),this.device=e;const t=` +struct VarysStruct { + @builtin( position ) Position: vec4, + @location( 0 ) vTex : vec2 +}; + +@vertex +fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array< vec2, 4 >( + vec2( -1.0, 1.0 ), + vec2( 1.0, 1.0 ), + vec2( -1.0, -1.0 ), + vec2( 1.0, -1.0 ) + ); + + var tex = array< vec2, 4 >( + vec2( 0.0, 0.0 ), + vec2( 1.0, 0.0 ), + vec2( 0.0, 1.0 ), + vec2( 1.0, 1.0 ) + ); + + Varys.vTex = tex[ vertexIndex ]; + Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); + + return Varys; + +} +`,n=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vTex ); + +} +`,r=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); + +} +`;this.mipmapSampler=e.createSampler({minFilter:Xc.Linear}),this.flipYSampler=e.createSampler({minFilter:Xc.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Uf.TriangleStrip,stripIndexFormat:kd.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Uf.TriangleStrip,stripIndexFormat:kd.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:o}=t.size,a=this.getTransferPipeline(r),l=this.getFlipYPipeline(r),u=this.device.createTexture({size:{width:s,height:o,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),d=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Nr.TwoD,baseArrayLayer:n}),A=u.createView({baseMipLevel:0,mipLevelCount:1,dimension:Nr.TwoD,baseArrayLayer:0}),g=this.device.createCommandEncoder({}),v=(x,T,S)=>{const w=x.getBindGroupLayout(0),C=this.device.createBindGroup({layout:w,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:T}]}),E=g.beginRenderPass({colorAttachments:[{view:S,loadOp:ci.Clear,storeOp:Us.Store,clearValue:[0,0,0,0]}]});E.setPipeline(x),E.setBindGroup(0,C),E.draw(4,1,0,0),E.end()};v(a,d,A),v(l,A,d),this.device.queue.submit([g.finish()]),u.destroy()}generateMipmaps(e,t,n=0,r=null){const s=this.get(e);s.layers===void 0&&(s.layers=[]);const o=s.layers[n]||this._mipmapCreateBundles(e,t,n),a=r||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(a,o),r===null&&this.device.queue.submit([a.finish()]),s.layers[n]=o}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let o=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Nr.TwoD,baseArrayLayer:n});const a=[];for(let l=1;l0)for(let o=0,a=r.length;o0)for(let o=0,a=r.length;o0?e.width:n.size.width,d=a>0?e.height:n.size.height;try{l.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:a,origin:{x:0,y:0,z:r},premultipliedAlpha:o},{width:u,height:d,depthOrArrayLayers:1})}catch{}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new Qse(this.backend.device)),e}_generateMipmaps(e,t,n=0,r=null){this._getPassUtils().generateMipmaps(e,t,n,r)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,s,o=0,a=0){const l=this.backend.device,u=e.data,d=this._getBytesPerTexel(n.format),A=e.width*d;l.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:r}},u,{offset:e.width*e.height*d*o,bytesPerRow:A},{width:e.width,height:e.height,depthOrArrayLayers:1}),s===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n){const r=this.backend.device,s=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1;for(let a=0;a]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,eoe=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,rC={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"},toe=i=>{i=i.trim();const e=i.match(Jse);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=eoe.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let d=0;d "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class ioe extends R7{parseFunction(e){return new noe(e)}}const roe={[us.READ_ONLY]:"read",[us.WRITE_ONLY]:"write",[us.READ_WRITE]:"read_write"},sC={[Ah]:"repeat",[io]:"clamp",[ph]:"mirror"},Km={vertex:oh.VERTEX,fragment:oh.FRAGMENT,compute:oh.COMPUTE},oC={instance:!0,swizzleAssign:!1,storageBuffer:!0},soe={"^^":"tsl_xor"},ooe={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"},aC={},OA={tsl_xor:new Wr("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Wr("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Wr("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Wr("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Wr("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Wr("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Wr("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Wr("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 Wr("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 Wr("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Wr("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 Wr("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Wr(` +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 ); + +} +`)},aoe={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",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 V7="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(V7+=`diagnostic( off, derivative_uniformity ); +`);class loe extends C7{constructor(e,t){super(e,t,new ioe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,r,s,o=this.shaderStage){return o==="fragment"?r?s?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:s?`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",r)}generateTextureSampleLevel(e,t,n,r,s,o){return this.isUnfilterable(e)===!1?o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,o,r):this.generateTextureLod(e,t,n,s,o,r)}generateWrapFunction(e){const t=`tsl_coord_${sC[e.wrapS]}S_${sC[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`;let n=aC[t];if(n===void 0){const r=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let o=`fn ${t}( coord : ${s} ) -> ${s} { + + return ${s}( +`;const a=(l,u)=>{l===Ah?(r.push(OA.repeatWrapping_float),o+=` tsl_repeatWrapping_float( coord.${u} )`):l===io?(r.push(OA.clampWrapping_float),o+=` tsl_clampWrapping_float( coord.${u} )`):l===ph?(r.push(OA.mirrorWrapping_float),o+=` tsl_mirrorWrapping_float( coord.${u} )`):(o+=` coord.${u}`,Ue(`WebGPURenderer: Unsupported texture wrap type "${l}" for vertex shader.`))};a(e.wrapS,"x"),o+=`, +`,a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(o+=`, +`,a(e.wrapR,"z")),o+=` + ); + +} +`,aC[t]=n=new Wr(o,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let o,a;const{primarySamples:l}=this.renderer.backend.utils.getTextureSampleData(e),u=l>1;e.is3DTexture||e.isData3DTexture?a="vec3":a="vec2",u||e.isStorageTexture?o=t:o=`${t}${n?`, u32( ${n} )`:""}`,s=new Tg(new wg(`textureDimensions( ${o} )`,a)),r.dimensionsSnippet[n]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Tg(new wg(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Tg(new wg("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r,s="0u"){this._include("biquadraticTexture");const o=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,s);return r&&(n=`${n} + vec2(${r}) / ${a}`),`tsl_biquadraticTexture( ${t}, ${o}( ${n} ), ${a}, u32( ${s} ) )`}generateTextureLod(e,t,n,r,s,o="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,o),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";s&&(n=`${n} + ${u}(${s}) / ${u}( ${l} )`);const d=`${u}( ${a}( ${n} ) * ${u}( ${l} ) )`;return this.generateTextureLoad(e,t,d,o,r,null)}generateTextureLoad(e,t,n,r,s,o){r===null&&(r="0u"),o&&(n=`${n} + ${o}`);let a;return s?a=`textureLoad( ${t}, ${n}, ${s}, u32( ${r} ) )`:(a=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,n,r,s){let o;return r?o=`textureStore( ${t}, ${n}, ${r}, ${s} )`:o=`textureStore( ${t}, ${n}, ${s} )`,o}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===dr||this.isSampleCompare(e)===!1&&e.minFilter===xi&&e.magFilter===xi||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s,o=this.shaderStage){let a=null;return this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,s,"0",o):a=this._generateTextureSample(e,t,n,r,s,o),a}generateTextureGrad(e,t,n,r,s,o,a=this.shaderStage){if(a==="fragment")return o?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;He(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,o,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?o?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${r}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${r} )`:o?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;He(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,o){return this.isUnfilterable(e)===!1?o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,o,r):this.generateTextureLod(e,t,n,s,o,r)}generateTextureBias(e,t,n,r,s,o,a=this.shaderStage){if(a==="fragment")return o?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;He(`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 n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="cubeDepthTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=soe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(Ue("WebGPURenderer: Atomic operations are only supported in compute shaders."),us.READ_WRITE):us.READ_ONLY:e.access}getStorageAccess(e,t){return roe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),o=this.getDataFromNode(e,n,this.globalCache);if(o.uniformGPU===void 0){let a;const l=e.groupNode,u=l.name,d=this.getBindGroupArray(u,n);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let A=null;const g=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?A=new xy(s.name,s.node,l,g):A=new B_(s.name,s.node,l,g):t==="cubeTexture"||t==="cubeDepthTexture"?A=new F7(s.name,s.node,l,g):t==="texture3D"&&(A=new xy(s.name,s.node,l,g)),A.store=e.isStorageTextureNode===!0,A.mipLevel=A.store?e.mipLevel:0,A.setVisibility(Km[n]),this.isUnfilterable(e.value)===!1&&A.store===!1){const v=new Wse(`${s.name}_sampler`,s.node,l);v.setVisibility(Km[n]),d.push(v,A),a=[v,A]}else d.push(A),a=[A]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const A=this.getSharedDataFromNode(e);let g=A.buffer;if(g===void 0){const v=t==="buffer"?I7:Xse;g=new v(e,l),A.buffer=g}g.setVisibility(g.getVisibility()|Km[n]),d.push(g),a=g,s.name=r||"NodeBuffer_"+s.id}else{const A=this.uniformGroups[n]||(this.uniformGroups[n]={});let g=A[u];g===void 0&&(g=new B7(u,l),g.setVisibility(Km[n]),A[u]=g,d.push(g)),a=this.getNodeUniform(s,t),g.addUniform(a)}o.uniformGPU=a}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),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,n=this.flowShaderNode(e),r=[];for(const o of t.inputs)r.push(o.name+" : "+this.getType(o.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} { +${n.vars} +${n.code} +`;return n.result&&(s+=` return ${n.result}; +`),s+=` +} +`,s}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=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);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=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:o}of n.values())t.push(`@builtin( ${r} ) ${s} : ${o}`);return t.join(`, + `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:o}of this.scopedArrays.values()){const a=this.getType(s);t.push(`var<${r}> ${n}: 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 n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,o=r.length;s"),t.push(` ${r+n.name} : ${s}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, +`)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const r=[];for(const s of n){let o=`struct ${s.name} { +`;o+=this.getStructMembers(s),o+=` +};`,r.push(o)}t=` +`+r.join(` + +`)+` +`}return t}getVar(e,t,n=null){let r=`var ${t} : `;return n!==null?r+=this.generateArrayDeclaration(e,n):r+=this.getType(e),r}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name,r.count)};`);return` +${t.join(` +`)} +`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,o=this.vars[e];for(let a=0;an.value.itemSize;return r&&!s}getUniforms(e){const t=this.uniforms[e],n=[],r=[],s=[],o={};for(const l of t){const u=l.groupNode.name,d=this.bindingsIndexes[u];if(l.type==="texture"||l.type==="cubeTexture"||l.type==="cubeDepthTexture"||l.type==="storageTexture"||l.type==="texture3D"){const A=l.node.value;this.isUnfilterable(A)===!1&&l.node.isStorageTextureNode!==!0&&(this.isSampleCompare(A)?n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler_comparison;`):n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler;`));let g,v="";const{primarySamples:x}=this.renderer.backend.utils.getTextureSampleData(A);if(x>1&&(v="_multisampled"),A.isCubeTexture===!0&&A.isDepthTexture===!0)g="texture_depth_cube";else if(A.isCubeTexture===!0)g="texture_cube";else if(A.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&A.compareFunction===null?g=`texture${v}_2d`:g=`texture_depth${v}_2d${A.isArrayTexture===!0?"_array":""}`;else if(l.node.isStorageTextureNode===!0){const T=by(A),S=this.getStorageAccess(l.node,e),w=l.node.value.is3DTexture,C=l.node.value.isArrayTexture;g=`texture_storage_${w?"3d":`2d${C?"_array":""}`}<${T}, ${S}>`}else if(A.isArrayTexture===!0||A.isDataArrayTexture===!0||A.isCompressedArrayTexture===!0)g="texture_2d_array";else if(A.is3DTexture===!0||A.isData3DTexture===!0)g="texture_3d";else{const T=this.getComponentTypeFromTexture(A).charAt(0);g=`texture${v}_2d<${T}32>`}n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name} : ${g};`)}else if(l.type==="buffer"||l.type==="storageBuffer"||l.type==="indirectStorageBuffer"){const A=l.node,g=this.getType(A.getNodeType(this)),v=A.bufferCount,x=v>0&&l.type==="buffer"?", "+v:"",T=A.isStorageBufferNode?`storage, ${this.getStorageAccess(A,e)}`:"uniform";if(this.isCustomStruct(l))r.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${T}> ${l.name} : ${g};`);else{const w=` value : array< ${A.isAtomic?`atomic<${g}>`:`${g}`}${x} >`;r.push(this._getWGSLStructBinding(l.name,w,T,d.binding++,d.group))}}else{const A=this.getType(this.getVectorType(l.type)),g=l.groupNode.name;(o[g]||(o[g]={index:d.binding++,id:d.group,snippets:[]})).snippets.push(` ${l.name} : ${A}`)}}for(const l in o){const u=o[l];s.push(this._getWGSLStructBinding(l,u.snippets.join(`, +`),"uniform",u.index,u.id))}return[...n,...r,...s].join(` +`)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code + +`;r+=this.flowCode[t];const s=this.flowNodes[t],o=s[s.length-1],a=o.outputNode,l=a!==void 0&&a.isOutputStructNode===!0;for(const u of s){const d=this.getFlowData(u),A=u.name;if(A&&(r.length>0&&(r+=` +`),r+=` // flow -> ${A} +`),r+=`${d.code} + `,u===o&&t!=="compute"){if(r+=`// result + + `,t==="vertex")r+=`varyings.Vertex = ${d.result};`;else if(t==="fragment")if(l)n.returnType=a.getNodeType(this),n.structs+="var output : "+n.returnType+";",r+=`return ${d.result};`;else{let g=" @location(0) color: vec4";const v=this.getBuiltins("output");v&&(g+=`, + `+v),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",g),n.structs+=` +var output : OutputStruct;`,r+=`output.color = ${d.result}; + + return output;`}}}n.flow=r}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 n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||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,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return ooe[e]||e}isAvailable(e){let t=oC[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),oC[e]=t),t}_getWGSLMethod(e){return OA[e]!==void 0&&this._include(e),aoe[e]}_include(e){const t=OA[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; + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // vars + ${e.vars} + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${V7} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){const[n,r,s]=t;return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// codes +${e.codes} + +@compute @workgroup_size( ${n}, ${r}, ${s} ) +fn main( ${e.attributes} ) { + + // system + instanceIndex = globalId.x + + globalId.y * ( ${n} * numWorkgroups.x ) + + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y ); + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const o=e+"Struct";return`${this._getWGSLStruct(o,t)} +@binding( ${r} ) @group( ${s} ) +var<${n}> ${e} : ${o};`}}class uoe{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=fe.Depth24PlusStencil8:e.depth&&(t=fe.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 s=this.backend.renderer,o=s.getRenderTarget();t=o?o.samples:s.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}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 Uf.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Uf.LineList;if(e.isLine)return Uf.LineStrip;if(e.isMesh)return Uf.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 navigator.gpu.getPreferredCanvasFormat();if(t===Gi)return fe.BGRA8Unorm;if(t===zi)return fe.RGBA16Float;throw new Error("Unsupported output buffer type.")}}const G7=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"&&G7.set(Float16Array,["float16"]);const coe=new Map([[uR,["float16"]]]),hoe=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class foe{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let o=s.buffer;if(o===void 0){const a=r.device;let l=n.array;if(e.normalized===!1){if(l.constructor===Int16Array||l.constructor===Int8Array)l=new Int32Array(l);else if((l.constructor===Uint16Array||l.constructor===Uint8Array)&&(l=new Uint32Array(l),t&GPUBufferUsage.INDEX))for(let A=0;A0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(l=o.groups[n])),l===void 0&&(l=this.createBindGroup(e,a),n>0&&(o.groups[n]=l,o.versions[n]=r)),o.group=l}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer,o=e.updateRanges;if(o.length===0)n.queue.writeBuffer(s,0,r,0);else{const a=Ig(r),l=a?1:r.BYTES_PER_ELEMENT;for(let u=0,d=o.length;u1&&(g+=`-${l.texture.depthOrArrayLayers}`),g+=`-${d}-${A}`,u=l[g],u===void 0){const v=Hse.All;let x;a.isSampledCubeTexture?x=Nr.Cube:a.isSampledTexture3D?x=Nr.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?x=Nr.TwoDArray:x=Nr.TwoD,u=l[g]=l.texture.createView({aspect:v,dimension:x,mipLevelCount:d,baseMipLevel:A})}}o.push({binding:s,resource:u})}else if(a.isSampler){const l=n.get(a.texture);o.push({binding:s,resource:l.sampler})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:o})}_createLayoutEntries(e){const t=[];let n=0;for(const r of e.bindings){const s=this.backend,o={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){const a={};r.isStorageBuffer&&(r.visibility&oh.COMPUTE&&(r.access===us.READ_WRITE||r.access===us.WRITE_ONLY)?a.type=Ov.Storage:a.type=Ov.ReadOnlyStorage),o.buffer=a}else if(r.isSampledTexture&&r.store){const a={};a.format=this.backend.get(r.texture).texture.format;const l=r.access;l===us.READ_WRITE?a.access=kv.ReadWrite:l===us.WRITE_ONLY?a.access=kv.WriteOnly:a.access=kv.ReadOnly,r.texture.isArrayTexture?a.viewDimension=Nr.TwoDArray:r.texture.is3DTexture&&(a.viewDimension=Nr.ThreeD),o.storageTexture=a}else if(r.isSampledTexture){const a={},{primarySamples:l}=s.utils.getTextureSampleData(r.texture);if(l>1&&(a.multisampled=!0,r.texture.isDepthTexture||(a.sampleType=kc.UnfilterableFloat)),r.texture.isDepthTexture)s.compatibilityMode&&r.texture.compareFunction===null?a.sampleType=kc.UnfilterableFloat:a.sampleType=kc.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const u=r.texture.type;u===jr?a.sampleType=kc.SInt:u===vi?a.sampleType=kc.UInt:u===dr&&(this.backend.hasFeature("float32-filterable")?a.sampleType=kc.Float:a.sampleType=kc.UnfilterableFloat)}r.isSampledCubeTexture?a.viewDimension=Nr.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?a.viewDimension=Nr.TwoDArray:r.isSampledTexture3D&&(a.viewDimension=Nr.ThreeD),o.texture=a}else if(r.isSampler){const a={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null?a.type=tC.Comparison:s.compatibilityMode&&(a.type=tC.NonFiltering)),o.sampler=a}else He(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(o),n++}return t}deleteBindGroupData(e){const{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class poe{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:o}=e,{vertexProgram:a,fragmentProgram:l}=o,u=this.backend,d=u.device,A=u.utils,g=u.get(o),v=[];for(const j of e.getBindings()){const Y=u.get(j),{layoutGPU:$}=Y.layout;v.push($)}const x=u.attributeUtils.createShaderVertexBuffers(e);let T;r.blending!==$s&&(r.blending!==js||r.transparent!==!1)&&(T=this._getBlending(r));let S={};r.stencilWrite===!0&&(S={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const w=this._getColorWriteMask(r),C=[];if(e.context.textures!==null){const j=e.context.textures;for(let Y=0;Y1},layout:d.createPipelineLayout({bindGroupLayouts:v})},O={},G=e.context.depth,q=e.context.stencil;if((G===!0||q===!0)&&(G===!0&&(O.format=I,O.depthWriteEnabled=r.depthWrite,O.depthCompare=B),q===!0&&(O.stencilFront=S,O.stencilBack={},O.stencilReadMask=r.stencilFuncMask,O.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(O.depthBias=r.polygonOffsetUnits,O.depthBiasSlopeScale=r.polygonOffsetFactor,O.depthBiasClamp=0),P.depthStencil=O),d.pushErrorScope("validation"),t===null)g.pipeline=d.createRenderPipeline(P),d.popErrorScope().then(j=>{j!==null&&(g.error=!0,He(j.message))});else{const j=new Promise(async Y=>{try{g.pipeline=await d.createRenderPipelineAsync(P)}catch{}const $=await d.popErrorScope();$!==null&&(g.error=!0,He($.message)),Y()});t.push(j)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:r,device:s}=n,o=r.getCurrentDepthStencilFormat(e),a=r.getCurrentColorFormats(e),l=this._getSampleCount(e),u={label:t,colorFormats:a,depthStencilFormat:o,sampleCount:l};return s.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,o=n.get(e),a=[];for(const l of t){const u=n.get(l),{layoutGPU:d}=u.layout;a.push(d)}o.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,o=e.blendDst,a=e.blendEquation;if(r===Of){const l=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,u=e.blendDstAlpha!==null?e.blendDstAlpha:o,d=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(a)},n={srcFactor:this._getBlendFactor(l),dstFactor:this._getBlendFactor(u),operation:this._getBlendOperation(d)}}else{const l=e.premultipliedAlpha,u=(d,A,g,v)=>{t={srcFactor:d,dstFactor:A,operation:Oc.Add},n={srcFactor:g,dstFactor:v,operation:Oc.Add}};if(l)switch(r){case js:u(Qn.One,Qn.OneMinusSrcAlpha,Qn.One,Qn.OneMinusSrcAlpha);break;case Qf:u(Qn.One,Qn.One,Qn.One,Qn.One);break;case Yf:u(Qn.Zero,Qn.OneMinusSrc,Qn.Zero,Qn.One);break;case Kf:u(Qn.Dst,Qn.OneMinusSrcAlpha,Qn.Zero,Qn.One);break}else switch(r){case js:u(Qn.SrcAlpha,Qn.OneMinusSrcAlpha,Qn.One,Qn.OneMinusSrcAlpha);break;case Qf:u(Qn.SrcAlpha,Qn.One,Qn.One,Qn.One);break;case Yf:He("WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Kf:He("WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};He("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Ol:t=Qn.Zero;break;case qy:t=Qn.One;break;case zy:t=Qn.Src;break;case Hy:t=Qn.OneMinusSrc;break;case g0:t=Qn.SrcAlpha;break;case _0:t=Qn.OneMinusSrcAlpha;break;case jy:t=Qn.Dst;break;case Xy:t=Qn.OneMinusDst;break;case Wy:t=Qn.DstAlpha;break;case $y:t=Qn.OneMinusDstAlpha;break;case Qy:t=Qn.SrcAlphaSaturated;break;case aJ:t=Qn.Constant;break;case lJ:t=Qn.OneMinusConstant;break;default:He("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case jB:t=is.Never;break;case sx:t=is.Always;break;case XB:t=is.Less;break;case YB:t=is.LessEqual;break;case QB:t=is.Equal;break;case JB:t=is.GreaterEqual;break;case KB:t=is.Greater;break;case ZB:t=is.NotEqual;break;default:He("WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case qc:t=Iu.Keep;break;case VB:t=Iu.Zero;break;case GB:t=Iu.Replace;break;case $B:t=Iu.Invert;break;case qB:t=Iu.IncrementClamp;break;case zB:t=Iu.DecrementClamp;break;case HB:t=Iu.IncrementWrap;break;case WB:t=Iu.DecrementWrap;break;default:He("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case bs:t=Oc.Add;break;case Vy:t=Oc.Subtract;break;case Gy:t=Oc.ReverseSubtract;break;case eR:t=Oc.Min;break;case tR:t=Oc.Max;break;default:He("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?kd.Uint16:kd.Uint32);let o=n.side===Ai;return e.isMesh&&e.matrixWorld.determinant()<0&&(o=!o),r.frontFace=o===!0?Z4.CW:Z4.CCW,r.cullMode=n.side===xr?J4.None:J4.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?eC.All:eC.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=is.Always;else{const n=e.depthFunc;switch(n){case v0:t=is.Never;break;case x0:t=is.Always;break;case y0:t=is.Less;break;case tc:t=is.LessEqual;break;case b0:t=is.Equal;break;case S0:t=is.GreaterEqual;break;case T0:t=is.Greater;break;case w0:t=is.NotEqual;break;default:He("WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class moe extends k7{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Ci(`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,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const s=r.finish();if(this.device.queue.submit([s]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const o=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),a={},l=[];for(const[d,A]of e){const g=d.match(/^(.*):f(\d+)$/),v=parseInt(g[2]);l.includes(v)===!1&&l.push(v),a[v]===void 0&&(a[v]=0);const x=o[A],T=o[A+1],S=Number(T-x)/1e6;this.timestamps.set(d,S),a[v]+=S}const u=a[l[l.length-1]];return this.resultBuffer.unmap(),this.lastValue=u,this.frames=l,u}catch(e){return He("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){He("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){He("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 goe extends O7{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new uoe(this),this.attributeUtils=new foe(this),this.bindingUtils=new Aoe(this),this.pipelineUtils=new poe(this),this.textureUtils=new Zse(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const r={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(s===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const o=Object.values(yy),a=[];for(const u of o)s.features.has(u)&&a.push(u);const l={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await s.requestDevice(l)}else n=t.device;n.lost.then(r=>{if(r.reason==="destroyed")return;const s={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};e.onDeviceLost(s)}),this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(yy.TimestampQuery),this.updateSize()}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let n=t.context;if(n===void 0){const r=this.parameters;e.isDefaultCanvasTarget===!0&&r.context!==void 0?n=r.context:n=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${wh} webgpu`);const s=r.alpha?"premultiplied":"opaque",o=r.outputType===zi?"extended":"standard";n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:o}}),t.context=n}return n}get coordinateSystem(){return Xo}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples;let s=n.descriptor;if(s===void 0||n.samples!==r){s={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(s.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});const a=s.colorAttachments[0];r>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,n.descriptor=s,n.samples=r}const o=s.colorAttachments[0];return r>0?o.resolveTarget=this.context.getCurrentTexture().createView():o.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;(s===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples)&&(s={},r.descriptors=s);const o=e.getCacheKey();let a=s[o];if(a===void 0){const u=e.textures,d=[];let A;const g=this._isRenderCameraDepthArray(e);for(let v=0;v1)if(g===!0){const S=e.camera.cameras;for(let w=0;w0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let o;e.textures===null?o=this._getDefaultRenderPassDescriptor():o=this._getRenderPassDescriptor(e,{loadOp:ci.Load}),this.initTimestampQuery(nl.RENDER,this.getTimestampUID(e),o),o.occlusionQuerySet=s;const a=o.depthStencilAttachment;if(e.textures!==null){const u=o.colorAttachments;for(let d=0;d0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const s=[];for(let o=0;o0){const s=n*8;let o=this.occludedResolveCache.get(s);o===void 0&&(o=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,o));const a=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,o,0),t.encoder.copyBufferToBuffer(o,0,a,0,s),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const s=e.textures;for(let o=0;ov&&(s[0]=Math.min(g,v),s[1]=Math.ceil(g/v)),o.dispatchSize=s}s=o.dispatchSize}a.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:n,material:r,context:s,pipeline:o}=e,a=e.getBindings(),l=this.get(s),u=this.get(o),d=u.pipeline;if(u.error===!0)return;const A=e.getIndex(),g=A!==null,v=e.getDrawParameters();if(v===null)return;const x=(S,w)=>{this.pipelineUtils.setPipeline(S,d),w.pipeline=d;const C=w.bindingGroups;for(let N=0,L=a.length;N{if(x(S,w),n.isBatchedMesh===!0){const C=n._multiDrawStarts,E=n._multiDrawCounts,N=n._multiDrawCount,L=n._multiDrawInstances;L!==null&&Ci("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let B=0;B1?0:B;g===!0?S.drawIndexed(E[B],I,C[B]/A.array.BYTES_PER_ELEMENT,0,F):S.draw(E[B],I,C[B],F),t.update(n,E[B],I)}}else if(g===!0){const{vertexCount:C,instanceCount:E,firstVertex:N}=v,L=e.getIndirect();if(L!==null){const B=this.get(L).buffer,I=e.getIndirectOffset(),F=Array.isArray(I)?I:[I];for(let P=0;P0){const S=this.get(e.camera),w=e.camera.cameras,C=e.getBindingGroup("cameraIndex");if(S.indexesGPU===void 0||S.indexesGPU.length!==w.length){const N=this.get(C),L=[],B=new Uint32Array([0,0,0,0]);for(let I=0,F=w.length;I(Ue("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new K4(e)));const n=new t(e);super(n,e),this.library=new xoe,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}/** + * @license + * Copyright 2010-2025 Three.js Authors + * SPDX-License-Identifier: MIT + */U.BRDF_GGX;U.BRDF_Lambert;U.BasicPointShadowFilter;U.BasicShadowFilter;U.Break;U.Const;U.Continue;U.DFGLUT;U.D_GGX;U.Discard;U.EPSILON;U.F_Schlick;const yoe=U.Fn;U.INFINITY;const boe=U.If,Soe=U.Loop;U.NodeAccess;U.NodeShaderStage;U.NodeType;U.NodeUpdateType;U.PCFShadowFilter;U.PCFSoftShadowFilter;U.PI;U.PI2;U.TWO_PI;U.HALF_PI;U.PointShadowFilter;U.Return;U.Schlick_to_F0;U.ScriptableNodeResources;U.ShaderNode;U.Stack;U.Switch;U.TBNViewMatrix;U.VSMShadowFilter;U.V_GGX_SmithCorrelated;U.Var;U.VarIntent;U.abs;U.acesFilmicToneMapping;U.acos;U.add;U.addMethodChaining;U.addNodeElement;U.agxToneMapping;U.all;U.alphaT;U.and;U.anisotropy;U.anisotropyB;U.anisotropyT;U.any;U.append;U.array;U.arrayBuffer;const Toe=U.asin;U.assign;U.atan;U.atan2;U.atomicAdd;U.atomicAnd;U.atomicFunc;U.atomicLoad;U.atomicMax;U.atomicMin;U.atomicOr;U.atomicStore;U.atomicSub;U.atomicXor;U.attenuationColor;U.attenuationDistance;U.attribute;U.attributeArray;U.backgroundBlurriness;U.backgroundIntensity;U.backgroundRotation;U.batch;U.bentNormalView;U.billboarding;U.bitAnd;U.bitNot;U.bitOr;U.bitXor;U.bitangentGeometry;U.bitangentLocal;U.bitangentView;U.bitangentWorld;U.bitcast;U.blendBurn;U.blendColor;U.blendDodge;U.blendOverlay;U.blendScreen;U.blur;U.bool;U.buffer;U.bufferAttribute;U.bumpMap;U.burn;U.builtin;U.builtinAOContext;U.builtinShadowContext;U.bvec2;U.bvec3;U.bvec4;U.bypass;U.cache;U.call;U.cameraFar;U.cameraIndex;U.cameraNear;U.cameraNormalMatrix;U.cameraPosition;U.cameraProjectionMatrix;U.cameraProjectionMatrixInverse;U.cameraViewMatrix;U.cameraViewport;U.cameraWorldMatrix;U.cbrt;U.cdl;U.ceil;U.checker;U.cineonToneMapping;U.clamp;U.clearcoat;U.clearcoatNormalView;U.clearcoatRoughness;U.code;U.color;U.colorSpaceToWorking;U.colorToDirection;U.compute;U.computeKernel;U.computeSkinning;U.context;U.convert;U.convertColorSpace;U.convertToTexture;U.countLeadingZeros;U.countOneBits;U.countTrailingZeros;const woe=U.cos;U.cross;U.cubeTexture;U.cubeTextureBase;U.dFdx;U.dFdy;U.dashSize;U.debug;U.decrement;U.decrementBefore;U.defaultBuildStages;U.defaultShaderStages;U.defined;U.degrees;U.deltaTime;U.densityFog;U.densityFogFactor;U.depth;U.depthPass;U.determinant;U.difference;U.diffuseColor;U.directPointLight;U.directionToColor;U.directionToFaceDirection;U.dispersion;U.distance;U.div;U.dodge;U.dot;U.drawIndex;U.dynamicBufferAttribute;U.element;U.emissive;U.equal;U.equals;U.equirectUV;const Moe=U.exp;U.exp2;U.expression;U.faceDirection;U.faceForward;U.faceforward;const Eoe=U.float;U.floatBitsToInt;U.floatBitsToUint;U.floor;U.fog;U.fract;U.frameGroup;U.frameId;U.frontFacing;U.fwidth;U.gain;U.gapSize;U.getConstNodeType;U.getCurrentStack;U.getDirection;U.getDistanceAttenuation;U.getGeometryRoughness;U.getNormalFromDepth;U.interleavedGradientNoise;U.vogelDiskSample;U.getParallaxCorrectNormal;U.getRoughness;U.getScreenPosition;U.getShIrradianceAt;U.getShadowMaterial;U.getShadowRenderObjectFunction;U.getTextureIndex;U.getViewPosition;U.globalId;U.glsl;U.glslFn;U.grayscale;U.greaterThan;U.greaterThanEqual;U.hash;U.highpModelNormalViewMatrix;U.highpModelViewMatrix;U.hue;U.increment;U.incrementBefore;U.instance;const Coe=U.instanceIndex;U.instancedArray;U.instancedBufferAttribute;U.instancedDynamicBufferAttribute;U.instancedMesh;U.int;U.intBitsToFloat;U.inverse;U.inverseSqrt;U.inversesqrt;U.invocationLocalIndex;U.invocationSubgroupIndex;U.ior;U.iridescence;U.iridescenceIOR;U.iridescenceThickness;U.ivec2;U.ivec3;U.ivec4;U.js;U.label;U.length;U.lengthSq;U.lessThan;U.lessThanEqual;U.lightPosition;U.lightProjectionUV;U.lightShadowMatrix;U.lightTargetDirection;U.lightTargetPosition;U.lightViewPosition;U.lightingContext;U.lights;U.linearDepth;U.linearToneMapping;U.localId;U.log;U.log2;U.logarithmicDepthToViewZ;U.luminance;U.mat2;U.mat3;U.mat4;U.matcapUV;U.materialAO;U.materialAlphaTest;U.materialAnisotropy;U.materialAnisotropyVector;U.materialAttenuationColor;U.materialAttenuationDistance;U.materialClearcoat;U.materialClearcoatNormal;U.materialClearcoatRoughness;U.materialColor;U.materialDispersion;U.materialEmissive;U.materialEnvIntensity;U.materialEnvRotation;U.materialIOR;U.materialIridescence;U.materialIridescenceIOR;U.materialIridescenceThickness;U.materialLightMap;U.materialLineDashOffset;U.materialLineDashSize;U.materialLineGapSize;U.materialLineScale;U.materialLineWidth;U.materialMetalness;U.materialNormal;U.materialOpacity;U.materialPointSize;U.materialReference;U.materialReflectivity;U.materialRefractionRatio;U.materialRotation;U.materialRoughness;U.materialSheen;U.materialSheenRoughness;U.materialShininess;U.materialSpecular;U.materialSpecularColor;U.materialSpecularIntensity;U.materialSpecularStrength;U.materialThickness;U.materialTransmission;U.max;U.maxMipLevel;U.mediumpModelViewMatrix;U.metalness;U.min;U.mix;U.mixElement;U.mod;U.modInt;U.modelDirection;U.modelNormalMatrix;U.modelPosition;U.modelRadius;U.modelScale;U.modelViewMatrix;U.modelViewPosition;U.modelViewProjection;U.modelWorldMatrix;U.modelWorldMatrixInverse;U.morphReference;U.mrt;U.mul;U.mx_aastep;U.mx_add;U.mx_atan2;U.mx_cell_noise_float;U.mx_contrast;U.mx_divide;U.mx_fractal_noise_float;U.mx_fractal_noise_vec2;U.mx_fractal_noise_vec3;U.mx_fractal_noise_vec4;U.mx_frame;U.mx_heighttonormal;U.mx_hsvtorgb;U.mx_ifequal;U.mx_ifgreater;U.mx_ifgreatereq;U.mx_invert;U.mx_modulo;U.mx_multiply;U.mx_noise_float;U.mx_noise_vec3;U.mx_noise_vec4;U.mx_place2d;U.mx_power;U.mx_ramp4;U.mx_ramplr;U.mx_ramptb;U.mx_rgbtohsv;U.mx_rotate2d;U.mx_rotate3d;U.mx_safepower;U.mx_separate;U.mx_splitlr;U.mx_splittb;U.mx_srgb_texture_to_lin_rec709;U.mx_subtract;U.mx_timer;U.mx_transform_uv;U.mx_unifiednoise2d;U.mx_unifiednoise3d;U.mx_worley_noise_float;U.mx_worley_noise_vec2;U.mx_worley_noise_vec3;const Roe=U.negate;U.neutralToneMapping;U.nodeArray;U.nodeImmutable;U.nodeObject;U.nodeObjectIntent;U.nodeObjects;U.nodeProxy;U.nodeProxyIntent;U.normalFlat;U.normalGeometry;U.normalLocal;U.normalMap;U.normalView;U.normalViewGeometry;U.normalWorld;U.normalWorldGeometry;U.normalize;U.not;U.notEqual;U.numWorkgroups;U.objectDirection;U.objectGroup;U.objectPosition;U.objectRadius;U.objectScale;U.objectViewPosition;U.objectWorldMatrix;U.OnBeforeObjectUpdate;U.OnBeforeMaterialUpdate;U.OnObjectUpdate;U.OnMaterialUpdate;U.oneMinus;U.or;U.orthographicDepthToViewZ;U.oscSawtooth;U.oscSine;U.oscSquare;U.oscTriangle;U.output;U.outputStruct;U.overlay;U.overloadingFn;U.packHalf2x16;U.packSnorm2x16;U.packUnorm2x16;U.parabola;U.parallaxDirection;U.parallaxUV;U.parameter;U.pass;U.passTexture;U.pcurve;U.perspectiveDepthToViewZ;U.pmremTexture;U.pointShadow;U.pointUV;U.pointWidth;U.positionGeometry;U.positionLocal;U.positionPrevious;U.positionView;U.positionViewDirection;U.positionWorld;U.positionWorldDirection;U.posterize;U.pow;U.pow2;U.pow3;U.pow4;U.premultiplyAlpha;U.property;U.radians;U.rand;U.range;U.rangeFog;U.rangeFogFactor;U.reciprocal;U.reference;U.referenceBuffer;U.reflect;U.reflectVector;U.reflectView;U.reflector;U.refract;U.refractVector;U.refractView;U.reinhardToneMapping;U.remap;U.remapClamp;U.renderGroup;U.renderOutput;U.rendererReference;U.replaceDefaultUV;U.rotate;U.rotateUV;U.roughness;U.round;U.rtt;U.sRGBTransferEOTF;U.sRGBTransferOETF;U.sample;U.sampler;U.samplerComparison;U.saturate;U.saturation;U.screen;U.screenCoordinate;U.screenDPR;U.screenSize;U.screenUV;U.scriptable;U.scriptableValue;U.select;U.setCurrentStack;U.setName;U.shaderStages;U.shadow;U.shadowPositionWorld;U.shapeCircle;U.sharedUniformGroup;U.sheen;U.sheenRoughness;U.shiftLeft;U.shiftRight;U.shininess;U.sign;const Noe=U.sin;U.sinc;U.skinning;U.smoothstep;U.smoothstepElement;U.specularColor;U.specularF90;U.spherizeUV;U.split;U.spritesheetUV;const Poe=U.sqrt;U.stack;U.step;U.stepElement;const Doe=U.storage;U.storageBarrier;U.storageObject;U.storageTexture;U.string;U.struct;U.sub;U.subgroupAdd;U.subgroupAll;U.subgroupAnd;U.subgroupAny;U.subgroupBallot;U.subgroupBroadcast;U.subgroupBroadcastFirst;U.subBuild;U.subgroupElect;U.subgroupExclusiveAdd;U.subgroupExclusiveMul;U.subgroupInclusiveAdd;U.subgroupInclusiveMul;U.subgroupIndex;U.subgroupMax;U.subgroupMin;U.subgroupMul;U.subgroupOr;U.subgroupShuffle;U.subgroupShuffleDown;U.subgroupShuffleUp;U.subgroupShuffleXor;U.subgroupSize;U.subgroupXor;U.tan;U.tangentGeometry;U.tangentLocal;U.tangentView;U.tangentWorld;U.texture;U.texture3D;U.textureBarrier;U.textureBicubic;U.textureBicubicLevel;U.textureCubeUV;U.textureLoad;U.textureSize;U.textureLevel;U.textureStore;U.thickness;U.time;U.toneMapping;U.toneMappingExposure;U.toonOutlinePass;U.transformDirection;U.transformNormal;U.transformNormalToView;U.transformedClearcoatNormalView;U.transformedNormalView;U.transformedNormalWorld;U.transmission;U.transpose;U.triNoise3D;U.triplanarTexture;U.triplanarTextures;U.trunc;U.uint;U.uintBitsToFloat;const Loe=U.uniform;U.uniformArray;U.uniformCubeTexture;U.uniformGroup;U.uniformFlow;U.uniformTexture;U.unpackHalf2x16;U.unpackSnorm2x16;U.unpackUnorm2x16;U.unpremultiplyAlpha;U.userData;U.uv;U.uvec2;U.uvec3;U.uvec4;U.varying;U.varyingProperty;U.vec2;U.vec3;U.vec4;U.vectorComponents;U.velocity;U.vertexColor;U.vertexIndex;U.vertexStage;U.vibrance;U.viewZToLogarithmicDepth;U.viewZToOrthographicDepth;U.viewZToPerspectiveDepth;U.viewport;U.viewportCoordinate;U.viewportDepthTexture;U.viewportLinearDepth;U.viewportMipTexture;U.viewportResolution;U.viewportSafeUV;U.viewportSharedTexture;U.viewportSize;U.viewportTexture;U.viewportUV;U.wgsl;U.wgslFn;U.workgroupArray;U.workgroupBarrier;U.workgroupId;U.workingToColorSpace;U.xor;const lC=new fu,Zm=new te;class z7 extends GU{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Jn(e,3)),this.setAttribute("uv",new Jn(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Og(t,6,1);return this.setAttribute("instanceStart",new il(n,3,0)),this.setAttribute("instanceEnd",new il(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Og(t,6,1);return this.setAttribute("instanceColorStart",new il(n,3,0)),this.setAttribute("instanceColorEnd",new il(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new xU(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fu);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),lC.setFromBufferAttribute(t),this.boundingBox.union(lC))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ac),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,o=e.count;s + #include + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + void trimSegment( const in vec4 start, inout vec4 end ) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column + float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column + float nearEstimate = - 0.5 * b / a; + + float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); + + end.xyz = mix( start.xyz, end.xyz, alpha ); + + } + + void main() { + + #ifdef USE_COLOR + + vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; + vUv = uv; + + #endif + + float aspect = resolution.x / resolution.y; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + #ifdef WORLD_UNITS + + worldStart = start.xyz; + worldEnd = end.xyz; + + #else + + vUv = uv; + + #endif + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column + + if ( perspective ) { + + if ( start.z < 0.0 && end.z >= 0.0 ) { + + trimSegment( start, end ); + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + trimSegment( end, start ); + + } + + } + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + #ifdef WORLD_UNITS + + vec3 worldDir = normalize( end.xyz - start.xyz ); + vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); + vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); + vec3 worldFwd = cross( worldDir, worldUp ); + worldPos = position.y < 0.5 ? start: end; + + // height offset + float hw = linewidth * 0.5; + worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; + + // don't extend the line if we're rendering dashes because we + // won't be rendering the endcaps + #ifndef USE_DASH + + // cap extension + worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; + + // add width to the box + worldPos.xyz += worldFwd * hw; + + // endcaps + if ( position.y > 1.0 || position.y < 0.0 ) { + + worldPos.xyz -= worldFwd * 2.0 * hw; + + } + + #endif + + // project the worldpos + vec4 clip = projectionMatrix * worldPos; + + // shift the depth of the projected points so the line + // segments overlap neatly + vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; + clip.z = clipPose.z * clip.w; + + #else + + vec2 offset = vec2( dir.y, - dir.x ); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + #endif + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `,fragmentShader:` + uniform vec3 diffuse; + uniform float opacity; + uniform float linewidth; + + #ifdef USE_DASH + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #include + #include + #include + #include + #include + + vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { + + float mua; + float mub; + + vec3 p13 = p1 - p3; + vec3 p43 = p4 - p3; + + vec3 p21 = p2 - p1; + + float d1343 = dot( p13, p43 ); + float d4321 = dot( p43, p21 ); + float d1321 = dot( p13, p21 ); + float d4343 = dot( p43, p43 ); + float d2121 = dot( p21, p21 ); + + float denom = d2121 * d4343 - d4321 * d4321; + + float numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mua = clamp( mua, 0.0, 1.0 ); + mub = ( d1343 + d4321 * ( mua ) ) / d4343; + mub = clamp( mub, 0.0, 1.0 ); + + return vec2( mua, mub ); + + } + + void main() { + + float alpha = opacity; + vec4 diffuseColor = vec4( diffuse, alpha ); + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + #ifdef WORLD_UNITS + + // Find the closest points on the view ray and the line segment + vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; + vec3 lineDir = worldEnd - worldStart; + vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); + + vec3 p1 = worldStart + lineDir * params.x; + vec3 p2 = rayEnd * params.y; + vec3 delta = p1 - p2; + float len = length( delta ); + float norm = len / linewidth; + + #ifndef USE_DASH + + #ifdef USE_ALPHA_TO_COVERAGE + + float dnorm = fwidth( norm ); + alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); + + #else + + if ( norm > 0.5 ) { + + discard; + + } + + #endif + + #endif + + #else + + #ifdef USE_ALPHA_TO_COVERAGE + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth( len2 ); + + if ( abs( vUv.y ) > 1.0 ) { + + alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); + + } + + #else + + if ( abs( vUv.y ) > 1.0 ) { + + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + + if ( len2 > 1.0 ) discard; + + } + + #endif + + #endif + + #include + #include + + gl_FragColor = vec4( diffuseColor.rgb, alpha ); + + #include + #include + #include + #include + + } + `};class ES extends Rs{constructor(e){super({type:"LineMaterial",uniforms:W1.clone(Js.line.uniforms),vertexShader:Js.line.vertexShader,fragmentShader:Js.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Vv=new dn,uC=new te,cC=new te,rs=new dn,ss=new dn,Xa=new dn,Gv=new te,qv=new gn,os=new WU,hC=new te,Jm=new fu,eg=new ac,Qa=new dn;let tl,fh;function fC(i,e,t){return Qa.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),Qa.multiplyScalar(1/Qa.w),Qa.x=fh/t.width,Qa.y=fh/t.height,Qa.applyMatrix4(i.projectionMatrixInverse),Qa.multiplyScalar(1/Qa.w),Math.abs(Math.max(Qa.x,Qa.y))}function Ioe(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,o=Math.min(n.instanceCount,r.count);for(let a=0,l=o;aA&&ss.z>A)continue;if(rs.z>A){const E=rs.z-ss.z,N=(rs.z-A)/E;rs.lerp(ss,N)}else if(ss.z>A){const E=ss.z-rs.z,N=(ss.z-A)/E;ss.lerp(rs,N)}rs.applyMatrix4(n),ss.applyMatrix4(n),rs.multiplyScalar(1/rs.w),ss.multiplyScalar(1/ss.w),rs.x*=s.x/2,rs.y*=s.y/2,ss.x*=s.x/2,ss.y*=s.y/2,os.start.copy(rs),os.start.z=0,os.end.copy(ss),os.end.z=0;const T=os.closestPointToPointParameter(Gv,!0);os.at(T,hC);const S=Md.lerp(rs.z,ss.z,T),w=S>=-1&&S<=1,C=Gv.distanceTo(hC)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(Q=le===$)&&(F=ee[(I=ee[4])?5:(I=3,3)],ee[4]=ee[5]=i):ee[0]<=ue&&((Q=Y<2&&ue$||$>le)&&(ee[4]=Y,ee[5]=$,q.n=le,I=0))}if(Q||Y>1)return o;throw G=!0,$}return function(Y,$,Q){if(P>1)throw TypeError("Generator is already running");for(G&&$===1&&j($,Q),I=$,F=Q;(e=I<2?i:F)||!G;){B||(I?I<3?(I>1&&(q.n=-1),j(I,F)):q.n=F:q.v=F);try{if(P=2,B){if(I||(Y="next"),e=B[Y]){if(!(e=e.call(B,F)))throw TypeError("iterator result is not an object");if(!e.done)return e;F=e.value,I<2&&(I=0)}else I===1&&(e=B.return)&&e.call(B),I<2&&(F=TypeError("The iterator does not provide a '"+Y+"' method"),I=1);B=i}else if((e=(G=q.n<0)?F:E.call(N,q))!==o)break}catch(ee){B=i,I=1,F=ee}finally{P=1}}return{value:e,done:G}}}(v,T,S),!0),C}var o={};function a(){}function l(){}function u(){}e=Object.getPrototypeOf;var d=[][n]?e(e([][n]())):(wo(e={},n,function(){return this}),e),A=u.prototype=a.prototype=Object.create(d);function g(v){return Object.setPrototypeOf?Object.setPrototypeOf(v,u):(v.__proto__=u,wo(v,r,"GeneratorFunction")),v.prototype=Object.create(A),v}return l.prototype=u,wo(A,"constructor",u),wo(u,"constructor",l),l.displayName="GeneratorFunction",wo(u,r,"GeneratorFunction"),wo(A),wo(A,r,"Generator"),wo(A,n,function(){return this}),wo(A,"toString",function(){return"[object Generator]"}),(wy=function(){return{w:s,m:g}})()}function wo(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}wo=function(s,o,a,l){function u(d,A){wo(s,d,function(g){return this._invoke(d,A,g)})}o?r?r(s,o,{value:a,enumerable:!l,configurable:!l,writable:!l}):s[o]=a:(u("next",0),u("throw",1),u("return",2))},wo(i,e,t,n)}function My(i,e){return My=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},My(i,e)}function $i(i,e){return Goe(i)||Xoe(i,e)||j7(i,e)||Qoe()}function eae(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=Vd(i))!==null;);return i}function Wv(i,e,t,n){var r=Ty(Vd(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Ri(i){return qoe(i)||joe(i)||j7(i)||Yoe()}function tae(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function $7(i){var e=tae(i,"string");return typeof e=="symbol"?e:e+""}function j7(i,e){if(i){if(typeof i=="string")return Sy(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Sy(i,e):void 0}}var X7=function(e){e instanceof Array?e.forEach(X7):(e.map&&e.map.dispose(),e.dispose())},NS=function(e){e.geometry&&e.geometry.dispose(),e.material&&X7(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(NS)},Li=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),NS(t)}};function Qs(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(o,a){a[i][r](o)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var o=s[i],a=arguments.length,l=new Array(a>1?a-1:0),u=1;u2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=qi*(1+t),o=Math.sin(n);return{x:s*o*Math.cos(r),y:s*Math.cos(n),z:s*o*Math.sin(r)}}function Q7(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),o=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-o*180/Math.PI-(o<-Math.PI/2?360:0),altitude:r/qi-1}}function Qc(i){return i*Math.PI/180}var J0=window.THREE?window.THREE:{BackSide:Ai,BufferAttribute:Ji,Color:Gt,Mesh:si,ShaderMaterial:Rs},nae=` +uniform float hollowRadius; + +varying vec3 vVertexWorldPosition; +varying vec3 vVertexNormal; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + vVertexNormal = normalize(normalMatrix * normal); + vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; + + vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); + vCameraDistanceToObjCenter = length(objCenterViewPosition); + + float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); + float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); + vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; + + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +}`,iae=` +uniform vec3 color; +uniform float coefficient; +uniform float power; +uniform float hollowRadius; + +varying vec3 vVertexNormal; +varying vec3 vVertexWorldPosition; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius + if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius + + vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; + vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; + viewCameraToVertex = normalize(viewCameraToVertex); + float intensity = pow( + coefficient + dot(vVertexNormal, viewCameraToVertex), + power + ); + gl_FragColor = vec4(color, intensity); +}`;function rae(i,e,t,n){return new J0.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:nae,fragmentShader:iae,uniforms:{coefficient:{value:i},color:{value:new J0.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function sae(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,o=s===void 0?"gold":s,a=r.size,l=a===void 0?2:a,u=r.coefficient,d=u===void 0?.5:u,A=r.power,g=A===void 0?1:A,v=r.hollowRadius,x=v===void 0?0:v,T=r.backside,S=T===void 0?!0:T;F_(this,e),n=U_(this,e);var w=sae(t,l),C=rae(d,o,g,x);return S&&(C.side=J0.BackSide),n.geometry=w,n.material=C,n}return k_(e,i),O_(e)}(J0.Mesh),Ya=window.THREE?window.THREE:{Color:Gt,Group:so,LineBasicMaterial:jd,LineSegments:fR,Mesh:si,MeshPhongMaterial:MR,SphereGeometry:Tl,SRGBColorSpace:as,TextureLoader:Cb},Y7=kr({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Li(e.globeObj),Li(e.tileEngine),Li(e.graticulesObj)}},stateInit:function(){var e=new Ya.MeshPhongMaterial({color:0}),t=new Ya.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new uW(qi),r=new Ya.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new Ya.LineSegments(new L8(EH(),qi,2),new Ya.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){Li(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new Ya.SphereGeometry(qi,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new Ya.TextureLoader().load(e.globeImageUrl,function(a){a.colorSpace=Ya.SRGBColorSpace,n.map=a,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new Ya.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new Ya.TextureLoader().load(e.bumpImageUrl,function(a){n.bumpMap=a,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Li(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var o=e.atmosphereObj=new oae(e.globeObj.geometry,{color:e.atmosphereColor,size:qi*e.atmosphereAltitude,hollowRadius:qi,coefficient:.1,power:3.5});o.visible=!!e.showAtmosphere,o.__globeObjType="atmosphere",e.scene.add(o)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),xl=function(e){return isNaN(e)?parseInt(an(e).toHex(),16):e},ya=function(e){return e&&isNaN(e)?xh(e).opacity:1},oc=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,o=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(o){var a=o.slice(1),l=$i(a,4),u=l[0],d=l[1],A=l[2],g=l[3];r=new Gt("rgb(".concat(+u,",").concat(+d,",").concat(+A,")")),s=Math.min(+g,1)}else r=new Gt(e);n&&r.convertLinearToSRGB();var v=r.toArray();return t?[].concat(Ri(v),[s]):v};function aae(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var gC=window.THREE?window.THREE:{BufferAttribute:Ji};function yl(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new gC.BufferAttribute(new t(i),e);for(var n=new gC.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,o=s===void 0?"__data":s,a=r.objBindAttr,l=a===void 0?"__threeObj":a,u=r.removeDelay,d=u===void 0?0:u;return F_(this,e),n=U_(this,e),Kr(n,"scene",void 0),zv(n,$v,void 0),zv(n,tg,void 0),zv(n,ng,void 0),n.scene=t,Hv($v,n,o),Hv(tg,n,l),Hv(ng,n,d),n.onRemoveObj(function(){}),n}return k_(e,i),O_(e,[{key:"onCreateObj",value:function(n){var r=this;return Wv(e,"onCreateObj",this)([function(s){var o=n(s);return s[kA(tg,r)]=o,o[kA($v,r)]=s,r.scene.add(o),o}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return Wv(e,"onRemoveObj",this)([function(s,o){var a=Wv(e,"getData",r)([s]);n(s,o);var l=function(){r.scene.remove(s),Li(s),delete a[kA(tg,r)]};kA(ng,r)?setTimeout(l,kA(ng,r)):l()}]),this}}])}(O$),ua=window.THREE?window.THREE:{BufferGeometry:ui,CylinderGeometry:Q1,Matrix4:gn,Mesh:si,MeshLambertMaterial:du,Object3D:ji,Vector3:te},_C=Object.assign({},Hb),vC=_C.BufferGeometryUtils||_C,K7=kr({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=Ke(e.pointLat),r=Ke(e.pointLng),s=Ke(e.pointAltitude),o=Ke(e.pointRadius),a=Ke(e.pointColor),l=new ua.CylinderGeometry(1,1,1,e.pointResolution);l.applyMatrix4(new ua.Matrix4().makeRotationX(Math.PI/2)),l.applyMatrix4(new ua.Matrix4().makeTranslation(0,0,-.5));var u=2*Math.PI*qi/360,d={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&Li(e.scene),e.dataMapper.scene=e.pointsMerge?new ua.Object3D:e.scene,e.dataMapper.onCreateObj(v).onUpdateObj(x).digest(e.pointsData),e.pointsMerge){var A=e.pointsData.length?(vC.mergeGeometries||vC.mergeBufferGeometries)(e.pointsData.map(function(T){var S=e.dataMapper.getObj(T),w=S.geometry.clone();S.updateMatrix(),w.applyMatrix4(S.matrix);var C=oc(a(T));return w.setAttribute("color",yl(Array(w.getAttribute("position").count).fill(C),4)),w})):new ua.BufferGeometry,g=new ua.Mesh(A,new ua.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));g.__globeObjType="points",g.__data=e.pointsData,e.dataMapper.clear(),Li(e.scene),e.scene.add(g)}function v(){var T=new ua.Mesh(l);return T.__globeObjType="point",T}function x(T,S){var w=function(F){var P=T.__currentTargetD=F,O=P.r,G=P.alt,q=P.lat,j=P.lng;Object.assign(T.position,Jo(q,j));var Y=e.pointsMerge?new ua.Vector3(0,0,0):e.scene.localToWorld(new ua.Vector3(0,0,0));T.lookAt(Y),T.scale.x=T.scale.y=Math.min(30,O)*u,T.scale.z=Math.max(G*qi,.1)},C={alt:+s(S),r:+o(S),lat:+n(S),lng:+r(S)},E=T.__currentTargetD||Object.assign({},C,{alt:-.001});if(Object.keys(C).some(function(I){return E[I]!==C[I]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?w(C):e.tweenGroup.add(new Ns(E).to(C,e.pointsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(w).start())),!e.pointsMerge){var N=a(S),L=N?ya(N):0,B=!!L;T.visible=B,B&&(d.hasOwnProperty(N)||(d[N]=new ua.MeshLambertMaterial({color:xl(N),transparent:L<1,opacity:L})),T.material=d[N])}}}}),Z7=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` + `.concat(Ln.common,` + `).concat(Ln.logdepthbuf_pars_vertex,` + + uniform float dashTranslate; + + attribute vec4 color; + varying vec4 vColor; + + attribute float relDistance; + varying float vRelDistance; + + void main() { + // pass through colors and distances + vColor = color; + vRelDistance = relDistance + dashTranslate; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + + `).concat(Ln.logdepthbuf_vertex,` + } + `),fragmentShader:` + `.concat(Ln.logdepthbuf_pars_fragment,` + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + varying vec4 vColor; + varying float vRelDistance; + + void main() { + // ignore pixels in the gap + if (vRelDistance < dashOffset) discard; + if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; + + // set px color: [r, g, b, a], interpolated between vertices + gl_FragColor = vColor; + + `).concat(Ln.logdepthbuf_fragment,` + } + `)}},Ey=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` +`)),e.fragmentShader=(`uniform float uSurfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` +`)),e},uae=function(e){return e.vertexShader=` + attribute float r; + + const float PI = 3.1415926535897932384626433832795; + float toRad(in float a) { + return a * PI / 180.0; + } + + vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] + float phi = toRad(90.0 - c.x); + float theta = toRad(90.0 - c.y); + float r = c.z; + return vec3( // x,y,z + r * sin(phi) * cos(theta), + r * cos(phi), + r * sin(phi) * sin(theta) + ); + } + + vec2 Cartesian2Polar(in vec3 p) { + float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); + float phi = acos(p.y / r); + float theta = atan(p.z, p.x); + return vec2( // lat,lng + 90.0 - phi * 180.0 / PI, + 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) + ); + } + `.concat(e.vertexShader.replace("}",` + vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); + gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); + } + `),` + `),e},PS=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},cae=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},hae=["stroke"],ca=window.THREE?window.THREE:{BufferGeometry:ui,CubicBezierCurve3:mR,Curve:Ia,Group:so,Line:j1,Mesh:si,NormalBlending:js,ShaderMaterial:Rs,TubeGeometry:Mb,Vector3:te},fae=Id.default||Id,J7=kr({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new fae,sharedMaterial:new ca.ShaderMaterial(mi(mi({},Z7()),{},{transparent:!0,blending:ca.NormalBlending}))}},init:function(e,t){Li(e),t.scene=e,t.dataMapper=new mo(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new ca.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var o=$i(s,2),a=o[1];return a}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var o=s.children[0],a=o.__dashAnimateStep*r,l=o.material.uniforms.dashTranslate.value%1e9;o.material.uniforms.dashTranslate.value=l+a})})},update:function(e){var t=Ke(e.arcStartLat),n=Ke(e.arcStartLng),r=Ke(e.arcStartAltitude),s=Ke(e.arcEndLat),o=Ke(e.arcEndLng),a=Ke(e.arcEndAltitude),l=Ke(e.arcAltitude),u=Ke(e.arcAltitudeAutoScale),d=Ke(e.arcStroke),A=Ke(e.arcColor),g=Ke(e.arcDashLength),v=Ke(e.arcDashGap),x=Ke(e.arcDashInitialGap),T=Ke(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(E,N){var L=d(N),B=L!=null;if(!E.children.length||B!==(E.children[0].type==="Mesh")){Li(E);var I=B?new ca.Mesh:new ca.Line(new ca.BufferGeometry);I.material=e.sharedMaterial.clone(),E.add(I)}var F=E.children[0];Object.assign(F.material.uniforms,{dashSize:{value:g(N)},gapSize:{value:v(N)},dashOffset:{value:x(N)}});var P=T(N);F.__dashAnimateStep=P>0?1e3/P:0;var O=w(A(N),e.arcCurveResolution,B?e.arcCircularResolution+1:1),G=C(e.arcCurveResolution,B?e.arcCircularResolution+1:1,!0);F.geometry.setAttribute("color",O),F.geometry.setAttribute("relDistance",G);var q=function(Q){var ee=E.__currentTargetD=Q,ue=ee.stroke,le=Koe(ee,hae),de=S(le);B?(F.geometry&&F.geometry.dispose(),F.geometry=new ca.TubeGeometry(de,e.arcCurveResolution,ue/2,e.arcCircularResolution),F.geometry.setAttribute("color",O),F.geometry.setAttribute("relDistance",G)):F.geometry.setFromPoints(de.getPoints(e.arcCurveResolution))},j={stroke:L,alt:l(N),altAutoScale:+u(N),startLat:+t(N),startLng:+n(N),startAlt:+r(N),endLat:+s(N),endLng:+o(N),endAlt:+a(N)},Y=E.__currentTargetD||Object.assign({},j,{altAutoScale:-.001});Object.keys(j).some(function($){return Y[$]!==j[$]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?q(j):e.tweenGroup.add(new Ns(Y).to(j,e.arcsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(q).start()))}).digest(e.arcsData);function S(E){var N=E.alt,L=E.altAutoScale,B=E.startLat,I=E.startLng,F=E.startAlt,P=E.endLat,O=E.endLng,G=E.endAlt,q=function(ve){var Re=$i(ve,3),Je=Re[0],Ct=Re[1],et=Re[2],qt=Jo(Ct,Je,et),en=qt.x,zt=qt.y,Oe=qt.z;return new ca.Vector3(en,zt,Oe)},j=[I,B],Y=[O,P],$=N;if($==null&&($=ic(j,Y)/2*L+Math.max(F,G)),$||F||G){var Q=kb(j,Y),ee=function(ve,Re){return Re+(Re-ve)*(ve2&&arguments[2]!==void 0?arguments[2]:1,B=N+1,I;if(E instanceof Array||E instanceof Function){var F=E instanceof Array?tu().domain(E.map(function($,Q){return Q/(E.length-1)})).range(E):E;I=function(Q){return oc(F(Q),!0,!0)}}else{var P=oc(E,!0,!0);I=function(){return P}}for(var O=[],G=0,q=B;G1&&arguments[1]!==void 0?arguments[1]:1,L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,B=E+1,I=[],F=0,P=B;F=F?L:B}),4)),N})):new Bu.BufferGeometry,x=new Bu.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:Bu.DoubleSide});x.onBeforeCompile=function(C){x.userData.shader=Ey(C)};var T=new Bu.Mesh(v,x);T.__globeObjType="hexBinPoints",T.__data=A,e.dataMapper.clear(),Li(e.scene),e.scene.add(T)}function S(C){var E=new Bu.Mesh;E.__hexCenter=J8(C.h3Idx),E.__hexGeoJson=e5(C.h3Idx,!0).reverse();var N=E.__hexCenter[1];return E.__hexGeoJson.forEach(function(L){var B=L[0];Math.abs(N-B)>170&&(L[0]+=N>B?360:-360)}),E.__globeObjType="hexbin",E}function w(C,E){var N=function(ee,ue,le){return ee-(ee-ue)*le},L=Math.max(0,Math.min(1,+u(E))),B=$i(C.__hexCenter,2),I=B[0],F=B[1],P=L===0?C.__hexGeoJson:C.__hexGeoJson.map(function(Q){var ee=$i(Q,2),ue=ee[0],le=ee[1];return[[ue,F],[le,I]].map(function(de){var Te=$i(de,2),Qe=Te[0],Ye=Te[1];return N(Qe,Ye,L)})}),O=e.hexTopCurvatureResolution;C.geometry&&C.geometry.dispose(),C.geometry=new Qb([P],0,qi,!1,!0,!0,O);var G={alt:+o(E)},q=function(ee){var ue=C.__currentTargetD=ee,le=ue.alt;C.scale.x=C.scale.y=C.scale.z=1+le;var de=qi/(le+1);C.geometry.setAttribute("surfaceRadius",yl(Array(C.geometry.getAttribute("position").count).fill(de),1))},j=C.__currentTargetD||Object.assign({},G,{alt:-.001});if(Object.keys(G).some(function(Q){return j[Q]!==G[Q]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?q(G):e.tweenGroup.add(new Ns(j).to(G,e.hexTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(q).start())),!e.hexBinMerge){var Y=l(E),$=a(E);[Y,$].forEach(function(Q){if(!g.hasOwnProperty(Q)){var ee=ya(Q);g[Q]=PS(new Bu.MeshLambertMaterial({color:xl(Q),transparent:ee<1,opacity:ee,side:Bu.DoubleSide}),Ey)}}),C.material=[Y,$].map(function(Q){return g[Q]})}}}}),tD=function(e){return e*e},zl=function(e){return e*Math.PI/180};function dae(i,e){var t=Math.sqrt,n=Math.cos,r=function(d){return tD(Math.sin(d/2))},s=zl(i[1]),o=zl(e[1]),a=zl(i[0]),l=zl(e[0]);return 2*Math.asin(t(r(o-s)+n(s)*n(o)*r(l-a)))}var Aae=Math.sqrt(2*Math.PI);function pae(i,e){return Math.exp(-tD(i/e)/2)/(e*Aae)}var mae=function(e){var t=$i(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=o.lngAccessor,l=a===void 0?function(S){return S[0]}:a,u=o.latAccessor,d=u===void 0?function(S){return S[1]}:u,A=o.weightAccessor,g=A===void 0?function(){return 1}:A,v=o.bandwidth,x=[n,r],T=v*Math.PI/180;return iz(s.map(function(S){var w=g(S);if(!w)return 0;var C=dae(x,[l(S),d(S)]);return pae(C,T)*w}))},gae=function(){var i=Hoe(wy().m(function e(t){var n,r,s,o,a,l,u,d,A,g,v,x,T,S,w,C,E,N,L,B,I,F,P,O,G,q,j,Y,$,Q,ee,ue,le,de,Te,Qe,Ye,Et,at,ve,Re=arguments,Je,Ct,et;return wy().w(function(qt){for(;;)switch(qt.n){case 0:if(r=Re.length>1&&Re[1]!==void 0?Re[1]:[],s=Re.length>2&&Re[2]!==void 0?Re[2]:{},o=s.lngAccessor,a=o===void 0?function(en){return en[0]}:o,l=s.latAccessor,u=l===void 0?function(en){return en[1]}:l,d=s.weightAccessor,A=d===void 0?function(){return 1}:d,g=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){qt.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),qt.a(2,t.map(function(en){return mae(en,r,{lngAccessor:a,latAccessor:u,weightAccessor:A,bandwidth:g})}));case 1:return v=4,x=yoe,T=boe,S=Loe,w=Doe,C=Eoe,E=Coe,N=Soe,L=Poe,B=Noe,I=woe,F=Toe,P=Moe,O=Roe,G=w(new Rg(new Float32Array(t.flat().map(zl)),2),"vec2",t.length),q=w(new Rg(new Float32Array(r.map(function(en){return[zl(a(en)),zl(u(en)),A(en)]}).flat()),3),"vec3",r.length),j=new Rg(t.length,1),Y=w(j,"float",t.length),$=C(Math.PI),Q=L($.mul(2)),ee=function(zt){return zt.mul(zt)},ue=function(zt){return ee(B(zt.div(2)))},le=function(zt,Oe){var tt=C(zt[1]),Ve=C(Oe[1]),pt=C(zt[0]),ae=C(Oe[0]);return C(2).mul(F(L(ue(Ve.sub(tt)).add(I(tt).mul(I(Ve)).mul(ue(ae.sub(pt)))))))},de=function(zt,Oe){return P(O(ee(zt.div(Oe)).div(2))).div(Oe.mul(Q))},Te=S(zl(g)),Qe=S(zl(g*v)),Ye=S(r.length),Et=x(function(){var en=G.element(E),zt=Y.element(E);zt.assign(0),N(Ye,function(Oe){var tt=Oe.i,Ve=q.element(tt),pt=Ve.z;T(pt,function(){var ae=le(Ve.xy,en.xy);T(ae&&ae.lessThan(Qe),function(){zt.addAssign(de(ae,Te).mul(pt))})})})}),at=Et().compute(t.length),ve=new q7,qt.n=2,ve.computeAsync(at);case 2:return Je=Array,Ct=Float32Array,qt.n=3,ve.getArrayBufferAsync(j);case 3:return et=qt.v,qt.a(2,Je.from.call(Je,new Ct(et)))}},e)}));return function(t){return i.apply(this,arguments)}}(),ig=window.THREE?window.THREE:{Mesh:si,MeshLambertMaterial:du,SphereGeometry:Tl},_ae=3.5,vae=.1,bC=100,xae=function(e){var t=xh(jX(e));return t.opacity=Math.cbrt(e),t.formatRgb()},nD=kr({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return xae}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new ig.Mesh(new ig.SphereGeometry(qi),PS(new ig.MeshLambertMaterial({vertexColors:!0,transparent:!0}),uae));return s.__globeObjType="heatmap",s})},update:function(e){var t=Ke(e.heatmapPoints),n=Ke(e.heatmapPointLat),r=Ke(e.heatmapPointLng),s=Ke(e.heatmapPointWeight),o=Ke(e.heatmapBandwidth),a=Ke(e.heatmapColorFn),l=Ke(e.heatmapColorSaturation),u=Ke(e.heatmapBaseAltitude),d=Ke(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(A,g){var v=o(g),x=a(g),T=l(g),S=u(g),w=d(g),C=t(g).map(function(I){var F=n(I),P=r(I),O=Jo(F,P),G=O.x,q=O.y,j=O.z;return{x:G,y:q,z:j,lat:F,lng:P,weight:s(I)}}),E=Math.max(vae,v/_ae),N=Math.ceil(360/(E||-1));A.geometry.parameters.widthSegments!==N&&(A.geometry.dispose(),A.geometry=new ig.SphereGeometry(qi,N,N/2));var L=lae(A.geometry.getAttribute("position")),B=L.map(function(I){var F=$i(I,3),P=F[0],O=F[1],G=F[2],q=Q7({x:P,y:O,z:G}),j=q.lng,Y=q.lat;return[j,Y]});gae(B,C,{latAccessor:function(F){return F.lat},lngAccessor:function(F){return F.lng},weightAccessor:function(F){return F.weight},bandwidth:v}).then(function(I){var F=Ri(new Array(bC)).map(function(q,j){return oc(x(j/(bC-1)))}),P=function(j){var Y=A.__currentTargetD=j,$=Y.kdeVals,Q=Y.topAlt,ee=Y.saturation,ue=ez($.map(Math.abs))||1e-15,le=JR([0,ue/ee],F);A.geometry.setAttribute("color",yl($.map(function(Te){return le(Math.abs(Te))}),4));var de=tu([0,ue],[qi*(1+S),qi*(1+(Q||S))]);A.geometry.setAttribute("r",yl($.map(de)))},O={kdeVals:I,topAlt:w,saturation:T},G=A.__currentTargetD||Object.assign({},O,{kdeVals:I.map(function(){return 0}),topAlt:w&&S,saturation:.5});G.kdeVals.length!==I.length&&(G.kdeVals=I.slice()),Object.keys(O).some(function(q){return G[q]!==O[q]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?P(O):e.tweenGroup.add(new Ns(G).to(O,e.heatmapsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(P).start()))})}).digest(e.heatmapsData)}}),Uu=window.THREE?window.THREE:{DoubleSide:xr,Group:so,LineBasicMaterial:jd,LineSegments:fR,Mesh:si,MeshBasicMaterial:no},iD=kr({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new Uu.Group;return s.__defaultSideMaterial=PS(new Uu.MeshBasicMaterial({side:Uu.DoubleSide,depthWrite:!0}),Ey),s.__defaultCapMaterial=new Uu.MeshBasicMaterial({side:Uu.DoubleSide,depthWrite:!0}),s.add(new Uu.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new Uu.LineSegments(void 0,new Uu.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=Ke(e.polygonGeoJsonGeometry),n=Ke(e.polygonAltitude),r=Ke(e.polygonCapCurvatureResolution),s=Ke(e.polygonCapColor),o=Ke(e.polygonCapMaterial),a=Ke(e.polygonSideColor),l=Ke(e.polygonSideMaterial),u=Ke(e.polygonStrokeColor),d=[];e.polygonsData.forEach(function(A){var g={data:A,capColor:s(A),capMaterial:o(A),sideColor:a(A),sideMaterial:l(A),strokeColor:u(A),altitude:+n(A),capCurvatureResolution:+r(A)},v=t(A),x=A.__id||"".concat(Math.round(Math.random()*1e9));A.__id=x,v.type==="Polygon"?d.push(mi({id:"".concat(x,"_0"),coords:v.coordinates},g)):v.type==="MultiPolygon"?d.push.apply(d,Ri(v.coordinates.map(function(T,S){return mi({id:"".concat(x,"_").concat(S),coords:T},g)}))):console.warn("Unsupported GeoJson geometry type: ".concat(v.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(A,g){var v=g.coords,x=g.capColor,T=g.capMaterial,S=g.sideColor,w=g.sideMaterial,C=g.strokeColor,E=g.altitude,N=g.capCurvatureResolution,L=$i(A.children,2),B=L[0],I=L[1],F=!!C;I.visible=F;var P=!!(x||T),O=!!(S||w);yae(B.geometry.parameters||{},{polygonGeoJson:v,curvatureResolution:N,closedTop:P,includeSides:O})||(B.geometry&&B.geometry.dispose(),B.geometry=new Qb(v,0,qi,!1,P,O,N)),F&&(!I.geometry.parameters||I.geometry.parameters.geoJson.coordinates!==v||I.geometry.parameters.resolution!==N)&&(I.geometry&&I.geometry.dispose(),I.geometry=new L8({type:"Polygon",coordinates:v},qi,N));var G=O?0:-1,q=P?O?1:0:-1;if(G>=0&&(B.material[G]=w||A.__defaultSideMaterial),q>=0&&(B.material[q]=T||A.__defaultCapMaterial),[[!w&&S,G],[!T&&x,q]].forEach(function(ue){var le=$i(ue,2),de=le[0],Te=le[1];if(!(!de||Te<0)){var Qe=B.material[Te],Ye=ya(de);Qe.color.set(xl(de)),Qe.transparent=Ye<1,Qe.opacity=Ye}}),F){var j=I.material,Y=ya(C);j.color.set(xl(C)),j.transparent=Y<1,j.opacity=Y}var $={alt:E},Q=function(le){var de=A.__currentTargetD=le,Te=de.alt;B.scale.x=B.scale.y=B.scale.z=1+Te,F&&(I.scale.x=I.scale.y=I.scale.z=1+Te+1e-4),cae(A.__defaultSideMaterial,function(Qe){return Qe.uSurfaceRadius.value=qi/(Te+1)})},ee=A.__currentTargetD||Object.assign({},$,{alt:-.001});Object.keys($).some(function(ue){return ee[ue]!==$[ue]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ee.alt===$.alt?Q($):e.tweenGroup.add(new Ns(ee).to($,e.polygonsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(Q).start()))}).digest(d)}});function yae(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=$i(n,2),s=r[0],o=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],o)})}var Sf=window.THREE?window.THREE:{BufferGeometry:ui,DoubleSide:xr,Mesh:si,MeshLambertMaterial:du,Vector3:te},SC=Object.assign({},Hb),TC=SC.BufferGeometryUtils||SC,rD=kr({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new Sf.Mesh(void 0,new Sf.MeshLambertMaterial({side:Sf.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=Ke(e.hexPolygonGeoJsonGeometry),n=Ke(e.hexPolygonColor),r=Ke(e.hexPolygonAltitude),s=Ke(e.hexPolygonResolution),o=Ke(e.hexPolygonMargin),a=Ke(e.hexPolygonUseDots),l=Ke(e.hexPolygonCurvatureResolution),u=Ke(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(d,A){var g=t(A),v=s(A),x=r(A),T=Math.max(0,Math.min(1,+o(A))),S=a(A),w=l(A),C=u(A),E=n(A),N=ya(E);d.material.color.set(xl(E)),d.material.transparent=N<1,d.material.opacity=N;var L={alt:x,margin:T,curvatureResolution:w},B={geoJson:g,h3Res:v},I=d.__currentTargetD||Object.assign({},L,{alt:-.001}),F=d.__currentMemD||B;if(Object.keys(L).some(function(q){return I[q]!==L[q]})||Object.keys(B).some(function(q){return F[q]!==B[q]})){d.__currentMemD=B;var P=[];g.type==="Polygon"?VE(g.coordinates,v,!0).forEach(function(q){return P.push(q)}):g.type==="MultiPolygon"?g.coordinates.forEach(function(q){return VE(q,v,!0).forEach(function(j){return P.push(j)})}):console.warn("Unsupported GeoJson geometry type: ".concat(g.type,". Skipping geometry..."));var O=P.map(function(q){var j=J8(q),Y=e5(q,!0).reverse(),$=j[1];return Y.forEach(function(Q){var ee=Q[0];Math.abs($-ee)>170&&(Q[0]+=$>ee?360:-360)}),{h3Idx:q,hexCenter:j,hexGeoJson:Y}}),G=function(j){var Y=d.__currentTargetD=j,$=Y.alt,Q=Y.margin,ee=Y.curvatureResolution;d.geometry&&d.geometry.dispose(),d.geometry=O.length?(TC.mergeGeometries||TC.mergeBufferGeometries)(O.map(function(ue){var le=$i(ue.hexCenter,2),de=le[0],Te=le[1];if(S){var Qe=Jo(de,Te,$),Ye=Jo(ue.hexGeoJson[0][1],ue.hexGeoJson[0][0],$),Et=.85*(1-Q)*new Sf.Vector3(Qe.x,Qe.y,Qe.z).distanceTo(new Sf.Vector3(Ye.x,Ye.y,Ye.z)),at=new X1(Et,C);return at.rotateX(Qc(-de)),at.rotateY(Qc(Te)),at.translate(Qe.x,Qe.y,Qe.z),at}else{var ve=function(Ct,et,qt){return Ct-(Ct-et)*qt},Re=Q===0?ue.hexGeoJson:ue.hexGeoJson.map(function(Je){var Ct=$i(Je,2),et=Ct[0],qt=Ct[1];return[[et,Te],[qt,de]].map(function(en){var zt=$i(en,2),Oe=zt[0],tt=zt[1];return ve(Oe,tt,Q)})});return new Qb([Re],qi,qi*(1+$),!1,!0,!1,ee)}})):new Sf.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?G(L):e.tweenGroup.add(new Ns(I).to(L,e.hexPolygonsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(G).start())}}).digest(e.hexPolygonsData)}}),bae=window.THREE?window.THREE:{Vector3:te};function Sae(i,e){var t=function(o,a){var l=o[o.length-1];return[].concat(Ri(o),Ri(Array(a-o.length).fill(l)))},n=Math.max(i.length,e.length),r=vz.apply(void 0,Ri([i,e].map(function(s){return s.map(function(o){var a=o.x,l=o.y,u=o.z;return[a,l,u]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(o){var a=$i(o,3),l=a[0],u=a[1],d=a[2];return new bae.Vector3(l,u,d)})}}var Vc=window.THREE?window.THREE:{BufferGeometry:ui,Color:Gt,Group:so,Line:j1,NormalBlending:js,ShaderMaterial:Rs,Vector3:te},Tae=Id.default||Id,sD=kr({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Tae,sharedMaterial:new Vc.ShaderMaterial(mi(mi({},Z7()),{},{transparent:!0,blending:Vc.NormalBlending}))}},init:function(e,t){Li(e),t.scene=e,t.dataMapper=new mo(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Vc.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var o=$i(s,2),a=o[1];return a}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var o=s.children[0],a=o.__dashAnimateStep*r;if(o.type==="Line"){var l=o.material.uniforms.dashTranslate.value%1e9;o.material.uniforms.dashTranslate.value=l+a}else if(o.type==="Line2"){for(var u=o.material.dashOffset-a,d=o.material.dashSize+o.material.gapSize;u<=-d;)u+=d;o.material.dashOffset=u}})})},update:function(e){var t=Ke(e.pathPoints),n=Ke(e.pathPointLat),r=Ke(e.pathPointLng),s=Ke(e.pathPointAlt),o=Ke(e.pathStroke),a=Ke(e.pathColor),l=Ke(e.pathDashLength),u=Ke(e.pathDashGap),d=Ke(e.pathDashInitialGap),A=Ke(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(S,w){var C=o(w),E=C!=null;if(!S.children.length||E===(S.children[0].type==="Line")){Li(S);var N=E?new Foe(new H7,new ES):new Vc.Line(new Vc.BufferGeometry,e.sharedMaterial.clone());S.add(N)}var L=S.children[0],B=v(t(w),n,r,s,e.pathResolution),I=A(w);if(L.__dashAnimateStep=I>0?1e3/I:0,E){L.material.resolution=e.rendererSize;{var O=l(w),G=u(w),q=d(w);L.material.dashed=G>0,L.material.dashed?L.material.defines.USE_DASH="":delete L.material.defines.USE_DASH,L.material.dashed&&(L.material.dashScale=1/g(B),L.material.dashSize=O,L.material.gapSize=G,L.material.dashOffset=-q)}{var j=a(w);if(j instanceof Array){var Y=x(a(w),B.length-1,1,!1);L.geometry.setColors(Y.array),L.material.vertexColors=!0}else{var $=j,Q=ya($);L.material.color=new Vc.Color(xl($)),L.material.transparent=Q<1,L.material.opacity=Q,L.material.vertexColors=!1}}L.material.needsUpdate=!0}else{Object.assign(L.material.uniforms,{dashSize:{value:l(w)},gapSize:{value:u(w)},dashOffset:{value:d(w)}});var F=x(a(w),B.length),P=T(B.length,1,!0);L.geometry.setAttribute("color",F),L.geometry.setAttribute("relDistance",P)}var ee=Sae(S.__currentTargetD&&S.__currentTargetD.points||[B[0]],B),ue=function(Qe){var Ye=S.__currentTargetD=Qe,Et=Ye.stroke,at=Ye.interpolK,ve=S.__currentTargetD.points=ee(at);if(E){var Re;L.geometry.setPositions((Re=[]).concat.apply(Re,Ri(ve.map(function(Je){var Ct=Je.x,et=Je.y,qt=Je.z;return[Ct,et,qt]})))),L.material.linewidth=Et,L.material.dashed&&L.computeLineDistances()}else L.geometry.setFromPoints(ve),L.geometry.computeBoundingSphere()},le={stroke:C,interpolK:1},de=Object.assign({},S.__currentTargetD||le,{interpolK:0});Object.keys(le).some(function(Te){return de[Te]!==le[Te]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?ue(le):e.tweenGroup.add(new Ns(de).to(le,e.pathTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(ue).start()))}).digest(e.pathsData);function g(S){var w=0,C;return S.forEach(function(E){C&&(w+=C.distanceTo(E)),C=E}),w}function v(S,w,C,E,N){var L=function(P,O,G){for(var q=[],j=1;j<=G;j++)q.push(P+(O-P)*j/(G+1));return q},B=function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=[],q=null;return P.forEach(function(j){if(q){for(;Math.abs(q[1]-j[1])>180;)q[1]+=360*(q[1]O)for(var $=Math.floor(Y/O),Q=L(q[0],j[0],$),ee=L(q[1],j[1],$),ue=L(q[2],j[2],$),le=0,de=Q.length;le2&&arguments[2]!==void 0?arguments[2]:1,E=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,N=w+1,L;if(S instanceof Array||S instanceof Function){var B=S instanceof Array?tu().domain(S.map(function(j,Y){return Y/(S.length-1)})).range(S):S;L=function(Y){return oc(B(Y),E,!0)}}else{var I=oc(S,E,!0);L=function(){return I}}for(var F=[],P=0,O=N;P1&&arguments[1]!==void 0?arguments[1]:1,C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,E=S+1,N=[],L=0,B=E;L0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;F_(this,e),t=U_(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],o=0;o<=r;o++){var a=(o/r-.25)*Math.PI*2;s.push({x:Math.cos(a)*n,y:Math.sin(a)*n,z:0})}return t.setFromPoints(s),t}return k_(e,i),O_(e)}(wae.BufferGeometry),wf=window.THREE?window.THREE:{Color:Gt,Group:so,Line:j1,LineBasicMaterial:jd,Vector3:te},Eae=Id.default||Id,lD=kr({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new wf.Group;return s.__globeObjType="ring",s}),t.ticker=new Eae,t.ticker.onTick.add(function(s){if(t.ringsData.length){var o=Ke(t.ringColor),a=Ke(t.ringAltitude),l=Ke(t.ringMaxRadius),u=Ke(t.ringPropagationSpeed),d=Ke(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(A){var g=$i(A,2),v=g[1];return v}).forEach(function(A){var g=$i(A,2),v=g[0],x=g[1];if((x.__nextRingTime||0)<=s){var T=d(v)/1e3;x.__nextRingTime=s+(T<=0?1/0:T);var S=new wf.Line(new Mae(1,t.ringResolution),new wf.LineBasicMaterial),w=o(v),C=w instanceof Array||w instanceof Function,E;C?w instanceof Array?(E=tu().domain(w.map(function(G,q){return q/(w.length-1)})).range(w),S.material.transparent=w.some(function(G){return ya(G)<1})):(E=w,S.material.transparent=!0):(S.material.color=new wf.Color(xl(w)),aae(S.material,ya(w)));var N=qi*(1+a(v)),L=l(v),B=L*Math.PI/180,I=u(v),F=I<=0,P=function(q){var j=q.t,Y=(F?1-j:j)*B;if(S.scale.x=S.scale.y=N*Math.sin(Y),S.position.z=N*(1-Math.cos(Y)),C){var $=E(j);S.material.color=new wf.Color(xl($)),S.material.transparent&&(S.material.opacity=ya($))}};if(I===0)P({t:0}),x.add(S);else{var O=Math.abs(L/I)*1e3;t.tweenGroup.add(new Ns({t:0}).to({t:1},O).onUpdate(P).onStart(function(){return x.add(S)}).onComplete(function(){x.remove(S),NS(S)}).start())}}})}})},update:function(e){var t=Ke(e.ringLat),n=Ke(e.ringLng),r=Ke(e.ringAltitude),s=e.scene.localToWorld(new wf.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(o,a){var l=t(a),u=n(a),d=r(a);Object.assign(o.position,Jo(l,u,d)),o.lookAt(s)}).digest(e.ringsData)}}),Cae={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},Rae="normal",Nae=1189,Pae=-100,Dae="normal",Lae={yMin:-334,xMin:-111,yMax:1189,xMax:1672},Iae=1e3,Bae={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r +\r +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r +\r +The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r +\r +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r +\r +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r +\r +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r +\r +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Uae=-334,Fae="Helvetiker",Oae=1522,kae=50,Vae={glyphs:Cae,cssFontWeight:Rae,ascender:Nae,underlinePosition:Pae,cssFontStyle:Dae,boundingBox:Lae,resolution:Iae,original_font_information:Bae,descender:Uae,familyName:Fae,lineHeight:Oae,underlineThickness:kae},ha=mi(mi({},window.THREE?window.THREE:{BoxGeometry:lc,CircleGeometry:X1,DoubleSide:xr,Group:so,Mesh:si,MeshLambertMaterial:du,TextGeometry:dC,Vector3:te}),{},{Font:Ooe,TextGeometry:dC}),uD=kr({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Vae,onChange:function(e,t){t.font=new ha.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r;var s=new ha.CircleGeometry(1,32);t.dataMapper=new mo(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var o=new ha.MeshLambertMaterial;o.side=xr;var a=new ha.Group;a.add(new ha.Mesh(s,o));var l=new ha.Mesh(void 0,o);a.add(l);var u=new ha.Mesh;return u.visible=!1,l.add(u),a.__globeObjType="label",a})},update:function(e){var t=Ke(e.labelLat),n=Ke(e.labelLng),r=Ke(e.labelAltitude),s=Ke(e.labelText),o=Ke(e.labelSize),a=Ke(e.labelRotation),l=Ke(e.labelColor),u=Ke(e.labelIncludeDot),d=Ke(e.labelDotRadius),A=Ke(e.labelDotOrientation),g=new Set(["right","top","bottom"]),v=2*Math.PI*qi/360;e.dataMapper.onUpdateObj(function(x,T){var S=$i(x.children,2),w=S[0],C=S[1],E=$i(C.children,1),N=E[0],L=l(T),B=ya(L);C.material.color.set(xl(L)),C.material.transparent=B<1,C.material.opacity=B;var I=u(T),F=A(T);!I||!g.has(F)&&(F="bottom");var P=I?+d(T)*v:1e-12;w.scale.x=w.scale.y=P;var O=+o(T)*v;if(C.geometry&&C.geometry.dispose(),C.geometry=new ha.TextGeometry(s(T),{font:e.font,size:O,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),N.geometry&&N.geometry.dispose(),C.geometry.computeBoundingBox(),N.geometry=CS(ha.BoxGeometry,Ri(new ha.Vector3().subVectors(C.geometry.boundingBox.max,C.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),F!=="right"&&C.geometry.center(),I){var G=P+O/2;F==="right"&&(C.position.x=G),C.position.y={right:-O/2,top:G+O/2,bottom:-G-O/2}[F]}var q=function(Q){var ee=x.__currentTargetD=Q,ue=ee.lat,le=ee.lng,de=ee.alt,Te=ee.rot,Qe=ee.scale;Object.assign(x.position,Jo(ue,le,de)),x.lookAt(e.scene.localToWorld(new ha.Vector3(0,0,0))),x.rotateY(Math.PI),x.rotateZ(-Te*Math.PI/180),x.scale.x=x.scale.y=x.scale.z=Qe},j={lat:+t(T),lng:+n(T),alt:+r(T),rot:+a(T),scale:1},Y=x.__currentTargetD||Object.assign({},j,{scale:1e-12});Object.keys(j).some(function($){return Y[$]!==j[$]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?q(j):e.tweenGroup.add(new Ns(Y).to(j,e.labelsTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(q).start()))}).digest(e.labelsData)}}),Gae=mi(mi({},window.THREE?window.THREE:{}),{},{CSS2DObject:zG}),cD=kr({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=$i(r,2),o=s[1];return o}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;Li(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new mo(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var o=Ke(t.htmlElement)(s),a=new Gae.CSS2DObject(o);return a.__globeObjType="html",a})},update:function(e,t){var n=this,r=Ke(e.htmlLat),s=Ke(e.htmlLng),o=Ke(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(a,l){var u=function(g){var v=a.__currentTargetD=g,x=v.alt,T=v.lat,S=v.lng;Object.assign(a.position,Jo(T,S,x)),n.updateObjVisibility(a)},d={lat:+r(l),lng:+s(l),alt:+o(l)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!a.__currentTargetD?u(d):e.tweenGroup.add(new Ns(a.__currentTargetD).to(d,e.htmlTransitionDuration).easing(Lr.Quadratic.InOut).onUpdate(u).start())}).digest(e.htmlElementsData)}}),sg=window.THREE?window.THREE:{Group:so,Mesh:si,MeshLambertMaterial:du,SphereGeometry:Tl},hD=kr({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new sg.Mesh(new sg.SphereGeometry(1,16,8),new sg.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){Li(e),t.scene=e,t.dataMapper=new mo(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=Ke(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new sg.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=Ke(e.objectLat),r=Ke(e.objectLng),s=Ke(e.objectAltitude),o=Ke(e.objectFacesSurface),a=Ke(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var d=+n(u),A=+r(u),g=+s(u);Object.assign(l.position,Jo(d,A,g)),o(u)?l.setRotationFromEuler(new fs(Qc(-d),Qc(A),0,"YXZ")):l.rotation.set(0,0,0);var v=l.children[0],x=a(u);x&&v.setRotationFromEuler(new fs(Qc(x.x||0),Qc(x.y||0),Qc(x.z||0)))}).digest(e.objectsData)}}),fD=kr({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){Li(e),t.scene=e,t.dataMapper=new mo(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=Ke(t.customThreeObject)(n,qi);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||Li(e.scene);var n=Ke(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,qi)}).digest(e.customLayerData)}}),og=window.THREE?window.THREE:{Camera:hp,Group:so,Vector2:qe,Vector3:te},qae=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],dD=Qs("globeLayer",Y7),zae=Object.assign.apply(Object,Ri(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Kr({},i,dD.linkProp(i))}))),Hae=Object.assign.apply(Object,Ri(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Kr({},i,dD.linkMethod(i))}))),Wae=Qs("pointsLayer",K7),$ae=Object.assign.apply(Object,Ri(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Kr({},i,Wae.linkProp(i))}))),jae=Qs("arcsLayer",J7),Xae=Object.assign.apply(Object,Ri(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Kr({},i,jae.linkProp(i))}))),Qae=Qs("hexBinLayer",eD),Yae=Object.assign.apply(Object,Ri(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Kr({},i,Qae.linkProp(i))}))),Kae=Qs("heatmapsLayer",nD),Zae=Object.assign.apply(Object,Ri(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Kr({},i,Kae.linkProp(i))}))),Jae=Qs("hexedPolygonsLayer",rD),ele=Object.assign.apply(Object,Ri(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Kr({},i,Jae.linkProp(i))}))),tle=Qs("polygonsLayer",iD),nle=Object.assign.apply(Object,Ri(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Kr({},i,tle.linkProp(i))}))),ile=Qs("pathsLayer",sD),rle=Object.assign.apply(Object,Ri(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Kr({},i,ile.linkProp(i))}))),sle=Qs("tilesLayer",oD),ole=Object.assign.apply(Object,Ri(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Kr({},i,sle.linkProp(i))}))),ale=Qs("particlesLayer",aD),lle=Object.assign.apply(Object,Ri(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Kr({},i,ale.linkProp(i))}))),ule=Qs("ringsLayer",lD),cle=Object.assign.apply(Object,Ri(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Kr({},i,ule.linkProp(i))}))),hle=Qs("labelsLayer",uD),fle=Object.assign.apply(Object,Ri(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Kr({},i,hle.linkProp(i))}))),dle=Qs("htmlElementsLayer",cD),Ale=Object.assign.apply(Object,Ri(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Kr({},i,dle.linkProp(i))}))),ple=Qs("objectsLayer",hD),mle=Object.assign.apply(Object,Ri(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Kr({},i,ple.linkProp(i))}))),gle=Qs("customLayer",fD),_le=Object.assign.apply(Object,Ri(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Kr({},i,gle.linkProp(i))}))),vle=kr({props:mi(mi(mi(mi(mi(mi(mi(mi(mi(mi(mi(mi(mi(mi(mi({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new og.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},zae),$ae),Xae),Yae),Zae),nle),ele),rle),ole),lle),cle),fle),Ale),mle),_le),methods:mi({getGlobeRadius:mC,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=function(r){function s(){var o;F_(this,s);for(var a=arguments.length,l=new Array(a),u=0;uwC&&(this.dispatchEvent(jv),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>wC||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(jv),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=fi.NONE,this.keyState=fi.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(jv),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Fu.copy(this._panEnd).sub(this._panStart),Fu.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;Fu.x*=e,Fu.y*=t}Fu.multiplyScalar(this._eye.length()*this.panSpeed),lg.copy(this._eye).cross(this.object.up).setLength(Fu.x),lg.add(ble.copy(this.object.up).setLength(Fu.y)),this.object.position.add(lg),this.target.add(lg),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Fu.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){cg.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=cg.length();e?(this._eye.copy(this.object.position).sub(this.target),MC.copy(this._eye).normalize(),ug.copy(this.object.up).normalize(),Qv.crossVectors(ug,MC).normalize(),ug.setLength(this._moveCurr.y-this._movePrev.y),Qv.setLength(this._moveCurr.x-this._movePrev.x),cg.copy(ug.add(Qv)),Xv.crossVectors(cg,this._eye).normalize(),e*=this.rotateSpeed,Mf.setFromAxisAngle(Xv,e),this._eye.applyQuaternion(Mf),this.object.up.applyQuaternion(Mf),this._lastAxis.copy(Xv),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Mf.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Mf),this.object.up.applyQuaternion(Mf)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===fi.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=Md.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=Md.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 ag.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),ag}_getMouseOnCircle(e,t){return ag.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),ag}_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&&(n-=Zs),r<-Math.PI?r+=Zs:r>Math.PI&&(r-=Zs),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 s=!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),s=o!=this._spherical.radius}if(Ur.setFromSpherical(this._spherical),Ur.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ur),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=Ur.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new te(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const u=new te(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(a),this.object.updateMatrixWorld(),o=Ur.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):(hg.origin.copy(this.object.position),hg.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(hg.direction))Yv||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yv||this._lastTargetPosition.distanceToSquared(this.target)>Yv?(this.dispatchEvent(EC),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Zs/60*this.autoRotateSpeed*e:Zs/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){Ur.setFromMatrixColumn(t,0),Ur.multiplyScalar(-e),this._panOffset.add(Ur)}_panUp(e,t){this.screenSpacePanning===!0?Ur.setFromMatrixColumn(t,1):(Ur.setFromMatrixColumn(t,0),Ur.crossVectors(this.object.up,Ur)),Ur.multiplyScalar(e),this._panOffset.add(Ur)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Ur.copy(r).sub(this.target);let s=Ur.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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 n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/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(Zs*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zs*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(Zs*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(-Zs*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(Zs*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(-Zs*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_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 n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Zs*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zs*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),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;tRC||8*(1-this._lastQuaternion.dot(t.quaternion))>RC)&&(this.dispatchEvent(Zle),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 eue(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 tue(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 nue(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 iue(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function rue(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 sue(){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 oue(i){this.enabled!==!1&&i.preventDefault()}const aue={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 V_{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 lue=new Xd(-1,1,1,-1,0,1);class uue extends ui{constructor(){super(),this.setAttribute("position",new Jn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Jn([0,2,0,0,2,0],2))}}const cue=new uue;class hue{constructor(e){this._mesh=new si(cue,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,lue)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class fue extends V_{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Rs?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=W1.clone(e.uniforms),this.material=new Rs({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 hue(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.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 PC extends V_{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class due extends V_{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class Aue{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new qe);this._width=n.width,this._height=n.height,t=new xa(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:zi}),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 fue(aue),this.copyPass.material.blending=$s,this.clock=new NR}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&&r<1?(a=s,l=o):r>=1&&r<2?(a=o,l=s):r>=2&&r<3?(l=s,u=o):r>=3&&r<4?(l=o,u=s):r>=4&&r<5?(a=o,u=s):r>=5&&r<6&&(a=s,u=o);var d=t-s/2,A=a+d,g=l+d,v=u+d;return n(A,g,v)}var DC={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 yue(i){if(typeof i!="string")return i;var e=i.toLowerCase();return DC[e]?"#"+DC[e]:i}var bue=/^#[a-fA-F0-9]{6}$/,Sue=/^#[a-fA-F0-9]{8}$/,Tue=/^#[a-fA-F0-9]{3}$/,wue=/^#[a-fA-F0-9]{4}$/,Zv=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Mue=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Eue=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,Cue=/^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 Gd(i){if(typeof i!="string")throw new rl(3);var e=yue(i);if(e.match(bue))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(Sue)){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(Tue))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(wue)){var n=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:n}}var r=Zv.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=Mue.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var o=Eue.exec(e);if(o){var a=parseInt(""+o[1],10),l=parseInt(""+o[2],10)/100,u=parseInt(""+o[3],10)/100,d="rgb("+F1(a,l,u)+")",A=Zv.exec(d);if(!A)throw new rl(4,e,d);return{red:parseInt(""+A[1],10),green:parseInt(""+A[2],10),blue:parseInt(""+A[3],10)}}var g=Cue.exec(e.substring(0,50));if(g){var v=parseInt(""+g[1],10),x=parseInt(""+g[2],10)/100,T=parseInt(""+g[3],10)/100,S="rgb("+F1(v,x,T)+")",w=Zv.exec(S);if(!w)throw new rl(4,e,S);return{red:parseInt(""+w[1],10),green:parseInt(""+w[2],10),blue:parseInt(""+w[3],10),alpha:parseFloat(""+g[4])>1?parseFloat(""+g[4])/100:parseFloat(""+g[4])}}throw new rl(5)}function Rue(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),o=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:o,alpha:i.alpha}:{hue:0,saturation:0,lightness:o};var a,l=r-s,u=o>.5?l/(2-r-s):l/(r+s);switch(r){case e:a=(t-n)/l+(t=1?gD(i.hue,i.saturation,i.lightness):"rgba("+F1(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new rl(2)}function _D(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return Ny("#"+Hc(i)+Hc(e)+Hc(t));if(typeof i=="object"&&e===void 0&&t===void 0)return Ny("#"+Hc(i.red)+Hc(i.green)+Hc(i.blue));throw new rl(6)}function G_(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?_D(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new rl(7)}var Iue=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Bue=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Uue=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Fue=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function pc(i){if(typeof i!="object")throw new rl(8);if(Bue(i))return G_(i);if(Iue(i))return _D(i);if(Fue(i))return Lue(i);if(Uue(i))return Due(i);throw new rl(8)}function vD(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):vD(i,e,r)}}function Bo(i){return vD(i,i.length,[])}function Oue(i,e){if(e==="transparent")return e;var t=Ac(e);return pc(po({},t,{hue:t.hue+parseFloat(i)}))}Bo(Oue);function tA(i,e,t){return Math.max(i,Math.min(e,t))}function kue(i,e){if(e==="transparent")return e;var t=Ac(e);return pc(po({},t,{lightness:tA(0,1,t.lightness-parseFloat(i))}))}Bo(kue);function Vue(i,e){if(e==="transparent")return e;var t=Ac(e);return pc(po({},t,{saturation:tA(0,1,t.saturation-parseFloat(i))}))}Bo(Vue);function Gue(i,e){if(e==="transparent")return e;var t=Ac(e);return pc(po({},t,{lightness:tA(0,1,t.lightness+parseFloat(i))}))}Bo(Gue);function que(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=Gd(e),r=po({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=Gd(t),o=po({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),a=r.alpha-o.alpha,l=parseFloat(i)*2-1,u=l*a===-1?l:l+a,d=1+l*a,A=(u/d+1)/2,g=1-A,v={red:Math.floor(r.red*A+o.red*g),green:Math.floor(r.green*A+o.green*g),blue:Math.floor(r.blue*A+o.blue*g),alpha:r.alpha*parseFloat(i)+o.alpha*(1-parseFloat(i))};return G_(v)}var zue=Bo(que),xD=zue;function Hue(i,e){if(e==="transparent")return e;var t=Gd(e),n=typeof t.alpha=="number"?t.alpha:1,r=po({},t,{alpha:tA(0,1,(n*100+parseFloat(i)*100)/100)});return G_(r)}var Wue=Bo(Hue),$ue=Wue;function jue(i,e){if(e==="transparent")return e;var t=Ac(e);return pc(po({},t,{saturation:tA(0,1,t.saturation+parseFloat(i))}))}Bo(jue);function Xue(i,e){return e==="transparent"?e:pc(po({},Ac(e),{hue:parseFloat(i)}))}Bo(Xue);function Que(i,e){return e==="transparent"?e:pc(po({},Ac(e),{lightness:parseFloat(i)}))}Bo(Que);function Yue(i,e){return e==="transparent"?e:pc(po({},Ac(e),{saturation:parseFloat(i)}))}Bo(Yue);function Kue(i,e){return e==="transparent"?e:xD(parseFloat(i),"rgb(0, 0, 0)",e)}Bo(Kue);function Zue(i,e){return e==="transparent"?e:xD(parseFloat(i),"rgb(255, 255, 255)",e)}Bo(Zue);function Jue(i,e){if(e==="transparent")return e;var t=Gd(e),n=typeof t.alpha=="number"?t.alpha:1,r=po({},t,{alpha:tA(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return G_(r)}Bo(Jue);var Py="http://www.w3.org/1999/xhtml";const LC={svg:"http://www.w3.org/2000/svg",xhtml:Py,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function yD(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),LC.hasOwnProperty(e)?{space:LC[e],local:i}:i}function ece(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Py&&e.documentElement.namespaceURI===Py?e.createElement(i):e.createElementNS(t,i)}}function tce(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function bD(i){var e=yD(i);return(e.local?tce:ece)(e)}function nce(){}function SD(i){return i==null?nce:function(){return this.querySelector(i)}}function ice(i){typeof i!="function"&&(i=SD(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r=E&&(E=C+1);!(L=S[E])&&++E=0;)(o=n[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Nce(i){i||(i=Pce);function e(A,g){return A&&g?i(A.__data__,g.__data__):!A-!g}for(var t=this._groups,n=t.length,r=new Array(n),s=0;se?1:i>=e?0:NaN}function Dce(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function Lce(){return Array.from(this)}function Ice(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?Wce:typeof e=="function"?jce:$ce)(i,e,t??"")):Qce(this.node(),i)}function Qce(i,e){return i.style.getPropertyValue(e)||MD(i).getComputedStyle(i,null).getPropertyValue(e)}function Yce(i){return function(){delete this[i]}}function Kce(i,e){return function(){this[i]=e}}function Zce(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function Jce(i,e){return arguments.length>1?this.each((e==null?Yce:typeof e=="function"?Zce:Kce)(i,e)):this.node()[i]}function ED(i){return i.trim().split(/^|\s+/)}function BS(i){return i.classList||new CD(i)}function CD(i){this._node=i,this._names=ED(i.getAttribute("class")||"")}CD.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function RD(i,e){for(var t=BS(i),n=-1,r=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Ehe(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t2&&(o.children=arguments.length>3?Cp.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)o[s]===void 0&&(o[s]=i.defaultProps[s]);return p0(i,o,n,r,null)}function p0(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++DD,__i:-1,__u:0};return r==null&&Zi.vnode!=null&&Zi.vnode(s),s}function z_(i){return i.children}function Dg(i,e){this.props=i,this.context=e}function qd(i,e){if(e==null)return i.__?qd(i.__,i.__i+1):null;for(var t;ea&&Yc.sort(BD),i=Yc.shift(),a=Yc.length,i.__d&&(t=void 0,n=void 0,r=(n=(e=i).__v).__e,s=[],o=[],e.__P&&((t=sl({},n)).__v=n.__v+1,Zi.vnode&&Zi.vnode(t),OS(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,s,r??qd(n),!!(32&n.__u),o),t.__v=n.__v,t.__.__k[t.__i]=t,GD(s,t,o),n.__e=n.__=null,t.__e!=r&&OD(t)));k1.__r=0}function kD(i,e,t,n,r,s,o,a,l,u,d){var A,g,v,x,T,S,w,C=n&&n.__k||FD,E=e.length;for(l=Ghe(t,e,C,l,E),A=0;A0?o=i.__k[s]=p0(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[s]=o,l=s+g,o.__=i,o.__b=i.__b+1,a=null,(u=o.__i=qhe(o,t,l,A))!=-1&&(A--,(a=t[u])&&(a.__u|=2)),a==null||a.__v==null?(u==-1&&(r>d?g--:rl?g--:g++,o.__u|=4))):i.__k[s]=null;if(A)for(s=0;s(d?1:0)){for(r=t-1,s=t+1;r>=0||s=0?r--:s++])!=null&&!(2&u.__u)&&a==u.key&&l==u.type)return o}return-1}function UC(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||khe.test(e)?t:t+"px"}function fg(i,e,t,n,r){var s,o;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||UC(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||UC(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(UD,"$1")),o=e.toLowerCase(),e=o in i||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=US,i.addEventListener(e,s?Ly:Dy,s)):i.removeEventListener(e,s?Ly:Dy,s);else{if(r=="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 i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function FC(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=US++;else if(e.t0?i:q_(i)?i.map(qD):sl({},i)}function zhe(i,e,t,n,r,s,o,a,l){var u,d,A,g,v,x,T,S=t.props||tp,w=e.props,C=e.type;if(C=="svg"?r="http://www.w3.org/2000/svg":C=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(u=0;u2&&(a.children=arguments.length>3?Cp.call(arguments,2):t),p0(i.type,a,n||i.key,r||i.ref,null)}Cp=FD.slice,Zi={__e:function(i,e,t,n){for(var r,s,o;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),o=r.__d),o)return r.__E=r}catch(a){i=a}throw i}},DD=0,LD=function(i){return i!=null&&i.constructor===void 0},Dg.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=sl({},this.state),typeof i=="function"&&(i=i(sl({},t),this.props)),i&&sl(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),BC(this))},Dg.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),BC(this))},Dg.prototype.render=z_,Yc=[],ID=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,BD=function(i,e){return i.__v.__b-e.__v.__b},k1.__r=0,UD=/(PointerCapture)$|Capture$/i,US=0,Dy=FC(!1),Ly=FC(!0);function OC(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var rfe=`.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; +} +`;ife(rfe);var sfe=kr({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,o=!!e&&V1(e)==="object"&&!!e.node&&typeof e.node=="function",a=Uhe(o?e.node():e);a.style("position")==="static"&&a.style("position","relative"),t.tooltipEl=a.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(u){var d=Khe(u,2),A=d[0],g=d[1];return t.tooltipEl.style(A,g)}),t.tooltipEl.style("left","-10000px").style("display","none");var l="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,a.on("mousemove.".concat(l),function(u){t.mouseInside=!0;var d=Ohe(u),A=a.node(),g=A.offsetWidth,v=A.offsetHeight,x=[t.offsetX===null||t.offsetX===void 0?"-".concat(d[0]/g*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?v>130&&v-d[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",d[0]+"px").style("top",d[1]+"px").style("transform","translate(".concat(x.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),a.on("mouseover.".concat(l),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),a.on("mouseout.".concat(l),function(){t.mouseInside=!1,t.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):tfe(e.content)?(e.tooltipEl.text(""),nfe(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 ofe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var afe=`.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; +}`;ofe(afe);function Uy(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(o,a){return e.hoverOrderComparator(o.object,a.object)});var s=r.find(function(o){return e.hoverFilter(o.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Ke(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var o=t,a=n||{x:0,y:0,z:0};if(!r)d(o),A(a);else{var l=Object.assign({},s.position),u=g();e.tweenGroup.add(new Ns(l).to(o,r).easing(Lr.Quadratic.Out).onUpdate(d).start()),e.tweenGroup.add(new Ns(u).to(a,r/3).easing(Lr.Quadratic.Out).onUpdate(A).start())}return this}return Object.assign({},s.position,{lookAt:g()});function d(v){var x=v.x,T=v.y,S=v.z;x!==void 0&&(s.position.x=x),T!==void 0&&(s.position.y=T),S!==void 0&&(s.position.z=S)}function A(v){var x=new Qi.Vector3(v.x,v.y,v.z);e.controls.enabled&&e.controls.target?e.controls.target=x:s.lookAt(x)}function g(){return Object.assign(new Qi.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),o=3;o2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var o=new Qi.Vector3(0,0,0),a=Math.max.apply(Math,Gc(Object.entries(t).map(function(v){var x=pfe(v,2),T=x[0],S=x[1];return Math.max.apply(Math,Gc(S.map(function(w){return Math.abs(o[T]-w)})))})))*2,l=(1-r*2/e.height)*s.fov,u=a/Math.atan(l*Math.PI/180),d=u/s.aspect,A=Math.max(u,d);if(A>0){var g=o.clone().sub(s.position).normalize().multiplyScalar(-A);this.cameraPosition(g,o,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new Qi.Box3(new Qi.Vector3(0,0,0),new Qi.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Gc(["x","y","z"].map(function(s){return cfe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new Qi.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new Qi.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new Qi.Raycaster;return o.setFromCamera(s,e.camera),Object.assign({},o.ray.at(r,new Qi.Vector3))},intersectingObjects:function(e,t,n){var r=new Qi.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new Qi.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.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}},stateInit:function(){return{scene:new Qi.Scene,camera:new Qi.PerspectiveCamera,clock:new Qi.Clock,tweenGroup:new J1,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,o=n.useWebGPU,a=o===void 0?!1:o,l=n.rendererConfig,u=l===void 0?{}:l,d=n.extraRenderers,A=d===void 0?[]:d,g=n.waitForLoadComplete,v=g===void 0?!0:g;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"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new sfe(t.container),t.pointerPos=new Qi.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(x){return t.container.addEventListener(x,function(T){if(x==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&T.type==="pointermove"&&(T.pressure>0||t.isPointerPressed)&&(T.pointerType==="mouse"||T.movementX===void 0||[T.movementX,T.movementY].some(function(C){return Math.abs(C)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var S=w(t.container);t.pointerPos.x=T.pageX-S.left,t.pointerPos.y=T.pageY-S.top}function w(C){var E=C.getBoundingClientRect(),N=window.pageXOffset||document.documentElement.scrollLeft,L=window.pageYOffset||document.documentElement.scrollTop;return{top:E.top+L,left:E.left+N}}},{passive:!0})}),t.container.addEventListener("pointerup",function(x){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){x.button===0&&t.onClick(t.hoverObj||null,x,t.intersection),x.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,x,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(x){t.onRightClick&&x.preventDefault()}),t.renderer=new(a?q7:Qi.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},u)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=A,t.extraRenderers.forEach(function(x){x.domElement.style.position="absolute",x.domElement.style.top="0px",x.domElement.style.pointerEvents="none",t.container.appendChild(x.domElement)}),t.postProcessingComposer=new Aue(t.renderer),t.postProcessingComposer.addPass(new pue(t.scene,t.camera)),t.controls=new{trackball:Sle,orbit:kle,fly:Jle}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="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(Gc(t.extraRenderers)).forEach(function(x){return x.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 Qi.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!v,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Gc(e.extraRenderers)).forEach(function(v){return v.setSize(r,s)}),e.camera.aspect=r/s;var o=e.viewOffset.slice(0,2);o.some(function(v){return v})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Gc(o),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var a,l=e.width,u=e.height,d=e.viewOffset.slice(0,2);d.some(function(v){return v})?(a=e.camera).setViewOffset.apply(a,[l,u].concat(Gc(d),[l,u])):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 Qi.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var A=Gd(e.backgroundColor).alpha;A===void 0&&(A=1),e.renderer.setClearColor(new Qi.Color($ue(1,e.backgroundColor)),A)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Qi.TextureLoader().load(e.backgroundImageUrl,function(v){v.colorSpace=Qi.SRGBColorSpace,e.skysphere.material=new Qi.MeshBasicMaterial({map:v,side:Qi.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&g()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&g())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(v){return e.scene.remove(v)}),e.lights.forEach(function(v){return e.scene.add(v)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(v){return e.scene.remove(v)}),e.objects.forEach(function(v){return e.scene.add(v)}));function g(){e.loadComplete=e.scene.visible=!0}}});function _fe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var vfe=`.scene-container .clickable { + cursor: pointer; +}`;_fe(vfe);function Fy(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?a-1:0),u=1;u1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=o();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(l){return s[l]=+s[l]}),!n)a(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new Ns(r).to(s,n).easing(Lr.Cubic.InOut).onUpdate(a).start())}return this;function o(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function a(l){var u=l.lat,d=l.lng,A=l.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(u,d,A)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;s + ${T.name}
${T.type} + `}async function g(){try{r=await $I(n),t(0,s=""),a&&(a.pointsData(r),a.arcsData(r.filter(T=>T.destCoord)))}catch(T){t(0,s=T.message)}}function v(){if(!o)return;const T=new no({transparent:!0,opacity:.7}),S=new no({transparent:!0,opacity:.3,side:Ai}),w=o.clientWidth,C=Math.min(w,600);a=Lfe()(o).globeImageUrl(Bfe).globeMaterial(T).backgroundColor("rgba(0,0,0,0)").showAtmosphere(!1).width(w).height(C).pointsData(r).pointLat(N=>N.coord.lat).pointLng(N=>N.coord.lon).pointColor(d).pointRadius(Ufe).pointAltitude(.01).pointLabel(A).arcsData(r.filter(N=>N.destCoord)).arcStartLat(N=>N.coord.lat).arcStartLng(N=>N.coord.lon).arcEndLat(N=>N.destCoord.lat).arcEndLng(N=>N.destCoord.lon).arcColor(d).arcStroke(.5).arcDashLength(.4).arcDashGap(.2).arcDashAnimateTime(1500).arcLabel(A);const E=a.scene();if(E&&E.children){for(const N of E.children)if(N.type==="Mesh"&&N.__globeObjType==="globe"){const L=N.clone();L.material=S,E.add(L);break}}}bl(async()=>{await g(),v()}),bI(()=>{var T,S;if(a){try{(T=a.renderer())==null||T.dispose(),(S=a.controls())==null||S.dispose()}catch{}a=null}});function x(T){ex[T?"unshift":"push"](()=>{o=T,t(1,o)})}return i.$$set=T=>{"gameSlot"in T&&t(3,n=T.gameSlot)},i.$$.update=()=>{i.$$.dirty&8&&n&&g()},[s,o,u,n,x]}class Ofe extends Da{constructor(e){super(),Pa(this,e,Ffe,Ife,Ca,{gameSlot:3})}}function HC(i,e,t){const n=i.slice();return n[14]=e[t],n}function WC(i){let e,t;return{c(){e=ye("div"),t=ut(i[4]),ge(e,"class","error svelte-1gsu8dt")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&16&&Dt(t,n[4])},d(n){n&&ct(e)}}}function $C(i){var at;let e,t,n=i[1].title+"",r,s,o,a=i[1].time+"",l,u,d=((at=i[1].balance)==null?void 0:at.toLocaleString())+"",A,g,v,x,T,S,w,C,E,N,L,B,I,F,P,O,G,q,j,Y,$,Q,ee,ue,le=er(i[5]),de=[];for(let ve=0;ve{Qe[Je]=null}),ip()),~S?(w=Qe[S],w?w.p(ve,Re):(w=Qe[S]=Te[S](ve),w.c()),mr(w,1),w.m(T,null)):w=null),ve[3]?Et?Et.p(ve,Re):(Et=XC(ve),Et.c(),Et.m(E,null)):Et&&(Et.d(1),Et=null)},i(ve){Q||(mr(w),Q=!0)},o(ve){Pr(w),Q=!1},d(ve){ve&&(ct(e),ct(g),ct(v),ct(x),ct(T),ct(C),ct(E)),ta(de,ve),~S&&Qe[S].d(),Et&&Et.d(),ee=!1,uu(ue)}}}function jC(i){let e,t,n;function r(){return i[7](i[14])}return{c(){e=ye("button"),e.textContent=`${i[14].label}`,ge(e,"class","tab svelte-1gsu8dt"),Qr(e,"active",i[2]===i[14].id)},m(s,o){ht(s,e,o),t||(n=Mi(e,"click",r),t=!0)},p(s,o){i=s,o&36&&Qr(e,"active",i[2]===i[14].id)},d(s){s&&ct(e),t=!1,n()}}}function kfe(i){let e,t;return e=new Ofe({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function Vfe(i){let e,t;return e=new EB({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function Gfe(i){let e,t;return e=new TB({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function qfe(i){let e,t;return e=new vB({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function zfe(i){let e,t;return e=new AB({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function Hfe(i){let e,t;return e=new oB({props:{gameSlot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.gameSlot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function XC(i){let e,t;return{c(){e=ye("span"),t=ut(i[3]),ge(e,"class","status svelte-1gsu8dt")},m(n,r){ht(n,e,r),J(e,t)},p(n,r){r&8&&Dt(t,n[3])},d(n){n&&ct(e)}}}function Wfe(i){let e,t,n,r=i[4]&&WC(i),s=i[1]&&$C(i);return{c(){r&&r.c(),e=ke(),s&&s.c(),t=cu()},m(o,a){r&&r.m(o,a),ht(o,e,a),s&&s.m(o,a),ht(o,t,a),n=!0},p(o,[a]){o[4]?r?r.p(o,a):(r=WC(o),r.c(),r.m(e.parentNode,e)):r&&(r.d(1),r=null),o[1]?s?(s.p(o,a),a&2&&mr(s,1)):(s=$C(o),s.c(),mr(s,1),s.m(t.parentNode,t)):s&&(np(),Pr(s,1,1,()=>{s=null}),ip())},i(o){n||(mr(s),n=!0)},o(o){Pr(s),n=!1},d(o){o&&(ct(e),ct(t)),r&&r.d(o),s&&s.d(o)}}}function $fe(i,e,t){let{slot:n}=e,r=null,s="soldiers",o="",a="";const l=[{id:"soldiers",label:"Soldiers"},{id:"bases",label:"Bases"},{id:"craft",label:"Crafts"},{id:"transfers",label:"Transfers"},{id:"financials",label:"Financials"},{id:"globe",label:"Globe"}];async function u(){try{t(1,r=await NI(n)),t(4,a="")}catch(w){t(4,a=w.message)}}bl(u);async function d(w,C){try{t(3,o=w+"..."),await C(),t(3,o=w+" done!"),await u(),setTimeout(()=>t(3,o=""),2e3)}catch(E){t(3,o=""),t(4,a=E.message)}}const A=w=>t(2,s=w.id),g=()=>d("Healing",()=>GI(n)),v=()=>d("Completing",()=>qI(n)),x=()=>d("Speeding up",()=>zI(n)),T=()=>d("Reloading",()=>WI(n)),S=()=>d("Saving",()=>HI(n));return i.$$set=w=>{"slot"in w&&t(0,n=w.slot)},i.$$.update=()=>{i.$$.dirty&1&&n&&u()},[n,r,s,o,a,l,d,A,g,v,x,T,S]}class jfe extends Da{constructor(e){super(),Pa(this,e,$fe,Wfe,Ca,{slot:0})}}function Xfe(i){let e;return{c(){e=ye("div"),e.textContent="Select a savegame from the sidebar.",ge(e,"class","placeholder svelte-xxy1o3")},m(t,n){ht(t,e,n)},p:Bi,i:Bi,o:Bi,d(t){t&&ct(e)}}}function Qfe(i){let e,t;return e=new jfe({props:{slot:i[0]}}),{c(){Sl(e.$$.fragment)},m(n,r){Ra(e,n,r),t=!0},p(n,r){const s={};r&1&&(s.slot=n[0]),e.$set(s)},i(n){t||(mr(e.$$.fragment,n),t=!0)},o(n){Pr(e.$$.fragment,n),t=!1},d(n){Na(e,n)}}}function Yfe(i){let e,t,n,r,s,o,a,l,u,d,A;o=new QI({props:{selectedSlot:i[0]}}),o.$on("select",i[1]);const g=[Qfe,Xfe],v=[];function x(T,S){return T[0]?0:1}return u=x(i),d=v[u]=g[u](i),{c(){e=ye("main"),t=ye("div"),n=ye("aside"),r=ye("h1"),r.textContent="X-COM Editor",s=ke(),Sl(o.$$.fragment),a=ke(),l=ye("section"),d.c(),ge(r,"class","svelte-xxy1o3"),ge(n,"class","sidebar svelte-xxy1o3"),ge(l,"class","detail svelte-xxy1o3"),ge(t,"class","layout svelte-xxy1o3")},m(T,S){ht(T,e,S),J(e,t),J(t,n),J(n,r),J(n,s),Ra(o,n,null),J(t,a),J(t,l),v[u].m(l,null),A=!0},p(T,[S]){const w={};S&1&&(w.selectedSlot=T[0]),o.$set(w);let C=u;u=x(T),u===C?v[u].p(T,S):(np(),Pr(v[C],1,1,()=>{v[C]=null}),ip(),d=v[u],d?d.p(T,S):(d=v[u]=g[u](T),d.c()),mr(d,1),d.m(l,null))},i(T){A||(mr(o.$$.fragment,T),mr(d),A=!0)},o(T){Pr(o.$$.fragment,T),Pr(d),A=!1},d(T){T&&ct(e),Na(o),v[u].d()}}}function Kfe(i,e,t){let n=null;function r(s){t(0,n=s.detail)}return[n,r]}class Zfe extends Da{constructor(e){super(),Pa(this,e,Kfe,Yfe,Ca,{})}}new Zfe({target:document.getElementById("app")}); diff --git a/cmd/savegame-editor/frontend/dist/assets/index-CrskB67L.css b/cmd/savegame-editor/frontend/dist/assets/index-CrskB67L.css new file mode 100644 index 0000000..34df33d --- /dev/null +++ b/cmd/savegame-editor/frontend/dist/assets/index-CrskB67L.css @@ -0,0 +1 @@ +.game-card.svelte-19y2p2f{display:block;width:100%;text-align:left;background:#1a1a2e;border:1px solid #0f3460;border-radius:6px;padding:10px 12px;margin-bottom:8px;cursor:pointer;color:#e0e0e0;font-family:inherit;font-size:13px;transition:border-color .15s}.game-card.svelte-19y2p2f:hover{border-color:#00ff41}.game-card.selected.svelte-19y2p2f{border-color:#00ff41;background:#0f3460}.slot.svelte-19y2p2f{font-size:11px;color:#888;text-transform:uppercase;letter-spacing:.5px}.title.svelte-19y2p2f{font-weight:700;color:#00ff41;margin:2px 0}.meta.svelte-19y2p2f{font-size:12px;color:#888}.counts.svelte-19y2p2f{font-size:11px;color:#666;margin-top:4px}.error.svelte-19y2p2f{color:#f44;padding:8px;font-size:13px}.edit-form.svelte-1efrnwg h3.svelte-1efrnwg{color:#00ff41;margin:0 0 8px}.info.svelte-1efrnwg.svelte-1efrnwg{color:#888;font-size:13px;margin-bottom:4px}h4.svelte-1efrnwg.svelte-1efrnwg{color:#aaa;font-size:13px;margin:16px 0 8px;text-transform:uppercase;letter-spacing:.5px}.fields.svelte-1efrnwg.svelte-1efrnwg{display:flex;gap:16px;margin-top:16px;flex-wrap:wrap}.stats-grid.svelte-1efrnwg.svelte-1efrnwg{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}.stats-display.svelte-1efrnwg.svelte-1efrnwg{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:4px;font-size:13px}.stats-display.svelte-1efrnwg span.svelte-1efrnwg{color:#888}label.svelte-1efrnwg.svelte-1efrnwg{display:flex;flex-direction:column;gap:4px}label.svelte-1efrnwg span.svelte-1efrnwg{font-size:11px;color:#888;text-transform:uppercase;letter-spacing:.3px}input.svelte-1efrnwg.svelte-1efrnwg,select.svelte-1efrnwg.svelte-1efrnwg{background:#16213e;border:1px solid #0f3460;color:#e0e0e0;padding:6px 8px;border-radius:4px;font-family:inherit;font-size:13px}input.svelte-1efrnwg.svelte-1efrnwg:focus,select.svelte-1efrnwg.svelte-1efrnwg:focus{outline:none;border-color:#00ff41}input[type=number].svelte-1efrnwg.svelte-1efrnwg{width:80px}.actions.svelte-1efrnwg.svelte-1efrnwg{margin-top:20px}.save-btn.svelte-1efrnwg.svelte-1efrnwg{background:#0a5c0a;border:1px solid #0f8f0f;color:#e0e0e0;padding:8px 20px;border-radius:4px;cursor:pointer;font-family:inherit;font-size:14px}.save-btn.svelte-1efrnwg.svelte-1efrnwg:hover{background:#0f8f0f}.save-btn.svelte-1efrnwg.svelte-1efrnwg:disabled{opacity:.5;cursor:not-allowed}.error.svelte-1efrnwg.svelte-1efrnwg{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}table.svelte-8vrigc.svelte-8vrigc{width:100%;border-collapse:collapse;font-size:13px}th.svelte-8vrigc.svelte-8vrigc{text-align:left;padding:6px 10px;border-bottom:1px solid #0f3460;color:#888;font-size:11px;text-transform:uppercase;letter-spacing:.5px}td.svelte-8vrigc.svelte-8vrigc{padding:6px 10px;border-bottom:1px solid #16213e}tr.svelte-8vrigc.svelte-8vrigc{cursor:pointer;transition:background .1s}tr.svelte-8vrigc.svelte-8vrigc:hover{background:#16213e}tr.dead.svelte-8vrigc.svelte-8vrigc{opacity:.5}tr.wounded.svelte-8vrigc td.svelte-8vrigc{color:#fa4}.name.svelte-8vrigc.svelte-8vrigc{font-weight:700}.num.svelte-8vrigc.svelte-8vrigc{text-align:right;font-variant-numeric:tabular-nums}.badge.svelte-8vrigc.svelte-8vrigc{font-size:10px;padding:2px 6px;border-radius:3px;font-weight:700}.badge.dead.svelte-8vrigc.svelte-8vrigc{background:#5c0a0a;color:#f44}.badge.wounded.svelte-8vrigc.svelte-8vrigc{background:#5c3a0a;color:#fa4}.badge.ok.svelte-8vrigc.svelte-8vrigc{background:#0a3a0a;color:#4f4}.back.svelte-8vrigc.svelte-8vrigc{background:none;border:none;color:#00ff41;cursor:pointer;font-family:inherit;font-size:13px;padding:4px 0;margin-bottom:12px}.back.svelte-8vrigc.svelte-8vrigc:hover{text-decoration:underline}.error.svelte-8vrigc.svelte-8vrigc{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}h3.svelte-x2jonz.svelte-x2jonz{color:#00ff41;margin:0 0 4px}.meta.svelte-x2jonz.svelte-x2jonz{color:#666;font-size:12px;margin-bottom:16px}h4.svelte-x2jonz.svelte-x2jonz{color:#aaa;font-size:13px;margin:20px 0 8px;text-transform:uppercase;letter-spacing:.5px}.fields.svelte-x2jonz.svelte-x2jonz{display:flex;gap:16px;margin-bottom:8px}label.svelte-x2jonz.svelte-x2jonz{display:flex;flex-direction:column;gap:4px}label.svelte-x2jonz span.svelte-x2jonz{font-size:11px;color:#888;text-transform:uppercase}input.svelte-x2jonz.svelte-x2jonz{background:#16213e;border:1px solid #0f3460;color:#e0e0e0;padding:6px 8px;border-radius:4px;font-family:inherit;font-size:13px;width:80px}input.svelte-x2jonz.svelte-x2jonz:focus{outline:none;border-color:#00ff41}.grid.svelte-x2jonz.svelte-x2jonz{display:flex;flex-direction:column;gap:2px}.grid-row.svelte-x2jonz.svelte-x2jonz{display:flex;gap:2px}.tile.svelte-x2jonz.svelte-x2jonz{width:80px;height:48px;background:#0f3460;border-radius:3px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:9px;color:#ccc;position:relative;overflow:hidden}.tile.empty.svelte-x2jonz.svelte-x2jonz{background:#1a1a2e;border:1px dashed #333}.tile.building.svelte-x2jonz.svelte-x2jonz{border:1px solid #ffaa44}.tile-name.svelte-x2jonz.svelte-x2jonz{text-align:center;line-height:1.1;padding:0 2px}.tile-days.svelte-x2jonz.svelte-x2jonz{color:#fa4;font-size:8px;font-weight:700}.inventory.svelte-x2jonz.svelte-x2jonz{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:4px;font-size:13px}.inv-item.svelte-x2jonz.svelte-x2jonz{display:flex;justify-content:space-between;padding:3px 8px;background:#16213e;border-radius:3px}.inv-name.svelte-x2jonz.svelte-x2jonz{color:#ccc}.inv-count.svelte-x2jonz.svelte-x2jonz{color:#00ff41;font-weight:700}.actions.svelte-x2jonz.svelte-x2jonz{margin-top:20px}.save-btn.svelte-x2jonz.svelte-x2jonz{background:#0a5c0a;border:1px solid #0f8f0f;color:#e0e0e0;padding:8px 20px;border-radius:4px;cursor:pointer;font-family:inherit;font-size:14px}.save-btn.svelte-x2jonz.svelte-x2jonz:hover{background:#0f8f0f}.save-btn.svelte-x2jonz.svelte-x2jonz:disabled{opacity:.5;cursor:not-allowed}.error.svelte-x2jonz.svelte-x2jonz{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}.base-grid.svelte-egad06{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px}.base-card.svelte-egad06{display:block;width:100%;text-align:left;background:#16213e;border:1px solid #0f3460;border-radius:6px;padding:14px;cursor:pointer;color:#e0e0e0;font-family:inherit;font-size:13px;transition:border-color .15s}.base-card.svelte-egad06:hover{border-color:#00ff41}.base-name.svelte-egad06{font-weight:700;color:#00ff41;font-size:15px;margin-bottom:4px}.base-coord.svelte-egad06{color:#666;font-size:11px;margin-bottom:8px}.base-staff.svelte-egad06{display:flex;gap:16px;font-size:12px;color:#888}.back.svelte-egad06{background:none;border:none;color:#00ff41;cursor:pointer;font-family:inherit;font-size:13px;padding:4px 0;margin-bottom:12px}.back.svelte-egad06:hover{text-decoration:underline}.error.svelte-egad06{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}table.svelte-15cjom9{width:100%;border-collapse:collapse;font-size:13px}th.svelte-15cjom9{text-align:left;padding:6px 10px;border-bottom:1px solid #0f3460;color:#888;font-size:11px;text-transform:uppercase;letter-spacing:.5px}td.svelte-15cjom9{padding:6px 10px;border-bottom:1px solid #16213e}.name.svelte-15cjom9{font-weight:700}.num.svelte-15cjom9{text-align:right;font-variant-numeric:tabular-nums}.badge.svelte-15cjom9{font-size:11px;padding:2px 8px;border-radius:3px;background:#0f3460}.badge.ready.svelte-15cjom9{background:#0a3a0a;color:#4f4}.badge.out.svelte-15cjom9{background:#3a3a0a;color:#ff4}.empty.svelte-15cjom9{color:#666;text-align:center;padding:40px}.error.svelte-15cjom9{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}table.svelte-qimr4z{width:100%;border-collapse:collapse;font-size:13px}th.svelte-qimr4z{text-align:left;padding:6px 10px;border-bottom:1px solid #0f3460;color:#888;font-size:11px;text-transform:uppercase;letter-spacing:.5px}td.svelte-qimr4z{padding:6px 10px;border-bottom:1px solid #16213e}.num.svelte-qimr4z{text-align:right;font-variant-numeric:tabular-nums}.empty.svelte-qimr4z{color:#666;text-align:center;padding:40px}.error.svelte-qimr4z{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}.balance-section.svelte-1sskyg0.svelte-1sskyg0{margin-bottom:24px}.balance-edit.svelte-1sskyg0.svelte-1sskyg0{display:flex;gap:8px;align-items:center;margin-top:4px}.balance-display.svelte-1sskyg0.svelte-1sskyg0{font-size:28px;color:#00ff41;font-weight:700;margin-top:8px}h4.svelte-1sskyg0.svelte-1sskyg0{color:#aaa;font-size:13px;margin:20px 0 8px;text-transform:uppercase;letter-spacing:.5px}label.svelte-1sskyg0 span.svelte-1sskyg0{font-size:11px;color:#888;text-transform:uppercase;letter-spacing:.3px}input.svelte-1sskyg0.svelte-1sskyg0{background:#16213e;border:1px solid #0f3460;color:#e0e0e0;padding:6px 8px;border-radius:4px;font-family:inherit;font-size:13px;width:160px}input.svelte-1sskyg0.svelte-1sskyg0:focus{outline:none;border-color:#00ff41}.save-btn.svelte-1sskyg0.svelte-1sskyg0{background:#0a5c0a;border:1px solid #0f8f0f;color:#e0e0e0;padding:6px 14px;border-radius:4px;cursor:pointer;font-family:inherit;font-size:13px}.save-btn.svelte-1sskyg0.svelte-1sskyg0:hover{background:#0f8f0f}.save-btn.svelte-1sskyg0.svelte-1sskyg0:disabled{opacity:.5;cursor:not-allowed}table.svelte-1sskyg0.svelte-1sskyg0{width:100%;border-collapse:collapse;font-size:13px}th.svelte-1sskyg0.svelte-1sskyg0{text-align:left;padding:6px 10px;border-bottom:1px solid #0f3460;color:#888;font-size:11px;text-transform:uppercase;letter-spacing:.5px}td.svelte-1sskyg0.svelte-1sskyg0{padding:6px 10px;border-bottom:1px solid #16213e}.num.svelte-1sskyg0.svelte-1sskyg0{text-align:right;font-variant-numeric:tabular-nums}.negative.svelte-1sskyg0.svelte-1sskyg0{color:#f44}.error.svelte-1sskyg0.svelte-1sskyg0{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}.globe-wrapper.svelte-mnrxuc{display:flex;flex-direction:column;align-items:center}.globe-container.svelte-mnrxuc{width:100%;max-width:600px}.globe-container.svelte-mnrxuc canvas{cursor:grab}.globe-container.svelte-mnrxuc canvas:active{cursor:grabbing}.legend.svelte-mnrxuc{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;margin-top:12px;font-size:12px;color:#aaa}.legend-item.svelte-mnrxuc{display:flex;align-items:center;gap:4px}.dot.svelte-mnrxuc{display:inline-block;width:8px;height:8px;border-radius:50%}.error.svelte-mnrxuc{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}.header.svelte-1gsu8dt h2.svelte-1gsu8dt{margin:0;color:#00ff41}.meta.svelte-1gsu8dt.svelte-1gsu8dt{color:#888;font-size:13px;margin-top:4px}.tabs.svelte-1gsu8dt.svelte-1gsu8dt{display:flex;gap:0;margin:16px 0 0;border-bottom:1px solid #0f3460}.tab.svelte-1gsu8dt.svelte-1gsu8dt{background:none;border:none;border-bottom:2px solid transparent;color:#888;padding:8px 16px;cursor:pointer;font-family:inherit;font-size:14px;transition:color .15s,border-color .15s}.tab.svelte-1gsu8dt.svelte-1gsu8dt:hover{color:#e0e0e0}.tab.active.svelte-1gsu8dt.svelte-1gsu8dt{color:#00ff41;border-bottom-color:#00ff41}.tab-content.svelte-1gsu8dt.svelte-1gsu8dt{margin-top:16px;min-height:300px}.action-bar.svelte-1gsu8dt.svelte-1gsu8dt{display:flex;align-items:center;gap:8px;margin-top:24px;padding-top:16px;border-top:1px solid #0f3460;flex-wrap:wrap}.action.svelte-1gsu8dt.svelte-1gsu8dt{background:#0f3460;border:1px solid #1a4a8a;color:#e0e0e0;padding:6px 14px;border-radius:4px;cursor:pointer;font-family:inherit;font-size:13px;transition:background .15s}.action.svelte-1gsu8dt.svelte-1gsu8dt:hover{background:#1a4a8a}.action.save.svelte-1gsu8dt.svelte-1gsu8dt{background:#0a5c0a;border-color:#0f8f0f}.action.save.svelte-1gsu8dt.svelte-1gsu8dt:hover{background:#0f8f0f}.action.reload.svelte-1gsu8dt.svelte-1gsu8dt{background:#5c3a0a;border-color:#8f5c0f}.action.reload.svelte-1gsu8dt.svelte-1gsu8dt:hover{background:#8f5c0f}.spacer.svelte-1gsu8dt.svelte-1gsu8dt{flex:1}.status.svelte-1gsu8dt.svelte-1gsu8dt{font-size:12px;color:#00ff41}.error.svelte-1gsu8dt.svelte-1gsu8dt{color:#f44;padding:8px;margin-bottom:8px;background:#ff44441a;border-radius:4px}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,monospace;background:#1a1a2e;color:#e0e0e0}*{box-sizing:border-box}.layout.svelte-xxy1o3.svelte-xxy1o3{display:grid;grid-template-columns:280px 1fr;height:100vh}.sidebar.svelte-xxy1o3.svelte-xxy1o3{background:#16213e;padding:16px;overflow-y:auto;border-right:1px solid #0f3460}.sidebar.svelte-xxy1o3 h1.svelte-xxy1o3{font-size:18px;color:#00ff41;margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid #0f3460}.detail.svelte-xxy1o3.svelte-xxy1o3{padding:16px 24px;overflow-y:auto}.placeholder.svelte-xxy1o3.svelte-xxy1o3{color:#666;text-align:center;padding:60px 20px;font-size:16px} diff --git a/cmd/savegame-editor/frontend/dist/earth-day.jpg b/cmd/savegame-editor/frontend/dist/earth-day.jpg new file mode 100644 index 0000000..cc68dd8 Binary files /dev/null and b/cmd/savegame-editor/frontend/dist/earth-day.jpg differ diff --git a/cmd/savegame-editor/frontend/dist/earth-night.jpg b/cmd/savegame-editor/frontend/dist/earth-night.jpg new file mode 100644 index 0000000..6889180 Binary files /dev/null and b/cmd/savegame-editor/frontend/dist/earth-night.jpg differ diff --git a/cmd/savegame-editor/frontend/dist/index.html b/cmd/savegame-editor/frontend/dist/index.html new file mode 100644 index 0000000..0ea391a --- /dev/null +++ b/cmd/savegame-editor/frontend/dist/index.html @@ -0,0 +1,21 @@ + + + + + + X-COM Savegame Editor + + + + +

+ + + diff --git a/cmd/savegame-editor/frontend/index.html b/cmd/savegame-editor/frontend/index.html new file mode 100644 index 0000000..c09f146 --- /dev/null +++ b/cmd/savegame-editor/frontend/index.html @@ -0,0 +1,20 @@ + + + + + + X-COM Savegame Editor + + +
+ + + + diff --git a/cmd/savegame-editor/frontend/package-lock.json b/cmd/savegame-editor/frontend/package-lock.json new file mode 100644 index 0000000..33b8f4a --- /dev/null +++ b/cmd/savegame-editor/frontend/package-lock.json @@ -0,0 +1,1995 @@ +{ + "name": "savegame-editor-frontend", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "savegame-editor-frontend", + "version": "0.0.1", + "dependencies": { + "globe.gl": "^2.45.0", + "three-globe": "^2.41.6" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.1.2", + "@tsconfig/svelte": "^5.0.6", + "svelte": "^4.2.20", + "svelte-check": "^4.3.5", + "svelte-preprocess": "^6.0.3", + "tslib": "^2.8.1", + "typescript": "^5.0.0", + "vite": "^5.0.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", + "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "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==", + "dev": true, + "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==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "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==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.57.1.tgz", + "integrity": "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.57.1.tgz", + "integrity": "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.57.1.tgz", + "integrity": "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.57.1.tgz", + "integrity": "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.57.1.tgz", + "integrity": "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.57.1.tgz", + "integrity": "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.57.1.tgz", + "integrity": "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.57.1.tgz", + "integrity": "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.57.1.tgz", + "integrity": "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.57.1.tgz", + "integrity": "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.57.1.tgz", + "integrity": "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.57.1.tgz", + "integrity": "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.57.1.tgz", + "integrity": "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.57.1.tgz", + "integrity": "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.57.1.tgz", + "integrity": "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.57.1.tgz", + "integrity": "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.57.1.tgz", + "integrity": "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.57.1.tgz", + "integrity": "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.57.1.tgz", + "integrity": "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.57.1.tgz", + "integrity": "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.57.1.tgz", + "integrity": "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.57.1.tgz", + "integrity": "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.57.1.tgz", + "integrity": "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.57.1.tgz", + "integrity": "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.57.1.tgz", + "integrity": "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-3.1.2.tgz", + "integrity": "sha512-Txsm1tJvtiYeLUVRNqxZGKR/mI+CzuIQuc2gn+YCs9rMTowpNZ2Nqt53JdL8KF9bLhAf2ruR/dr9eZCwdTriRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^2.1.0", + "debug": "^4.3.4", + "deepmerge": "^4.3.1", + "kleur": "^4.1.5", + "magic-string": "^0.30.10", + "svelte-hmr": "^0.16.0", + "vitefu": "^0.2.5" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-2.1.0.tgz", + "integrity": "sha512-9QX28IymvBlSCqsCll5t0kQVxipsfhFFL+L2t3nTWfXnddYwxBuAEtTtlaVQpRz9c37BhJjltSeY4AJSC03SSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@tsconfig/svelte": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.6.tgz", + "integrity": "sha512-yGxYL0I9eETH1/DR9qVJey4DAsCdeau4a9wYPKuXfEhm8lFO8wg+LLYJjIpAm6Fw7HSlhepPhYPDop75485yWQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@turf/boolean-point-in-polygon": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/boolean-point-in-polygon/-/boolean-point-in-polygon-7.3.3.tgz", + "integrity": "sha512-hmXV4PofLAVbVZcnKk/yp//0s65huap+L3wKGKzbLWk57fWla/eRmFKx/iQ15xGu05zylHz5cA5AfriVGZHj2g==", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.3", + "@turf/invariant": "7.3.3", + "@types/geojson": "^7946.0.10", + "point-in-polygon-hao": "^1.1.0", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/helpers": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-7.3.3.tgz", + "integrity": "sha512-9Ias0L1GuZPIzO6sk8jraTEuLJye6n9LYNEdw69ZGOQ6C1IigjxkPW49zmn21aTv1z27vxdVLSS3r+78DB2QnQ==", + "license": "MIT", + "dependencies": { + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/invariant": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/invariant/-/invariant-7.3.3.tgz", + "integrity": "sha512-q6UDgWmtIlU+AIxt5Awnh18ZMSuNti6drCXbIBdGdgQaQ1qEiyGZDE3P9RKk6otoLXOBYecOuI0HIwf2IxurhQ==", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.3", + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "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.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "license": "MIT" + }, + "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/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz", + "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/code-red": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz", + "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15", + "@types/estree": "^1.0.1", + "acorn": "^8.10.0", + "estree-walker": "^3.0.3", + "periscopic": "^3.1.0" + } + }, + "node_modules/css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "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-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-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "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-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo-voronoi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/d3-geo-voronoi/-/d3-geo-voronoi-2.1.0.tgz", + "integrity": "sha512-kqE4yYuOjPbKdBXG0xztCacPwkVSK2REF1opSNrnqqtXJmNcM++UbwQ8SxvwP6IQTj9RvIjjK4qeiVsEfj0Z2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-delaunay": "6", + "d3-geo": "3", + "d3-tricontour": "1" + }, + "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-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-tricontour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/d3-tricontour/-/d3-tricontour-1.1.0.tgz", + "integrity": "sha512-G7gHKj89n2owmkGb6WX6ixcnQ0Kf/0wpa9VIh9DGdbHu8wdrlaHU4ir3/bFNERl8N8nn4G7e7qbtBG8N9caihQ==", + "license": "ISC", + "dependencies": { + "d3-delaunay": "6", + "d3-scale": "4" + }, + "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/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/delaunator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", + "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/earcut": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.0.2.tgz", + "integrity": "sha512-X7hshQbLyMJ/3RPhyObLARM2sNxxmRALLKx1+NVFFnQ9gKzmCrxm9+uLIAdBcvc8FNLpctqlQ2V6AE92Ol9UDQ==", + "license": "ISC" + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "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/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/frame-ticker": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/frame-ticker/-/frame-ticker-1.0.3.tgz", + "integrity": "sha512-E0X2u2JIvbEMrqEg5+4BpTqaD22OwojJI63K7MdKHdncjtAhGRbCR8nJCr2vwEt9NWBPCPcu70X9smPviEBy8Q==", + "license": "MIT", + "dependencies": { + "simplesignal": "^2.1.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/globe.gl": { + "version": "2.45.0", + "resolved": "https://registry.npmjs.org/globe.gl/-/globe.gl-2.45.0.tgz", + "integrity": "sha512-fjkLHVBrnbESkUgklTd4UbcGLciu4nIl49IIi1hclLjI6MU3ASu6JYmf/K5qwPf7I+tNOauQRr4i5Y28JTtHQg==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "kapsule": "^1.16", + "three": ">=0.154 <1", + "three-globe": "^2.45", + "three-render-objects": "^1.40" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/h3-js": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/h3-js/-/h3-js-4.4.0.tgz", + "integrity": "sha512-DvJh07MhGgY2KcC4OeZc8SSyA+ZXpdvoh6uCzGpoKvWtZxJB+g6VXXC1+eWYkaMIsLz7J/ErhOalHCpcs1KYog==", + "license": "Apache-2.0", + "engines": { + "node": ">=4", + "npm": ">=3", + "yarn": ">=1.3.0" + } + }, + "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-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "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/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.17.23", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz", + "integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==", + "license": "MIT" + }, + "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==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "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/periscopic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz", + "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^3.0.0", + "is-reference": "^3.0.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/point-in-polygon-hao": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/point-in-polygon-hao/-/point-in-polygon-hao-1.2.4.tgz", + "integrity": "sha512-x2pcvXeqhRHlNRdhLs/tgFapAbSSe86wa/eqmj1G6pWftbEs5aVRJhRGM6FYSUERKu0PjekJzMq0gsI2XyiclQ==", + "license": "MIT", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "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.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "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.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/preact": { + "version": "10.28.3", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.28.3.tgz", + "integrity": "sha512-tCmoRkPQLpBeWzpmbhryairGnhW9tKV6c6gr/w+RhoRoKEJwsjzipwp//1oCpGPOchvSLaAPlpcJi9MwMmoPyA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", + "license": "Unlicense" + }, + "node_modules/rollup": { + "version": "4.57.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", + "integrity": "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.57.1", + "@rollup/rollup-android-arm64": "4.57.1", + "@rollup/rollup-darwin-arm64": "4.57.1", + "@rollup/rollup-darwin-x64": "4.57.1", + "@rollup/rollup-freebsd-arm64": "4.57.1", + "@rollup/rollup-freebsd-x64": "4.57.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", + "@rollup/rollup-linux-arm-musleabihf": "4.57.1", + "@rollup/rollup-linux-arm64-gnu": "4.57.1", + "@rollup/rollup-linux-arm64-musl": "4.57.1", + "@rollup/rollup-linux-loong64-gnu": "4.57.1", + "@rollup/rollup-linux-loong64-musl": "4.57.1", + "@rollup/rollup-linux-ppc64-gnu": "4.57.1", + "@rollup/rollup-linux-ppc64-musl": "4.57.1", + "@rollup/rollup-linux-riscv64-gnu": "4.57.1", + "@rollup/rollup-linux-riscv64-musl": "4.57.1", + "@rollup/rollup-linux-s390x-gnu": "4.57.1", + "@rollup/rollup-linux-x64-gnu": "4.57.1", + "@rollup/rollup-linux-x64-musl": "4.57.1", + "@rollup/rollup-openbsd-x64": "4.57.1", + "@rollup/rollup-openharmony-arm64": "4.57.1", + "@rollup/rollup-win32-arm64-msvc": "4.57.1", + "@rollup/rollup-win32-ia32-msvc": "4.57.1", + "@rollup/rollup-win32-x64-gnu": "4.57.1", + "@rollup/rollup-win32-x64-msvc": "4.57.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/simplesignal": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/simplesignal/-/simplesignal-2.1.7.tgz", + "integrity": "sha512-PEo2qWpUke7IMhlqiBxrulIFvhJRLkl1ih52Rwa+bPjzhJepcd4GIjn2RiQmFSx3dQvsEAgF0/lXMwMN7vODaA==", + "license": "MIT" + }, + "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==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/svelte": { + "version": "4.2.20", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.20.tgz", + "integrity": "sha512-eeEgGc2DtiUil5ANdtd8vPwt9AgaMdnuUFnPft9F5oMvU/FHu5IHFic+p1dR/UOB7XU2mX2yHW+NcTch4DCh5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@jridgewell/sourcemap-codec": "^1.4.15", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/estree": "^1.0.1", + "acorn": "^8.9.0", + "aria-query": "^5.3.0", + "axobject-query": "^4.0.0", + "code-red": "^1.0.3", + "css-tree": "^2.3.1", + "estree-walker": "^3.0.3", + "is-reference": "^3.0.1", + "locate-character": "^3.0.0", + "magic-string": "^0.30.4", + "periscopic": "^3.1.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/svelte-check": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.3.5.tgz", + "integrity": "sha512-e4VWZETyXaKGhpkxOXP+B/d0Fp/zKViZoJmneZWe/05Y2aqSKj3YN2nLfYPJBQ87WEiY4BQCQ9hWGu9mPT1a1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "chokidar": "^4.0.1", + "fdir": "^6.2.0", + "picocolors": "^1.0.0", + "sade": "^1.7.4" + }, + "bin": { + "svelte-check": "bin/svelte-check" + }, + "engines": { + "node": ">= 18.0.0" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "typescript": ">=5.0.0" + } + }, + "node_modules/svelte-hmr": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.16.0.tgz", + "integrity": "sha512-Gyc7cOS3VJzLlfj7wKS0ZnzDVdv3Pn2IuVeJPk9m2skfhcu5bq3wtIZyQGggr7/Iim5rH5cncyQft/kRLupcnA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^12.20 || ^14.13.1 || >= 16" + }, + "peerDependencies": { + "svelte": "^3.19.0 || ^4.0.0" + } + }, + "node_modules/svelte-preprocess": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-6.0.3.tgz", + "integrity": "sha512-PLG2k05qHdhmRG7zR/dyo5qKvakhm8IJ+hD2eFRQmMLHp7X3eJnjeupUtvuRpbNiF31RjVw45W+abDwHEmP5OA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "engines": { + "node": ">= 18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.10.2", + "coffeescript": "^2.5.1", + "less": "^3.11.3 || ^4.0.0", + "postcss": "^7 || ^8", + "postcss-load-config": ">=3", + "pug": "^3.0.0", + "sass": "^1.26.8", + "stylus": ">=0.55", + "sugarss": "^2.0.0 || ^3.0.0 || ^4.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.100 || ^5.0.0", + "typescript": "^5.0.0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "coffeescript": { + "optional": true + }, + "less": { + "optional": true + }, + "postcss": { + "optional": true + }, + "postcss-load-config": { + "optional": true + }, + "pug": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/three": { + "version": "0.182.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.182.0.tgz", + "integrity": "sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ==", + "license": "MIT" + }, + "node_modules/three-conic-polygon-geometry": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/three-conic-polygon-geometry/-/three-conic-polygon-geometry-2.1.2.tgz", + "integrity": "sha512-NaP3RWLJIyPGI+zyaZwd0Yj6rkoxm4FJHqAX1Enb4L64oNYLCn4bz1ESgOEYavgcUwCNYINu1AgEoUBJr1wZcA==", + "license": "MIT", + "dependencies": { + "@turf/boolean-point-in-polygon": "^7.2", + "d3-array": "1 - 3", + "d3-geo": "1 - 3", + "d3-geo-voronoi": "2", + "d3-scale": "1 - 4", + "delaunator": "5", + "earcut": "3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.72.0" + } + }, + "node_modules/three-geojson-geometry": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/three-geojson-geometry/-/three-geojson-geometry-2.1.1.tgz", + "integrity": "sha512-dC7bF3ri1goDcihYhzACHOBQqu7YNNazYLa2bSydVIiJUb3jDFojKSy+gNj2pMkqZNSVjssSmdY9zlmnhEpr1w==", + "license": "MIT", + "dependencies": { + "d3-geo": "1 - 3", + "d3-interpolate": "1 - 3", + "earcut": "3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.72.0" + } + }, + "node_modules/three-globe": { + "version": "2.45.0", + "resolved": "https://registry.npmjs.org/three-globe/-/three-globe-2.45.0.tgz", + "integrity": "sha512-Ur6BVkezvmHnvsEg8fbq6gIscSZtknSQMWwDRbiJ95o6OSDjDbGTc4oO6nP7mOM9aAA3YrF7YZyOwSkP4T56QA==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "d3-array": "3", + "d3-color": "3", + "d3-geo": "3", + "d3-interpolate": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "data-bind-mapper": "1", + "frame-ticker": "1", + "h3-js": "4", + "index-array-by": "1", + "kapsule": "^1.16", + "three-conic-polygon-geometry": "2", + "three-geojson-geometry": "2", + "three-slippy-map-globe": "1", + "tinycolor2": "1" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.154" + } + }, + "node_modules/three-render-objects": { + "version": "1.40.4", + "resolved": "https://registry.npmjs.org/three-render-objects/-/three-render-objects-1.40.4.tgz", + "integrity": "sha512-Ukpu1pei3L5r809izvjsZxwuRcYLiyn6Uvy3lZ9bpMTdvj3i6PeX6w++/hs2ZS3KnEzGjb6YvTvh4UQuwHTDJg==", + "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.168" + } + }, + "node_modules/three-slippy-map-globe": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/three-slippy-map-globe/-/three-slippy-map-globe-1.0.4.tgz", + "integrity": "sha512-am8A4PP38AfTdrhXBDucwPRHLTbBl93yhpjIs56K1TLs9VuUWzg68oim4Dibs9QC1riXbj5SoBp/okA1VN9eYg==", + "license": "MIT", + "dependencies": { + "d3-geo": "1 - 3", + "d3-octree": "^1.1", + "d3-scale": "1 - 4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.154" + } + }, + "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/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vite": { + "version": "5.4.21", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", + "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.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", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz", + "integrity": "sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + } + } +} diff --git a/cmd/savegame-editor/frontend/package.json b/cmd/savegame-editor/frontend/package.json new file mode 100644 index 0000000..eb14d36 --- /dev/null +++ b/cmd/savegame-editor/frontend/package.json @@ -0,0 +1,25 @@ +{ + "name": "savegame-editor-frontend", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.1.2", + "@tsconfig/svelte": "^5.0.6", + "svelte": "^4.2.20", + "svelte-check": "^4.3.5", + "svelte-preprocess": "^6.0.3", + "tslib": "^2.8.1", + "typescript": "^5.0.0", + "vite": "^5.0.0" + }, + "dependencies": { + "globe.gl": "^2.45.0", + "three-globe": "^2.41.6" + } +} diff --git a/cmd/savegame-editor/frontend/public/earth-day.jpg b/cmd/savegame-editor/frontend/public/earth-day.jpg new file mode 100644 index 0000000..cc68dd8 Binary files /dev/null and b/cmd/savegame-editor/frontend/public/earth-day.jpg differ diff --git a/cmd/savegame-editor/frontend/public/earth-night.jpg b/cmd/savegame-editor/frontend/public/earth-night.jpg new file mode 100644 index 0000000..6889180 Binary files /dev/null and b/cmd/savegame-editor/frontend/public/earth-night.jpg differ diff --git a/cmd/savegame-editor/frontend/src/App.svelte b/cmd/savegame-editor/frontend/src/App.svelte new file mode 100644 index 0000000..b016289 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/App.svelte @@ -0,0 +1,66 @@ + + +
+
+ +
+ {#if selectedSlot} + + {:else} +
Select a savegame from the sidebar.
+ {/if} +
+
+
+ + diff --git a/cmd/savegame-editor/frontend/src/BaseDetail.svelte b/cmd/savegame-editor/frontend/src/BaseDetail.svelte new file mode 100644 index 0000000..93c79fe --- /dev/null +++ b/cmd/savegame-editor/frontend/src/BaseDetail.svelte @@ -0,0 +1,222 @@ + + +{#if error} +
{error}
+{/if} + +{#if base} +

{base.name}

+
{base.coord}
+ +
+ + +
+ +

Facility Grid (6x6)

+
+ {#each { length: 6 } as _, y} +
+ {#each { length: 6 } as _, x} + {@const tile = base.tiles[x + y * 6]} +
0} + title={tile.type + (tile.daysToCompletion > 0 ? ` (${tile.daysToCompletion} days)` : '')} + > + {tile.type === 'Empty' ? '' : tile.type.replace(/ *\(.*\)/, '')} + {#if tile.daysToCompletion > 0} + {tile.daysToCompletion}d + {/if} +
+ {/each} +
+ {/each} +
+ + {#if Object.keys(base.inventory).length > 0} +

Inventory

+
+ {#each Object.entries(base.inventory).sort((a, b) => a[0].localeCompare(b[0])) as [item, count]} +
+ {item} + {count} +
+ {/each} +
+ {/if} + +
+ +
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/BaseList.svelte b/cmd/savegame-editor/frontend/src/BaseList.svelte new file mode 100644 index 0000000..eb090c5 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/BaseList.svelte @@ -0,0 +1,111 @@ + + +{#if error} +
{error}
+{/if} + +{#if selectedIdx !== null} + + +{:else} +
+ {#each bases as base} + + {/each} +
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/CraftList.svelte b/cmd/savegame-editor/frontend/src/CraftList.svelte new file mode 100644 index 0000000..53a8f2f --- /dev/null +++ b/cmd/savegame-editor/frontend/src/CraftList.svelte @@ -0,0 +1,101 @@ + + +{#if error} +
{error}
+{/if} + +{#if craft.length === 0 && !error} +
No craft found.
+{:else} + + + + + + + + + + + + + {#each craft as c} + + + + + + + + + {/each} + +
NameTypeBaseStatusDamageFuel
{c.name}{c.type}{c.baseName} + {c.status} + {c.damage}{c.fuel}
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/FinancialView.svelte b/cmd/savegame-editor/frontend/src/FinancialView.svelte new file mode 100644 index 0000000..92e5a5b --- /dev/null +++ b/cmd/savegame-editor/frontend/src/FinancialView.svelte @@ -0,0 +1,168 @@ + + +{#if error} +
{error}
+{/if} + +{#if financials} +
+ +
{formatCurrency(balance)}
+
+ +

Monthly History (Last 12 Months)

+ + + + + + + + + + + {#each financials.expenditure as _, i} + + + + + + + {/each} + +
MonthExpenditureMaintenanceBalance
{months[i] ?? `M${i+1}`}{formatCurrency(financials.expenditure[i])}{formatCurrency(financials.maintenance[i])} + {formatCurrency(financials.balance[i])} +
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/GameDetail.svelte b/cmd/savegame-editor/frontend/src/GameDetail.svelte new file mode 100644 index 0000000..0b6e6ac --- /dev/null +++ b/cmd/savegame-editor/frontend/src/GameDetail.svelte @@ -0,0 +1,183 @@ + + +{#if error} +
{error}
+{/if} + +{#if game} +
+

{game.title}

+
{game.time} · Balance: ${game.balance?.toLocaleString()}
+
+ + + +
+ {#if activeTab === 'soldiers'} + + {:else if activeTab === 'bases'} + + {:else if activeTab === 'craft'} + + {:else if activeTab === 'transfers'} + + {:else if activeTab === 'financials'} + + {:else if activeTab === 'globe'} + + {/if} +
+ +
+ + + +
+ + + {#if status} + {status} + {/if} +
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/GlobeView.svelte b/cmd/savegame-editor/frontend/src/GlobeView.svelte new file mode 100644 index 0000000..7221845 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/GlobeView.svelte @@ -0,0 +1,200 @@ + + +{#if error} +
{error}
+{/if} + +
+
+
+ {#each legendEntries as entry} + + + {entry.label} + + {/each} +
+
+ + diff --git a/cmd/savegame-editor/frontend/src/Sidebar.svelte b/cmd/savegame-editor/frontend/src/Sidebar.svelte new file mode 100644 index 0000000..66a3a2b --- /dev/null +++ b/cmd/savegame-editor/frontend/src/Sidebar.svelte @@ -0,0 +1,93 @@ + + +{#if error} +
{error}
+{/if} + +{#each games as game} + +{/each} + + diff --git a/cmd/savegame-editor/frontend/src/SoldierEdit.svelte b/cmd/savegame-editor/frontend/src/SoldierEdit.svelte new file mode 100644 index 0000000..4d2c7e3 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/SoldierEdit.svelte @@ -0,0 +1,235 @@ + + +{#if error} +
{error}
+{/if} + +{#if soldier} +
+

Edit: {soldier.name}

+
+ {soldier.rank} · {soldier.gender} · {soldier.appearance} + {#if soldier.baseName} · Base: {soldier.baseName}{/if} + {#if soldier.craftName} · Craft: {soldier.craftName}{/if} +
+
+ Missions: {soldier.missions} · Kills: {soldier.kills} + {#if soldier.recoveryDays > 0} · Recovery: {soldier.recoveryDays} days{/if} +
+ +
+ + + +
+ +

Initial Stats

+
+ + + + + + + + + + +
+ +

Current Totals (Initial + Improvements)

+
+
TU: {soldier.timeUnits}
+
HP: {soldier.health}
+
Energy: {soldier.energy}
+
React: {soldier.reactions}
+
Str: {soldier.strength}
+
Fire: {soldier.firingAccuracy}
+
Throw: {soldier.throwingAccuracy}
+
Melee: {soldier.meleeAccuracy}
+
Psi Str: {soldier.psionicStrength}
+
Psi Skl: {soldier.psionicSkill}
+
Bravery: {soldier.bravery}
+
+ +
+ +
+
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/SoldierList.svelte b/cmd/savegame-editor/frontend/src/SoldierList.svelte new file mode 100644 index 0000000..95d4d91 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/SoldierList.svelte @@ -0,0 +1,128 @@ + + +{#if error} +
{error}
+{/if} + +{#if selectedIdx !== null} + + +{:else} + + + + + + + + + + + + + + {#each soldiers as s} + selectedIdx = s.index} + > + + + + + + + + + {/each} + +
NameRankBaseCraftMissionsKillsStatus
{s.name}{s.rank}{s.baseName}{s.craftName}{s.missions}{s.kills} + {#if s.isDead}DEAD + {:else if s.isWounded}WOUNDED + {:else}OK + {/if} +
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/TransferList.svelte b/cmd/savegame-editor/frontend/src/TransferList.svelte new file mode 100644 index 0000000..294ffaf --- /dev/null +++ b/cmd/savegame-editor/frontend/src/TransferList.svelte @@ -0,0 +1,87 @@ + + +{#if error} +
{error}
+{/if} + +{#if transfers.length === 0 && !error} +
No active transfers.
+{:else} + + + + + + + + + + + + {#each transfers as t} + + + + + + + + {/each} + +
OriginDestinationHours LeftTypeQuantity
{t.origin === 255 ? 'Purchase' : `Base ${t.origin}`}Base {t.destination}{t.hoursLeft}h{t.type}{t.quantity}
+{/if} + + diff --git a/cmd/savegame-editor/frontend/src/globe.gl.d.ts b/cmd/savegame-editor/frontend/src/globe.gl.d.ts new file mode 100644 index 0000000..faf50c6 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/globe.gl.d.ts @@ -0,0 +1,56 @@ +declare module 'globe.gl' { + import { Object3D, Material } from 'three'; + + interface GlobeInstance { + (element: HTMLElement): GlobeInstance; + + // Globe appearance + globeImageUrl(url: string): GlobeInstance; + globeMaterial(material: Material): GlobeInstance; + backgroundColor(color: string): GlobeInstance; + showAtmosphere(show: boolean): GlobeInstance; + showGraticules(show: boolean): GlobeInstance; + + // Points layer + pointsData(data: object[]): GlobeInstance; + pointLat(accessor: string | ((d: any) => number)): GlobeInstance; + pointLng(accessor: string | ((d: any) => number)): GlobeInstance; + pointColor(accessor: string | ((d: any) => string)): GlobeInstance; + pointRadius(accessor: string | ((d: any) => number)): GlobeInstance; + pointAltitude(accessor: string | ((d: any) => number)): GlobeInstance; + pointLabel(accessor: string | ((d: any) => string)): GlobeInstance; + + // Arcs layer + arcsData(data: object[]): GlobeInstance; + arcStartLat(accessor: string | ((d: any) => number)): GlobeInstance; + arcStartLng(accessor: string | ((d: any) => number)): GlobeInstance; + arcEndLat(accessor: string | ((d: any) => number)): GlobeInstance; + arcEndLng(accessor: string | ((d: any) => number)): GlobeInstance; + arcColor(accessor: string | ((d: any) => string)): GlobeInstance; + arcLabel(accessor: string | ((d: any) => string)): GlobeInstance; + arcStroke(width: number | ((d: any) => number)): GlobeInstance; + arcDashLength(length: number | ((d: any) => number)): GlobeInstance; + arcDashGap(gap: number | ((d: any) => number)): GlobeInstance; + arcDashAnimateTime(ms: number | ((d: any) => number)): GlobeInstance; + + // Camera + pointOfView(pov: { lat?: number; lng?: number; altitude?: number }, transitionMs?: number): GlobeInstance; + + // Size + width(width: number): GlobeInstance; + height(height: number): GlobeInstance; + + // Scene access + scene(): Object3D; + renderer(): { dispose(): void }; + controls(): { dispose(): void }; + + // Lifecycle + pauseAnimation(): GlobeInstance; + resumeAnimation(): GlobeInstance; + + _destructor?(): void; + } + + export default function Globe(): GlobeInstance; +} diff --git a/cmd/savegame-editor/frontend/src/lib/api.ts b/cmd/savegame-editor/frontend/src/lib/api.ts new file mode 100644 index 0000000..5dbf18c --- /dev/null +++ b/cmd/savegame-editor/frontend/src/lib/api.ts @@ -0,0 +1,98 @@ +import type { + GameSummary, GameDetail, SoldierSummary, SoldierDetail, + BaseSummary, BaseDetail, CraftSummary, TransferSummary, Financials, + GlobeLocation +} from './types'; + +async function fetchJSON(url: string, options?: RequestInit): Promise { + const res = await fetch(url, options); + if (!res.ok) { + const body = await res.json().catch(() => ({ error: res.statusText })); + throw new Error(body.error || res.statusText); + } + return res.json(); +} + +export async function listGames(): Promise { + return fetchJSON('/api/games'); +} + +export async function getGame(slot: string): Promise { + return fetchJSON(`/api/games/${slot}`); +} + +export async function listSoldiers(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/soldiers`); +} + +export async function getSoldier(slot: string, idx: number): Promise { + return fetchJSON(`/api/games/${slot}/soldiers/${idx}`); +} + +export async function updateSoldier(slot: string, idx: number, updates: Partial): Promise { + await fetchJSON(`/api/games/${slot}/soldiers/${idx}`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(updates), + }); +} + +export async function listBases(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/bases`); +} + +export async function getBase(slot: string, idx: number): Promise { + return fetchJSON(`/api/games/${slot}/bases/${idx}`); +} + +export async function updateBase(slot: string, idx: number, updates: Record): Promise { + await fetchJSON(`/api/games/${slot}/bases/${idx}`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(updates), + }); +} + +export async function listCraft(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/craft`); +} + +export async function listTransfers(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/transfers`); +} + +export async function getFinancials(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/financials`); +} + +export async function updateFinancials(slot: string, updates: Partial): Promise { + await fetchJSON(`/api/games/${slot}/financials`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(updates), + }); +} + +export async function healAll(slot: string): Promise { + await fetchJSON(`/api/games/${slot}/actions/heal-all`, { method: 'POST' }); +} + +export async function completeConstructions(slot: string): Promise { + await fetchJSON(`/api/games/${slot}/actions/complete-constructions`, { method: 'POST' }); +} + +export async function speedupDeliveries(slot: string): Promise { + await fetchJSON(`/api/games/${slot}/actions/speedup-deliveries`, { method: 'POST' }); +} + +export async function saveGame(slot: string): Promise { + await fetchJSON(`/api/games/${slot}/save`, { method: 'POST' }); +} + +export async function reloadGame(slot: string): Promise { + await fetchJSON(`/api/games/${slot}/reload`, { method: 'POST' }); +} + +export async function listLocations(slot: string): Promise { + return fetchJSON(`/api/games/${slot}/locations`); +} diff --git a/cmd/savegame-editor/frontend/src/lib/types.ts b/cmd/savegame-editor/frontend/src/lib/types.ts new file mode 100644 index 0000000..4d6b9fc --- /dev/null +++ b/cmd/savegame-editor/frontend/src/lib/types.ts @@ -0,0 +1,127 @@ +export interface GameSummary { + slot: string; + title: string; + time: string; + soldierCount: number; + baseCount: number; + craftCount: number; +} + +export interface GameDetail { + slot: string; + title: string; + time: string; + soldierCount: number; + baseCount: number; + craftCount: number; + balance: number; +} + +export interface SoldierSummary { + index: number; + name: string; + rank: string; + baseName: string; + craftName: string; + isDead: boolean; + isWounded: boolean; + missions: number; + kills: number; +} + +export interface SoldierDetail { + index: number; + name: string; + rank: string; + baseName: string; + craftName: string; + isDead: boolean; + isWounded: boolean; + missions: number; + kills: number; + recoveryDays: number; + timeUnits: number; + health: number; + energy: number; + reactions: number; + strength: number; + firingAccuracy: number; + throwingAccuracy: number; + meleeAccuracy: number; + psionicStrength: number; + psionicSkill: number; + bravery: number; + armor: string; + gender: string; + appearance: string; + initialTimeUnits: number; + initialHealth: number; + initialEnergy: number; + initialReactions: number; + initialStrength: number; + initialFiringAccuracy: number; + initialThrowingAccuracy: number; + initialMeleeAccuracy: number; + initialPsionicStrength: number; + initialPsionicSkill: number; + initialBravery: number; +} + +export interface BaseSummary { + index: number; + name: string; + active: boolean; + engineers: number; + scientists: number; + coord: string; +} + +export interface BaseDetail { + index: number; + name: string; + active: boolean; + engineers: number; + scientists: number; + coord: string; + tiles: TileInfo[]; + inventory: Record; +} + +export interface TileInfo { + type: string; + daysToCompletion: number; +} + +export interface CraftSummary { + index: number; + name: string; + type: string; + status: string; + damage: number; + fuel: number; + baseName: string; +} + +export interface TransferSummary { + index: number; + origin: number; + destination: number; + hoursLeft: number; + type: number; + quantity: number; +} + +export interface Financials { + currentBalance: number; + expenditure: number[]; + maintenance: number[]; + balance: number[]; +} + +export interface GlobeLocation { + type: string; + typeCode: number; + name: string; + coord: { lat: number; lon: number }; + destCoord?: { lat: number; lon: number }; +} diff --git a/cmd/savegame-editor/frontend/src/main.ts b/cmd/savegame-editor/frontend/src/main.ts new file mode 100644 index 0000000..d5f003c --- /dev/null +++ b/cmd/savegame-editor/frontend/src/main.ts @@ -0,0 +1,7 @@ +import App from './App.svelte' + +const app = new App({ + target: document.getElementById('app')!, +}) + +export default app diff --git a/cmd/savegame-editor/frontend/src/vite-env.d.ts b/cmd/savegame-editor/frontend/src/vite-env.d.ts new file mode 100644 index 0000000..4078e74 --- /dev/null +++ b/cmd/savegame-editor/frontend/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/cmd/savegame-editor/frontend/svelte.config.js b/cmd/savegame-editor/frontend/svelte.config.js new file mode 100644 index 0000000..09a1bf7 --- /dev/null +++ b/cmd/savegame-editor/frontend/svelte.config.js @@ -0,0 +1,5 @@ +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' + +export default { + preprocess: vitePreprocess() +} diff --git a/cmd/savegame-editor/frontend/tsconfig.json b/cmd/savegame-editor/frontend/tsconfig.json new file mode 100644 index 0000000..57bd40d --- /dev/null +++ b/cmd/savegame-editor/frontend/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "allowJs": true, + "checkJs": true, + "isolatedModules": true + }, + "include": ["src/**/*.ts", "src/**/*.svelte"] +} diff --git a/cmd/savegame-editor/frontend/vite.config.js b/cmd/savegame-editor/frontend/vite.config.js new file mode 100644 index 0000000..143a066 --- /dev/null +++ b/cmd/savegame-editor/frontend/vite.config.js @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' + +export default defineConfig({ + plugins: [svelte()], + server: { + proxy: { + '/api': 'http://localhost:8080' + } + }, + build: { + outDir: 'dist', + emptyOutDir: true + } +}) diff --git a/cmd/savegame-editor/main.go b/cmd/savegame-editor/main.go new file mode 100644 index 0000000..8c5cc04 --- /dev/null +++ b/cmd/savegame-editor/main.go @@ -0,0 +1,166 @@ +package main + +import ( + "context" + "embed" + "flag" + "fmt" + "io/fs" + "log" + "net/http" + "os" + "os/exec" + "os/signal" + "path" + "path/filepath" + "runtime" + "strings" + "sync" + "time" + + "github.com/gorilla/mux" + "github.com/redtoad/xcom-editor/savegame" +) + +var ( + version = "dev" + commit = "none" + date = "unknown" + builtBy = "unknown" +) + +//go:embed frontend/dist +var frontendFS embed.FS + +// gameEntry holds a savegame and its synchronization mutex. +type gameEntry struct { + sg *savegame.Savegame + mu sync.RWMutex +} + +// games holds all loaded savegames indexed by slot name (e.g. "GAME_1"). +var games map[string]*gameEntry + +// OpenURL opens the specified URL in the default browser. +func OpenURL(url string) error { + var cmd string + var args []string + + switch runtime.GOOS { + case "windows": + cmd = "cmd" + args = []string{"/c", "start"} + case "darwin": + cmd = "open" + default: + cmd = "xdg-open" + } + args = append(args, url) + return exec.Command(cmd, args...).Start() +} + +func main() { + var port string + var host string + flag.StringVar(&port, "port", "8080", "port to run server on") + flag.StringVar(&host, "host", "127.0.0.1", "host address to bind to") + flag.Parse() + + root := flag.Arg(0) + if root == "" { + fmt.Fprintln(os.Stderr, "Usage: savegame-editor [-port PORT] [-host HOST] ") + os.Exit(1) + } + + log.Printf("Starting savegame editor server...") + log.Printf("Version %s-%s %s %s", version, commit, date, builtBy) + log.Printf("Savegame root: %s", root) + + // Scan for GAME_1 through GAME_10 + games = make(map[string]*gameEntry) + for i := 1; i <= 10; i++ { + slot := fmt.Sprintf("GAME_%d", i) + gamePath := filepath.Join(root, slot) + if _, err := os.Stat(filepath.Join(gamePath, "SAVEINFO.DAT")); os.IsNotExist(err) { + continue + } + sg, err := savegame.Load(gamePath) + if err != nil { + log.Printf("Warning: could not load %s: %v", slot, err) + continue + } + games[slot] = &gameEntry{sg: sg} + log.Printf("Loaded %s: %s", slot, sg.Title()) + } + + if len(games) == 0 { + log.Fatal("No savegames found in ", root) + } + + r := mux.NewRouter() + + // API routes + api := r.PathPrefix("/api").Subrouter() + api.HandleFunc("/games", handleListGames).Methods("GET") + api.HandleFunc("/games/{slot}", handleGetGame).Methods("GET") + api.HandleFunc("/games/{slot}/soldiers", handleListSoldiers).Methods("GET") + api.HandleFunc("/games/{slot}/soldiers/{idx}", handleGetSoldier).Methods("GET") + api.HandleFunc("/games/{slot}/soldiers/{idx}", handleUpdateSoldier).Methods("PUT") + api.HandleFunc("/games/{slot}/bases", handleListBases).Methods("GET") + api.HandleFunc("/games/{slot}/bases/{idx}", handleGetBase).Methods("GET") + api.HandleFunc("/games/{slot}/bases/{idx}", handleUpdateBase).Methods("PUT") + api.HandleFunc("/games/{slot}/craft", handleListCraft).Methods("GET") + api.HandleFunc("/games/{slot}/transfers", handleListTransfers).Methods("GET") + api.HandleFunc("/games/{slot}/locations", handleListLocations).Methods("GET") + api.HandleFunc("/games/{slot}/financials", handleGetFinancials).Methods("GET") + api.HandleFunc("/games/{slot}/financials", handleUpdateFinancials).Methods("PUT") + api.HandleFunc("/games/{slot}/actions/heal-all", handleHealAll).Methods("POST") + api.HandleFunc("/games/{slot}/actions/complete-constructions", handleCompleteConstructions).Methods("POST") + api.HandleFunc("/games/{slot}/actions/speedup-deliveries", handleSpeedupDeliveries).Methods("POST") + api.HandleFunc("/games/{slot}/save", handleSave).Methods("POST") + api.HandleFunc("/games/{slot}/reload", handleReload).Methods("POST") + + // SPA fallback: serve frontend for all non-API routes + frontendContent, err := fs.Sub(frontendFS, "frontend/dist") + if err != nil { + log.Fatal("Could not access embedded frontend: ", err) + } + fileServer := http.FileServer(http.FS(frontendContent)) + r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // If the path has no extension, serve index.html (SPA routing) + p := r.URL.Path + if p != "/" && !strings.Contains(path.Base(p), ".") { + r.URL.Path = "/" + } + fileServer.ServeHTTP(w, r) + }) + + srv := &http.Server{ + Addr: host + ":" + port, + WriteTimeout: time.Second * 15, + ReadTimeout: time.Second * 15, + IdleTimeout: time.Second * 60, + Handler: r, + } + + go func() { + if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + log.Fatal(err) + } + }() + + log.Printf("Server running on http://localhost:%s", port) + log.Println("Opening browser...") + _ = OpenURL("http://localhost:" + port) + + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + log.Println("Press Ctrl+C to stop.") + <-c + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + _ = srv.Shutdown(ctx) + log.Println("Shutting down.") + os.Exit(0) +} diff --git a/examples/animated-zombie/main.go b/examples/animated-zombie/main.go index 83d07b4..e50ad2a 100644 --- a/examples/animated-zombie/main.go +++ b/examples/animated-zombie/main.go @@ -5,7 +5,7 @@ import ( "image/gif" "os" - "github.com/redtoad/xcom-editor/lib/resources" + "github.com/redtoad/xcom-editor/resources" ) func main() { diff --git a/examples/revive-soldiers/main.go b/examples/revive-soldiers/main.go index ccdbc4c..06459d9 100644 --- a/examples/revive-soldiers/main.go +++ b/examples/revive-soldiers/main.go @@ -4,103 +4,48 @@ import ( "flag" "fmt" "log" - "os" - "path" - "strings" - "github.com/redtoad/xcom-editor/lib/savegame" + "github.com/redtoad/xcom-editor/savegame" ) +var Reset = "\033[0m" +var Red = "\033[31m" + func main() { rootPath := flag.String("path", ".", "save game path") flag.Parse() - pathSoldiersFile := path.Join(*rootPath, "SOLDIER.DAT") - if _, err := os.Stat(pathSoldiersFile); os.IsNotExist(err) { - log.Fatalf("could not open file: %v", err) - } - - fmt.Printf("Loading %s...\n", pathSoldiersFile) - var soldiers savegame.FileSoldier - if err := savegame.LoadFile(pathSoldiersFile, &soldiers); err != nil { - log.Fatalf("could not load file: %v", err) - } - - if err := savegame.SaveFile(pathSoldiersFile+".bak", &soldiers); err != nil { - log.Fatalf("could not create backup: %v\n", err) - } - - for no := 0; no < len(soldiers.Soldiers); no++ { - soldier := &soldiers.Soldiers[no] - // resurrect solders - if soldier.Rank == savegame.DeadOrUnused && strings.TrimSpace(soldier.Name) != "" { - fmt.Printf("Resurrect %s from the dead\n", soldier.Name) - soldier.Rank = savegame.Squaddie - } - if soldier.Rank != savegame.DeadOrUnused { - fmt.Printf("%d %v %s (%v)\n", no, soldier.Rank, soldier.Name, soldier.Armor) - soldier.Armor = savegame.PersonalArmor - soldier.InitialFiringAccuracy += 10 - soldier.InitialTimeUnits += 10 - soldier.InitialReactions += 10 - soldier.InitialBravery = 0 - soldier.InitialEnergy += 10 - soldier.RecoveryDays = 0 - } - } - - fmt.Printf("Storing %s...\n", pathSoldiersFile) - if err := savegame.SaveFile(pathSoldiersFile, &soldiers); err != nil { - log.Fatalf("could not save file: %v\n", err) - } - - pathBasesFile := *rootPath + string(os.PathSeparator) + "BASE.DAT" - if _, err := os.Stat(pathBasesFile); os.IsNotExist(err) { - log.Fatalf("could not open file: %v", err) - } - - fmt.Printf("Loading %s...\n", pathBasesFile) - var bases savegame.FileBase - if err := savegame.LoadFile(pathBasesFile, &bases); err != nil { - log.Fatalf("could not load file: %v", err) + sg, err := savegame.Load(*rootPath) + if err != nil { + log.Fatalf("could not load savegame: %v", err) } + fmt.Printf("Savegame %s: time=%v title=%s\n", + *rootPath, sg.Time(), sg.Title()) - if err := savegame.SaveFile(pathBasesFile+".bak", &bases); err != nil { - log.Fatalf("could not create backup: %v\n", err) - } - - for no := 0; no < len(bases.Bases); no++ { - base := &bases.Bases[no] - fmt.Printf("%d %s (%v)\n", no, base.Name, base.Active) - if !base.Active { - continue + for _, soldier := range sg.Soldiers() { + var craftName = "" + if craft := soldier.Craft(); craft == nil { + craftName = "no craft" + } else { + craftName = craft.Name() } - for no, cell := range base.Grid { - if no%6 == 0 { - println() - } - fmt.Print(cell.Tile()) + line := fmt.Sprintf("%s (%s) @ %v / %s", + soldier.Name(), soldier.Rank(), + craftName, soldier.Base().Name()) + if soldier.IsDead() { + soldier.Heal() + fmt.Println(Red + line + " revived as Squaddie" + Reset) + } else if soldier.IsWounded() { + soldier.Heal() + fmt.Println(Red + line + " healed" + Reset) + } else { + fmt.Println(line) } - println() - fmt.Printf("%v\n", base.Grid) - fmt.Printf("%v\n", base.DaysToCompletion) - - // complete constructions in progress - for i := 0; i < len(base.Grid); i++ { - if base.Grid[i] != savegame.Empty && base.DaysToCompletion[i] > 0 { - base.DaysToCompletion[i] = 0 - } - } - - // increase Elirium-115 - Elirium115 := 60 - base.Inventory[Elirium115] = 0xfffe } - fmt.Printf("Storing %s...\n", pathBasesFile) - if err := savegame.SaveFile(pathBasesFile, &bases); err != nil { - log.Fatalf("could not save file: %v\n", err) + if err := sg.Save(); err != nil { + panic(err) } } diff --git a/examples/world/main.go b/examples/world/main.go new file mode 100644 index 0000000..2f42da1 --- /dev/null +++ b/examples/world/main.go @@ -0,0 +1,87 @@ +package main + +import ( + "flag" + "fmt" + "image/color" + "log" + "path" + + "github.com/mmcloughlin/globe" + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geodata" + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/redtoad/xcom-editor/savegame" +) + +func main() { + + pth := flag.String("path", "./", "path to savegame dir") + flag.Parse() + + fmt.Print("Loading WORLD.DAT...\n") + world := geodata.WorldFile{} + if err := internal.LoadDATFile(path.Join(*pth, "..", "GEODATA", "WORLD.DAT"), &world); err != nil { + log.Fatalf("could not open WORLD.DAT: %s", err) + } + + locations := geoscape.LocFile{} + if err := internal.LoadDATFile(path.Join(*pth, "LOC.DAT"), &locations); err != nil { + log.Fatalf("could not read data from LOC.DAT: %s", err) + } + + //green := color.NRGBA{0x00, 0x64, 0x3c, 192} + red := color.NRGBA{0xff, 0x0, 0x0, 192} + blue := color.NRGBA{0x0, 0x0, 0xff, 192} + + g := globe.New() + g.DrawGraticule(10.0) + g.DrawLandBoundaries() + + for _, loc := range locations.Objects { + coord := savegame.NewCoord(loc.X, loc.Y) + x, y := float64(coord.Lat), float64(coord.Lon) + switch loc.Type { + case geoscape.XCOMBase: + log.Printf("BaseData: %s", coord) + //g.DrawDot(x, y, 0.1, globe.Color(green)) + case geoscape.XCOMShip: + log.Printf("Ship: %s", coord) + g.DrawDot(x, y, 0.1, globe.Color(blue)) + case geoscape.AlienShip: + log.Printf("UFO: %s", coord) + g.DrawDot(x, y, 0.05, globe.Color(red)) + case geoscape.CrashSite: + log.Printf("Crash site: %s", coord) + g.DrawDot(x, y, 0.5, globe.Color(red)) + case geoscape.AlienBase: + log.Printf("Alien base: %s", coord) + g.DrawDot(x, y, 0.5, globe.Color(red)) + case geoscape.LandedUFO: + log.Printf("UFO landed: %s", coord) + case geoscape.Waypoint: + log.Printf("Waypoint: %s", coord) + + } + } + + g.CenterOn(51.453349, -2.588323) + g.SavePNG("land.png", 400) + + fmt.Printf("%v\n", locations) + fmt.Printf("%v\n", world.Polygons[0]) + + /* + fmt.Printf(` + + `) + for _, poly := range world.Polygons { + points := fmt.Sprintf("%d %d %d %d %d %d %d %d", poly.X0, poly.Y0, poly.X1, poly.Y1, poly.X2, poly.Y2, poly.X3, poly.Y3) + if poly.Type() == resources.Triangle { + points = fmt.Sprintf("%d %d %d %d %d %d", poly.X0, poly.Y0, poly.X1, poly.Y1, poly.X2, poly.Y2) + } + fmt.Printf(``, resources.TerrainHexColorsXCom[poly.Terrain], points) + } + fmt.Printf(``) + */ +} diff --git a/go.mod b/go.mod index a3146ed..0b5384f 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,20 @@ require ( github.com/go-restruct/restruct v1.2.0-alpha github.com/gorilla/mux v1.8.0 github.com/stretchr/testify v1.8.4 + golang.org/x/text v0.14.0 +) + +require ( + github.com/fogleman/gg v1.3.0 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/google/btree v1.1.2 // indirect + github.com/tidwall/pinhole v0.0.0-20210130162507-d8644a7c3d19 // indirect + golang.org/x/image v0.6.0 // indirect ) require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/mmcloughlin/globe v0.0.0-20230826193537-2fd3b7115b13 github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index db9232c..5d51fd3 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,18 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/go-restruct/restruct v1.2.0-alpha h1:2Lp474S/9660+SJjpVxoKuWX09JsXHSrdV7Nv3/gkvc= github.com/go-restruct/restruct v1.2.0-alpha/go.mod h1:KqrpKpn4M8OLznErihXTGLlsXFGeLxHUrLRRI/1YjGk= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/mmcloughlin/globe v0.0.0-20230826193537-2fd3b7115b13 h1:ZCUNYSI5s6huQeP+9t0r1/E1Fwk7eTMWC8jfbkvWr0Y= +github.com/mmcloughlin/globe v0.0.0-20230826193537-2fd3b7115b13/go.mod h1:KO2C9UXlC8EA6ScZmeX+bi4Ashw0Nn3DZS2LPoIcO90= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -12,10 +20,49 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tidwall/pinhole v0.0.0-20210130162507-d8644a7c3d19 h1:PH18rfaiwA/34DAtuREBTrrByvZeLHqhfYh4SG7jYg4= +github.com/tidwall/pinhole v0.0.0-20210130162507-d8644a7c3d19/go.mod h1:5VfbOBfzaI6Y0XiGSkz7hiXgKtwYaDBI3plwKGsLonM= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/image v0.6.0 h1:bR8b5okrPI3g/gyZakLZHeWxAR8Dn5CyxXv1hLH5g/4= +golang.org/x/image v0.6.0/go.mod h1:MXLdDR43H7cDJq5GEGXEVeeNhPgi+YYEQ2pC1byI1x0= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/geodata/geodata.go b/internal/geodata/geodata.go new file mode 100644 index 0000000..a3b7215 --- /dev/null +++ b/internal/geodata/geodata.go @@ -0,0 +1,5 @@ +// Package geodata +// +// These are data files which store information for the game like +// localization strings, weapons data and globe terrain. +package geodata diff --git a/internal/geodata/interwin_dat.go b/internal/geodata/interwin_dat.go new file mode 100644 index 0000000..0011070 --- /dev/null +++ b/internal/geodata/interwin_dat.go @@ -0,0 +1,4 @@ +package geodata + +// Ten images used by the UFO Interception display. Direct palette indexes, no compression. 88,960 bytes in total. +// https://www.ufopaedia.org/index.php/INTERWIN.DAT diff --git a/internal/geodata/loftemps_dat.go b/internal/geodata/loftemps_dat.go new file mode 100644 index 0000000..a74ecc2 --- /dev/null +++ b/internal/geodata/loftemps_dat.go @@ -0,0 +1,6 @@ +package geodata + +// LOFTEMPS.DAT is found in the GEODATA folder. It contains "Line of Fire Templates", used to create +// 3D representations of the creatures and objects within the battlescape. These are used for Line of sight (LOS) +// (to see units, terrain uses MCD[31]) and line of fire (LOF) purposes. +// https://www.ufopaedia.org/index.php/LOFTEMPS.DAT diff --git a/internal/geodata/obdata_dat.go b/internal/geodata/obdata_dat.go new file mode 100644 index 0000000..3057892 --- /dev/null +++ b/internal/geodata/obdata_dat.go @@ -0,0 +1,5 @@ +package geodata + +// OBDATA.DAT is found in GEODATA and contains general information on objects found in the game, such as their accuracy +// and weight. It also contains template information regarding clip size +// https://www.ufopaedia.org/index.php/OBDATA.DAT diff --git a/internal/geodata/scang_dat.go b/internal/geodata/scang_dat.go new file mode 100644 index 0000000..bddf14c --- /dev/null +++ b/internal/geodata/scang_dat.go @@ -0,0 +1,5 @@ +package geodata + +// Stored in the GEODATA folder, SCANG.DAT is used along with SCANBORD.PCK to present the overhead map. +// The title presumably stands for SCANner Graphics. +// https://www.ufopaedia.org/index.php/SCANG.DAT diff --git a/internal/geodata/world_dat.go b/internal/geodata/world_dat.go new file mode 100644 index 0000000..abc595e --- /dev/null +++ b/internal/geodata/world_dat.go @@ -0,0 +1,95 @@ +package geodata + +import ( + "bytes" + "encoding/binary" + "fmt" + "io" + + "github.com/go-restruct/restruct" +) + +// WorldFile describes the terrain on the geoscape screen using quadrilateral polygons and triangles +// loaded from GEODATA/WORLD.DAT. +// +// The first 16 bytes of file contain the points for the polygon. 4 sets of 2 short (2-byte) integers, +// designating the 'X' and 'Y' coordinate (or longitude and latitude respectively, if you prefer). If +// the last set has an x value of -1 then it is to be rendered as a triangle, otherwise it is a quad. +// +// The last 4 bytes in the record contain the terrain type. This could be a long integer or 2 short +// integers as the last 2 bytes in each record are 0. +// +// See https://www.ufopaedia.org/index.php/WORLD.DAT for more information. +type WorldFile struct { + Polygons []Polygon +} + +func (w *WorldFile) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { + + reader := bytes.NewReader(buf) + for { + data := make([]byte, 20) + noBytes, err := reader.Read(data) + if err != nil { + if err == io.EOF { + break + } + return nil, fmt.Errorf("could not read next data chunk: %w", err) + } + var poly Polygon + if noBytes != poly.SizeOf() { + return nil, fmt.Errorf("not enough to read all polygon data") + } + if err := restruct.Unpack(data, order, &poly); err != nil { + return nil, fmt.Errorf("could not unpack polygon: %w", err) + } + w.Polygons = append(w.Polygons, poly) + } + return []byte{}, nil +} + +type Polygon struct { + + // First X coordinate/longitude + X0 int `struct:"int16"` + // First Y coordinate/latitude + Y0 int `struct:"int16"` + // Second X coordinate/longitude + X1 int `struct:"int16"` + // Second Y coordinate/latitude + Y1 int `struct:"int16"` + // Third X coordinate/longitude + X2 int `struct:"int16"` + // Third Y coordinate/latitude + Y2 int `struct:"int16"` + // Fourth* X coordinate/longitude + X3 int `struct:"int16"` + // Fourth* Y coordinate/latitude + Y3 int `struct:"int16"` + + // Terrain Type/Texture 0-12 + Terrain int `struct:"int32"` +} + +func (p *Polygon) Type() PolygonType { + if p.X3 == -1 { + return Triangle + } + return QuadrilateralPolygon +} + +func (p Polygon) SizeOf() int { return 20 } + +func (p Polygon) String() string { + return fmt.Sprintf( + "P{(%d,%d) (%d,%d) (%d,%d) (%d,%d) terrain=%d}", + p.X0, p.Y0, p.X1, p.Y1, p.X2, p.Y2, p.X3, p.Y3, p.Terrain, + ) +} + +type PolygonType int + +const ( + Triangle PolygonType = iota + QuadrilateralPolygon +) diff --git a/internal/geodata/world_dat_test.go b/internal/geodata/world_dat_test.go new file mode 100644 index 0000000..9390cf8 --- /dev/null +++ b/internal/geodata/world_dat_test.go @@ -0,0 +1,50 @@ +package geodata_test + +import ( + "encoding/base64" + "encoding/binary" + "reflect" + "testing" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geodata" +) + +func MustDecode(txt string) []byte { + data, err := base64.StdEncoding.DecodeString(txt) + if err != nil { + panic(err) + } + return data +} + +func TestWORLD_DAT_Unpack(t *testing.T) { + tests := []struct { + name string + buffer []byte + want []geodata.Polygon + wantErr bool + }{ + { + "read one polygon", + MustDecode("7Ape/vQKZf4MC17+9gpW/gEAAAA="), + []geodata.Polygon{ + {2796, -418, 2804, -411, 2828, -418, 2806, -426, 1}, + }, + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + world := &geodata.WorldFile{} + err := restruct.Unpack(tt.buffer, binary.LittleEndian, &world) + if (err != nil) != tt.wantErr { + t.Errorf("WORLD_DAT.Unpack() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(world.Polygons, tt.want) { + t.Errorf("WORLD_DAT.Unpack() = %v, want %v", world.Polygons, tt.want) + } + }) + } +} diff --git a/internal/geoscape/base_dat.go b/internal/geoscape/base_dat.go new file mode 100644 index 0000000..443710b --- /dev/null +++ b/internal/geoscape/base_dat.go @@ -0,0 +1,229 @@ +package geoscape + +//go:generate stringer -type=Facility,Inventory -output=base_dat_string.go -linecomment -trimprefix Inventory + +import ( + "encoding/binary" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal" +) + +const maxBases = 8 + +// Each base entry is 292 bytes long. +const baseByteLength = 292 + +// BaseFile has all of the base layout and contents information, as well as +// base name info. +// +// https://www.ufopaedia.org/index.php/BASE.DAT +type BaseFile struct { + Bases []BaseData +} + +func (s BaseFile) SizeOf() int { + return baseByteLength * maxBases +} + +func (s BaseFile) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { + for i := 0; i < maxBases; i++ { + data, err := restruct.Pack(order, &s.Bases[i]) + if err != nil { + return nil, err + } + offset := i * baseByteLength + for j := 0; j < len(data); j++ { + buf[offset+j] = data[j] + } + } + return buf, nil +} + +func (s *BaseFile) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { + s.Bases = make([]BaseData, maxBases) + for i := 0; i < maxBases; i++ { + offset := i * baseByteLength + data := buf[offset : offset+baseByteLength] + if err := restruct.Unpack(data, order, &s.Bases[i]); err != nil { + return nil, err + } + } + return buf[s.SizeOf():], nil +} + +type BaseData struct { + + // 00-0E: BaseData Name, pretty obvious + // 0F: Presumably the Null character if the BaseData Name uses all 15 characters + Name internal.NullString `struct:"[16]byte"` + + // Logical values for the detection capabilities: + // + //10 short, 0 long: This base has small radar(s) only. + // + //20 short, 20 long: This base has large radar(s) only. + // + //30 short, 20 long: This base has small and large radar(s). + // + //100 hyperwave: This base has a hyperwave decoder(s). + // + //The radar values can be set to 100 for perfect short range detection (presumably -- it definitely makes UFOs appear more often), but these reset to the correct values any time you complete a build in that base. + + // 10-11: BaseData's short range detection capability. + ShortRange int `struct:"int16"` + + // 12-13: BaseData's long range detection capability. + LongRange int `struct:"int16"` + + // 14-15: BaseData's hyperwave detection capability. + Hyperwave int `struct:"int16"` + + // 16-39: The next offsets are arranged so they're easier to understand. They are for facilities in the base: + Grid [36]Facility `struct:"[36]uint8"` + + // 3A-5D: The next offsets represent the days until a facility is completed. They're set up the same way: + DaysToCompletion [36]uint `struct:"[36]uint8"` + + Engineers int `struct:"int8"` + Scientists int `struct:"int8"` + + // 60-11E inventory + Inventory [96]int `struct:"[96]int16"` + + // 0120-0123: Active/Inactive BaseData, stored as a 4-byte integer. + // Inactive entries have a value of 1. Active entries have a value of 0. + // Creating a new base will overwrite the first inactive entry. If a base is + // dismantled, the only change to the record is this value so it is possible + // to restore a dismantled base (Access lift removed) by restoring this value to 0. + Active bool `struct:"int32,invertedbool"` +} + + +type Facility uint + +const ( + AccessLift Facility = iota // Access Lift + LivingQuarters // Living Quarters + Laboratory + Workshop + SmallRadarSystem // Small Radar System + LargeRadarSystem // Large Radar System + MissileDefense // Missile Defense + GeneralStores // General Stores + AlienContainment // Alien Containment + LaserDefense // Laser Defense + PlasmaDefense // Plasma Defense + FusionBallDefense // Fusion Ball Defense + GravShield // Grav Shield + MindShield // Mind Shield + PsionicLaboratory // Psionic laboratory + HyperwaveDecoder // Hyperwave Decoder + HangarTopLeft // Hangar (top left) + HangarTopRight// Hangar (top right) + HangarBottomLeft // Hangar (bottom left) + HangarBottomRight // Hangar (bottom right) + Empty Facility = 0xff +) + +type Inventory int +const ( + InventoryStingrayLauncher Inventory = iota // stingray launcher + InventoryAvalancheLauncher // avalanche launcher + InventoryCannon + InventoryFusionBallLauncher + InventoryLaserCannon + InventoryPlasmaBeam + InventoryStingrayMissile + InventoryAvalancheMissile + InventoryCannonRounds + InventoryFusionBalls + InventoryTankCannon + InventoryTankRocketLauncher + InventoryTankLaserCannon + InventoryHovertankPlasma + InventoryHovertankLauncher + InventoryPistol + InventoryPistolClip + InventoryRifle + InventoryRifleClip + InventoryHeavyCannon + InventoryHCAPAmmo + InventoryHCHEAmmo + InventoryHCINAmmo + InventoryAutoCannon + InventoryACAPAmmo + InventoryACHEAmmo + InventoryACINAmmo + InventoryRocketLauncher + InventorySmallRocket + InventoryLargeRocket + InventoryIncendiaryRocket + InventoryLaserPistol + InventoryLaserRifle + InventoryHeavyLaser + InventoryGrenade + InventorySmokeGrenade + InventoryProximityGrenade + InventoryHighExplosive + InventoryMotionScanner + InventoryMediKit + InventoryPsiAmp + InventoryStunRod + InventoryElectroFlare + _ + _ + _ + InventoryCorpse + InventoryCorpseArmour + InventoryCorpsePowersuit + InventoryHeavyPlasma + InventoryHeavyPlasmaClip + InventoryPlasmaRifle + InventoryPlasmaRifleClip + InventoryPlasmaPistol + InventoryPlasmaPistolClip + InventoryBlasterLauncher + InventoryBlasterBomb + InventorySmallLauncher + InventoryStunBomb + InventoryAlienGrenade + InventoryElerium115 + InventoryMindProbe + _ + _ + _ + InventorySectoidCorpse + InventorySnakemanCorpse + InventoryEtherealCorpse + InventoryMutonCorpse + InventoryFloaterCorpse + InventoryCelatidCorpse + InventorySilacoidCorpse + InventoryChryssalidCorpse + InventoryReaperCorpse + InventorySectopodCorpse + InventoryCyberdiscCorpse + InventoryHovertankCorpse + InventoryTankCorpse + InventoryMaleCivilianCorpse + InventoryFemaleCivilianCorpse + InventoryUFOPowerSource + InventoryUFONavigation + InventoryUFOConstruction + InventoryAlienFood + InventoryAlienReproduction + InventoryAlienEntertainment + InventoryAlienSurgery + InventoryExaminationRoom + InventoryAlienAlloys + InventoryAlienHabitat + InventoryPersonalArmour + InventoryPowerSuit + InventoryFlyingSuit + InventoryHWPCannonShell + InventoryHWPRockets + InventoryHWPFusionBomb +) + + diff --git a/internal/geoscape/base_dat_string.go b/internal/geoscape/base_dat_string.go new file mode 100644 index 0000000..2a24038 --- /dev/null +++ b/internal/geoscape/base_dat_string.go @@ -0,0 +1,174 @@ +// Code generated by "stringer -type=Facility,Inventory -output=base_dat_string.go -linecomment -trimprefix Inventory"; DO NOT EDIT. + +package geoscape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[AccessLift-0] + _ = x[LivingQuarters-1] + _ = x[Laboratory-2] + _ = x[Workshop-3] + _ = x[SmallRadarSystem-4] + _ = x[LargeRadarSystem-5] + _ = x[MissileDefense-6] + _ = x[GeneralStores-7] + _ = x[AlienContainment-8] + _ = x[LaserDefense-9] + _ = x[PlasmaDefense-10] + _ = x[FusionBallDefense-11] + _ = x[GravShield-12] + _ = x[MindShield-13] + _ = x[PsionicLaboratory-14] + _ = x[HyperwaveDecoder-15] + _ = x[HangarTopLeft-16] + _ = x[HangarTopRight-17] + _ = x[HangarBottomLeft-18] + _ = x[HangarBottomRight-19] + _ = x[Empty-255] +} + +const ( + _Facility_name_0 = "Access LiftLiving QuartersLaboratoryWorkshopSmall Radar SystemLarge Radar SystemMissile DefenseGeneral StoresAlien ContainmentLaser DefensePlasma DefenseFusion Ball DefenseGrav ShieldMind ShieldPsionic laboratoryHyperwave DecoderHangar (top left)Hangar (top right)Hangar (bottom left)Hangar (bottom right)" + _Facility_name_1 = "Empty" +) + +var ( + _Facility_index_0 = [...]uint16{0, 11, 26, 36, 44, 62, 80, 95, 109, 126, 139, 153, 172, 183, 194, 212, 229, 246, 264, 284, 305} +) + +func (i Facility) String() string { + switch { + case i <= 19: + return _Facility_name_0[_Facility_index_0[i]:_Facility_index_0[i+1]] + case i == 255: + return _Facility_name_1 + default: + return "Facility(" + strconv.FormatInt(int64(i), 10) + ")" + } +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[InventoryStingrayLauncher-0] + _ = x[InventoryAvalancheLauncher-1] + _ = x[InventoryCannon-2] + _ = x[InventoryFusionBallLauncher-3] + _ = x[InventoryLaserCannon-4] + _ = x[InventoryPlasmaBeam-5] + _ = x[InventoryStingrayMissile-6] + _ = x[InventoryAvalancheMissile-7] + _ = x[InventoryCannonRounds-8] + _ = x[InventoryFusionBalls-9] + _ = x[InventoryTankCannon-10] + _ = x[InventoryTankRocketLauncher-11] + _ = x[InventoryTankLaserCannon-12] + _ = x[InventoryHovertankPlasma-13] + _ = x[InventoryHovertankLauncher-14] + _ = x[InventoryPistol-15] + _ = x[InventoryPistolClip-16] + _ = x[InventoryRifle-17] + _ = x[InventoryRifleClip-18] + _ = x[InventoryHeavyCannon-19] + _ = x[InventoryHCAPAmmo-20] + _ = x[InventoryHCHEAmmo-21] + _ = x[InventoryHCINAmmo-22] + _ = x[InventoryAutoCannon-23] + _ = x[InventoryACAPAmmo-24] + _ = x[InventoryACHEAmmo-25] + _ = x[InventoryACINAmmo-26] + _ = x[InventoryRocketLauncher-27] + _ = x[InventorySmallRocket-28] + _ = x[InventoryLargeRocket-29] + _ = x[InventoryIncendiaryRocket-30] + _ = x[InventoryLaserPistol-31] + _ = x[InventoryLaserRifle-32] + _ = x[InventoryHeavyLaser-33] + _ = x[InventoryGrenade-34] + _ = x[InventorySmokeGrenade-35] + _ = x[InventoryProximityGrenade-36] + _ = x[InventoryHighExplosive-37] + _ = x[InventoryMotionScanner-38] + _ = x[InventoryMediKit-39] + _ = x[InventoryPsiAmp-40] + _ = x[InventoryStunRod-41] + _ = x[InventoryElectroFlare-42] + _ = x[InventoryCorpse-46] + _ = x[InventoryCorpseArmour-47] + _ = x[InventoryCorpsePowersuit-48] + _ = x[InventoryHeavyPlasma-49] + _ = x[InventoryHeavyPlasmaClip-50] + _ = x[InventoryPlasmaRifle-51] + _ = x[InventoryPlasmaRifleClip-52] + _ = x[InventoryPlasmaPistol-53] + _ = x[InventoryPlasmaPistolClip-54] + _ = x[InventoryBlasterLauncher-55] + _ = x[InventoryBlasterBomb-56] + _ = x[InventorySmallLauncher-57] + _ = x[InventoryStunBomb-58] + _ = x[InventoryAlienGrenade-59] + _ = x[InventoryElerium115-60] + _ = x[InventoryMindProbe-61] + _ = x[InventorySectoidCorpse-65] + _ = x[InventorySnakemanCorpse-66] + _ = x[InventoryEtherealCorpse-67] + _ = x[InventoryMutonCorpse-68] + _ = x[InventoryFloaterCorpse-69] + _ = x[InventoryCelatidCorpse-70] + _ = x[InventorySilacoidCorpse-71] + _ = x[InventoryChryssalidCorpse-72] + _ = x[InventoryReaperCorpse-73] + _ = x[InventorySectopodCorpse-74] + _ = x[InventoryCyberdiscCorpse-75] + _ = x[InventoryHovertankCorpse-76] + _ = x[InventoryTankCorpse-77] + _ = x[InventoryMaleCivilianCorpse-78] + _ = x[InventoryFemaleCivilianCorpse-79] + _ = x[InventoryUFOPowerSource-80] + _ = x[InventoryUFONavigation-81] + _ = x[InventoryUFOConstruction-82] + _ = x[InventoryAlienFood-83] + _ = x[InventoryAlienReproduction-84] + _ = x[InventoryAlienEntertainment-85] + _ = x[InventoryAlienSurgery-86] + _ = x[InventoryExaminationRoom-87] + _ = x[InventoryAlienAlloys-88] + _ = x[InventoryAlienHabitat-89] + _ = x[InventoryPersonalArmour-90] + _ = x[InventoryPowerSuit-91] + _ = x[InventoryFlyingSuit-92] + _ = x[InventoryHWPCannonShell-93] + _ = x[InventoryHWPRockets-94] + _ = x[InventoryHWPFusionBomb-95] +} + +const ( + _Inventory_name_0 = "stingray launcheravalanche launcherCannonFusionBallLauncherLaserCannonPlasmaBeamStingrayMissileAvalancheMissileCannonRoundsFusionBallsTankCannonTankRocketLauncherTankLaserCannonHovertankPlasmaHovertankLauncherPistolPistolClipRifleRifleClipHeavyCannonHCAPAmmoHCHEAmmoHCINAmmoAutoCannonACAPAmmoACHEAmmoACINAmmoRocketLauncherSmallRocketLargeRocketIncendiaryRocketLaserPistolLaserRifleHeavyLaserGrenadeSmokeGrenadeProximityGrenadeHighExplosiveMotionScannerMediKitPsiAmpStunRodElectroFlare" + _Inventory_name_1 = "CorpseCorpseArmourCorpsePowersuitHeavyPlasmaHeavyPlasmaClipPlasmaRiflePlasmaRifleClipPlasmaPistolPlasmaPistolClipBlasterLauncherBlasterBombSmallLauncherStunBombAlienGrenadeElerium115MindProbe" + _Inventory_name_2 = "SectoidCorpseSnakemanCorpseEtherealCorpseMutonCorpseFloaterCorpseCelatidCorpseSilacoidCorpseChryssalidCorpseReaperCorpseSectopodCorpseCyberdiscCorpseHovertankCorpseTankCorpseMaleCivilianCorpseFemaleCivilianCorpseUFOPowerSourceUFONavigationUFOConstructionAlienFoodAlienReproductionAlienEntertainmentAlienSurgeryExaminationRoomAlienAlloysAlienHabitatPersonalArmourPowerSuitFlyingSuitHWPCannonShellHWPRocketsHWPFusionBomb" +) + +var ( + _Inventory_index_0 = [...]uint16{0, 17, 35, 41, 59, 70, 80, 95, 111, 123, 134, 144, 162, 177, 192, 209, 215, 225, 230, 239, 250, 258, 266, 274, 284, 292, 300, 308, 322, 333, 344, 360, 371, 381, 391, 398, 410, 426, 439, 452, 459, 465, 472, 484} + _Inventory_index_1 = [...]uint8{0, 6, 18, 33, 44, 59, 70, 85, 97, 113, 128, 139, 152, 160, 172, 182, 191} + _Inventory_index_2 = [...]uint16{0, 13, 27, 41, 52, 65, 78, 92, 108, 120, 134, 149, 164, 174, 192, 212, 226, 239, 254, 263, 280, 298, 310, 325, 336, 348, 362, 371, 381, 395, 405, 418} +) + +func (i Inventory) String() string { + switch { + case 0 <= i && i <= 42: + return _Inventory_name_0[_Inventory_index_0[i]:_Inventory_index_0[i+1]] + case 46 <= i && i <= 61: + i -= 46 + return _Inventory_name_1[_Inventory_index_1[i]:_Inventory_index_1[i+1]] + case 65 <= i && i <= 95: + i -= 65 + return _Inventory_name_2[_Inventory_index_2[i]:_Inventory_index_2[i+1]] + default: + return "Inventory(" + strconv.FormatInt(int64(i), 10) + ")" + } +} diff --git a/internal/geoscape/base_dat_test.go b/internal/geoscape/base_dat_test.go new file mode 100644 index 0000000..15c1a9b --- /dev/null +++ b/internal/geoscape/base_dat_test.go @@ -0,0 +1,64 @@ +package geoscape_test + +import ( + "encoding/binary" + "testing" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_BASE_DAT_RoundTrip(t *testing.T) { + // Create a buffer of 2336 bytes (8 bases * 292 bytes each) + data := make([]byte, 8*292) + + // Set up first base with a name and active flag + // Name: "XCOM BASE" (16 bytes, null-terminated) + copy(data[0:16], []byte("XCOM BASE\x00\x00\x00\x00\x00\x00\x00")) + + // Short range radar: 10 + data[16] = 0x0A + data[17] = 0x00 + + // Grid: access lift at position 0 + data[22] = byte(geoscape.AccessLift) + // Rest of grid defaults to 0 (also AccessLift) - set to Empty (0xFF) + for i := 23; i < 22+36; i++ { + data[i] = 0xFF + } + data[22] = byte(geoscape.AccessLift) + + // Engineers at offset 94 (16+2+2+2+36+36) + data[94] = 10 + // Scientists at offset 95 + data[95] = 5 + + // Active flag at offset 288 (16+2+2+2+36+36+2+192) + // Active=true means the int32 is 0 (invertedbool) + data[288] = 0x00 + data[289] = 0x00 + data[290] = 0x00 + data[291] = 0x00 + + // Set remaining bases as inactive (Active=false means int32=1 with invertedbool) + for b := 1; b < 8; b++ { + offset := b * 292 + data[offset+288] = 0x01 + } + + var obj geoscape.BaseFile + err := restruct.Unpack(data, binary.LittleEndian, &obj) + require.NoError(t, err) + assert.Equal(t, 8, len(obj.Bases)) + assert.Equal(t, "XCOM BASE", obj.Bases[0].Name.String()) + assert.Equal(t, 10, obj.Bases[0].Engineers) + assert.Equal(t, 5, obj.Bases[0].Scientists) + assert.True(t, obj.Bases[0].Active) + assert.False(t, obj.Bases[1].Active) + + encoded, err := restruct.Pack(binary.LittleEndian, obj) + require.NoError(t, err) + assert.Equal(t, data, encoded, "round-trip should produce identical bytes") +} diff --git a/internal/geoscape/craft_dat.go b/internal/geoscape/craft_dat.go new file mode 100644 index 0000000..9785769 --- /dev/null +++ b/internal/geoscape/craft_dat.go @@ -0,0 +1,259 @@ +package geoscape + +//go:generate stringer -type=CraftType,Altitude,FlightMode,WeaponType,MissionType,MissionZone,CraftStatus -output=craft_dat_string.go -linecomment + +import ( + "encoding/binary" + "fmt" + + "github.com/go-restruct/restruct" +) + +type CraftFile struct { + Crafts []CraftData +} + +const maxCrafts = 50 +const craftByteLength = 104 + +func (cf CraftFile) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { + for i := 0; i < maxCrafts; i++ { + data, err := restruct.Pack(order, &cf.Crafts[i]) + if err != nil { + return nil, err + } + offset := i * craftByteLength + for j := 0; j < len(data); j++ { + buf[offset+j] = data[j] + } + } + return buf, nil +} + +func (cf *CraftFile) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { + cf.Crafts = make([]CraftData, maxCrafts) + for i := 0; i < maxCrafts; i++ { + offset := i * craftByteLength + data := buf[offset : offset+craftByteLength] + if err := restruct.Unpack(data, order, &cf.Crafts[i]); err != nil { + return nil, fmt.Errorf("could not unpack []Crafts: %w", err) + } + } + return buf[cf.SizeOf():], nil +} + +func (cf *CraftFile) SizeOf() int { + return maxCrafts * craftByteLength +} + +type CraftData struct { + + // 0 0x00 Craft type, Possible values are the same as GEODATA.DAT: + // *HUMAN* *ALIEN* + // 0 - Skyranger 5 - Small Scout 255 - Entry Not Used + // 1 - Lightning 6 - Medium Scout + // 2 - Avenger 7 - Large Scout + // 3 - Interceptor 8 - Harvester + // 4 - Firestorm 9 - Abductor + // 10 - Terror Ship + // 11 - Battleship + // 12 - Supply Ship + Type CraftType `struct:"int8"` + + // Offsets 1 and 5 refer to the weapon placed in the left and right slots respectively. (The Lightning does not have a center weapon type, only a left). Their possible values are listed here: + // 0 - Stingray + // 1 - Avalanche + // 2 - Cannon + // 3 - Fusion Ball + // 4 - Laser Cannon + // 5 - Plasma Beam + // 255 - No Weapon + + // 1 0x01 Left weapon type + LeftWeapon WeaponType `struct:"int8"` + + // 2-3 0x02-0x03 Left ammo + LeftAmmo int `struct:"int16"` + + // 4 0x04 Indicates flight mode + FlightMode FlightMode `struct:"int8"` + + // 5 0x05 Right weapon type + RightWeapon WeaponType `struct:"int8"` + + // 6-7 0x06-0x07 Right ammo + RightAmmo int `struct:"int16"` + + // 8-9 0x08-0x09 Unused. + Unused int `struct:"int16"` + + // Damage, that is the amount it currently has taken. This value divided by the + // crafts damage capacity gives the percentage shown in-game. + Damage int `struct:"int16"` + + // 12-13 0x0C-0x0D Altitude of craft. Is a index within ENGLISH.DAT for string. + // 0 = GROUND * + // 1 = VERY LOW + // 2 = LOW + // 3 = HIGH + // 4 = VERY HIGH + // (*NOTE: If craft is airborne and you change it to this value the altitude will remain the same. Speed must be edited to 0 for the change to hold.) + Altitude Altitude `struct:"int16"` + + // 14-15 0x0E-0x0F Speed of craft. + Speed int `struct:"int16"` + + // 16-17 0x10-0x11 Index into LOC.DAT referencing the destination - for example, waypoints for X-COM craft, or X-COM bases for alien craft. + Destination int `struct:"int16"` + + // 18-19 0x12-0x13 Index into INTER.DAT when the ship is in interception mode. + InterceptionRef int `struct:"int16"` + + // 20-21 0x14-0x15 Next UFO waypoint coordinate X (longitude). + NextUFOWaypointLon int `struct:"int16"` + + // 22-23 0x16-0x17 Next UFO waypoint coordinate Y (latitude). + NextUFOWaypointLat int `struct:"int16"` + + // 24-25 0x18-0x19 Fuel, amount remaining. This value divided by the crafts total fuel capacity gives the percentage shown in-game. + FuelAmountRemaining int `struct:"int16"` + + // 26-27 0x1A-0x1B BaseData reference as an index to LOC.DAT. + BaseReference Altitude `struct:"int16"` + + // 28-29 0x1C-0x1D Mission type craft is on. Is an index within ENGLISH.DAT for the string (558 + this value). + MissionType MissionType `struct:"int16"` + + // 30-31 0x1E-0x1F Zone where mission is being carried out. Is an index within ENGLISH.DAT for string (543 + this value). + MissionZone MissionZone `struct:"int16"` + + // 32-33 0x20-0x21 UFO trajectory segment (ranges from 0-7). + UFOTrajectorySegment int `struct:"int16"` + + // 34-35 0x22-0x23 UFO trajectory type (ranges from 0-9). + UFOTrajectoryType int `struct:"int16"` + + // 36-37 0x24-0x25 Alien Race found on craft. Is index within ENGLISH.DAT for the string (466 + this value). + // UFO TFTD + // 0 = Sectoid Aquatoid + // 1 = Snakeman Gillman + // 2 = Ethereal Lobsterman + // 3 = Muton Tasoth + // 4 = Floater Mixed Crew (Type I) + // 5 = Final mission mix Mixed Crew (Type II) + AlienRace int `struct:"int16"` + + // 38-39 0x26-0x27 UFO attack timer. + UFOAttackTimer int `struct:"int16"` + + // 40-41 0x28-0x29 UFO escape manuever timer. + UFOEscapeManueverTimer int `struct:"int16"` + + // 42-43 0x2A-0x2B Craft status. Is an index within ENGLISH.DAT for the string (268 + this value). + Status CraftStatus `struct:"int16"` + + // 44-103: Cargo items and flags. Offsets 44-98 contain item counts on board the craft + // (mapping to OBDATA.DAT entries). Offsets 100-103 contain a bitfield for craft state flags. + Cargo [60]byte `struct:"[60]byte"` +} + +// SizeOf implements restruct.Sizer +func (c CraftData) SizeOf() int { + return 104 +} + +type CraftType int + +const ( + Skyranger CraftType = iota + Lightning + Avenger + Interceptor + Firestorm + + SmallScout // small scout + MediumScout // medium scout + LargeScout // large scout + Harvester + Abductor + + TerrorShip // terror ship + Battleship + SupplyShip // supply ship + + EntryNotUsed = -1 // entry not used +) + +type Altitude int + +const ( + Ground Altitude = iota + VeryLow // very low + Low + High + VeryHigh // very high +) + +type FlightMode int + +const ( + NoDestination FlightMode = iota // No destination set (at base) + SingleDestination // Single destination + MultipleDestinations // Multiple destinations (UFO only) + +) + +type WeaponType int + +const ( + Stingray WeaponType = iota + Avalanche + Cannon + FusionBall // fusion ball + LaserCannon // laser cannon + PlasmaBeam // plasma beam + NoWeapon = 255 +) + +type MissionType int + +const ( + MissionAlienResearch MissionType = iota // Alien Research + MissionAlienHarvest // Alien Harvest + MissionAlienAbduction // Alien Abduction + MissionAlienInfiltration // Alien Infiltration + MissionAlienBase // Alien Base + MissionAlienTerror // Alien Terror + MissionAlienRetaliation // Alien Retaliation + MissionAlienSupply // Alien Supply +) + +type MissionZone int + +const ( + NorthAmerica MissionZone = iota // North America + Arctic // Arctic + Antarctica // Antarctica + SouthAmerica // South America + Europe // Europe + NorthAfrica // North Africa + SouthernAfrica // Southern Africa + CentralAsia // Central Asia + SouthEastAsia // South East Asia + Siberia // Siberia + Australasia // Australasia + Pacific // Pacific + NorthAtlantic // North Atlantic (unused) + SouthAtlantic // South Atlantic (unused) + IndianOcean // Indian Ocean (unused) +) + +type CraftStatus int + +const ( + Ready CraftStatus = iota + Out + Repairs + Refueling + Rearming +) diff --git a/internal/geoscape/craft_dat_string.go b/internal/geoscape/craft_dat_string.go new file mode 100644 index 0000000..58288a2 --- /dev/null +++ b/internal/geoscape/craft_dat_string.go @@ -0,0 +1,180 @@ +// Code generated by "stringer -type=CraftType,Altitude,FlightMode,WeaponType,MissionType,MissionZone,CraftStatus -output=craft_dat_string.go -linecomment"; DO NOT EDIT. + +package geoscape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Skyranger-0] + _ = x[Lightning-1] + _ = x[Avenger-2] + _ = x[Interceptor-3] + _ = x[Firestorm-4] + _ = x[SmallScout-5] + _ = x[MediumScout-6] + _ = x[LargeScout-7] + _ = x[Harvester-8] + _ = x[Abductor-9] + _ = x[TerrorShip-10] + _ = x[Battleship-11] + _ = x[SupplyShip-12] +} + +const _CraftType_name = "SkyrangerLightningAvengerInterceptorFirestormsmall scoutmedium scoutlarge scoutHarvesterAbductorterror shipBattleshipsupply ship" + +var _CraftType_index = [...]uint8{0, 9, 18, 25, 36, 45, 56, 68, 79, 88, 96, 107, 117, 128} + +func (i CraftType) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_CraftType_index)-1 { + return "CraftType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _CraftType_name[_CraftType_index[idx]:_CraftType_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Ground-0] + _ = x[VeryLow-1] + _ = x[Low-2] + _ = x[High-3] + _ = x[VeryHigh-4] +} + +const _Altitude_name = "Groundvery lowLowHighvery high" + +var _Altitude_index = [...]uint8{0, 6, 14, 17, 21, 30} + +func (i Altitude) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Altitude_index)-1 { + return "Altitude(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Altitude_name[_Altitude_index[idx]:_Altitude_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NoDestination-0] + _ = x[SingleDestination-1] + _ = x[MultipleDestinations-2] +} + +const _FlightMode_name = "No destination set (at base)Single destinationMultiple destinations (UFO only)" + +var _FlightMode_index = [...]uint8{0, 28, 46, 78} + +func (i FlightMode) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_FlightMode_index)-1 { + return "FlightMode(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _FlightMode_name[_FlightMode_index[idx]:_FlightMode_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Stingray-0] + _ = x[Avalanche-1] + _ = x[Cannon-2] + _ = x[FusionBall-3] + _ = x[LaserCannon-4] + _ = x[PlasmaBeam-5] +} + +const _WeaponType_name = "StingrayAvalancheCannonfusion balllaser cannonplasma beam" + +var _WeaponType_index = [...]uint8{0, 8, 17, 23, 34, 46, 57} + +func (i WeaponType) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_WeaponType_index)-1 { + return "WeaponType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _WeaponType_name[_WeaponType_index[idx]:_WeaponType_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[MissionAlienResearch-0] + _ = x[MissionAlienHarvest-1] + _ = x[MissionAlienAbduction-2] + _ = x[MissionAlienInfiltration-3] + _ = x[MissionAlienBase-4] + _ = x[MissionAlienTerror-5] + _ = x[MissionAlienRetaliation-6] + _ = x[MissionAlienSupply-7] +} + +const _MissionType_name = "Alien ResearchAlien HarvestAlien AbductionAlien InfiltrationAlien BaseAlien TerrorAlien RetaliationAlien Supply" + +var _MissionType_index = [...]uint8{0, 14, 27, 42, 60, 70, 82, 99, 111} + +func (i MissionType) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_MissionType_index)-1 { + return "MissionType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _MissionType_name[_MissionType_index[idx]:_MissionType_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NorthAmerica-0] + _ = x[Arctic-1] + _ = x[Antarctica-2] + _ = x[SouthAmerica-3] + _ = x[Europe-4] + _ = x[NorthAfrica-5] + _ = x[SouthernAfrica-6] + _ = x[CentralAsia-7] + _ = x[SouthEastAsia-8] + _ = x[Siberia-9] + _ = x[Australasia-10] + _ = x[Pacific-11] + _ = x[NorthAtlantic-12] + _ = x[SouthAtlantic-13] + _ = x[IndianOcean-14] +} + +const _MissionZone_name = "North AmericaArcticAntarcticaSouth AmericaEuropeNorth AfricaSouthern AfricaCentral AsiaSouth East AsiaSiberiaAustralasiaPacificNorth Atlantic (unused)South Atlantic (unused)Indian Ocean (unused)" + +var _MissionZone_index = [...]uint8{0, 13, 19, 29, 42, 48, 60, 75, 87, 102, 109, 120, 127, 150, 173, 194} + +func (i MissionZone) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_MissionZone_index)-1 { + return "MissionZone(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _MissionZone_name[_MissionZone_index[idx]:_MissionZone_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Ready-0] + _ = x[Out-1] + _ = x[Repairs-2] + _ = x[Refueling-3] + _ = x[Rearming-4] +} + +const _CraftStatus_name = "ReadyOutRepairsRefuelingRearming" + +var _CraftStatus_index = [...]uint8{0, 5, 8, 15, 24, 32} + +func (i CraftStatus) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_CraftStatus_index)-1 { + return "CraftStatus(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _CraftStatus_name[_CraftStatus_index[idx]:_CraftStatus_index[idx+1]] +} diff --git a/internal/geoscape/craft_dat_test.go b/internal/geoscape/craft_dat_test.go new file mode 100644 index 0000000..0cd526a --- /dev/null +++ b/internal/geoscape/craft_dat_test.go @@ -0,0 +1,152 @@ +package geoscape_test + +import ( + "encoding/base64" + "encoding/binary" + "strings" + "testing" + "unicode" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_CRAFT_DAT_Unpack(t *testing.T) { + var obj geoscape.CraftFile + data := loadCRAFT_DAT() + err := restruct.Unpack(data, binary.LittleEndian, &obj) + require.NoError(t, err) + assert.EqualValues(t, 50, len(obj.Crafts), "should have all 50 slots") + // First 8 entries have valid craft types, rest are EntryNotUsed + for i := 0; i < 8; i++ { + assert.NotEqual(t, geoscape.EntryNotUsed, obj.Crafts[i].Type, "craft %d should be active", i) + } + for i := 8; i < 50; i++ { + assert.Equal(t, geoscape.CraftType(geoscape.EntryNotUsed), obj.Crafts[i].Type, "craft %d should be unused", i) + } +} + +func Test_CRAFT_DAT_RoundTrip(t *testing.T) { + data := loadCRAFT_DAT() + + var obj geoscape.CraftFile + _, err := obj.Unpack(data, binary.LittleEndian) + require.NoError(t, err) + require.Equal(t, 50, len(obj.Crafts), "should have 50 crafts after unpack") + + encoded := make([]byte, obj.SizeOf()) + _, err = obj.Pack(encoded, binary.LittleEndian) + require.NoError(t, err) + assert.Equal(t, data, encoded, "round-trip should produce identical bytes") +} + +func stripWhitespace(str string) string { + var b strings.Builder + b.Grow(len(str)) + for _, ch := range str { + if !unicode.IsSpace(ch) && ch != '=' { + b.WriteRune(ch) + } + } + return b.String() +} + +func loadCRAFT_DAT() []byte { + data, err := base64.RawStdEncoding.DecodeString(stripWhitespace(testCRAFTfile)) + if err != nil { + panic(err) + } + return data +} + +// base64 -b 80 -i GAME_1/CRAFT.DAT | pbcopy +const testCRAFTfile = ` +AP8AAAH/AAD//wAAAQD4AgoA//+I/4r/1QUAAJH/k/+V/5f/mf+c/57/AQAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAODgAIAAAAAwAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/6D/4/8DBWAAAQVgAP//AAABADQI +AAD///z//v8BAwAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMFZAAABWQA//8AAAAAAAAAAP//AAAAAOgDAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAARAAAAAwEDAAABAwD//wAAAAAAAAQA//8+Cb4A6AMEAAUACgAEAAAABAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADkAAAADAQMA +AAEDAP//AAAAAAAA/////9wBrQLoAwQABQADAAcAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQAAAAMBAwAAAQMA//8AAAAAAAD///// +BABs/ugDBgABAAQAAgACAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAA5AAAAAwEDAAABAwD//wAAAAAAAP////9XCHH96AMGAAUACgAEAAcA +BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAABkAAAAHAAAAAgAAAAAAvQAAAAAA//8AAEgBVP8AAAAABQAFAAIAAQABAAAAswAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAP8AAAACAAAA +AACAAAAAAAD//wAA1AC9/gAAAAABAAQAAQADAAAAAABsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAOAxAAAk8CQALGMdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==` diff --git a/internal/geoscape/geoscape.go b/internal/geoscape/geoscape.go new file mode 100644 index 0000000..181f0d2 --- /dev/null +++ b/internal/geoscape/geoscape.go @@ -0,0 +1,5 @@ +// Package geoscape +// +// These are savegame files used by the Geoscape portion of the game. +// This can be considered a *standard* save. +package geoscape diff --git a/internal/geoscape/geoscape_test.go b/internal/geoscape/geoscape_test.go new file mode 100644 index 0000000..3fc3233 --- /dev/null +++ b/internal/geoscape/geoscape_test.go @@ -0,0 +1,19 @@ +package geoscape_test + +import ( + "encoding/hex" + "strings" + "unicode" +) + +func loadHex(str string) ([]byte, error) { + txt := strings.Map(func(r rune) rune { + if unicode.IsSpace(r) { + // if the character is a space, drop it + return -1 + } + // else keep it in the string + return r + }, str) + return hex.DecodeString(txt) +} diff --git a/internal/geoscape/inter_dat.go b/internal/geoscape/inter_dat.go new file mode 100644 index 0000000..fbdef43 --- /dev/null +++ b/internal/geoscape/inter_dat.go @@ -0,0 +1,79 @@ +package geoscape + +import ( + "encoding/binary" + "github.com/go-restruct/restruct" +) + +type InterceptionData struct { + + // Geoscape Window/Icon related bytes + + // 0x00 ( word): active/inactive window: + // 0= active window (aircraft exists & is in intercept range) + // 1= no active window (aircraft does not exist or does exist but is not in intercept range now) + ActiveWindow bool `struct:"int8,invertedbool"` + + // 0x02 ( word): aircraft type for icon's picture + // 0x04 ( word): byte A (craft number) from LOC.DAT for icon of minimized window + // 0x06 ( word): craft LOC.DAT entry number. + // 0x08 ( word): CRAFT.DAT entry number. + // 0x0A ( word): UFO LOC.DAT entry number. + + // Active Window bytes + + // 0x0C ( word): UFO size (size is [5 - entry from UFO data]: vs= 0; s= 1; m= 2; l= 3; vl= 4) + // 0x0e ( word): window minimized (=1) or active (=0) + // 0x12 ( word): y position of window (accessed as a byte where I found it but it is most likely a word). + // 0x14 ( word): x position of window (x position is accessed as a word) + // 0x16 ( word): status message (starting at offset 0x397 in ENGLISH.DAT) + // 0x18 ( word): count down before the status message is cleared + // 0x1A ( word): attack mode [0 = Standoff; 1 = Cautious; 2 = Standard; 3 = Aggressive] + // 0x1C ( word): current distance to target (km x8) - can exceed standoff range (if byte00 = 1) + // 0x1E ( word): requested distance to target (km x8) eg 560 = 70km (stand off) + // 0x20 ( word): change in position for projectiles due to Xcraft stance and/or UFO escape speed delta (difference between speed of target ufo and xcom craft), "approach speed " + // 0x22 ( word): current air speed + // 0x24-0x41 (word): 15 entries for the positions of launched projectiles from the left weapon + // 0x42-0x5F (word): 15 entries for the positions of launched projectiles from the right weapon + // 0x60 ( word): Left weapon type + // 0x62 ( word): Right weapon type + // 0x64 ( word): Left weapon reload timer + // 0x66 ( word): Right weapon reload timer + // 0x68 ( word): explosion/hit radius value (and timer to delay the interception window closing until this is zero). + // 0x6A ( word): timer to prevent a craft from firing or being fired upon. Set when the UFO is downed/destroyed. + // 0x6C ( word): UFO return fire intense level + // 0x6E ( word): timer to prevent a craft from firing or being fired upon. Set when an Xcraft is destroyed. + // 0x70 ( word): UFO side view preview opened + // 0x72 ( word): XCOM craft type + // 0x74 ( word): UFO craft type + // 0x76 (dword): pointer to CRAFT.DAT offset of the attacking craft + // 0x7A (dword): pointer to attacking craft stats offset + // 0x7E (dword): pointer to attacking craft left weapon stats offset + // 0x82 (dword): pointer to attacking craft right weapon stats offset + // 0x86 (dword): pointer to CRAFT.DAT offset of the attacked UFO + // 0x8A (dword): pointer to UFO stats offset +} + +func (id InterceptionData) SizeOf() int { + return 142 +} + +// InterFile details the specifics of any interceptions +// currently occurring on the Geoscape. +type InterFile struct { + Interceptions []InterceptionData +} + +func (if_ InterFile) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { + for i := 0; i < maxCrafts; i++ { + data, err := restruct.Pack(order, &if_.Interceptions[i]) + if err != nil { + return nil, err + } + offset := i * craftByteLength + for j := 0; j < len(data); j++ { + buf[offset+j] = data[j] + } + } + return buf, nil +} diff --git a/internal/geoscape/liglob_dat.go b/internal/geoscape/liglob_dat.go new file mode 100644 index 0000000..f6bf768 --- /dev/null +++ b/internal/geoscape/liglob_dat.go @@ -0,0 +1,20 @@ +package geoscape + +// LiglobFile contains financial data for a savegame. +// +// This file is used by GEOSCAPE.EXE and it's structure is very simple. Every record is a 4 byte signed +// long integer. Probably the most useful offset is the first 4 bytes where your current money is stored. +// The rest of the bytes are used for the Finance graphs: Expenditure, Maintenance, and Balance (the +// others are stored elsewhere). +// +// https://www.ufopaedia.org/index.php/LIGLOB.DAT +type LiglobFile struct { + // Current balance + CurrentBalance int32 `struct:"int32"` + // Expenditure for the last 12 months + Expenditure []int32 `struct:"[12]int32"` + // Maintenance costs for the last 12 months + Maintenance []int32 `struct:"[12]int32"` + // Balance for the last 12 months + Balance []int32 `struct:"[12]int32"` +} diff --git a/internal/geoscape/loc_dat.go b/internal/geoscape/loc_dat.go new file mode 100644 index 0000000..8a458c4 --- /dev/null +++ b/internal/geoscape/loc_dat.go @@ -0,0 +1,80 @@ +package geoscape + +//go:generate stringer -type=LocationType -output=loc_dat_string.go -linecomment + +import "fmt" + +// LocFile provides location Data for bases and crafts +// +// LOC.DAT has a row width of 20 bytes. There are a total of 50 records (not all of them necessarily used) for a fixed +// file size of 1,000 bytes. +// +// https://www.ufopaedia.org/index.php/LOC.DAT +type LocFile struct { + Objects [50]LocationData +} + +type LocationData struct { + // Object type + Type LocationType `struct:"uint8"` + + // Object table reference - Possible values - 00 to FF - Just a reference. This just shows how many there are of + // this type on the geoscape. If the object is either a UFO (Alien Ship for TFTD) or X-COM craft, then this is the + // index into CRAFT.DAT. If the object is an X-Com base, then this is the index into BASE.DAT and if it is an Alien + // Base this byte contains the race. + TableReference uint `struct:"uint8"` + + // Horizontal coordinates or longitude (low bit then high bit respectively). Value range: 0 - 2880 + X int `struct:"int16"` + + // Vertical coordinates or latitude (low bit then high bit respectively). Value range: -720 - 720 + Y int `struct:"int16"` + + // For crash site or terror site - countdown timer (in hours). For moving objects - how many game ticks (5s) have to + // pass until craft moved to next globe coordinate (cell_size div speed). Note that ground UFOs are treated as moving + // objects, except for speed = 0. + Timer int `struct:"int16"` + + // Fractional part of how much is left to the next globe coordinate (cell_size mod speed), used only for moving objects. + Fraction int `struct:"int16"` + + // Count suffix of the item, eg: Skyranger-1 or Crash Site-47. It appears to have no meaning for XCOM Bases, but for + // other types where it is set, 0B is the high byte for when you go over 255 UFO's or crafts, etc. + CountSuffix int `struct:"int16"` + + // unused + _ int `struct:"int16"` + + // CraftData transfer mode + TransferMode int `struct:"int8"` + + // unused + _ int `struct:"int8"` + + // Globe object visiblity/mobility bitfield + Visibility int `struct:"int32"` +} + +// SizeOf implemtents the restruct.Sizer interface. +func (o LocationData) SizeOf() uint { + return 20 +} + +func (o LocationData) String() string { + return fmt.Sprintf("{%v %v}", o.Type, o.TableReference) +} + +// LocationType is the the type of object for which a location is stored. +type LocationType uint + +const ( + Unused LocationType = iota + AlienShip // Alien Ship + XCOMShip // X-COM Ship + XCOMBase // X-COM Base + AlienBase // Alien Base + CrashSite // Crash Site + LandedUFO // Landed UFO + Waypoint + TerrorSite +) diff --git a/internal/geoscape/loc_dat_string.go b/internal/geoscape/loc_dat_string.go new file mode 100644 index 0000000..bdc3d09 --- /dev/null +++ b/internal/geoscape/loc_dat_string.go @@ -0,0 +1,32 @@ +// Code generated by "stringer -type=LocationType -output=loc_dat_string.go -linecomment"; DO NOT EDIT. + +package geoscape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Unused-0] + _ = x[AlienShip-1] + _ = x[XCOMShip-2] + _ = x[XCOMBase-3] + _ = x[AlienBase-4] + _ = x[CrashSite-5] + _ = x[LandedUFO-6] + _ = x[Waypoint-7] + _ = x[TerrorSite-8] +} + +const _LocationType_name = "UnusedAlien ShipX-COM ShipX-COM BaseAlien BaseCrash SiteLanded UFOWaypointTerrorSite" + +var _LocationType_index = [...]uint8{0, 6, 16, 26, 36, 46, 56, 66, 74, 84} + +func (i LocationType) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_LocationType_index)-1 { + return "LocationType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _LocationType_name[_LocationType_index[idx]:_LocationType_index[idx+1]] +} diff --git a/internal/geoscape/saveinfo_dat.go b/internal/geoscape/saveinfo_dat.go new file mode 100644 index 0000000..696b277 --- /dev/null +++ b/internal/geoscape/saveinfo_dat.go @@ -0,0 +1,52 @@ +package geoscape + +// This file is present in any save. +// https://www.ufopaedia.org/index.php/SAVEINFO.DAT + +import ( + "time" + + "github.com/redtoad/xcom-editor/internal" +) + +// SaveinfoFile contains name and game time of the saved game. +// This file is 40 bytes long, no separate entries. +type SaveinfoFile struct { + + // 0-1 0x00-0x01 Ignore this if the file is not in the missdat folder. If 0, then this is a savegame made on the beginning of a new battlescape game. If 1, then check DIRECT.DAT to see where which save slot to load from. + MissdatFlag bool `struct:"int16"` + + // 2-27 0x02-0x1D This a 26 byte null terminated string, which details the name of the save file. The name may be 25 characters long; the final byte is always of value 0. A 0 also marks the end of the save name, should it not use all 25 characters. + Name internal.NullString `struct:"[26]byte"` + + // 28-29 0x1C-0x1D The current year. + Year int `struct:"int16"` + + // 30-31 0x1E-0x1F The current month. Note that 0 is January. + Month int `struct:"int16"` + + // 32-33 0x20-0x21 The current day of the month. + DayOfMonth int `struct:"int16"` + + // 34-35 0x22-0x23 The current hour (24 hour time). + Hour int `struct:"int16"` + + // 36-37 0x24-0x25 The current minute. + Minute int `struct:"int16"` + + // 38-39 0x26-0x27 0 for geoscape save, 1 for tactical save. + TacticalSave bool `struct:"int16"` +} + +// SizeOf imlements restruct.Sizer +func (s SaveinfoFile) SizeOf() int { + return 40 +} + +func (s SaveinfoFile) Time() time.Time { + return time.Date( + s.Year, time.Month(s.Month+1), s.DayOfMonth, + s.Hour, s.Minute, 0, 0, + time.UTC, + ) +} diff --git a/internal/geoscape/saveinfo_dat_test.go b/internal/geoscape/saveinfo_dat_test.go new file mode 100644 index 0000000..b420f9c --- /dev/null +++ b/internal/geoscape/saveinfo_dat_test.go @@ -0,0 +1,88 @@ +package geoscape_test + +import ( + "encoding/binary" + "testing" + "time" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/stretchr/testify/assert" +) + +func TestSaveinfoFile_Time(t *testing.T) { + tests := []struct { + hex string + want time.Time + }{ + { + "01005465737400000000000000000000000000000000000000000000cf0703000d00040014000000", + time.Date(1999, 4, 13, 4, 20, 0, 0, time.UTC), + }, + { + "010057656c6c206f6e20746865207761790000000000000000000000cf0703000e0002002f000000", + time.Date(1999, 4, 14, 2, 47, 0, 0, time.UTC), + }, + } + for _, tt := range tests { + t.Run(tt.hex, func(t *testing.T) { + data, err := loadHex(tt.hex) + assert.NoError(t, err) + + var info geoscape.SaveinfoFile + err = restruct.Unpack(data, binary.LittleEndian, &info) + assert.NoError(t, err, "could not unpack test data: %v", err) + + assert.Equal(t, tt.want, info.Time()) + }) + } +} + +func TestSaveinfoFile_Name(t *testing.T) { + tests := []struct { + hex string + want string + }{ + { + "01005465737400000000000000000000000000000000000000000000cf0703000d00040014000000", + "Test", + }, + { + "010057656c6c206f6e20746865207761790000000000000000000000cf0703000e0002002f000000", + "Well on the way", + }, + } + for _, tt := range tests { + t.Run(tt.hex, func(t *testing.T) { + data, err := loadHex(tt.hex) + assert.NoError(t, err) + + var info geoscape.SaveinfoFile + err = restruct.Unpack(data, binary.LittleEndian, &info) + assert.NoError(t, err, "could not unpack test data: %v", err) + + assert.Equal(t, tt.want, info.Name.String()) + }) + } +} + +func TestSaveinfoFile_RoundTrip(t *testing.T) { + tests := []string{ + "01005465737400000000000000000000000000000000000000000000cf0703000d00040014000000", + "010057656c6c206f6e20746865207761790000000000000000000000cf0703000e0002002f000000", + } + for _, hex := range tests { + t.Run(hex, func(t *testing.T) { + data, err := loadHex(hex) + assert.NoError(t, err) + + var info geoscape.SaveinfoFile + err = restruct.Unpack(data, binary.LittleEndian, &info) + assert.NoError(t, err, "could not unpack test data: %v", err) + + encoded, err := restruct.Pack(binary.LittleEndian, &info) + assert.NoError(t, err, "could not pack test data: %v", err) + assert.Equal(t, data, encoded) + }) + } +} diff --git a/lib/savegame/file_soldiers.go b/internal/geoscape/soldier_dat.go similarity index 83% rename from lib/savegame/file_soldiers.go rename to internal/geoscape/soldier_dat.go index 834a32f..36ef069 100644 --- a/lib/savegame/file_soldiers.go +++ b/internal/geoscape/soldier_dat.go @@ -1,29 +1,38 @@ -package savegame +package geoscape + +//go:generate stringer -type=Rank,Armor,Gender,Appearance -output=soldier_dat_string.go -linecomment import ( "encoding/binary" "fmt" "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal" ) -// https://www.ufopaedia.org/index.php/SOLDIER.DAT +const maxSoldiers = 250 -type FileSoldier struct { - Soldiers []Soldier +// Each soldier entry is 68 bytes long. +const soldierByteLength = 68 + +// SoldierFile contains all information abot the soldiers. +// +// https://www.ufopaedia.org/index.php/SOLDIER.DAT +type SoldierFile struct { + Soldiers []SoldierData } -func (s FileSoldier) SizeOf() int { - return 250 * 68 +func (s SoldierFile) SizeOf() int { + return maxSoldiers * soldierByteLength } -func (s FileSoldier) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { - for i := 0; i < 250; i++ { +func (s SoldierFile) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { + for i := 0; i < maxSoldiers; i++ { data, err := restruct.Pack(order, &s.Soldiers[i]) if err != nil { - return nil, err + return nil, fmt.Errorf("could not pack SoldierData: %w", err) } - offset := i * 68 + offset := i * soldierByteLength for j := 0; j < len(data); j++ { buf[offset+j] = data[j] } @@ -31,19 +40,19 @@ func (s FileSoldier) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { return buf, nil } -func (s *FileSoldier) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { - s.Soldiers = make([]Soldier, 250) - for i := 0; i < 250; i++ { - offset := i * 68 - data := buf[offset : offset+68] +func (s *SoldierFile) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { + s.Soldiers = make([]SoldierData, maxSoldiers) + for i := 0; i < maxSoldiers; i++ { + offset := i * soldierByteLength + data := buf[offset : offset+soldierByteLength] if err := restruct.Unpack(data, order, &s.Soldiers[i]); err != nil { - return nil, err + return nil, fmt.Errorf("could not unpack SoldierData: %w", err) } } return buf[s.SizeOf():], nil } -type Soldier struct { +type SoldierData struct { // Basic Information @@ -58,9 +67,6 @@ type Soldier struct { // 5 Commander (CDR) // 6 Select Squad for // 7 SPACE AVAILABLE> - - /* byte=8bits word=2bytes int=4bytes long=8bytes */ - Rank Rank `struct:"int16"` // 2-3 / 02-03 (various, FF): Base the soldier is at, using reference values @@ -86,7 +92,7 @@ type Soldier struct { // 12-13 / 0C-0D (0+): Wound recovery days. Signed integer. RecoveryDays int `struct:"int16"` - // 14-15 / 0E-0F (20+): Soldier value a.k.a. victory point loss if dies on a + // 14-15 / 0E-0F (20+): SoldierData value a.k.a. victory point loss if dies on a // mission. Signed integer. Is equal to 20 + Missions + Rank Bonus, as follows: // 0 Recruit @@ -104,13 +110,13 @@ type Soldier struct { SoldierValue int `struct:"int16"` // 16-40 / 10-28 (Text): Name, 25 characters long. Only approx. 21 characters - // can be entered when editing the field within the game's Soldier display, but + // can be entered when editing the field within the game's SoldierData display, but // longer names can be hex edited and will be seen in the game. Almost any // keyboard character can be entered (including within the game) because they are // stored directly instead of going through Windows objects. The end of the current // name is a null byte; garbage can be present after that (ends of longer previous // names, etc.). - Name string `struct:"[25]byte"` + Name internal.NullString `struct:"[25]byte"` // 41 / 29 (various): Always 0 except for existing soldiers being transferred, in // which case it equals the LOC.DAT value for destination base. New recruits on @@ -229,36 +235,8 @@ type Soldier struct { Appearance Appearance `struct:"int8"` } -func (s *Soldier) String() string { - if s.Rank == DeadOrUnused { - return "{Soldier }" - } else { - return fmt.Sprintf("{Soldier %v %s}", s.Rank, s.Name) - } -} - type Rank int -func (r Rank) String() string { - switch r { - case DeadOrUnused: - return "Dead" - case Rookie: - return "Rookie" - case Squaddie: - return "Squaddie" - case Sergeant: - return "Sergeant" - case Captain: - return "Captain" - case Colonel: - return "Colonel" - case Commander: - return "Commander" - } - return "???" -} - const ( Rookie Rank = iota Squaddie @@ -266,26 +244,27 @@ const ( Captain Colonel Commander - DeadOrUnused Rank = -1 + DeadOrUnused Rank = -1 // Dead or Unused ) type Armor int const ( - NoArmor Armor = iota - PersonalArmor - PowerSuit - FlyingSuit + NoArmor Armor = iota + PersonalArmour // Personal Armour + PowerSuit // Power Suit + FlyingSuit // Flying Suit // Can be hacked to - Sectoid - Snakeman - Ethereal - Muton - Floater - Celatid - Silacoid - Chryssalid + + SectoidArmor // Sectoid Armour + SnakemanArmor // Snakeman Armour + EtherealArmor // Ethereal Armour + MutonArmor // Muton Armour + FloaterArmor // Floater Armour + CelatidArmor // Celatid Armour + SilacoidArmor // Silacoid Armour + ChryssalidArmor // Chryssalid Armour ) type Gender int @@ -298,8 +277,8 @@ const ( type Appearance int const ( - Blonde Appearance = 0 - BrownHair + Blonde Appearance = iota + BrownHair // Brown Hair Oriental African ) diff --git a/internal/geoscape/soldier_dat_string.go b/internal/geoscape/soldier_dat_string.go new file mode 100644 index 0000000..cbec328 --- /dev/null +++ b/internal/geoscape/soldier_dat_string.go @@ -0,0 +1,99 @@ +// Code generated by "stringer -type=Rank,Armor,Gender,Appearance -output=soldier_dat_string.go -linecomment"; DO NOT EDIT. + +package geoscape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Rookie-0] + _ = x[Squaddie-1] + _ = x[Sergeant-2] + _ = x[Captain-3] + _ = x[Colonel-4] + _ = x[Commander-5] + _ = x[DeadOrUnused - -1] +} + +const _Rank_name = "Dead or UnusedRookieSquaddieSergeantCaptainColonelCommander" + +var _Rank_index = [...]uint8{0, 14, 20, 28, 36, 43, 50, 59} + +func (i Rank) String() string { + idx := int(i) - -1 + if i < -1 || idx >= len(_Rank_index)-1 { + return "Rank(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Rank_name[_Rank_index[idx]:_Rank_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NoArmor-0] + _ = x[PersonalArmour-1] + _ = x[PowerSuit-2] + _ = x[FlyingSuit-3] + _ = x[SectoidArmor-4] + _ = x[SnakemanArmor-5] + _ = x[EtherealArmor-6] + _ = x[MutonArmor-7] + _ = x[FloaterArmor-8] + _ = x[CelatidArmor-9] + _ = x[SilacoidArmor-10] + _ = x[ChryssalidArmor-11] +} + +const _Armor_name = "NoArmorPersonal ArmourPower SuitFlying SuitSectoid ArmourSnakeman ArmourEthereal ArmourMuton ArmourFloater ArmourCelatid ArmourSilacoid ArmourChryssalid Armour" + +var _Armor_index = [...]uint8{0, 7, 22, 32, 43, 57, 72, 87, 99, 113, 127, 142, 159} + +func (i Armor) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Armor_index)-1 { + return "Armor(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Armor_name[_Armor_index[idx]:_Armor_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Male-0] + _ = x[Female-1] +} + +const _Gender_name = "MaleFemale" + +var _Gender_index = [...]uint8{0, 4, 10} + +func (i Gender) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Gender_index)-1 { + return "Gender(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Gender_name[_Gender_index[idx]:_Gender_index[idx+1]] +} +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Blonde-0] + _ = x[BrownHair-1] + _ = x[Oriental-2] + _ = x[African-3] +} + +const _Appearance_name = "BlondeBrown HairOrientalAfrican" + +var _Appearance_index = [...]uint8{0, 6, 16, 24, 31} + +func (i Appearance) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Appearance_index)-1 { + return "Appearance(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Appearance_name[_Appearance_index[idx]:_Appearance_index[idx+1]] +} diff --git a/lib/savegame/file_soldiers_test.go b/internal/geoscape/soldier_dat_test.go similarity index 98% rename from lib/savegame/file_soldiers_test.go rename to internal/geoscape/soldier_dat_test.go index 91e2e79..72a380f 100644 --- a/lib/savegame/file_soldiers_test.go +++ b/internal/geoscape/soldier_dat_test.go @@ -1,40 +1,26 @@ -package savegame +package geoscape_test import ( "encoding/binary" - "encoding/hex" - "strings" "testing" - "unicode" "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geoscape" "github.com/stretchr/testify/assert" ) -func loadHex(str string) ([]byte, error) { - txt := strings.Map(func(r rune) rune { - if unicode.IsSpace(r) { - // if the character is a space, drop it - return -1 - } - // else keep it in the string - return r - }, str) - return hex.DecodeString(txt) -} - func TestUnpackSoldier(t *testing.T) { tests := []struct { hexData string - expected Soldier + expected geoscape.SoldierData }{ { `00000000 0100FFFF 00000000 00001400 47756472 756E2055 6E676572 00000000 00000000 00000000 00003919 32211635 391A1800 08000000 00000000 00000000 00000100`, - Soldier{ - Rank: Rookie, + geoscape.SoldierData{ + Rank: geoscape.Rookie, Base: 0, Craft: 1, CraftBefore: -1, @@ -64,12 +50,12 @@ func TestUnpackSoldier(t *testing.T) { ThrowingAccuracyImprovement: 0, MeleeAccuracyImprovement: 0, BraveryImprovement: 0, - Armor: NoArmor, + Armor: geoscape.NoArmor, MostRecentPsiLabTraining: 0, InPsiLabTraining: false, Promotion: false, - Sex: Female, - Appearance: Blonde, + Sex: geoscape.Female, + Appearance: geoscape.Blonde, }, }, } @@ -80,10 +66,13 @@ func TestUnpackSoldier(t *testing.T) { t.Errorf("could not convert test data: %v", err) } - var soldier Soldier + var soldier geoscape.SoldierData err = restruct.Unpack(data, binary.LittleEndian, &soldier) assert.NoError(t, err, "could not unpack test data: %v", err) + assert.Equal(t, tt.expected.Name.String(), soldier.Name.String()) + // Name carries null padding from binary data; normalize before struct comparison. + soldier.Name = tt.expected.Name assert.Equal(t, tt.expected, soldier) }) @@ -629,7 +618,7 @@ func TestFileSoldier_Pack(t *testing.T) { decoded, err := loadHex(hexDump) assert.NoError(t, err, "could not decode hex dump") - var file FileSoldier + var file geoscape.SoldierFile err = restruct.Unpack(decoded, binary.LittleEndian, &file) assert.NoError(t, err, "could not decode data") diff --git a/internal/geoscape/transfer_dat.go b/internal/geoscape/transfer_dat.go new file mode 100644 index 0000000..3dec4fe --- /dev/null +++ b/internal/geoscape/transfer_dat.go @@ -0,0 +1,72 @@ +package geoscape + +import ( + "encoding/binary" + + "github.com/go-restruct/restruct" +) + +const transferByteLength = 8 +const maxTransfers = 100 + +// TransferFile contains all information about items in transit. Each record is +// 8 bytes long and is fixed at 100 entries thus a fixed size of 800. +type TransferFile struct { + Transfers []TransferData +} + +func (tf TransferFile) SizeOf() int { + return transferByteLength * maxTransfers +} + +func (tf TransferFile) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { + for i := 0; i < maxTransfers; i++ { + data, err := restruct.Pack(order, &tf.Transfers[i]) + if err != nil { + return nil, err + } + offset := i * transferByteLength + for j := 0; j < len(data); j++ { + buf[offset+j] = data[j] + } + } + return buf, nil +} + +func (tf *TransferFile) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { + tf.Transfers = make([]TransferData, maxTransfers) + for i := 0; i < maxTransfers; i++ { + offset := i * transferByteLength + data := buf[offset : offset+transferByteLength] + if err := restruct.Unpack(data, order, &tf.Transfers[i]); err != nil { + return nil, err + } + } + return buf[tf.SizeOf():], nil +} + +type TransferData struct { + + // BaseData the item is coming from (as indexed in LOC.DAT). 255 if the item is purchased and thus no base of origin. + Origin uint8 `struct:"uint8"` + + // Destination the item is going to (again from LOC.DAT). 255 should not be used here. + Destination uint8 `struct:"uint8"` + + // HoursLeft in transit. NOTE: Setting this to 0 will make the game think it has been completed already. + HoursLeft uint8 `struct:"uint8"` + + // Offset 3 (1 Byte) - Item Type. This also affects what can be used in the next offset. + Type uint8 `struct:"uint8"` + + // Offset 4-5 (2 Bytes) - Reference number. The meaning of this value depends on the above Item Type value. + ReferenceNumber int `struct:"int16"` + + // Offset 6 (1 Byte) - Quantity. Also the entry is ignored if this value is 0, thus there can be invalid data in the other entries but they will always have this byte set to 0. + Quantity uint8 `struct:"uint8"` +} + +// SizeOf implements restruct.Sizer +func (td TransferData) SizeOf() int { + return transferByteLength +} diff --git a/internal/geoscape/transfer_dat_test.go b/internal/geoscape/transfer_dat_test.go new file mode 100644 index 0000000..231e158 --- /dev/null +++ b/internal/geoscape/transfer_dat_test.go @@ -0,0 +1,42 @@ +package geoscape_test + +import ( + "encoding/binary" + "testing" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal/geoscape" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_TRANSFER_DAT_RoundTrip(t *testing.T) { + // Create a buffer of 800 bytes (100 entries * 8 bytes each), all zeros + data := make([]byte, 800) + + // Set up a couple of active transfers + // Transfer 0: Origin=0, Destination=1, HoursLeft=10, Type=2, ReferenceNumber=5, Quantity=3 + data[0] = 0x00 // Origin + data[1] = 0x01 // Destination + data[2] = 0x0A // HoursLeft + data[3] = 0x02 // Type + data[4] = 0x05 // ReferenceNumber low byte + data[5] = 0x00 // ReferenceNumber high byte + data[6] = 0x03 // Quantity + data[7] = 0x00 // padding + + var obj geoscape.TransferFile + err := restruct.Unpack(data, binary.LittleEndian, &obj) + require.NoError(t, err) + assert.Equal(t, 100, len(obj.Transfers)) + assert.Equal(t, uint8(0), obj.Transfers[0].Origin) + assert.Equal(t, uint8(1), obj.Transfers[0].Destination) + assert.Equal(t, uint8(10), obj.Transfers[0].HoursLeft) + assert.Equal(t, uint8(2), obj.Transfers[0].Type) + assert.Equal(t, 5, obj.Transfers[0].ReferenceNumber) + assert.Equal(t, uint8(3), obj.Transfers[0].Quantity) + + encoded, err := restruct.Pack(binary.LittleEndian, obj) + require.NoError(t, err) + assert.Equal(t, data, encoded, "round-trip should produce identical bytes") +} diff --git a/internal/types.go b/internal/types.go new file mode 100644 index 0000000..32f3112 --- /dev/null +++ b/internal/types.go @@ -0,0 +1,18 @@ +package internal + +import ( + "strings" +) + +// NullString is a null byte terminated string. When read from binary data via +// restruct, the full fixed-size byte field (including null bytes) is stored. +// Use String() to get the value truncated at the first null byte. +type NullString string + +// String returns the string value, truncated at the first null byte. +func (s NullString) String() string { + if nul := strings.IndexByte(string(s), 0x0); nul >= 0 { + return string(s[:nul]) + } + return string(s) +} diff --git a/internal/types_test.go b/internal/types_test.go new file mode 100644 index 0000000..9423e58 --- /dev/null +++ b/internal/types_test.go @@ -0,0 +1,115 @@ +package internal_test + +import ( + "encoding/binary" + "fmt" + "testing" + + "github.com/go-restruct/restruct" + "github.com/redtoad/xcom-editor/internal" + "github.com/stretchr/testify/assert" +) + +func TestNullString_String(t *testing.T) { + + type nullStringStruct struct { + Name internal.NullString `struct:"[26]byte"` + } + + tests := []struct { + bytes []byte + want string + wantErr bool + }{ + { + []byte{0x4d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x20, 0x53, 0x74, 0x65, 0x77, 0x61, 0x72, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + "Michael Stewart", + false, + }, + { + []byte{0x00, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x20, 0x53, 0x74, 0x65, 0x77, 0x61, 0x72, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + "", + false, + }, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("%x", tt.bytes), func(t *testing.T) { + var value nullStringStruct + err := restruct.Unpack(tt.bytes, binary.LittleEndian, &value) + assert.NoError(t, err) + assert.Equal(t, tt.want, value.Name.String()) + }) + } +} + +func TestNullString_StringNoNull(t *testing.T) { + // When no null byte is present, the full string is returned. + s := internal.NullString("ABCDEF") + assert.Equal(t, "ABCDEF", s.String()) +} + +func TestNullString_MultiField(t *testing.T) { + + // Verify NullString works correctly in a struct with multiple fields. + type multiFieldStruct struct { + ID int16 `struct:"int16"` + Name internal.NullString `struct:"[10]byte"` + Age int16 `struct:"int16"` + } + + buf := []byte{ + 0x01, 0x00, // ID = 1 + 0x41, 0x6c, 0x69, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, // Name = "Alice\0\0\0\0\0" + 0x1e, 0x00, // Age = 30 + } + + var value multiFieldStruct + err := restruct.Unpack(buf, binary.LittleEndian, &value) + assert.NoError(t, err) + assert.Equal(t, int16(1), value.ID) + assert.Equal(t, "Alice", value.Name.String()) + assert.Equal(t, int16(30), value.Age) + + // Round-trip: packing the unpacked struct must produce identical bytes. + encoded, err := restruct.Pack(binary.LittleEndian, &value) + assert.NoError(t, err) + assert.Equal(t, buf, encoded) +} + +func TestNullString_Pack(t *testing.T) { + + type nullStringStruct struct { + Name string `struct:"[26]byte"` + } + + tests := []struct { + bytes []byte + want string + wantErr bool + }{ + { + []byte{ + 0x4d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x20, 0x53, 0x74, 0x65, 0x77, 0x61, 0x72, 0x74, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + "Michael Stewart", + false, + }, + { + []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + "", + false, + }, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("%x", tt.bytes), func(t *testing.T) { + value := nullStringStruct{Name: tt.want} + data, _ := restruct.Pack(binary.LittleEndian, &value) + assert.Equal(t, tt.bytes, data) + + }) + } +} diff --git a/internal/utils.go b/internal/utils.go new file mode 100644 index 0000000..2f6cefb --- /dev/null +++ b/internal/utils.go @@ -0,0 +1,64 @@ +package internal + +import ( + "bytes" + "encoding/binary" + "fmt" + "os" + + "github.com/go-restruct/restruct" +) + +var DefaultByteOrder = binary.LittleEndian + +// LoadDATFile loads binary file found at path and populates obj instance. +func LoadDATFile(path string, obj interface{}) error { + buf, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("could not open file %s: %w", path, err) + } + if err = Unmarshall(buf, obj); err != nil { + return fmt.Errorf("could not unpack data: %w", err) + } + return nil +} + +// Unmarshall decodes binary data from a buffer into a struct. +func Unmarshall(buffer []byte, obj interface{}) error { + if err := restruct.Unpack(buffer, DefaultByteOrder, obj); err != nil { + return fmt.Errorf("could not unpack data: %w", err) + } + return nil +} + +// SaveDATFile saves a single data to its original location on disk file +// if the content has changed. name is the path inside the game directory. +func SaveDATFile(path string, obj interface{}) error { + + saveData, err := Marshall(obj) + if err != nil { + return fmt.Errorf("could load data from file %s: %w", path, err) + } + + original, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("could not read file %s: %w", path, err) + } + + if bytes.Equal(saveData, original) { + return nil + } + if err = os.WriteFile(path, saveData, os.ModePerm); err != nil { + return fmt.Errorf("could not save file %s: %w", path, err) + } + return nil +} + +// Marshall encodes a struct into binary data. +func Marshall(obj interface{}) ([]byte, error) { + buffer, err := restruct.Pack(binary.LittleEndian, obj) + if err != nil { + return nil, fmt.Errorf("could not pack data: %w", err) + } + return buffer, nil +} diff --git a/internal/utils_test.go b/internal/utils_test.go new file mode 100644 index 0000000..b41d7e9 --- /dev/null +++ b/internal/utils_test.go @@ -0,0 +1,30 @@ +package internal_test + +import ( + "testing" + + "github.com/redtoad/xcom-editor/internal" +) + +func TestLoadDATFile(t *testing.T) { + + tests := []struct { + name string + path string + obj interface{} + wantErr bool + }{ + { + "empty path", + "", nil, + true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := internal.LoadDATFile(tt.path, &tt.obj); (err != nil) != tt.wantErr { + t.Errorf("LoadDATFile() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/lib/savegame/file_base.go b/lib/savegame/file_base.go deleted file mode 100644 index c579be7..0000000 --- a/lib/savegame/file_base.go +++ /dev/null @@ -1,148 +0,0 @@ -package savegame - -import ( - "encoding/binary" - "fmt" - - "github.com/go-restruct/restruct" -) - -type FileBase struct { - Bases []Base -} - -func (s FileBase) SizeOf() int { - return 292 * 8 -} - -func (s FileBase) Pack(buf []byte, order binary.ByteOrder) ([]byte, error) { - for i := 0; i < 8; i++ { - data, err := restruct.Pack(order, &s.Bases[i]) - if err != nil { - return nil, err - } - offset := i * 292 - for j := 0; j < len(data); j++ { - buf[offset+j] = data[j] - } - } - return buf, nil -} - -func (s *FileBase) Unpack(buf []byte, order binary.ByteOrder) ([]byte, error) { - s.Bases = make([]Base, 8) - for i := 0; i < 8; i++ { - offset := i * 292 - data := buf[offset : offset+292] - if err := restruct.Unpack(data, order, &s.Bases[i]); err != nil { - return nil, err - } - } - return buf[s.SizeOf():], nil -} - -// https://www.ufopaedia.org/index.php/BASE.DAT - -type Base struct { - - // Each entry is 292 Bytes long - - // 00-0E: Base Name, pretty obvious - // 0F: Presumably the Null character if the Base Name uses all 15 characters - Name string `struct:"[16]byte"` - - // Logical values for the detection capabilities: - // - //10 short, 0 long: This base has small radar(s) only. - // - //20 short, 20 long: This base has large radar(s) only. - // - //30 short, 20 long: This base has small and large radar(s). - // - //100 hyperwave: This base has a hyperwave decoder(s). - // - //The radar values can be set to 100 for perfect short range detection (presumably -- it definitely makes UFOs appear more often), but these reset to the correct values any time you complete a build in that base. - - // 10-11: Base's short range detection capability. - ShortRange int `struct:"int16"` - - // 12-13: Base's long range detection capability. - LongRange int `struct:"int16"` - - // 14-15: Base's hyperwave detection capability. - Hyperwave int `struct:"int16"` - - // 16-39: The next offsets are arranged so they're easier to understand. They are for facilities in the base: - Grid [36]Facility `struct:"[36]uint8"` - - // 3A-5D: The next offsets represent the days until a facility is completed. They're set up the same way: - DaysToCompletion [36]uint `struct:"[36]uint8"` - - Engineers int `struct:"int8"` - Scientists int `struct:"int8"` - - // 60-11E inventory - Inventory [96]int `struct:"[96]int16"` - - // 0120: Active/Inactive Base. Inactive entries have a value of 1. Active entries have a value of 0. Creating a new base will overwrite the first inactive entry. If a base is dismantled, the only change to the record is this value so it is possible to restore a dismantled base (Access lift removed) by restoring this value to 0. --SeulDragon 12:24, 11 July 2008 (PDT) - Active bool `struct:"int8,invertedbool"` - - // 0121~0123: 0120 is stored as an integer. These fields are the unused portion of that integer. -} - -type Facility uint - -const ( - AccessLift Facility = iota - LivingQuarters - Laboratory - Workshop - SmallRadarSystem - LargeRadarSystem - MissileDefense - GeneralStores - AlienContainment - LaserDefense - PlasmaDefense - FusionBallDefense - GravShield - MindShield - PsionicLaboratory - HyperwaveDecoder - HangarTopLeft - HangarTopRight - HangarBottomLeft - HangarBottomRight - Empty Facility = 0xff -) - -func (f Facility) Tile() string { - switch f { - case Empty: - return " " - case AccessLift: - return "↑↑" - case HangarTopLeft: - return " ⌜" - case HangarTopRight: - return "⌝ " - case HangarBottomLeft: - return " ⌞" - case HangarBottomRight: - return "⌟ " - case LivingQuarters: - return "LQ" - case SmallRadarSystem: - return "SR" - case LargeRadarSystem: - return "LR" - case Workshop: - return "WS" - case Laboratory: - return "LB" - case GeneralStores: - return "GS" - default: - return fmt.Sprintf("%#v", f) - } -} diff --git a/lib/savegame/files.go b/lib/savegame/files.go deleted file mode 100644 index 753fa67..0000000 --- a/lib/savegame/files.go +++ /dev/null @@ -1,31 +0,0 @@ -package savegame - -import ( - "encoding/binary" - "io/ioutil" - "os" - - "github.com/go-restruct/restruct" -) - -func LoadFile(path string, obj interface{}) error { - buf, err := ioutil.ReadFile(path) - if err != nil { - return err - } - if err = restruct.Unpack(buf, binary.LittleEndian, &obj); err != nil { - return err - } - return nil -} - -func SaveFile(path string, obj interface{}) error { - buf, err := restruct.Pack(binary.LittleEndian, &obj) - if err != nil { - return err - } - if err = ioutil.WriteFile(path, buf, os.ModePerm); err != nil { - return err - } - return nil -} diff --git a/misc/HexFiend/XCOM-CRAFT.DAT.tcl b/misc/HexFiend/XCOM-CRAFT.DAT.tcl new file mode 100644 index 0000000..bec89bb --- /dev/null +++ b/misc/HexFiend/XCOM-CRAFT.DAT.tcl @@ -0,0 +1,34 @@ +# X-COM Enemy Unknown +# savegame file CRAFT.DAT + +little_endian + +while {![end]} { + + section "Craft" { + + set craft_type [uint8 "craft type"] + + switch $craft_type { + 0 { set craft_str "Skyranger" } + 1 { set craft_str "Lightning" } + 2 { set craft_str "Avenger" } + 3 { set craft_str "Interceptor" } + 4 { set craft_str "Firestorm" } + 5 { set craft_str "Small Scout" } + 6 { set craft_str "Medium Scout" } + 7 { set craft_str "Large Scout" } + 8 { set craft_str "Harvester" } + 9 { set craft_str "Abductor" } + 10 { set craft_str "Terror Ship" } + 11 { set craft_str "Battleship" } + 12 { set craft_str "Supply Ship" } + 255 { set craft_str "not used" } + default { set craft_str "Unknown" } + } + + sectionvalue $craft_str + + bytes 103 "data (tbd)" + } +} diff --git a/misc/HexFiend/XCOM-LOC.DAT.tcl b/misc/HexFiend/XCOM-LOC.DAT.tcl new file mode 100644 index 0000000..0e2e947 --- /dev/null +++ b/misc/HexFiend/XCOM-LOC.DAT.tcl @@ -0,0 +1,33 @@ +# X-COM Enemy Unknown +# savegame file LOC.DAT + +little_endian + +while {![end]} { + + section "Location" { + + set location_type [uint8 "location type"] + + switch $location_type { + 0 { set type_str "Unused" } + 1 { set type_str "Alien Ship" } + 2 { set type_str "X-COM Ship" } + 3 { set type_str "X-COM Base" } + 4 { set type_str "Alien Base" } + 5 { set type_str "Crash Site" } + 6 { set type_str "Landed UFO" } + 7 { set type_str "Waypoint" } + 8 { set type_str "TerrorSite" } + default { set type_str "Unknown" } + } + + sectionvalue $type_str + + int8 "reference" + uint16 "lon" + int16 "lat" + + bytes 14 "data (tbd)" + } +} diff --git a/misc/HexFiend/XCOM-SOLDIER.DAT.tcl b/misc/HexFiend/XCOM-SOLDIER.DAT.tcl new file mode 100644 index 0000000..3e09532 --- /dev/null +++ b/misc/HexFiend/XCOM-SOLDIER.DAT.tcl @@ -0,0 +1,23 @@ +# X-COM Enemy Unknown +# savegame file SOLDIER.DAT + +little_endian + +while {![end]} { + + section "Soldier" { + + uint16 "rank" + uint16 "base" + uint16 "craft" + uint16 "craft before" + uint16 "missions" + uint16 "kills" + uint16 "recovery days" + uint16 "soldier value" + set name [ascii 25 "name"] + sectionvalue $name + + bytes 27 "data (tbd)" + } +} diff --git a/misc/kaitai-structs/CRAFT.DAT.ksy b/misc/kaitai-structs/CRAFT.DAT.ksy new file mode 100644 index 0000000..d69e818 --- /dev/null +++ b/misc/kaitai-structs/CRAFT.DAT.ksy @@ -0,0 +1,195 @@ +meta: + id: craft_dat + file-extension: CRAFT.DAT + endian: le +doc: | + This file contains information specific to the crafts in the game. Both X-COM + and Alien crafts (including hidden ones) are in this file, though the values + for the alien craft are still shrouded in mystery. +seq: + - id: crafts + type: craft + size: 104 + repeat: eos +enums: + craft_type: + 0: skyranger + 1: lightning + 2: avenger + 3: interceptor + 4: firestorm + 5: small_scout + 6: medium_scout + 7: large_scout + 8: harvester + 9: abductor + 10: terror_ship + 11: battleship + 12: supply_ship + 255: not_used + weapon_type: + 0: stingray + 1: avalanche + 2: cannon + 3: fusion_ball + 4: laser_cannon + 5: plasma_beam + 255: no_weapon + flight_mode: + 0: no_destination + 1: single_destination + 2: multiple_destinations + altitude: + 0: ground + 1: very_low + 2: low + 3: high + 4: very_high + mission_type: + 0: alien_research + 1: alien_harvest + 2: alien_abduction + 3: alien_infiltration + 4: alien_base + 5: alien_terror + 6: alien_retaliation + 7: alien_supply + mission_zone: + 0: morth_america + 1: arctic + 2: antarctica + 3: south_america + 4: europe + 5: north_africa + 6: southern_africa + 7: central_asia + 8: south_east_asia + 9: siberia + 10: australasia + 11: pacific + 12: north_atlantic + 13: south_atlantic + 14: indian_ocean + alien_race: + 0: sectoid_aquatoid + 1: snakeman_gillman + 2: ethereal_lobsterman + 3: muton_tasoth + 4: floater__mixed_crew_type_i + 5: final_mission_mix__mixed_crew_type_ii + craft_status: + 0: ready + 1: out + 2: repairs + 3: refueling + 4: rearming + status: + 0: craft_is_in_hangar + 2: want_to_go_home + 4: out_of_elerium + 8: out_of_left_ammo + 16: out_of_right_ammo + 32: ufo_in_interception_window + 64: hyperwaved_extra_info +types: + craft: + seq: + - id: type + type: u1 + enum: craft_type + - id: left_weapon_type + type: u1 + enum: weapon_type + - id: left_ammo + type: u2 + - id: flight_mode + type: u1 + enum: flight_mode + - id: right_weapon_type + type: u1 + enum: weapon_type + - id: right_ammo + type: u2 + - id: unused_ + type: u2 + - id: damage + type: u2 + doc: | + Damage, that is the amount it currently has taken. This value divided + by the crafts damage capacity gives the percentage shown in-game. + - id: altitude + type: u2 + enum: altitude + - id: speed + type: u2 + - id: loc_index + type: u2 + doc: | + Index into LOC.DAT referencing the destination - for example, + waypoints for X-COM craft, or X-COM bases for alien craft. + - id: inter_index + type: u2 + doc: | + Index into INTER.DAT when the ship is in interception mode. + - id: next_waypoint_lon + type: u2 + doc: | + Next UFO waypoint coordinate X (longitude). + - id: next_waypoint_lat + type: u2 + doc: | + Next UFO waypoint coordinate Y (latitude). + - id: fuel + type: u2 + doc: | + Fuel, amount remaining. This value divided by the crafts total fuel + capacity gives the percentage shown in-game. + - id: base + type: u2 + doc: | + Base reference as an index to LOC.DAT. + - id: mission_type + type: u2 + enum: mission_type + doc: | + Mission type craft is on. Is an index within ENGLISH.DAT for the + string (558 + this value). + - id: mission_zone + type: u2 + enum: mission_zone + doc: | + Zone where mission is being carried out. Is an index within + ENGLISH.DAT for string (543 + this value). + - id: ufo_trajectory_segment + type: u2 + doc: UFO trajectory segment (ranges from 0-7). + - id: ufo_trajectory_type + type: u2 + doc: UFO trajectory type (ranges from 0-9). + - id: alien_race + type: u2 + enum: alien_race + doc: | + Alien Race found on craft. Is index within ENGLISH.DAT for the string + (466 + this value). + - id: ufo_attack_timer + type: u2 + - id: ufo_escape_maneuver_timer + type: u2 + - id: craft_status + type: u2 + enum: craft_status + - id: cargo + type: u1 + repeat: expr + repeat-expr: 55 + doc: | + The rest of the known values detail the items on board of the craft. + 49-98 refer to offsets 0-49 in OBDATA.DAT. + - id: status + type: b6 + enum: status + + + + diff --git a/misc/kaitai-structs/LIBGLOB.DAT.ksy b/misc/kaitai-structs/LIBGLOB.DAT.ksy new file mode 100644 index 0000000..47c524c --- /dev/null +++ b/misc/kaitai-structs/LIBGLOB.DAT.ksy @@ -0,0 +1,39 @@ +meta: + id: libglob_dat + file-extension: LIBGLOB.DAT + endian: le +doc: | + This file is used by GEOSCAPE.EXE and it's structure is very simple. Every + record is a 4 byte signed long integer. Probably the most useful offset is the + first 4 bytes where your current money is stored. The rest of the bytes are + used for the Finance graphs: Expenditure, Maintenance, and Balance (the others + are stored elsewhere). + + Note: This file is only updated once a month, except for the first four bytes. +seq: + - id: current_money + type: s4 + doc: | + The most useful and probably the most hacked, these 4 bytes hold your + current funds. + - id: expenditure + type: s4 + repeat: expr + repeat-expr: 12 + doc: | + This is the expenditure for the months (exactly 12 of these 4 byte values) + going in order January to December. The graph is adjusted to the current + date so these essentially contain a years worth of data. + - id: maintenance + type: s4 + repeat: expr + repeat-expr: 12 + doc: | + Same as above only for Maintenance. + - id: balance + type: s4 + repeat: expr + repeat-expr: 12 + doc: | + Same as above only for Balance (hence why you will sometimes see similar + numbers here to your funds). \ No newline at end of file diff --git a/misc/kaitai-structs/LOC.DAT.ksy b/misc/kaitai-structs/LOC.DAT.ksy new file mode 100644 index 0000000..a19fddf --- /dev/null +++ b/misc/kaitai-structs/LOC.DAT.ksy @@ -0,0 +1,44 @@ +meta: + id: loc_dat + file-extension: DAT + endian: le +doc-ref: https://www.ufopaedia.org/index.php?title=LOC.DAT +seq: + - id: location + type: location + repeat: eos +types: + location: + seq: + - id: type + type: u1 + enum: object_type + - id: reference + type: u1 + - id: lon + type: u2 + - id: lat + type: s2 + - id: tbd + size: 14 + instances: + lat_float: + value: -lat / 8.0 + lon_float: + value: (lon / 8.0) +enums: + object_type: + 0x00: unused + 0x01: alien_ship + 0x02: xcom_ship + 0x03: xcom_base + 0x04: alien_base + 0x05: crash_site + 0x06: landed_ufo + 0x07: waypoint + 0x08: terror_site + # Extras for TFTD only: + 0x51: port_attack + 0x52: island_attack + 0x53: passenger_cargo_ship + 0x54: artefact_site \ No newline at end of file diff --git a/misc/kaitai-structs/README.md b/misc/kaitai-structs/README.md new file mode 100644 index 0000000..3e2162a --- /dev/null +++ b/misc/kaitai-structs/README.md @@ -0,0 +1,5 @@ +# Kaitai format descriptions + +[Kaitai Struct](http://kaitai.io/#quick-start) is a declarative language used to describe various binary data structures, laid out in files or in memory: i.e. binary file formats, network stream packet formats, etc. + +You can try out any of the files in this directory using the [Kaitai Web IDE](https://ide.kaitai.io). diff --git a/misc/kaitai-structs/SAVEINFO.DAT.ksy b/misc/kaitai-structs/SAVEINFO.DAT.ksy new file mode 100644 index 0000000..fce5df9 --- /dev/null +++ b/misc/kaitai-structs/SAVEINFO.DAT.ksy @@ -0,0 +1,55 @@ +meta: + id: saveinfo_dat + title: Format of SAVEINFO.DAT + file-extension: DAT + endian: le +doc: | + SAVEINFO.DAT stores the game time and save game title. + This file is present in any save. +seq: + - id: battlescape_game + type: u2 + enum: bools + doc: | + Ignore this if the file is not in the missdat folder. If 0, then + this is a savegame made on the beginning of a new battlescape game. + If 1, then check DIRECT.DAT to see where which save slot to load + from. + - id: name + type: strz + size: 26 + encoding: ascii + - id: year + type: u2 + - id: month + type: u2 + enum: months + - id: day + type: u2 + - id: hour + type: u2 + - id: minute + type: u2 + - id: tactical_save + type: u2 + enum: bools + doc: | + 0 for geoscape save, 1 for tactical save. +enums: + months: + 0: jan + 1: feb + 3: mar + 4: apr + 5: may + 6: jun + 7: jul + 8: aug + 9: sep + 10: oct + 11: nov + 12: dec + bools: + 0: false + 1: true + \ No newline at end of file diff --git a/misc/kaitai-structs/SOLDIER.DAT.ksy b/misc/kaitai-structs/SOLDIER.DAT.ksy new file mode 100644 index 0000000..5b33e1b --- /dev/null +++ b/misc/kaitai-structs/SOLDIER.DAT.ksy @@ -0,0 +1,132 @@ +meta: + id: soldier_dat + title: Format of SOLDIER.DAT + file-extension: DAT + endian: le +doc: | + SOLDIER.DAT has a fixed structure of 250 entries of 68 bytes each. (Only a + maximum of 250 soldiers can be had.) Thus it is always 17,000 bytes long + (250x68). +seq: + - id: soldier + type: soldier_data + repeat: eos +enums: + ranks: + 0: rookie + 1: squaddie + 2: sergeant + 3: captain + 4: colonel + 5: commander + bools: + 0: false + 1: true + sex: + 0: male + 1: female + appearance: + 0: blonde + 1: brown_hair + 2: oriental + 3: african + armor: + 0: none + 1: personal_armor + 2: power_suit + 3: flying_suit +types: + soldier_data: + seq: + - id: rank + type: u2 + enum: ranks + doc: | + Integer set to Rank or FFFF if soldier is dead (or slot not yet used). + Ranks are: + + 0 Rookie + 1 Squaddie + 2 Sergeant (SGT) + 3 Captain (CPT) + 4 Colonel (COL) + 5 Commander (CDR) + FF Dead + - id: base + type: u2 + - id: craft + type: u2 + - id: craft_before + type: u2 + - id: missions + type: u2 + - id: kills + type: u2 + - id: recovery_days + type: u2 + - id: soldier_value + type: u2 + - id: name + type: strz + size: 25 + encoding: ascii + - id: destination_base + type: u1 + - id: initial_time_units + type: u1 + - id: initial_health + type: u1 + - id: initial_energy + type: u1 + - id: initial_reactions + type: u1 + - id: initial_strength + type: u1 + - id: initial_firing_accuracy + type: u1 + - id: initial_throwing_accuracy + type: u1 + - id: initial_melee_accuracy + type: u1 + - id: initial_psionic_strength + type: u1 + - id: initial_psionic_skill + type: u1 + - id: initial_bravery + type: u1 + - id: time_unit_improvement + type: u1 + - id: health_improvement + type: u1 + - id: energy_improvement + type: u1 + - id: reactions_improvement + type: u1 + - id: strength_improvement + type: u1 + - id: firing_accuracy_improvement + type: u1 + - id: throwing_accuracy_improvement + type: u1 + - id: melee_accuracy_improvement + type: u1 + - id: bravery_improvement + type: u1 + - id: armor + type: u1 + enum: armor + - id: most_recent_psi_lab_training + type: u1 + - id: in_psy_lab_training + type: b8 + enum: bools + - id: promotion + type: b8 + enum: bools + - id: sex + type: u1 + enum: sex + - id: appearance + type: u1 + enum: appearance + \ No newline at end of file diff --git a/lib/resources/generate/gen_resource_list.go b/resources/gen_resource_list.go similarity index 99% rename from lib/resources/generate/gen_resource_list.go rename to resources/gen_resource_list.go index 2db1314..3e1c549 100644 --- a/lib/resources/generate/gen_resource_list.go +++ b/resources/gen_resource_list.go @@ -1,6 +1,8 @@ // This program generates resources_list.go. It can be invoked by running // go generate ./... +//go:build ignore + package main import ( @@ -117,6 +119,7 @@ func dieOnError(err error) { var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT. // This file was generated automatically based on {{ .Input }} + package resources var Images = map[string]ImageEntry{ diff --git a/lib/resources/palette.go b/resources/palette.go similarity index 100% rename from lib/resources/palette.go rename to resources/palette.go diff --git a/lib/resources/pck.go b/resources/pck.go similarity index 100% rename from lib/resources/pck.go rename to resources/pck.go diff --git a/lib/resources/resource_files.csv b/resources/resource_files.csv similarity index 100% rename from lib/resources/resource_files.csv rename to resources/resource_files.csv diff --git a/lib/resources/resource_list.go b/resources/resource_list.go similarity index 99% rename from lib/resources/resource_list.go rename to resources/resource_list.go index 1638486..910a73c 100644 --- a/lib/resources/resource_list.go +++ b/resources/resource_list.go @@ -1,5 +1,6 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated automatically based on resource_files.csv + package resources var Images = map[string]ImageEntry{ diff --git a/lib/resources/resources.go b/resources/resources.go similarity index 96% rename from lib/resources/resources.go rename to resources/resources.go index 0228e5a..3790c08 100644 --- a/lib/resources/resources.go +++ b/resources/resources.go @@ -1,6 +1,7 @@ +// Contains functions to load X-COM resource files like images. package resources -//go:generate go run github.com/redtoad/xcom-editor/lib/resources/generate +//go:generate go run gen_resource_list.go import ( "errors" diff --git a/lib/resources/scr.go b/resources/scr.go similarity index 91% rename from lib/resources/scr.go rename to resources/scr.go index 40460f5..422829f 100644 --- a/lib/resources/scr.go +++ b/resources/scr.go @@ -1,8 +1,6 @@ package resources -import ( - "io/ioutil" -) +import "os" // LoadSCR loads an SCR image from path. // @@ -12,7 +10,7 @@ import ( // though the line width tends to vary depending on the specific use to which they are to // be put. func LoadSCR(path string, width int) (*ImageResource, error) { - buf, err := ioutil.ReadFile(path) + buf, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/lib/resources/spk.go b/resources/spk.go similarity index 100% rename from lib/resources/spk.go rename to resources/spk.go diff --git a/savegame/bases.go b/savegame/bases.go new file mode 100644 index 0000000..1233a01 --- /dev/null +++ b/savegame/bases.go @@ -0,0 +1,130 @@ +package savegame + +import ( + "fmt" + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geoscape" + "log" + "path" +) + +type Base struct { + offset int + game *Savegame +} + +// Index returns the base's index in BASE.DAT. +func (b *Base) Index() int { + return b.offset +} + +// Active returns whether the base is active. +func (b *Base) Active() bool { + return b.game.BasesData.Bases[b.offset].Active +} + +// Engineers returns the number of engineers at this base. +func (b *Base) Engineers() int { + return b.game.BasesData.Bases[b.offset].Engineers +} + +// Scientists returns the number of scientists at this base. +func (b *Base) Scientists() int { + return b.game.BasesData.Bases[b.offset].Scientists +} + +// Inventory returns the inventory quantities for this base. +func (b *Base) Inventory() [96]int { + return b.game.BasesData.Bases[b.offset].Inventory +} + +func (b *Base) Name() string { + return b.game.BasesData.Bases[b.offset].Name.String() +} + +func (b *Base) Coord() Coord { + locationRefs := b.game.locationsForType(geoscape.XCOMBase) + for _, ref := range locationRefs { + if ref.Ref == b.offset { + return ref.Coord() + } + } + return Coord{-1, -1} +} + +func (b *Base) Tiles() []BaseTile { + data := b.game.BasesData.Bases[b.offset] + tiles := make([]BaseTile, 36) + for i := 0; i < 36; i++ { + tiles[i] = BaseTile{ + Type: data.Grid[i], + DaysToCompletion: int(data.DaysToCompletion[i]), + } + } + return tiles +} + +func (b *Base) TileAt(x, y int) BaseTile { + data := b.game.BasesData.Bases[b.offset] + tileNo := x + y*6 + return BaseTile{ + Type: data.Grid[tileNo], + DaysToCompletion: int(data.DaysToCompletion[tileNo]), + } +} + +type BaseTile struct { + Type geoscape.Facility + DaysToCompletion int +} + +func (game *Savegame) loadBases() error { + filePath := path.Join(game.Path, "BASE.DAT") + if err := internal.LoadDATFile(filePath, &game.BasesData); err != nil { + return fmt.Errorf("could not load BASE.DAT: %w", err) + } + return nil +} + +func (game *Savegame) saveBases() error { + filePath := path.Join(game.Path, "BASE.DAT") + return internal.SaveDATFile(filePath, game.BasesData) +} + +// CompleteConstructions will complete all ongoing constructions in all BasesData. +func (game *Savegame) CompleteConstructions() { + for b := 0; b < len(game.BasesData.Bases); b++ { + base := &game.BasesData.Bases[b] + for i := 0; i < len(base.DaysToCompletion); i++ { + if base.DaysToCompletion[i] > 0 { + log.Printf("Complete construction of %v in %s.\n", base.Grid[i].String(), base.Name) + base.DaysToCompletion[i] = 0 + } + } + } +} + +func (game *Savegame) Base(offset int) *Base { + base := game.BasesData.Bases[offset] + if base.Name.String() != "" { + return &Base{ + offset: offset, + game: game, + } + } + return nil +} + +func (game *Savegame) Bases() []*Base { + bases := make([]*Base, 0) + for idx, base := range game.BasesData.Bases { + if base.Name.String() != "" { + bases = append(bases, game.Base(idx)) + } + } + return bases +} + +func (game *Savegame) SetInventory(baseNr int, item geoscape.Inventory, amount int) { + +} diff --git a/savegame/crafts.go b/savegame/crafts.go new file mode 100644 index 0000000..7191932 --- /dev/null +++ b/savegame/crafts.go @@ -0,0 +1,155 @@ +package savegame + +import ( + "fmt" + "path" + + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geoscape" +) + +type Craft struct { + offset int + game *Savegame +} + +func (c *Craft) Name() string { + var suffix = 0 + for _, object := range c.game.locationFile.Objects { + if object.Type == geoscape.XCOMShip && int(object.TableReference) == c.offset { + suffix = object.CountSuffix + } + } + prefixMapping := map[geoscape.CraftType]string{ + geoscape.Skyranger: "SKYRANGER", + geoscape.Lightning: "LIGHTNING", + geoscape.Avenger: "AVENGER", + geoscape.Interceptor: "INTERCEPTOR", + geoscape.Firestorm: "FIRESTORM", + geoscape.SmallScout: "UFO", + geoscape.MediumScout: "UFO", + geoscape.LargeScout: "UFO", + geoscape.Harvester: "UFO", + geoscape.Abductor: "UFO", + geoscape.TerrorShip: "UFO", + geoscape.Battleship: "UFO", + geoscape.SupplyShip: "UFO", + } + prefix := prefixMapping[c.game.craftsFile.Crafts[c.offset].Type] + return fmt.Sprintf("%s-%d", prefix, suffix) +} + +func (game *Savegame) loadCrafts() error { + filePath := path.Join(game.Path, "CRAFT.DAT") + if err := internal.LoadDATFile(filePath, &game.craftsFile); err != nil { + return fmt.Errorf("could not load CRAFT.DAT: %w", err) + } + return nil +} + +func (game *Savegame) saveCrafts() error { + filePath := path.Join(game.Path, "CRAFT.DAT") + return internal.SaveDATFile(filePath, game.craftsFile) +} + +// Crafts returns all active craft (skipping EntryNotUsed slots). +func (game *Savegame) Crafts() []*Craft { + crafts := make([]*Craft, 0) + for idx, data := range game.craftsFile.Crafts { + if data.Type == geoscape.EntryNotUsed { + continue + } + crafts = append(crafts, &Craft{ + offset: idx, + game: game, + }) + } + return crafts +} + +// Index returns the craft's index in CRAFT.DAT. +func (c *Craft) Index() int { + return c.offset +} + +// Type returns the craft type. +func (c *Craft) Type() geoscape.CraftType { + return c.game.craftsFile.Crafts[c.offset].Type +} + +// Status returns the craft status. +func (c *Craft) Status() geoscape.CraftStatus { + return c.game.craftsFile.Crafts[c.offset].Status +} + +// Damage returns the current damage amount. +func (c *Craft) Damage() int { + return c.game.craftsFile.Crafts[c.offset].Damage +} + +// Fuel returns the remaining fuel amount. +func (c *Craft) Fuel() int { + return c.game.craftsFile.Crafts[c.offset].FuelAmountRemaining +} + +// Base returns the base this craft is stationed at. +func (c *Craft) Base() *Base { + baseRef := int(c.game.craftsFile.Crafts[c.offset].BaseReference) + return c.game.Base(baseRef) +} + +// Speed returns the craft's current speed. +func (c *Craft) Speed() int { + return c.game.craftsFile.Crafts[c.offset].Speed +} + +// Destination returns the GPS coordinate of the craft's destination, +// or nil if the craft is stationary (speed 0 or no destination set). +func (c *Craft) Destination() *Coord { + data := c.game.craftsFile.Crafts[c.offset] + if data.Speed == 0 || data.FlightMode == geoscape.NoDestination { + return nil + } + idx := data.Destination + if idx < 0 || idx >= len(c.game.locationFile.Objects) { + return nil + } + dest := c.game.locationFile.Objects[idx] + coord := NewCoord(dest.X, dest.Y) + return &coord +} + +// NextWaypoint returns the GPS coordinate of the craft's next UFO waypoint, +// or nil if the craft is stationary or has no waypoint set. +func (c *Craft) NextWaypoint() *Coord { + data := c.game.craftsFile.Crafts[c.offset] + if data.Speed == 0 || data.FlightMode == geoscape.NoDestination { + return nil + } + if data.NextUFOWaypointLon == 0 && data.NextUFOWaypointLat == 0 { + return nil + } + coord := NewCoord(data.NextUFOWaypointLon, data.NextUFOWaypointLat) + return &coord +} + +// MissionType returns the mission type string for this craft. +func (c *Craft) MissionType() string { + return c.game.craftsFile.Crafts[c.offset].MissionType.String() +} + +// MissionZone returns the mission zone string for this craft. +func (c *Craft) MissionZone() string { + return c.game.craftsFile.Crafts[c.offset].MissionZone.String() +} + +func (game *Savegame) Craft(offset int) *Craft { + craft := game.craftsFile.Crafts[offset] + if craft.Type == geoscape.EntryNotUsed { + return nil + } + return &Craft{ + offset: offset, + game: game, + } +} diff --git a/savegame/geo.go b/savegame/geo.go new file mode 100644 index 0000000..814ea5a --- /dev/null +++ b/savegame/geo.go @@ -0,0 +1,70 @@ +package savegame + +import ( + "fmt" + "math" +) + +// Coord is a real-world GPS coordinate. +type Coord struct { + // Vertical coordinates or latitude + Lat float32 + // Horizontal coordinates or longitude + Lon float32 +} + +func NewCoord(x int, y int) Coord { + // A Y coordinate value of 720 corresponds to 90.0 "90° S" latitude (the South Pole); + // a Y coordinate value of -720 corresponds to "90° N" latitude (the North Pole). + lat := float32(y) / (720.0 / -90.0) + + // The X coordinate starts with X = 0 at 0° longitude (the Prime Meridian or Greenwich + // Meridian) and increases going eastward. Unlike real-world longitude, there is only + // "East" longitude, from 0°E to 359.875°E. This is the result of forcing the + // coordinate system to be positive-only, for algorithmic purposes. So, for example, + // the equivalent of 90°W longitude would be "270°E longitude", with a game X + // coordinate of 270 x 8 = 2160. + lon := float32(x) / (2880.0 / 360.0) + for lon > 180.0 { + lon = lon - 360.0 + } + for lon < -180.0 { + lon = lon + 360.0 + } + + return Coord{Lat: lat, Lon: lon} +} + +func (l Coord) String() string { + latDir := "N" + if l.Lat < 0 { + latDir = "S" + } + lonDir := "E" + if l.Lon < 0 { + lonDir = "W" + } + return fmt.Sprintf( + "%.5f° %s %.5f° %s", + math.Abs(float64(l.Lat)), latDir, + math.Abs(float64(l.Lon)), lonDir, + ) +} + +// TerrainHexColorsXCom stores a color map for the world terrain types +// (see geodata.Polygon#Terrain). +var TerrainHexColorsXCom = []string{ + "#7FFE11", // Forest / Jungle + "#6CD911", // Farm + "#5AB411", // Farm + "#478F11", // Farm + "#356A11", // Farm + "#224511", // Mountain + "#464645", // Forest / Jungle + "#6B6B45", // Desert + "#909045", // Desert + "#B5B545", // Polar Ice + "#DADA45", // Forest / Jungle + "#FFFF45", // Forest / Jungle + "#FFFFFF", // Polar Seas w/Icebergs +} diff --git a/savegame/geo_test.go b/savegame/geo_test.go new file mode 100644 index 0000000..48d12a7 --- /dev/null +++ b/savegame/geo_test.go @@ -0,0 +1,47 @@ +package savegame_test + +import ( + "fmt" + "reflect" + "testing" + + "github.com/redtoad/xcom-editor/savegame" +) + +func TestNewCoord(t *testing.T) { + tests := []struct { + x int + y int + want savegame.Coord + }{ + {0, -0, savegame.Coord{}}, + {2160, 720, savegame.Coord{Lat: -90.0, Lon: -90.0}}, + {2879, -720, savegame.Coord{Lat: 90.0, Lon: -0.125}}, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("(x=%d,y=%d)", tt.x, tt.y), func(t *testing.T) { + if got := savegame.NewCoord(tt.x, tt.y); !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewCoord() = %#v, want %#v", got, tt.want) + } + }) + } +} + +func TestCoord_String(t *testing.T) { + tests := []struct { + coord savegame.Coord + want string + }{ + {savegame.Coord{}, "0.00000° N 0.00000° E"}, + {savegame.Coord{Lat: 90.0, Lon: 270.0}, "90.00000° N 270.00000° E"}, + {savegame.Coord{Lat: 90.0, Lon: -90.0}, "90.00000° N 90.00000° W"}, + {savegame.Coord{Lat: -90.0, Lon: 359.875}, "90.00000° S 359.87500° E"}, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("(lat=%f,lon=%f)", tt.coord.Lat, tt.coord.Lon), func(t *testing.T) { + if got := tt.coord.String(); !reflect.DeepEqual(got, tt.want) { + t.Errorf(".String() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/savegame/location.go b/savegame/location.go new file mode 100644 index 0000000..6d724f5 --- /dev/null +++ b/savegame/location.go @@ -0,0 +1,74 @@ +package savegame + +import ( + "fmt" + "path" + + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geoscape" +) + +type LocationRef struct { + X, Y int + Ref int +} + +func (loc *LocationRef) Coord() Coord { + return NewCoord(loc.X, loc.Y) +} + +func (game *Savegame) loadLocations() error { + filePath := path.Join(game.Path, "LOC.DAT") + if err := internal.LoadDATFile(filePath, &game.locationFile); err != nil { + return fmt.Errorf("could not load LOC.DAT: %w", err) + } + return nil +} + +func (game *Savegame) savelocations() error { + filePath := path.Join(game.Path, "LOC.DAT") + return internal.SaveDATFile(filePath, game.locationFile) +} + +func (game *Savegame) locationsForType(type_ geoscape.LocationType) []*LocationRef { + data := make([]*LocationRef, 0) + for _, loc := range game.locationFile.Objects { + if loc.Type == type_ { + data = append(data, &LocationRef{ + loc.X, loc.Y, int(loc.TableReference), + }) + } + } + return data +} + +// Location holds exported data for a single location entry from LOC.DAT. +type Location struct { + Type geoscape.LocationType + TableReference int + X, Y int + CountSuffix int +} + +// Coord converts the location's game coordinates to GPS coordinates. +func (loc *Location) Coord() Coord { + return NewCoord(loc.X, loc.Y) +} + +// Locations returns all active locations, skipping Unused and Waypoint entries. +func (game *Savegame) Locations() []Location { + locs := make([]Location, 0) + for _, obj := range game.locationFile.Objects { + if obj.Type == geoscape.Unused || obj.Type == geoscape.Waypoint { + continue + } + locs = append(locs, Location{ + Type: obj.Type, + TableReference: int(obj.TableReference), + X: obj.X, + Y: obj.Y, + CountSuffix: obj.CountSuffix, + }) + } + return locs +} diff --git a/savegame/metadata.go b/savegame/metadata.go new file mode 100644 index 0000000..41c10fd --- /dev/null +++ b/savegame/metadata.go @@ -0,0 +1,26 @@ +package savegame + +import ( + "fmt" + "github.com/redtoad/xcom-editor/internal" + "path" + "time" +) + +func (game *Savegame) loadMetadata() error { + filePath := path.Join(game.Path, "SAVEINFO.DAT") + if err := internal.LoadDATFile(filePath, &game.meta); err != nil { + return fmt.Errorf("could not load SAVEINFO.DAT: %w", err) + } + return nil +} + +// Title returns the savegame title. +func (game *Savegame) Title() string { + return game.meta.Name.String() +} + +// Time returns the game time. +func (game *Savegame) Time() time.Time { + return game.meta.Time() +} diff --git a/savegame/savegame.go b/savegame/savegame.go new file mode 100644 index 0000000..1022024 --- /dev/null +++ b/savegame/savegame.go @@ -0,0 +1,89 @@ +package savegame + +import ( + "fmt" + "path" + + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geoscape" +) + +type Savegame struct { + Path string + meta geoscape.SaveinfoFile + Financials geoscape.LiglobFile + BasesData geoscape.BaseFile + locationFile geoscape.LocFile + soldierFile geoscape.SoldierFile + transferFile geoscape.TransferFile + craftsFile geoscape.CraftFile +} + +type loadOrSaveFunc func() error + +// Load loads a savegame from disk. This includes loading all required data files +// one by one. +func Load(root string) (*Savegame, error) { + game := &Savegame{Path: root} + for _, fnc := range []loadOrSaveFunc{ + game.loadMetadata, // read-only + game.loadSoldiers, + game.loadBases, + game.loadTransfers, + game.loadCrafts, + game.loadLocations, + game.loadFinancials, + } { + if err := fnc(); err != nil { + return nil, err + } + } + return game, nil +} + +// Reload reloads the savegame from disk, discarding any unsaved changes. +func (game *Savegame) Reload() error { + for _, fnc := range []loadOrSaveFunc{ + game.loadMetadata, + game.loadSoldiers, + game.loadBases, + game.loadTransfers, + game.loadCrafts, + game.loadLocations, + game.loadFinancials, + } { + if err := fnc(); err != nil { + return err + } + } + return nil +} + +func (game *Savegame) loadFinancials() error { + filePath := path.Join(game.Path, "LIGLOB.DAT") + if err := internal.LoadDATFile(filePath, &game.Financials); err != nil { + return fmt.Errorf("could not load LIGLOB.DAT: %w", err) + } + return nil +} + +func (game *Savegame) saveFinancials() error { + filePath := path.Join(game.Path, "LIGLOB.DAT") + return internal.SaveDATFile(filePath, game.Financials) +} + +// Save saves the entire savegame on disk at its original location. +func (game *Savegame) Save() error { + for _, fnc := range []loadOrSaveFunc{ + game.saveSoldiers, + game.saveBases, + game.saveTransfers, + game.saveCrafts, + game.saveFinancials, + } { + if err := fnc(); err != nil { + return err + } + } + return nil +} diff --git a/savegame/savegame_test.go b/savegame/savegame_test.go new file mode 100644 index 0000000..2e37628 --- /dev/null +++ b/savegame/savegame_test.go @@ -0,0 +1 @@ +package savegame_test diff --git a/savegame/soldiers.go b/savegame/soldiers.go new file mode 100644 index 0000000..be70fee --- /dev/null +++ b/savegame/soldiers.go @@ -0,0 +1,302 @@ +package savegame + +//go:generate stringer -type=Rank -output=soldiers_string.go -linecomment + +import ( + "fmt" + "path" + "strings" + + "github.com/redtoad/xcom-editor/internal" + "github.com/redtoad/xcom-editor/internal/geoscape" +) + +type Soldier struct { + game *Savegame + offset int // offset in file SOLDIER.DAT +} + +// Index returns the soldier's index in SOLDIER.DAT. +func (s *Soldier) Index() int { + return s.offset +} + +func (s *Soldier) Name() string { + return s.game.soldierFile.Soldiers[s.offset].Name.String() +} + +// data returns a pointer to the underlying soldier data for direct access. +func (s *Soldier) data() *geoscape.SoldierData { + return &s.game.soldierFile.Soldiers[s.offset] +} + +// SetName sets the soldier's name. +func (s *Soldier) SetName(name string) { + s.game.soldierFile.Soldiers[s.offset].Name = internal.NullString(name) +} + +// Missions returns the number of missions completed. +func (s *Soldier) Missions() int { + return s.game.soldierFile.Soldiers[s.offset].Missions +} + +// Kills returns the number of kills. +func (s *Soldier) Kills() int { + return s.game.soldierFile.Soldiers[s.offset].Kills +} + +// RecoveryDays returns the number of wound recovery days remaining. +func (s *Soldier) RecoveryDays() int { + return s.game.soldierFile.Soldiers[s.offset].RecoveryDays +} + +// TimeUnits returns total time units (initial + improvement). +func (s *Soldier) TimeUnits() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialTimeUnits + d.TimeUnitImprovement +} + +// Health returns total health (initial + improvement). +func (s *Soldier) Health() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialHealth + d.HealthImprovement +} + +// Energy returns total energy/stamina (initial + improvement). +func (s *Soldier) Energy() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialEnergy + d.EnergyImprovement +} + +// Reactions returns total reactions (initial + improvement). +func (s *Soldier) Reactions() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialReactions + d.ReactionsImprovement +} + +// Strength returns total strength (initial + improvement). +func (s *Soldier) Strength() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialStrength + d.StrengthImprovement +} + +// FiringAccuracy returns total firing accuracy (initial + improvement). +func (s *Soldier) FiringAccuracy() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialFiringAccuracy + d.FiringAccuracyImprovement +} + +// ThrowingAccuracy returns total throwing accuracy (initial + improvement). +func (s *Soldier) ThrowingAccuracy() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialThrowingAccuracy + d.ThrowingAccuracyImprovement +} + +// MeleeAccuracy returns total melee accuracy (initial + improvement). +func (s *Soldier) MeleeAccuracy() int { + d := s.game.soldierFile.Soldiers[s.offset] + return d.InitialMeleeAccuracy + d.MeleeAccuracyImprovement +} + +// PsionicStrength returns psionic strength (never changes). +func (s *Soldier) PsionicStrength() int { + return s.game.soldierFile.Soldiers[s.offset].InitialPsionicStrength +} + +// PsionicSkill returns current psionic skill. +func (s *Soldier) PsionicSkill() int { + return s.game.soldierFile.Soldiers[s.offset].InitialPsionicSkill +} + +// Bravery returns bravery value (110 - 10*(initial - improvement)). +func (s *Soldier) Bravery() int { + d := s.game.soldierFile.Soldiers[s.offset] + return 110 - 10*(d.InitialBravery-d.BraveryImprovement) +} + +// Armor returns the soldier's current armor type. +func (s *Soldier) Armor() geoscape.Armor { + return s.game.soldierFile.Soldiers[s.offset].Armor +} + +// SetArmor sets the soldier's armor type. +func (s *Soldier) SetArmor(armor geoscape.Armor) { + s.game.soldierFile.Soldiers[s.offset].Armor = armor +} + +// Gender returns the soldier's gender. +func (s *Soldier) Gender() string { + return s.data().Sex.String() +} + +// Appearance returns the soldier's appearance. +func (s *Soldier) Appearance() string { + return s.data().Appearance.String() +} + +// InitialTimeUnits returns the soldier's initial time units (before improvements). +func (s *Soldier) InitialTimeUnits() int { return s.data().InitialTimeUnits } + +// InitialHealth returns the soldier's initial health (before improvements). +func (s *Soldier) InitialHealth() int { return s.data().InitialHealth } + +// InitialEnergy returns the soldier's initial energy (before improvements). +func (s *Soldier) InitialEnergy() int { return s.data().InitialEnergy } + +// InitialReactions returns the soldier's initial reactions (before improvements). +func (s *Soldier) InitialReactions() int { return s.data().InitialReactions } + +// InitialStrength returns the soldier's initial strength (before improvements). +func (s *Soldier) InitialStrength() int { return s.data().InitialStrength } + +// InitialFiringAccuracy returns the soldier's initial firing accuracy (before improvements). +func (s *Soldier) InitialFiringAccuracy() int { return s.data().InitialFiringAccuracy } + +// InitialThrowingAccuracy returns the soldier's initial throwing accuracy (before improvements). +func (s *Soldier) InitialThrowingAccuracy() int { return s.data().InitialThrowingAccuracy } + +// InitialMeleeAccuracy returns the soldier's initial melee accuracy (before improvements). +func (s *Soldier) InitialMeleeAccuracy() int { return s.data().InitialMeleeAccuracy } + +// InitialPsionicStrength returns the soldier's initial psionic strength. +func (s *Soldier) InitialPsionicStrength() int { return s.data().InitialPsionicStrength } + +// InitialPsionicSkill returns the soldier's initial psionic skill. +func (s *Soldier) InitialPsionicSkill() int { return s.data().InitialPsionicSkill } + +// InitialBravery returns the soldier's initial bravery value. +func (s *Soldier) InitialBravery() int { return s.data().InitialBravery } + +// SetInitialTimeUnits sets the soldier's initial time units. +func (s *Soldier) SetInitialTimeUnits(v int) { s.data().InitialTimeUnits = v } + +// SetInitialHealth sets the soldier's initial health. +func (s *Soldier) SetInitialHealth(v int) { s.data().InitialHealth = v } + +// SetInitialEnergy sets the soldier's initial energy. +func (s *Soldier) SetInitialEnergy(v int) { s.data().InitialEnergy = v } + +// SetInitialReactions sets the soldier's initial reactions. +func (s *Soldier) SetInitialReactions(v int) { s.data().InitialReactions = v } + +// SetInitialStrength sets the soldier's initial strength. +func (s *Soldier) SetInitialStrength(v int) { s.data().InitialStrength = v } + +// SetInitialFiringAccuracy sets the soldier's initial firing accuracy. +func (s *Soldier) SetInitialFiringAccuracy(v int) { s.data().InitialFiringAccuracy = v } + +// SetInitialThrowingAccuracy sets the soldier's initial throwing accuracy. +func (s *Soldier) SetInitialThrowingAccuracy(v int) { s.data().InitialThrowingAccuracy = v } + +// SetInitialMeleeAccuracy sets the soldier's initial melee accuracy. +func (s *Soldier) SetInitialMeleeAccuracy(v int) { s.data().InitialMeleeAccuracy = v } + +// SetInitialPsionicStrength sets the soldier's initial psionic strength. +func (s *Soldier) SetInitialPsionicStrength(v int) { s.data().InitialPsionicStrength = v } + +// SetInitialPsionicSkill sets the soldier's initial psionic skill. +func (s *Soldier) SetInitialPsionicSkill(v int) { s.data().InitialPsionicSkill = v } + +type Rank int + +const ( + Rookie Rank = iota + Squaddie + Sergeant + Captain + Colonel + Commander +) + +func (s *Soldier) Rank() Rank { + mapping := map[geoscape.Rank]Rank{ + geoscape.Rookie: Rookie, + geoscape.Squaddie: Squaddie, + geoscape.Sergeant: Sergeant, + geoscape.Captain: Captain, + geoscape.Colonel: Colonel, + geoscape.Commander: Commander, + } + data := s.game.soldierFile.Soldiers[s.offset] + return mapping[data.Rank] +} + +func (s *Soldier) Base() *Base { + baseNo := s.game.soldierFile.Soldiers[s.offset].Base + return s.game.Base(baseNo) +} + +const NoCraft = -1 //0xffff + +func (s *Soldier) Craft() *Craft { + currCraftNo := s.game.soldierFile.Soldiers[s.offset].Craft + prevCraftNo := s.game.soldierFile.Soldiers[s.offset].CraftBefore + if currCraftNo != NoCraft { + return s.game.Craft(currCraftNo - 1) + } + if prevCraftNo != NoCraft { + return s.game.Craft(prevCraftNo - 1) + } + return nil +} + +func (s *Soldier) IsDead() bool { + data := s.game.soldierFile.Soldiers[s.offset] + return data.Rank == geoscape.DeadOrUnused && strings.TrimSpace(data.Name.String()) != "" +} + +func (s *Soldier) IsWounded() bool { + data := s.game.soldierFile.Soldiers[s.offset] + return !s.IsDead() && data.RecoveryDays > 0 +} + +func (s *Soldier) Heal() { + data := &s.game.soldierFile.Soldiers[s.offset] + // Dead soldiers are resurrected as Squaddies. + if s.IsDead() { + data.Rank = geoscape.Squaddie + } + data.RecoveryDays = 0 + // Soldiers are returned to their original craft. + if data.Craft == NoCraft { + data.Craft = data.CraftBefore + data.CraftBefore = NoCraft + } +} + +func (game *Savegame) loadSoldiers() error { + filePath := path.Join(game.Path, "SOLDIER.DAT") + if err := internal.LoadDATFile(filePath, &game.soldierFile); err != nil { + return fmt.Errorf("could not load SOLDIER.DAT: %w", err) + } + return nil +} + +func (game *Savegame) saveSoldiers() error { + filePath := path.Join(game.Path, "SOLDIER.DAT") + return internal.SaveDATFile(filePath, game.soldierFile) +} + +func (game *Savegame) Soldiers() []*Soldier { + soldiers := make([]*Soldier, 0) + for idx, data := range game.soldierFile.Soldiers { + // When soldiers die, their Rank is set to geoscape.DeadOrUnused any can + // be overwritten. Therefore we assume that any non empty name marks a + // soldier's entry. + if data.Name.String() == "" { + continue + } + soldiers = append(soldiers, &Soldier{ + offset: idx, + game: game, + }) + } + return soldiers +} + +// HealAllSoldiers will restore all soldiers back to health. +func (game *Savegame) HealAllSoldiers() { + for _, soldier := range game.Soldiers() { + soldier.Heal() + } +} diff --git a/savegame/soldiers_string.go b/savegame/soldiers_string.go new file mode 100644 index 0000000..384893b --- /dev/null +++ b/savegame/soldiers_string.go @@ -0,0 +1,29 @@ +// Code generated by "stringer -type=Rank -output=soldiers_string.go -linecomment"; DO NOT EDIT. + +package savegame + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Rookie-0] + _ = x[Squaddie-1] + _ = x[Sergeant-2] + _ = x[Captain-3] + _ = x[Colonel-4] + _ = x[Commander-5] +} + +const _Rank_name = "RookieSquaddieSergeantCaptainColonelCommander" + +var _Rank_index = [...]uint8{0, 6, 14, 22, 29, 36, 45} + +func (i Rank) String() string { + idx := int(i) - 0 + if i < 0 || idx >= len(_Rank_index)-1 { + return "Rank(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Rank_name[_Rank_index[idx]:_Rank_index[idx+1]] +} diff --git a/savegame/transfers.go b/savegame/transfers.go new file mode 100644 index 0000000..29866c9 --- /dev/null +++ b/savegame/transfers.go @@ -0,0 +1,86 @@ +package savegame + +import ( + "fmt" + "path" + + "github.com/redtoad/xcom-editor/internal" +) + +// Transfer wraps a single transfer entry. +type Transfer struct { + offset int + game *Savegame +} + +// Index returns the transfer's index in TRANSFER.DAT. +func (t *Transfer) Index() int { + return t.offset +} + +// Origin returns the base index the item is coming from (255 = purchased). +func (t *Transfer) Origin() int { + return int(t.game.transferFile.Transfers[t.offset].Origin) +} + +// Destination returns the destination base index. +func (t *Transfer) Destination() int { + return int(t.game.transferFile.Transfers[t.offset].Destination) +} + +// HoursLeft returns the number of hours until delivery. +func (t *Transfer) HoursLeft() int { + return int(t.game.transferFile.Transfers[t.offset].HoursLeft) +} + +// Type returns the item type being transferred. +func (t *Transfer) Type() int { + return int(t.game.transferFile.Transfers[t.offset].Type) +} + +// ReferenceNumber returns the reference number (meaning depends on Type). +func (t *Transfer) ReferenceNumber() int { + return t.game.transferFile.Transfers[t.offset].ReferenceNumber +} + +// Quantity returns the number of items being transferred. +func (t *Transfer) Quantity() int { + return int(t.game.transferFile.Transfers[t.offset].Quantity) +} + +// Transfers returns all active transfers (where Quantity > 0). +func (game *Savegame) Transfers() []*Transfer { + transfers := make([]*Transfer, 0) + for idx, data := range game.transferFile.Transfers { + if data.Quantity > 0 { + transfers = append(transfers, &Transfer{ + offset: idx, + game: game, + }) + } + } + return transfers +} + +func (game *Savegame) loadTransfers() error { + filePath := path.Join(game.Path, "TRANSFER.DAT") + if err := internal.LoadDATFile(filePath, &game.transferFile); err != nil { + return fmt.Errorf("could not load TRANSFER.DAT: %w", err) + } + return nil +} + +func (game *Savegame) saveTransfers() error { + filePath := path.Join(game.Path, "TRANSFER.DAT") + return internal.SaveDATFile(filePath, game.transferFile) +} + +// SpeedupDelivery will reduce delivery time for all outstanding deliveries to 1 hour. +func (game *Savegame) SpeedupDelivery() { + for no := 0; no < len(game.transferFile.Transfers); no++ { + transfer := &game.transferFile.Transfers[no] + if transfer.HoursLeft > 0 { + transfer.HoursLeft = 1 + } + } +}