• 01 - Games
  • 02 - Creative Instruments & Explorers
  • 03 - Language, Signals & Text
  • 04 - Developer & Web Utilities
  • 05 - Generators & Data
  • 06 - Colour Theory
  • 07 - Music 26
  • 08 - 3D, Shaders & Visuals
ARCHIVE

APACHE CANYON - INTERACTIVE GAME SOURCE CODE

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  <title>Apache//Can.yon — Dusk Ops</title>
  <meta name="description" content="A canyon gunship shooter flown from dusk to dawn.">
  <meta name="theme-color" content="#140b08">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Share+Tech+Mono&display=swap">
  <style>:root{--ink: #140b08;--panel: #1c110b;--sky-top: #1e1330;--sky-mid: #7a2f3d;--sky-horizon: #e8763a;--sun-core: #ffe9b8;--sun-glow: #ffb454;--sand-shadow: #3a1c10;--sand-dark: #6b2f1a;--sand-mid: #9c4a26;--sand-light: #d98a4f;--rim-light: #ffcf8a;--amber: #f0a44c;--amber-bright: #ffc36b;--rust-red: #d9502f;--dust: #c9a67a}*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}body{background:var(--ink);color:var(--amber);font-family:Share Tech Mono,Courier New,monospace;overflow:hidden;width:100vw;height:100vh;height:100dvh;display:flex;justify-content:center;align-items:center;background-image:linear-gradient(rgba(240,164,76,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(240,164,76,.04) 1px,transparent 1px);background-size:40px 40px;touch-action:none;position:relative}#gameContainer{position:relative;width:100%;height:100%;display:flex;flex-direction:column;box-shadow:inset 0 0 90px #000000a6;overflow:hidden}#hud{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:center;gap:clamp(6px,1.4vw,18px);padding:clamp(4px,.8vh,8px) clamp(8px,1.5vw,14px);background:linear-gradient(180deg,#1c110bf7,#140b08eb);border-bottom:1px solid var(--sand-mid);font-size:clamp(9px,1.3vh,13px);flex-shrink:0;z-index:3}.hud-item{display:flex;align-items:baseline;gap:5px;padding:0 6px;border-left:2px solid rgba(240,164,76,.5);transition:filter .2s ease}.hud-item:first-child{border-left:none}.hud-label{font-family:Oswald,sans-serif;color:var(--dust);font-size:clamp(7px,1vh,10px);letter-spacing:.08em;text-transform:uppercase;opacity:.85;white-space:nowrap}.hud-value{color:var(--amber-bright);font-size:clamp(11px,1.7vh,16px);font-weight:700;text-shadow:0 0 8px rgba(255,180,84,.5);letter-spacing:.03em;white-space:nowrap;transition:color .3s ease,text-shadow .3s ease}.hud-bar-item{gap:6px}.hud-bar{position:relative;width:clamp(46px,8vw,90px);height:clamp(10px,1.8vh,15px);border:1px solid var(--sand-mid);background:#0000008c;overflow:hidden;box-shadow:inset 0 0 8px #d98a4f1f}.hud-bar-fill{position:absolute;top:0;bottom:0;left:0;background:linear-gradient(to right,var(--rust-red),var(--amber));transition:width .3s ease,background .3s ease;box-shadow:0 0 10px #f0a44c80}.hud-bar-value{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:clamp(7px,1.1vh,10px);font-weight:700;color:var(--amber-bright);text-shadow:0 0 4px rgba(0,0,0,.9);white-space:nowrap}#gameCanvas{flex:1 1 0;min-width:0;min-height:0;width:100%;background:#000;touch-action:none;display:block}#message{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-family:Oswald,sans-serif;font-size:clamp(20px,4vh,32px);color:var(--amber-bright);text-align:center;text-shadow:0 0 20px rgba(255,180,84,.6),2px 0 rgba(217,80,47,.4),-2px 0 rgba(255,233,184,.3);display:none;z-index:20;background:#140b08f7;padding:clamp(16px,4vh,32px);border:2px solid var(--amber);box-shadow:0 0 50px #d98a4f59;max-width:90vw;max-height:90vh;overflow:auto}.title-screen{text-align:center;line-height:1.5}.controls-hint{position:absolute;bottom:clamp(8px,2vh,16px);left:50%;transform:translate(-50%);font-size:clamp(10px,1.4vh,14px);color:var(--amber);text-align:center;letter-spacing:.05em;background:#140b08f7;padding:clamp(6px,1vh,10px) clamp(12px,2vh,16px);border:1px solid var(--sand-mid);opacity:.9;max-width:90vw;white-space:normal;line-height:1.4;z-index:7}#muteStatus{margin-left:6px;opacity:.9}.dust-grain{position:absolute;inset:0;pointer-events:none;z-index:5;background:radial-gradient(1px 1px at 10% 20%,rgba(255,220,170,.5),transparent),radial-gradient(1px 1px at 80% 60%,rgba(255,220,170,.4),transparent),radial-gradient(1px 1px at 40% 80%,rgba(255,220,170,.35),transparent),radial-gradient(1px 1px at 65% 15%,rgba(255,220,170,.4),transparent),radial-gradient(1px 1px at 25% 55%,rgba(255,220,170,.3),transparent);background-size:300px 300px;opacity:.5;animation:driftDust 22s linear infinite;mix-blend-mode:screen}@keyframes driftDust{0%{background-position:0 0}to{background-position:-300px 400px}}.warm-vignette{position:absolute;inset:0;pointer-events:none;z-index:6;background:radial-gradient(ellipse at 50% 60%,#0000 45%,#140804b3);transition:background .2s ease}.heat-flicker{animation:flicker 7s infinite}@keyframes flicker{0%,to{opacity:1}91%{opacity:1}92%{opacity:.93}93%{opacity:1}96%{opacity:.88}97%{opacity:1}}#gameContainer.critical .warm-vignette{animation:critPulse .55s ease-in-out infinite}@keyframes critPulse{0%,to{background:radial-gradient(ellipse at 50% 60%,#d9502f00 40%,#d9502f59)}50%{background:radial-gradient(ellipse at 50% 60%,#d9502f00 50%,#d9502f99)}}#gameContainer.critical .hud-item{filter:drop-shadow(0 0 5px rgba(217,80,47,.7))}.mobile-warning{display:none;position:fixed;top:0;left:0;width:100vw;height:100vh;background:radial-gradient(ellipse at 50% 30%,#3a1c10,#140b08 70%);z-index:1000;flex-direction:column;justify-content:center;align-items:center;padding:20px;text-align:center;border:3px solid var(--amber);box-shadow:0 0 60px #d98a4f66 inset}.warning-content{max-width:800px;width:90%;padding:40px;background:#140b08f5;border:2px solid var(--amber);box-shadow:0 0 40px #d98a4f4d}.warning-title{font-family:Oswald,sans-serif;font-size:clamp(24px,5vh,48px);color:var(--amber-bright);margin-bottom:30px;text-shadow:0 0 20px rgba(255,180,84,.6),2px 0 rgba(217,80,47,.5),-2px 0 rgba(255,233,184,.4);letter-spacing:.1em;line-height:1.3}.warning-message{font-size:clamp(16px,3vh,24px);color:var(--amber);margin-bottom:40px;line-height:1.6;opacity:.9}.warning-subtitle{font-size:clamp(14px,2.5vh,20px);color:var(--dust);margin-top:40px;opacity:.8;border-top:1px solid var(--sand-mid);padding-top:20px}.scan-effect{position:absolute;top:0;left:0;width:100%;height:2px;background:#ffb45480;box-shadow:0 0 10px var(--amber);animation:scan 3s linear infinite}@keyframes scan{0%{top:0;opacity:1}50%{opacity:.7}to{top:100%;opacity:1}}.grid-overlay-warning{position:absolute;top:0;left:0;width:100%;height:100%;background-image:linear-gradient(rgba(240,164,76,.04) 1px,transparent 1px),linear-gradient(90deg,rgba(240,164,76,.04) 1px,transparent 1px);background-size:30px 30px;pointer-events:none}.version-label{position:absolute;top:clamp(8px,2vh,16px);right:clamp(8px,2vw,16px);font-size:clamp(8px,1.2vh,12px);color:var(--dust);opacity:.6;letter-spacing:.05em;z-index:7}.grid-overlay{position:absolute;inset:0;background-image:linear-gradient(rgba(240,164,76,.03) 1px,transparent 1px),linear-gradient(90deg,rgba(240,164,76,.03) 1px,transparent 1px);background-size:20px 20px;pointer-events:none;z-index:1}@media(max-width:480px){#hud{gap:clamp(4px,1.5vw,10px);padding:4px 6px}.hud-item{padding:0 4px}.hud-bar{width:clamp(38px,14vw,60px)}}@media(max-height:400px){#hud{padding:2px 6px;gap:4px}.hud-label{display:none}}body.mobile-active #gameContainer{display:none!important}body.mobile-active .mobile-warning{display:flex!important}.warning-alert{margin-bottom:20px;color:#d9502f;text-shadow:0 0 10px #d9502f}.msg-title{font-size:clamp(20px,4vh,32px);margin-bottom:20px}.msg-big{margin:20px 0;font-size:clamp(16px,3vh,24px)}.msg-small{margin-top:30px;font-size:clamp(12px,2vh,16px)}#title{position:absolute;inset:0;z-index:8;display:none;flex-direction:column;align-items:center;justify-content:center;gap:clamp(6px,1.4vh,14px);pointer-events:none;background:radial-gradient(ellipse at 50% 50%,#140b0840,#140b08b3 75%);text-align:center}.title-kicker{font-family:Oswald,sans-serif;letter-spacing:.6em;color:var(--dust);font-size:clamp(11px,1.6vh,16px);padding-left:.6em}.title-logo{font-family:Oswald,sans-serif;font-weight:700;font-size:clamp(36px,9vh,96px);letter-spacing:.04em;line-height:1;color:var(--amber-bright);text-shadow:0 0 30px rgba(255,180,84,.55),3px 0 rgba(217,80,47,.55),-3px 0 rgba(255,233,184,.35),0 4px 0 #3a1c10}.title-logo span{color:var(--rust-red)}.title-sub{color:var(--sun-core);opacity:.8;font-size:clamp(12px,1.8vh,18px);letter-spacing:.08em}.title-start{margin-top:clamp(10px,3vh,30px);padding:8px 18px;border:1px solid var(--amber);background:#140b08bf;color:var(--amber-bright);letter-spacing:.18em;font-size:clamp(12px,1.8vh,18px);animation:titlePulse 1.4s ease-in-out infinite}@keyframes titlePulse{50%{opacity:.45}}.title-hi{color:var(--dust);font-size:clamp(10px,1.4vh,14px);letter-spacing:.12em}#debug{display:none;position:absolute;left:8px;top:calc(var(--hud-h, 40px) + 8px);z-index:9;margin:0;padding:6px 10px;background:#000000a6;color:#9dffb0;font:12px/1.35 Share Tech Mono,monospace;pointer-events:none;white-space:pre}.emp-fill{background:linear-gradient(to right,#3a6a8a,#9fe8ff)!important;box-shadow:0 0 10px #9fe8ff80}#empItem.ready .hud-bar{border-color:#9fe8ff;animation:empReady .6s ease-in-out infinite}@keyframes empReady{50%{box-shadow:0 0 12px #9fe8ffe6}}#mult.hot{color:#ffe070;text-shadow:0 0 12px rgba(255,224,112,.9)}#boss{display:none;position:absolute;left:50%;transform:translate(-50%);top:calc(var(--hud-h, 40px) + 10px);z-index:8;width:min(420px,70%);text-align:center;pointer-events:none}#boss .boss-name{font-family:Oswald,sans-serif;letter-spacing:.2em;font-size:12px;color:#ff8a6a;text-shadow:0 0 8px rgba(217,80,47,.8);margin-bottom:4px}#boss .boss-bar{height:6px;border:1px solid #d9502f;background:#0009}#bossFill{height:100%;width:100%;background:linear-gradient(to right,#8a1a10,#ff5a3a);box-shadow:0 0 10px #ff5a3ab3;transition:width .15s}#bossBanner{display:none;position:absolute;top:30%;left:50%;transform:translate(-50%,-50%);z-index:9;font-family:Oswald,sans-serif;font-size:clamp(13px,2.6vh,22px);letter-spacing:.2em;white-space:nowrap;color:#ff6a4a;text-shadow:0 0 20px rgba(255,90,58,.9);pointer-events:none;animation:bannerBlink .35s steps(2) infinite}@keyframes bannerBlink{50%{opacity:.25}}#hint{position:absolute;left:50%;top:calc(var(--hud-h, 40px) + 44px);z-index:8;transform:translate(-50%,-10px);opacity:0;transition:opacity .3s,transform .3s;max-width:min(640px,90%);padding:6px 14px;text-align:center;pointer-events:none;background:#140b08e6;border-left:3px solid var(--amber-bright);color:var(--sun-core);font-size:clamp(11px,1.6vh,15px);letter-spacing:.06em}#hint.on{opacity:1;transform:translate(-50%)}.menu{display:flex;flex-direction:column;gap:4px;min-width:min(440px,86vw);pointer-events:auto;margin-top:clamp(8px,2vh,20px)}.menu-item{display:flex;align-items:baseline;gap:10px;width:100%;padding:7px 14px;border:1px solid transparent;background:#140b08b8;color:var(--amber);font:inherit;font-size:clamp(12px,1.8vh,16px);letter-spacing:.12em;text-align:left;cursor:pointer}.menu-item.sel{border-color:var(--amber-bright);background:#3c1e0ee6;color:var(--amber-bright);box-shadow:0 0 18px #ffb45440}.menu-item.sel .menu-label:before{content:"\25b8  "}.menu-item.off{opacity:.38;cursor:default}.menu-tag{min-width:58px;font-size:.75em;color:var(--dust);letter-spacing:.08em}.menu-label{flex:0 0 auto;font-family:Oswald,sans-serif;letter-spacing:.18em}.menu-detail{margin-left:auto;font-size:.78em;color:var(--dust);letter-spacing:.04em;text-align:right}#title{pointer-events:none}#panel{display:none;position:absolute;inset:0;z-index:9;flex-direction:column;align-items:center;justify-content:center;background:radial-gradient(ellipse at 50% 50%,#140b088c,#140b08e0 70%);padding:20px;overflow:auto}#panel h2{font-family:Oswald,sans-serif;font-weight:700;letter-spacing:.3em;color:var(--amber-bright);font-size:clamp(20px,4vh,34px);text-shadow:0 0 18px rgba(255,180,84,.5);margin-bottom:10px}#panelBody{color:var(--sun-core);font-size:clamp(11px,1.6vh,14px);letter-spacing:.06em;text-align:center;max-width:min(560px,90vw);display:flex;flex-direction:column;gap:3px}.deb-row{display:flex;justify-content:space-between;gap:24px;min-width:min(520px,86vw);padding:3px 10px;border-bottom:1px solid rgba(156,74,38,.35);text-align:left}.deb-row span:first-child{color:var(--dust);letter-spacing:.14em}.deb-row span:last-child{text-align:right}.deb-row.gold span:last-child{color:#ffe070;text-shadow:0 0 10px rgba(255,224,112,.6)}.deb-row.warn span:last-child{color:#ff8a6a}#progress{display:none;position:absolute;left:50%;transform:translate(-50%);top:calc(var(--hud-h, 40px) + 2px);width:min(420px,60%);height:3px;background:#00000080;z-index:7;pointer-events:none}#progress.on{display:block}#progressFill{height:100%;width:0;background:linear-gradient(to right,var(--rust-red),var(--amber-bright))}#progressLabel{position:absolute;right:-4px;top:-5px;transform:translate(100%);font-size:10px;color:var(--dust);white-space:nowrap;padding-left:8px;letter-spacing:.1em}#sectorCard{position:absolute;left:50%;top:24%;transform:translate(-50%,-50%);z-index:8;text-align:center;opacity:0;transition:opacity .6s;pointer-events:none}#sectorCard.on{opacity:1}#sectorCard .sc-title{font-family:Oswald,sans-serif;font-weight:700;font-size:clamp(20px,4.4vh,40px);letter-spacing:.3em;color:var(--amber-bright);text-shadow:0 0 24px rgba(255,180,84,.7),0 3px 0 #3a1c10}#sectorCard .sc-sub{margin-top:6px;color:var(--sun-core);letter-spacing:.2em;font-size:clamp(11px,1.7vh,15px);opacity:.85}#captions{position:absolute;left:12px;bottom:110px;z-index:8;display:flex;flex-direction:column;gap:3px;pointer-events:none;max-width:60%}#captions div{background:#000000b8;color:#fff;font-size:clamp(11px,1.7vh,15px);padding:3px 8px;letter-spacing:.04em;border-left:3px solid #ffe040}body.reduced-motion *,body.reduced-motion *:before,body.reduced-motion *:after{animation:none!important;transition:none!important}#touch{display:none;position:absolute;inset:0;z-index:6;pointer-events:none}#touch.on{display:block}#touch .t-zone{position:absolute;inset:0 96px 0 0;pointer-events:auto;touch-action:none}#touch .t-buttons{position:absolute;right:10px;bottom:calc(18px + env(safe-area-inset-bottom));display:grid;gap:10px;pointer-events:auto}#touch button{width:72px;height:72px;border-radius:50%;border:2px solid rgba(255,195,107,.7);background:#140b088c;color:var(--amber-bright);font:600 14px Oswald,sans-serif;letter-spacing:.08em;display:flex;flex-direction:column;align-items:center;justify-content:center;touch-action:none;user-select:none}#touch button small{font-size:9px;opacity:.7;letter-spacing:.1em}#touch button.on{background:#ffb45473;color:#fff}#touch .t-fire{position:absolute;left:14px;bottom:calc(18px + env(safe-area-inset-bottom));pointer-events:auto}#touch .t-pause{position:absolute;right:10px;top:54px;width:44px;height:44px;font-size:13px;pointer-events:auto}body.touch .controls-hint{display:none}body.touch #captions{bottom:18px;left:14px;max-width:calc(100% - 190px)}@media(orientation:portrait){#touch .t-buttons{grid-template-columns:1fr 1fr}}@media(max-width:600px){#bossBanner{white-space:normal;width:92%;text-align:center}#progressLabel{display:none}}#touch .t-pause{top:calc(var(--hud-h, 40px) + 40px)}.menu-item.gold .menu-tag,.menu-item.gold .menu-label{color:#ffe070;text-shadow:0 0 10px rgba(255,224,112,.55)}.menu-item.dim .menu-label,.menu-item.dim .menu-tag{opacity:.55}

.hud-chrome {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hud-chrome-left {
  margin-right: auto;
}
.hud-chrome-right {
  margin-left: auto;
}
#hud {
  gap: 8px 14px !important;
  padding: 7px 14px !important;
  background: linear-gradient(180deg, #21140d, #140b08) !important;
  border-bottom: 1px solid rgba(240, 164, 76, 0.5) !important;
}
#hud .hud-item {
  padding: 0 8px !important;
  gap: 6px !important;
}
#hud .hud-label {
  color: #e6caa0 !important;
  font-size: clamp(10px, 1.3vh, 12px) !important;
  opacity: 1 !important;
  letter-spacing: 0.08em !important;
}
#hud .hud-value {
  color: #ffd791 !important;
  font-size: clamp(13px, 1.85vh, 17px) !important;
}
#hud .hud-bar {
  width: clamp(54px, 8vw, 96px) !important;
  height: clamp(14px, 2vh, 18px) !important;
  border-color: rgba(240, 164, 76, 0.55) !important;
}
#hud .hud-bar-value {
  font-size: clamp(9px, 1.2vh, 11px) !important;
  color: #fff6e2 !important;
}
.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid rgba(255, 195, 107, 0.7);
  border-radius: 3px;
  background: rgba(46, 25, 15, 0.94);
  color: #ffe8ba;
  font-family: "Oswald", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.hud-btn:hover {
  border-color: #ffe0a6;
  background: rgba(240, 164, 76, 0.24);
  color: #ffffff;
}
.hud-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}
.hud-btn-icon {
  padding: 4px 10px;
  font-size: 15px;
  line-height: 1;
}
</style>
</head>
<body>
  <div id="gameContainer">

    <div id="hud">
      <div class="hud-chrome hud-chrome-left">
        <a class="hud-btn" href="/games" target="_top" data-back-to-games title="Back to Games" aria-label="Back to Games">← BACK</a>
      </div>
      <div class="hud-item"><span class="hud-label">HI-SC</span><span class="hud-value" id="hiscore">000000</span></div>
      <div class="hud-item"><span class="hud-label">SCORE</span><span class="hud-value" id="score">000000</span></div>
      <div class="hud-item"><span class="hud-label">LIVES</span><span class="hud-value" id="lives">03</span></div>
      <div class="hud-item"><span class="hud-label">TIME</span><span class="hud-value" id="time">000</span></div>
      <div class="hud-item"><span class="hud-label">CHAIN</span><span class="hud-value" id="mult">×1.0</span></div>
      <div class="hud-item"><span class="hud-label">MSL</span><span class="hud-value" id="missiles">10</span></div>
      <div class="hud-item"><span class="hud-label">FLR</span><span class="hud-value" id="flares">3</span></div>
      <div class="hud-item"><span class="hud-label">SPD</span><span class="hud-value" id="speed">2.5</span></div>
      <div class="hud-item hud-bar-item">
        <span class="hud-label">SHLD</span>
        <div class="hud-bar"><div class="hud-bar-fill" id="shieldsBar"></div><span class="hud-bar-value" id="shieldsValue">100%</span></div>
      </div>
      <div class="hud-item hud-bar-item">
        <span class="hud-label">FUEL</span>
        <div class="hud-bar"><div class="hud-bar-fill" id="fuelBar"></div><span class="hud-bar-value" id="fuelValue">100%</span></div>
      </div>
      <div class="hud-item hud-bar-item" id="empItem">
        <span class="hud-label">EMP</span>
        <div class="hud-bar"><div class="hud-bar-fill emp-fill" id="empBar"></div><span class="hud-bar-value" id="empValue">0%</span></div>
      </div>
      <div class="hud-chrome hud-chrome-right">
        <a class="hud-btn" href="https://github.com/alaric-visi/apache-canyon" target="_blank" rel="noopener noreferrer" data-github-link title="View on GitHub" aria-label="View on GitHub">
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.28-.01-1.02-.02-2-3.2.7-3.88-1.54-3.88-1.54-.52-1.33-1.28-1.68-1.28-1.68-1.05-.71.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.73-1.54-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.09-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11.1 11.1 0 0 1 5.8 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.8 1.19 1.83 1.19 3.09 0 4.42-2.7 5.39-5.26 5.67.41.36.78 1.06.78 2.14 0 1.55-.01 2.79-.01 3.17 0 .31.21.68.8.56A11.51 11.51 0 0 0 23.5 12C23.5 5.65 18.35.5 12 .5Z"/></svg>
          <span>GITHUB</span>
        </a>
        <button type="button" class="hud-btn hud-btn-icon" data-fullscreen-toggle title="Toggle fullscreen" aria-label="Toggle fullscreen">⛶</button>
      </div>
    </div>

    <canvas id="gameCanvas"></canvas>

    <div id="title">
      <div class="title-kicker">DUSK OPS · VER 8.0</div>
      <h1 class="title-logo">APACHE<span>//</span>CAN.YON</h1>
      <div class="title-sub">Low sun. Narrow canyon. Hostile sky.</div>
      <div class="menu" id="menu"></div>
      <div class="title-hi">HI-SCORE <span data-hiscore>000000</span> · ↑↓ SELECT · [SPACE] LAUNCH</div>
    </div>

    <div id="panel">
      <h2 id="panelTitle"></h2>
      <div id="panelBody"></div>
      <div class="menu" id="panelMenu"></div>
    </div>

    <div id="progress"><div id="progressFill"></div><span id="progressLabel"></span></div>
    <div id="sectorCard"><div class="sc-title"></div><div class="sc-sub"></div></div>

    <div id="boss"><div class="boss-name" id="bossName"></div><div class="boss-bar"><div id="bossFill"></div></div></div>
    <div id="bossBanner">⚠ HOSTILE GUNSHIP INBOUND ⚠</div>

    <div id="hint"></div>
    <div id="captions" aria-live="polite"></div>
    <pre id="debug"></pre>
    <div id="message"></div>
    <div class="controls-hint">[Z] FIRE (tap to cool) · [X] MISSILE (hold to lock) · [C] FLARE · [V] EMP · [SHIFT] BOOST · ARROWS MOVE · [SPACE] PAUSE · <span id="qualityStatus">[Q] QUALITY: HIGH</span> · <span id="muteStatus">[M]: MUTE (OFF)</span> · [`] DEBUG</div>
  </div>

  <script>"use strict";(()=>{var EM=Object.create;var Wh=Object.defineProperty;var PM=Object.getOwnPropertyDescriptor;var kM=Object.getOwnPropertyNames;var AM=Object.getPrototypeOf,RM=Object.prototype.hasOwnProperty;var f=(i,e)=>()=>(i&&(e=i(i=0)),e);var BM=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Fa=(i,e)=>{for(var t in e)Wh(i,t,{get:e[t],enumerable:!0})},IM=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of kM(e))!RM.call(i,s)&&s!==t&&Wh(i,s,{get:()=>e[s],enumerable:!(r=PM(e,s))||r.enumerable});return i};var GM=(i,e,t)=>(t=i!=null?EM(AM(i)):{},IM(e||!i||!i.__esModule?Wh(t,"default",{value:i,enumerable:!0}):t,i));function Vh(){return Math.random()*4294967295>>>0}var Ir,pn=f(()=>{"use strict";Ir=class{a;b;c;d;constructor(e){let t=e>>>0,r=()=>{t=t+2654435769>>>0;let s=t;return s=Math.imul(s^s>>>16,2246822507)>>>0,s=Math.imul(s^s>>>13,3266489909)>>>0,(s^s>>>16)>>>0};this.a=r(),this.b=r(),this.c=r(),this.d=r();for(let s=0;s<12;s++)this.next()}next(){let e=(this.a+this.b>>>0)+this.d>>>0;return this.d=this.d+1>>>0,this.a=this.b^this.b>>>9,this.b=this.c+(this.c<<3)>>>0,this.c=this.c<<21|this.c>>>11,this.c=this.c+e>>>0,e/4294967296}range(e,t){return e+this.next()*(t-e)}int(e){return Math.floor(this.next()*e)}pick(e){return e[this.int(e.length)]}chance(e){return this.next()<e}}});var be,j,FM,DM,Ki,Am,$h,La,At=f(()=>{"use strict";pn();be=800,j=600,FM=300,DM=72,Ki=24,Am=4,$h={width:FM,amp:1,narrow:1,height:1},La=class{ph;profileAt=()=>$h;constructor(e){let t=new Ir(e^1554098974);this.ph=Array.from({length:8},()=>t.range(0,Math.PI*2))}at(e,t={left:0,right:0}){let r=e/Am,s=this.ph,n=this.profileAt(e),o=n.amp*(Math.sin(r*.0234+s[0])*70+Math.cos(r*.0431+s[1])*55+Math.sin(r*.0627+s[2])*40+Math.cos(r*.0089+s[3])*60+Math.sin(r*.0153+s[4])*35),a=n.narrow*(Math.sin(r*.0179+s[5])*55+Math.cos(r*.0347+s[6])*45+Math.sin(r*.0521+s[7])*30);a=Math.max(a,(DM-n.width)/2);let l=be/2+o,c=l-n.width/2-a,h=l+n.width/2+a;return c<Ki?(h+=Ki-c,c=Ki):h>be-Ki&&(c-=h-(be-Ki),h=be-Ki),t.left=c,t.right=h,t}height(e){let t=e/Am,r=this.ph,s=(.6+Math.sin(t*.0113+r[2])*.25+Math.sin(t*.0371+r[6])*.15)*this.profileAt(e).height;return Math.min(1,Math.max(.15,s))}}});var Na,Xh,fn,Yh,Ha,za,ji=f(()=>{"use strict";At();Na=j*.7,Xh=250,fn=530,Yh=99,Ha=120,za=500});function st(i,e){let t=0;for(;t<i.length;)e(i[t])?t++:(i[t]=i[i.length-1],i.pop())}var Jt,Rt,qi,Kh,Gr=f(()=>{"use strict";Jt=(i,e,t)=>i<e?e:i>t?t:i,Rt=(i,e,t)=>i+(e-i)*t,qi=(i,e)=>i.x<e.x+e.w&&i.x+i.w>e.x&&i.y<e.y+e.h&&i.y+i.h>e.y,Kh=(i,e,t)=>i>=t.x&&i<=t.x+t.w&&e>=t.y&&e<=t.y+t.h});var mn,Bt,xt,Rm,di=f(()=>{"use strict";mn={ground:!1,bounces:!0},Bt={ground:!0,bounces:!1,vxSpread:0},xt={drone:{...mn,w:16,h:16,hp:2,vy:1.5,vxSpread:1.5,score:200,missileDamage:1/0,particles:12,bigExplosion:!1,shake:4,emp:6},uav:{...mn,w:16,h:16,hp:3,vy:1.8,vxSpread:1,score:300,missileDamage:1/0,particles:18,bigExplosion:!0,shake:6,emp:8},mine:{...mn,w:16,h:16,hp:1,vy:.5,vxSpread:1,score:100,missileDamage:1/0,particles:12,bigExplosion:!1,shake:4,emp:4},gunner:{...mn,w:18,h:18,hp:4,vy:2.2,vxSpread:0,score:400,missileDamage:1/0,particles:16,bigExplosion:!0,shake:6,emp:10},gunship:{...mn,w:30,h:30,hp:70,vy:1.6,vxSpread:0,score:3e3,missileDamage:6,particles:40,bigExplosion:!0,shake:14,emp:40},turret:{...Bt,w:14,h:14,hp:4,vy:0,score:350,missileDamage:1/0,particles:14,bigExplosion:!1,shake:5,emp:8},flak:{...Bt,w:16,h:16,hp:5,vy:0,score:450,missileDamage:1/0,particles:16,bigExplosion:!0,shake:6,emp:10},sam:{...Bt,w:18,h:18,hp:5,vy:0,score:600,missileDamage:1/0,particles:20,bigExplosion:!0,shake:7,emp:12},tank:{...Bt,w:18,h:22,hp:8,vy:-.6,score:700,missileDamage:5,particles:22,bigExplosion:!0,shake:8,emp:14},depot:{...Bt,w:18,h:18,hp:3,vy:0,score:150,missileDamage:1/0,particles:22,bigExplosion:!0,shake:6,emp:4},dam:{...Bt,w:300,h:28,hp:90,vy:0,score:5e3,missileDamage:6,particles:60,bigExplosion:!0,shake:16,emp:30},sluice:{...Bt,w:18,h:12,hp:14,vy:0,score:500,missileDamage:5,particles:18,bigExplosion:!0,shake:8,emp:8},traincar:{...Bt,w:20,h:34,hp:14,vy:0,score:600,missileDamage:6,particles:24,bigExplosion:!0,shake:8,emp:10},engine:{...Bt,w:22,h:40,hp:75,vy:0,score:5e3,missileDamage:6,particles:50,bigExplosion:!0,shake:16,emp:30},dish:{...Bt,w:36,h:36,hp:70,vy:0,score:6e3,missileDamage:6,particles:50,bigExplosion:!0,shake:16,emp:30},shieldgen:{...Bt,w:14,h:14,hp:14,vy:0,score:500,missileDamage:6,particles:16,bigExplosion:!0,shake:6,emp:8},gate:{...Bt,w:12,h:12,hp:6,vy:0,score:400,missileDamage:1/0,particles:22,bigExplosion:!0,shake:8,emp:10}},Rm=i=>i!=="mine"});function OM(i){return Math.min(5,1+Math.floor(i/4)*.5)}function Fr(i,e,t,r,s){let n=Math.round(e*i.combo.mult);return i.score+=n,i.emit({type:"score",x:t,y:r,amount:n,label:s}),n}function Bm(i,e=1){let t=i.combo,r=t.mult;t.count+=e,t.timer=180,t.mult=OM(t.count),t.mult>r&&i.emit({type:"combo",mult:t.mult})}function jh(i){i.combo.count>0&&(i.combo.timer=Math.max(i.combo.timer,60))}function Wa(i){let e=i.combo;e.count>=4&&i.emit({type:"comboBreak"}),e.count=0,e.timer=0,e.mult=1}function gn(i,e){i.emp=Math.min(100,i.emp+e)}function Im(i){let e=i.combo;e.timer>0&&--e.timer===0&&Wa(i);let t=i.player,r=i.corridorAt(t.y+t.h/2),s=Math.min(t.x-(r.left+10),r.right-10-(t.x+t.w));if(s>2&&s<16&&t.invuln===0){if(i.grazeTicks++,i.stats.grazeTicks++,gn(i,.25),jh(i),i.grazeTicks%10===0){let n=t.x-r.left<r.right-(t.x+t.w);Fr(i,20,n?t.x-6:t.x+t.w+6,t.y,"GRAZE")}}else i.grazeTicks=0;for(i.distScoreAcc+=i.scrollSpeed;i.distScoreAcc>=20;)i.distScoreAcc-=20,i.score+=Math.round(i.combo.mult)}var xn=f(()=>{"use strict"});var O,yR,fr=f(()=>{"use strict";O={player:{lives:3,missiles:10,flares:3,maxFlares:6,invulnTicks:120,scrapeDamage:.5,hurtGrace:12,agilityExponent:1},speed:{start:2.5,max:4.5,step:.2,every:1200,boost:1.6},economy:{fuelBurn:.025,boostFuelBurn:.05,pickupInterval:210,pickups:{fuel:.34,shield:.25,missile:.2,flare:.13,spread:.12},fuelPickup:35,shieldPickup:40,missilePickup:5,flarePickup:2,spreadTicks:900},damage:{droneShot:8,gunnerShot:10,turretShot:10,tankShell:20,sam:30,gunshipBullet:12,gunshipRocket:20,flak:15,mine:25,gate:15},ram:{drone:10,uav:12,mine:20,gunner:20,gunship:35},gate:{hp:4,on:90,off:30},uav:{steer:.03,maxVx:2},shotSpeed:{drone:2.6,gunner:3.6,turret:3.8,tank:2.3,sam:2.4,gunshipFan:3,gunshipBurst:4,rocket:3},telegraph:{scout:26,gunner:45,turretAim:55,turretLock:14,mineFuse:42,flakFuse:62,samLock:95,tank:40},director:{paceMax:.3,paceSeconds:600,reliefTicks:180,reliefRate:.55}},yR=structuredClone(O)});function Zh(i,e){let{on:t,off:r}=O.gate;return(i.tick+e.id*37)%(t+r)<t}function Fm(i,e){let{on:t,off:r}=O.gate,s=(i.tick+e.id*37)%(t+r);return s<t?t-s:t+r-s}function Qh(i,e){let t=e.y+e.h/2,r=i.corridorAt(t);return{x:r.left,y:t-3,w:r.right-r.left,h:6}}function Jh(i,e,t){let r=xt[e.kind],s=e.x+e.w/2,n=e.y+e.h/2;if(e.shielded)return i.emit({type:"block",x:s,y:n}),!1;if(e.hp-=t,e.flash=4,e.hp>0)return i.emit({type:"hit",x:s,y:n}),!1;if(i.emit({type:"explode",x:s,y:n,particles:r.particles,big:r.bigExplosion,shake:r.shake}),Bm(i),Fr(i,r.score,s,n),gn(i,r.emp),i.stats.kills[e.kind]=(i.stats.kills[e.kind]??0)+1,e.group!==0&&i.bossState&&e.kind===i.bossState.core&&i.stats.bossKills.push(e.group),e.kind==="depot"){i.emit({type:"depot",x:s,y:n});let o=i.corridorAt(n),a=Math.min(Math.max(s-6,o.left+yn),o.right-12-yn);i.pickups.push({kind:"fuel",x:a,y:n-6,w:12,h:12,px:a,py:n-6,vy:i.scrollSpeed*.6,rot:0})}return e.kind==="sam"&&e.state===1&&i.emit({type:"lockEnd"}),!0}function Dm(i){for(let e of i.bullets)e.x+=e.vx,e.y+=e.vy;st(i.bullets,e=>e.y>-10&&e.x>-20&&e.x<820);for(let e of i.playerMissiles){let t=e.targetId!==null?i.hostiles.find(s=>s.id===e.targetId):void 0;if(!t){let s=eu(i,e.x+e.w/2,e.y);e.targetId=s?s.id:null,t=s??void 0}if(t){let s=t.x+t.w/2-(e.x+e.w/2),n=t.y+t.h/2-e.y,o=Math.hypot(s,n);o>0&&(e.vx+=s/o*Gm,e.vy+=n/o*Gm)}let r=Math.hypot(e.vx,e.vy);r>qh&&(e.vx=e.vx/r*qh,e.vy=e.vy/r*qh),e.x+=e.vx,e.y+=e.vy}st(i.playerMissiles,e=>e.y>-10&&e.y<j)}function Om(i){i.hostileGrid.rebuild(i.hostiles);let e=new Set,t=i.hostiles.filter(o=>o.kind==="gate"&&Zh(i,o)),r=t.map(o=>Qh(i,o)),s=(o,a,l)=>{for(let c of i.hostileGrid.query(o,a,0,0))if(!(e.has(c)||!Kh(o,a,c)))return Jh(i,c,l(c))&&e.add(c),!0;for(let c=0;c<t.length;c++)if(!e.has(t[c])&&Kh(o,a,r[c]))return i.emit({type:"block",x:o,y:r[c].y+3}),!0;return!1};st(i.bullets,o=>{let a=i.events.length;return s(o.x,o.y,()=>1)?(i.events.slice(a).some(l=>l.type==="block")||i.stats.shotsHit++,!1):!0}),st(i.playerMissiles,o=>!s(o.x+o.w/2,o.y,a=>xt[a.kind].missileDamage));let n=i.player;if(n.invuln===0){let o={x:n.x+2,y:n.y+2,w:n.w-4,h:n.h-4};for(let a of i.hostileGrid.query(n.x,n.y,n.w,n.h)){let l=O.ram[a.kind]??0;if(!(e.has(a)||l===0||!qi(a,o))&&(e.add(a),i.emit({type:"explode",x:a.x+a.w/2,y:a.y+a.h/2,particles:14,big:!1,shake:10,damage:!0}),i.damagePlayer(l,`contact:${a.kind}`),i.status!=="running"||n.invuln>0))break}for(let a=0;a<t.length&&n.invuln===0&&i.status==="running";a++)e.has(t[a])||!qi(r[a],n)||(e.add(t[a]),i.emit({type:"explode",x:n.x+n.w/2,y:n.y+n.h/2,particles:16,big:!1,shake:12,damage:!0}),i.damagePlayer(O.damage.gate,"gate"))}i.status==="running"&&st(i.hostiles,o=>!e.has(o)&&(o.group!==0||o.y<j+30&&o.y>-200))}function Lm(i){let e=i.player,t={left:0,right:0};st(i.pickups,r=>{if(r.y+=r.vy,r.rot+=.1,i.mods.magnet>0){let s=e.x+e.w/2-(r.x+r.w/2),n=e.y+e.h/2-(r.y+r.h/2),o=Math.hypot(s,n);o<i.mods.magnet&&o>1&&(r.x+=s/o*2.2,r.y+=n/o*2.2)}if(i.corridorAt(r.y+r.h/2,t),r.x=Math.min(Math.max(r.x,t.left+yn),Math.max(t.left+yn,t.right-r.w-yn)),qi(r,e)){let s=O.economy;return r.kind==="fuel"?i.fuel=Math.min(100,i.fuel+s.fuelPickup):r.kind==="shield"?i.shields=Math.min(i.maxShields,i.shields+s.shieldPickup):r.kind==="missile"?i.missiles=Math.min(99,i.missiles+s.missilePickup):r.kind==="flare"?i.flares=Math.min(O.player.maxFlares,i.flares+s.flarePickup):e.spread=s.spreadTicks,i.emit({type:"pickup",x:r.x+r.w/2,y:r.y+r.h/2,kind:r.kind}),!1}return r.y<j})}var Gm,qh,yn,Va=f(()=>{"use strict";At();di();Gr();bn();xn();fr();Gm=.5,qh=8,yn=4});function Wm(i,e){let t=i.player;t.invuln>0&&t.invuln--,t.flash>0&&t.flash--,t.hurtGrace>0&&t.hurtGrace--,t.muzzle>0&&t.muzzle--,t.fireCooldown>0&&t.fireCooldown--,t.flareCooldown>0&&t.flareCooldown--,t.spread>0&&t.spread--,t.steer=(e.right?1:0)-(e.left?1:0),t.x+=t.steer*t.speed*i.mods.agility*Math.max(1,i.scrollSpeed/O.speed.start)**O.player.agilityExponent,t.y=Jt(t.y+((e.down?1:0)-(e.up?1:0))*LM,Xh,fn);let r=i.corridorAt(t.y+t.h/2),s=r.left+Um,n=r.right-t.w-Um;t.x=Jt(t.x,s,Math.max(s,n));let o=t.x<=s+Nm,a=t.x>=n-Nm;if(!((o||a)&&t.invuln===0&&(i.tick%8===0&&i.emit({type:"scrape",x:o?t.x:t.x+t.w,y:t.y+t.h/2}),i.options.assist||i.damagePlayer(O.player.scrapeDamage,"scrape"),i.status!=="running"))){if(ZM(i,e),QM(i,e),e.flare&&t.flareCooldown===0&&i.flares>0){i.flares--,i.stats.flaresUsed++,t.flareCooldown=jM;for(let l=0;l<4;l++){let c=(l-1.5)*1.1;i.flareObjs.push({id:i.nextId++,x:t.x+t.w/2-2,y:t.y+t.h,w:4,h:4,px:t.x+t.w/2-2,py:t.y+t.h,vx:c,vy:1.2+Math.abs(c)*.3,life:80})}i.emit({type:"flare",x:t.x+t.w/2,y:t.y+t.h})}if(e.emp&&i.emp>=100){i.emp=0,i.stats.empsUsed++;let l=t.x+t.w/2,c=t.y+t.h/2;i.emit({type:"emp",x:l,y:c});for(let u of i.enemyShots)i.emit({type:"hit",x:u.x,y:u.y});i.enemyShots.length=0,i.hazards.length=0;let h=[];for(let u of i.hostiles)u.y+u.h<0||(Jh(i,u,qM)?h.push(u):u.kind==="sam"&&u.state===1&&(u.state=0,u.timer=120,u.charge=0));h.length&&(i.hostiles=i.hostiles.filter(u=>!h.includes(u)))}}}function ZM(i,e){let t=i.player,r=e.fire&&!t.overheated;if(!e.fire&&t.fireHeld&&!t.overheated&&t.heat>=er[0]-i.mods.coolWiden/2&&t.heat<=er[1]+i.mods.coolWiden/2&&(t.heat=Math.max(0,t.heat-VM),i.emit({type:"coolPerfect",x:t.x+t.w/2,y:t.y-6})),t.fireHeld=e.fire,t.overheated?(t.heat=Math.max(0,t.heat-zM),t.heat<=WM&&(t.overheated=!1)):r||(t.heat=Math.max(0,t.heat-HM)),r&&t.fireCooldown===0){let s=t.x+t.w/2-1;if(i.bullets.push({x:s,y:t.y,w:2,h:8,px:s,py:t.y,vx:0,vy:tu}),t.spread>0)for(let n of[-Hm,Hm])i.bullets.push({x:s,y:t.y+2,w:2,h:8,px:s,py:t.y+2,vx:Math.sin(n)*-tu,vy:Math.cos(n)*tu});t.fireCooldown=UM,t.muzzle=4,t.heat+=NM*i.mods.heat,i.stats.shotsFired++,i.emit({type:"shoot",x:t.x+t.w/2,y:t.y}),t.heat>=100&&(t.heat=100,t.overheated=!0,i.emit({type:"overheat"}))}}function eu(i,e,t,r=[]){let s=null,n=1/0;for(let o of i.hostiles){if(!Rm(o.kind)||o.shielded||r.includes(o.id))continue;let a=o.x+o.w/2,l=o.y+o.h/2,c=t-l;if(c<=0||l<-10||Math.abs(a-e)>c*.8+40)continue;let h=(a-e)**2+c**2;h<n&&(n=h,s=o)}return s}function zm(i,e){let t=i.player;if(i.missiles<=0)return;i.missiles--,i.stats.missilesFired++;let r=t.x+t.w/2-2;i.playerMissiles.push({x:r,y:t.y,w:4,h:12,px:r,py:t.y,vx:(i.rng.next()-.5)*2,vy:$M,targetId:e}),i.emit({type:"missile",x:t.x+t.w/2,y:t.y})}function QM(i,e){let t=i.player,r=s=>i.hostiles.some(n=>n.id===s);if(t.locks=t.locks.filter(r),e.missile){if(t.missileHold++,t.missileHold>=_n&&(t.missileHold-_n)%XM===0&&t.locks.length<Math.min(YM,i.missiles)){let s=eu(i,t.x+t.w/2,t.y,t.locks);s&&(t.locks.push(s.id),i.emit({type:"paint",x:s.x+s.w/2,y:s.y+s.h/2,count:t.locks.length}))}}else t.missileHeld&&(t.missileHold<_n||t.locks.length===0?zm(i,null):(t.ripple.push(...t.locks),t.rippleTimer=0),t.locks.length=0,t.missileHold=0);if(t.missileHeld=e.missile,t.ripple.length>0&&t.rippleTimer--<=0){let s=t.ripple.shift();zm(i,r(s)?s:null),t.rippleTimer=KM}}var Um,Nm,LM,UM,tu,NM,HM,zM,WM,er,VM,Hm,$M,_n,XM,YM,KM,jM,qM,bn=f(()=>{"use strict";ji();Gr();di();Va();fr();Um=10,Nm=2,LM=3,UM=5,tu=-8.5,NM=7,HM=1.1,zM=1,WM=30,er=[55,82],VM=32,Hm=.2,$M=-6,_n=10,XM=12,YM=4,KM=6,jM=45,qM=3});function Vm(i,e,t,r,s=JM){let n=-1/0,o=1/0;for(let c=e;c<=e+r;c+=Math.max(4,r/4)){let h=i.corridorAt(c);n=Math.max(n,h.left),o=Math.min(o,h.right)}let a=n+s,l=o-t-s;return l>=a?[a,l]:null}function vn(i,e,t,r){let s=xt[e];return{id:i.nextId++,kind:e,x:t,y:r,w:s.w,h:s.h,px:t,py:r,vx:s.vxSpread?i.rng.range(-s.vxSpread/2,s.vxSpread/2):0,vy:s.vy,hp:s.hp,maxHp:s.hp,flash:0,pulse:0,state:0,timer:30+i.rng.int(60),charge:0,aim:Math.PI/2,burst:0,burst2:1,cycles:0,side:1,ground:s.ground,group:0,ox:0,oy:0,variant:0,shielded:!1}}function Dr(i,e){let t=xt[e],r=-t.h-6,s,n=1;if(e==="turret"||e==="gate"){n=i.rng.chance(.5)?-1:1;let a=i.corridorAt(r+t.h/2);if(a.right-a.left<90)return null;let l=e==="gate"?Zi:1;s=n<0?a.left+l:a.right-t.w-l}else if(e==="gunship"){let a=i.corridorAt(60);s=(a.left+a.right)/2-t.w/2}else{let a=Vm(i,r,t.w,t.h);if(!a)return null;s=i.rng.range(a[0],a[1])}let o=vn(i,e,Math.min(be,s),r);return o.side=n,e==="gate"&&(o.hp=o.maxHp=O.gate.hp),e==="gunship"&&(o.y=o.py=-40),i.hostiles.push(o),o}function $a(i,e){let t=Vm(i,-20,12,12);if(!t)return!1;let r=i.rng.range(t[0],t[1]);return i.pickups.push({kind:e,x:r,y:-20,w:12,h:12,px:r,py:-20,vy:1.5,rot:0}),!0}var JM,Zi,pi=f(()=>{"use strict";di();At();fr();JM=15,Zi=24});var ue,Ke,Qi=f(()=>{"use strict";ue=(i,e,t,r,s=!1)=>({kind:i,from:e,every:t,max:r,duringBoss:s}),Ke=[{id:"red-mesa",name:"RED MESA",subtitle:"Late afternoon \xB7 wide canyon",length:27600,canyon:{width:340,amp:.85,narrow:.7,height:.8},light:{sun:[1.12,1,.86],shadow:[.32,.25,.42],shadowLen:.7,exposure:1.05,gradeLow:[.08,.04,.12],gradeHigh:[1.05,.99,.9],glow:[1,.7,.35],glowStrength:.18,night:0,nvg:0,dust:0},rules:[ue("drone",0,[100,150],3,!0),ue("uav",12,[180,260],2),ue("mine",25,[260,360],2),ue("gunner",40,[360,500],1)],setPieces:[{at:.3,wave:"droneV"},{at:.55,wave:"depotRun"},{at:.8,wave:"gunnerPincer"}],boss:"dustDevil",bossName:'RIVAL GUNSHIP "DUST DEVIL"',depots:.75,bridges:.5},{id:"narrows",name:"THE NARROWS",subtitle:"Golden hour \xB7 deep shadow",length:3e4,canyon:{width:240,amp:1.1,narrow:.9,height:1.35},light:{sun:[1.15,.95,.75],shadow:[.26,.19,.38],shadowLen:1.25,exposure:.98,gradeLow:[.1,.04,.16],gradeHigh:[1.08,.96,.82],glow:[1,.6,.25],glowStrength:.24,night:0,nvg:0,dust:0},rules:[ue("drone",0,[110,160],3,!0),ue("turret",5,[240,340],2),ue("gunner",20,[340,480],1),ue("gate",30,[700,1e3],1),ue("mine",40,[300,400],2)],setPieces:[{at:.25,wave:"turretAlley"},{at:.6,wave:"mineField"},{at:.85,wave:"turretAlley"}],boss:"dam",bossName:"FORTIFIED DAM",depots:.45,bridges:1},{id:"dry-lake",name:"DRY LAKE",subtitle:"Sunset \xB7 open flats",length:32200,canyon:{width:470,amp:.55,narrow:.55,height:.55},light:{sun:[1.18,.92,.72],shadow:[.3,.2,.36],shadowLen:1,exposure:1,gradeLow:[.12,.04,.12],gradeHigh:[1.1,.94,.8],glow:[1,.55,.3],glowStrength:.3,night:0,nvg:0,dust:0},rules:[ue("drone",0,[100,150],3,!0),ue("tank",6,[380,520],2),ue("flak",25,[500,660],1),ue("uav",10,[200,280],2),ue("gunner",35,[380,520],1)],setPieces:[{at:.2,wave:"tankColumn"},{at:.5,wave:"depotRun"},{at:.75,wave:"tankColumn"}],boss:"train",bossName:'ARMOURED TRAIN "IRON MULE"',depots:1.8,bridges:.3},{id:"sandstorm",name:"SANDSTORM PASS",subtitle:"Dusk \xB7 visibility falling",length:3e4,canyon:{width:300,amp:1,narrow:1,height:1},light:{sun:[.95,.78,.6],shadow:[.36,.27,.3],shadowLen:.6,exposure:.92,gradeLow:[.12,.07,.06],gradeHigh:[1.04,.92,.78],glow:[.9,.6,.35],glowStrength:.12,night:0,nvg:0,dust:.85},rules:[ue("drone",0,[110,160],3,!0),ue("uav",0,[200,280],2),ue("mine",10,[240,340],3,!0),ue("sam",20,[520,720],1),ue("gunner",30,[380,520],1)],setPieces:[{at:.3,wave:"samTrap"},{at:.65,wave:"mineField"}],pickups:{flare:.25},boss:"twinVipers",bossName:'TWIN GUNSHIPS "VIPER PAIR"',depots:.75,bridges:.4},{id:"night",name:"NIGHT RUN",subtitle:"Night \xB7 NVG on",length:3e4,canyon:{width:280,amp:1,narrow:.95,height:1.1},light:{sun:[.55,.65,.9],shadow:[.18,.2,.34],shadowLen:.4,exposure:.85,gradeLow:[.02,.05,.1],gradeHigh:[.9,1,1.1],glow:[.4,.5,.9],glowStrength:.08,night:.75,nvg:.55,dust:0},rules:[ue("drone",0,[110,160],3,!0),ue("turret",5,[280,380],2),ue("sam",15,[560,760],1),ue("flak",25,[440,600],1),ue("gunner",30,[380,520],1),ue("gate",45,[800,1100],1)],setPieces:[{at:.25,wave:"samTrap"},{at:.55,wave:"turretAlley"},{at:.8,wave:"gunnerPincer"}],boss:"radar",bossName:'RADAR COMPLEX "OVERWATCH"',depots:.9,bridges:.6},{id:"dawn",name:"DAWN STRIKE",subtitle:"Sunrise \xB7 everything they have",length:32200,canyon:{width:300,amp:1.05,narrow:1,height:1},light:{sun:[1.12,.92,.95],shadow:[.3,.26,.45],shadowLen:1.1,exposure:1.08,gradeLow:[.06,.04,.14],gradeHigh:[1.06,.98,1],glow:[1,.7,.75],glowStrength:.26,night:0,nvg:0,dust:0},rules:[ue("drone",0,[100,150],3,!0),ue("gunner",5,[340,460],2),ue("turret",10,[280,380],2),ue("tank",20,[440,600],1),ue("sam",30,[560,760],1),ue("flak",40,[460,620],1),ue("uav",15,[200,280],2),ue("gate",50,[800,1100],1)],setPieces:[{at:.2,wave:"gunnerPincer"},{at:.45,wave:"tankColumn"},{at:.7,wave:"samTrap"},{at:.9,wave:"droneV"}],boss:"sunhammer",bossName:'HEAVY GUNSHIP "SUNHAMMER"',depots:.9,bridges:.5}]});function es(i){let e=i.player;return[e.x+e.w/2,e.y+e.h/2]}function Or(i,e){let[t,r]=mr(e),[s,n]=es(i);return Math.atan2(n-r,s-t)}function It(i,e,t,r,s,n,o,a="test"){let l=n==="shell"?7:n==="bullet"?5:6;i.options.assist&&(s*=.85),i.enemyShots.push({id:i.nextId++,kind:n,x:e-l/2,y:t-l/2,w:l,h:l,px:e-l/2,py:t-l/2,vx:Math.cos(r)*s,vy:Math.sin(r)*s,life:n==="sam"||n==="rocket"?300:400,damage:o,grazed:!1,decoy:null,source:a}),i.emit({type:"enemyShot",x:e,y:t,kind:n})}function rs(i,e,t){let r=e-i;for(;r>Math.PI;)r-=Math.PI*2;for(;r<-Math.PI;)r+=Math.PI*2;return i+Jt(r,-t,t)}function Lr(i,e){let[t,r]=mr(e);i.emit({type:"telegraph",x:t,y:r,kind:e.kind})}function ng(i){let e={left:0,right:0};for(let t of i.hostiles){t.flash>0&&t.flash--,t.pulse=(t.pulse+.1)%(Math.PI*2);let r=xt[t.kind];if(t.group!==0&&t.kind!=="gunship"||(t.ground?t.y+=i.scrollSpeed+t.vy:t.kind!=="gunship"&&(t.x+=t.vx,t.y+=t.vy)),og[t.kind](i,t),t.group===0)if(i.corridorAt(t.y+t.h/2,e),t.kind==="turret"||t.kind==="gate"){let s=t.kind==="gate"?Zi:1;t.x=t.side<0?e.left+s:e.right-t.w-s}else{let s=e.left+rg,n=Math.max(s,e.right-t.w-rg);t.x<s?(t.x=s,r.bounces&&(t.vx=Math.abs(t.vx))):t.x>n&&(t.x=n,r.bounces&&(t.vx=-Math.abs(t.vx)))}}st(i.hostiles,t=>t.state!==iu)}function sg(i,e){let t=Or(i,e);switch(e.state){case 0:e.aim=rs(e.aim,t,.05),--e.timer<=0&&ts(e,0,440)&&(e.state=1,e.timer=O.telegraph.turretAim,Lr(i,e));break;case 1:e.timer>O.telegraph.turretLock&&(e.aim=rs(e.aim,t,.06)),e.charge=1-e.timer/O.telegraph.turretAim,--e.timer<=0&&(e.state=2,e.burst=4,e.timer=0,e.charge=0);break;case 2:if(--e.timer<=0){let[r,s]=mr(e);It(i,r+Math.cos(e.aim)*8,s+Math.sin(e.aim)*8,e.aim,O.shotSpeed.turret,"bullet",O.damage.turretShot,e.kind),e.timer=5,--e.burst<=0&&(e.state=0,e.timer=100+i.rng.int(40))}break}}function Ka(i){i.state=1,i.timer=70,i.charge=0,i.cycles++}var iu,rg,aC,Tn,ig,h3,mr,ts,og,ja=f(()=>{"use strict";di();Gr();At();fr();pi();iu=99,rg=4,aC=70,Tn=46,ig=30,h3=O.telegraph.samLock,mr=i=>[i.x+i.w/2,i.y+i.h/2];ts=(i,e=0,t=j-120)=>i.y+i.h>e&&i.y<t;og={drone(i,e){if(e.x+=Math.sin(i.tick*.05+e.id)*.6,e.state===0)--e.timer<=0&&ts(e,10,320)&&(e.state=1,e.timer=O.telegraph.scout,Lr(i,e));else if(e.state===1&&(e.charge=1-e.timer/O.telegraph.scout,--e.timer<=0)){let[t,r]=mr(e);It(i,t,r,Or(i,e),O.shotSpeed.drone,"bullet",O.damage.droneShot,e.kind),e.state=0,e.charge=0,e.timer=110+i.rng.int(90)}},uav(i,e){let[t]=es(i);e.y<i.player.y-110&&(e.vx=Jt(e.vx+Math.sign(t-(e.x+e.w/2))*O.uav.steer,-O.uav.maxVx,O.uav.maxVx))},mine(i,e){let[t,r]=mr(e),[s,n]=es(i);e.state===0?Math.hypot(s-t,n-r)<aC&&(e.state=1,e.timer=O.telegraph.mineFuse,e.vx*=.3,e.vy=.3,Lr(i,e)):e.state===1&&(e.charge=1-e.timer/O.telegraph.mineFuse,--e.timer<=0&&(i.emit({type:"airburst",x:t,y:r,r:Tn}),Math.hypot(s-t,n-r)<Tn+6&&i.damagePlayer(O.damage.mine,"mine"),e.state=iu))},gunner(i,e){let t=70+e.id%4*32;switch(e.state){case 0:e.y>=t&&(e.vy=0,e.state=1,e.timer=30);break;case 1:{let[r]=es(i);e.vx=Jt((r-(e.x+e.w/2))*.02,-.9,.9),e.aim=Or(i,e),--e.timer<=0&&(e.state=2,e.timer=O.telegraph.gunner,Lr(i,e));break}case 2:e.vx*=.9,e.timer>10&&(e.aim=Or(i,e)),e.charge=1-e.timer/O.telegraph.gunner,--e.timer<=0&&(e.state=3,e.burst=3,e.timer=0,e.charge=0);break;case 3:if(--e.timer<=0){let[r,s]=mr(e);It(i,r,s,e.aim,O.shotSpeed.gunner,"bullet",O.damage.gunnerShot,e.kind),e.timer=6,--e.burst<=0&&(e.cycles++,e.cycles>=3?(e.state=4,e.vy=2.6,e.vx=0):(e.state=1,e.timer=55))}break}},turret(i,e){sg(i,e)},depot(){},sluice(){},shieldgen(){},traincar(i,e){sg(i,e)},dam(i,e){if(e.shielded&&e.timer>300&&(e.timer=300),--e.timer<=0){let t=i.player,r=t.x+t.w/2,s=t.y+t.h/2,n=e.shielded?2:3;for(let o=0;o<n;o++){let a=Jt(r+(o-(n-1)/2)*70+t.steer*t.speed*12,0,800);i.hazards.push({id:i.nextId++,x:a,y:s-10+o*8,px:a,py:s-10+o*8,r:ig,timer:O.telegraph.flakFuse,maxTimer:O.telegraph.flakFuse}),i.emit({type:"flakMark",x:a,y:s})}e.timer=e.shielded?230:170}},engine(i,e){og.tank(i,e)},dish(i,e){e.aim+=.03,--e.timer<=0&&(Dr(i,"drone"),Dr(i,"drone"),e.timer=e.shielded?320:220,Lr(i,e))},flak(i,e){if(e.aim=rs(e.aim,Or(i,e),.05),--e.timer<=0&&ts(e,0,400)){let t=i.player,[r,s]=es(i),n=Jt(r+t.steer*t.speed*14,0,800);i.hazards.push({id:i.nextId++,x:n,y:s,px:n,py:s,r:ig,timer:O.telegraph.flakFuse,maxTimer:O.telegraph.flakFuse}),i.emit({type:"flakMark",x:n,y:s}),e.timer=120+i.rng.int(50)}},sam(i,e){switch(e.state){case 0:--e.timer<=0&&ts(e,30,340)&&(e.state=1,e.timer=O.telegraph.samLock,e.charge=0,i.emit({type:"lockStart"}),Lr(i,e));break;case 1:if(e.charge=1-e.timer/O.telegraph.samLock,e.aim=Or(i,e),!ts(e,0,430)){e.state=0,e.timer=9999,e.charge=0,i.emit({type:"lockEnd"});break}if(--e.timer<=0){let[t,r]=mr(e);It(i,t,r,e.aim,O.shotSpeed.sam,"sam",O.damage.sam,e.kind),i.emit({type:"samLaunch",x:t,y:r}),i.emit({type:"lockEnd"}),e.state=2,e.timer=260,e.charge=0}break;case 2:--e.timer<=0&&(e.state=0);break}},tank(i,e){if(e.aim=rs(e.aim,Or(i,e),.035),e.state===0)--e.timer<=0&&ts(e,0,420)&&(e.state=1,e.timer=O.telegraph.tank,Lr(i,e));else if(e.charge=1-e.timer/O.telegraph.tank,--e.timer<=0){let[t,r]=mr(e);It(i,t+Math.cos(e.aim)*12,r+Math.sin(e.aim)*12,e.aim,O.shotSpeed.tank,"shell",O.damage.tankShell,e.kind),e.state=0,e.charge=0,e.timer=140+i.rng.int(70)}},gunship(i,e){let[t]=es(i);if(e.state===0){e.y+=1.6,e.y>=60&&(e.state=1,e.timer=60);return}if(e.state===5){e.y-=2.2,e.y<-60&&(e.state=iu);return}let r=e.variant===1,s=e.variant===2,n=s&&e.hp<e.maxHp/2,o=t+(r?e.side*90:0)+Math.sin(i.tick*.021+e.side)*70-e.w/2,a=r?3:n?2.6:2;e.vx=Jt((o-e.x)*.03,-a,a),e.x+=e.vx,e.y=60+Math.sin(i.tick*.03)*14,e.aim=Or(i,e);let[l,c]=mr(e);switch(e.state){case 1:if(--e.timer<=0){if(!s&&e.cycles>=(r?10:12)){e.state=5;break}e.state=n&&e.cycles%4===3?6:2+e.cycles%3;let h=r?.75:1;e.timer=Math.round((e.state===2?50:e.state===3?32:e.state===6?56:42)*h),e.burst2=e.timer,e.burst=e.state===3?6:0,Lr(i,e)}break;case 2:if(e.charge=1-e.timer/e.burst2,--e.timer<=0){let h=s?4:3;for(let u=-h;u<=h;u++)It(i,l,c+10,e.aim+u*.2,O.shotSpeed.gunshipFan,"bullet",O.damage.gunshipBullet,e.kind);Ka(e)}break;case 3:if(e.timer>0){e.charge=1-e.timer/e.burst2,e.timer--;break}i.tick%5===0&&(It(i,l,c+10,e.aim,O.shotSpeed.gunshipBurst,"bullet",O.damage.gunshipBullet,e.kind),--e.burst<=0&&Ka(e));break;case 4:e.charge=1-e.timer/e.burst2,--e.timer<=0&&(It(i,l-12,c+4,e.aim-.5,O.shotSpeed.rocket,"rocket",O.damage.gunshipRocket,e.kind),It(i,l+12,c+4,e.aim+.5,O.shotSpeed.rocket,"rocket",O.damage.gunshipRocket,e.kind),s&&(It(i,l-20,c,e.aim-.9,O.shotSpeed.rocket,"rocket",O.damage.gunshipRocket,e.kind),It(i,l+20,c,e.aim+.9,O.shotSpeed.rocket,"rocket",O.damage.gunshipRocket,e.kind)),Ka(e));break;case 6:if(e.charge=1-e.timer/e.burst2,--e.timer<=0){for(let h=0;h<18;h++){let u=e.aim+h/18*Math.PI*2;Math.abs(Math.sin((u-e.aim)/2))<.18||It(i,l,c,u,2.4,"bullet",O.damage.gunshipBullet,e.kind)}Ka(e)}break}},gate(){}}});var bg,xr,cl,ou=f(()=>{"use strict";Gr();At();Qi();bg=1400,xr={x:12,y:-10},cl=class{particles=[];popups=[];motes=[];camera={trauma:0,leadX:0,kickY:0,zoomOut:0,t:0};hitStop=0;hurt=0;shakeScale=1;reducedMotion=!1;free=[];constructor(){let e=Math.floor(be*j/12e3);for(let t=0;t<e;t++)this.motes.push({x:Math.random()*be,y:Math.random()*j,size:Math.random()*1.4+.5,speed:Math.random()*.6+.2,drift:Math.random()*.3+.05,alpha:Math.random()*.35+.1,phase:Math.random()*Math.PI*2})}get shake(){return this.camera.trauma*this.camera.trauma*14}reset(){this.free.push(...this.particles),this.particles.length=0,this.popups.length=0,this.camera.trauma=0,this.camera.kickY=0,this.hitStop=0,this.hurt=0}addTrauma(e){this.reducedMotion||(this.camera.trauma=Math.min(1,this.camera.trauma+e*this.shakeScale))}spawn(e,t,r,s,n,o,a,l={}){if(this.particles.length>=(this.reducedMotion?bg/2:bg))return null;let c=this.free.pop()??{};return c.kind=e,c.x=t,c.y=r,c.vx=s,c.vy=n,c.life=o,c.maxLife=o,c.size=a,c.grow=l.grow??0,c.rot=l.rot??Math.random()*Math.PI*2,c.vrot=l.vrot??0,c.alpha=l.alpha??1,c.drag=l.drag??1,c.ground=l.ground??!1,c.seed=Math.random(),c.delay=l.delay??0,this.particles.push(c),c}popup(e,t,r,s=16761707,n=1,o=50){this.popups.length>40&&this.popups.shift(),this.popups.push({x:e,y:t,text:r,life:o,maxLife:o,color:s,size:n})}explosion(e,t,r,s=!1){let n=o=>Math.round(o*r);this.spawn("flash",e,t,0,0,7,24*r,{alpha:s?.7:1}),this.spawn("ring",e,t,0,0,20,6,{grow:3.2*r,alpha:.8});for(let o=0;o<n(10);o++){let a=Math.random()*Math.PI*2,l=Math.random()*2.2*r;this.spawn("fire",e+Math.cos(a)*3,t+Math.sin(a)*3,Math.cos(a)*l,Math.sin(a)*l,16+Math.random()*16,(5+Math.random()*6)*r,{grow:.35,drag:.9,delay:Math.floor(Math.random()*4)})}for(let o=0;o<n(14);o++){let a=Math.random()*Math.PI*2,l=3+Math.random()*4*r;this.spawn("spark",e,t,Math.cos(a)*l,Math.sin(a)*l,12+Math.random()*14,1,{drag:.9})}for(let o=0;o<n(8);o++){let a=Math.random()*Math.PI*2,l=Math.random()*1.2;this.spawn("smoke",e+(Math.random()-.5)*10*r,t+(Math.random()-.5)*10*r,Math.cos(a)*l+.2,Math.sin(a)*l-.15,70+Math.random()*60,(6+Math.random()*6)*r,{grow:.22,drag:.97,ground:!0,alpha:s?.7:.55,delay:4+Math.floor(Math.random()*8),vrot:(Math.random()-.5)*.02})}for(let o=0;o<n(6);o++){let a=Math.random()*Math.PI*2,l=1+Math.random()*2.5;this.spawn("debris",e,t,Math.cos(a)*l,Math.sin(a)*l,160+Math.random()*120,1.5+Math.random()*2,{drag:.9,ground:!0,vrot:(Math.random()-.5)*.4})}for(let o=0;o<n(5);o++){let a=Math.random()*Math.PI*2,l=.5+Math.random()*1.5;this.spawn("ember",e,t,Math.cos(a)*l,Math.sin(a)*l,40+Math.random()*40,1.5,{drag:.96})}this.spawn("scorch",e,t,0,0,900,12+8*r,{ground:!0,alpha:.38})}handle(e,t){switch(e.type){case"explode":{let r=e.big?1.5:e.damage?1.1:1;this.explosion(e.x,e.y,r,e.damage),this.addTrauma(e.shake/22),e.big&&!this.reducedMotion&&(this.hitStop=Math.max(this.hitStop,3));break}case"hit":this.spawn("flash",e.x,e.y,0,0,4,12,{alpha:.8});for(let r=0;r<4;r++){let s=Math.random()*Math.PI*2,n=2+Math.random()*3;this.spawn("spark",e.x,e.y,Math.cos(s)*n,Math.sin(s)*n-1,8+Math.random()*6,1,{drag:.88})}break;case"pickup":this.spawn("ring",e.x,e.y,0,0,22,4,{grow:2.2,alpha:.9}),this.spawn("flash",e.x,e.y,0,0,8,26,{alpha:.8});for(let r=0;r<12;r++){let s=r/12*Math.PI*2;this.spawn("ember",e.x,e.y,Math.cos(s)*1.8,Math.sin(s)*1.8,26,1.8,{drag:.93})}break;case"scrape":for(let r=0;r<4;r++)this.spawn("spark",e.x,e.y,(Math.random()-.5)*4,1+Math.random()*3,8+Math.random()*8,1,{drag:.9});this.spawn("dust",e.x,e.y,0,.5,30,6,{grow:.3,ground:!0,alpha:.4}),this.addTrauma(.05);break;case"missile":for(let r=0;r<5;r++)this.spawn("smoke",e.x+(Math.random()-.5)*6,e.y+6,(Math.random()-.5)*.8,.6+Math.random(),40,4,{grow:.25,ground:!0,alpha:.45});this.spawn("flash",e.x,e.y,0,0,5,18,{alpha:.9}),this.reducedMotion||(this.camera.kickY=3),this.addTrauma(.12);break;case"playerHit":this.hurt=1;break;case"enemyShot":this.spawn("flash",e.x,e.y,0,0,4,e.kind==="shell"?14:9,{alpha:.7});break;case"telegraph":this.spawn("flash",e.x,e.y,0,0,10,10,{alpha:.6});break;case"samLaunch":for(let r=0;r<8;r++)this.spawn("smoke",e.x+(Math.random()-.5)*10,e.y+(Math.random()-.5)*10,(Math.random()-.5)*1.5,(Math.random()-.5)*1.5,60,5,{grow:.25,ground:!0,alpha:.55});this.spawn("flash",e.x,e.y,0,0,6,20);break;case"airburst":this.spawn("flash",e.x,e.y,0,0,8,e.r*1.2,{alpha:.9}),this.spawn("ring",e.x,e.y,0,0,16,e.r*.4,{grow:e.r*.06,alpha:.9});for(let r=0;r<12;r++){let s=Math.random()*Math.PI*2,n=2+Math.random()*3;this.spawn("spark",e.x,e.y,Math.cos(s)*n,Math.sin(s)*n,14,1,{drag:.9})}for(let r=0;r<4;r++)this.spawn("smoke",e.x+(Math.random()-.5)*e.r,e.y+(Math.random()-.5)*e.r,.2,-.1,70,6,{grow:.2,alpha:.5,delay:3});this.addTrauma(.2);break;case"flare":this.spawn("flash",e.x,e.y,0,0,8,26,{alpha:.9});break;case"decoyed":this.popup(e.x,e.y-8,"DECOYED",10479871,.9);break;case"paint":this.spawn("ring",e.x,e.y,0,0,12,14,{grow:-.6,alpha:.9});break;case"overheat":{let r=t.player;for(let s=0;s<8;s++)this.spawn("smoke",r.x+r.w/2+(Math.random()-.5)*8,r.y,(Math.random()-.5)*1.2,-.4-Math.random(),40,3,{grow:.2,alpha:.45});this.popup(r.x+r.w/2,r.y-20,"OVERHEAT",16738890,1);break}case"coolPerfect":this.spawn("shock",e.x,e.y,0,0,14,4,{grow:1.4,alpha:.7}),this.popup(e.x,e.y-10,"COOLED",10479871,.8,34);break;case"block":for(let r=0;r<3;r++)this.spawn("spark",e.x,e.y,(Math.random()-.5)*4,1+Math.random()*2,10,1,{drag:.88});this.spawn("flash",e.x,e.y,0,0,4,8,{alpha:.7});break;case"emp":this.spawn("shock",e.x,e.y,0,0,40,10,{grow:22,alpha:1}),this.spawn("shock",e.x,e.y,0,0,30,6,{grow:14,alpha:.7,delay:4}),this.spawn("flash",e.x,e.y,0,0,10,120,{alpha:.8}),this.addTrauma(.5),this.popup(e.x,e.y-30,"EMP",10479871,1.6,60);break;case"score":this.popup(e.x,e.y,e.label?`${e.label} +${e.amount}`:`+${e.amount}`,e.label?16771512:16761707,e.amount>=1e3?1.5:.8);break;case"combo":{let r=t.player;this.popup(r.x+r.w/2,r.y-38,`\xD7${e.mult.toFixed(1)} CHAIN`,16769136,1.3,70);break}case"comboBreak":{let r=t.player;this.popup(r.x+r.w/2,r.y-38,"CHAIN LOST",16738890,1,50);break}case"bossEnter":this.addTrauma(.35);break;case"lifeLost":{let r=t.player;this.explosion(r.x+r.w/2,r.y+r.h/2,2,!0),this.addTrauma(.9),this.reducedMotion||(this.hitStop=Math.max(this.hitStop,10)),this.hurt=1;break}}}tick(e,t){let r=this.camera;r.t+=1,r.trauma=Math.max(0,r.trauma-.022),r.kickY*=.8,this.hurt=Math.max(0,this.hurt-.04);let s=e?e.scrollSpeed:2.5;if(e){let n=e.player;r.leadX+=((n.x+n.w/2-be/2)*.14-r.leadX)*.05,r.zoomOut+=((this.reducedMotion?0:(e.scrollSpeed-2.5)*.03)-r.zoomOut)*.02}for(let n of this.motes)n.y+=n.speed*(s/2.5)+.2,n.x+=n.drift,n.phase+=.03,(n.y>j+20||n.x>be+200)&&(n.y=-20,n.x=Math.random()*(be+400)-200);e&&t&&this.ambient(e),st(this.popups,n=>(n.y-=.5,--n.life>0)),st(this.particles,n=>n.delay>0?(n.delay--,n.ground&&(n.y+=s),!0):(n.x+=n.vx,n.y+=n.vy,n.ground&&(n.y+=s),n.vx*=n.drag,n.vy*=n.drag,n.size+=n.grow,n.rot+=n.vrot,n.life--,n.life>0&&n.y<j+80?!0:(this.free.push(n),!1)))}ambient(e){let t=e.player,r=t.x+t.w/2,s=t.y+t.h/2,n=Math.random()*Math.PI*2,o=10+Math.random()*8;this.spawn("dust",r+xr.x+Math.cos(n)*o,s+xr.y+Math.sin(n)*o,Math.cos(n)*.9,Math.sin(n)*.9,26+Math.random()*14,3+Math.random()*3,{grow:.18,ground:!0,alpha:.22,drag:.96});for(let l of e.playerMissiles)this.spawn("smoke",l.x+l.w/2+(Math.random()-.5)*2,l.y+l.h,(Math.random()-.5)*.3,.2,38+Math.random()*20,2.5,{grow:.16,ground:!0,alpha:.4,drag:.98});e.shields<35&&e.tick%3===0&&(this.spawn("smoke",r+(Math.random()-.5)*6,s+4,(Math.random()-.5)*.4,.6,40,3,{grow:.2,ground:!0,alpha:.55}),Math.random()<.3&&this.spawn("ember",r,s,(Math.random()-.5)*1.5,.5+Math.random(),20,1.4,{drag:.95}));for(let l of e.enemyShots)l.kind!=="sam"&&l.kind!=="rocket"||this.spawn("smoke",l.x+l.w/2-l.vx*2,l.y+l.h/2-l.vy*2,(Math.random()-.5)*.3,0,40,2.5,{grow:.15,ground:!0,alpha:.45});for(let l of e.flareObjs)this.spawn("smoke",l.x,l.y,(Math.random()-.5)*.3,0,30,2,{grow:.14,ground:!0,alpha:.4}),Math.random()<.5&&this.spawn("ember",l.x,l.y,(Math.random()-.5)*1.5,(Math.random()-.5)*1.5,12,1.2,{drag:.9});let a=Ke[e.course.sector].light.dust;for(let l=0;l<a*3;l++)Math.random()<a&&this.spawn("streak",-40+Math.random()*200,Math.random()*j,9+Math.random()*6,2+Math.random()*2,70,1,{alpha:.25+Math.random()*.2});if(t.boosting){for(let l=0;l<2;l++)this.spawn("streak",Math.random()*be,-10,0,18+Math.random()*8,40,1,{alpha:.35});Math.random()<.6&&this.spawn("dust",r+xr.x+(Math.random()-.5)*30,s+xr.y+10,(Math.random()-.5)*2,2,24,4,{grow:.25,ground:!0,alpha:.25})}for(let l of e.hostiles)l.kind!=="gate"&&l.hp<l.maxHp&&Math.random()<.25&&this.spawn("smoke",l.x+l.w/2,l.y+l.h/2,(Math.random()-.5)*.3,.3,36,2.5,{grow:.18,ground:!0,alpha:.45})}}});var b,hu,gl,H,P=f(()=>{"use strict";b=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGLLoader="webgl-loader",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.WebGPULoader="webgpu-loader",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.CanvasLoader="canvas-loader",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.TextureUploaderWebGL="texture-uploader-webgl",i.TextureUploaderWebGPU="texture-uploader-webgpu",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(b||{}),hu=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},gl=(i,e)=>hu(i).priority??e,H={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(hu).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...i){return i.map(hu).forEach(e=>{e.type.forEach(t=>{let r=this._addHandlers,s=this._queue;r[t]?r[t]?.(e):(s[t]=s[t]||[],s[t]?.push(e))})}),this},handle(i,e,t){let r=this._addHandlers,s=this._removeHandlers;if(r[i]||s[i])throw new Error(`Extension type ${i} already has a handler`);r[i]=e,s[i]=t;let n=this._queue;return n[i]&&(n[i]?.forEach(o=>e(o)),delete n[i]),this},handleByMap(i,e){return this.handle(i,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(i,e,t=-1){return this.handle(i,r=>{e.findIndex(n=>n.name===r.name)>=0||(e.push({name:r.name,value:r.ref}),e.sort((n,o)=>gl(o.value,t)-gl(n.value,t)))},r=>{let s=e.findIndex(n=>n.name===r.name);s!==-1&&e.splice(s,1)})},handleByList(i,e,t=-1){return this.handle(i,r=>{e.includes(r.ref)||(e.push(r.ref),e.sort((s,n)=>gl(n,t)-gl(s,t)))},r=>{let s=e.indexOf(r.ref);s!==-1&&e.splice(s,1)})},mixin(i,...e){for(let t of e)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(t))}}});var Gg=BM((jB,uu)=>{"use strict";var GC=Object.prototype.hasOwnProperty,at="~";function Pn(){}Object.create&&(Pn.prototype=Object.create(null),new Pn().__proto__||(at=!1));function FC(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function Ig(i,e,t,r,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var n=new FC(t,r||i,s),o=at?at+e:e;return i._events[o]?i._events[o].fn?i._events[o]=[i._events[o],n]:i._events[o].push(n):(i._events[o]=n,i._eventsCount++),i}function xl(i,e){--i._eventsCount===0?i._events=new Pn:delete i._events[e]}function nt(){this._events=new Pn,this._eventsCount=0}nt.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)GC.call(t,r)&&e.push(at?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};nt.prototype.listeners=function(e){var t=at?at+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,n=r.length,o=new Array(n);s<n;s++)o[s]=r[s].fn;return o};nt.prototype.listenerCount=function(e){var t=at?at+e:e,r=this._events[t];return r?r.fn?1:r.length:0};nt.prototype.emit=function(e,t,r,s,n,o){var a=at?at+e:e;if(!this._events[a])return!1;var l=this._events[a],c=arguments.length,h,u;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,s),!0;case 5:return l.fn.call(l.context,t,r,s,n),!0;case 6:return l.fn.call(l.context,t,r,s,n,o),!0}for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];l.fn.apply(l.context,h)}else{var d=l.length,p;for(u=0;u<d;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,s);break;default:if(!h)for(p=1,h=new Array(c-1);p<c;p++)h[p-1]=arguments[p];l[u].fn.apply(l[u].context,h)}}return!0};nt.prototype.on=function(e,t,r){return Ig(this,e,t,r,!1)};nt.prototype.once=function(e,t,r){return Ig(this,e,t,r,!0)};nt.prototype.removeListener=function(e,t,r,s){var n=at?at+e:e;if(!this._events[n])return this;if(!t)return xl(this,n),this;var o=this._events[n];if(o.fn)o.fn===t&&(!s||o.once)&&(!r||o.context===r)&&xl(this,n);else{for(var a=0,l=[],c=o.length;a<c;a++)(o[a].fn!==t||s&&!o[a].once||r&&o[a].context!==r)&&l.push(o[a]);l.length?this._events[n]=l.length===1?l[0]:l:xl(this,n)}return this};nt.prototype.removeAllListeners=function(e){var t;return e?(t=at?at+e:e,this._events[t]&&xl(this,t)):(this._events=new Pn,this._eventsCount=0),this};nt.prototype.off=nt.prototype.removeListener;nt.prototype.addListener=nt.prototype.on;nt.prefixed=at;nt.EventEmitter=nt;typeof uu<"u"&&(uu.exports=nt)});var Fg,le,Oe=f(()=>{Fg=GM(Gg(),1),le=Fg.default});var DC,yr,je,Gt,Wg,Dg,du,OC,yl,Vg,$g,Og,Lg,Ug,kn,LC,UC,NC,HC,mu,Ng,zC,pu,fu,Hg,gu,zt,zg,Xg,Yg=f(()=>{DC={grad:.9,turn:360,rad:360/(2*Math.PI)},yr=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},je=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*i)/t+0},Gt=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),i>t?t:i>e?i:e},Wg=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Dg=function(i){return{r:Gt(i.r,0,255),g:Gt(i.g,0,255),b:Gt(i.b,0,255),a:Gt(i.a)}},du=function(i){return{r:je(i.r),g:je(i.g),b:je(i.b),a:je(i.a,3)}},OC=/^#([0-9a-f]{3,8})$/i,yl=function(i){var e=i.toString(16);return e.length<2?"0"+e:e},Vg=function(i){var e=i.r,t=i.g,r=i.b,s=i.a,n=Math.max(e,t,r),o=n-Math.min(e,t,r),a=o?n===e?(t-r)/o:n===t?2+(r-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},$g=function(i){var e=i.h,t=i.s,r=i.v,s=i.a;e=e/360*6,t/=100,r/=100;var n=Math.floor(e),o=r*(1-t),a=r*(1-(e-n)*t),l=r*(1-(1-e+n)*t),c=n%6;return{r:255*[r,a,o,o,l,r][c],g:255*[l,r,r,a,o,o][c],b:255*[o,o,l,r,r,a][c],a:s}},Og=function(i){return{h:Wg(i.h),s:Gt(i.s,0,100),l:Gt(i.l,0,100),a:Gt(i.a)}},Lg=function(i){return{h:je(i.h),s:je(i.s),l:je(i.l),a:je(i.a,3)}},Ug=function(i){return $g((t=(e=i).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},kn=function(i){return{h:(e=Vg(i)).h,s:(s=(200-(t=e.s))*(r=e.v)/100)>0&&s<200?t*r/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,r,s},LC=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,UC=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,NC=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,HC=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mu={string:[[function(i){var e=OC.exec(i);return e?(i=e[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?je(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?je(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var e=NC.exec(i)||HC.exec(i);return e?e[2]!==e[4]||e[4]!==e[6]?null:Dg({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(i){var e=LC.exec(i)||UC.exec(i);if(!e)return null;var t,r,s=Og({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(DC[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Ug(s)},"hsl"]],object:[[function(i){var e=i.r,t=i.g,r=i.b,s=i.a,n=s===void 0?1:s;return yr(e)&&yr(t)&&yr(r)?Dg({r:Number(e),g:Number(t),b:Number(r),a:Number(n)}):null},"rgb"],[function(i){var e=i.h,t=i.s,r=i.l,s=i.a,n=s===void 0?1:s;if(!yr(e)||!yr(t)||!yr(r))return null;var o=Og({h:Number(e),s:Number(t),l:Number(r),a:Number(n)});return Ug(o)},"hsl"],[function(i){var e=i.h,t=i.s,r=i.v,s=i.a,n=s===void 0?1:s;if(!yr(e)||!yr(t)||!yr(r))return null;var o=(function(a){return{h:Wg(a.h),s:Gt(a.s,0,100),v:Gt(a.v,0,100),a:Gt(a.a)}})({h:Number(e),s:Number(t),v:Number(r),a:Number(n)});return $g(o)},"hsv"]]},Ng=function(i,e){for(var t=0;t<e.length;t++){var r=e[t][0](i);if(r)return[r,e[t][1]]}return[null,void 0]},zC=function(i){return typeof i=="string"?Ng(i.trim(),mu.string):typeof i=="object"&&i!==null?Ng(i,mu.object):[null,void 0]},pu=function(i,e){var t=kn(i);return{h:t.h,s:Gt(t.s+100*e,0,100),l:t.l,a:t.a}},fu=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Hg=function(i,e){var t=kn(i);return{h:t.h,s:t.s,l:Gt(t.l+100*e,0,100),a:t.a}},gu=(function(){function i(e){this.parsed=zC(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return je(fu(this.rgba),2)},i.prototype.isDark=function(){return fu(this.rgba)<.5},i.prototype.isLight=function(){return fu(this.rgba)>=.5},i.prototype.toHex=function(){return e=du(this.rgba),t=e.r,r=e.g,s=e.b,o=(n=e.a)<1?yl(je(255*n)):"","#"+yl(t)+yl(r)+yl(s)+o;var e,t,r,s,n,o},i.prototype.toRgb=function(){return du(this.rgba)},i.prototype.toRgbString=function(){return e=du(this.rgba),t=e.r,r=e.g,s=e.b,(n=e.a)<1?"rgba("+t+", "+r+", "+s+", "+n+")":"rgb("+t+", "+r+", "+s+")";var e,t,r,s,n},i.prototype.toHsl=function(){return Lg(kn(this.rgba))},i.prototype.toHslString=function(){return e=Lg(kn(this.rgba)),t=e.h,r=e.s,s=e.l,(n=e.a)<1?"hsla("+t+", "+r+"%, "+s+"%, "+n+")":"hsl("+t+", "+r+"%, "+s+"%)";var e,t,r,s,n},i.prototype.toHsv=function(){return e=Vg(this.rgba),{h:je(e.h),s:je(e.s),v:je(e.v),a:je(e.a,3)};var e},i.prototype.invert=function(){return zt({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},i.prototype.saturate=function(e){return e===void 0&&(e=.1),zt(pu(this.rgba,e))},i.prototype.desaturate=function(e){return e===void 0&&(e=.1),zt(pu(this.rgba,-e))},i.prototype.grayscale=function(){return zt(pu(this.rgba,-1))},i.prototype.lighten=function(e){return e===void 0&&(e=.1),zt(Hg(this.rgba,e))},i.prototype.darken=function(e){return e===void 0&&(e=.1),zt(Hg(this.rgba,-e))},i.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},i.prototype.alpha=function(e){return typeof e=="number"?zt({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):je(this.rgba.a,3);var t},i.prototype.hue=function(e){var t=kn(this.rgba);return typeof e=="number"?zt({h:e,s:t.s,l:t.l,a:t.a}):je(t.h)},i.prototype.isEqual=function(e){return this.toHex()===zt(e).toHex()},i})(),zt=function(i){return i instanceof gu?i:new gu(i)},zg=[],Xg=function(i){i.forEach(function(e){zg.indexOf(e)<0&&(e(gu,mu),zg.push(e))})}});function Kg(i,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var s in t)r[t[s]]=s;var n={};i.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,c=r[this.toHex()];if(c)return c;if(o?.closest){var h=this.toRgb(),u=1/0,d="black";if(!n.length)for(var p in t)n[p]=new i(t[p]).toRgb();for(var m in t){var x=(a=h,l=n[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));x<u&&(u=x,d=m)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new i(l).toRgb():null},"name"])}var jg=f(()=>{});var os,q,Je=f(()=>{Yg();jg();Xg([Kg]);os=class An{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof An)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){let r=typeof e;if(r!==typeof t)return!1;if(r==="number"||r==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,o)=>n===t[o]);if(e!==null&&t!==null){let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?!1:n.every(a=>e[a]===t[a])}return e===t}toRgba(){let[e,t,r,s]=this._components;return{r:e,g:t,b:r,a:s}}toRgb(){let[e,t,r]=this._components;return{r:e,g:t,b:r}}toRgbaString(){let[e,t,r]=this.toUint8RgbArray();return`rgba(${e},${t},${r},${this.alpha})`}toUint8RgbArray(e){let[t,r,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(r*255),e[2]=Math.round(s*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);let[t,r,s,n]=this._components;return e[0]=t,e[1]=r,e[2]=s,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);let[t,r,s]=this._components;return e[0]=t,e[1]=r,e[2]=s,e}toNumber(){return this._int}toBgrNumber(){let[e,t,r]=this.toUint8RgbArray();return(r<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){let[t,r,s,n]=An._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=r,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let r=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return t&&(r=r*e+.5|0,s=s*e+.5|0,n=n*e+.5|0),(e*255<<24)+(r<<16)+(s<<8)+n}toHex(){let e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){let t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let t,r,s,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){let o=e;t=(o>>16&255)/255,r=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,r,s,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,r,s,n=255]=e,t/=255,r/=255,s/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){let a=An.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}let o=zt(e);o.isValid()&&({r:t,g:r,b:s,a:n}=o.rgba,t/=255,r/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=r,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);let[e,t,r]=this._components;this._int=(e*255<<16)+(t*255<<8)+(r*255|0)}_clamp(e,t=0,r=1){return typeof e=="number"?Math.min(Math.max(e,t),r):(e.forEach((s,n)=>{e[n]=Math.min(Math.max(s,t),r)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof An||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};os.shared=new os;os._temp=new os;os.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;q=os});var qg,Zg=f(()=>{"use strict";qg={cullArea:null,cullable:!1,cullableChildren:!0}});var Qg,Jg,ex,xu=f(()=>{"use strict";Qg=Math.PI*2,Jg=180/Math.PI,ex=Math.PI/180});var ne,yu,Wt=f(()=>{"use strict";ne=class i{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new i(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return yu.x=0,yu.y=0,yu}},yu=new ne});var I,WC,VC,oe=f(()=>{xu();Wt();I=class i{constructor(e=1,t=0,r=0,s=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=r,this.d=s,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,r,s,n,o){return this.a=e,this.b=t,this.c=r,this.d=s,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));let r=t||this.array;return e?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(e,t){t=t||new ne;let r=e.x,s=e.y;return t.x=this.a*r+this.c*s+this.tx,t.y=this.b*r+this.d*s+this.ty,t}applyInverse(e,t){t=t||new ne;let r=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,c=1/(r*o+n*-s),h=e.x,u=e.y;return t.x=o*c*h+-n*c*u+(l*n-a*o)*c,t.y=r*c*u+-s*c*h+(-l*r+a*s)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),r=Math.sin(e),s=this.a,n=this.c,o=this.tx;return this.a=s*t-this.b*r,this.b=s*r+this.b*t,this.c=n*t-this.d*r,this.d=n*r+this.d*t,this.tx=o*t-this.ty*r,this.ty=o*r+this.ty*t,this}append(e){let t=this.a,r=this.b,s=this.c,n=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*r+e.b*n,this.c=e.c*t+e.d*s,this.d=e.c*r+e.d*n,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*r+e.ty*n+this.ty,this}appendFrom(e,t){let r=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,c=t.a,h=t.b,u=t.c,d=t.d;return this.a=r*c+s*u,this.b=r*h+s*d,this.c=n*c+o*u,this.d=n*h+o*d,this.tx=a*c+l*u+t.tx,this.ty=a*h+l*d+t.ty,this}setTransform(e,t,r,s,n,o,a,l,c){return this.a=Math.cos(a+c)*n,this.b=Math.sin(a+c)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(r*this.a+s*this.c),this.ty=t-(r*this.b+s*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let r=this.a,s=this.c;this.a=r*e.a+this.b*e.c,this.b=r*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,r=this.b,s=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-s,n),l=Math.atan2(r,t),c=Math.abs(a+l),h=Math.sqrt(t*t+r*r);return c<1e-5||Math.abs(Qg-c)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):Math.abs(Math.PI-c)<1e-5?(e.rotation=l-Math.PI,e.skew.x=e.skew.y=0,h=-h):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=h,e.scale.y=Math.sqrt(s*s+n*n),e.position.x=this.tx+(o.x*t+o.y*s),e.position.y=this.ty+(o.x*r+o.y*n),e}invert(){let e=this.a,t=this.b,r=this.c,s=this.d,n=this.tx,o=e*s-t*r;return this.a=s/o,this.b=-t/o,this.c=-r/o,this.d=e/o,this.tx=(r*this.ty-s*n)/o,this.ty=-(e*this.ty-t*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let e=new i;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return VC.identity()}static get shared(){return WC.identity()}},WC=new I,VC=new I});var Le,bl=f(()=>{"use strict";Le=class i{constructor(e,t,r){this._x=t||0,this._y=r||0,this._observer=e}clone(e){return new i(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}});function K(i="default"){return bu[i]===void 0&&(bu[i]=-1),++bu[i]}var bu,Ue=f(()=>{"use strict";bu={default:-1}});var tx,$,_u,_t,vu,as,B,de=f(()=>{"use strict";tx=new Set,$="8.0.0",_u="8.3.4",_t="8.21.0",vu="8.22.0",as={quiet:!1,noColor:!1},B=((i,e,t=3)=>{if(as.quiet||tx.has(e))return;let r=new Error().stack,s=`${e}
Deprecated since v${i}`,n=typeof console.groupCollapsed=="function"&&!as.noColor;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",s):(r=r.split(`
`).splice(t).join(`
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(r))),tx.add(e)});Object.defineProperties(B,{quiet:{get:()=>as.quiet,set:i=>{as.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>as.noColor,set:i=>{as.noColor=i},enumerable:!0,configurable:!1}})});function G(...i){Su!==rx&&(Su++,Su===rx?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}var Su,rx,ie=f(()=>{"use strict";Su=0,rx=500});var Ft,xi=f(()=>{"use strict";Ft={_registeredResources:new Set,register(i){this._registeredResources.add(i)},unregister(i){this._registeredResources.delete(i)},release(){this._registeredResources.forEach(i=>i.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(i){return this._registeredResources.has(i)},reset(){this._registeredResources.clear()}}});var _l,ix=f(()=>{"use strict";_l=class{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}});var Tu,Te,br=f(()=>{xi();ix();Tu=class{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new _l(e)),this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach(t=>{let r=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[r]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}},Te=new Tu;Ft.register(Te)});var sx,nx=f(()=>{de();sx={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){B("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}}});function vl(i,e,t){let r=i.length,s;if(e>=r||t===0)return;t=e+t>r?r-e:t;let n=r-t;for(s=e;s<n;++s)i[s]=i[s+t];i.length=n}var wu=f(()=>{"use strict"});var ox,ax=f(()=>{wu();de();ox={allowChildren:!0,removeChildren(i=0,e){let t=e??this.children.length,r=t-i,s=[];if(r>0&&r<=t){for(let o=t-1;o>=i;o--){let a=this.children[o];a&&(s.push(a),a.parent=null)}vl(this.children,i,t);let n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(s);for(let o=0;o<s.length;++o){let a=s[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),s[o].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(r===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){let e=this.getChildAt(i);return this.removeChild(e)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,e)},getChildIndex(i){let e=this.children.indexOf(i);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(i,e){this.allowChildren||B($,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:t}=this;if(e<0||e>t.length)throw new Error(`${i}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);let r=i.parent===this;if(i.parent){let n=i.parent.children.indexOf(i);if(r){if(n===e)return i;i.parent.children.splice(n,1)}else i.removeFromParent()}e===t.length?t.push(i):t.splice(e,0,i);let s=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),r?(s&&(s.structureDidChange=!0),i):(i.parent=this,i.didChange=!0,i._updateFlags=15,s&&s.addChild(i),this.emit("childAdded",i,this,e),i.emit("added",this),i)},swapChildren(i,e){if(i===e)return;let t=this.getChildIndex(i),r=this.getChildIndex(e);this.children[t]=e,this.children[r]=i;let s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(e=>this.reparentChildAt(e,this.children.length)),i[0])},reparentChildAt(i,e){if(i.parent===this)return this.setChildIndex(i,e),i;let t=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,e);let r=this.worldTransform.clone();return r.invert(),t.prepend(r),i.setFromMatrix(t),i},replaceChild(i,e){i.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(i)),e.setFromMatrix(i.localTransform),e.updateLocalTransform(),this.removeChild(i)}}});var lx,cx=f(()=>{"use strict";lx={collectRenderables(i,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(i,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,i):this.collectRenderablesWithEffects(i,e,t))},collectRenderablesSimple(i,e,t){let r=this.children,s=r.length;for(let n=0;n<s;n++)r[n].collectRenderables(i,e,t)},collectRenderablesWithEffects(i,e,t){let{renderPipes:r}=e;for(let s=0;s<this.effects.length;s++){let n=this.effects[s];r[n.pipe].push(n,this,i)}this.collectRenderablesSimple(i,e,t);for(let s=this.effects.length-1;s>=0;s--){let n=this.effects[s];r[n.pipe].pop(n,this,i)}}}});var _r,Sl=f(()=>{"use strict";_r=class{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}});var Mu,Tl,hx=f(()=>{P();br();Mu=class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){let r=this._tests[t];if(r.test(e))return Te.get(r.maskClass,e)}return e}returnMaskEffect(e){Te.return(e)}},Tl=new Mu;H.handleByList(b.MaskEffect,Tl._effectClasses)});var ux,dx=f(()=>{Sl();hx();ux={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){let i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0)},addEffect(i){this.effects.indexOf(i)===-1&&(this.effects.push(i),this.effects.sort((t,r)=>t.priority-r.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(i){let e=this.effects.indexOf(i);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(i){let e=this._maskEffect;e?.mask!==i&&(e&&(this.removeEffect(e),Tl.returnMaskEffect(e),this._maskEffect=null),i!=null&&(this._maskEffect=Tl.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){!Array.isArray(i)&&i&&(i=[i]);let e=this._filterEffect||(this._filterEffect=new _r);i=i;let t=i?.length>0,r=e.filters?.length>0,s=t!==r;i=Array.isArray(i)?i.slice(0):i,e.filters=Object.freeze(i),s&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new _r),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}}});var px,fx=f(()=>{de();px={label:null,get name(){return B($,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){B($,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,e=!1){return this.getChildByLabel(i,e)},getChildByLabel(i,e=!1){let t=this.children;for(let r=0;r<t.length;r++){let s=t[r];if(s.label===i||i instanceof RegExp&&i.test(s.label))return s}if(e)for(let r=0;r<t.length;r++){let n=t[r].getChildByLabel(i,!0);if(n)return n}return null},getChildrenByLabel(i,e=!1,t=[]){let r=this.children;for(let s=0;s<r.length;s++){let n=r[s];(n.label===i||i instanceof RegExp&&i.test(n.label))&&t.push(n)}if(e)for(let s=0;s<r.length;s++)r[s].getChildrenByLabel(i,!0,t);return t}}});var wl,V,Ge=f(()=>{Wt();wl=[new ne,new ne,new ne,new ne],V=class i{constructor(e=0,t=0,r=0,s=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(r),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new i(0,0,0,0)}clone(){return new i(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,r,s=.5){let{width:n,height:o}=this;if(n<=0||o<=0)return!1;let a=this.x,l=this.y,c=r*(1-s),h=r-c,u=a-c,d=a+n+c,p=l-c,m=l+o+c,x=a+h,y=a+n-h,g=l+h,v=l+o-h;return e>=u&&e<=d&&t>=p&&t<=m&&!(e>x&&e<y&&t>g&&t<v)}intersects(e,t){if(!t){let R=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=R)return!1;let C=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>C}let r=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=r||o<=n)return!1;let a=wl[0].set(e.left,e.top),l=wl[1].set(e.left,e.bottom),c=wl[2].set(e.right,e.top),h=wl[3].set(e.right,e.bottom);if(c.x<=a.x||l.y<=a.y)return!1;let u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(a,a),t.apply(l,l),t.apply(c,c),t.apply(h,h),Math.max(a.x,l.x,c.x,h.x)<=r||Math.min(a.x,l.x,c.x,h.x)>=s||Math.max(a.y,l.y,c.y,h.y)<=n||Math.min(a.y,l.y,c.y,h.y)>=o))return!1;let d=u*(l.y-a.y),p=u*(a.x-l.x),m=d*r+p*n,x=d*s+p*n,y=d*r+p*o,g=d*s+p*o;if(Math.max(m,x,y,g)<=d*a.x+p*a.y||Math.min(m,x,y,g)>=d*h.x+p*h.y)return!1;let v=u*(a.y-c.y),_=u*(c.x-a.x),S=v*r+_*n,T=v*s+_*n,w=v*r+_*o,E=v*s+_*o;return!(Math.max(S,T,w,E)<=v*a.x+_*a.y||Math.min(S,T,w,E)>=v*h.x+_*h.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),r=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(r-t,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(e=1,t=.001){let r=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=r-this.x,this.height=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),r=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=r-t,this.y=s,this.height=n-s,this}getBounds(e){return e||(e=new i),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;let t=e.x,r=e.y,s=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&r>=this.y&&r<this.y+this.height&&s>=this.x&&s<=this.x+this.width&&n>=this.y&&n<=this.y+this.height}set(e,t,r,s){return this.x=e,this.y=t,this.width=r,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}});var mx,fe,lt=f(()=>{oe();Ge();mx=new I,fe=class i{constructor(e=1/0,t=1/0,r=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=mx,this.minX=e,this.minY=t,this.maxX=r,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new V);let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=mx,this}set(e,t,r,s){this.minX=e,this.minY=t,this.maxX=r,this.maxY=s}addFrame(e,t,r,s,n){n||(n=this.matrix);let o=n.a,a=n.b,l=n.c,c=n.d,h=n.tx,u=n.ty,d=this.minX,p=this.minY,m=this.maxX,x=this.maxY,y=o*e+l*t+h,g=a*e+c*t+u;y<d&&(d=y),g<p&&(p=g),y>m&&(m=y),g>x&&(x=g),y=o*r+l*t+h,g=a*r+c*t+u,y<d&&(d=y),g<p&&(p=g),y>m&&(m=y),g>x&&(x=g),y=o*e+l*s+h,g=a*e+c*s+u,y<d&&(d=y),g<p&&(p=g),y>m&&(m=y),g>x&&(x=g),y=o*r+l*s+h,g=a*r+c*s+u,y<d&&(d=y),g<p&&(p=g),y>m&&(m=y),g>x&&(x=g),this.minX=d,this.minY=p,this.maxX=m,this.maxY=x}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){let t=this.minX,r=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:c,tx:h,ty:u}=e,d=o*t+l*r+h,p=a*t+c*r+u;this.minX=d,this.minY=p,this.maxX=d,this.maxY=p,d=o*s+l*r+h,p=a*s+c*r+u,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*t+l*n+h,p=a*t+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*s+l*n+h,p=a*s+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,r,s){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<r&&(this.minY=r),this.maxY>s&&(this.maxY=s),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new i(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,r,s){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;s||(s=this.matrix);let c=s.a,h=s.b,u=s.c,d=s.d,p=s.tx,m=s.ty;for(let x=t;x<r;x+=2){let y=e[x],g=e[x+1],v=c*y+u*g+p,_=h*y+d*g+m;n=v<n?v:n,o=_<o?_:o,a=v>a?v:a,l=_>l?_:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}});var Ne,vt,yi=f(()=>{oe();br();lt();Ne=Te.getPool(I),vt=Te.getPool(fe)});var $C,gx,xx=f(()=>{oe();lt();yi();$C=new I,gx={getFastGlobalBounds(i,e){e||(e=new fe),e.clear(),this._getGlobalBoundsRecursive(!!i,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);let t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(i,e,t){let r=e;if(i&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;let s=!!this.effects.length;if((this.renderGroup||s)&&(r=vt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let o=this.bounds;r.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}let n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(i,r,t)}if(s){let n=!1,o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,r.applyMatrix(o.worldTransform)),this.effects[a].addBounds(r,!0));n&&r.applyMatrix(o.worldTransform.copyTo($C).invert()),e.addBounds(r),vt.return(r)}else this.renderGroup&&(e.addBounds(r,this.relativeGroupTransform),vt.return(r))}}});function ls(i,e,t){t.clear();let r,s;return i.parent?e?r=i.parent.worldTransform:(s=Ne.get().identity(),r=Ml(i,s)):r=I.IDENTITY,yx(i,t,r,e),s&&Ne.return(s),t.isValid||t.set(0,0,0,0),t}function yx(i,e,t,r){if(!i.visible||!i.measurable)return;let s;r?s=i.worldTransform:(i.updateLocalTransform(),s=Ne.get(),s.appendFrom(i.localTransform,t));let n=e,o=!!i.effects.length;if(o&&(e=vt.get().clear()),i.boundsArea)e.addRect(i.boundsArea,s);else{let a=i.bounds;a&&!a.isEmpty()&&(e.matrix=s,e.addBounds(a));for(let l=0;l<i.children.length;l++)yx(i.children[l],e,s,r)}if(o){for(let a=0;a<i.effects.length;a++)i.effects[a].addBounds?.(e);n.addBounds(e,I.IDENTITY),vt.return(e)}r||Ne.return(s)}function Ml(i,e){let t=i.parent;return t&&(Ml(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}var Rn=f(()=>{oe();yi()});function tr(i,e){if(i===16777215||!e)return e;if(e===16777215||!i)return i;let t=i>>16&255,r=i>>8&255,s=i&255,n=e>>16&255,o=e>>8&255,a=e&255,l=t*n/255|0,c=r*o/255|0,h=s*a/255|0;return(l<<16)+(c<<8)+h}var Bn=f(()=>{"use strict"});function cs(i,e){return i===bx?e:e===bx?i:tr(i,e)}var bx,Cu=f(()=>{Bn();bx=16777215});function vr(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}var _x,Cl=f(()=>{oe();Rn();yi();Cu();_x={getGlobalAlpha(i){if(i)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(i=new I,e){if(e)return i.copyFrom(this.worldTransform);this.updateLocalTransform();let t=Ml(this,Ne.get().identity());return i.appendFrom(this.localTransform,t),Ne.return(t),i},getGlobalTint(i){if(i)return this.renderGroup?vr(this.renderGroup.worldColor):this.parentRenderGroup?vr(cs(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=cs(e,t.localColor),t=t.parent;return vr(e)}}});function hs(i,e,t){return e.clear(),t||(t=I.IDENTITY),vx(i,e,t,i,!0),e.isValid||e.set(0,0,0,0),e}function vx(i,e,t,r,s){let n;if(s)n=Ne.get(),n=t.copyTo(n);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();let l=i.localTransform;n=Ne.get(),n.appendFrom(l,t)}let o=e,a=!!i.effects.length;if(a&&(e=vt.get().clear()),i.boundsArea)e.addRect(i.boundsArea,n);else{i.renderPipeId&&(e.matrix=n,e.addBounds(i.bounds));let l=i.children;for(let c=0;c<l.length;c++)vx(l[c],e,n,r,!1)}if(a){for(let l=0;l<i.effects.length;l++)i.effects[l].addLocalBounds?.(e,r);o.addBounds(e,I.IDENTITY),vt.return(e)}Ne.return(n)}var El=f(()=>{oe();yi()});function Eu(i,e){let t=i.children;for(let r=0;r<t.length;r++){let s=t[r],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,s.children.length&&Eu(s,e)}return e.didChange}var Sx=f(()=>{"use strict"});var XC,Tx,wx=f(()=>{oe();lt();Rn();El();Sx();XC=new I,Tx={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,e){let t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=i/e*t:this.scale.x=t},_setHeight(i,e){let t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=i/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new fe});let i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),Eu(this,i),i.didChange&&hs(this,i.localBounds,XC),i.localBounds},getBounds(i,e){return ls(this,i,e||new fe)}}});var Mx,Cx=f(()=>{"use strict";Mx={_onRender:null,set onRender(i){let e=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&e?.removeOnRender(this),this._onRender=null;return}this._onRender||e?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}}});function YC(i,e){return i._zIndex-e._zIndex}var Ex,Px=f(()=>{"use strict";Ex={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(YC))}}});var kx,Ax=f(()=>{Wt();yi();kx={getGlobalPosition(i=new ne,e=!1){return this.parent?this.parent.toGlobal(this._position,i,e):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,e,t=!1){let r=this.getGlobalTransform(Ne.get(),t);return e=r.apply(i,e),Ne.return(r),e},toLocal(i,e,t,r){e&&(i=e.toGlobal(i,t,r));let s=this.getGlobalTransform(Ne.get(),r);return t=s.applyInverse(i,t),Ne.return(s),t}}});var Hr,Pl=f(()=>{Ue();Hr=class{constructor(){this.uid=K("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){if(this.renderPipes)for(let e in this.renderPipes)this.renderPipes[e].destroyInstructionSet?.(this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}});function Sr(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Tr(i){return!(i&i-1)&&!!i}var In=f(()=>{"use strict"});function kl(i){let e={};for(let t in i)i[t]!==void 0&&(e[t]=i[t]);return e}var Pu=f(()=>{"use strict"});function KC(i){let e=Rx[i];return e===void 0&&(Rx[i]=K("resource")),e}var Rx,Bx,dt,us=f(()=>{Oe();Ue();de();Rx=Object.create(null);Bx=class Ix extends le{constructor(e={}){super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,e={...Ix.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){B($,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){let e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=KC(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Bx.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};dt=Bx});function jC(i){return i.viewDimension?i.viewDimension:i.depth?"3d":i.arrayLayerCount>1?"2d-array":"2d"}function qC(i,e,t){if(i.depth!==void 0&&typeof i.depth!="number")throw new Error(`[TextureSource] depth is a 3D texture's depth in texels, but got ${i.depth}. For a depth buffer, use the depth option of a RenderTarget or the renderer.`);if(i.depth&&i.arrayLayerCount>1)throw new Error("[TextureSource] depth and arrayLayerCount can't be combined: use depth for a 3D texture or arrayLayerCount for a 2D array.");if(i.depth&&e!=="3d")throw new Error(`[TextureSource] depth makes a 3D texture, but viewDimension is '${e}'. Use arrayLayerCount for layered textures.`);if(e==="3d"&&i.arrayLayerCount>1)throw new Error("[TextureSource] a 3D texture takes depth, not arrayLayerCount.");if(i.dimensions&&i.dimensions!==t)throw new Error(`[TextureSource] dimensions '${i.dimensions}' doesn't match viewDimension '${e}'. Leave dimensions out; it is derived from the view.`);if(i.dimensions&&B(vu,"TextureSource dimensions is derived from viewDimension and depth; leave it out."),t==="3d"&&i.antialias)throw new Error("[TextureSource] a 3D texture can't be antialiased: WebGPU has no multisampled 3D textures.")}var Gx,te,et=f(()=>{Oe();In();Pu();Ue();de();us();Gx=class Fx extends le{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=K("textureSource"),this._resourceType="textureSource",this._resourceId=K("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.depth=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this.storage=!1,this._batchTick=-1,this._textureBindLocation=-1;let t=e;e={...Fx.defaultOptions,...e};let r=jC(e),s=r==="3d"||r==="1d"?r:"2d";qC(t,r,s),this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=s,this.viewDimension=r,this.arrayLayerCount=e.arrayLayerCount,this.depth=s==="3d"?e.depth??1:1,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=s==="3d"?!1:e.antialias,this.transient=e.transient??!1,this.storage=e.storage??!1,this.alphaMode=e.alphaMode,this.style=new dt(kl(e)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get depthOrArrayLayers(){return this.dimension==="3d"?this.depth:this.arrayLayerCount||1}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._ownsStyle=!1,this._style?.off("change",this._onStyleChange,this),this._style=e,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){let e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._ownsStyle&&this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=K("resource"),this.emit("change",this),this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){let{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,r){r||(r=this._resolution),e||(e=this.width),t||(t=this.height);let s=Math.round(e*r),n=Math.round(t*r);return this.width=s/r,this.height=n/r,this._resolution=r,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=K("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Tr(this.pixelWidth)&&Tr(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Gx.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};te=Gx});function ZC(){for(let i=0;i<16;i++){let e=[];ku.push(e);for(let t=0;t<16;t++){let r=Al(bi[i]*bi[t]+vi[i]*_i[t]),s=Al(_i[i]*bi[t]+Si[i]*_i[t]),n=Al(bi[i]*vi[t]+vi[i]*Si[t]),o=Al(_i[i]*vi[t]+Si[i]*Si[t]);for(let a=0;a<16;a++)if(bi[a]===r&&_i[a]===s&&vi[a]===n&&Si[a]===o){e.push(a);break}}}for(let i=0;i<16;i++){let e=new I;e.set(bi[i],_i[i],vi[i],Si[i],0,0),Dx.push(e)}}var bi,_i,vi,Si,ku,Dx,Al,ee,Gn=f(()=>{oe();bi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],_i=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],vi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Si=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],ku=[],Dx=[],Al=Math.sign;ZC();ee={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>bi[i],uY:i=>_i[i],vX:i=>vi[i],vY:i=>Si[i],inv:i=>i&8?i&15:-i&7,add:(i,e)=>ku[i][e],sub:(i,e)=>ku[i][ee.inv(e)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,e)=>Math.abs(i)*2<=Math.abs(e)?e>=0?ee.S:ee.N:Math.abs(e)*2<=Math.abs(i)?i>0?ee.E:ee.W:e>0?i>0?ee.SE:ee.SW:i>0?ee.NE:ee.NW,matrixAppendRotationInv:(i,e,t=0,r=0,s=0,n=0)=>{let o=Dx[ee.inv(e)],a=o.a,l=o.b,c=o.c,h=o.d,u=t-Math.min(0,a*s,c*n,a*s+c*n),d=r-Math.min(0,l*s,h*n,l*s+h*n),p=i.a,m=i.b,x=i.c,y=i.d;i.a=a*p+l*x,i.b=a*m+l*y,i.c=c*p+h*x,i.d=c*m+h*y,i.tx=u*p+d*x+i.tx,i.ty=u*m+d*y+i.ty},transformRectCoords:(i,e,t,r)=>{let{x:s,y:n,width:o,height:a}=i,{x:l,y:c,width:h,height:u}=e;return t===ee.E?(r.set(s+l,n+c,o,a),r):t===ee.S?r.set(h-n-a+l,s+c,a,o):t===ee.W?r.set(h-s-o+l,u-n-a+c,o,a):t===ee.N?r.set(n+l,u-s-o+c,a,o):r.set(s+l,n+c,o,a)}}});var Au,Ox=f(()=>{"use strict";Au=()=>{}});function Fn(i){return i.endsWith("int")}var Ru=f(()=>{"use strict"});var Ti,Bu=f(()=>{P();Ru();et();Ti=class extends te{constructor(e){let t=e.depth??e.arrayLayerCount??1,r=e.resource||new Float32Array(e.width*e.height*t*4),s=e.format;s||(r instanceof Float32Array?s="rgba32float":r instanceof Int32Array||r instanceof Uint32Array?s="rgba32uint":r instanceof Int16Array||r instanceof Uint16Array?s="rgba16uint":(r instanceof Int8Array,s="bgra8unorm"));let n=Fn(s)||t>1;super({...n&&{alphaMode:"no-premultiply-alpha"},...e,resource:r,format:s}),this.uploadMethodId="buffer",this._updateStart=0,this._updateEnd=1/0}update(e=0,t=1/0){if((e>0||t<1/0)&&this.depthOrArrayLayers>1)throw new Error("[BufferImageSource] a 3D texture or 2D array uploads whole: call update() with no range.");this._updateStart=e,this._updateEnd=t,super.update(),this._updateStart=0,this._updateEnd=1/0}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}};Ti.extension=b.TextureSource});var Lx,ds,Iu=f(()=>{oe();Lx=new I,ds=class{constructor(e,t){this.mapCoord=new I,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture?.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}destroy(){this._texture?.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,t){t===void 0&&(t=e);let r=this.mapCoord;for(let s=0;s<e.length;s+=2){let n=e[s],o=e[s+1];t[s]=n*r.a+o*r.c+r.tx,t[s+1]=n*r.b+o*r.d+r.ty}return t}update(){let e=this._texture;this._updateID++;let t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);let r=e.orig,s=e.trim;s&&(Lx.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Lx));let n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+l)/n.width,o[1]=(e.frame.y+a+l)/n.height,o[2]=(e.frame.x+e.frame.width-a+l)/n.width,o[3]=(e.frame.y+e.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}});var F,ye=f(()=>{Oe();Gn();Ge();Ue();de();Ox();Bu();et();Iu();F=class extends le{constructor({source:e,label:t,frame:r,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:c}={}){if(super(),this.uid=K("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new V,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new te,this.noFrame=!r,r)this.frame.copyFrom(r);else{let{width:h,height:u}=this._source;this.frame.width=h,this.frame.height=u}this.orig=s||this.frame,this.trim=n,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new ds(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:r,height:s}=this._source,n=t.x/r,o=t.y/s,a=t.width/r,l=t.height/s,c=this.rotate;if(c){let h=a/2,u=l/2,d=n+h,p=o+u;c=ee.add(c,ee.NW),e.x0=d+h*ee.uX(c),e.y0=p+u*ee.uY(c),c=ee.add(c,2),e.x1=d+h*ee.uX(c),e.y1=p+u*ee.uY(c),c=ee.add(c,2),e.x2=d+h*ee.uX(c),e.y2=p+u*ee.uY(c),c=ee.add(c,2),e.x3=d+h*ee.uX(c),e.y3=p+u*ee.uY(c)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+l,e.x3=n,e.y3=o+l}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return B($,"Texture.baseTexture is now Texture.source"),this._source}};F.EMPTY=new F({label:"EMPTY",source:new te({label:"EMPTY"})});F.EMPTY.destroy=Au;F.WHITE=new F({source:new Ti({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});F.WHITE.destroy=Au});var ps,Gu=f(()=>{"use strict";ps=class{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[]}get size(){return this._screenSizes.size}set(e,t,r){let s=this._screenSizes.get(e);return s&&s.pixelWidth===t&&s.pixelHeight===r?!1:(this._screenSizes.set(e,{pixelWidth:t,pixelHeight:r}),this._update(),!0)}remove(e){return this._screenSizes.delete(e)?(this._update(),!0):!1}getFittingWidth(e){return this._getFittingAxis(e,this._widths)}getFittingHeight(e){return this._getFittingAxis(e,this._heights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,t){for(let r=0;r<t.length;r++){let s=t[r];if(s>=e)return s}}_update(){this._widths=[...this._screenSizes.values()].map(e=>e.pixelWidth).filter((e,t,r)=>r.indexOf(e)===t).sort((e,t)=>e-t),this._heights=[...this._screenSizes.values()].map(e=>e.pixelHeight).filter((e,t,r)=>r.indexOf(e)===t).sort((e,t)=>e-t)}}});function rE(i){let e=Ux[i];return e!==void 0?e:Ux[i]=tE++}function iE(i,e,t,r,s,n){return(i<<17)+(e<<2)+((r?1:0)<<1)+(t?1:0)+(n==="nearest"?1:0)*JC+rE(s)*eE}var QC,Fu,JC,eE,Ux,tE,Rl,ce,wr=f(()=>{In();de();ie();xi();et();ye();us();Gu();QC=0,Fu=32767,JC=4294967296,eE=8589934592,Ux=Object.create(null),tE=0;Rl=class{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new ps,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){return B(_t,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle||(this._textureStyle=new dt(this.textureOptions)),this._textureStyle}set textureStyle(e){B(_t,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return B(_t,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){B(_t,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let t=e[0];typeof t=="number"&&(B(_t,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1});let r=t.format??this.textureOptions.format??te.defaultOptions.format,s=t.scaleMode??this.textureOptions.scaleMode??dt.defaultOptions.scaleMode,n=new te({...this.textureOptions,width:t.width,height:t.height,resolution:1,antialias:t.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:t.autoGenerateMipmaps??!1,format:r,scaleMode:s});return new F({source:n,label:`texturePool_${QC++}`})}getOptimalTexture(...e){let t=e[0];typeof t=="number"&&(B(_t,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1});let r=t.width,s=t.height,n=t.resolution??1,o=t.antialias??!1,a=t.autoGenerateMipmaps??!1,l=t.format??this.textureOptions.format??te.defaultOptions.format,c=t.scaleMode??this.textureOptions.scaleMode??dt.defaultOptions.scaleMode,{width:h,height:u}=this.getOptimalSize(r,s,n);(h>Fu||u>Fu)&&G(`TexturePool: ${h}x${u} is larger than the ${Fu}px pool key limit, textures of this size may be pooled together`);let d=iE(h,u,o,a,l,c),p=this._buckets.get(d);p||(p=[],this._buckets.set(d,p));let m=p.pop();return m||(m=this.createTexture({width:h,height:u,antialias:o,autoGenerateMipmaps:a,format:l,scaleMode:c}),this._poolStyle[m.uid]=m.source.style),m.source._resolution=n,m.source.width=h/n,m.source.height=u/n,m.source.pixelWidth=h,m.source.pixelHeight=u,m.frame.x=0,m.frame.y=0,m.frame.width=r,m.frame.height=s,m.updateUvs(),this._poolKey[m.uid]=d,m}getOptimalSize(e,t,r=1){let s=Math.ceil(e*r-1e-6),n=Math.ceil(t*r-1e-6),o=Sr(s),a=this._screens.getFittingWidth(s),l=Sr(n),c=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:c!==void 0?Math.min(c,l):l}}getSameSizeTexture(e,t=!1){let r=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:r._resolution,antialias:t})}returnTexture(e,t=!1){let r=e.uid,s=this._poolKey[r];if(s===void 0){G("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}let n=this._poolStyle[r];t&&e.source.style!==n&&(e.source.style=n);let o=this._buckets.get(s);if(!o){delete this._poolKey[r],delete this._poolStyle[r],e.destroy(!0);return}o.push(e)}setScreenSize(e,t,r){this._screens.set(e,t,r)&&this._pruneScreenTextures()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenTextures()}_pruneScreenTextures(){for(let[e,t]of this._buckets){let r=e>>>0,s=r>>>17,n=r>>>2&32767;(Tr(s)||this._screens.hasWidth(s))&&(Tr(n)||this._screens.hasHeight(n))||(this._dropTextures(t,!0),this._buckets.delete(e))}}_dropTextures(e,t){for(let r=0;r<e.length;r++){let s=e[r];delete this._poolKey[s.uid],delete this._poolStyle[s.uid],t&&s.destroy(!0)}}clear(e){for(let t of this._buckets.values())this._dropTextures(t,e!==!1);this._buckets.clear()}},ce=new Rl;Ft.register(ce)});var wi,Du=f(()=>{oe();Pl();wr();wi=class{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new I,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Hr,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;let t=e.children;for(let r=0;r<t.length;r++){let s=t[r];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(ce.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;let e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(let e in this.childrenToUpdate){let t=this.childrenToUpdate[e];t.list.fill(null),t.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);let t=e.children;for(let r=0;r<t.length;r++)this.addChild(t[r])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let r=0;r<t.length;r++)this.removeChild(t[r])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){let t=this._onRenderContainers.indexOf(e);t!==-1&&this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet?.destroy(),this.instructionSet=null}getChildren(e=[]){let t=this.root.children;for(let r=0;r<t.length;r++)this._getChildren(t[r],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;let r=e.children;for(let s=0;s<r.length;s++)this._getChildren(r[s],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new I),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new I),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;let e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new I),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}});function Nx(i,e,t={}){for(let r in e)!t[r]&&e[r]!==void 0&&(i[r]=e[r])}var Hx=f(()=>{"use strict"});var Ou,Bl,Lu,Il,fs,Dn,Mi,ge,Vt=f(()=>{Oe();Je();Zg();P();oe();xu();bl();Ue();de();ie();br();nx();ax();cx();dx();fx();xx();Cl();wx();Cx();Px();Ax();Du();Hx();Ou=new Le(null),Bl=new Le(null),Lu=new Le(null,1,1),Il=new Le(null),fs=1,Dn=2,Mi=4,ge=class i extends le{constructor(e={}){super(),this.uid=K("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new I,this.relativeGroupTransform=new I,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Le(this,0,0),this._scale=Lu,this._pivot=Bl,this._origin=Il,this._skew=Ou,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Nx(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(t=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){B("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),H.mixin(i,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||B($,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let s=0;s<e.length;s++)this.addChild(e[s]);return e[0]}let t=e[0],r=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),r&&(r.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,r&&r.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let s=0;s<e.length;s++)this.removeChild(e[s]);return e[0]}let t=e[0],r=this.children.indexOf(t);return r>-1&&(this._didViewChangeTick++,this.children.splice(r,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,r),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Te.get(wi,this),this.groupTransform=I.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Te.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new I),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*Jg}set angle(e){this.rotation=e*ex}get pivot(){return this._pivot===Bl&&(this._pivot=new Le(this,0,0)),this._pivot}set pivot(e){this._pivot===Bl&&(this._pivot=new Le(this,0,0),this._origin!==Il&&G("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===Ou&&(this._skew=new Le(this,0,0)),this._skew}set skew(e){this._skew===Ou&&(this._skew=new Le(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Lu&&(this._scale=new Le(this,1,1)),this._scale}set scale(e){this._scale===Lu&&(this._scale=new Le(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Il&&(this._origin=new Le(this,0,0)),this._origin}set origin(e){this._origin===Il&&(this._origin=new Le(this,0,0),this._pivot!==Bl&&G("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let r=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,r.width),t!==void 0&&this._setHeight(t,r.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX:this.scale.x,typeof e.scaleY=="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,r=this._scale,s=this._pivot,n=this._origin,o=this._position,a=r._x,l=r._y,c=s._x,h=s._y,u=-n._x,d=-n._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*l,t.d=this._sy*l,t.tx=o._x-(c*t.a+h*t.c)+(u*t.a+d*t.c)-u,t.ty=o._y-(c*t.b+h*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=fs,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){let r=q.shared.setValue(e??16777215).toBgrNumber();r!==this.localColor&&(this.localColor=r,this._updateFlags|=fs,this._onUpdate())}get tint(){return vr(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Dn,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Mi,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Mi,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=Mi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e=="boolean"?e:e?.children)&&t)for(let s=0;s<t.length;++s)t[s].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}};H.mixin(ge,ox,gx,kx,Mx,Tx,ux,px,Ex,qg,sx,_x,lx)});var rr,On=f(()=>{"use strict";rr=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(rr||{})});var ms,zx=f(()=>{"use strict";ms=class{constructor(e,t=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=r,this._once=s}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}}});var Wx,tt,gs=f(()=>{On();zx();Wx=class St{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new ms(null,null,1/0),this.deltaMS=1/St.targetFPMS,this.elapsedMS=1/St.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,r=rr.NORMAL){return this._addListener(new ms(e,t,r))}addOnce(e,t,r=rr.NORMAL){return this._addListener(new ms(e,t,r,!0))}_addListener(e){let t=this._head.next,r=this._head;if(!t)e.connect(r);else{for(;t;){if(e.priority>t.priority){e.connect(r);break}r=t,t=t.next}e.previous||e.connect(r)}return this._startIfPossible(),this}remove(e,t){let r=this._head.next;for(;r;)r.match(e,t)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){let n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*St.targetFPMS;let r=this._head,s=r.next;for(;s;)s=s.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){let t=Math.min(Math.max(0,e)/1e3,St.targetFPMS);this._maxElapsedMS=1/t,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!St._shared){let e=St._shared=new St;e.autoStart=!0,e._protected=!0}return St._shared}static get system(){if(!St._system){let e=St._system=new St;e.autoStart=!0,e._protected=!0}return St._system}};Wx.targetFPMS=.06;tt=Wx});var xs,Uu=f(()=>{On();gs();xs=class{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let t=this._canvas.getBoundingClientRect(),r=this._canvas.width,s=this._canvas.height,n=t.width/r*this._renderer.resolution,o=t.height/s*this._renderer.resolution,a=t.left,l=t.top,c=`translate(${a}px, ${l}px) scale(${n}, ${o})`;c!==this._lastTransform&&(this._domElement.style.transform=c,this._lastTransform=c)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let r=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/r*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||tt.shared.add(this.updateTranslation,this,rr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&tt.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}});var zr,Gl=f(()=>{Wt();zr=class i{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=i.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ne,this.page=new ne,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,r,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}});function sE(i){return function(e){return e.test(i)}}function Ln(i){var e={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?e.userAgent=i:i&&i.userAgent&&(e={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var t=e.userAgent,r=t.split("[FBAN");typeof r[1]<"u"&&(t=r[0]),r=t.split("Twitter"),typeof r[1]<"u"&&(t=r[0]);var s=sE(t),n={apple:{phone:s(Nu)&&!s(Mr),ipod:s(Vx),tablet:!s(Nu)&&(s($x)||e0(e))&&!s(Mr),universal:s(Xx),device:(s(Nu)||s(Vx)||s($x)||s(Xx)||e0(e))&&!s(Mr)},amazon:{phone:s(ys),tablet:!s(ys)&&s(Fl),device:s(ys)||s(Fl)},android:{phone:!s(Mr)&&s(ys)||!s(Mr)&&s(Hu),tablet:!s(Mr)&&!s(ys)&&!s(Hu)&&(s(Fl)||s(Yx)),device:!s(Mr)&&(s(ys)||s(Fl)||s(Hu)||s(Yx))||s(/\bokhttp\b/i)},windows:{phone:s(Mr),tablet:s(Kx),device:s(Mr)||s(Kx)},other:{blackberry:s(jx),blackberry10:s(qx),opera:s(Zx),firefox:s(Jx),chrome:s(Qx),device:s(jx)||s(qx)||s(Zx)||s(Jx)||s(Qx)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var Nu,Vx,$x,Xx,Hu,Yx,ys,Fl,Mr,Kx,jx,qx,Zx,Qx,Jx,e0,zu=f(()=>{Nu=/iPhone/i,Vx=/iPod/i,$x=/iPad/i,Xx=/\biOS-universal(?:.+)Mac\b/i,Hu=/\bAndroid(?:.+)Mobile\b/i,Yx=/Android/i,ys=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Fl=/Silk/i,Mr=/Windows Phone/i,Kx=/\bWindows(?:.+)ARM\b/i,jx=/BlackBerry/i,qx=/BB10/i,Zx=/Opera Mini/i,Qx=/\b(CriOS|Chrome)(?:.+)Mobile/i,Jx=/Mobile(?:.+)Firefox\b/i,e0=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"}});var t0=f(()=>{zu();zu()});var nE,r0,i0=f(()=>{t0();nE=Ln.default??Ln,r0=nE(globalThis.navigator)});var oE,s0,aE,lE,n0,o0,cE,hE,uE,Wu,l0,c0=f(()=>{Uu();Gl();P();i0();wu();oE=9,s0=100,aE=0,lE=0,n0=2,o0=1,cE=-1e3,hE=-1e3,uE=2,Wu=class a0{constructor(e,t=r0){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement("button");e.style.width=`${o0}px`,e.style.height=`${o0}px`,e.style.position="absolute",e.style.top=`${cE}px`,e.style.left=`${hE}px`,e.style.zIndex=uE.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${aE}px`,this._div.style.left=`${lE}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=n0.toString(),this._canvasObserver=new xs({domElement:this._div,renderer:this._renderer})),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(r=>{r.parentNode&&r.parentNode.removeChild(r)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let r=0;r<t.length;r++)this._updateAccessibleObjects(t[r])}init(e){let r={accessibilityOptions:{...a0.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=r.accessibilityOptions.debug,this._activateOnTab=r.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=r.accessibilityOptions.deactivateOnMouseMove,this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),r.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let r of this._children)r._renderId===this._renderId&&t.add(this._children.indexOf(r))}for(let r=this._children.length-1;r>=0;r--){let s=this._children[r];t.has(r)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,vl(this._children,r,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let r=0;r<this._children.length;r++){let s=this._children[r];if(!s._accessibleActive||!s._accessibleDiv)continue;let n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){let a=s.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:r}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>r&&(e.height=r-e.y)}_addChild(e){let r=this._getPool(e.accessibleType).pop();r?(r.innerHTML="",r.removeAttribute("title"),r.removeAttribute("aria-label"),r.tabIndex=0):(e.accessibleType==="button"?(r=document.createElement("button"),this.debug||(r.style.color="transparent")):(r=document.createElement(e.accessibleType),r.style.cssText=`
                        color: transparent;
                        pointer-events: none;
                        padding: 0;
                        margin: 0;
                        border: 0;
                        outline: 0;
                        background: transparent;
                        box-sizing: border-box;
                        user-select: none;
                        -webkit-user-select: none;
                        -moz-user-select: none;
                        -ms-user-select: none;
                    `),r.style.width=`${s0}px`,r.style.height=`${s0}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=n0.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=e.accessiblePointerEvents,r.type=e.accessibleType,e.accessibleText&&(r.innerText=e.accessibleText),e.accessibleTitle&&e.accessibleTitle!==null?r.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(r.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&r.setAttribute("aria-label",e.accessibleHint),e.interactive?r.tabIndex=e.tabIndex:r.tabIndex=0,this.debug&&this._updateDebugHTML(r),e._accessibleActive=!0,e._accessibleDiv=r,r.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){let{container:r}=e.target,s=this._renderer.events.rootBoundary,n=Object.assign(new zr(s),{target:r});s.rootTarget=this._renderer.lastObjectRendered,t.forEach(o=>s.dispatchEvent(n,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode!==oE||!this._activateOnTab||this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(e){e?this._activate():this._deactivate()}_getPool(e){return this._pools[e]||(this._pools[e]=[]),this._pools[e]}};Wu.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"accessibility"};Wu.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};l0=Wu});var h0,u0=f(()=>{"use strict";h0={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}});var d0=f(()=>{P();Vt();c0();u0();H.add(l0);H.mixin(ge,h0)});var Un,p0=f(()=>{P();Uu();Un=class{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new xs({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){let e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){let r=e[t],s=r.element;if(!r.parent||r.globalDisplayStatus<7)s?.remove(),e.splice(t,1),t--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));let n=r.worldTransform,o=r._anchor,a=r.width*o.x,l=r.height*o.y;s.style.transformOrigin=`${a}px ${l}px`,s.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,s.style.opacity=r.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)this._attachedDomElements[e].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}};Un.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"dom"}});var ir,Nn=f(()=>{lt();Vt();ir=class extends ge{constructor(e){super(e),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new fe(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){let t=this.bounds,{x:r,y:s}=e;return r>=t.minX&&r<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,r){let{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);let o=s[this.renderPipeId];o?.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;let a=this.children,l=a.length;for(let c=0;c<l;c++)a[c].collectRenderables(e,t,r);s.blendMode.popBlendMode(e)}}});var f0=f(()=>{P();p0();H.add(Un)});var Vu,$t,$u=f(()=>{On();gs();Vu=class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||(tt.system.add(this._tickerUpdate,this,rr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(tt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}let e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}},$t=new Vu});var Cr,Dl=f(()=>{Wt();Gl();Cr=class extends zr{constructor(){super(...arguments),this.client=new ne,this.movement=new ne,this.offset=new ne,this.global=new ne,this.screen=new ne}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,r){return e.worldTransform.applyInverse(r||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,r,s,n,o,a,l,c,h,u,d,p,m,x){throw new Error("Method not implemented.")}}});var rt,Xu=f(()=>{Dl();rt=class extends Cr{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1,this.persistentDeviceId=0}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}});var sr,Yu=f(()=>{Dl();sr=class extends Cr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};sr.DOM_DELTA_PIXEL=0;sr.DOM_DELTA_LINE=1;sr.DOM_DELTA_PAGE=2});var dE,pE,Hn,Ol,m0=f(()=>{Oe();Wt();ie();$u();Dl();Xu();Yu();dE=2048,pE=new ne,Hn=new ne,Ol=class{constructor(e){this.dispatch=new le,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mapContextMenu=this.mapContextMenu.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel),this.addEventMapping("contextmenu",this.mapContextMenu)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((r,s)=>r.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;let t=this.mappingTable[e.type];if(t)for(let r=0,s=t.length;r<s;r++)t[r].fn(e);else G(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){$t.pauseUpdate=!0;let s=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[s](this.rootTarget,this.rootTarget.eventMode,pE.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;let r=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let s=0,n=r.length-1;s<n;s++)if(e.currentTarget=r[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let s=r.length-2;s>=0;s--)if(e.currentTarget=r[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,r=this._allInteractiveElements){if(r.length===0)return;e.eventPhase=e.BUBBLING_PHASE;let s=Array.isArray(t)?t:[t];for(let n=r.length-1;n>=0;n--)s.forEach(o=>{e.currentTarget=r[n],this.notifyTarget(e,o)})}propagationPath(e){let t=[e];for(let r=0;r<dE&&e!==this.rootTarget&&e.parent;r++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,r,s,n,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&($t.pauseUpdate=!1),e.interactiveChildren&&e.children){let h=e.children;for(let u=h.length-1;u>=0;u--){let d=h[u],p=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,r,s,n,o||n(e,r));if(p){if(p.length>0&&!p[p.length-1].parent)continue;let m=e.isInteractive();(p.length>0||m)&&(m&&this._allInteractiveElements.push(e),p.push(e)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}let l=this._isInteractive(t),c=e.isInteractive();return c&&c&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(e,r)&&s(e,r)?c?[e]:[]:null}hitTestRecursive(e,t,r,s,n){if(this._interactivePrune(e)||n(e,r))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&($t.pauseUpdate=!1),e.interactiveChildren&&e.children){let l=e.children,c=r;for(let h=l.length-1;h>=0;h--){let u=l[h],d=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,c,s,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;let p=e.isInteractive();return(d.length>0||p)&&d.push(e),d}}}let o=this._isInteractive(t),a=e.isInteractive();return o&&s(e,r)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,Hn),!e.hitArea.contains(Hn.x,Hn.y)))return!0;if(e.effects&&e.effects.length)for(let r=0;r<e.effects.length;r++){let s=e.effects[r];if(s.containsPoint&&!s.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e?.containsPoint?(e.worldTransform.applyInverse(t,Hn),e.containsPoint(Hn)):!1}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??(t=e.type);let r=`on${t}`;e.currentTarget[r]?.(e);let s=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,s),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){let s=t.button===2;this.dispatchEvent(t,s?"rightdown":"mousedown")}let r=this.trackingData(e.pointerId);r.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;let t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;let r=t.pointerType==="mouse"||t.pointerType==="pen",s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==t.target){let l=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,l,n);if(this.dispatchEvent(c,"pointerout"),r&&this.dispatchEvent(c,"mouseout"),!t.composedPath().includes(n)){let h=this.createPointerEvent(e,"pointerleave",n);for(h.eventPhase=h.AT_TARGET;h.target&&!t.composedPath().includes(h.target);)h.currentTarget=h.target,this.notifyTarget(h),r&&this.notifyTarget(h,"mouseleave"),h.target=h.target.parent;this.freeEvent(h)}this.freeEvent(c)}if(n!==t.target){let l=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(t,l);this.dispatchEvent(c,"pointerover"),r&&this.dispatchEvent(c,"mouseover");let h=n?.parent;for(;h&&h!==this.rootTarget.parent&&h!==t.target;)h=h.parent;if(!h||h===this.rootTarget.parent){let d=this.clonePointerEvent(t,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==n&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),r&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}let o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),r&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=t.target?.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),r=this.createPointerEvent(e),s=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=r.target?.cursor);let n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;t.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId);if(t.overTargets){let r=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",s);this.dispatchEvent(n),r&&this.dispatchEvent(n,"mouseout");let o=this.createPointerEvent(e,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=performance.now(),r=this.createPointerEvent(e);if(this.dispatchEvent(r,"pointerup"),r.pointerType==="touch")this.dispatchEvent(r,"touchend");else if(r.pointerType==="mouse"||r.pointerType==="pen"){let a=r.button===2;this.dispatchEvent(r,a?"rightup":"mouseup")}let s=this.trackingData(e.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[e.button]),o=n;if(n&&!r.composedPath().includes(n)){let a=n;for(;a&&!r.composedPath().includes(a);){if(r.currentTarget=a,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch")this.notifyTarget(r,"touchendoutside");else if(r.pointerType==="mouse"||r.pointerType==="pen"){let l=r.button===2;this.notifyTarget(r,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[e.button],o=a}if(o){let a=this.clonePointerEvent(r,"click");a.target=o,a.path=null,s.clicksByButton[e.button]||(s.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});let l=s.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){let c=a.button===2;this.dispatchEvent(a,c?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(r)}mapPointerUpOutside(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),r=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(r){let n=r;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof sr)){G("EventBoundary cannot map a non-wheel event as a wheel event");return}let t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}mapContextMenu(e){if(!(e instanceof rt)){G("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.createPointerEvent(e);this.dispatchEvent(t,"contextmenu"),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let r=1;r<e.length&&e[r].parent===t;r++)t=e[r];return t}createPointerEvent(e,t,r){let s=this.allocateEvent(rt);return this.copyPointerData(e,s),this.copyMouseData(e,s),this.copyData(e,s),s.nativeEvent=e.nativeEvent,s.originalEvent=e,s.target=r??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof t=="string"&&(s.type=t),s}createWheelEvent(e){let t=this.allocateEvent(sr);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){let r=this.allocateEvent(rt);return r.nativeEvent=e.nativeEvent,r.originalEvent=e.originalEvent,this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.target=e.target,r.path=e.composedPath().slice(),r.type=t??r.type,r}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof rt&&t instanceof rt&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.persistentDeviceId=e.persistentDeviceId)}copyMouseData(e,t){e instanceof Cr&&t instanceof Cr&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);let t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");let t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){let r=e.currentTarget._events[t];if(r)if("fn"in r)r.once&&e.currentTarget.removeListener(t,r.fn,void 0,!0),r.fn.call(r.context,e);else for(let s=0,n=r.length;s<n&&!e.propagationImmediatelyStopped;s++)r[s].once&&e.currentTarget.removeListener(t,r[s].fn,void 0,!0),r[s].fn.call(r[s].context,e)}}});var fE,mE,ju,Ll,qu=f(()=>{P();m0();$u();Xu();Yu();fE=1,mE={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ju=class Ku{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new Ol(null),$t.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new rt(null),this._rootWheelEvent=new sr(null),this._rootContextMenuEvent=new rt(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ku.defaultEventFeatures},{set:(t,r,s)=>(r==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),t[r]=s,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){let{canvas:t,resolution:r}=this.renderer;this.setTargetElement(t),this.resolution=r,Ku._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){$t.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;let r=this.cursorStyles[e];if(r)switch(typeof r){case"string":t&&(this.domElement.style.cursor=r);break;case"function":r(e);break;case"object":t&&Object.assign(this.domElement.style,r);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let r=0,s=t.length;r<s;r++){let n=t[r],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,$t.pointerMoved();let t=this._normalizeToPointerData(e);for(let r=0,s=t.length;r<s;r++){let n=this._bootstrapEvent(this._rootPointerEvent,t[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);let r=t!==this.domElement?"outside":"",s=this._normalizeToPointerData(e);for(let n=0,o=s.length;n<o;n++){let a=this._bootstrapEvent(this._rootPointerEvent,s[n]);a.type+=r,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=this._normalizeToPointerData(e);for(let r=0,s=t.length;r<s;r++){let n=this._bootstrapEvent(this._rootPointerEvent,t[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onContextMenu(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=this._normalizeToPointerData(e);for(let r=0,s=t.length;r<s;r++){let n=this._bootstrapEvent(this._rootContextMenuEvent,t[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;let t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,$t.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;$t.addTickerListener();let e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.domElement.addEventListener("contextmenu",this._onContextMenu,!0),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;$t.removeTickerListener();let e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement.removeEventListener("contextmenu",this._onContextMenu,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,r){let s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;e.x=(t-s.left)*(this.domElement.width/s.width)*n,e.y=(r-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(e){let t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let r=0,s=e.changedTouches.length;r<s;r++){let n=e.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,n.altKey??(n.altKey=e.altKey),n.ctrlKey??(n.ctrlKey=e.ctrlKey),n.metaKey??(n.metaKey=e.metaKey),n.shiftKey??(n.shiftKey=e.shiftKey),t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){let r=e;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=fE),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),r.isNormalized=!0,t.push(r)}else t.push(e);return t}normalizeWheelEvent(e){let t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=mE[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};ju.extension={name:"events",type:[b.WebGLSystem,b.CanvasSystem,b.WebGPUSystem],priority:-1};ju.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};Ll=ju});var g0,x0=f(()=>{qu();Gl();g0={onclick:null,oncontextmenu:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ll.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,e,t){let r=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof t=="object"?t.signal:void 0,n=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;i=r?`${i}capture`:i;let a=typeof e=="function"?e:e.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(i,a,o)}),n?l.once(i,a,o):l.on(i,a,o)},removeEventListener(i,e,t){let r=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;i=r?`${i}capture`:i,e=typeof e=="function"?e:e.handleEvent,this.off(i,e,s)},dispatchEvent(i){if(!(i instanceof zr))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}}});var y0=f(()=>{P();Vt();qu();x0();H.add(Ll);H.mixin(ge,g0)});var Zu,b0=f(()=>{"use strict";Zu=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Zu||{})});var _0,v0=f(()=>{"use strict";_0={createCanvas:(i,e)=>{let t=document.createElement("canvas");return t.width=i,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,e)=>fetch(i,e),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")}});var S0,W,we=f(()=>{v0();S0=_0,W={get(){return S0},set(i){S0=i}}});function Xt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function zn(i){return i.split("?")[0].split("#")[0]}function gE(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xE(i,e,t){return i.replace(new RegExp(gE(e),"g"),t)}function yE(i,e){let t="",r=0,s=-1,n=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(t.length<2||r!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){let l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",r=0):(t=t.slice(0,l),r=t.length-1-t.lastIndexOf("/")),s=a,n=0;continue}}else if(t.length===2||t.length===1){t="",r=0,s=a,n=0;continue}}e&&(t.length>0?t+="/..":t="..",r=2)}else t.length>0?t+=`/${i.slice(s+1,a)}`:t=i.slice(s+1,a),r=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}var Ci,Qu=f(()=>{we();Ci={toPosix(i){return xE(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){Xt(i),i=this.toPosix(i);let e=/^file:\/\/\//.exec(i);if(e)return e[0];let t=/^[^/:]+:\/{0,2}/.exec(i);return t?t[0]:""},toAbsolute(i,e,t){if(Xt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;let r=zn(this.toPosix(e??W.get().getBaseUrl())),s=zn(this.toPosix(t??this.rootname(r)));return i=this.toPosix(i),i.startsWith("/")?Ci.join(s,i.slice(1)):this.isAbsolute(i)?i:this.join(r,i)},normalize(i){if(Xt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let e="",t=i.startsWith("/");this.hasProtocol(i)&&(e=this.rootname(i),i=i.slice(e.length));let r=i.endsWith("/");return i=yE(i,!1),i.length>0&&r&&(i+="/"),t?`/${i}`:e+i},isAbsolute(i){return Xt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let e;for(let t=0;t<i.length;++t){let r=i[t];if(Xt(r),r.length>0)if(e===void 0)e=r;else{let s=i[t-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${r}`:e+=`/${r}`}}return e===void 0?".":this.normalize(e)},dirname(i){if(Xt(i),i.length===0)return".";i=this.toPosix(i);let e=i.charCodeAt(0),t=e===47,r=-1,s=!0,n=this.getProtocol(i),o=i;i=i.slice(n.length);for(let a=i.length-1;a>=1;--a)if(e=i.charCodeAt(a),e===47){if(!s){r=a;break}}else s=!1;return r===-1?t?"/":this.isUrl(o)?n+i:n:t&&r===1?"//":n+i.slice(0,r)},rootname(i){Xt(i),i=this.toPosix(i);let e="";if(i.startsWith("/")?e="/":e=this.getProtocol(i),this.isUrl(i)){let t=i.indexOf("/",e.length);t!==-1?e=i.slice(0,t):e=i,e.endsWith("/")||(e+="/")}return e},basename(i,e){Xt(i),e&&Xt(e),i=zn(this.toPosix(i));let t=0,r=-1,s=!0,n;if(e!==void 0&&e.length>0&&e.length<=i.length){if(e.length===i.length&&e===i)return"";let o=e.length-1,a=-1;for(n=i.length-1;n>=0;--n){let l=i.charCodeAt(n);if(l===47){if(!s){t=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(r=n):(o=-1,r=a))}return t===r?r=a:r===-1&&(r=i.length),i.slice(t,r)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!s){t=n+1;break}}else r===-1&&(s=!1,r=n+1);return r===-1?"":i.slice(t,r)},extname(i){Xt(i),i=zn(this.toPosix(i));let e=-1,t=0,r=-1,s=!0,n=0;for(let o=i.length-1;o>=0;--o){let a=i.charCodeAt(o);if(a===47){if(!s){t=o+1;break}continue}r===-1&&(s=!1,r=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||r===-1||n===0||n===1&&e===r-1&&e===t+1?"":i.slice(e,r)},parse(i){Xt(i);let e={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return e;i=zn(this.toPosix(i));let t=i.charCodeAt(0),r=this.isAbsolute(i),s,n="";e.root=this.rootname(i),r||this.hasProtocol(i)?s=1:s=0;let o=-1,a=0,l=-1,c=!0,h=i.length-1,u=0;for(;h>=s;--h){if(t=i.charCodeAt(h),t===47){if(!c){a=h+1;break}continue}l===-1&&(c=!1,l=h+1),t===46?o===-1?o=h:u!==1&&(u=1):o!==-1&&(u=-1)}return o===-1||l===-1||u===0||u===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&r?e.base=e.name=i.slice(1,l):e.base=e.name=i.slice(a,l)):(a===0&&r?(e.name=i.slice(1,o),e.base=i.slice(1,l)):(e.name=i.slice(a,o),e.base=i.slice(a,l)),e.ext=i.slice(o,l)),e.dir=this.dirname(i),n&&(e.dir=n+e.dir),e},sep:"/",delimiter:":",joinExtensions:[".html"]}});var Wr,Ju=f(()=>{"use strict";Wr=(i,e,t=!1)=>(Array.isArray(i)||(i=[i]),e?i.map(r=>typeof r=="string"||t?e(r):r):i)});function T0(i,e,t,r,s){let n=e[t];for(let o=0;o<n.length;o++){let a=n[o];t<e.length-1?T0(i.replace(r[t],a),e,t+1,r,s):s.push(i.replace(r[t],a))}}function w0(i){let e=/\{(.*?)\}/g,t=i.match(e),r=[];if(t){let s=[];t.forEach(n=>{let o=n.substring(1,n.length-1).split(",");s.push(o)}),T0(i,s,0,t,r)}else r.push(i);return r}var M0=f(()=>{"use strict"});var ed,C0=f(()=>{"use strict";ed=i=>!Array.isArray(i)});function bE(i){return i.split(".").pop().split("?").shift().split("#").shift()}var Wn,E0=f(()=>{ie();Qu();Ju();M0();C0();Wn=class{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{let t=e;this._defaultSearchParams=Object.keys(t).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(t[r])}`).join("&")}}getAlias(e){let{alias:t,src:r}=e;return Wr(t||r,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>o?.src??o):n?.src?n.src:n,!0)}removeAlias(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&G("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){let r=[],s=t;Array.isArray(t)||(s=Object.entries(t).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),s.forEach(n=>{let o=n.src,a=n.alias,l;if(typeof a=="string"){let c=this._createBundleAssetId(e,a);r.push(c),l=[a,c]}else{let c=a.map(h=>this._createBundleAssetId(e,h));r.push(...c),l=[...a,...c]}this.add({...n,alias:l,src:o})}),this._bundles[e]=r}add(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e);let r;r=n=>{this.hasKey(n)&&G(`[Resolver] already has key: ${n} overwriting`)},Wr(t).forEach(n=>{let{src:o}=n,{data:a,format:l,loadParser:c,parser:h}=n,u=Wr(o).map(x=>typeof x=="string"?w0(x):Array.isArray(x)?x:[x]),d=this.getAlias(n);Array.isArray(d)?d.forEach(r):r(d);let p=[],m=x=>{let y=this._parsers.find(g=>g.test(x));return{src:x,...y?.parse(x)}};u.forEach(x=>{x.forEach(y=>{let g={};if(typeof y!="object"?g=m(y):(a=y.data??a,l=y.format??l,(y.loadParser||y.parser)&&(c=y.loadParser??c,h=y.parser??h),g={...m(y.src),...y}),!d)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:d,data:a,format:l,loadParser:c,parser:h,progressSize:n.progressSize}),p.push(g)})}),d.forEach(x=>{this._assetMap[x]=p})})}resolveBundle(e){let t=ed(e);e=Wr(e);let r={};return e.forEach(s=>{let n=this._bundles[s];if(n){let o=this.resolve(n),a={};for(let l in o){let c=o[l];a[this._extractAssetIdFromBundle(s,l)]=c}r[s]=a}}),t?r[e[0]]:r}resolveUrl(e){let t=this.resolve(e);if(typeof e!="string"){let r={};for(let s in t)r[s]=t[s].src;return r}return t.src}resolve(e){let t=ed(e);e=Wr(e);let r={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s],o=this._getPreferredOrder(n);o?.priority.forEach(a=>{o.params[a].forEach(l=>{let c=n.filter(h=>h[a]?h[a]===l:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});r[s]=this._resolverHash[s]}),t?r[e[0]]:r}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){let r=e[t],s=this._preferredOrder.find(n=>n.params.format.includes(r.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;let t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){let{aliases:r,data:s,loadParser:n,parser:o,format:a,progressSize:l}=t;return(this._basePath||this._rootPath)&&(e.src=Ci.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=r??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??bE(e.src),l!==void 0&&(e.progressSize=l),e}};Wn.RETINA_PREFIX=/@([0-9\.]+)x/});var td,P0=f(()=>{"use strict";td=(i,e)=>{let t=e.split("?")[1];return t&&(i+=`?${t}`),i}});var k0,rd,A0=f(()=>{Ge();et();ye();k0=class Vn{constructor(e,t){this.linkedSheets=[];let r=e;e?.source instanceof te&&(r={texture:e,data:t});let{texture:s,data:n,cachePrefix:o=""}=r;this.cachePrefix=o,this._texture=s instanceof F?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;let a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Vn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let r=e,s=t?1/0:Vn.BATCH_SIZE;for(;r-e<s&&r<this._frameKeys.length;){let n=this._frameKeys[r],o=this._frames[n],a=o.frame;if(a){let l=null,c=null,h=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new V(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);o.rotated?l=new V(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new V(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(c=new V(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new F({source:this.textureSource,frame:l,orig:u,trim:c,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}r++}}_processAnimations(){let e=this.data.animations||{};for(let t in e){this.animations[t]=[];for(let r=0;r<e[t].length;r++){let s=e[t][r];this.animations[t].push(this.textures[s])}}}_parseComplete(){let e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Vn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Vn.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(let t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};k0.BATCH_SIZE=1e3;rd=k0});function R0(i,e,t){let r={};if(i.forEach(s=>{r[s]=e}),Object.keys(e.textures).forEach(s=>{r[`${e.cachePrefix}${s}`]=e.textures[s]}),!t){let s=Ci.dirname(i[0]);e.linkedSheets.forEach((n,o)=>{let a=R0([`${s}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(r,a)})}return r}var _E,B0,I0=f(()=>{b0();E0();P0();P();ye();Qu();A0();_E=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];B0={extension:b.Asset,cache:{test:i=>i instanceof rd,getCacheableAssets:(i,e)=>R0(i,e,!1)},resolver:{extension:{type:b.ResolveParser,name:"resolveSpritesheet"},test:i=>{let t=i.split("?")[0].split("."),r=t.pop(),s=t.pop();return r==="json"&&_E.includes(s)},parse:i=>{let e=i.split(".");return{resolution:parseFloat(Wn.RETINA_PREFIX.exec(i)?.[1]??"1"),format:e[e.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:b.LoadParser,priority:Zu.Normal,name:"spritesheetLoader"},async testParse(i,e){return Ci.extname(e.src).toLowerCase()===".json"&&!!i.frames},async parse(i,e,t){let{texture:r,imageFilename:s,textureOptions:n,cachePrefix:o}=e?.data??{},a=Ci.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(r instanceof F)l=r;else{let u=td(a+(s??i.meta.image),e.src);l=(await t.load([{src:u,data:n}]))[u]}let c=new rd({texture:l.source,data:i,cachePrefix:o});await c.parse();let h=i?.meta?.related_multi_packs;if(Array.isArray(h)){let u=[];for(let p of h){if(typeof p!="string")continue;let m=a+p;e.data?.ignoreMultiPack||(m=td(m,e.src),u.push(t.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}let d=await Promise.all(u);c.linkedSheets=d,d.forEach(p=>{p.linkedSheets=[c].concat(c.linkedSheets.filter(m=>m!==p))})}return c},async unload(i,e,t){await t.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}}});var Ul=f(()=>{P();I0();H.add(B0)});function Nl(i,e,t){let{width:r,height:s}=t.orig,n=t.trim;if(n){let o=n.width,a=n.height;i.minX=n.x-e._x*r,i.maxX=i.minX+o,i.minY=n.y-e._y*s,i.maxY=i.minY+a}else i.minX=-e._x*r,i.maxX=i.minX+r,i.minY=-e._y*s,i.maxY=i.minY+s}var id=f(()=>{"use strict"});var nr,Hl=f(()=>{bl();ye();id();de();Nn();nr=class i extends ir{constructor(e=F.EMPTY){e instanceof F&&(e={texture:e});let{texture:t=F.EMPTY,anchor:r,roundPixels:s,width:n,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Le({_onUpdate:()=>{this.onViewUpdate()}}),r?this.anchor=r:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof F?new i(e):new i(F.from(e,t))}set texture(e){e||(e=F.EMPTY);let t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Nl(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return B("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){let e=this._anchor,t=this._texture,r=this._bounds,{width:s,height:n}=t.orig;r.minX=-e._x*s,r.maxX=r.minX+s,r.minY=-e._y*n,r.maxY=r.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e?.texture){let r=typeof e=="boolean"?e:e?.textureSource;this._texture.destroy(r)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}});function zl(i,e,t){let r=vE;i.measurable=!0,ls(i,t,r),e.addBoundsMask(r),i.measurable=!1}var vE,sd=f(()=>{lt();Rn();vE=new fe});function Wl(i,e,t){let r=vt.get();i.measurable=!0;let s=Ne.get().identity(),n=G0(i,t,s);hs(i,r,n),i.measurable=!1,e.addBoundsMask(r),Ne.return(s),vt.return(r)}function G0(i,e,t){return i?(i!==e&&(G0(i.parent,e,t),i.updateLocalTransform(),t.append(i.localTransform)),t):(G("Mask bounds, renderable is not inside the root container"),t)}var nd=f(()=>{El();yi();ie()});var $n,F0=f(()=>{P();Hl();sd();nd();$n=class{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof nr),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(e,t){this.inverse||zl(this.mask,e,t)}addLocalBounds(e,t){Wl(this.mask,e,t)}containsPoint(e,t){let r=this.mask;return t(r,e)}destroy(){this.reset()}static test(e){return e instanceof nr}};$n.extension=b.MaskEffect});var Xn,D0=f(()=>{P();Xn=class{constructor(e){this.priority=0,this.pipe="colorMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}};Xn.extension=b.MaskEffect});var Yn,O0=f(()=>{P();Vt();sd();nd();Yn=class{constructor(e){this.priority=0,this.pipe="stencilMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){zl(this.mask,e,t)}addLocalBounds(e,t){Wl(this.mask,e,t)}containsPoint(e,t){let r=this.mask;return t(r,e)}destroy(){this.reset()}static test(e){return e instanceof ge}};Yn.extension=b.MaskEffect});var Pe,Vr=f(()=>{we();P();et();Pe=class extends te{constructor(e){e.resource||(e.resource=W.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,t=this.height,r=this._resolution){let s=super.resize(e,t,r);return s&&this.resizeCanvas(),s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}};Pe.extension=b.TextureSource});var or,Vl=f(()=>{P();et();or=class extends te{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}};or.extension=b.TextureSource});async function L0(){return od??(od=(async()=>{let e=W.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";let t=await new Promise(o=>{let a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return"premultiply-alpha-on-upload";let r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);let s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);let n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(s),e.deleteTexture(r),e.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),od}var od,U0=f(()=>{we()});var $l,H0,z0=f(()=>{P();gs();U0();et();$l=class N0 extends te{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...N0.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let e=tt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await L0(),this._load=new Promise((r,s)=>{this.isValid?r(this):(this._resolve=r,this._reject=s,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){let e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){let e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(tt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(tt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(tt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};$l.extension=b.TextureSource;$l.defaultOptions={...te.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};$l.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};H0=$l});var ad,$e,Xl=f(()=>{ie();Ju();ad=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);return t||G(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){let r=Wr(e),s;for(let l=0;l<this.parsers.length;l++){let c=this.parsers[l];if(c.test(t)){s=c.getCacheableAssets(r,t);break}}let n=new Map(Object.entries(s||{}));s||r.forEach(l=>{n.set(l,t)});let o=[...n.keys()],a={cacheKeys:o,keys:r};r.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{let c=s?s[l]:t;this._cache.has(l)&&this._cache.get(l)!==c&&G("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(e){if(!this._cacheMap.has(e)){G(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach(s=>{this._cache.delete(s)}),t.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}},$e=new ad});function W0(i={}){let e=i&&i.resource,t=e?i.resource:i,r=e?i:{resource:i};for(let s=0;s<ld.length;s++){let n=ld[s];if(n.test(t))return new n(r)}throw new Error(`Could not find a source type for resource: ${r.resource}`)}function V0(i={},e=!1){let t=i&&i.resource,r=t?i.resource:i,s=t?i:{resource:i};if(!e&&$e.has(r))return $e.get(r);let n=new F({source:W0(s)});return n.on("destroy",()=>{$e.has(r)&&$e.remove(r)}),e||$e.set(r,n),n}function $0(i,e=!1){return typeof i=="string"?$e.get(i):i instanceof te?new F({source:i}):V0(i,e)}var ld,cd=f(()=>{Xl();P();et();ye();ld=[];H.handleByList(b.TextureSource,ld);F.from=$0;te.from=W0});var Yl=f(()=>{P();F0();D0();O0();Bu();Vr();Vl();z0();cd();H.add($n,Xn,Yn,H0,or,Pe,Ti)});function X0(i){let e=W.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=i,t.fillRect(0,0,6,1),e}function Kl(){if(bs!==void 0)return bs;try{let i=X0("#ff00ff"),e=X0("#ffff00"),r=W.get().createCanvas(6,1).getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(i,0,0),r.drawImage(e,2,0);let s=r.getImageData(2,0,1,1);if(!s)bs=!1;else{let n=s.data;bs=n[0]===255&&n[1]===0&&n[2]===0}}catch{bs=!1}return bs}var bs,hd=f(()=>{we()});var Q,_s=f(()=>{Je();we();Gn();hd();Q={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Kl(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:i=>{let e=i.source,t=e?.resource;if(!t)return null;let r=e.alphaMode==="premultiplied-alpha",s=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=s!==e.pixelWidth||n!==e.pixelHeight;if(r){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;let a=Q._unpremultipliedCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){let a=Q._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;let l=W.get().createCanvas(e.pixelWidth,e.pixelHeight),c=l.getContext("2d"),h=c.createImageData(e.pixelWidth,e.pixelHeight),u=h.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let p=0;p<u.length&&p+3<d.length;p+=4)u[p]=d[p+2],u[p+1]=d[p+1],u[p+2]=d[p],u[p+3]=d[p+3];else u.set(d.subarray(0,u.length));return c.putImageData(h,0,0),Q._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(r){let a=W.get().createCanvas(e.pixelWidth,e.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,l.drawImage(t,0,0);let c=l.getImageData(0,0,a.width,a.height),h=c.data;for(let u=0;u<h.length;u+=4){let d=h[u+3];if(d>0){let p=255/d;h[u]=Math.min(255,h[u]*p+.5),h[u+1]=Math.min(255,h[u+1]*p+.5),h[u+2]=Math.min(255,h[u+2]*p+.5)}}return l.putImageData(c,0,0),Q._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){let a=Q._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;let l=W.get().createCanvas(e.pixelWidth,e.pixelHeight),c=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,c.drawImage(t,0,0),Q._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(i,e)=>{let t=i.texture,r=q.shared.setValue(e).toHex(),s=t.tintCache||(t.tintCache={}),n=s[r],o=t.source._resourceId;if(n?.tintId===o)return n;let a=n&&"getContext"in n?n:W.get().createCanvas();if(Q.tintMethod(t,e,a),a.tintId=o,Q.convertTintToImage&&a.toDataURL!==void 0){let l=W.get().createImage();l.src=a.toDataURL(),l.tintId=o,s[r]=l}else s[r]=a;return s[r]},getTintedPattern:(i,e)=>{let t=q.shared.setValue(e).toHex(),r=i.patternCache||(i.patternCache={}),s=i.source._resourceId,n=r[t];return n?.tintId===s||(Q.canvas||(Q.canvas=W.get().createCanvas()),Q.tintMethod(i,e,Q.canvas),n=Q.canvas.getContext("2d").createPattern(Q.canvas,"repeat"),n.tintId=s,r[t]=n),n},applyPatternTransform:(i,e,t=!0)=>{if(!e)return;let r=i;if(!r.setTransform)return;let s=globalThis.DOMMatrix;if(!s)return;let n=new s([e.a,e.b,e.c,e.d,e.tx,e.ty]);r.setTransform(t?n.inverse():n)},tintWithMultiply:(i,e,t)=>{let r=t.getContext("2d"),s=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;let a=ee.isVertical(o),l=a?s.height:s.width,c=a?s.width:s.height;t.width=Math.ceil(l),t.height=Math.ceil(c),r.save(),e!==16777215&&(r.fillStyle=q.shared.setValue(e).toHex(),r.fillRect(0,0,l,c),r.globalCompositeOperation="multiply");let h=Q.getCanvasSource(i);if(!h){r.restore();return}o&&Q._applyInverseRotation(r,o,s.width,s.height),r.drawImage(h,s.x,s.y,s.width,s.height,0,0,s.width,s.height),e!==16777215&&(r.globalCompositeOperation="destination-atop",r.drawImage(h,s.x,s.y,s.width,s.height,0,0,s.width,s.height)),r.restore()},tintWithOverlay:(i,e,t)=>{let r=t.getContext("2d"),s=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;let a=ee.isVertical(o),l=a?s.height:s.width,c=a?s.width:s.height;t.width=Math.ceil(l),t.height=Math.ceil(c),r.save(),r.globalCompositeOperation="copy",r.fillStyle=q.shared.setValue(e).toHex(),r.fillRect(0,0,l,c),r.globalCompositeOperation="destination-atop";let h=Q.getCanvasSource(i);if(!h){r.restore();return}o&&Q._applyInverseRotation(r,o,s.width,s.height),r.drawImage(h,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore()},tintWithPerPixel:(i,e,t)=>{let r=t.getContext("2d"),s=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;s.x*=n,s.y*=n,s.width*=n,s.height*=n;let a=ee.isVertical(o),l=a?s.height:s.width,c=a?s.width:s.height;t.width=Math.ceil(l),t.height=Math.ceil(c),r.save(),r.globalCompositeOperation="copy";let h=Q.getCanvasSource(i);if(!h){r.restore();return}o&&Q._applyInverseRotation(r,o,s.width,s.height),r.drawImage(h,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r.restore();let u=e>>16&255,d=e>>8&255,p=e&255,m=r.getImageData(0,0,l,c),x=m.data;for(let y=0;y<x.length;y+=4)x[y]=x[y]*u/255,x[y+1]=x[y+1]*d/255,x[y+2]=x[y+2]*p/255;r.putImageData(m,0,0)},_applyInverseRotation:(i,e,t,r)=>{let s=ee.inv(e),n=ee.uX(s),o=ee.uY(s),a=ee.vX(s),l=ee.vY(s),c=-Math.min(0,n*t,a*r,n*t+a*r),h=-Math.min(0,o*t,l*r,o*t+l*r);i.transform(n,o,a,l,c,h)}};Q.tintMethod=Q.canUseMultiply?Q.tintWithMultiply:Q.tintWithPerPixel});function Y0(i,e){return(i<<17)+(e<<2)}var ud,dd,ct,vs=f(()=>{we();In();de();ie();xi();Gu();ud=32767;dd=class{constructor(e){this._buckets=new Map,this._screens=new ps,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return B(_t,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){B(_t,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,t){let r=W.get().createCanvas();r.width=e,r.height=t;let s=r.getContext("2d");return{canvas:r,context:s}}getOptimalCanvasAndContext(e,t,r=1){let{width:s,height:n}=this.getOptimalSize(e,t,r);(s>ud||n>ud)&&G(`CanvasPool: ${s}x${n} is larger than the ${ud}px pool key limit, canvases of this size may be pooled together`);let o=Y0(s,n),a=this._buckets.get(o);a||(a=[],this._buckets.set(o,a));let l=a.pop();return l||(l=this._createCanvasAndContext(s,n)),l}getOptimalSize(e,t,r=1){let s=Math.ceil(e*r-1e-6),n=Math.ceil(t*r-1e-6),o=Sr(s),a=this._screens.getFittingWidth(s),l=Sr(n),c=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:c!==void 0?Math.min(c,l):l}}returnCanvasAndContext(e){let t=e.canvas,{width:r,height:s}=t,n=this._buckets.get(Y0(r,s));n&&(e.context.resetTransform(),e.context.clearRect(0,0,r,s),n.push(e))}setScreenSize(e,t,r){this._screens.set(e,t,r)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(let[e]of this._buckets){let t=e>>>17,r=e>>>2&32767;(Tr(t)||this._screens.hasWidth(t))&&(Tr(r)||this._screens.hasHeight(r))||this._buckets.delete(e)}}},ct=new dd;Ft.register(ct)});function jl(i){let e=i.length;if(e<6)return 1;let t=0;for(let r=0,s=i[e-2],n=i[e-1];r<e;r+=2){let o=i[r],a=i[r+1];t+=(o-s)*(a+n),s=o,n=a}return t<0?-1:1}var pd=f(()=>{"use strict"});function K0(i,e,t,r,s,n){let o=i-t,a=e-r,l=s-t,c=n-r,h=o*l+a*c,u=l*l+c*c,d=-1;u!==0&&(d=h/u);let p,m;d<0?(p=t,m=r):d>1?(p=s,m=n):(p=t+d*l,m=r+d*c);let x=i-p,y=e-m;return x*x+y*y}var j0=f(()=>{"use strict"});function fd(i,e,t,r,s,n,o,a){let l=o-t,c=a-r,h=s-t,u=n-r,d=i-t,p=e-r,m=l*l+c*c,x=l*h+c*u,y=l*d+c*p,g=h*h+u*u,v=h*d+u*p,_=1/(m*g-x*x),S=(g*y-x*v)*_,T=(m*v-x*y)*_;return S>=0&&T>=0&&S+T<1}var q0=f(()=>{"use strict"});var ql,Z0=f(()=>{Ge();ql=class i{constructor(e=0,t=0,r=0){this.type="circle",this.x=e,this.y=t,this.radius=r}clone(){return new i(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let r=this.radius*this.radius,s=this.x-e,n=this.y-t;return s*=s,n*=n,s+n<=r}strokeContains(e,t,r,s=.5){if(this.radius===0)return!1;let n=this.x-e,o=this.y-t,a=this.radius,l=(1-s)*r,c=Math.sqrt(n*n+o*o);return c<=a+l&&c>a-(r-l)}getBounds(e){return e||(e=new V),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}});var Zl,Q0=f(()=>{Ge();Zl=class i{constructor(e=0,t=0,r=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=r,this.halfHeight=s}clone(){return new i(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return r*=r,s*=s,r+s<=1}strokeContains(e,t,r,s=.5){let{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;let a=r*(1-s),l=r-a,c=n-l,h=o-l,u=n+a,d=o+a,p=e-this.x,m=t-this.y;return p*p/(u*u)+m*m/(d*d)>1?!1:c<=0||h<=0?!0:p*p/(c*c)+m*m/(h*h)>1}getBounds(e){return e||(e=new V),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}});var SE,TE,Ss,J0=f(()=>{de();pd();j0();Ge();Ss=class i{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){let r=[];for(let s=0,n=t.length;s<n;s++)r.push(t[s].x,t[s].y);t=r}this.points=t,this.closePath=!0}isClockwise(){let e=0,t=this.points,r=t.length;for(let s=0;s<r;s+=2){let n=t[s],o=t[s+1],a=t[(s+2)%r],l=t[(s+3)%r];e+=(a-n)*(l+o)}return e<0}containsPolygon(e){let t=this.getBounds(SE),r=e.getBounds(TE);if(!t.containsRect(r))return!1;let s=e.points;for(let n=0;n<s.length;n+=2){let o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){let e=this.points.slice(),t=new i(e);return t.closePath=this.closePath,t}contains(e,t){let r=!1,s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){let a=this.points[n*2],l=this.points[n*2+1],c=this.points[o*2],h=this.points[o*2+1];l>t!=h>t&&e<(c-a)*((t-l)/(h-l))+a&&(r=!r)}return r}strokeContains(e,t,r,s=.5){let{points:n}=this,o=s===.5?s:(s-.5)*jl(n)+.5,a=r*o,l=r-a,c=a*a,h=l*l,u=n.length-(this.closePath?0:2);for(let d=0;d<u;d+=2){let p=n[d],m=n[d+1],x=n[(d+2)%n.length],y=n[(d+3)%n.length],g=K0(e,t,p,m,x,y),v=Math.sign((x-p)*(t-m)-(y-m)*(e-p));if(g<=(v<0?c:h))return!0}return!1}getBounds(e){e||(e=new V);let t=this.points,r=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=2){let c=t[a],h=t[a+1];r=c<r?c:r,s=c>s?c:s,n=h<n?h:n,o=h>o?h:o}return e.x=r,e.width=s-r,e.y=n,e.height=o-n,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return B("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return B("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}});var Ql,Jl,ey=f(()=>{Ge();Ql=(i,e,t,r,s,n,o)=>{let a=i-t,l=e-r,c=Math.sqrt(a*a+l*l);return c>=s-n&&c<=s+o},Jl=class i{constructor(e=0,t=0,r=0,s=0,n=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=r,this.height=s,this.radius=n}getBounds(e){return e||(e=new V),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new i(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){let r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+r&&t<=this.y+this.height-r||e>=this.x+r&&e<=this.x+this.width-r)return!0;let s=e-(this.x+r),n=t-(this.y+r),o=r*r;if(s*s+n*n<=o||(s=e-(this.x+this.width-r),s*s+n*n<=o)||(n=t-(this.y+this.height-r),s*s+n*n<=o)||(s=e-(this.x+r),s*s+n*n<=o))return!0}return!1}strokeContains(e,t,r,s=.5){let{x:n,y:o,width:a,height:l,radius:c}=this,h=r*(1-s),u=r-h,d=n+c,p=o+c,m=a-c*2,x=l-c*2,y=n+a,g=o+l;return(e>=n-h&&e<=n+u||e>=y-u&&e<=y+h)&&t>=p&&t<=p+x||(t>=o-h&&t<=o+u||t>=g-u&&t<=g+h)&&e>=d&&e<=d+m?!0:e<d&&t<p&&Ql(e,t,d,p,c,u,h)||e>y-c&&t<p&&Ql(e,t,y-c,p,c,u,h)||e>y-c&&t>g-c&&Ql(e,t,y-c,g-c,c,u,h)||e<d&&t>g-c&&Ql(e,t,d,g-c,c,u,h)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}});function ec(i,e){e.clear();let t=e.matrix;for(let r=0;r<i.length;r++){let s=i[r];if(s.globalDisplayStatus<7)continue;let n=s.renderGroup??s.parentRenderGroup;n?.isCachedAsTexture?e.matrix=ty.copyFrom(n.textureOffsetInverseTransform).append(s.worldTransform):n?._parentCacheAsTextureRenderGroup?e.matrix=ty.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):e.matrix=s.worldTransform,e.addBounds(s.bounds)}return e.matrix=t,e}var ty,md=f(()=>{oe();ty=new I});function tc(i,e,t,r,s=!1,n){let o=wE;o.minX=0,o.minY=0,o.maxX=i.width/r|0,o.maxY=i.height/r|0;let a=ce.getOptimalTexture({width:o.width,height:o.height,resolution:r,autoGenerateMipmaps:s,scaleMode:n});return a.source.uploadMethodId="image",a.source.resource=i,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/r,a.frame.height=t/r,a.source.emit("update",a.source),a.updateUvs(),a}var wE,gd=f(()=>{wr();lt();wE=new fe});function ry(i){return typeof i.getCanvasFilterString=="function"}var xd,Kn,iy=f(()=>{P();_s();vs();lt();md();gd();xd=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new fe,this.cssFilterString=""}},Kn=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),r=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=r,t.container=e.container,t.cssFilterString="",r.every(l=>!l.enabled)){t.skip=!0;return}let s=[],n=1;for(let l of r){if(!l.enabled)continue;if(!ry(l)){this._warnUnsupportedFilter(l);continue}let c=l.getCanvasFilterString();if(c===null){this._warnUnsupportedFilter(l);continue}c&&s.push(c)}if(s.length===0&&n===1){t.skip=!0;return}t.cssFilterString=s.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*l,t.bounds.y*l,t.bounds.width*l,t.bounds.height*l),o.clip()}else t.useClip=!1;n!==1&&(this._alphaMultiplier*=n),t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let r=this.renderer.canvasContext.activeContext;e.useClip?r.restore():r.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(g=>!g.enabled))return e;let r=[],s=1;for(let g of t){if(!g.enabled)continue;if(!ry(g)){this._warnUnsupportedFilter(g);continue}let v=g.getCanvasFilterString();if(v===null){this._warnUnsupportedFilter(g);continue}v&&r.push(v)}if(r.length===0&&s===1)return e;let n=Q.getCanvasSource(e);if(!n)return e;let o=e.frame,a=e.source._resolution??e.source.resolution??1,l=o.width,c=o.height,h=ct.getOptimalCanvasAndContext(l,c,a),{canvas:u,context:d}=h;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),r.length&&(d.filter=r.join(" ")),s!==1&&(d.globalAlpha=s);let p=o.x*a,m=o.y*a,x=l*a,y=c*a;return d.drawImage(n,p,m,x,y,0,0,x,y),d.filter="none",d.globalAlpha=1,tc(u,l,c,a)}_calculateFilterArea(e,t){if(e.renderables?ec(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;s&&t.applyMatrix(s)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new xd),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};Kn.extension={type:[b.CanvasSystem],name:"filter"}});var jn,sy=f(()=>{P();jn=class{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}};jn.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"}});function Yt(i,e){let t=ny[i];return t===void 0&&(yd[e]===void 0&&(yd[e]=1),ny[i]=t=yd[e]++),t}var yd,ny,Ts=f(()=>{"use strict";yd=Object.create(null),ny=Object.create(null)});function ic(){return(!rc||rc?.isContextLost())&&(rc=W.get().createCanvas().getContext("webgl",{})),rc}var rc,bd=f(()=>{we()});function oy(){if(!sc){sc="mediump";let i=ic();i&&i.getShaderPrecisionFormat&&(sc=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return sc}var sc,ay=f(()=>{bd()});function ly(i,e,t){return e?i:t?(i=i.replace("out vec4 finalColor;",""),`

        #ifdef GL_ES // This checks if it is WebGL1
        #define in varying
        #define finalColor gl_FragColor
        #define texture texture2D
        #endif
        ${i}
        `):`

        #ifdef GL_ES // This checks if it is WebGL1
        #define in attribute
        #define out varying
        #endif
        ${i}
        `}var cy=f(()=>{"use strict"});function hy(i,e,t){let r=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;n==="highp"&&r!=="highp"&&(n="mediump"),i=`precision ${n} float;
${i}`}else r!=="highp"&&i.substring(0,15)==="precision highp"&&(i=i.replace("precision highp","precision mediump"));let s=e.maxSupportedFragmentPrecision==="highp"?"highp":"mediump";return PE(i,s)}function PE(i,e){let t=new Set,r="";for(let[,s]of i.matchAll(CE))t.add(s);for(let[,s]of i.matchAll(ME))t.has(s)||(t.add(s),r+=`precision ${EE[s]??e} ${s};
`);return r+i}var ME,CE,EE,uy=f(()=>{"use strict";ME=/\buniform\s+([iu]?sampler\w+)/g,CE=/\bprecision\s+\w+\s+([iu]?sampler\w+)\s*;/g,EE={sampler2D:"lowp",samplerCube:"lowp"}});function dy(i,e){return e?`#version 300 es
${i}`:i}var py=f(()=>{"use strict"});function fy(i,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";let r=t?kE:AE;return r[e]?(r[e]++,e+=`-${r[e]}`):r[e]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${e}`}
${i}`}var kE,AE,my=f(()=>{"use strict";kE={},AE={}});function gy(i,e){return e?i.replace("#version 300 es",""):i}var xy=f(()=>{"use strict"});var _d,qn,yy,Fe,$r=f(()=>{Ts();ay();cy();uy();py();my();xy();_d={stripVersion:gy,ensurePrecision:hy,addProgramDefines:ly,setProgramName:fy,insertVersion:dy},qn=Object.create(null),yy=class vd{constructor(e){e={...vd.defaultOptions,...e};let t=e.fragment.indexOf("#version 300 es")!==-1,r={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:oy()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t},s=e.fragment,n=e.vertex;Object.keys(_d).forEach(o=>{let a=r[o];s=_d[o](s,a,!0),n=_d[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Yt(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,qn[this._cacheKey]=null}static from(e){let t=`${e.vertex}:${e.fragment}`;return qn[t]||(qn[t]=new vd(e),qn[t]._cacheKey=t),qn[t]}};yy.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};Fe=yy});function Er(i){return by[i]??by.float32}var by,Zn=f(()=>{"use strict";by={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}}});function vy(i,e){let t;for(;(t=_y.exec(i))!==null;){let r=RE[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:r,stride:Er(r).stride,offset:0,instance:!1,start:0}}_y.lastIndex=0}function BE(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Sy({source:i,entryPoint:e}){let t={},r=BE(i),s=r.indexOf(`fn ${e}(`);if(s===-1)return t;let n=r.indexOf("->",s);if(n===-1)return t;let o=r.substring(s,n);if(vy(o,t),Object.keys(t).length===0){let a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){let l=a[1],c=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),h=r.match(c);h&&vy(h[1],t)}}return t}var RE,_y,Ty=f(()=>{Zn();RE={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},_y=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g});function nc(i){let e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,c=i.match(e)?.map(u=>{let d=u.match(s),p=d?.[1]??"",m;return p==="<uniform>"?m="uniform":p.startsWith("<storage")&&(m="storage"),{group:parseInt(u.match(t)[1],10),binding:parseInt(u.match(r)[1],10),name:d[2],accessMode:m,type:u.match(n)[1]}});if(!c)return{groups:[],structs:[]};let h=i.match(o)?.map(u=>{let d=u.match(l)[1],p=u.match(a).reduce((m,x)=>{let[y,g]=x.split(":");return m[y.trim()]=g.trim(),m},{});return p?{name:d,members:p}:null}).filter(({name:u})=>c.some(d=>d.type===u||d.type.includes(`<${u}>`)))??[];return{groups:c,structs:h}}var wy=f(()=>{"use strict"});var Re,My=f(()=>{"use strict";Re=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Re||{})});function oc(i){return i.endsWith("<u32>")?"uint":i.endsWith("<i32>")?"sint":"float"}function Cy({groups:i}){let e=[];for(let t=0;t<i.length;t++){let r=i[t];e[r.group]||(e[r.group]=[]),r.accessMode==="uniform"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,buffer:{type:"uniform"}}):r.accessMode==="storage"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,buffer:{type:"read-only-storage"}}):r.type==="sampler"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,sampler:{type:"filtering"}}):r.type==="sampler_comparison"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,sampler:{type:"comparison"}}):r.type==="texture_2d"||r.type.startsWith("texture_2d<")?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:oc(r.type),viewDimension:"2d",multisampled:!1}}):r.type==="texture_depth_2d"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d",multisampled:!1}}):r.type==="texture_depth_2d_array"?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d-array",multisampled:!1}}):r.type==="texture_2d_array"||r.type.startsWith("texture_2d_array<")?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:oc(r.type),viewDimension:"2d-array",multisampled:!1}}):r.type==="texture_3d"||r.type.startsWith("texture_3d<")?e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:oc(r.type),viewDimension:"3d",multisampled:!1}}):(r.type==="texture_cube"||r.type.startsWith("texture_cube<"))&&e[r.group].push({binding:r.binding,visibility:Re.VERTEX|Re.FRAGMENT,texture:{sampleType:oc(r.type),viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}var Ey=f(()=>{My()});function Py({groups:i}){let e=[];for(let t=0;t<i.length;t++){let r=i[t];e[r.group]||(e[r.group]={}),e[r.group][r.name]=r.binding}return e}var ky=f(()=>{"use strict"});function Ay(i,e){let t=new Set,r=new Set,s=[...i.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...i.groups,...e.groups].filter(o=>{let a=`${o.name}-${o.binding}`;return r.has(a)?!1:(r.add(a),!0)});return{structs:s,groups:n}}var Ry=f(()=>{"use strict"});var Qn,Xe,Ei=f(()=>{Ts();Ty();wy();Ey();ky();Ry();Qn=Object.create(null),Xe=class i{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;let{fragment:t,vertex:r,layout:s,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=r,t.source===r.source){let a=nc(t.source);this.structsAndGroups=a}else{let a=nc(r.source),l=nc(t.source);this.structsAndGroups=Ay(a,l)}this.layout=s??Py(this.structsAndGroups),this.gpuLayout=n??Cy(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){let{vertex:e,fragment:t}=this,r=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=Yt(r,"program")}get attributeData(){return this._attributeData??(this._attributeData=Sy(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Qn[this._cacheKey]=null}static from(e){let t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return Qn[t]||(Qn[t]=new i(e),Qn[t]._cacheKey=t),Qn[t]}}});var qe,Xr=f(()=>{ie();qe=class{constructor(e){this.resources=Object.create(null),this._resourceKeysValue=null,this._dirty=!0;let t=0;for(let r in e){let s=e[r];this.setResource(s,t++)}}get _resourceKeys(){return this._resourceKeysValue??(this._resourceKeysValue=Object.keys(this.resources).map(Number)),this._resourceKeysValue}get _key(){if(this._dirty){this._dirty=!1;let e=[],t=0;for(let r in this.resources)e[t++]=this.resources[r]?this.resources[r]._resourceId:-1;this._keyValue=e.join("|")}return this._keyValue}setResource(e,t){let r=this.resources[t];e!==r&&(r&&r.off?.("change",this.onResourceChange,this),e.on?.("change",this.onResourceChange,this),r===void 0&&(this._resourceKeysValue=null),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e){let t=this.resources,r=this._resourceKeys;for(let s=0;s<r.length;s++){let n=t[r[s]];n&&(n._gcLastUsed=e)}}destroy(){let e=this.resources;for(let t in e)e[t]?.off?.("change",this.onResourceChange,this);this.resources=null,this._resourceKeysValue=null}onResourceChange(e){if(this._dirty=!0,e.destroyed){let t=this.resources;for(let r in t)t[r]===e&&(t[r]=null);G(`[BindGroup] a '${e._resourceType}' was destroyed while still bound to a shader. Remove it from the shader before destroying it.`)}}}});var He,ar=f(()=>{"use strict";He=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(He||{})});var ws,Sd=f(()=>{Ts();ws=class i{constructor(e){this.data={...e};let t=Object.keys(e).sort().map(r=>`${r}:${e[r]}`).join("|");this.id=Yt(t,"shader-overrides")}static from(e){return e instanceof i?e:new i(e)}}});var Td,By,Iy=f(()=>{"use strict";Td=["f32","i32","u32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>","vec2<u32>","vec3<u32>","vec4<u32>"],By=Td.reduce((i,e)=>(i[e]=!0,i),{})});function Gy(i,e){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Fy=f(()=>{"use strict"});var Dy,Me,Tt=f(()=>{Oe();Ue();Ts();Iy();Fy();Dy=class Oy extends le{constructor(e,t){super(),this.uid=K("uniform"),this._resourceType="uniformGroup",this._resourceId=K("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...Oy.defaultOptions,...t},this.uniformStructures=e;let r={};for(let s in e){let n=e[s];if(n.name=s,n.size=n.size??1,!By[n.type]){let o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){let[,a,l]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Td.join(", ")}`)}n.value??(n.value=Gy(n.type,n.size)),r[s]=n.value}this.uniforms=r,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=Yt(Object.keys(r).map(s=>`${s}-${e[s].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(e){this._buffer!==e&&(this._buffer?.off("change",this.onBufferChange,this),this._buffer=e,e?.on("change",this.onBufferChange,this))}get _gcLastUsed(){return this._buffer?._gcLastUsed??-1}set _gcLastUsed(e){this._buffer&&(this._buffer._gcLastUsed=e)}onBufferChange(){this._resourceId=K("resource"),this.emit("change",this)}update(){this._dirtyId++}};Dy.defaultOptions={ubo:!1,isStatic:!1};Me=Dy});var De,lr=f(()=>{Oe();Ue();ie();$r();Xr();Ei();ar();Sd();Tt();De=class i extends le{constructor(e){super(),this.uid=K("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:r,groups:s,resources:n,compatibleRenderers:o,groupMap:a,overrides:l}=e;this._overrides=l?ws.from(l):null,this.gpuProgram=t,this.glProgram=r,o===void 0&&(o=0,t&&(o|=He.WEBGPU),r&&(o|=He.WEBGL)),this.compatibleRenderers=o;let c={};if(a)for(let h in a)for(let u in a[h]){let d=a[h][u];c[d]={group:h,binding:u,name:d}}if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(t&&s&&!a){let h=t.structsAndGroups.groups;a={},h.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,c[u.name]=u})}else if(n){s={},a||(a={}),t&&t.structsAndGroups.groups.forEach(d=>{a[d.group]=a[d.group]||{},a[d.group][d.binding]=d.name,c[d.name]=d});let h=0;for(let u in n)c[u]||(t&&!r&&G(`[Shader] the resource '${u}' matches no binding in the WGSL source \u2014 is the name correct?`),s[99]||(s[99]=new qe,this._ownedBindGroups.push(s[99])),c[u]={group:99,binding:h,name:u},a[99]=a[99]||{},a[99][h]=u,h++);for(let u in n){let d=u,p=n[u];!p.source&&!p._resourceType&&(p=new Me(p));let m=c[d];m&&(s[m.group]||(s[m.group]=new qe,this._ownedBindGroups.push(s[m.group])),s[m.group].setResource(p,m.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,c)}addResource(e,t,r){var s,n;(s=this._uniformBindMap)[t]||(s[t]={}),(n=this._uniformBindMap[t])[r]||(n[r]=e),this.groups[t]||(this.groups[t]=new qe,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){let r={};for(let s in t){let n=t[s];Object.defineProperty(r,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return r}destroy(e=!1){this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null)}static from(e){let{gpu:t,gl:r,...s}=e,n,o;return t&&(n=Xe.from(t)),r&&(o=Fe.from(r)),new i({gpuProgram:n,glProgram:o,...s})}}});var IE,Rd,wd,Md,Cd,Ed,Pd,kd,Ad,ze,Kt=f(()=>{"use strict";IE={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Rd={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:wd,OFFSET:Md,CULLING:Cd,DEPTH_TEST:Ed,WINDING:Pd,DEPTH_MASK:kd}=Rd,Ad=class Ly{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<wd)}set blend(e){!!(this.data&1<<wd)!==e&&(this.data^=1<<wd)}get offsets(){return!!(this.data&1<<Md)}set offsets(e){!!(this.data&1<<Md)!==e&&(this.data^=1<<Md)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Cd)}set culling(e){!!(this.data&1<<Cd)!==e&&(this.data^=1<<Cd)}get depthTest(){return!!(this.data&1<<Ed)}set depthTest(e){!!(this.data&1<<Ed)!==e&&(this.data^=1<<Ed)}get depthMask(){return!!(this.data&1<<kd)}set depthMask(e){!!(this.data&1<<kd)!==e&&(this.data^=1<<kd)}get clockwiseFrontFace(){return!!(this.data&1<<Pd)}set clockwiseFrontFace(e){!!(this.data&1<<Pd)!==e&&(this.data^=1<<Pd)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=IE[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){let e=new Ly;return e.depthTest=!1,e.depthMask=!1,e.blend=!0,e}};Ad.default2d=Ad.for2d();ze=Ad});var Uy,wt,ac=f(()=>{$r();Ei();lr();Kt();Uy=class Bd extends De{constructor(e){e={...Bd.defaultOptions,...e},super(e),this.enabled=!0,this._state=ze.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,r,s){e.applyFilter(this,t,r,s)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){let{gpu:t,gl:r,...s}=e,n,o;return t&&(n=Xe.from(t)),r&&(o=Fe.from(r)),new Bd({gpuProgram:n,glProgram:o,...s})}};Uy.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};wt=Uy});var Ny,Hy=f(()=>{Ny=`in vec2 aPosition;
out vec2 vTextureCoord;

uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;

vec4 filterVertexPosition( void )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
    
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
}
`});var zy,Wy=f(()=>{zy=`in vec2 vTextureCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
    finalColor = texture(uTexture, vTextureCoord);
}
`});var Id,Vy=f(()=>{Id=`struct GlobalFilterUniforms {
  uInputSize: vec4<f32>,
  uInputPixel: vec4<f32>,
  uInputClamp: vec4<f32>,
  uOutputFrame: vec4<f32>,
  uGlobalFrame: vec4<f32>,
  uOutputTexture: vec4<f32>,
};

@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler: sampler;

struct VSOutput {
  @builtin(position) position: vec4<f32>,
  @location(0) uv: vec2<f32>
};

fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

@vertex
fn mainVertex(
  @location(0) aPosition: vec2<f32>,
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
) -> @location(0) vec4<f32> {
    return textureSample(uTexture, uSampler, uv);
}
`});var lc,$y=f(()=>{$r();Ei();ac();Hy();Wy();Vy();lc=class extends wt{constructor(){let e=Xe.from({vertex:{source:Id,entryPoint:"mainVertex"},fragment:{source:Id,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=Fe.from({vertex:Ny,fragment:zy,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}});var se,Yr=f(()=>{"use strict";se=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(se||{})});var Ye,Pi=f(()=>{Oe();Ue();Yr();Ye=class extends le{constructor(e){let{data:t,size:r}=e,{usage:s,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=K("buffer"),this._resourceType="buffer",this._resourceId=K("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,r??(r=t?.byteLength);let a=!!t;this.descriptor={size:r,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&se.STATIC)}set static(e){e?this.descriptor.usage|=se.STATIC:this.descriptor.usage&=~se.STATIC}setDataWithSize(e,t,r){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===e){r&&this.emit("update",this);return}let s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){!this.shrinkToFit&&s&&e.byteLength<s.byteLength?r&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=K("resource"),this.emit("change",this));return}r&&this.emit("update",this)}update(e,t){this._updateSize=e??this._updateSize,this._updateOffset=t||0,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.destroyed||(this._resourceId=K("resource"),this.emit("change",this))}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}});function Gd(i,e){if(!(i instanceof Ye)){let t=e?se.INDEX:se.VERTEX;i instanceof Array&&(e?(i=new Uint32Array(i),t=se.INDEX|se.COPY_DST):(i=new Float32Array(i),t=se.VERTEX|se.COPY_DST)),i=new Ye({data:i,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return i}var Xy=f(()=>{Pi();Yr()});function Yy(i,e,t){let r=i.getAttribute(e);if(!r)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;let s=r.buffer.data,n=1/0,o=1/0,a=-1/0,l=-1/0,c=s.BYTES_PER_ELEMENT,h=(r.offset||0)/c,u=(r.stride||8)/c;for(let d=h;d<s.length;d+=u){let p=s[d],m=s[d+1];p>a&&(a=p),m>l&&(l=m),p<n&&(n=p),m<o&&(o=m)}return t.minX=n,t.minY=o,t.maxX=a,t.maxY=l,t}var Ky=f(()=>{"use strict"});function GE(i){return(i instanceof Ye||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=Gd(i.buffer,!1),i}var ht,ki=f(()=>{Oe();lt();Ue();de();Pi();Xy();Ky();ht=class extends le{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=K("geometry"),this._layoutKey=0,this.instanceCount=1,this.indexCount=0,this._bounds=new fe,this._boundsDirty=!0,this._vertexCount=0,this._vertexCountDirty=!0;let{attributes:t,indexBuffer:r,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(let n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,this.indexCount=e.indexCount??0,r&&this.addIndex(r),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this._vertexCountDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}get vertexCount(){if(!this._vertexCountDirty)return this._vertexCount;this._vertexCountDirty=!1;let e=this.attributes;for(let t in e){let r=e[t];if(r.instance)continue;let s=r.buffer;return this._vertexCount=s.data.length/(r.stride/4||r.size),this._vertexCount}return this._vertexCount=0,0}getSize(){return B("8.20.0","Geometry.getSize is deprecated, please use Geometry.vertexCount instead."),this.vertexCount}addAttribute(e,t){let r=GE(t);this.buffers.indexOf(r.buffer)===-1&&(this.buffers.push(r.buffer),r.buffer.on("update",this.onBufferUpdate,this),r.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=r,this._vertexCountDirty=!0}addIndex(e){this.indexBuffer=Gd(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Yy(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit("destroy",this);for(let t of this.buffers)t.off("update",this.onBufferUpdate,this),t.off("change",this.onBufferUpdate,this),e&&t.destroy();this.unload(),this.removeAllListeners(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}});var FE,Fd,Jn,jy=f(()=>{P();$y();oe();Xr();ki();Tt();ye();wr();ar();lt();md();ie();FE=new ht({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),Fd=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new fe,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},Jn=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Me({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new qe({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,r=e.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=e.container,s.outputRenderSurface=t.renderTarget.renderSurface;let n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(r.every(h=>!h.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(e,l),this._calculateFilterBounds(s,t.renderTarget.rootViewPort,a,o,1),s.skip)return;let c=this._getPreviousFilterData();this._setupFilterTextures(s,l,t,c)}generateFilteredTexture({texture:e,filters:t}){if(t.every(h=>!h.enabled))return e;let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=t;let s=e.source,n=s.resolution,o=s.antialias,a=r.bounds;if(a.clear(),a.addRect(e.frame),this._calculateFilterBounds(r,a.rectangle,o,n,0),r.skip)return this._popFilterData(),e;r.outputRenderSurface=ce.getOptimalTexture({width:a.width,height:a.height,resolution:r.resolution,antialias:r.antialias}),r.backTexture=F.EMPTY,r.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let c=r.outputRenderSurface;return c.source.alphaMode="premultiplied-alpha",this._popFilterData(),c}pop(){let e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&ce.returnTexture(t.backTexture),ce.returnTexture(t.inputTexture))}getBackTexture(e,t,r){let s=e.colorTexture.source._resolution,n=ce.getOptimalTexture({width:t.width,height:t.height,resolution:s}),o=t.minX,a=t.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(t.width*s),c=Math.ceil(t.height*s);return this.renderer.renderTarget.copyToTexture(e,n,{x:o,y:a},{width:l,height:c},{x:0,y:0}),n}applyFilter(e,t,r,s){let n=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,c=this._findClosestFilterData(),h=c?c.inputTexture.source._resolution:n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=0,d=0;l&&c&&(u=c.bounds.minX,d=c.bounds.minY),this._updateFilterUniforms(t,r,o,u,d,h,l,s);let p=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,t,n)}calculateSpriteMatrix(e,t){let r=this._activeFilterData,s=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(I.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/t.texture.orig.width,1/t.texture.orig.height),s.translate(t.anchor.x,t.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new lc),this._passthroughFilter}_setupBindGroupsAndRender(e,t,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:FE,shader:e,state:e._state,topology:"triangle-list"}),r.type===He.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,r,s){if(e.backTexture=F.EMPTY,e.inputTexture=ce.getOptimalTexture({width:t.width,height:t.height,resolution:e.resolution,antialias:e.antialias}),e.blendRequired){r.renderTarget.finishRenderPass();let n=r.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,s?.bounds)}r.renderTarget.bind({target:e.inputTexture,clear:!0}),r.globalUniforms.push({offset:t})}_updateFilterUniforms(e,t,r,s,n,o,a,l){let c=this._filterGlobalUniforms.uniforms,h=c.uOutputFrame,u=c.uInputSize,d=c.uInputPixel,p=c.uInputClamp,m=c.uGlobalFrame,x=c.uOutputTexture;a?(h[0]=r.bounds.minX-s,h[1]=r.bounds.minY-n):(h[0]=0,h[1]=0),h[2]=e.frame.width,h[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[1],d[0]=e.source.pixelWidth,d[1]=e.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],p[0]=.5*d[2],p[1]=.5*d[3],p[2]=e.frame.width*u[2]-.5*d[2],p[3]=e.frame.height*u[3]-.5*d[3];let y=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=s*o,m[1]=n*o,m[2]=y.source.width*o,m[3]=y.source.height*o,t instanceof F&&(t.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind({target:t,clear:!!l}),t instanceof F?(x[0]=t.frame.width,x[1]=t.frame.height):(x[0]=g.width,x[1]=g.height),x[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findClosestFilterData(){for(let e=this._filterStackIndex-1;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_calculateFilterArea(e,t){if(e.renderables?ec(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;s&&t.applyMatrix(s)}}_applyFiltersToTexture(e,t){let r=e.inputTexture,s=e.bounds,n=e.filters,o=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===a)n[o].apply(this,r,e.outputRenderSurface,t);else{let l=e.inputTexture,c=ce.getOptimalTexture({width:s.width,height:s.height,resolution:l.source._resolution}),h=c;for(let u=o;u<a;u++){let d=n[u];if(!d.enabled)continue;d.apply(this,l,h,!0);let p=l;l=h,h=p}n[a].apply(this,l,e.outputRenderSurface,t),ce.returnTexture(c)}}_calculateFilterBounds(e,t,r,s,n){let o=this.renderer,a=e.bounds,l=e.filters,c=1/0,h=0,u=!0,d=!1,p=!1,m=!0,x=-1,y=-1;for(let g=0;g<l.length;g++){let v=l[g];if(!v.enabled)continue;if(x===-1&&(x=g),y=g,c=Math.min(c,v.resolution==="inherit"?s:v.resolution),h+=v.padding,v.antialias==="off"?u=!1:v.antialias==="inherit"&&u&&(u=r),v.clipToViewport||(m=!1),!!!(v.compatibleRenderers&o.type)){p=!1;break}if(v.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){G("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),p=!1;break}p=!0,d||(d=v.blendRequired)}if(!p){e.skip=!0;return}if(m&&a.fitBounds(0,t.width/s,0,t.height/s),a.scale(c).ceil().scale(1/c).pad((h|0)*n),!a.isPositive){e.skip=!0;return}e.antialias=u,e.resolution=c,e.blendRequired=d,e.firstEnabledIndex=x,e.lastEnabledIndex=y}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){for(let e=this._filterStackIndex-2;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new Fd),this._filterStackIndex++,e}};Jn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"}});var Dd=f(()=>{P();iy();sy();jy();H.add(Jn,Kn);H.add(jn)});var DE={};var qy=f(()=>{d0();f0();y0();Ul();Yl();Dd()});var Zy,Qy=f(()=>{P();Zy={extension:{type:b.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>(qy(),DE))}}});var OE={};var Jy=f(()=>{Ul();Yl();Dd()});var eb,tb=f(()=>{P();eb={extension:{type:b.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(Jy(),OE))}}});async function rb(i){if(!i)for(let e=0;e<Od.length;e++){let t=Od[e];if(t.value.test()){await t.value.load();return}}}var Od,ib=f(()=>{P();Od=[];H.handleByNamedList(b.Environment,Od)});function cc(){if(typeof eo=="boolean")return eo;try{eo=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{eo=!1}return eo}var eo,Ld=f(()=>{"use strict"});function fc(i,e,t=2){let r=e&&e.length,s=r?e[0]*t:i.length;io.size&&io.clear();let n=ab(i,0,s,t,!0),o=[];if(!n||n.next===n.prev)return o;let a=0,l=0,c=0;if(r&&(n=zE(i,e,n,t)),i.length>80*t){a=i[0],l=i[1];let h=a,u=l;for(let d=t;d<s;d+=t){let p=i[d],m=i[d+1];p<a&&(a=p),m<l&&(l=m),p>h&&(h=p),m>u&&(u=m)}c=Math.max(h-a,u-l),c=c!==0?32767/c:0}return Nd(n,o,a,l,c),o}function ab(i,e,t,r,s){let n=null;if(s===tP(i,e,t,r)>0)for(let o=e;o<t;o+=r)n=ob(o/r|0,i[o],i[o+1],n);else for(let o=t-r;o>=e;o-=r)n=ob(o/r|0,i[o],i[o+1],n);return n&&so(n,n.next)&&(oo(n),n=n.next),n}function Ri(i,e=i){let t=e===i,r=i,s;do s=!1,r!==r.next&&(io.size===0||!io.has(r))&&(so(r,r.next)||We(r.prev,r,r.next)===0)?((t||r===e)&&(e=r.prev),Ud=!0,oo(r),r=r.prev,s=!0):(t||r!==e)&&(r=r.next,s=!t);while(s||r!==e);return e}function Nd(i,e,t,r,s){s&&jE(i,t,r,s);let n=i,o=!1;for(;i.prev!==i.next;){let a=i.prev,l=i.next;if(We(a,i,l)<0&&(s?UE(i,t,r,s):LE(i))){e.push(a.i,i.i,l.i),oo(i),i=l,n=l;continue}if(i=l,i===n){if(Ud=!1,i=Ri(i),Ud){n=i;continue}if(!o){i=NE(i,e),n=i,o=!0;continue}HE(i,e,t,r,s);break}}}function LE(i){let e=i.prev,t=i,r=i.next,s=e.x,n=t.x,o=r.x,a=e.y,l=t.y,c=r.y,h=Math.min(s,n,o),u=Math.min(a,l,c),d=Math.max(s,n,o),p=Math.max(a,l,c),m=r.next;for(;m!==e;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&!(s===m.x&&a===m.y)&&pc(s,a,n,l,o,c,m.x,m.y)&&We(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function UE(i,e,t,r){let s=i.prev,n=i,o=i.next,a=s.x,l=n.x,c=o.x,h=s.y,u=n.y,d=o.y,p=Math.min(a,l,c),m=Math.min(h,u,d),x=Math.max(a,l,c),y=Math.max(h,u,d),g=Vd(p,m,e,t,r),v=Vd(x,y,e,t,r),_=i.prevZ;for(;_&&_.z>=g;){if(_.x>=p&&_.x<=x&&_.y>=m&&_.y<=y&&_!==o&&!(a===_.x&&h===_.y)&&pc(a,h,l,u,c,d,_.x,_.y)&&We(_.prev,_,_.next)>=0)return!1;_=_.prevZ}let S=i.nextZ;for(;S&&S.z<=v;){if(S.x>=p&&S.x<=x&&S.y>=m&&S.y<=y&&S!==o&&!(a===S.x&&h===S.y)&&pc(a,h,l,u,c,d,S.x,S.y)&&We(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function NE(i,e){let t=i,r=!1;do{let s=t.prev,n=t.next.next;hb(s,t,t.next,n,!1)&&no(s,n)&&no(n,s)&&(e.push(s.i,t.i,n.i),oo(t),oo(t.next),t=i=n,r=!0),t=t.next}while(t!==i);return r?Ri(t):t}function HE(i,e,t,r,s){let n=i;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&QE(n,o)){let a=ub(n,o);n=Ri(n,n.next),a=Ri(a,a.next),Nd(n,e,t,r,s),Nd(a,e,t,r,s);return}o=o.next}n=n.next}while(n!==i)}function zE(i,e,t,r){let s=[];for(let n=0,o=e.length;n<o;n++){let a=e[n]*r,l=n<o-1?e[n+1]*r:i.length,c=ab(i,a,l,r,!1);c===c.next&&io.add(c),s.push(ZE(c))}s.sort(WE),$E(i.length/r,e.length),cb(t,t),Hd=!0;for(let n=0;n<s.length;n++)t=VE(s[n],t);return Hd=!1,Ri(t)}function WE(i,e){return i.x-e.x||i.y-e.y||(i.next.y-i.y)/(i.next.x-i.x)-(e.next.y-e.y)/(e.next.x-e.x)}function VE(i,e){let t=YE(i,e);if(!t)return e;let r=ub(t,i),s=r.next;return cb(t,s.next),Ri(r,r.next),Ri(t,t.next)}function $E(i,e){let t=Math.ceil((i+2*e)/lb)+e+2;Be.length<t*4&&(Be=new Float64Array(t*4)),dc=0}function cb(i,e){let t=i;do{let r=dc++;zd[r]=t;let s=t.x,n=t.y,o=t.x,a=t.y,l=0;do{let h=t.next;t.z=r,h.x<s&&(s=h.x),h.x>o&&(o=h.x),h.y<n&&(n=h.y),h.y>a&&(a=h.y),t=h}while(++l<lb&&t!==e);Wd[r]=t;let c=r*4;Be[c]=s,Be[c+1]=n,Be[c+2]=o,Be[c+3]=a}while(t!==e)}function XE(i,e){let t=i.z*4;e.x<Be[t]&&(Be[t]=e.x),e.y<Be[t+1]&&(Be[t+1]=e.y),e.x>Be[t+2]&&(Be[t+2]=e.x),e.y>Be[t+3]&&(Be[t+3]=e.y)}function sb(i){let e=Wd[i];for(;e.prev.next!==e;)e=e.next;return Wd[i]=e,e}function nb(i){let e=zd[i];for(;e.prev.next!==e;)e=e.next;return zd[i]=e,e}function YE(i,e){let t=e,r=i.x,s=i.y,n=-1/0,o;if(so(i,t))return t;for(let d=0,p=0;d<dc;d++,p+=4){if(s<Be[p+1]||s>Be[p+3]||Be[p]>r||Be[p+2]<=n)continue;let m=sb(d);t=nb(d);do{if(t.prev.next===t){if(so(i,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){let x=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=r&&x>n&&(n=x,o=t.x<t.next.x?t:t.next,x===r))return o}}t=t.next}while(t!==m)}if(!o)return null;let a=o.x,l=o.y,c=Math.min(s,l),h=Math.max(s,l),u=1/0;for(let d=0,p=0;d<dc;d++,p+=4){if(Be[p+2]<a||Be[p]>r||Be[p+3]<c||Be[p+1]>h)continue;let m=sb(d);t=nb(d);do{if(t.prev.next===t&&r>=t.x&&t.x>=a&&r!==t.x&&pc(s<l?r:n,s,a,l,s<l?n:r,s,t.x,t.y)){let x=Math.abs(s-t.y)/(r-t.x);(no(t,i)||t.y===s&&t.next.y===s&&t.next.x>r)&&(x<u||x===u&&(t.x>o.x||t.x===o.x&&KE(o,t)))&&(o=t,u=x)}t=t.next}while(t!==m)}return o}function KE(i,e){return We(i.prev,i,e.prev)<0&&We(e.next,i,i.next)<0}function jE(i,e,t,r){let s=i,n=0;do s.z=Vd(s.x,s.y,e,t,r),Mt[n++]=s,s=s.next;while(s!==i);qE(n);let o=null;for(let a=0;a<n;a++){let l=Mt[a];l.prevZ=o,o&&(o.nextZ=l),o=l}o.nextZ=null,Mt.fill(null,0,n),Ms.fill(null,0,n)}function qE(i){if(i<=32){for(let e=1;e<i;e++){let t=Mt[e],r=t.z,s=e-1;for(;s>=0&&Mt[s].z>r;)Mt[s+1]=Mt[s],s--;Mt[s+1]=t}return}Ai.length<i&&(Ai=new Uint32Array(i),to=new Uint32Array(i),Ms=new Array(i));for(let e=0;e<i;e++)Ai[e]=Mt[e].z;hc(i,Mt,Ai,Ms,to,0),hc(i,Ms,to,Mt,Ai,8),hc(i,Mt,Ai,Ms,to,16),hc(i,Ms,to,Mt,Ai,24)}function hc(i,e,t,r,s,n){ro.fill(0);for(let a=0;a<i;a++)ro[t[a]>>>n&255]++;let o=0;for(let a=0;a<256;a++){let l=ro[a];ro[a]=o,o+=l}for(let a=0;a<i;a++){let l=t[a],c=ro[l>>>n&255]++;r[c]=e[a],s[c]=l}}function Vd(i,e,t,r,s){return i=(i-t)*s|0,e=(e-r)*s|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 ZE(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function pc(i,e,t,r,s,n,o,a){return(s-o)*(e-a)>=(i-o)*(n-a)&&(i-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(s-o)*(r-a)}function QE(i,e){let t=so(i,e)&&We(i.prev,i,i.next)>0&&We(e.prev,e,e.next)>0;return i.next.i!==e.i&&(t||no(i,e)&&no(e,i)&&(We(i.prev,i,e.prev)!==0||We(i,e.prev,e)!==0))&&!JE(i,e)&&(t||eP(i,e))}function We(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function so(i,e){return i.x===e.x&&i.y===e.y}function hb(i,e,t,r,s=!0){let n=We(i,e,t),o=We(i,e,r),a=We(t,r,i),l=We(t,r,e);return(n>0&&o<0||n<0&&o>0)&&(a>0&&l<0||a<0&&l>0)?!0:s?!!(n===0&&uc(i,t,e)||o===0&&uc(i,r,e)||a===0&&uc(t,i,r)||l===0&&uc(t,e,r)):!1}function uc(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 JE(i,e){let t=Math.min(i.x,e.x),r=Math.max(i.x,e.x),s=Math.min(i.y,e.y),n=Math.max(i.y,e.y),o=i;do{let a=o.next;if(o.x>r&&a.x>r||o.x<t&&a.x<t||o.y>n&&a.y>n||o.y<s&&a.y<s){o=a;continue}if(o.i!==i.i&&a.i!==i.i&&o.i!==e.i&&a.i!==e.i&&hb(o,a,i,e))return!0;o=a}while(o!==i);return!1}function no(i,e){return We(i.prev,i,i.next)<0?We(i,e,i.next)>=0&&We(i,i.prev,e)>=0:We(i,e,i.prev)<0||We(i,i.next,e)<0}function eP(i,e){let t=i,r=!1,s=(i.x+e.x)/2,n=(i.y+e.y)/2;do{let o=t.next;t.y>n!=o.y>n&&s<(o.x-t.x)*(n-t.y)/(o.y-t.y)+t.x&&(r=!r),t=o}while(t!==i);return r}function ub(i,e){let t=$d(i.i,i.x,i.y),r=$d(e.i,e.x,e.y),s=i.next,n=e.prev;return i.next=e,e.prev=i,t.next=s,s.prev=t,r.next=t,t.prev=r,n.next=r,r.prev=n,r}function ob(i,e,t,r){let s=$d(i,e,t);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function oo(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),Hd&&XE(i.prev,i.next)}function $d(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function tP(i,e,t,r){let s=0;for(let n=e,o=t-r;n<t;n+=r)s+=(i[o]-i[n])*(i[n+1]+i[o+1]),o=n;return s}var io,Ud,Hd,lb,Be,dc,zd,Wd,Mt,Ms,Ai,to,ro,db=f(()=>{io=new Set,Ud=!1;Hd=!1;lb=16,Be=new Float64Array(0),dc=0,zd=[],Wd=[];Mt=[],Ms=[],Ai=new Uint32Array(0),to=new Uint32Array(0),ro=new Uint32Array(256)});var pb,fb=f(()=>{db();Oe();pb=fc.default||fc});var Ce,Cs=f(()=>{"use strict";Ce=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(Ce||{})});var Es,Xd=f(()=>{"use strict";Es=class{constructor(e){this.items=[],this._name=e}emit(e,t,r,s,n,o,a,l){let{name:c,items:h}=this;for(let u=0,d=h.length;u<d;u++)h[u][c](e,t,r,s,n,o,a,l);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){let t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}});var rP,mb,cr,Ps=f(()=>{Je();ib();Vt();Ld();Ue();de();xi();Cs();Xd();Oe();rP=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],mb=class gb extends le{constructor(e){super(),this.tick=0,this.uid=K("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;let t=[...rP,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){let t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await rb(t),!t&&this.config.loaders&&await Promise.all(this.config.loaders.map(r=>r.value.load())),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let r in this._systemsHash)e={...this._systemsHash[r].constructor.defaultOptions,...e};e={...gb.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let r=0;r<this.runners.init.items.length;r++)await this.runners.init.items[r].init(e);this._initOptions=e}render(e,t){this.tick++;let r=e;if(r instanceof ge&&(r={container:r},t&&(B($,"passing a second argument is deprecated, please use render options instead"),r.target=t.renderTexture)),r.target||(r.target=this.view.renderTarget),r.target===this.view.renderTarget&&(this._lastObjectRendered=r.container,r.clearColor??(r.clearColor=this.background.colorRgba),r.clear??(r.clear=this.background.clearBeforeRender)),r.clearColor){let s=Array.isArray(r.clearColor)&&r.clearColor.length===4;r.clearColor=s?r.clearColor:q.shared.setValue(r.clearColor).toArray()}r.transform||(r.container.updateLocalTransform(),r.transform=r.container.localTransform),r.container.visible&&(r.container.enableRenderGroup(),this.runners.prerender.emit(r),this.runners.renderStart.emit(r),this.runners.render.emit(r),this.runners.renderEnd.emit(r),this.runners.postrender.emit(r))}resize(e,t,r){let s=this.view.resolution;this.view.resize(e,t,r),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),r!==void 0&&r!==s&&this.runners.resolutionChange.emit(r)}clear(e={}){let t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=Ce.ALL);let{clear:r,clearColor:s,target:n,mipLevel:o,layer:a}=e;q.shared.setValue(s??this.background.colorRgba),t.renderTarget.clear(n,r,q.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(t=>{this.runners[t]=new Es(t)})}_addSystems(e){let t;for(t in e){let r=e[t];this._addSystem(r.value,r.name)}}_addSystem(e,t){let r=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=r,this._systemsHash[t]=r;for(let s in this.runners)this.runners[s].add(r);return this}_addPipes(e,t){let r=t.reduce((s,n)=>(s[n.name]=n.value,s),{});e.forEach(s=>{let n=s.value,o=s.name,a=r[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&Ft.release(),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!cc())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};mb.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};cr=mb});function xb(i){return mc!==void 0||(mc=(()=>{let e={stencil:!0,failIfMajorPerformanceCaveat:i??cr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!W.get().getWebGLRenderingContext())return!1;let r=W.get().createCanvas().getContext("webgl",e),s=!!r?.getContextAttributes()?.stencil;if(r){let n=r.getExtension("WEBGL_lose_context");n&&n.loseContext()}return r=null,s}catch{return!1}})()),mc}var mc,yb=f(()=>{we();Ps()});async function bb(i={}){return gc!==void 0||(gc=await(async()=>{let e=W.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),gc}var gc,_b=f(()=>{we()});function ks(i,e,t){let r=2166136261;for(let s=0;s<e;s++)r^=i[s].uid,r=Math.imul(r,16777619),r>>>=0;return vb[r]||iP(i,e,r,t)}function iP(i,e,t,r){let s={},n=0;for(let a=0;a<r;a++){let l=a<e?i[a]:F.EMPTY.source;s[n++]=l.source,s[n++]=l.style}let o=new qe(s);return vb[t]=o,o}var vb,xc=f(()=>{Xr();ye();vb={}});function Yd(i,e,t){if(i)for(let r in i){let s=r.toLocaleLowerCase(),n=e[s];if(n){let o=i[r];r==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&n.push(`//----${t}----//`),n.push(o)}else G(`${r} placement hook does not exist in shader`)}}var Sb=f(()=>{ie()});function Kd(i){let e={};return(i.match(sP)?.map(r=>r.replace(/[{()}]/g,""))??[]).forEach(r=>{e[r]=[]}),e}var sP,Tb=f(()=>{"use strict";sP=/\{\{(.*?)\}\}/g});function wb(i,e){let t,r=/@in\s+([^;]+);/g;for(;(t=r.exec(i))!==null;)e.push(t[1])}function jd(i,e,t=!1){let r=[];wb(e,r),i.forEach(a=>{a.header&&wb(a.header,r)});let s=r;t&&s.sort();let n=s.map((a,l)=>`       @location(${l}) ${a},`).join(`
`),o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
${n}
`),o}var Mb=f(()=>{"use strict"});function Cb(i,e){let t,r=/@out\s+([^;]+);/g;for(;(t=r.exec(i))!==null;)e.push(t[1])}function nP(i){let t=/\b(\w+)\s*:/g.exec(i);return t?t[1]:""}function oP(i){let e=/@.*?\s+/g;return i.replace(e,"")}function Eb(i,e){let t=[];Cb(e,t),i.forEach(l=>{l.header&&Cb(l.header,t)});let r=0,s=t.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${r++}) ${l}`).join(`,
`),n=t.sort().map(l=>`       var ${oP(l)};`).join(`
`),o=`return VSOutput(
            ${t.sort().map(l=>` ${nP(l)}`).join(`,
`)});`,a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
${s}
`),a=a.replace("{{start}}",`
${n}
`),a=a.replace("{{return}}",`
${o}
`),a}var Pb=f(()=>{"use strict"});function qd(i,e){let t=i;for(let r in e){let s=e[r];s.join(`
`).length?t=t.replace(`{{${r}}}`,`//-----${r} START-----//
${s.join(`
`)}
//----${r} FINISH----//`):t=t.replace(`{{${r}}}`,"")}return t}var kb=f(()=>{"use strict"});function Ab({template:i,bits:e}){let t=Bb(i,e);if(Kr[t])return Kr[t];let{vertex:r,fragment:s}=lP(i,e);return Kr[t]=Ib(r,s,e),Kr[t]}function Rb({template:i,bits:e}){let t=Bb(i,e);return Kr[t]||(Kr[t]=Ib(i.vertex,i.fragment,e)),Kr[t]}function lP(i,e){let t=e.map(o=>o.vertex).filter(o=>!!o),r=e.map(o=>o.fragment).filter(o=>!!o),s=jd(t,i.vertex,!0);s=Eb(t,s);let n=jd(r,i.fragment,!0);return{vertex:s,fragment:n}}function Bb(i,e){return e.map(t=>(Zd.has(t)||Zd.set(t,aP++),Zd.get(t))).sort((t,r)=>t-r).join("-")+i.vertex+i.fragment}function Ib(i,e,t){let r=Kd(i),s=Kd(e);return t.forEach(n=>{Yd(n.vertex,r,n.name),Yd(n.fragment,s,n.name)}),{vertex:qd(i,r),fragment:qd(e,s)}}var Kr,Zd,aP,Gb=f(()=>{Sb();Tb();Mb();Pb();kb();Kr=Object.create(null),Zd=new Map,aP=0});var Fb,Db,Ob,Lb,Ub=f(()=>{"use strict";Fb=`
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        var position = aPosition;
        var uv = aUV;

        {{start}}

        vColor = vec4<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);

        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`,Db=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;

    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {

        {{start}}

        var outColor:vec4<f32>;

        {{main}}

        var finalColor:vec4<f32> = outColor * vColor;

        {{end}}

        return finalColor;
      };
`,Ob=`
    in vec2 aPosition;
    in vec2 aUV;

    out vec4 vColor;
    out vec2 vUV;

    {{header}}

    void main(void){

        mat3 worldTransformMatrix = uWorldTransformMatrix;
        mat3 modelMatrix = mat3(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        vec2 position = aPosition;
        vec2 uv = aUV;

        {{start}}

        vColor = vec4(1.);

        {{main}}

        vUV = uv;

        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;

        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);

        vColor *= uWorldColorAlpha;

        {{end}}
    }
`,Lb=`

    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {

        {{start}}

        vec4 outColor;

        {{main}}

        finalColor = outColor * vColor;

        {{end}}
    }
`});var Nb,Hb,zb=f(()=>{"use strict";Nb={name:"global-uniforms-bit",vertex:{header:`
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `}},Hb={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}}});function jr({bits:i,name:e}){let t=Ab({template:{fragment:Db,vertex:Fb},bits:[Nb,...i]});return Xe.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function qr({bits:i,name:e}){return new Fe({name:e,...Rb({template:{vertex:Ob,fragment:Lb},bits:[Hb,...i]})})}var Bi=f(()=>{$r();Ei();Gb();Ub();zb()});var As,Rs,ao=f(()=>{"use strict";As={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},Rs={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}}});function cP(i){let e=[];if(i===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let t=0;for(let r=0;r<i;r++)e.push(`@group(1) @binding(${t++}) var textureSource${r+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${r+1}: sampler;`)}return e.join(`
`)}function hP(i){let e=[];if(i===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<i;t++)t===i-1?e.push("  default:{"):e.push(`  case ${t}:{`),e.push(`      outColor = textureSampleGrad(textureSource${t+1}, textureSampler${t+1}, vUV, uvDx, uvDy);`),e.push("      break;}");e.push("}")}return e.join(`
`)}function Bs(i){return Qd[i]||(Qd[i]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;

                ${cP(i)}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);

                ${hP(i)}
            `}}),Qd[i]}function uP(i){let e=[];for(let t=0;t<i;t++)t>0&&e.push("else"),t<i-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(`	outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
`)}function Is(i){return Jd[i]||(Jd[i]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;

            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;

                uniform sampler2D uTextures[${i}];

            `,main:`

                ${uP(i)}
            `}}),Jd[i]}var Qd,Jd,lo=f(()=>{"use strict";Qd={};Jd={}});var co,Wb,yc,ho=f(()=>{"use strict";co={name:"local-uniform-bit",vertex:{header:`

            struct LocalUniforms {
                uTransformMatrix:mat3x3<f32>,
                uColor:vec4<f32>,
                uRound:f32,
            }

            @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `}},Wb={...co,vertex:{...co.vertex,header:co.vertex.header.replace("group(1)","group(2)")}},yc={name:"local-uniform-bit",vertex:{header:`

            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix = uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `}}});var Zr,Qr,Ii=f(()=>{"use strict";Zr={name:"round-pixels-bit",vertex:{header:`
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},Qr={name:"round-pixels-bit",vertex:{header:`
            vec2 roundPixels(vec2 position, vec2 targetSize)
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}}});var uo,Vb=f(()=>{P();oe();xc();Bi();ao();lo();ho();Ii();lr();Tt();uo=class{constructor(){this._maxTextures=0}contextChange(e){let t=new Me({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=e.limits.maxBatchableTextures;let r=jr({name:"graphics",bits:[As,Bs(this._maxTextures),Wb,Zr]});this.shader=new De({gpuProgram:r,resources:{localUniforms:t}})}execute(e,t){let r=t.context,s=r.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r),c=n.encoder;c.setGeometry(a.geometry,s.gpuProgram);let h=n.globalUniforms.bindGroup;c.setBindGroup(0,h,s.gpuProgram);let u=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);c.setBindGroup(2,u,s.gpuProgram);let d=l.instructions,p=null;for(let m=0;m<l.instructionSize;m++){let x=d[m];if(x.topology!==p&&(p=x.topology,c.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,e.state,x.topology,s._overrides)),s.groups[1]=x.bindGroup,!x.gpuBindGroup){let y=x.textures;x.bindGroup=ks(y.textures,y.count,this._maxTextures),x.gpuBindGroup=n.bindGroup.getBindGroup(x.bindGroup,s.gpuProgram,1)}c.setBindGroup(1,x.bindGroup,s.gpuProgram),c.renderPassEncoder.drawIndexed(x.size,1,x.start)}}destroy(){this.shader.destroy(),this.shader=null}};uo.extension={type:[b.WebGPUPipesAdaptor],name:"graphics"}});var $b,Xb,ep=f(()=>{"use strict";$b={name:"texture-bit",vertex:{header:`

        struct TextureUniforms {
            uTextureMatrix:mat3x3<f32>,
        }

        @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
        `,main:`
            uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
            @group(2) @binding(0) var uTexture: texture_2d<f32>;
            @group(2) @binding(1) var uSampler: sampler;


        `,main:`
            outColor = textureSample(uTexture, uSampler, vUV);
        `}},Xb={name:"texture-bit",vertex:{header:`
            uniform mat3 uTextureMatrix;
        `,main:`
            uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
        uniform sampler2D uTexture;


        `,main:`
            outColor = texture(uTexture, vUV);
        `}}});var po,Yb=f(()=>{P();oe();Bi();ho();Ii();ep();lr();ye();ie();po=class{init(){let e=jr({name:"mesh",bits:[co,$b,Zr]});this._shader=new De({gpuProgram:e,resources:{uTexture:F.EMPTY._source,uSampler:F.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(e,t){let r=e.renderer,s=t._shader;if(!s)s=this._shader,s.groups[2]=r.texture.getTextureBindGroup(t.texture);else if(!s.gpuProgram){G("Mesh shader has no gpuProgram",t.shader);return}let n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=r.globalUniforms.bindGroup),n.autoAssignLocalUniforms){let o=e.localUniforms;s.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}r.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(),this._shader=null}};po.extension={type:[b.WebGPUPipesAdaptor],name:"mesh"}});var bc,fo,Kb=f(()=>{P();Kt();xc();bc=ze.for2d(),fo=class{start(e,t,r){let s=e.renderer,n=s.encoder,o=r.gpuProgram;this._shader=r,this._geometry=t,n.setGeometry(t,o),bc.blendMode="normal",s.pipeline.getPipeline(t,o,bc,void 0,r._overrides);let a=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(e,t){let r=this._shader.gpuProgram,s=e.renderer,n=s.encoder;if(!t.bindGroup){let l=t.textures;t.bindGroup=ks(l.textures,l.count,s.limits.maxBatchableTextures)}bc.blendMode=t.blendMode;let o=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,bc,t.topology,this._shader._overrides);t.bindGroup._touch(s.gc.now),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(t.size,1,t.start)}};fo.extension={type:[b.WebGPUPipesAdaptor],name:"batch"}});var Gi,tp=f(()=>{P();Gi=class{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}};Gi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"customRender"}});var Jr,_c=f(()=>{"use strict";Jr=class{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}});function mo(i,e){let t=i.instructionSet,r=t.instructions;for(let s=0;s<t.instructionSize;s++){let n=r[s];e[n.renderPipeId].execute(n)}}var rp=f(()=>{"use strict"});var Fi,ip=f(()=>{P();oe();br();_c();rp();Fi=class{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(Te.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){let r=e._batchableRenderGroup??(e._batchableRenderGroup=Te.get(Jr));r.renderable=e.root,r.transform=e.root.relativeGroupTransform,r.texture=e.texture,r.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(r,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;let t=new I().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),mo(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),mo(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}};Fi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"renderGroup"}});function go(i,e){e||(e=0);for(let t=e;t<i.length&&i[t];t++)i[t]=null}var sp=f(()=>{"use strict"});function np(i,e=!1){pP(i);let t=i.childrenToUpdate,r=i.updateTick++;for(let s in t){let n=Number(s),o=t[s],a=o.list,l=o.index;for(let c=0;c<l;c++){let h=a[c];h.parentRenderGroup===i&&h.relativeRenderGroupDepth===n&&Zb(h,r,0)}go(a,l),o.index=0}if(e)for(let s=0;s<i.renderGroupChildren.length;s++)np(i.renderGroupChildren[s],e)}function pP(i){let e=i.root,t;if(i.renderGroupParent){let r=i.renderGroupParent;i.worldTransform.appendFrom(e.relativeGroupTransform,r.worldTransform),i.worldColor=cs(e.groupColor,r.worldColor),t=e.groupAlpha*r.worldAlpha}else i.worldTransform.copyFrom(e.localTransform),i.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,i.worldAlpha=t,i.worldColorAlpha=i.worldColor+((t*255|0)<<24)}function Zb(i,e,t){if(e===i.updateTick)return;i.updateTick=e,i.didChange=!1;let r=i.localTransform;i.updateLocalTransform();let s=i.parent;if(s&&!s.renderGroup?(t|=i._updateFlags,i.relativeGroupTransform.appendFrom(r,s.relativeGroupTransform),t&jb&&qb(i,s,t)):(t=i._updateFlags,i.relativeGroupTransform.copyFrom(r),t&jb&&qb(i,dP,t)),!i.renderGroup){let n=i.children,o=n.length;for(let c=0;c<o;c++)Zb(n[c],e,t);let a=i.parentRenderGroup,l=i;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function qb(i,e,t){if(t&fs){i.groupColor=cs(i.localColor,e.groupColor);let r=i.localAlpha*e.groupAlpha;r=r<0?0:r>1?1:r,i.groupAlpha=r,i.groupColorAlpha=i.groupColor+((r*255|0)<<24)}t&Dn&&(i.groupBlendMode=i.localBlendMode==="inherit"?e.groupBlendMode:i.localBlendMode),t&Mi&&(i.globalDisplayStatus=i.localDisplayStatus&e.globalDisplayStatus),i._updateFlags=0}var dP,jb,Qb=f(()=>{Vt();sp();Cu();dP=new ge,jb=Mi|fs|Dn});function Jb(i,e){let{list:t}=i.childrenRenderablesToUpdate,r=!1;for(let s=0;s<i.childrenRenderablesToUpdate.index;s++){let n=t[s];if(r=e[n.renderPipeId].validateRenderable(n),r)break}return i.structureDidChange=r,r}var e_=f(()=>{"use strict"});var fP,xo,t_=f(()=>{P();oe();wr();lt();sp();rp();Qb();e_();fP=new I,xo=class{constructor(e){this._renderer=e}render({container:e,transform:t}){let r=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let n=this._renderer,o=fP;t&&(o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));let a=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),mo(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=r,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let r=e.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(e.renderGroupChildren[r],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){let r=e.root.getLocalBounds(),s=this._renderer,n=e.textureOptions.resolution||s.view.resolution,o=e.textureOptions.antialias??s.view.antialias,a=e.textureOptions.scaleMode??"linear",l=e.texture;r.ceil(),e.texture&&ce.returnTexture(e.texture);let c=ce.getOptimalTexture({width:r.width,height:r.height,resolution:n,antialias:o,scaleMode:a});e.texture=c,e._textureBounds||(e._textureBounds=new fe),e._textureBounds.copyFrom(r),l!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(ce.returnTexture(e.texture),e.texture=null)}_updateRenderGroups(e){let t=this._renderer,r=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=r,e.structureDidChange?go(e.childrenRenderablesToUpdate.list,0):Jb(e,r),np(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let s=0;s<e.renderGroupChildren.length;s++)this._updateRenderGroups(e.renderGroupChildren[s])}_updateRenderables(e){let{list:t,index:r}=e.childrenRenderablesToUpdate;for(let s=0;s<r;s++){let n=t[s];n.didViewUpdate&&e.updateRenderable(n)}go(t,r)}_buildInstructions(e,t){let r=e.root,s=e.instructionSet;s.reset();let n=t.renderPipes?t:t.batch.renderer,o=n.renderPipes;o.batch.buildStart(s),o.blendMode.buildStart(),o.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(s,n,null),o.batch.buildEnd(s),o.blendMode.buildEnd(s)}};xo.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderGroup"}});var Di,op=f(()=>{P();_c();Di=class{constructor(e){this._renderer=e}addRenderable(e,t){let r=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){let t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){let t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=new Jr;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}};Di.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"sprite"}});var Gs,ap=f(()=>{Oe();Gs="8.22.0"});var yo,bo,lp=f(()=>{P();ap();yo=class{static init(){globalThis.__PIXI_APP_INIT__?.(this,Gs)}static destroy(){}};yo.extension=b.Application;bo=class{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Gs)}destroy(){this._renderer=null}};bo.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"initHook",priority:-10}});var _o,r_=f(()=>{"use strict";_o=class{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}});function vo(i,e,t,r){if(t??(t=0),r??(r=Math.min(i.byteLength-t,e.byteLength)),!(t&7)&&!(r&7)){let s=r/8;new Float64Array(e,0,s).set(new Float64Array(i,t,s))}else if(!(t&3)&&!(r&3)){let s=r/4;new Float32Array(e,0,s).set(new Float32Array(i,t,s))}else new Uint8Array(e).set(new Uint8Array(i,t,r))}var cp=f(()=>{"use strict"});var i_,_e,ei=f(()=>{"use strict";i_={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},_e=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",i[i.NONE=5]="NONE",i))(_e||{})});function So(i,e){return e.alphaMode==="no-premultiply-alpha"&&i_[i]||i}var hp=f(()=>{ei()});function gP(i){let e="";for(let t=0;t<i;++t)t>0&&(e+=`
else `),t<i-1&&(e+=`if(test == ${t}.0){}`);return e}function vc(i,e){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){let r=mP.replace(/%forloop%/gi,gP(i));if(e.shaderSource(t,r),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))i=i/2|0;else break}}finally{e.deleteShader(t)}return i}var mP,up=f(()=>{"use strict";mP=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`)});function s_(){if(Fs)return Fs;let i=ic();return Fs=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),Fs=vc(Fs,i),i.getExtension("WEBGL_lose_context")?.loseContext(),Fs}var Fs,n_=f(()=>{bd();up();Fs=null});var Sc,o_=f(()=>{"use strict";Sc=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){let t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}});function a_(){return Tc>0?wo[--Tc]:new dp}function l_(i){i.elements=null,wo[Tc++]=i}var dp,wo,Tc,To,c_,u_,d_=f(()=>{Ue();r_();de();xi();cp();hp();n_();o_();dp=class{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Sc,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}},wo=[],Tc=0;Ft.register({clear:()=>{if(wo.length>0)for(let i of wo)i&&i.destroy();wo.length=0,Tc=0}});To=0,c_=class h_{constructor(e){this.uid=K("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...h_.defaultOptions,...e},e.maxTextures||(B("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=s_());let{maxTextures:t,attributesInitialSize:r,indicesInitialSize:s}=e;this.attributeBuffer=new _o(r*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)l_(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){let r=e._batch.textures.ids[t._source.uid];return!r&&r!==0?!1:(e._textureId=r,e.texture=t,!0)}updateElement(e){this.dirty=!0;let t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){let t=this._elements;if(!t[this.elementStart])return;let r=a_(),s=r.textures;s.clear();let n=t[this.elementStart],o=So(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);let l=this.attributeBuffer.float32View,c=this.attributeBuffer.uint32View,h=this.indexBuffer,u=this._batchIndexSize,d=this._batchIndexStart,p="startBatch",m=[],x=this.maxTextures;for(let y=this.elementStart;y<this.elementSize;++y){let g=t[y];t[y]=null;let _=g.texture._source,S=So(g.blendMode,_),T=o!==S||a!==g.topology;if(_._batchTick===To&&!T){g._textureId=_._textureBindLocation,u+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,c,g._attributeStart,g._textureId),this.packQuadIndex(h,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,c,g._attributeStart,g._textureId),this.packIndex(g,h,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=r,m.push(g);continue}_._batchTick=To,(s.count>=x||T)&&(this._finishBatch(r,d,u-d,s,o,a,e,p,m),p="renderBatch",d=u,o=S,a=g.topology,r=a_(),s=r.textures,s.clear(),m=[],++To),g._textureId=_._textureBindLocation=s.count,s.ids[_.uid]=s.count,s.textures[s.count++]=_,g._batch=r,m.push(g),u+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,c,g._attributeStart,g._textureId),this.packQuadIndex(h,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,c,g._attributeStart,g._textureId),this.packIndex(g,h,g._indexStart,g._attributeStart/this.vertexSize))}s.count>0&&(this._finishBatch(r,d,u-d,s,o,a,e,p,m),d=u,++To),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,r,s,n,o,a,l,c){e.gpuBindGroup=null,e.bindGroup=null,e.action=l,e.batcher=this,e.textures=s,e.blendMode=n,e.topology=o,e.start=t,e.size=r,e.elements=c,++To,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){let t=Math.max(e,this.attributeBuffer.size*2),r=new _o(t);vo(this.attributeBuffer.rawBinaryData,r.rawBinaryData),this.attributeBuffer=r}_resizeIndexBuffer(e){let t=this.indexBuffer,r=Math.max(e,t.length*1.5);r+=r%2;let s=r>65535?new Uint32Array(r):new Uint16Array(r);if(s.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let n=0;n<t.length;n++)s[n]=t[n];else vo(t.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(e,t,r){e[t]=r+0,e[t+1]=r+1,e[t+2]=r+2,e[t+3]=r+0,e[t+4]=r+2,e[t+5]=r+3}packIndex(e,t,r,s){let n=e.indices,o=e.indexSize,a=e.indexOffset,l=e.attributeOffset;for(let c=0;c<o;c++)t[r++]=s+n[c+a]-l}destroy(e={}){if(this.batches!==null){for(let t=0;t<this.batchIndex;t++)l_(this.batches[t]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&(this.shader?.destroy(),this.shader=null);for(let t=0;t<this._elements.length;t++)this._elements[t]&&(this._elements[t]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};c_.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};u_=c_});var xP,yP,wc,p_=f(()=>{Pi();Yr();ki();xP=new Float32Array(1),yP=new Uint32Array(1),wc=class extends ht{constructor(){let t=new Ye({data:xP,label:"attribute-batch-buffer",usage:se.VERTEX|se.COPY_DST,shrinkToFit:!1}),r=new Ye({data:yP,label:"index-batch-buffer",usage:se.INDEX|se.COPY_DST,shrinkToFit:!1}),s=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:20}},indexBuffer:r})}}});function Ds(i){let e=f_[i];if(e)return e;let t=new Int32Array(i);for(let r=0;r<i;r++)t[r]=r;return e=f_[i]=new Me({uTextures:{value:t,type:"i32",size:i}},{isStatic:!0}),e}var f_,Mc=f(()=>{Tt();f_={}});var Mo,m_=f(()=>{Bi();ao();lo();Ii();Mc();lr();Mo=class extends De{constructor(e){let t=qr({name:"batch",bits:[Rs,Is(e),Qr]}),r=jr({name:"batch",bits:[As,Bs(e),Zr]});super({glProgram:t,gpuProgram:r,resources:{batchSamplers:Ds(e)}}),this.maxTextures=e}}});var Co,g_,Eo,pp=f(()=>{P();d_();p_();m_();Co=null,g_=class x_ extends u_{constructor(e){super(e),this.geometry=new wc,this.name=x_.extension.name,this.vertexSize=6,Co??(Co=new Mo(e.maxTextures)),this.shader=Co}packAttributes(e,t,r,s,n){let o=n<<16|e.roundPixels&65535,a=e.transform,l=a.a,c=a.b,h=a.c,u=a.d,d=a.tx,p=a.ty,{positions:m,uvs:x}=e,y=e.color,g=e.attributeOffset,v=g+e.attributeSize;for(let _=g;_<v;_++){let S=_*2,T=m[S],w=m[S+1];t[s++]=l*T+h*w+d,t[s++]=u*w+c*T+p,t[s++]=x[S],t[s++]=x[S+1],r[s++]=y,r[s++]=o}}packQuadAttributes(e,t,r,s,n){let o=e.texture,a=e.transform,l=a.a,c=a.b,h=a.c,u=a.d,d=a.tx,p=a.ty,m=e.bounds,x=m.maxX,y=m.minX,g=m.maxY,v=m.minY,_=o.uvs,S=e.color,T=n<<16|e.roundPixels&65535;t[s+0]=l*y+h*v+d,t[s+1]=u*v+c*y+p,t[s+2]=_.x0,t[s+3]=_.y0,r[s+4]=S,r[s+5]=T,t[s+6]=l*x+h*v+d,t[s+7]=u*v+c*x+p,t[s+8]=_.x1,t[s+9]=_.y1,r[s+10]=S,r[s+11]=T,t[s+12]=l*x+h*g+d,t[s+13]=u*g+c*x+p,t[s+14]=_.x2,t[s+15]=_.y2,r[s+16]=S,r[s+17]=T,t[s+18]=l*y+h*g+d,t[s+19]=u*g+c*y+p,t[s+20]=_.x3,t[s+21]=_.y3,r[s+22]=S,r[s+23]=T}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Co=new Mo(e),this.shader=Co)}destroy(){this.shader=null,super.destroy()}};g_.extension={type:[b.Batcher],name:"default"};Eo=g_});var fp,Po,mp=f(()=>{P();Kt();pp();fp=class y_{constructor(e,t){this.state=ze.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e,t){return new this._availableBatchers[e]({maxTextures:t})}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new Eo({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(let r in this._activeBatches)this._activeBatches[r].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let r=this._activeBatches[e.batcherName];r||(r=this._activeBatches[e.batcherName]=y_.getBatcher(e.batcherName,this.renderer.limits.maxBatchableTextures),r.begin()),this._activeBatch=r}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);let t=this._activeBatches;for(let r in t){let s=t[r],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(e){let t=this._batchersByInstructionSet[e.uid];for(let r in t){let s=t[r],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(e){if(e.action==="startBatch"){let t=e.batcher,r=t.geometry,s=t.shader;this._adaptor.start(this,r,s)}this._adaptor.execute(this,e)}destroyInstructionSet(e){let t=this._batchersByInstructionSet[e.uid];if(t){for(let r in t)t[r].destroy();delete this._batchersByInstructionSet[e.uid],this._activeBatches===t&&(this._activeBatches=Object.create(null),this._activeBatch=null)}}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};fp.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"batch"};fp._availableBatchers=Object.create(null);Po=fp;H.handleByMap(b.Batcher,Po._availableBatchers);H.add(Eo)});var b_,__=f(()=>{b_=`in vec2 vMaskCoord;
in vec2 vTextureCoord;

uniform sampler2D uTexture;
uniform sampler2D uMaskTexture;

uniform float uAlpha;
uniform vec4 uMaskClamp;
uniform float uInverse;
uniform float uChannel;

out vec4 finalColor;

void main(void)
{
    float clip = step(3.5,
        step(uMaskClamp.x, vMaskCoord.x) +
        step(uMaskClamp.y, vMaskCoord.y) +
        step(vMaskCoord.x, uMaskClamp.z) +
        step(vMaskCoord.y, uMaskClamp.w));

    // TODO look into why this is needed
    float npmAlpha = uAlpha;
    vec4 original = texture(uTexture, vTextureCoord);
    vec4 masky = texture(uMaskTexture, vMaskCoord);

    float a;
    if (uChannel == 1.0) {
        a = masky.a * npmAlpha * clip;
    } else {
        float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
        a = alphaMul * masky.r * npmAlpha * clip;
    }

    if (uInverse == 1.0) {
        a = 1.0 - a;
    }

    finalColor = original * a;
}
`});var v_,S_=f(()=>{v_=`in vec2 aPosition;

out vec2 vTextureCoord;
out vec2 vMaskCoord;


uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
uniform mat3 uFilterMatrix;

vec4 filterVertexPosition(  vec2 aPosition )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
       
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord(  vec2 aPosition )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

vec2 getFilterCoord( vec2 aPosition )
{
    return  ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}   

void main(void)
{
    gl_Position = filterVertexPosition(aPosition);
    vTextureCoord = filterTextureCoord(aPosition);
    vMaskCoord = getFilterCoord(aPosition);
}
`});var gp,T_=f(()=>{gp=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

struct MaskUniforms {
  uFilterMatrix:mat3x3<f32>,
  uMaskClamp:vec4<f32>,
  uAlpha:f32,
  uInverse:f32,
  uChannel:f32,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;

@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>,
    @location(1) filterUv : vec2<f32>,
};

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}

fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}

@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>,
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition),
   getFilterCoord(aPosition)
  );
}

@fragment
fn mainFragment(
  @location(0) uv: vec2<f32>,
  @location(1) filterUv: vec2<f32>,
  @builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {

    var maskClamp = filterUniforms.uMaskClamp;
    var uAlpha = filterUniforms.uAlpha;

    var clip = step(3.5,
      step(maskClamp.x, filterUv.x) +
      step(maskClamp.y, filterUv.y) +
      step(filterUv.x, maskClamp.z) +
      step(filterUv.y, maskClamp.w));

    var mask = textureSample(uMaskTexture, uSampler, filterUv);
    var source = textureSample(uTexture, uSampler, uv);

    var a: f32;
    if (filterUniforms.uChannel == 1.0) {
        a = mask.a * uAlpha * clip;
    } else {
        var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
        a = alphaMul * mask.r * uAlpha * clip;
    }

    if (filterUniforms.uInverse == 1.0) {
        a = 1.0 - a;
    }

    return source * a;
}
`});var Cc,w_=f(()=>{oe();$r();Ei();Tt();ye();Iu();ie();ac();__();S_();T_();Cc=class extends wt{constructor(e){let{sprite:t,...r}=e,s=new ds(t.texture),n=new Me({uFilterMatrix:{value:new I,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),o=Xe.from({vertex:{source:gp,entryPoint:"mainVertex"},fragment:{source:gp,entryPoint:"mainFragment"}}),a=Fe.from({vertex:v_,fragment:b_,name:"mask-filter"});super({...r,gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=s}setSprite(e){this.sprite=e;let t=this._getSafeTexture();this._textureMatrix.texture=t,this.resources.uMaskTexture=t.source}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=e==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(e,t,r,s){let n=this._getSafeTexture();this._textureMatrix.texture=n,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=n.source,e.applyFilter(this,t,r,s)}_getSafeTexture(){let e=this.sprite.texture;return e.destroyed||!e.source||e.source.destroyed?(G("[MaskFilter] The mask texture was destroyed while the mask is still in use. Remove the mask before destroying its texture."),F.EMPTY):e}destroy(e=!1){this._textureMatrix.destroy(),super.destroy(e)}}});var bP,xp,Oi,yp=f(()=>{P();Sl();w_();lt();Rn();Hl();br();ye();wr();ar();bP=new fe,xp=class extends _r{constructor(){super(),this._placeholderSprite=new nr(F.EMPTY),this.filters=[new Cc({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=F.EMPTY,this.sprite=this._placeholderSprite}},Oi=class{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,r){let s=this._renderer;if(s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){let n=e.mask;n.includeInBuild=!0,n.collectRenderables(r,s,null),n.includeInBuild=!1}s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){let t=this._renderer,r=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){let s=Te.get(xp);if(s.inverse=e.inverse,s.channel=e.mask.channel,r){e.mask.mask.measurable=!0;let n=ls(e.mask.mask,!0,bP);e.mask.mask.measurable=!1,n.ceil();let o=t.renderTarget.renderTarget.colorTexture.source,a=ce.getOptimalTexture({width:n.width,height:n.height,resolution:o._resolution,antialias:o.antialias});t.renderTarget.push({target:a,clear:!0}),t.globalUniforms.push({offset:n,worldColor:4294967295});let l=s.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:a})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){let s=this._activeMaskStage[this._activeMaskStage.length-1];r&&(t.type===He.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();let s=this._activeMaskStage.pop();r&&ce.returnTexture(s.filterTexture),this._usedEffects.push(s.filterEffect)}}postrender(){let e=this._usedEffects;for(let t=0;t<e.length;t++)Te.return(e[t]);e.length=0}destroy(){this.postrender(),this._renderer.runners.postrender.remove(this),this._renderer=null,this._activeMaskStage=null,this._usedEffects=null}};Oi.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"alphaMask"}});var ko,M_=f(()=>{P();ko=class{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;let o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;this._colorStackIndex--;let o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}};ko.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"colorMask"}});var Ao,C_=f(()=>{P();Cs();ei();Ao=class{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){let s=e,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let o=s.mask;o.includeInBuild=!0,this._maskHash.has(s)||this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});let a=this._maskHash.get(s);a.instructionsStart=r.instructionSize,o.collectRenderables(r,n,null),o.includeInBuild=!1,n.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let l=r.instructionSize-a.instructionsStart-1;a.instructionsLength=l}pop(e,t,r){let s=e,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});let o=this._maskHash.get(e);for(let a=0;a<o.instructionsLength;a++)r.instructions[r.instructionSize++]=r.instructions[o.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){let r=this._renderer,s=r.renderTarget.getGpuRenderTarget(r.renderTarget.renderTarget),n=s.maskStackIndex;e.action==="pushMaskBegin"?(r.renderTarget.ensureDepthStencil(),r.stencil.setStencilMode(_e.RENDERING_MASK_ADD,n),n++,r.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?r.stencil.setStencilMode(_e.INVERSE_MASK_ACTIVE,n):r.stencil.setStencilMode(_e.MASK_ACTIVE,n),r.colorMask.setMask(15)):e.action==="popMaskBegin"?(r.colorMask.setMask(0),n!==0?r.stencil.setStencilMode(_e.RENDERING_MASK_REMOVE,n):(r.renderTarget.clear(null,Ce.STENCIL),r.stencil.setStencilMode(_e.DISABLED,n)),n--):e.action==="popMaskEnd"&&(e.inverse?r.stencil.setStencilMode(_e.INVERSE_MASK_ACTIVE,n):r.stencil.setStencilMode(_e.MASK_ACTIVE,n),r.colorMask.setMask(15)),s.maskStackIndex=n}destroy(){this._renderer=null,this._maskHash=null}};Ao.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"stencilMask"}});var bp,P_,k_=f(()=>{Je();P();ie();bp=class E_{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new q(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...E_.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){q.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&G("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};bp.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"background",priority:0};bp.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};P_=bp});var Ro,Li,_p=f(()=>{P();Sl();Du();ie();Ro={};H.handle(b.BlendMode,i=>{if(!i.name)throw new Error("BlendMode extension must have a name property");Ro[i.name]=i.ref},i=>{delete Ro[i.name]});Li=class{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,r){this._blendModeStack.push(t),this.setBlendMode(e,t,r)}popBlendMode(e){this._blendModeStack.pop();let t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,r){let s=e instanceof wi;if(this._activeBlendMode===t){this._isAdvanced&&e&&!s&&this._renderableList?.push(e);return}this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=t,e&&(this._isAdvanced=!!Ro[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,r))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let r=this._activeBlendMode;if(!Ro[r]){G(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let s=this._ensureFilterEffect(r),n=e instanceof wi,o={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=o.renderables,t.add(o)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new _r,t.filters=[new Ro[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}};Li.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"blendMode"}});var vp,Sp,R_,B_=f(()=>{we();P();Vt();ye();vp={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Sp=class A_{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof ge||e instanceof F?{target:e,...t}:{...t,...e}}async image(e){let t=W.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,A_.defaultImageOptions);let{format:t,quality:r}=e,s=this.canvas(e);if(s.toBlob!==void 0)return new Promise((n,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}let l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},vp[t],r)});if(s.toDataURL!==void 0)return s.toDataURL(vp[t],r);if(s.convertToBlob!==void 0){let n=await s.convertToBlob({type:vp[t],quality:r});return new Promise((o,a)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);let t=e.target,r=this._renderer;if(t instanceof F)return r.texture.generateCanvas(t);let s=r.textureGenerator.generateTexture(e),n=r.texture.generateCanvas(s);return s.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);let t=e.target,r=this._renderer,s=t instanceof F?t:r.textureGenerator.generateTexture(e),n=r.texture.getPixels(s);return t instanceof ge&&s.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof F?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);let t=this.canvas(e),r=document.createElement("a");r.download=e.filename??"image.png",r.href=t.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(e){let t=e.width??200;e=this._normalizeOptions(e);let r=this.canvas(e),s=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);let n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};Sp.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"extract"};Sp.defaultImageOptions={format:"png",quality:1};R_=Sp});var Ec,I_=f(()=>{et();ye();Ec=class i extends F{static create(e){let{dynamic:t,textureOptions:r,...s}=e;return new i({...r,source:new te(s),dynamic:t??!1})}resize(e,t,r){return this.source.resize(e,t,r),this}}});var _P,vP,SP,Bo,G_=f(()=>{Je();P();oe();Ge();lt();El();Vt();I_();_P=new V,vP=new fe,SP=[0,0,0,0],Bo=class{constructor(e){this._renderer=e}generateTexture(e){e instanceof ge&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});let t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,s=e.target,n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:q.shared.setValue(n).toArray():n=SP;let o=e.frame?.copyTo(_P)||hs(s,vP).rectangle,a=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;let l=Ec.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:r,textureOptions:a}),c=I.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:c,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}};Bo.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"textureGenerator"}});function F_(i){let e=!1;for(let r in i)if(i[r]==null){e=!0;break}if(!e)return i;let t=Object.create(null);for(let r in i){let s=i[r];s&&(t[r]=s)}return t}function D_(i){let e=0;for(let t=0;t<i.length;t++)i[t]==null?e++:i[t-e]=i[t];return i.length-=e,i}var O_=f(()=>{"use strict"});var Tp,U_,N_=f(()=>{P();O_();Tp=class L_{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=e}init(e){e={...L_.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(let t of this._managedCollections){let{context:r,collection:s,type:n}=t;n==="hash"?r[s]=F_(r[s]):r[s]=D_(r[s])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(let r of e.renderGroupChildren)this._updateInstructionGCTick(r,t)}addCollection(e,t,r){this._managedCollections.push({context:e,collection:t,type:r})}addResource(e,t){if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,e._onTouch?.(this.now);return}let r=this._managedResources.length;e._gcData={index:r,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){let t=e._gcData;if(!t)return;let r=t.index,s=this._managedResources.length-1;if(this._running)this._managedResources[r]=null;else{if(r!==s){let n=this._managedResources[s];this._managedResources[r]=n,n._gcData.index=r}this._managedResources.length--}e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,r,s=0){this._managedResourceHashes.push({context:e,hash:t,type:r,priority:s}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){if(this._running)return;let e=performance.now(),t=this._managedResourceHashes,r=this._managedResources;this._running=!0;try{for(let n of t)this.runOnHash(n,e);let s=r.length;for(let n=0;n<s;n++){let o=r[n];o&&this.runOnResource(o,e)}}finally{let s=0;for(let n=0;n<r.length;n++){let o=r[n];o&&(s!==n&&(r[s]=o,o._gcData.index=s),s++)}r.length=s,this._running=!1}}updateRenderableGCTick(e,t){let r=e.renderGroup??e.parentRenderGroup,s=r?.instructionSet?.gcTick??-1;(r?.gcTick??0)===s&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t){e._gcData.type==="renderable"&&this.updateRenderableGCTick(e,t),!(t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect)&&(e.off("unload",this.removeResource,this),e.unload(),this.removeResource(e))}_createHashClone(e,t){let r=Object.create(null);for(let s in e){if(s===t)break;e[s]!==null&&(r[s]=e[s])}return r}runOnHash(e,t){let{context:r,hash:s,type:n}=e,o=r[s],a=null,l=0;for(let c in o){let h=o[c];if(h===null){l++,l===1e4&&!a&&(a=this._createHashClone(o,c));continue}if(h._gcLastUsed===-1){h._gcLastUsed=t,h._onTouch?.(t),a&&(a[c]=h);continue}if(n==="renderable"&&this.updateRenderableGCTick(h,t),!(t-h._gcLastUsed<this.maxUnusedTime)&&h.autoGarbageCollect){if(n==="renderable"){let d=h,p=d.renderGroup??d.parentRenderGroup;p&&(p.structureDidChange=!0)}h.unload(),h._gcData=null,h._gcLastUsed=-1,a||(l+1!==1e4?(o[c]=null,l++):a=this._createHashClone(o,c))}else a&&(a[c]=h)}a&&(r[s]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e?.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Tp.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"gc",priority:0};Tp.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};U_=Tp});function Os(i,e,t){let r=(i>>24&255)/255;e[t++]=(i&255)/255*r,e[t++]=(i>>8&255)/255*r,e[t++]=(i>>16&255)/255*r,e[t++]=r}var Pc=f(()=>{"use strict"});var Io,H_=f(()=>{P();oe();Wt();Pc();Xr();ar();Tt();Io=class{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:r,worldColor:s,offset:n}){let o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new I,worldColor:4294967295,offset:new ne},l={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:r||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:n||a.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);let h=c.uniforms;h.uProjectionMatrix=l.projectionMatrix,h.uResolution=l.resolution,h.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),h.uWorldTransformMatrix.tx-=l.offset.x,h.uWorldTransformMatrix.ty-=l.offset.y,Os(l.worldColor,h.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new qe,this._activeBindGroups.push(u),u.setResource(c,0)),l.bindGroup=u,this._currentGlobalUniformData=l}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===He.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new Me({uProjectionMatrix:{value:new I,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new I,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}};Io.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"globalUniforms"}});var TP,Go,z_=f(()=>{P();gs();TP=1,Go=class{constructor(){this._tasks=[],this._offset=0}init(){tt.system.add(this._update,this)}repeat(e,t,r=!0){let s=TP++,n=0;return r&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){let e=performance.now();for(let t=0;t<this._tasks.length;t++){let r=this._tasks[t];if(e-r.offset-r.last>=r.duration){let s=e-r.start;r.func(s),r.last=e}}}destroy(){tt.system.remove(this._update,this),this._tasks.length=0}};Go.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"scheduler",priority:0}});function V_(i){if(!W_){if(W.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){let e=[`%c  %c  %c  %c  %c PixiJS %c v${Gs} (${i}) http://www.pixijs.com/

`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Gs} - ${i} - http://www.pixijs.com/`);W_=!0}}var W_,$_=f(()=>{we();ap();W_=!1});var Ls,X_=f(()=>{P();$_();ar();Ls=class{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===He.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),V_(t)}}};Ls.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"hello",priority:-2};Ls.defaultOptions={hello:!1}});var wp,K_,j_=f(()=>{P();de();wp=class Y_{constructor(e){this._renderer=e}init(e){e={...Y_.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return B("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){B("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){B("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){B("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){B("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){B("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};wp.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"renderableGC",priority:0};wp.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};K_=wp});var Mp,q_,Z_=f(()=>{P();de();Mp=class kc{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){B("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){B("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){B("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){B("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==kc.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==kc.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==kc.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){B("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Mp.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"textureGC"};Mp.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};q_=Mp});var Q_,Us,Cp=f(()=>{Oe();Ue();et();ye();Q_=class J_ extends le{constructor(e={}){super(),this.uid=K("renderTarget"),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;let t="colorAttachments"in e?e:this._normalizeOptions(e);if(this.isRoot=t.isRoot??!1,this.label=t.label,this.colorAttachments=t.colorAttachments,this.depthStencilAttachment=t.depthStencilAttachment,this.depthStencilAttachment){let r=this.depthStencilAttachment.texture.format;this._depth||(this._depth=r.includes("depth")),this._stencil||(this._stencil=r.includes("stencil"))}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw new Error("[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.");if(this.colorAttachments.length>0){let r=this.colorTexture;this.resize(r.width,r.height,r._resolution)}this.sizeSource&&this.sizeSource.on("resize",this.onSourceResize,this)}_normalizeOptions(e){let t={...J_.defaultOptions,...e},r=[],s;if(typeof t.colorTextures=="number"){if(t.colorTextures>0){this._managedColorTextures=!0;for(let o=0;o<t.colorTextures;o++)r.push({texture:new te({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}),loadOp:"clear",storeOp:"store"})}}else t.colorTextures.forEach(o=>{r.push({texture:o.source,loadOp:"clear",storeOp:"store"})});let n=t.depthStencilTexture===!0;if(this._depth=!!(t.depth||n),this._stencil=!!(t.stencil||n),t.depthStencilTexture instanceof F||t.depthStencilTexture instanceof te){if(t.isRoot)throw new Error("[RenderTarget] cannot attach a depth-stencil texture to the screen \u2014 the canvas owns its own depth/stencil buffers. Render to a texture target instead.");s={texture:t.depthStencilTexture.source}}else(n&&!t.isRoot||(t.stencil||t.depth)&&r.length===0)&&(s=this._createDepthStencilTexture(t.width,t.height,t.resolution));return{colorAttachments:r,depthStencilAttachment:s,isRoot:t.isRoot,label:t.label}}get size(){let e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||(this._colorTextures=this.colorAttachments.map(e=>e.texture)),this._colorTextures}get depthStencilTexture(){return this.depthStencilAttachment?.texture??null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){return this.colorAttachments[0]?.texture}get sizeSource(){return this.colorAttachments[0]?.texture??this.depthStencilAttachment?.texture}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(e,t,r=this.resolution,s=!1){if(this.dirtyId++,this.colorAttachments.forEach((n,o)=>{s&&o===0||n.texture.resize(e,t,r)}),this.depthStencilAttachment){if(s&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(e,t,r)}}destroy(){!this.colorAttachments&&!this.depthStencilAttachment||(this.emit("destroy",this),this.sizeSource.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorAttachments.forEach(e=>{e.texture.destroy()}),this.depthStencilAttachment&&(this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment),this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners())}_createDepthStencilTexture(e,t,r){return this.depthStencilAttachment??(this.depthStencilAttachment={texture:new te({width:e,height:t,resolution:r,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}),this.depthStencilAttachment}};Q_.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};Us=Q_});function Ac(i,e){if(!Ns.has(i)){let t=new F({source:new Pe({resource:i,...e})}),r=()=>{Ns.get(i)===t&&Ns.delete(i)};t.once("destroy",r),t.source.once("destroy",r),Ns.set(i,t)}return Ns.get(i)}var Ns,Ep=f(()=>{xi();Vr();ye();Ns=new Map;Ft.register(Ns)});var Pp,tv,rv=f(()=>{we();P();Ge();de();Cp();vs();wr();Ep();Pp=class ev{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}constructor(e){this._renderer=e}init(e){e={...ev.defaultOptions,...e},e.view&&(B($,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new V(0,0,e.width,e.height),this.canvas=e.canvas||W.get().createCanvas(),this.antialias=!!e.antialias;let{depth:t,...r}=e;this.texture=Ac(this.canvas,r),this.renderTarget=new Us({colorTextures:[this.texture],depth:!!t,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.texture.source.on("resize",this._updateScreenSize,this),this.resolution=e.resolution,this._updateScreenSize()}resize(e,t,r){this.texture.source.resize(e,t,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!e?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.source.off("resize",this._updateScreenSize,this),ce.removeScreen(this._renderer.uid),ct.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){let{pixelWidth:e,pixelHeight:t}=this.texture.source,r=this._renderer.uid;ce.setScreenSize(r,e,t),ct.setScreenSize(r,e,t)}};Pp.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:"view",priority:0};Pp.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};tv=Pp});var Hs,Rc,Bc=f(()=>{tp();ip();t_();op();lp();mp();yp();M_();C_();k_();_p();B_();G_();N_();H_();z_();X_();j_();Z_();rv();Hs=[P_,Io,Ls,tv,xo,U_,q_,Bo,R_,bo,K_,Go],Rc=[Li,Po,Di,Fi,Oi,Ao,ko,Gi]});var kp,Fo,iv=f(()=>{P();kp=class{constructor(e,t){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=e,this._gcLastUsed=t}unload(){this.gpuBindGroup=null}},Fo=class{constructor(e){this._hash=Object.create(null),this._renderer=e,e.gc.addResourceHash(this,"_hash","resource"),e.gc.addCollection(this,"_hash","hash")}contextChange(e){this._gpu=e,this._hash=Object.create(null)}getBindGroup(e,t,r){let s=`${e._key}:${t._layoutKey<<4|r}`,n=this._hash[s];return n?(n._gcLastUsed=this._renderer.gc.now,n.gpuBindGroup):this._createBindGroup(s,e,t,r)}_createBindGroup(e,t,r,s){let n=this._gpu.device,o=r.layout[s],a=[],l=this._renderer;for(let u in o){let d=t.resources[u]??t.resources[o[u]];if(!d||d.destroyed)throw new Error(`[BindGroup] the resource bound as '${u}' was destroyed while a shader still uses it. Remove it from the shader before destroying it.`);let p;if(d._resourceType==="uniformGroup"){let m=d;l.ubo.updateUniformGroup(m);let x=m.buffer;p={buffer:l.buffer.getGPUBuffer(x),offset:0,size:x.descriptor.size}}else if(d._resourceType==="buffer"){let m=d;p={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(d._resourceType==="bufferResource"){let m=d;p={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size??m.buffer.descriptor.size}}else if(d._resourceType==="textureSampler"){let m=d;p=l.texture.getGpuSampler(m)}else if(d._resourceType==="textureSource"){let m=d;p=l.texture.getTextureView(m)}else if(d._resourceType==="textureView"){let m=d;p=l.texture.getTextureView(m.source,m.viewDescriptor)}a.push({binding:o[u],resource:p})}let c=l.shader.getProgramData(r).bindGroups[s],h=n.createBindGroup({layout:c,entries:a});return this._hash[e]=new kp(h,l.gc.now),h}destroy(){this._hash=null,this._renderer=null}};Fo.extension={type:[b.WebGPUSystem],name:"bindGroup"}});var Ee,Dt=f(()=>{"use strict";Ee=class{constructor(e){this.items=Object.create(null);let{renderer:t,type:r,onUnload:s,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",r,n??0),this._onUnload=s,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){if(!this.items[e.uid])return;let r=e._gpuData[this._renderer.uid];r&&(this._onUnload?.(e,...t),e.off("unload",this.remove,this),r.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}});var Ap,Do,sv=f(()=>{P();Dt();cp();Ap=class{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}},Do=class{constructor(e){this._renderer=e,this._managedBuffers=new Ee({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e,this.destroyAll()}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){let t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,e._updateOffset,r.buffer,r.byteOffset+e._updateOffset,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(vo(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Ap(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}};Do.extension={type:[b.WebGPUSystem],name:"buffer"}});var Oo,nv=f(()=>{P();Oo=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}};Oo.extension={type:[b.WebGPUSystem],name:"colorMask"}});var wP,zs,ov=f(()=>{we();P();ie();wP=new Set(["apple","arm","qualcomm","img-tec"]),zs=class{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._options=e,this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>this._setGpu(t)),this._initPromise)}_setGpu(e){this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number",tileBased:wP.has(e.adapter?.info?.vendor)},this._options.gpu||e.device.lost.then(()=>this._restoreDevice()).catch(t=>G("WebGPU device was lost and could not be restored",t)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;let e=await this._createDeviceAndAdaptor(this._options);if(!this._renderer){e.device.destroy();return}this._setGpu(e)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await W.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter});if(!t)throw new Error("WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().");let r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2","indirect-first-instance","bgra8unorm-storage","texture-formats-tier1"].filter(n=>t.features.has(n)),s=await t.requestDevice({requiredFeatures:r,requiredLimits:{maxSampledTexturesPerShaderStage:t.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:t.limits.maxSamplersPerShaderStage}});return{adapter:t,device:s}}destroy(){this._options?.gpu||this.gpu?.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}};zs.extension={type:[b.WebGPUSystem],name:"device"};zs.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1}});var Ic,av=f(()=>{"use strict";Ic=class{constructor(e,t,r,s){this.gpuBundle=e,this.stateKey=t,this.device=r,this.label=s}}});var Lo,lv=f(()=>{P();ie();av();Lo=class{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e;for(let t=0;t<16;t++)this._boundBindGroup[t]={bindGroup:null,program:null,key:null}}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){return this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(e.descriptor),this.renderPassEncoder=this._passEncoder,this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(e){if(this._passEncoder!==this.renderPassEncoder)throw new Error("Cannot begin a new render bundle while one is already being recorded.");this._clearCache();let t=this._renderer.pipeline,r=t.getBundleDescriptor();r.label=e,this._bundleStateKey=t.bundleStateKey,this._bundleLabel=e,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(r)}endBundle(){let e=this.renderPassEncoder;if(!e||!("finish"in e))throw new Error("endBundle called without an active render bundle.");let t=e.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new Ic(t,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(e){return e?.stateKey===this._renderer.pipeline.bundleStateKey&&e.device===this._gpu.device}executeBundle(e){let t=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)t[r]=this._getGpuBundle(e[r]);else t[0]=this._getGpuBundle(e);this._clearCache(),this._passEncoder.executeBundles(t)}_getGpuBundle(e){return this.isBundleValid(e)||G(`Render bundle ${e?.label??"(unlabeled)"} was recorded against a different render target state or on a lost device. Re-record it \u2014 replaying it will either be rejected by WebGPU or draw with the wrong winding. Check encoder.isBundleValid(bundle) before executing.`),e.gpuBundle}setViewport(e){this._passEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setStencilReference(e){this._passEncoder.setStencilReference(e)}setPipelineFromGeometryProgramAndState(e,t,r,s,n){let o=this._renderer.pipeline.getPipeline(e,t,r,s,n);this.setPipeline(o)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=null}setBindGroup(e,t,r){let s=this._boundBindGroup[e];if(s.bindGroup===t&&s.program===r&&s.key===t._key)return;s.bindGroup=t,s.program=r,s.key=t._key,t._touch(this._renderer.gc.now);let n=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,n)}setGeometry(e,t){let r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let s=0;s<r.length;s++)this._setVertexBuffer(s,e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){let r=e.gpuProgram,s=r.layout;for(let n=0;n<s.length;n++){let o=e.groups[n];!s[n]||!o||(t||this._syncBindGroup(o),this.setBindGroup(n,o,r))}}_syncBindGroup(e){let t=e.resources,r=e._resourceKeys;for(let s=0;s<r.length;s++){let n=t[r[s]];n&&n.isUniformGroup&&this._renderer.ubo.updateUniformGroup(n)}}draw(e){let{geometry:t,shader:r,state:s,topology:n,size:o,start:a,baseVertex:l,instanceCount:c,skipSync:h,firstInstance:u}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,n,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,h),t.indexBuffer?this.renderPassEncoder.drawIndexed(o||t.indexCount||t.indexBuffer.data.length,c??t.instanceCount,a||0,l||0,u||0):this.renderPassEncoder.draw(o||t.vertexCount,c??t.instanceCount,a||0,u||0)}drawIndirect(e){let{geometry:t,shader:r,state:s,topology:n,skipSync:o,indirectBuffer:a,indirectOffset:l}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,n,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,o),t.indexBuffer?this.renderPassEncoder.drawIndexedIndirect(a,l):this.renderPassEncoder.drawIndirect(a,l)}finishRenderPass(){this._passEncoder&&(this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}_clearCache(){for(let e=0;e<16;e++){let t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=null,this._boundVertexBuffer[e]=null}this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null,this.renderPassEncoder=null,this._passEncoder=null}contextChange(e){this._gpu=e}};Lo.extension={type:[b.WebGPUSystem],name:"encoder",priority:1}});var Uo,cv=f(()=>{P();Uo=class{constructor(e){this.supportsOverrideConstants=!1,this._renderer=e}contextChange(){let e=this._renderer.device.gpu.device;this.maxTextures=Math.min(e.limits.maxSampledTexturesPerShaderStage,e.limits.maxSamplersPerShaderStage),this.maxBatchableTextures=this.maxTextures,this._detectOverrideConstantsSupport(e)}_detectOverrideConstantsSupport(e){e.pushErrorScope("validation");let t=e.createShaderModule({code:`override TEST_VALUE: f32 = 0.0;
@compute @workgroup_size(1) fn main() {}`});e.createComputePipeline({layout:"auto",compute:{module:t,entryPoint:"main",constants:{TEST_VALUE:1}}}),e.popErrorScope().then(r=>{this.supportsOverrideConstants=!r})}destroy(){}};Uo.extension={type:[b.WebGPUSystem],name:"limits"}});var No,hv=f(()=>{P();No=class{constructor(e){this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(){this._activeGpuRenderTarget=null}onRenderTargetChange(e){let t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeRenderTarget=e,this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let r=this._activeGpuRenderTarget??(this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget));r.stencilMode=e,r.stencilReference=t;let s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}};No.extension={type:[b.WebGPUSystem],name:"stencil"}});var Ws,Rp=f(()=>{Ld();Pi();Yr();Ws=class{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!cc())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){let t=this.getUniformGroupData(e);e.buffer||(e.buffer=new Ye({data:new Float32Array(t.layout.size/4),usage:se.UNIFORM|se.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){let t=e._signature,r=this._syncFunctionHash[t];if(!r){let s=Object.keys(e.uniformStructures).map(a=>e.uniformStructures[a]),n=this._adaptor.createUboElements(s),o=this._generateUboSync(n.uboElements);r=this._syncFunctionHash[t]={layout:n,syncFunction:o}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,r){let s=this.getUniformGroupData(e);e.buffer||(e.buffer=new Ye({data:new Float32Array(s.layout.size/4),usage:se.UNIFORM|se.COPY_DST}));let n=null;return t||(t=e.buffer.data,n=e.buffer.dataInt32),r||(r=0),s.syncFunction(e.uniforms,t,n,r),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;let t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}});function uv(i){let e=i.map(r=>({data:r,offset:0,size:0})),t=0;for(let r=0;r<e.length;r++){let s=e[r],n=Ho[s.data.type].size,o=Ho[s.data.type].align;if(!Ho[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,o)*s.data.size),t=Math.ceil(t/o)*o,s.size=n,s.offset=t,t+=n}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}var Ho,Bp=f(()=>{"use strict";Ho={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}}});var ti,Ip=f(()=>{"use strict";ti=[{type:"mat3x3<f32>",test:i=>i.value.a!==void 0,ubo:`
            var matrix = uv[name].toArray(true);
            data[offset] = matrix[0];
            data[offset + 1] = matrix[1];
            data[offset + 2] = matrix[2];
            data[offset + 4] = matrix[3];
            data[offset + 5] = matrix[4];
            data[offset + 6] = matrix[5];
            data[offset + 8] = matrix[6];
            data[offset + 9] = matrix[7];
            data[offset + 10] = matrix[8];
        `,uniform:`
            gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
        `},{type:"vec4<f32>",test:i=>i.type==="vec4<f32>"&&i.size===1&&i.value.width!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
            data[offset + 2] = v.width;
            data[offset + 3] = v.height;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
                cv[0] = v.x;
                cv[1] = v.y;
                cv[2] = v.width;
                cv[3] = v.height;
                gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
            }
        `},{type:"vec2<f32>",test:i=>i.type==="vec2<f32>"&&i.size===1&&i.value.x!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.x;
            data[offset + 1] = v.y;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.x || cv[1] !== v.y) {
                cv[0] = v.x;
                cv[1] = v.y;
                gl.uniform2f(ud[name].location, v.x, v.y);
            }
        `},{type:"vec4<f32>",test:i=>i.type==="vec4<f32>"&&i.size===1&&i.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
            data[offset + 3] = v.alpha;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                cv[3] = v.alpha;
                gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
            }
        `},{type:"vec3<f32>",test:i=>i.type==="vec3<f32>"&&i.size===1&&i.value.red!==void 0,ubo:`
            v = uv[name];
            data[offset] = v.red;
            data[offset + 1] = v.green;
            data[offset + 2] = v.blue;
        `,uniform:`
            cv = ud[name].value;
            v = uv[name];
            if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
                cv[0] = v.red;
                cv[1] = v.green;
                cv[2] = v.blue;
                gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
            }
        `}]});function Gc(i,e,t){let r=[`
        var v = null;
        var v2 = null;
        var t = 0;
        var index = 0;
        var name = null;
        var arrayOffset = null;
    `],s=0;for(let o=0;o<i.length;o++){let a=i[o],l=a.data.name,c=!1,h=0;for(let u=0;u<ti.length;u++)if(ti[u].test(a.data)){h=a.offset/4,r.push(`name = "${l}";`,`offset += ${h-s};`,ti[u].ubo),c=!0;break}if(!c)if(a.data.size>1)h=a.offset/4,r.push(t(a,h-s));else{let u=e[a.data.type];h=a.offset/4,r.push(`
                    v = uv.${l};
                    offset += ${h-s};
                    ${u};
                `)}s=h}let n=r.join(`
`);return new Function("uv","data","dataInt32","offset",n)}var Gp=f(()=>{Ip()});function Vs(i,e){return`
        for (let i = 0; i < ${i*e}; i++) {
            data[offset + (((i / ${i})|0) * 4) + (i % ${i})] = v[i];
        }
    `}var Fp,dv,Dp=f(()=>{"use strict";Fp={f32:`
        data[offset] = v;`,i32:`
        dataInt32[offset] = v;`,u32:`
        dataInt32[offset] = v;`,"vec2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];`,"vec3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];`,"vec4<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];`,"vec2<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];
        dataInt32[offset + 3] = v[3];`,"vec2<u32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];`,"vec3<u32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];`,"vec4<u32>":`
        dataInt32[offset] = v[0];
        dataInt32[offset + 1] = v[1];
        dataInt32[offset + 2] = v[2];
        dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 4] = v[2];
        data[offset + 5] = v[3];`,"mat3x3<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 4] = v[3];
        data[offset + 5] = v[4];
        data[offset + 6] = v[5];
        data[offset + 8] = v[6];
        data[offset + 9] = v[7];
        data[offset + 10] = v[8];`,"mat4x4<f32>":`
        for (let i = 0; i < 16; i++) {
            data[offset + i] = v[i];
        }`,"mat3x2<f32>":Vs(3,2),"mat4x2<f32>":Vs(4,2),"mat2x3<f32>":Vs(2,3),"mat4x3<f32>":Vs(4,3),"mat2x4<f32>":Vs(2,4),"mat3x4<f32>":Vs(3,4)},dv={...Fp,"mat2x2<f32>":`
        data[offset] = v[0];
        data[offset + 1] = v[1];
        data[offset + 2] = v[2];
        data[offset + 3] = v[3];
    `}});function pv(i,e){let{size:t,align:r}=Ho[i.data.type],s=(Math.max(t,r)-t)/4,n=i.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
         v = uv.${i.data.name};
         ${e!==0?`offset += ${e};`:""}

         arrayOffset = offset;

         t = 0;

         for(var i=0; i < ${i.data.size}; i++)
         {
             for(var j = 0; j < ${t/4}; j++)
             {
                 ${n}[arrayOffset++] = v[t++];
             }
             ${s!==0?`arrayOffset += ${s};`:""}
         }
     `}var fv=f(()=>{Bp()});function mv(i){return Gc(i,dv,pv)}var gv=f(()=>{Gp();Dp();fv()});var zo,xv=f(()=>{P();Rp();Bp();gv();zo=class extends Ws{constructor(){super({createUboElements:uv,generateUboSync:mv})}};zo.extension={type:[b.WebGPUSystem],name:"ubo"}});var ri,Fc=f(()=>{Oe();Ue();ri=class extends le{constructor({buffer:e,offset:t,size:r}){super(),this.uid=K("buffer"),this._resourceType="bufferResource",this._resourceId=K("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=r,this.buffer.on("change",this.onBufferChange,this)}get _gcLastUsed(){return this.buffer?._gcLastUsed??-1}set _gcLastUsed(e){this.buffer&&(this.buffer._gcLastUsed=e)}onBufferChange(){this._resourceId=K("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}});var Dc,yv=f(()=>{"use strict";Dc=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}});var ii,Wo,bv=f(()=>{P();Pi();Fc();Yr();yv();Xr();ii=128,Wo=class{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new Dc({minUniformOffsetAlignment:ii});let t=256/ii;for(let r=0;r<t;r++){let s=se.UNIFORM|se.COPY_DST;r===0&&(s|=se.COPY_SRC),this._buffers.push(new Ye({data:this._batchBuffer.data,usage:s}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);let r=e.buffer.data,s=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,s/4),this._bindGroupHash[e.uid]=this._getBindGroup(s/ii),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,r=this._batchBuffer.addGroup(t);return this._getBufferResource(r/ii)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/ii)}getArrayBufferResource(e){let r=this._batchBuffer.addGroup(e)/ii;return this._getBufferResource(r)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new ri({buffer:t,offset:(e/2|0)*256,size:ii})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new qe({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let r=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){let n=this._buffers[s];r.copyBufferToBuffer(e.getGPUBuffer(t),ii,e.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e]?.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}};Wo.extension={type:[b.WebGPUPipes],name:"uniformBatch"}});function Vo(i,e){for(let t in i.attributes){let r=i.attributes[t],s=e[t];s?(r.format??(r.format=s.format),r.offset??(r.offset=s.offset),r.instance??(r.instance=s.instance)):r.format||G(`Attribute ${t} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}MP(i)}function MP(i){let{buffers:e,attributes:t}=i,r={},s={};for(let n in e){let o=e[n];r[o.uid]=0,s[o.uid]=0}for(let n in t){let o=t[n];r[o.buffer.uid]+=Er(o.format).stride}for(let n in t){let o=t[n];o.stride??(o.stride=r[o.buffer.uid]),o.start??(o.start=s[o.buffer.uid]),s[o.buffer.uid]+=Er(o.format).stride}}var Op=f(()=>{ie();Zn()});var hr,Lp=f(()=>{ei();hr=[];hr[_e.NONE]=void 0;hr[_e.DISABLED]={stencilWriteMask:0,stencilReadMask:0};hr[_e.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};hr[_e.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};hr[_e.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};hr[_e.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}});function Sv(i,e){for(let[t,r]of Object.entries(e)){let s=new RegExp(`override\\s+${t}\\s*:\\s*(\\w+)\\s*(?:=[^;]*)?;`);i=i.replace(s,(n,o)=>{let a;return o==="u32"?a=`${Math.trunc(r)}u`:o==="i32"?a=`${Math.trunc(r)}`:a=Number.isInteger(r)?`${r}.0`:`${r}`,`const ${t}: ${o} = ${a};`})}return i}function Tv(i,e,t,r,s,n){return i*35184372088832+e*536870912+n*16384+(t<<8)+(r<<3)+s}function Mv(i){let e=wv[i];return e===void 0&&(e=wv[i]=PP++),e}function kP(i,e,t,r,s,n,o,a){return a<<20|n<<16|s<<13|t<<9|i<<6|o<<5|r<<1|e}function AP(i,e,t,r,s,n,o){return o<<11|n<<10|s<<9|r<<8|t<<5|e<<1|i}var _v,CP,EP,vv,wv,PP,$o,Cv=f(()=>{P();ie();Op();Sd();ei();Ts();Lp();_v={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4},CP=new ws({}),EP={"depth24plus-stencil8":{depth:!0,stencil:!0,index:1},depth24plus:{depth:!0,stencil:!1,index:2},depth32float:{depth:!0,stencil:!1,index:3},"depth32float-stencil8":{depth:!0,stencil:!0,index:4},depth16unorm:{depth:!0,stencil:!1,index:5},stencil8:{depth:!1,stencil:!0,index:6}},vv={depth:!1,stencil:!1,index:0};wv=Object.create(null),PP=0;$o=class{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=new Map,this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._colorFormat="bgra8unorm",this._colorFormatId=Mv("bgra8unorm"),this._depthStencilFormat="depth24plus-stencil8",this._depthStencilFormatData=vv,this._depthReadOnly=!1,this._stencilReadOnly=!1,this._invertFrontFace=!1,this._renderer=e}contextChange(e){this._gpu=e,this._moduleCache=Object.create(null),this._pipeStateCaches=Object.create(null),this.setStencilMode(_e.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){let t=e.colorAttachments[0]?.texture;this._multisampleCount=t?.source.antialias?4:1,this._colorTargetCount=e.colorAttachments.length,this._colorFormat=t?.format??"bgra8unorm",this._colorFormatId=Mv(this._colorFormat),this._depthStencilFormat=e.depthStencilAttachment?.texture.format,this._depthStencilFormatData=EP[this._depthStencilFormat]||vv,this._depthReadOnly=e.depthStencilAttachment?.depthReadOnly??!1,this._stencilReadOnly=e.depthStencilAttachment?.stencilReadOnly??this._depthReadOnly,this._invertFrontFace=this._renderer.renderTarget.isFrontFaceInverted(e,e.flipY),this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=hr[e],this._updatePipeHash())}get bundleStateKey(){let e=this._depthStencilFormatData;return AP(this._multisampleCount===1?0:1,this._colorTargetCount,e.index,e.depth&&this._depthReadOnly?1:0,e.stencil&&this._stencilReadOnly?1:0,this._invertFrontFace?1:0,this._colorFormatId)}getBundleDescriptor(){let e=[];for(let s=0;s<this._colorTargetCount;s++)e.push(this._colorFormat);let t={colorFormats:e,sampleCount:this._multisampleCount},r=this._depthStencilFormatData;return(r.depth||r.stencil)&&(t.depthStencilFormat=this._depthStencilFormat,r.depth&&this._depthReadOnly&&(t.depthReadOnly=!0),r.stencil&&this._stencilReadOnly&&(t.stencilReadOnly=!0)),t}setPipeline(e,t,r,s){let n=this.getPipeline(e,t,r);s.setPipeline(n)}getPipelineKey(e,t,r,s,n){return e._layoutKey||(Vo(e,t.attributeData),this._generateBufferKey(e)),Tv(e._layoutKey,t._layoutKey,r.data,r._blendModeId,_v[s],n.id)}getPipeline(e,t,r,s,n){e._layoutKey||(Vo(e,t.attributeData),this._generateBufferKey(e)),s||(s=e.topology),n||(n=CP);let o=Tv(e._layoutKey,t._layoutKey,r.data,r._blendModeId,_v[s],n.id),a=this._pipeCache.get(o);return a||(a=this._createPipeline(e,t,r,s,n),this._pipeCache.set(o,a)),a}_createPipeline(e,t,r,s,n){let o=this._gpu.device,a=this._createVertexBufferLayouts(e,t),l=this._renderer.state.getColorTargets(r,this._colorTargetCount,this._colorFormat),c=this._stencilMode===_e.RENDERING_MASK_ADD?0:this._colorMask;for(let g=0;g<l.length;g++)l[g].writeMask=c;let h=this._renderer.shader.getProgramData(t).pipeline,u=Object.keys(n.data).length>0,d=t.vertex.source,p=t.fragment.source,m;u&&(this._renderer.limits.supportsOverrideConstants?m=n.data:(d=Sv(d,n.data),p=Sv(p,n.data)));let x={vertex:{module:this._getModule(d),entryPoint:t.vertex.entryPoint,constants:m,buffers:a},fragment:{module:this._getModule(p),entryPoint:t.fragment.entryPoint,targets:l,constants:m},primitive:{topology:s,cullMode:r.culling?"back":"none",frontFace:r.clockwiseFrontFace!==this._invertFrontFace?"cw":"ccw"},layout:h,multisample:{count:this._multisampleCount},label:t.name?`PIXI Pipeline (${t.name})`:"PIXI Pipeline"};if(this._depthStencilFormatData.depth||this._depthStencilFormatData.stencil){let g=this._depthStencilFormatData;x.depthStencil={...this._stencilState,format:this._depthStencilFormat,depthWriteEnabled:g.depth?r.depthMask&&!this._depthReadOnly:!1,depthCompare:g.depth&&r.depthTest?"less":"always"}}return o.createRenderPipeline(x)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){let t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){let t=[],r=0,s=Object.keys(e.attributes).sort();for(let o=0;o<s.length;o++){let a=e.attributes[s[o]];t[r++]=a.offset,t[r++]=a.format,t[r++]=a.stride,t[r++]=a.instance}let n=t.join("|");return e._layoutKey=Yt(n,"geometry"),e._layoutKey}_generateAttributeLocationsKey(e){let t=[],r=0,s=Object.keys(e.attributeData).sort();for(let o=0;o<s.length;o++){let a=e.attributeData[s[o]];t[r++]=a.location}let n=t.join("|");return e._attributeLocationsKey=Yt(n,"programAttributes"),e._attributeLocationsKey}getBufferNamesToBind(e,t){let r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[r])return this._bindingNamesCache[r];let s=this._createVertexBufferLayouts(e,t),n=[],o=t.attributeData;for(let a=0;a<s.length;a++){let c=Object.values(s[a].attributes)[0].shaderLocation;for(let h in o)if(o[h].location===c){n[a]=h;break}}return this._bindingNamesCache[r]=n,n}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);let r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[r])return this._bufferLayoutsCache[r];let s=[];return e.buffers.forEach(n=>{let o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(let l in t.attributeData){let c=e.attributes[l];(c.divisor??1)!==1&&G(`Attribute ${l} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===n&&(o.arrayStride=c.stride,o.stepMode=c.instance?"instance":"vertex",a.push({shaderLocation:t.attributeData[l].location,offset:c.offset,format:c.format}))}a.length&&s.push(o)}),this._bufferLayoutsCache[r]=s,s}_updatePipeHash(){var e;let t=kP(this._stencilMode,this._multisampleCount===1?0:1,this._colorMask,this._colorTargetCount,this._depthStencilFormatData.index,this._colorFormatId,this._depthReadOnly?1:0,this._invertFrontFace?1:0);this._pipeCache=(e=this._pipeStateCaches)[t]??(e[t]=new Map)}destroy(){this._bufferLayoutsCache=null,this._pipeCache=null,this._gpu=null,this._renderer=null,this._bindingNamesCache=null,this._pipeStateCaches=null,this._moduleCache=null}};$o.extension={type:[b.WebGPUSystem],name:"pipeline"}});function Ev(i,e,t,r,s,n){let o=n?1:-1;return i.identity(),i.a=1/r*2,i.d=o*(1/s*2),i.tx=-1-e*i.a,i.ty=-o-t*i.d,i}var Pv=f(()=>{"use strict"});function kv(i){if(i.colorAttachments.length===0)return!1;let e=i.colorTexture.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}var Av=f(()=>{"use strict"});var si,Oc=f(()=>{oe();Ge();de();ie();Cs();Pv();ar();Xd();Vr();et();ye();Ep();Av();Cp();si=class{constructor(e){this.rootViewPort=new V,this.viewport=new V,this.onRenderTargetChange=new Es("onRenderTargetChange"),this.projectionMatrix=new I,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new V,this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(e){this._renderTargetStack.length=0,this.push(e),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=kv(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,r,s,n=0,o=0,a){let l;"target"in e?l=e:(B("8.20.0","RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),l={target:e,clear:t,clearColor:r,frame:s,mipLevel:n,layer:o,flipY:a});let c=l.target;t=l.clear??!0,r=l.clearColor,n=(l.mipLevel??0)|0,o=(l.layer??0)|0,a=l.flipY,s=l.frame;let h=this.getRenderTarget(c),u=this.renderTarget!==h||!!h.flipY!=!!a;this.renderTarget=h;let d=this.getGpuRenderTarget(h);(h.pixelWidth!==d.width||h.pixelHeight!==d.height)&&(this.adaptor.resizeGpuRenderTarget(h),d.width=h.pixelWidth,d.height=h.pixelHeight);let p=h.colorAttachments[0]?.texture||h.depthStencilAttachment?.texture,m=this.viewport,x=p.dimension==="3d"?Math.max(p.depth>>n,1):p.depthOrArrayLayers;if(o<0||o>=x)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (layer count=${x}).`);let y=this._bindState;y.target=c,y.frame=s?this._bindFrame.copyFrom(s):void 0,y.mipLevel=n,y.layer=o,y.flipY=a;let g=Math.max(p.pixelWidth>>n,1),v=Math.max(p.pixelHeight>>n,1);if(!s&&c instanceof F&&(s=c.frame),s){let _=p._resolution,S=1<<Math.max(n,0),T=s.x*_+.5|0,w=s.y*_+.5|0,E=s.width*_+.5|0,R=s.height*_+.5|0,k=Math.floor(T/S),C=Math.floor(w/S),M=Math.ceil(E/S),A=Math.ceil(R/S);k<0&&(M+=k,k=0),C<0&&(A+=C,C=0),k=Math.min(k,g-1),C=Math.min(C,v-1),M=Math.min(M,g-k),A=Math.min(A,v-C),M=Math.max(M,1),A=Math.max(A,1),m.x=k,m.y=C,m.width=M,m.height=A}else m.x=0,m.y=0,m.width=g,m.height=v;return h.flipY=a,Ev(this.projectionMatrix,0,0,m.width/p.resolution,m.height/p.resolution,!h.isRoot!=!!h.flipY),this.adaptor.startRenderPass(h,t,r,m,n,o),u&&this.onRenderTargetChange.emit(h),h}getBindState(e){if(!this.renderTarget)throw new Error("[RenderTargetSystem] getBindState is only valid while a render surface is bound");let t=this._bindState;return e??(e={}),e.target=t.target,e.clear=Ce.NONE,e.clearColor=void 0,t.frame?e.frame?e.frame.copyFrom(t.frame):e.frame=t.frame.clone():e.frame=void 0,e.mipLevel=t.mipLevel,e.layer=t.layer,e.flipY=!!t.flipY,e}isFrontFaceInverted(e,t){if(!e){if(e=this.renderTarget,!e)return!1;t=e.flipY}return!!t!=(this._renderer.type===He.WEBGL&&!e.isRoot)}get frontFaceInverted(){return B(_t,"RenderTargetSystem.frontFaceInverted is deprecated, use isFrontFaceInverted() instead"),this.isFrontFaceInverted()}clear(e,t=Ce.ALL,r,s=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport,s,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=Ce.ALL,r,s,n=0,o=0,a){let l;"target"in e?l=e:(B("8.20.0","RenderTargetSystem.push: positional arguments are deprecated, please use an options object instead: push({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),l={target:e,clear:t,clearColor:r,frame:s,mipLevel:n,layer:o,flipY:a});let c=this.bind(l);return this._renderTargetStack.push({target:l.target,clear:!1,clearColor:void 0,frame:l.frame?l.frame.clone():void 0,mipLevel:l.mipLevel,layer:l.layer,flipY:l.flipY}),c}pop(){this._renderTargetStack.pop();let e=this._renderTargetStack[this._renderTargetStack.length-1];if(!e)throw new Error("[RenderTargetSystem] pop: no previous binding to restore (unbalanced pop)");return this.bind(e)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,r,s,n){let o=this.getRenderTarget(e);r.x<0&&(s.width+=r.x,n.x-=r.x,r.x=0),r.y<0&&(s.height+=r.y,n.y-=r.y,r.y=0);let{pixelWidth:a,pixelHeight:l}=o;return s.width=Math.min(s.width,a-r.x),s.height=Math.min(s.height,l-r.y),this.adaptor.copyToTexture(o,t,r,s,n)}copyDepthTexture(e,t,r,s,n={x:0,y:0}){let o=this.getRenderTarget(e);if(!o.depthStencilAttachment){G("[RenderTargetSystem] copyDepthTexture: the source render target has no depth attachment to copy from");return}let a=t.source;if(!a.format.includes("depth")&&!a.format.includes("stencil")){G(`[RenderTargetSystem] copyDepthTexture: the destination texture must have a depth/stencil format (got '${a.format}')`);return}let l=r.x,c=r.y,h=n.x,u=n.y,d=s.width,p=s.height;l<0&&(d+=l,h-=l,l=0),c<0&&(p+=c,u-=c,c=0),d=Math.min(d,o.pixelWidth-l),p=Math.min(p,o.pixelHeight-c),d=Math.min(d,a.pixelWidth-h),p=Math.min(p,a.pixelHeight-u),!(d<=0||p<=0)&&this.adaptor.copyDepthTexture(o,t,{x:l,y:c},{width:d,height:p},{x:h,y:u})}ensureDepthStencil(){if(!this.renderTarget.stencil){if(this.renderTarget.depthStencilTexture){G(`[RenderTargetSystem] a stencil mask is being used, but the render target's depthStencilTexture format '${this.renderTarget.depthStencilTexture.format}' has no stencil aspect, so masking cannot work here. Use a 'depth24plus-stencil8' texture instead.`);return}this.renderTarget._depth=!0,this.renderTarget._stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer)}}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t?this._releaseRenderTarget(t,e):e.off("destroy",this._onRenderTargetDestroy,this)}),this._renderSurfaceToRenderTargetHash.clear();for(let e of Object.values(this._gpuRenderTargetHash))e&&this.adaptor.destroyGpuRenderTarget(e);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;if(Pe.test(e)&&(e=Ac(e).source),e instanceof Us)t=e,e.once("destroy",this._onRenderTargetDestroy,this);else if(e instanceof te){let r=e.format;t=r.includes("depth")||r.includes("stencil")?new Us({colorTextures:0,depthStencilTexture:e}):new Us({colorTextures:[e]}),e.source instanceof Pe&&(t.isRoot=!0),e.once("destroy",this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(e,t),t}_onRenderSurfaceDestroy(e){let t=this._renderSurfaceToRenderTargetHash.get(e);t&&this._releaseRenderTarget(e,t)}_onRenderTargetDestroy(e){this._renderSurfaceToRenderTargetHash.delete(e),this._releaseGpuRenderTarget(e)}_releaseRenderTarget(e,t){t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e),e.off("destroy",this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(t)}_releaseGpuRenderTarget(e){let t=this._gpuRenderTargetHash[e.uid];t&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(t))}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this._bindState.target=null}}});var Lc,Rv=f(()=>{et();Lc=class{constructor(e){this._pipelines=Object.create(null),this._modules=Object.create(null),this._bindGroups=new WeakMap,this._renderer=e,this._device=e.gpu.device,this._layout=this._device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"unfilterable-float"}}]}),this._pipelineLayout=this._device.createPipelineLayout({bindGroupLayouts:[this._layout]})}copy(e,t,r,s){var n;let o=this._renderer.renderTarget.getGpuRenderTarget(t),a=t.colorAttachments[r].texture;(n=o.msaaBackTextures)[r]??(n[r]=new te({label:"msaa-back-texture",width:a.width,height:a.height,resolution:a._resolution,format:o.msaaTextures[r].format,autoGenerateMipmaps:!1,autoGarbageCollect:!0}));let l=this._renderer.texture.getGpuSource(o.msaaBackTextures[r]);e.copyTextureToTexture({texture:s},{texture:l},{width:Math.min(s.width,l.width),height:Math.min(s.height,l.height)})}draw(e,t,r){var s;let n=this._renderer.renderTarget.getGpuRenderTarget(t),o=this._renderer.texture.getGpuSource(n.msaaBackTextures[r]),a=t.depthStencilAttachment?.texture.format??"";for(let h of t.colorAttachments)a+=`|${h.texture.format}`;let l=(s=this._pipelines)[a]??(s[a]=[]),c=this._bindGroups.get(o);c||(c=this._device.createBindGroup({layout:this._layout,entries:[{binding:0,resource:o.createView()}]}),this._bindGroups.set(o,c)),e.setPipeline(l[r]??(l[r]=this._createPipeline(t,r))),e.setBindGroup(0,c),e.draw(3)}_getModule(e){var t;return(t=this._modules)[e]??(t[e]=this._device.createShaderModule({label:"msaa-restore",code:`
                @group(0) @binding(0) var resolved: texture_2d<f32>;

                @vertex
                fn vertexMain(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> {
                    let pos = array<vec2<f32>, 3>(vec2<f32>(-1.0, -1.0), vec2<f32>(3.0, -1.0), vec2<f32>(-1.0, 3.0));

                    return vec4<f32>(pos[i], 0.0, 1.0);
                }

                @fragment
                fn fragmentMain(@builtin(position) position: vec4<f32>) -> @location(${e}) vec4<f32> {
                    return textureLoad(resolved, vec2<i32>(position.xy), 0);
                }
            `})),this._modules[e]}_createPipeline(e,t){let r=e.depthStencilAttachment?.texture.format,s;r&&(s={format:r},r.includes("depth")&&(s.depthWriteEnabled=!1,s.depthCompare="always"));let n=this._getModule(t);return this._device.createRenderPipeline({label:"msaa-restore",layout:this._pipelineLayout,vertex:{module:n,entryPoint:"vertexMain"},fragment:{module:n,entryPoint:"fragmentMain",targets:e.colorAttachments.map((o,a)=>({format:o.texture.format,writeMask:a===t?GPUColorWrite.ALL:0}))},depthStencil:s,multisample:{count:4}})}}});var Uc,Bv=f(()=>{ei();Uc=class{constructor(){this.contexts=[],this.canvasTextures=[],this.msaaTextures=[],this.transient=!1,this.msaaSamples=1,this.msaaBackTextures=[],this.stencilMode=_e.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}});function BP(i){if(RP[i])return i;let e=navigator.gpu.getPreferredCanvasFormat();return G(`[WebGPU] CanvasSource format '${i}' is not a valid GPUCanvasContext format. Falling back to '${e}'. Allowed formats are: bgra8unorm, rgba8unorm, rgba16float.`),e}var RP,Nc,Iv=f(()=>{ie();Cs();Vr();et();Rv();Bv();RP={bgra8unorm:!0,rgba8unorm:!0,rgba16float:!0};Nc=class{constructor(){this._activePass=null}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this),e.runners.destroy.add(this)}contextChange(){this._msaaRestore=null}destroy(){this._msaaRestore=null}copyToTexture(e,t,r,s,n){let o=this._renderer;this.finishRenderPass();let a=this._getGpuColorTexture(e),l=o.texture.getGpuSource(t.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:r},{texture:l,origin:n},s),t}copyDepthTexture(e,t,r,s,n){let o=this._renderer;this.finishRenderPass();let a=e.depthStencilAttachment.texture,l=o.texture.getGpuSource(a),c=o.texture.getGpuSource(t.source),h=o.encoder.commandEncoder===null,u=h?o.gpu.device.createCommandEncoder():o.encoder.commandEncoder;u.copyTextureToTexture({texture:l,origin:r},{texture:c,origin:n},{width:s.width,height:s.height}),h&&o.gpu.device.queue.submit([u.finish()])}startRenderPass(e,t=!0,r,s,n=0,o=0){let l=this._renderTargetSystem.getGpuRenderTarget(e);if(o!==0&&l.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&l.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");let c=t;typeof c=="boolean"&&(c=c?Ce.ALL:Ce.NONE),(e.stencil||e.depth)&&!e.depthStencilAttachment&&e.ensureDepthStencilTexture();let h=!!e.depthStencilAttachment,u=this._activePass,d=u!==null&&u.renderTarget===e&&u.mipLevel===n&&u.layer===o&&u.depthStencil===h&&this._renderer.encoder.renderPassEncoder!==null&&c===Ce.NONE;if(this._renderer.pipeline.setRenderTarget(e),d){this._renderer.encoder.setViewport(s);return}let{descriptor:p,restore:m}=this._buildDescriptor(e,t,r,n,o);l.descriptor=p;let x=this._renderer.encoder;m?(x.endRenderPass(),this._beginRestoredPass(e,m,x.commandEncoder,()=>x.beginRenderPass(l))):x.beginRenderPass(l),x.setViewport(s),this._activePass={renderTarget:e,mipLevel:n,layer:o,depthStencil:h}}finishRenderPass(){this._renderer.encoder.endRenderPass(),this._activePass=null}_beginRestoredPass(e,t,r,s){let n=this._msaaRestore??(this._msaaRestore=new Lc(this._renderer));for(let a of t)n.copy(r,e,a,this._getGpuColorTexture(e,a));let o=s();for(let a of t)n.draw(o,e,a);return o}_getGpuColorTexture(e,t=0){if(e.colorAttachments.length===0)throw new Error("[GpuRenderTargetAdaptor] cannot get gpu color texture from a depth-only render target");let r=e.colorAttachments[t].texture;return r instanceof Pe&&r._gpuContext?r._gpuContext.getCurrentTexture():this._renderer.texture.getGpuSource(r)}getDescriptor(e,t,r,s=0,n=0){return this._buildDescriptor(e,t,r,s,n).descriptor}_buildDescriptor(e,t,r,s=0,n=0){let o=null;typeof t=="boolean"&&(t=t?Ce.ALL:Ce.NONE);let a=this._renderTargetSystem,l=a.getGpuRenderTarget(e),c=e.colorAttachments.map((d,p)=>{let m=d.texture,x=m instanceof Pe?m._gpuContext:null,y,g,v=!1;if(x){if(n!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");let k=x.getCurrentTexture();v=l.canvasTextures[p]!==k,l.canvasTextures[p]=k,y=k.createView(d.viewDescriptor)}else y=this._renderer.texture.getTextureRenderTargetView(d.texture,s,n,d.viewDescriptor);let _=l.msaaTextures[p];_&&(g=y,y=this._renderer.texture.getTextureView(_));let S=d.loadOp;t!==void 0&&(S=t&Ce.COLOR?"clear":"load"),r??(r=a.defaultClearColor);let T=!!_?.transient,w=T&&S!=="clear",E=w&&!v;w&&(S="clear",E&&(o??(o=[])).push(p));let R={view:y,resolveTarget:g,storeOp:T?"discard":d.storeOp??"store",loadOp:S};m.dimension==="3d"&&(R.depthSlice=n),w?R.clearValue=[0,0,0,0]:S==="clear"&&(r??(r=d.clearValue??a.defaultClearColor),R.clearValue=r);for(let k in d)k!=="texture"&&k!=="viewDescriptor"&&k!=="clearValue"&&k!=="loadOp"&&k!=="storeOp"&&(R[k]=d[k]);return R}),h;if(e.depthStencilAttachment){this._prepareDepthStencil(e,l);let d=e.depthStencilAttachment,p=d.texture.format.includes("stencil"),m=d.texture.format.includes("depth"),x=l.transient?"discard":"store",y=l.transient?"clear":"load";h={view:this._renderer.texture.getTextureRenderTargetView(d.texture,s,n,d.viewDescriptor)};let g=d.depthReadOnly??!1,v=d.stencilReadOnly??g;p&&!v?(h.stencilLoadOp=t&Ce.STENCIL?"clear":d.stencilLoadOp??y,h.stencilStoreOp=d.stencilStoreOp??x,h.stencilLoadOp==="clear"&&(h.stencilClearValue=d.stencilClearValue??0)):p&&v&&(h.stencilReadOnly=!0),m&&!g?(h.depthLoadOp=t&Ce.DEPTH?"clear":d.depthLoadOp??y,h.depthStoreOp=d.depthStoreOp??x,h.depthLoadOp==="clear"&&(h.depthClearValue=d.depthClearValue??1)):m&&g&&(h.depthReadOnly=!0);for(let _ in d)_!=="texture"&&_!=="viewDescriptor"&&_!=="stencilLoadOp"&&_!=="stencilStoreOp"&&_!=="stencilClearValue"&&_!=="stencilReadOnly"&&_!=="depthLoadOp"&&_!=="depthStoreOp"&&_!=="depthClearValue"&&_!=="depthReadOnly"&&(h[_]=d[_])}return{descriptor:{colorAttachments:c,depthStencilAttachment:h,label:e.label},restore:o}}clear(e,t=!0,r,s,n=0,o=0){if(!t)return;let{gpu:a,encoder:l}=this._renderer,c=a.device;if(l.commandEncoder===null){let u=c.createCommandEncoder(),{descriptor:d,restore:p}=this._buildDescriptor(e,t,r,n,o),m=()=>u.beginRenderPass(d),x=p?this._beginRestoredPass(e,p,u,m):m();x.setViewport(s.x,s.y,s.width,s.height,0,1),x.end();let y=u.finish();c.queue.submit([y])}else this.startRenderPass(e,t,r,s,n,o)}initGpuRenderTarget(e){e.isRoot=!0;let t=new Uc;return t.transient=!!e.colorTexture?.antialias&&!!e.colorTexture.transient,e.colorAttachments.forEach((r,s)=>{let n=r.texture;if(n instanceof Pe){let o=n._gpuContext??(n._gpuContext=n.resource.getContext("webgpu")),a=n.transparent?"premultiplied":"opaque",l=BP(n.format);try{o.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:l,alphaMode:a,...l==="rgba16float"?{toneMapping:{mode:"extended"}}:{}})}catch(c){console.error(c)}t.contexts[s]=o}if(t.msaa=n.source.antialias,n.antialias){let o=new te({width:0,height:0,sampleCount:4,autoGenerateMipmaps:!1,transient:this._renderer.device.extensions.tileBased||t.transient,arrayLayerCount:n.arrayLayerCount,format:n.format});t.msaaTextures[s]=o}}),t.msaa&&(t.msaaSamples=4),t}_prepareDepthStencil(e,t){let r=e.depthStencilAttachment?.texture;!r||!t.msaa||(r.sampleCount=4,r.transient=t.transient)}destroyGpuRenderTarget(e){e.contexts.forEach(t=>{t.unconfigure()}),e.msaaTextures.forEach(t=>{t.destroy()}),e.msaaBackTextures.forEach(t=>{t?.destroy()}),e.msaaTextures.length=0,e.msaaBackTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){this._prepareDepthStencil(e,this._renderTargetSystem.getGpuRenderTarget(e))}resizeGpuRenderTarget(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorAttachments.forEach((r,s)=>{let n=r.texture;t.msaaTextures[s]?.resize(n.width,n.height,n._resolution),t.msaaBackTextures[s]?.resize(n.width,n.height,n._resolution)})}}});var Xo,Gv=f(()=>{P();Oc();Iv();Xo=class extends si{constructor(e){super(e),this.adaptor=new Nc,this.adaptor.init(e,this)}};Xo.extension={type:[b.WebGPUSystem],name:"renderTarget"}});var Yo,Fv=f(()=>{P();Yo=class{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e,this._gpuProgramData=Object.create(null)}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){let t=this._gpu.device,r=e.gpuLayout.map(n=>t.createBindGroupLayout({entries:n})),s={bindGroupLayouts:r};return this._gpuProgramData[e._layoutKey]={bindGroups:r,pipeline:t.createPipelineLayout(s)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}};Yo.extension={type:[b.WebGPUSystem],name:"shader"}});var ut,Dv=f(()=>{"use strict";ut={};ut.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};ut.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};ut.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};ut.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};ut.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};ut.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};ut["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};ut["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};ut["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};ut.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};ut.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};ut.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}});var Ko,Ov=f(()=>{P();Kt();Dv();Ko=class{constructor(){this.defaultState=new ze,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t,r){let s=e.blend?ut[e.blendMode]||ut.normal:void 0,n=[];for(let o=0;o<t;o++)n[o]={format:r,writeMask:0,blend:s};return n}destroy(){this.gpu=null}};Ko.extension={type:[b.WebGPUSystem],name:"state"}});function Hc(i,e,t,r,s){if(i=Math.max(0,i),e=Math.min(e,t*r),i>=e)return 0;let n=Math.floor(i/t),o=i-n*t,a=Math.floor(e/t),l=e-a*t;if(n===a)return s[0].set(o,n,l-o,1),1;let c=0,h=n;return o>0&&(s[c++].set(o,n,t-o,1),h++),a>h&&s[c++].set(0,h,t,a-h),l>0&&s[c++].set(0,a,l,1),c}var Up=f(()=>{"use strict"});var Lv,Uv,Nv=f(()=>{Ge();Up();Lv=[new V,new V,new V],Uv={type:"image",upload(i,e,t,r=0){let s=i.resource,n=i.pixelWidth|0,o=i.pixelHeight|0,a=i.depthOrArrayLayers,l=s.byteLength/(n*o*a);if(a>1){t.device.queue.writeTexture({texture:e,origin:{x:0,y:0,z:r}},s,{offset:0,rowsPerImage:o,bytesPerRow:n*l},{width:n,height:o,depthOrArrayLayers:a});return}let c=Hc(i._updateStart,i._updateEnd,n,o,Lv);for(let h=0;h<c;h++){let u=Lv[h];t.device.queue.writeTexture({texture:e,origin:{x:u.x,y:u.y,z:r}},s,{offset:(u.y*n+u.x)*l,rowsPerImage:u.height,bytesPerRow:n*l},{width:u.width,height:u.height,depthOrArrayLayers:1})}}}});var Np,IP,Hv,zv=f(()=>{"use strict";Np={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},IP={blockBytes:4,blockWidth:1,blockHeight:1},Hv={type:"compressed",upload(i,e,t,r=0){let s=i.pixelWidth,n=i.pixelHeight,o=Np[i.format]||IP;for(let a=0;a<i.resource.length;a++){let l=i.resource[a],c=Math.ceil(s/o.blockWidth)*o.blockBytes;t.device.queue.writeTexture({texture:e,mipLevel:a,origin:{x:0,y:0,z:r}},l,{offset:0,bytesPerRow:c},{width:Math.ceil(s/o.blockWidth)*o.blockWidth,height:Math.ceil(n/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}}}});function Vv(i){return{type:"cube",upload(e,t,r){let s=e.faces;for(let n=0;n<Wv.length;n++){let o=Wv[n],a=s[o];(i[a.uploadMethodId]||i.image).upload(a,t,r,n)}}}}var Wv,$v=f(()=>{"use strict";Wv=["right","left","top","bottom","front","back"]});var zc,Hp=f(()=>{we();ie();zc={type:"image",upload(i,e,t,r=0){let s=i.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){let l=W.get().createCanvas(s.width,s.height);l.getContext("2d").drawImage(s,0,0,s.width,s.height),i.resource=l,G("ImageSource: Image element passed, converting to canvas and replacing resource.")}let n=Math.min(e.width,i.resourceWidth||i.pixelWidth),o=Math.min(e.height,i.resourceHeight||i.pixelHeight),a=i.alphaMode==="premultiply-alpha-on-upload";t.device.queue.copyExternalImageToTexture({source:s},{texture:e,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:n,height:o})}}});var Xv,Yv=f(()=>{Hp();Xv={type:"video",upload(i,e,t,r){zc.upload(i,e,t,r)}}});function zp(i,e){if(!e)throw new Error("[Gpu3dMipmapGenerator] generating mipmaps for a 3D texture needs storage: true.");if(!Kv.includes(i))throw new Error(`[Gpu3dMipmapGenerator] format '${i}' can't be downsampled. Use ${Kv.join(", ")}.`)}var Kv,Wc,jv=f(()=>{"use strict";Kv=["rgba8unorm","rgba16float"];Wc=class{constructor(e){this._pipelines={},this._device=e,this._sampler=e.createSampler({magFilter:"linear",minFilter:"linear"})}_getMipmapPipeline(e){var t;return(t=this._pipelines)[e]??(t[e]=this._device.createComputePipeline({layout:"auto",compute:{module:this._device.createShaderModule({code:`
                        @group(0) @binding(0) var srcSampler : sampler;
                        @group(0) @binding(1) var src : texture_3d<f32>;
                        @group(0) @binding(2) var dst : texture_storage_3d<${e}, write>;

                        @compute @workgroup_size(4, 4, 4)
                        fn main(@builtin(global_invocation_id) gid : vec3<u32>) {
                            let dstSize = textureDimensions(dst);

                            if (gid.x >= dstSize.x || gid.y >= dstSize.y || gid.z >= dstSize.z) {
                                return;
                            }

                            // centre of the 2x2x2 footprint in the previous mip. When a dimension is
                            // odd its last texel, row or slice is never sampled, as in the 2D generator
                            let uv = (vec3<f32>(gid) * 2.0 + 1.0) / vec3<f32>(textureDimensions(src));

                            textureStore(dst, gid, textureSampleLevel(src, srcSampler, uv, 0.0));
                        }
                    `}),entryPoint:"main"}})),this._pipelines[e]}generateMipmap(e){if(e.dimension!=="3d")throw new Error("[Gpu3dMipmapGenerator] generateMipmap expects a 3D texture.");if(e.mipLevelCount<2)return;zp(e.format,(e.usage&GPUTextureUsage.STORAGE_BINDING)!==0);let t=this._getMipmapPipeline(e.format),r=t.getBindGroupLayout(0),s=this._device.createCommandEncoder({label:"Gpu3dMipmapGenerator"}),n=s.beginComputePass();n.setPipeline(t);let o=e.width,a=e.height,l=e.depthOrArrayLayers,c=e.createView({dimension:"3d",baseMipLevel:0,mipLevelCount:1});for(let h=1;h<e.mipLevelCount;h++){o=Math.max(1,o>>1),a=Math.max(1,a>>1),l=Math.max(1,l>>1);let u=e.createView({dimension:"3d",baseMipLevel:h,mipLevelCount:1});n.setBindGroup(0,this._device.createBindGroup({layout:r,entries:[{binding:0,resource:this._sampler},{binding:1,resource:c},{binding:2,resource:u}]})),n.dispatchWorkgroups(Math.ceil(o/4),Math.ceil(a/4),Math.ceil(l/4)),c=u}n.end(),this._device.queue.submit([s.finish()])}}});var Vc,qv=f(()=>{"use strict";Vc=class{constructor(e){this._pipelines={},this._device=e,this._sampler=e.createSampler({minFilter:"linear"})}_getMipmapPipeline(e){let t=this._pipelines[e];return t||(this._mipmapShaderModule||(this._mipmapShaderModule=this._device.createShaderModule({code:`
                        var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
                        vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));

                        struct VertexOutput {
                        @builtin(position) position : vec4<f32>,
                        @location(0) texCoord : vec2<f32>,
                        };

                        @vertex
                        fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
                        var output : VertexOutput;
                        output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
                        output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
                        return output;
                        }

                        @group(0) @binding(0) var imgSampler : sampler;
                        @group(0) @binding(1) var img : texture_2d<f32>;

                        @fragment
                        fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
                        return textureSample(img, imgSampler, texCoord);
                        }
                    `})),t=this._device.createRenderPipeline({layout:"auto",vertex:{module:this._mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this._mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this._pipelines[e]=t),t}generateMipmap(e){if(e.dimension==="3d")throw new Error("[GpuMipmapGenerator] a 3D texture uses Gpu3dMipmapGenerator.");if(e.dimension==="1d")throw new Error("Generating mipmaps for 1d textures is currently unsupported!");let t=this._getMipmapPipeline(e.format),r=e,s=e.depthOrArrayLayers||1,n=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){let l={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};r=this._device.createTexture(l)}let o=this._device.createCommandEncoder({}),a=t.getBindGroupLayout(0);for(let l=0;l<s;++l){let c=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),h=n?1:0;for(let u=1;u<e.mipLevelCount;++u){let d=r.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),p=o.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),m=this._device.createBindGroup({layout:a,entries:[{binding:0,resource:this._sampler},{binding:1,resource:c}]});p.setPipeline(t),p.setBindGroup(0,m),p.draw(3,1,0,0),p.end(),c=d}}if(!n){let l={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s};for(let c=1;c<e.mipLevelCount;++c)o.copyTextureToTexture({texture:r,mipLevel:c-1},{texture:e,mipLevel:c},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this._device.queue.submit([o.finish()]),n||r.destroy(),e}}});function FP(i){return GP.test(i)?[`${i}-srgb`]:void 0}function Zv(i){return`${i.format||""}.${i.dimension||""}.${i.aspect||""}.${i.baseMipLevel||0}.${i.mipLevelCount||""}.${i.baseArrayLayer||0}.${i.arrayLayerCount||""}`}var Wp,GP,Vp,$p,Jv=f(()=>{we();P();Dt();Tt();vs();Xr();Nv();zv();$v();Hp();Yv();jv();qv();Wp=class{constructor(e){this.textureView=null,this.textureViews=Object.create(null),this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.textureViews=null,this.gpuTexture=null}},GP=/^(rgba8|bgra8|bc[1237]-rgba-|etc2-rgb8|etc2-rgb8a1|etc2-rgba8|astc-\d+x\d+-)unorm$/;Vp=class Qv{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new Ee({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});let t={image:zc,buffer:Uv,video:Xv,compressed:Hv,...Qv.uploadExtensions};this._uploads={...t,cube:Vv(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e,this._managedTextures.removeAll(),this._gpuSamplers=Object.create(null),this._mipmapGenerator=null,this._mipmap3dGenerator=null}initSource(e){return e._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){e.dimension==="3d"&&zp(e.format,e.storage);let h=Math.max(e.pixelWidth,e.pixelHeight,e.depth);e.mipLevelCount=Math.floor(Math.log2(h))+1}let t,r;e.sampleCount>1?(t=GPUTextureUsage.RENDER_ATTACHMENT,e.transient&&this._renderer.device.extensions.transientAttachment&&(t|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,e.uploadMethodId!=="compressed"&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC),e.storage&&(t|=GPUTextureUsage.STORAGE_BINDING),r=FP(e.format));let s=Np[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},n=Math.ceil(e.pixelWidth/s.blockWidth)*s.blockWidth,o=Math.ceil(e.pixelHeight/s.blockHeight)*s.blockHeight,a={label:e.label,size:{width:n,height:o,depthOrArrayLayers:e.depthOrArrayLayers},format:e.format,viewFormats:r,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},l=this._gpu.device.createTexture(a);return e._gpuData[this._renderer.uid]=new Wp(l),this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),l}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){let t=this.getGpuSource(e);if(e.dimension==="3d"){this._mipmap3dGenerator??(this._mipmap3dGenerator=new Wc(this._gpu.device)),this._mipmap3dGenerator.generateMipmap(t);return}this._mipmapGenerator??(this._mipmapGenerator=new Vc(this._gpu.device)),this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;let t=e._gpuData[this._renderer.uid],r=t?.gpuTexture;r?(r.width!==e.pixelWidth||r.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new qe({0:t,1:t.style,2:new Me({uTextureMatrix:{type:"mat3x3<f32>",value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e,t){var r;let s=e.source;s._gcLastUsed=this._renderer.gc.now;let n=s._gpuData[this._renderer.uid];n||(this.initSource(s),n=s._gpuData[this._renderer.uid]);let o=t?Zv(t):0;return(r=n.textureViews)[o]||(r[o]=n.gpuTexture.createView({dimension:s.viewDimension,...t})),n.textureViews[o]}getTextureRenderTargetView(e,t=0,r=0,s){var n;let o=e.source;o._gcLastUsed=this._renderer.gc.now;let a=o._gpuData[this._renderer.uid];a||(this.initSource(o),a=o._gpuData[this._renderer.uid]);let l=o.dimension==="3d";l&&(r=0);let c=r*(o.mipLevelCount||1)+t+1;return s&&(c=`${c}.${Zv(s)}`),(n=a.textureViews)[c]||(n[c]=a.gpuTexture.createView({dimension:l?"3d":"2d",baseMipLevel:t,mipLevelCount:1,baseArrayLayer:r,arrayLayerCount:1,...s})),a.textureViews[c]}generateCanvas(e){let t=this._renderer,r=t.gpu.device.createCommandEncoder(),s=W.get().createCanvas();s.width=e.source.pixelWidth,s.height=e.source.pixelHeight;let n=s.getContext("webgpu");return n.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:W.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),t.gpu.device.queue.submit([r.finish()]),s}getPixels(e){let t=this.generateCanvas(e),r=ct.getOptimalCanvasAndContext(t.width,t.height),s=r.context;s.drawImage(t,0,0);let{width:n,height:o}=t,a=s.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return ct.returnCanvasAndContext(r),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._mipmap3dGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};Vp.extension={type:[b.WebGPUSystem],name:"texture"};Vp.uploadExtensions=Object.create(null);$p=Vp;H.handleByMap(b.TextureUploaderWebGPU,$p.uploadExtensions)});var sS={};Fa(sS,{WebGPURenderer:()=>Xp});var DP,OP,LP,eS,tS,rS,iS,Xp,nS=f(()=>{P();Vb();Yb();Kb();Ps();Bc();ar();iv();sv();nv();ov();lv();cv();hv();xv();bv();Cv();Gv();Fv();Ov();Jv();DP=[...Hs,zo,Lo,zs,Uo,Do,$p,Xo,Yo,Ko,$o,Oo,No,Fo],OP=[...Rc,Wo],LP=[fo,po,uo],eS=[],tS=[],rS=[],iS=[];H.handleByNamedList(b.WebGPUSystem,eS);H.handleByNamedList(b.WebGPUPipes,tS);H.handleByNamedList(b.WebGPUPipesAdaptor,rS);H.handleByNamedList(b.WebGPULoader,iS);H.add(...DP,...OP,...LP);Xp=class extends cr{constructor(){let e={name:"webgpu",type:He.WEBGPU,systems:eS,renderPipes:tS,renderPipeAdaptors:rS,loaders:iS};super(e)}}});var jo,oS=f(()=>{P();oe();Bi();ao();lo();ho();Ii();Mc();lr();Tt();jo=class{contextChange(e){let t=new Me({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),r=e.limits.maxBatchableTextures,s=qr({name:"graphics",bits:[Rs,Is(r),yc,Qr]});this.shader=new De({glProgram:s,resources:{localUniforms:t,batchSamplers:Ds(r)}})}execute(e,t){let r=t.context,s=r.customShader||this.shader,n=e.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(e.state),n.shader.bind(s),n.geometry.bind(a.geometry,s.glProgram);let c=l.instructions;for(let h=0;h<l.instructionSize;h++){let u=c[h];if(u.size){for(let d=0;d<u.textures.count;d++)n.texture.bind(u.textures.textures[d],d);n.texture.unbindIntegerTextures(u.textures.count),n.geometry.draw(u.topology,u.size,u.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}};jo.extension={type:[b.WebGLPipesAdaptor],name:"graphics"}});var qo,aS=f(()=>{P();oe();Bi();ho();Ii();ep();lr();ye();ie();qo=class{init(){let e=qr({name:"mesh",bits:[yc,Xb,Qr]});this._shader=new De({glProgram:e,resources:{uTexture:F.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new I}}}})}execute(e,t){let r=e.renderer,s=t._shader;if(s){if(!s.glProgram){G("Mesh shader has no glProgram",t.shader);return}}else{s=this._shader;let n=t.texture,o=n.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}s.groups[100]=r.globalUniforms.bindGroup,s.groups[101]=e.localUniformsBindGroup,r.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};qo.extension={type:[b.WebGLPipesAdaptor],name:"mesh"}});var Zo,lS=f(()=>{P();Kt();Zo=class{constructor(){this._tempState=ze.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,r){let s=e.renderer,n=this._didUploadHash[r.uid];s.shader.bind(r,n),n||(this._didUploadHash[r.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(t,r.glProgram)}execute(e,t){let r=e.renderer;this._tempState.blendMode=t.blendMode,r.state.set(this._tempState);let s=t.textures.textures;for(let n=0;n<t.textures.count;n++)r.texture.bind(s[n],n);r.texture.unbindIntegerTextures(t.textures.count),r.geometry.draw(t.topology,t.size,t.start)}};Zo.extension={type:[b.WebGLPipesAdaptor],name:"batch"}});var Qo,cS=f(()=>{"use strict";Qo=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(Qo||{})});var $c,hS=f(()=>{"use strict";$c=class{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}});var Jo,uS=f(()=>{P();Dt();Yr();cS();hS();Jo=class{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new Ee({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,r=this.getGlBuffer(e);t.bindBuffer(r.type,r.buffer)}bindBufferBase(e,t){let{_gl:r}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,r.bindBufferBase(r.UNIFORM_BUFFER,t,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let r=0,s=this._nextBindBaseIndex;for(;r<2;){s>=this._maxBindings&&(s=this._minBaseLocation,r++);let n=this._boundBufferBases[s];if(n&&n._lastBindCallId===this._bindCallId){s++;continue}break}return t=s,this._nextBindBaseIndex=s+1,r>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){let t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,r,s){let{_gl:n}=this;r||(r=0),t||(t=0),this._boundBufferBases[t]=null,n.bindBufferRange(n.UNIFORM_BUFFER,t||0,e.buffer,r*256,s||256)}updateBuffer(e){let{_gl:t}=this,r=this.getGlBuffer(e);if(e._updateID===r.updateID)return r;r.updateID=e._updateID,t.bindBuffer(r.type,r.buffer);let s=e.data,n=e.descriptor.usage&se.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return s?r.byteLength>=s.byteLength?t.bufferSubData(r.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT):(r.byteLength=s.byteLength,t.bufferData(r.type,s,n)):(r.byteLength=e.descriptor.size,t.bufferData(r.type,r.byteLength,n)),r}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){let r=e._gpuData[this._renderer.uid];r&&(t||this._gl.deleteBuffer(r.buffer))}createGLBuffer(e){let{_gl:t}=this,r=Qo.ARRAY_BUFFER;e.descriptor.usage&se.INDEX?r=Qo.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&se.UNIFORM&&(r=Qo.UNIFORM_BUFFER);let s=new $c(t.createBuffer(),r);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}};Jo.extension={type:[b.WebGLSystem],name:"buffer"}});var Yp,pS,fS=f(()=>{we();P();ie();Yp=class dS{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...dS.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(G("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=W.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{let r=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:r,premultipliedAlpha:s,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&G("multiView is disabled, but targetCanvas is not the main canvas");return}let{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof W.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let r,s=this.canvas;if(e===2&&(r=s.getContext("webgl2",t)),!r&&(r=s.getContext("webgl",t),!r))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=r,this.initFromContext(this.gl)}getExtensions(){let{gl:e}=this,t={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...t,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};let r=e.getExtension("WEBGL_provoking_vertex");r&&r.provokingVertexWEBGL(r.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){let t=e.getContextAttributes();t&&!t.stencil&&G("Provided WebGL context does not have a stencil buffer, masks may not render correctly");let r=this.supports,s=this.webGLVersion===2,n=this.extensions;r.uint32Indices=s||!!n.uint32ElementIndex,r.uniformBufferObject=s,r.vertexArrayObject=s||!!n.vertexArrayObject,r.srgbTextures=s||!!n.srgb,r.nonPowOf2wrapping=s,r.nonPowOf2mipmaps=s,r.msaa=s,r.uint32Indices||G("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Yp.extension={type:[b.WebGLSystem],name:"context"};Yp.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};pS=Yp});var Xc,ni,he,ea=f(()=>{"use strict";Xc=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(Xc||{}),ni=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(ni||{}),he=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(he||{})});function gS(i){return mS[i]??mS.float32}var mS,xS=f(()=>{ea();mS={uint8x2:he.UNSIGNED_BYTE,uint8x4:he.UNSIGNED_BYTE,sint8x2:he.BYTE,sint8x4:he.BYTE,unorm8x2:he.UNSIGNED_BYTE,unorm8x4:he.UNSIGNED_BYTE,snorm8x2:he.BYTE,snorm8x4:he.BYTE,uint16x2:he.UNSIGNED_SHORT,uint16x4:he.UNSIGNED_SHORT,sint16x2:he.SHORT,sint16x4:he.SHORT,unorm16x2:he.UNSIGNED_SHORT,unorm16x4:he.UNSIGNED_SHORT,snorm16x2:he.SHORT,snorm16x4:he.SHORT,float16x2:he.HALF_FLOAT,float16x4:he.HALF_FLOAT,float32:he.FLOAT,float32x2:he.FLOAT,float32x3:he.FLOAT,float32x4:he.FLOAT,uint32:he.UNSIGNED_INT,uint32x2:he.UNSIGNED_INT,uint32x3:he.UNSIGNED_INT,uint32x4:he.UNSIGNED_INT,sint32:he.INT,sint32x2:he.INT,sint32x3:he.INT,sint32x4:he.INT}});var UP,Kp,ta,yS=f(()=>{P();Dt();Zn();Op();xS();UP={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},Kp=class{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}},ta=class{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new Ee({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=s=>t.bindVertexArrayOES(s),e.deleteVertexArray=s=>t.deleteVertexArrayOES(s));let r=this._renderer.context.extensions.vertexAttribDivisorANGLE;r&&(e.drawArraysInstanced=(s,n,o,a)=>{r.drawArraysInstancedANGLE(s,n,o,a)},e.drawElementsInstanced=(s,n,o,a,l)=>{r.drawElementsInstancedANGLE(s,n,o,a,l)},e.vertexAttribDivisor=(s,n)=>r.vertexAttribDivisorANGLE(s,n)),this._activeGeometry=null,this._activeVao=null}bind(e,t){let r=this.gl;this._activeGeometry=e;let s=this.getVao(e,t);this._activeVao!==s&&(this._activeVao=s,r.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let r=0;r<e.buffers.length;r++){let s=e.buffers[r];t.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){let r=e.attributes,s=t._attributeData;for(let n in s)if(!r[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(e,t){let r=e.attributes,s=t._attributeData,n=["g",e.uid];for(let o in r)s[o]&&n.push(o,s[o].location);return n.join("-")}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,r=!0){let s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let o=this.getSignature(e,t),a=e._gpuData[this._renderer.uid];a||(a=new Kp,e._gpuData[this._renderer.uid]=a,this._managedGeometries.add(e));let l=a.vaoCache,c=l[o];if(c)return l[t._key]=c,c;Vo(e,t._attributeData);let h=e.buffers;c=s.createVertexArray(),s.bindVertexArray(c);for(let u=0;u<h.length;u++){let d=h[u];n.bind(d)}return this.activateVao(e,t),l[t._key]=c,l[o]=c,s.bindVertexArray(null),c}onGeometryUnload(e,t=!1){let r=e._gpuData[this._renderer.uid];if(!r)return;let s=r.vaoCache;if(!t)for(let n in s)this._activeVao===s[n]&&this.resetState(),this.gl.deleteVertexArray(s[n])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){let r=this._renderer.gl,s=this._renderer.buffer,n=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let o=null;for(let a in n){let l=n[a],c=l.buffer,h=s.getGlBuffer(c),u=t._attributeData[a];if(u){o!==h&&(s.bind(c),o=h);let d=u.location;r.enableVertexAttribArray(d);let p=Er(l.format),m=gS(l.format);if(u.format?.substring(1,4)==="int"?r.vertexAttribIPointer(d,p.size,m,l.stride,l.offset):r.vertexAttribPointer(d,p.size,m,p.normalised,l.stride,l.offset),l.instance)if(this.hasInstance){let x=l.divisor??1;r.vertexAttribDivisor(d,x)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,r,s){let{gl:n}=this._renderer,o=this._activeGeometry,a=UP[e||o.topology];if(s??(s=o.instanceCount),o.indexBuffer){let l=o.indexBuffer.data.BYTES_PER_ELEMENT,c=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT,h=t||o.indexCount||o.indexBuffer.data.length,u=(r||0)*l;s!==1?n.drawElementsInstanced(a,h,c,u,s):n.drawElements(a,h,c,u)}else s!==1?n.drawArraysInstanced(a,r||0,t||o.vertexCount,s):n.drawArrays(a,r||0,t||o.vertexCount);return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};ta.extension={type:[b.WebGLSystem],name:"geometry"}});var NP,jp,_S,vS=f(()=>{P();ie();ki();lr();Kt();et();ye();$r();NP=new ht({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),jp=class bS{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){let{useBackBuffer:t,antialias:r}={...bS.defaultOptions,...e};this.useBackBuffer=t,this._antialias=r,this._renderer.context.supports.msaa||(G("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=ze.for2d();let s=new Fe({vertex:`
                attribute vec2 aPosition;
                out vec2 vUv;

                void main() {
                    gl_Position = vec4(aPosition, 0.0, 1.0);

                    vUv = (aPosition + 1.0) / 2.0;

                    // flip dem UVs
                    vUv.y = 1.0 - vUv.y;
                }`,fragment:`
                in vec2 vUv;
                out vec4 finalColor;

                uniform sampler2D uTexture;

                void main() {
                    finalColor = texture(uTexture, vUv);
                }`,name:"big-triangle"});this._bigTriangleShader=new De({glProgram:s,resources:{uTexture:F.WHITE.source}})}renderStart(e){let t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){let r=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=r.colorTexture,e.target=this._getBackBufferTexture(r.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind({target:this._targetTexture,clear:!1}),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:NP,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new F({source:new te({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};jp.extension={type:[b.WebGLSystem],name:"backBuffer",priority:1};jp.defaultOptions={useBackBuffer:!1};_S=jp});var ra,SS=f(()=>{P();ra=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}};ra.extension={type:[b.WebGLSystem],name:"colorMask"}});var ia,TS=f(()=>{P();ia=class{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:r,shader:s,state:n,skipSync:o,topology:a,size:l,start:c,instanceCount:h}=e;t.shader.bind(s,o),t.geometry.bind(r,t.shader._activeProgram),n&&t.state.set(n),t.geometry.draw(a,l,c,h??r.instanceCount)}destroy(){this._renderer=null}};ia.extension={type:[b.WebGLSystem],name:"encoder"}});var sa,wS=f(()=>{P();up();sa=class{constructor(e){this._renderer=e}contextChange(){let e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=vc(this.maxTextures,e);let t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}};sa.extension={type:[b.WebGLSystem],name:"limits"}});var na,MS=f(()=>{P();Lp();ei();na=class{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:_e.NONE},this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._activeGpuRenderTarget=null,this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=_e.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){let r=this._activeGpuRenderTarget??(this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget)),s=this._gl,n=hr[e],o=this._stencilCache;if(r.stencilMode=e,r.stencilReference=t,e===_e.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(e!==o.stencilMode||o.stencilReference!==t)&&(o.stencilMode=e,o.stencilReference=t,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],t,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._gl=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}};na.extension={type:[b.WebGLSystem],name:"stencil"}});function CS(i){let e=i.map(n=>({data:n,offset:0,size:0})),t=16,r=0,s=0;for(let n=0;n<e.length;n++){let o=e[n];if(r=qp[o.data.type],!r)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(r=Math.max(r,t)*o.data.size);let a=r===12?16:r;o.size=r;let l=s%t;l>0&&t-l<a?s+=(t-l)%16:s+=(r-l%r)%r,o.offset=s,s+=r}return s=Math.ceil(s/16)*16,{uboElements:e,size:s}}var qp,Zp=f(()=>{"use strict";qp={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,u32:4,"vec2<u32>":8,"vec3<u32>":12,"vec4<u32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64}});function ES(i,e){let t=Math.max(qp[i.data.type]/16,1),r=i.data.value.length/i.data.size,s=(4-r%4)%4,n=i.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
        v = uv.${i.data.name};
        offset += ${e};

        arrayOffset = offset;

        t = 0;

        for(var i=0; i < ${i.data.size*t}; i++)
        {
            for(var j = 0; j < ${r}; j++)
            {
                ${n}[arrayOffset++] = v[t++];
            }
            ${s!==0?`arrayOffset += ${s};`:""}
        }
    `}var PS=f(()=>{Zp()});function kS(i){return Gc(i,Fp,ES)}var AS=f(()=>{Gp();Dp();PS()});var oa,RS=f(()=>{P();Rp();Zp();AS();oa=class extends Ws{constructor(){super({createUboElements:CS,generateUboSync:kS})}};oa.extension={type:[b.WebGLSystem],name:"ubo"}});var Yc,BS=f(()=>{ei();Yc=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[],this.stencilMode=_e.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}});var Kc,IS=f(()=>{Ge();ie();Vr();Cs();BS();Kc=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V,this._boundFramebuffer=void 0}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V,this._boundFramebuffer=void 0;let e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(r,s)=>e.COLOR_ATTACHMENT0+s)}copyToTexture(e,t,r,s,n){let o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(e),c=a.gl;return this.finishRenderPass(e),c.bindFramebuffer(c.FRAMEBUFFER,l.resolveTargetFramebuffer),this._boundFramebuffer=l.resolveTargetFramebuffer,a.texture.bind(t,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,n.x,n.y,r.x,r.y,s.width,s.height),t}copyDepthTexture(e,t,r,s,n){let o=this._renderTargetSystem,a=this._renderer.gl;this.finishRenderPass(e);let l=o.getRenderTarget(t),c=o.getGpuRenderTarget(e),h=o.getGpuRenderTarget(l);a.bindFramebuffer(a.READ_FRAMEBUFFER,c.framebuffer),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,h.framebuffer),this._boundFramebuffer=void 0,a.blitFramebuffer(r.x,r.y,r.x+s.width,r.y+s.height,n.x,n.y,n.x+s.width,n.y+s.height,a.DEPTH_BUFFER_BIT,a.NEAREST)}startRenderPass(e,t=!0,r,s,n=0,o=0){let l=this._renderTargetSystem.getGpuRenderTarget(e);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(l.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}e.colorAttachments.forEach(d=>{this._renderer.texture.unbind(d.texture)});let c=this._renderer.gl;this.bindFramebuffer(l.framebuffer),!e.isRoot&&e.colorAttachments.length>0&&(l._attachedMipLevel!==n||l._attachedLayer!==o)&&(e.colorAttachments.forEach((d,p)=>{let m=d.texture,x=this._renderer.texture.getGlSource(m);if(x.target===c.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+p,c.TEXTURE_2D,x.texture,n)}else if(x.target===c.TEXTURE_2D_ARRAY||x.target===c.TEXTURE_3D)c.framebufferTextureLayer(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+p,x.texture,n,o);else if(x.target===c.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+p,c.TEXTURE_CUBE_MAP_POSITIVE_X+o,x.texture,n)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),l._attachedMipLevel=n,l._attachedLayer=o),l.framebuffer&&(e.depthStencilAttachment?this._attachDepthStencilTexture(e,n,o):!l.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(l)),e.colorAttachments.length>1&&this._setDrawBuffers(e,c);let h=s.y;e.isRoot&&(h=e.pixelHeight-s.height-s.y);let u=this._viewPortCache;(u.x!==s.x||u.y!==h||u.width!==s.width||u.height!==s.height)&&(u.x=s.x,u.y=h,u.width=s.width,u.height=s.height,c.viewport(s.x,h,s.width,s.height)),this.clear(e,t,r)}finishRenderPass(e){let r=this._renderTargetSystem.getGpuRenderTarget(e);if(!r.msaa||e.colorAttachments.length===0)return;let s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,r.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,r.framebuffer),s.blitFramebuffer(0,0,r.width,r.height,0,0,r.width,r.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,r.framebuffer),this._boundFramebuffer=r.framebuffer}initGpuRenderTarget(e){let r=this._renderer.gl,s=new Yc;s._attachedMipLevel=0,s._attachedLayer=0;let n=e.colorTexture;return n instanceof Pe?(this._renderer.context.ensureCanvasSize(n.resource),s.framebuffer=null,s):(s.width=e.pixelWidth,s.height=e.pixelHeight,e.colorAttachments.length===0?this._initDepth(e,s):this._initColor(e,s),e.depthStencilAttachment&&this._attachDepthStencilTexture(e,0,0),r.bindFramebuffer(r.FRAMEBUFFER,null),this._boundFramebuffer=null,s)}destroyGpuRenderTarget(e){let t=this._renderer.gl;e.framebuffer&&(t.deleteFramebuffer(e.framebuffer),e.framebuffer=null),e.resolveTargetFramebuffer&&(t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null),e.depthStencilRenderBuffer&&(t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null),e.msaaRenderBuffer.forEach(r=>{t.deleteRenderbuffer(r)}),e.msaaRenderBuffer.length=0}clear(e,t,r,s,n=0,o=0){if(!t)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");let a=this._renderTargetSystem;if(typeof t=="boolean"&&(t=t?Ce.ALL:Ce.NONE),e.colorAttachments.length===0&&(t&=~Ce.COLOR,!t))return;let l=this._renderer.gl,c=!!(t&Ce.DEPTH)&&!this._renderer.state.depthMaskEnabled;if(t&Ce.COLOR){r??(r=a.defaultClearColor);let h=this._clearColorCache,u=r;(h[0]!==u[0]||h[1]!==u[1]||h[2]!==u[2]||h[3]!==u[3])&&(h[0]=u[0],h[1]=u[1],h[2]=u[2],h[3]=u[3],l.clearColor(u[0],u[1],u[2],u[3]))}c&&l.depthMask(!0),l.clear(t),c&&l.depthMask(!1)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.pixelWidth,t.height=e.pixelHeight,e.colorAttachments.length>0&&this._resizeColor(e,t),t.depthStencilRenderBuffer&&this._resizeStencil(t),this._boundFramebuffer=void 0}_initColor(e,t){let r=this._renderer,s=r.gl,n=s.createFramebuffer();if(t.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.colorAttachments.forEach((a,l)=>{let c=a.texture;c.antialias&&(r.context.supports.msaa?t.msaa=!0:G("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(c,0);let h=r.texture.getGlSource(c),u=h.texture;if(h.target===s.TEXTURE_2D)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,s.TEXTURE_2D,u,0);else if(h.target===s.TEXTURE_2D_ARRAY||h.target===s.TEXTURE_3D)s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,u,0,0);else if(h.target===s.TEXTURE_CUBE_MAP)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,s.TEXTURE_CUBE_MAP_POSITIVE_X,u,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){let a=s.createFramebuffer();t.framebuffer=a,s.bindFramebuffer(s.FRAMEBUFFER,a),e.colorAttachments.forEach((l,c)=>{let h=s.createRenderbuffer();t.msaaRenderBuffer[c]=h})}else t.framebuffer=n;this._resizeColor(e,t)}_initDepth(e,t){let r=this._renderer;if(r.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Depth-only render targets require WebGL2.");let s=r.gl,n=s.createFramebuffer();t.resolveTargetFramebuffer=n,t.framebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),s.drawBuffers([s.NONE]),s.readBuffer(s.NONE)}_resizeColor(e,t){let r=e.colorAttachments[0].texture;if(t._attachedMipLevel=0,t._attachedLayer=0,e.colorAttachments.forEach((s,n)=>{n!==0&&s.texture.resize(r.width,r.height,r._resolution)}),t.msaa){let s=this._renderer,n=s.gl,o=t.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),e.colorAttachments.forEach((a,l)=>{let c=a.texture;s.texture.bindSource(c,0);let u=s.texture.getGlSource(c).internalFormat,d=t.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,d),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,u,c.pixelWidth,c.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,d)})}}_attachDepthStencilTexture(e,t,r){let s=this._renderer,n=s.gl,o=e.depthStencilAttachment.texture,a=s.texture.getGlSource(o),l=a.texture,c=o.format,h;c==="depth24plus-stencil8"||c==="depth32float-stencil8"?h=n.DEPTH_STENCIL_ATTACHMENT:c==="stencil8"?h=n.STENCIL_ATTACHMENT:h=n.DEPTH_ATTACHMENT,a.target===n.TEXTURE_2D?n.framebufferTexture2D(n.FRAMEBUFFER,h,n.TEXTURE_2D,l,t):a.target===n.TEXTURE_2D_ARRAY||a.target===n.TEXTURE_3D?n.framebufferTextureLayer(n.FRAMEBUFFER,h,l,t,r):a.target===n.TEXTURE_CUBE_MAP&&n.framebufferTexture2D(n.FRAMEBUFFER,h,n.TEXTURE_CUBE_MAP_POSITIVE_X+r,l,t)}_initStencil(e){if(e.framebuffer===null)return;let t=this._renderer.gl,r=t.createRenderbuffer();e.depthStencilRenderBuffer=r,t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,r),this._resizeStencil(e)}_resizeStencil(e){let t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){if(e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture.resource;this._renderer.context.multiView&&Pe.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(!this._renderer.context.multiView||e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture;if(Pe.test(t.resource)){let r=this._renderer.context.canvas,s=t;s.context2D.drawImage(r,0,s.pixelHeight-r.height)}}_setDrawBuffers(e,t){let r=e.colorAttachments.length,s=this._drawBuffersCache[r];if(this._renderer.context.webGLVersion===1){let n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(s):G("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(s)}resetState(){this._boundFramebuffer=void 0,this._viewPortCache=new V,this._clearColorCache=[0,0,0,0]}bindFramebuffer(e){this._boundFramebuffer!==e&&(this._boundFramebuffer=e,this._renderer.gl.bindFramebuffer(this._renderer.gl.FRAMEBUFFER,e))}}});var aa,GS=f(()=>{P();Oc();IS();aa=class extends si{constructor(e){super(e),this.adaptor=new Kc,this.adaptor.init(e,this)}resetState(){this.adaptor.resetState()}};aa.extension={type:[b.WebGLSystem],name:"renderTarget"}});var jc,FS=f(()=>{Oe();Ue();jc=class extends le{constructor(e,t){super(),this._resourceType="textureView",this._resourceId=K("resource"),this.source=e,this.viewDescriptor=t,this._onChange=this._onChange.bind(this),this._onDestroy=this._onDestroy.bind(this),this.source.on("change",this._onChange),this.source.on("destroy",this._onDestroy)}_onChange(){this.emit("change",this)}_onDestroy(){this.destroy()}get destroyed(){return this.source.destroyed}destroy(){this.source&&(this.source.off("change",this._onChange),this.source.off("destroy",this._onDestroy)),this.emit("destroy",this),this.removeAllListeners()}}});function DS(i,e){let t=[],r=[`
        var g = s.groups;
        var sS = r.shader;
        var p = s.glProgram;
        var ugS = r.uniformGroup;
        var resources;
    `],s=!1,n=0,o=e._getProgramData(i.glProgram);for(let l in i.groups){let c=i.groups[l];t.push(`
            resources = g[${l}].resources;
        `);for(let h in c.resources){let u=c.resources[h];if(u instanceof Me)if(u.ubo){let d=i._uniformBindMap[l][Number(h)];t.push(`
                        sS.bindUniformBlock(
                            resources[${h}],
                            '${d}',
                            ${i.glProgram._uniformBlockData[d].index}
                        );
                    `)}else t.push(`
                        ugS.updateUniformGroup(resources[${h}], p, sD);
                    `);else if(u instanceof ri){let d=i._uniformBindMap[l][Number(h)];t.push(`
                    sS.bindUniformBlock(
                        resources[${h}],
                        '${d}',
                        ${i.glProgram._uniformBlockData[d].index}
                    );
                `)}else if(u instanceof te||u instanceof jc){let d=i._uniformBindMap[l][h],p=o.uniformData[d];p&&(s||(s=!0,r.push(`
                        var tS = r.texture;
                        `)),e._gl.uniform1i(p.location,n),t.push(`
                        tS.bind(resources[${h}], ${n});
                    `),n++)}}}let a=[...r,...t].join(`
`);return new Function("r","s","sD",a)}var OS=f(()=>{Fc();Tt();et();FS()});var qc,LS=f(()=>{"use strict";qc=class{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}});function Qp(i,e,t){let r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),r}var US=f(()=>{"use strict"});function Jp(i){let e=new Array(i);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Zc(i,e){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":case"sampler3D":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Jp(2*e);case"bvec3":return Jp(3*e);case"bvec4":return Jp(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var ef=f(()=>{"use strict"});function tf(i,e){if(!Qc){let t=Object.keys(NS);Qc={};for(let r=0;r<t.length;++r){let s=t[r];Qc[i[s]]=NS[s]}}return Qc[e]}function HS(i,e){let t=tf(i,e);return HP[t]||"float32"}var Qc,NS,HP,rf=f(()=>{"use strict";Qc=null,NS={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_2D_SHADOW:"sampler2DShadow",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_CUBE_SHADOW:"samplerCubeShadow",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray",SAMPLER_2D_ARRAY_SHADOW:"sampler2DArrayShadow",SAMPLER_3D:"sampler3D",INT_SAMPLER_3D:"sampler3D",UNSIGNED_INT_SAMPLER_3D:"sampler3D"},HP={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"}});function zS(i,e,t=!1){let r={},s=e.getProgramParameter(i,e.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){let a=e.getActiveAttrib(i,o);if(a.name.startsWith("gl_"))continue;let l=HS(e,a.type);r[a.name]={location:0,format:l,stride:Er(l).stride,offset:0,instance:!1,start:0}}let n=Object.keys(r);if(t){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)r[n[o]].location=o,e.bindAttribLocation(i,o,n[o]);e.linkProgram(i)}else for(let o=0;o<n.length;o++)r[n[o]].location=e.getAttribLocation(i,n[o]);return r}var WS=f(()=>{Zn();rf()});function VS(i,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};let t={},r=e.getProgramParameter(i,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<r;s++){let n=e.getActiveUniformBlockName(i,s),o=e.getUniformBlockIndex(i,n),a=e.getActiveUniformBlockParameter(i,s,e.UNIFORM_BLOCK_DATA_SIZE);t[n]={name:n,index:o,size:a}}return t}var $S=f(()=>{"use strict"});function XS(i,e){let t={},r=e.getProgramParameter(i,e.ACTIVE_UNIFORMS);for(let s=0;s<r;s++){let n=e.getActiveUniform(i,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=tf(e,n.type);t[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Zc(l,n.size)}}return t}var YS=f(()=>{ef();rf()});function KS(i,e){let t=i.getShaderSource(e);if(t===null){console.error("PixiJS Error: Could not retrieve shader source (WebGL context may be lost).");return}let r=t.split(`
`).map((h,u)=>`${u}: ${h}`),s=i.getShaderInfoLog(e)??"",n=s.split(`
`),o={},a=n.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!o[h]?(o[h]=!0,!0):!1),l=[""];a.forEach(h=>{r[h-1]=`%c${r[h-1]}%c`,l.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});let c=r.join(`
`);l[0]=c,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...l),console.groupEnd()}function jS(i,e,t,r){i.getProgramParameter(e,i.LINK_STATUS)||(i.getShaderParameter(t,i.COMPILE_STATUS)||KS(i,t),i.getShaderParameter(r,i.COMPILE_STATUS)||KS(i,r),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(e)))}var qS=f(()=>{"use strict"});function ZS(i,e){let t=Qp(i,i.VERTEX_SHADER,e.vertex),r=Qp(i,i.FRAGMENT_SHADER,e.fragment),s=i.createProgram();i.attachShader(s,t),i.attachShader(s,r);let n=e.transformFeedbackVaryings;n&&(typeof i.transformFeedbackVaryings!="function"?G("TransformFeedback is not supported but TransformFeedbackVaryings are given."):i.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS)||jS(i,s,t,r),e._attributeData=zS(s,i,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=XS(s,i),e._uniformBlockData=VS(s,i),i.deleteShader(t),i.deleteShader(r);let o={};for(let l in e._uniformData){let c=e._uniformData[l];o[l]={location:i.getUniformLocation(s,l),value:Zc(c.type,c.size)}}return new qc(s,o)}var QS=f(()=>{ie();LS();US();ef();WS();$S();YS();qS()});var Jc,la,JS=f(()=>{P();OS();QS();Jc={textureCount:0,blockIndex:0},la=class{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;Jc.textureCount=0,Jc.blockIndex=0;let r=this._shaderSyncFunctions[e.glProgram._key];r||(r=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),r(this._renderer,e,Jc)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,Jc)}bindUniformBlock(e,t,r=0){let s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=e._bufferResource;o||this._renderer.ubo.updateUniformGroup(e);let a=e.buffer,l=s.updateBuffer(a),c=s.freeLocationForBufferBase(l);if(o){let{offset:u,size:d}=e;u===0&&d===a.data.byteLength?s.bindBufferBase(l,c):s.bindBufferRange(l,c,u)}else s.getLastBindBaseLocation(l)!==c&&s.bindBufferBase(l,c);let h=this._activeProgram._uniformBlockData[t].index;n.uniformBlockBindings[r]!==c&&(n.uniformBlockBindings[r]=c,this._renderer.gl.uniformBlockBinding(n.program,h,c))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=ZS(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return DS(e,t)}resetState(){this._activeProgram=null}};la.extension={type:[b.WebGLSystem],name:"shader"}});var e1,t1,r1=f(()=>{"use strict";e1={f32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1f(location, v);
        }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2f(location, v[0], v[1]);
        }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3f(location, v[0], v[1], v[2]);
        }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4f(location, v[0], v[1], v[2], v[3]);
        }`,i32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,u32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1ui(location, v);
        }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2ui(location, v[0], v[1]);
        }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3ui(location, v[0], v[1], v[2]);
        }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
        }`,bool:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},t1={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"}});function i1(i,e){let t=[`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
        var name = null;
    `];for(let r in i.uniforms){if(!e[r]){i.uniforms[r]instanceof Me?i.uniforms[r].ubo?t.push(`
                        renderer.shader.bindUniformBlock(uv.${r}, "${r}");
                    `):t.push(`
                        renderer.shader.updateUniformGroup(uv.${r});
                    `):i.uniforms[r]instanceof ri&&t.push(`
                        renderer.shader.bindBufferResource(uv.${r}, "${r}");
                    `);continue}let s=i.uniformStructures[r],n=!1;for(let o=0;o<ti.length;o++){let a=ti[o];if(s.type===a.type&&a.test(s)){t.push(`name = "${r}";`,ti[o].uniform),n=!0;break}}if(!n){let a=(s.size===1?e1:t1)[s.type].replace("location",`ud["${r}"].location`);t.push(`
            cu = ud["${r}"];
            cv = cu.value;
            v = uv["${r}"];
            ${a};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
`))}var s1=f(()=>{Fc();Tt();Ip();r1()});var ca,n1=f(()=>{P();s1();ca=class{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,r){let s=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==s.uniformDirtyGroups[e.uid])&&(s.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(s.uniformData,e.uniforms,this._renderer,r))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let r=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),s=this._getSignature(e,t._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(e,t._uniformData)),r[t._key]=this._cache[s],r[t._key]}_generateUniformsSync(e,t){return i1(e,t)}_getSignature(e,t,r){let s=e.uniforms,n=[`${r}-`];for(let o in s)n.push(o),t[o]&&n.push(t[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}};ca.extension={type:[b.WebGLSystem],name:"uniformGroup"}});function o1(i){let e={};if(e.normal=[i.ONE,i.ONE_MINUS_SRC_ALPHA],e.add=[i.ONE,i.ONE],e.multiply=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],e.screen=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],e["screen-npm"]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],e.erase=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],!(i instanceof W.get().getWebGLRenderingContext()))e.min=[i.ONE,i.ONE,i.ONE,i.ONE,i.MIN,i.MIN],e.max=[i.ONE,i.ONE,i.ONE,i.ONE,i.MAX,i.MAX];else{let r=i.getExtension("EXT_blend_minmax");r&&(e.min=[i.ONE,i.ONE,i.ONE,i.ONE,r.MIN_EXT,r.MIN_EXT],e.max=[i.ONE,i.ONE,i.ONE,i.ONE,r.MAX_EXT,r.MAX_EXT])}return e}var a1=f(()=>{we()});var zP,WP,VP,$P,XP,l1,c1,h1,u1=f(()=>{P();Kt();a1();({BLEND:zP,OFFSET:WP,CULLING:VP,DEPTH_TEST:$P,WINDING:XP,DEPTH_MASK:l1}=Rd),c1=class sf{constructor(e){this._invertFrontFace=!1,this._renderer=e,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[zP]=this.setBlend,this.map[WP]=this.setOffset,this.map[VP]=this.setCullFace,this.map[$P]=this.setDepthTest,this.map[XP]=this.setFrontFace,this.map[l1]=this.setDepthMask,this.checks=[],this.defaultState=ze.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=this._renderer.renderTarget.isFrontFaceInverted(e,e.flipY),this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=o1(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,r=0;for(;t;)t&1&&this.map[r].call(this,!!(e.data&1<<r)),t>>=1,r++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||(e=this.defaultState);for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this._updateCheck(sf._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(sf._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}get depthMaskEnabled(){return!!(this.stateId&1<<l1)}setCullFace(e){this._cullFace=e,this.gl[e?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(e){this._frontFace=e,this._frontFaceDirty=!1;let t=this._invertFrontFace?!e:e;this._glFrontFace!==t&&(this._glFrontFace=t,this.gl.frontFace(this.gl[t?"CW":"CCW"]))}setBlendMode(e){if(this.blendModesMap[e]||(e="normal"),e===this.blendMode)return;this.blendMode=e;let t=this.blendModesMap[e],r=this.gl;t.length===2?r.blendFunc(t[0],t[1]):r.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,r.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(e,t){let r=this.checks.indexOf(e);t&&r===-1?this.checks.push(e):!t&&r!==-1&&this.checks.splice(r,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0,this._renderer=null}};c1.extension={type:[b.WebGLSystem],name:"state"};h1=c1});var eh,d1=f(()=>{ea();eh=class{constructor(e){this.target=ni.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=he.UNSIGNED_BYTE,this.internalFormat=Xc.RGBA,this.format=Xc.RGBA,this.samplerType=0}destroy(){}}});var p1,f1,m1=f(()=>{Ge();Up();ea();p1=[new V,new V,new V],f1={id:"buffer",upload(i,e,t,r,s,n=!1){let o=s||e.target,a=i.resource;if(o===ni.TEXTURE_3D||o===ni.TEXTURE_2D_ARRAY){n||e.width!==i.width||e.height!==i.height?t.texImage3D(o,0,e.internalFormat,i.width,i.height,i.depthOrArrayLayers,0,e.format,e.type,a):t.texSubImage3D(o,0,0,0,0,i.width,i.height,i.depthOrArrayLayers,e.format,e.type,a),e.width=i.width,e.height=i.height;return}let l=i.width*i.height,c=n||e.width!==i.width||e.height!==i.height,h=i._updateStart>0||i._updateEnd<l;if(c)t.texImage2D(o,0,e.internalFormat,i.width,i.height,0,e.format,e.type,a);else if(h){let u=a.length/l,d=Hc(i._updateStart,i._updateEnd,i.width,i.height,p1);for(let p=0;p<d;p++){let m=p1[p],x=(m.y*i.width+m.x)*u;t.texSubImage2D(o,0,m.x,m.y,m.width,m.height,e.format,e.type,a.subarray(x,x+m.width*m.height*u))}}else t.texSubImage2D(o,0,0,0,i.width,i.height,e.format,e.type,a);e.width=i.width,e.height=i.height}}});var YP,g1,x1=f(()=>{"use strict";YP={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},g1={id:"compressed",upload(i,e,t,r,s,n){let o=s??e.target;t.pixelStorei(t.UNPACK_ALIGNMENT,4);let a=i.pixelWidth,l=i.pixelHeight,c=!!YP[i.format];for(let h=0;h<i.resource.length;h++){let u=i.resource[h];c?t.compressedTexImage2D(o,h,e.internalFormat,a,l,0,u):t.texImage2D(o,h,e.internalFormat,a,l,0,e.format,e.type,u),a=Math.max(a>>1,1),l=Math.max(l>>1,1)}}}});function b1(i){return{id:"cube",upload(e,t,r,s){let n=e.faces;for(let o=0;o<y1.length;o++){let a=y1[o],l=n[a];if(!l.resource)continue;(i[l.uploadMethodId]||i.image).upload(l,t,r,s,ni.TEXTURE_CUBE_MAP_POSITIVE_X+o,(t._layerInitMask&1<<o)===0),t._layerInitMask|=1<<o}t.width=e.pixelWidth,t.height=e.pixelHeight}}}var y1,_1=f(()=>{ea();y1=["right","left","top","bottom","front","back"]});function KP(i,e,t,r,s,n,o,a,l,c){if(!c){l&&i.texImage2D(e,0,t.internalFormat,r,s,0,t.format,t.type,null),i.texSubImage2D(e,0,0,0,n,o,t.format,t.type,a);return}if(!l){i.texSubImage2D(e,0,0,0,t.format,t.type,a);return}i.texImage2D(e,0,t.internalFormat,r,s,0,t.format,t.type,a)}function jP(i,e,t,r,s,n,o,a,l,c){if(!c){l&&i.texImage2D(e,0,t.internalFormat,r,s,0,t.format,t.type,null),i.texSubImage2D(e,0,0,0,t.format,t.type,a);return}if(!l){i.texSubImage2D(e,0,0,0,t.format,t.type,a);return}i.texImage2D(e,0,t.internalFormat,t.format,t.type,a)}var th,nf=f(()=>{"use strict";th={id:"image",upload(i,e,t,r,s,n=!1){let o=s||e.target,a=i.pixelWidth,l=i.pixelHeight,c=i.resourceWidth,h=i.resourceHeight,u=r===2,d=n||e.width!==a||e.height!==l,p=c>=a&&h>=l,m=i.resource;(u?KP:jP)(t,o,e,a,l,c,h,m,d,p),e.width=a,e.height=l}}});function v1(){let{userAgent:i}=W.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}var S1=f(()=>{we()});var qP,T1,w1=f(()=>{S1();nf();qP=v1(),T1={id:"video",upload(i,e,t,r,s,n=qP){if(!i.isValid){let o=s??e.target;t.texImage2D(o,0,e.internalFormat,1,1,0,e.format,e.type,null);return}th.upload(i,e,t,r,s,n)}}});var of,M1,rh,C1,E1=f(()=>{"use strict";of={linear:9729,nearest:9728},M1={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},rh={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},C1={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519}});function af(i,e,t,r,s,n,o,a){let l=n;if(!a||i.addressModeU!=="repeat"||i.addressModeV!=="repeat"||i.addressModeW!=="repeat"){let c=rh[o?"clamp-to-edge":i.addressModeU],h=rh[o?"clamp-to-edge":i.addressModeV],u=rh[o?"clamp-to-edge":i.addressModeW];e[s](l,e.TEXTURE_WRAP_S,c),e[s](l,e.TEXTURE_WRAP_T,h),e.TEXTURE_WRAP_R&&e[s](l,e.TEXTURE_WRAP_R,u)}if((!a||i.magFilter!=="linear")&&e[s](l,e.TEXTURE_MAG_FILTER,of[i.magFilter]),t){if(!a||i.mipmapFilter!=="linear"){let c=M1[i.minFilter][i.mipmapFilter];e[s](l,e.TEXTURE_MIN_FILTER,c)}}else e[s](l,e.TEXTURE_MIN_FILTER,of[i.minFilter]);if(r&&i.maxAnisotropy>1){let c=Math.min(i.maxAnisotropy,e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[s](l,r.TEXTURE_MAX_ANISOTROPY_EXT,c)}i.compare?(e[s](l,e.TEXTURE_COMPARE_FUNC,C1[i.compare]),e[s](l,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE)):a||e[s](l,e.TEXTURE_COMPARE_MODE,e.NONE)}var P1=f(()=>{E1()});function k1(i){return{r8unorm:i.RED,r8snorm:i.RED,r8uint:i.RED_INTEGER,r8sint:i.RED_INTEGER,r16uint:i.RED_INTEGER,r16sint:i.RED_INTEGER,r16float:i.RED,rg8unorm:i.RG,rg8snorm:i.RG,rg8uint:i.RG_INTEGER,rg8sint:i.RG_INTEGER,r32uint:i.RED_INTEGER,r32sint:i.RED_INTEGER,r32float:i.RED,rg16uint:i.RG_INTEGER,rg16sint:i.RG_INTEGER,rg16float:i.RG,rgba8unorm:i.RGBA,"rgba8unorm-srgb":i.RGBA,rgba8snorm:i.RGBA,rgba8uint:i.RGBA_INTEGER,rgba8sint:i.RGBA_INTEGER,bgra8unorm:i.RGBA,"bgra8unorm-srgb":i.RGBA,rgb9e5ufloat:i.RGB,rgb10a2unorm:i.RGBA,rg11b10ufloat:i.RGB,rg32uint:i.RG_INTEGER,rg32sint:i.RG_INTEGER,rg32float:i.RG,rgba16uint:i.RGBA_INTEGER,rgba16sint:i.RGBA_INTEGER,rgba16float:i.RGBA,rgba32uint:i.RGBA_INTEGER,rgba32sint:i.RGBA_INTEGER,rgba32float:i.RGBA,stencil8:i.STENCIL_INDEX8,depth16unorm:i.DEPTH_COMPONENT,depth24plus:i.DEPTH_COMPONENT,"depth24plus-stencil8":i.DEPTH_STENCIL,depth32float:i.DEPTH_COMPONENT,"depth32float-stencil8":i.DEPTH_STENCIL}}var A1=f(()=>{"use strict"});function R1(i,e){let t={},r=i.RGBA;return i instanceof W.get().getWebGLRenderingContext()?e.srgb&&(t={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(t={"rgba8unorm-srgb":i.SRGB8_ALPHA8,"bgra8unorm-srgb":i.SRGB8_ALPHA8},r=i.RGBA8),{r8unorm:i.R8,r8snorm:i.R8_SNORM,r8uint:i.R8UI,r8sint:i.R8I,r16uint:i.R16UI,r16sint:i.R16I,r16float:i.R16F,rg8unorm:i.RG8,rg8snorm:i.RG8_SNORM,rg8uint:i.RG8UI,rg8sint:i.RG8I,r32uint:i.R32UI,r32sint:i.R32I,r32float:i.R32F,rg16uint:i.RG16UI,rg16sint:i.RG16I,rg16float:i.RG16F,rgba8unorm:i.RGBA,...t,rgba8snorm:i.RGBA8_SNORM,rgba8uint:i.RGBA8UI,rgba8sint:i.RGBA8I,bgra8unorm:r,rgb9e5ufloat:i.RGB9_E5,rgb10a2unorm:i.RGB10_A2,rg11b10ufloat:i.R11F_G11F_B10F,rg32uint:i.RG32UI,rg32sint:i.RG32I,rg32float:i.RG32F,rgba16uint:i.RGBA16UI,rgba16sint:i.RGBA16I,rgba16float:i.RGBA16F,rgba32uint:i.RGBA32UI,rgba32sint:i.RGBA32I,rgba32float:i.RGBA32F,stencil8:i.STENCIL_INDEX8,depth16unorm:i.DEPTH_COMPONENT16,depth24plus:i.DEPTH_COMPONENT24,"depth24plus-stencil8":i.DEPTH24_STENCIL8,depth32float:i.DEPTH_COMPONENT32F,"depth32float-stencil8":i.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}var B1=f(()=>{we()});function I1(i){return{r8unorm:i.UNSIGNED_BYTE,r8snorm:i.BYTE,r8uint:i.UNSIGNED_BYTE,r8sint:i.BYTE,r16uint:i.UNSIGNED_SHORT,r16sint:i.SHORT,r16float:i.HALF_FLOAT,rg8unorm:i.UNSIGNED_BYTE,rg8snorm:i.BYTE,rg8uint:i.UNSIGNED_BYTE,rg8sint:i.BYTE,r32uint:i.UNSIGNED_INT,r32sint:i.INT,r32float:i.FLOAT,rg16uint:i.UNSIGNED_SHORT,rg16sint:i.SHORT,rg16float:i.HALF_FLOAT,rgba8unorm:i.UNSIGNED_BYTE,"rgba8unorm-srgb":i.UNSIGNED_BYTE,rgba8snorm:i.BYTE,rgba8uint:i.UNSIGNED_BYTE,rgba8sint:i.BYTE,bgra8unorm:i.UNSIGNED_BYTE,"bgra8unorm-srgb":i.UNSIGNED_BYTE,rgb9e5ufloat:i.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:i.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:i.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:i.UNSIGNED_INT,rg32sint:i.INT,rg32float:i.FLOAT,rgba16uint:i.UNSIGNED_SHORT,rgba16sint:i.SHORT,rgba16float:i.HALF_FLOAT,rgba32uint:i.UNSIGNED_INT,rgba32sint:i.INT,rgba32float:i.FLOAT,stencil8:i.UNSIGNED_BYTE,depth16unorm:i.UNSIGNED_SHORT,depth24plus:i.UNSIGNED_INT,"depth24plus-stencil8":i.UNSIGNED_INT_24_8,depth32float:i.FLOAT,"depth32float-stencil8":i.FLOAT_32_UNSIGNED_INT_24_8_REV}}var G1=f(()=>{"use strict"});function F1(i){return{"2d":i.TEXTURE_2D,cube:i.TEXTURE_CUBE_MAP,"1d":null,"3d":i?.TEXTURE_3D||null,"2d-array":i?.TEXTURE_2D_ARRAY||null,"cube-array":i?.TEXTURE_CUBE_MAP_ARRAY||null}}var D1=f(()=>{"use strict"});var ZP,lf,cf,L1=f(()=>{we();P();Dt();ye();Ru();d1();m1();x1();_1();nf();w1();P1();A1();B1();G1();D1();ZP=4,lf=class O1{constructor(e){this._glSamplers=Object.create(null),this._boundTextures=[],this._integerUnits=0,this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=e,this._managedTextures=new Ee({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});let t={image:th,buffer:f1,video:T1,compressed:g1,...O1.uploadExtensions};this._uploads={...t,cube:b1(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=R1(e,this._renderer.context.extensions),this._mapFormatToType=I1(e),this._mapFormatToFormat=k1(e),this._mapViewDimensionToGlTarget=F1(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(F.EMPTY,t)}initSource(e){this.bind(e)}bind(e,t=0){let r=e.source;e?(this.bindSource(r,t),this._useSeparateSamplers&&this._bindSampler(r.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){let r=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._setBoundTexture(t,e),this._activateLocation(t),e||(e=F.EMPTY.source);let s=this.getGlSource(e);r.bindTexture(s.target,s.texture)}}unbindIntegerTextures(e){if(e>=32)return;let t=this._integerUnits>>>e<<e;for(;t;){let r=31-Math.clz32(t);t&=~(1<<r),this.bind(F.EMPTY,r)}}_setBoundTexture(e,t){this._boundTextures[e]=t,!(e<0||e>31)&&(!t||t.viewDimension!=="2d"||(Fn(t.format)?this._integerUnits|=1<<e:this._integerUnits&=~(1<<e)))}_bindSampler(e,t=0){let r=this._gl;if(!e){this._boundSamplers[t]=null,r.bindSampler(t,null);return}let s=this._getGlSampler(e);this._boundSamplers[t]!==s&&(this._boundSamplers[t]=s,r.bindSampler(t,s))}unbind(e){let t=e.source,r=this._boundTextures,s=this._gl;for(let n=0;n<r.length;n++)if(r[n]===t){this._activateLocation(n);let o=this.getGlSource(t);s.bindTexture(o.target,null),this._setBoundTexture(n,null)}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){let t=this._gl,r=new eh(t.createTexture());if(r.type=this._mapFormatToType[e.format],r.internalFormat=this._mapFormatToInternalFormat[e.format],r.format=this._mapFormatToFormat[e.format],r.target=this._mapViewDimensionToGlTarget[e.viewDimension],r.target===null)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){let n=Math.max(e.width,e.height,e.depth);e.mipLevelCount=Math.floor(Math.log2(n))+1}return e._gpuData[this._renderer.uid]=r,this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceUpdate,this),e.on("styleChange",this.onStyleChange,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),this.updateStyle(e,!1),r}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){let r=this._gl,s=this.getGlSource(e);r.bindTexture(s.target,s.texture),this._setBoundTexture(this._activeTextureLocation,e),af(e.style,r,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){let r=e._gpuData[this._renderer.uid];r&&(t||(this.unbind(e),this._gl.deleteTexture(r.texture)),e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceUpdate,this),e.off("styleChange",this.onStyleChange,this),e.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(e){let t=this._gl,r=this.getGlSource(e);t.bindTexture(r.target,r.texture),this._setBoundTexture(this._activeTextureLocation,e);let s=e.alphaMode==="premultiply-alpha-on-upload"&&!Fn(e.format)&&r.target!==t.TEXTURE_3D&&r.target!==t.TEXTURE_2D_ARRAY;if(this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[e.uploadMethodId])this._uploads[e.uploadMethodId].upload(e,r,t,this._renderer.context.webGLVersion);else if(r.target===t.TEXTURE_2D)this._initEmptyTexture2D(r,e);else if(r.target===t.TEXTURE_2D_ARRAY||r.target===t.TEXTURE_3D)this._initEmptyTexture3D(r,e);else if(r.target===t.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(r,e);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(r,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);let r=this.getGlSource(e);this._gl.generateMipmap(r.target)}_initEmptyTexture2D(e,t){let r=this._gl;r.texImage2D(r.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let s=Math.max(t.pixelWidth>>1,1),n=Math.max(t.pixelHeight>>1,1);for(let o=1;o<t.mipLevelCount;o++)r.texImage2D(r.TEXTURE_2D,o,e.internalFormat,s,n,0,e.format,e.type,null),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}_initEmptyTexture3D(e,t){let r=this._gl,s=e.target===r.TEXTURE_3D,n=t.pixelWidth,o=t.pixelHeight,a=t.depthOrArrayLayers;for(let l=0;l<t.mipLevelCount;l++)r.texImage3D(e.target,l,e.internalFormat,n,o,a,0,e.format,e.type,null),n=Math.max(n>>1,1),o=Math.max(o>>1,1),s&&(a=Math.max(a>>1,1))}_initEmptyTextureCube(e,t){let r=this._gl,s=6;for(let a=0;a<s;a++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let n=Math.max(t.pixelWidth>>1,1),o=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++){for(let l=0;l<s;l++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,a,e.internalFormat,n,o,0,e.format,e.type,null);n=Math.max(n>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(e,t){if(this._renderer.context.webGLVersion!==2||t.mipLevelCount<=1)return;let r=this._gl,s=Math.max((t.mipLevelCount|0)-1,0);r.texParameteri(e.target,r.TEXTURE_BASE_LEVEL,0),r.texParameteri(e.target,r.TEXTURE_MAX_LEVEL,s)}_initSampler(e){let t=this._gl,r=this._gl.createSampler();return this._glSamplers[e._resourceId]=r,af(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",r,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this._initSource(e)}generateCanvas(e){let{pixels:t,width:r,height:s}=this.getPixels(e),n=W.get().createCanvas();n.width=r,n.height=s;let o=n.getContext("2d");if(o){let a=o.createImageData(r,s);a.data.set(t),o.putImageData(a,0,0)}return n}getPixels(e){let t=e.source.resolution,r=e.frame,s=Math.max(Math.round(r.width*t),1),n=Math.max(Math.round(r.height*t),1),o=new Uint8Array(ZP*s*n),a=this._renderer,l=a.renderTarget.getRenderTarget(e),c=a.renderTarget.getGpuRenderTarget(l),h=a.gl;return a.renderTarget.adaptor.bindFramebuffer(c.resolveTargetFramebuffer),h.readPixels(Math.round(r.x*t),Math.round(r.y*t),s,n,h.RGBA,h.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:n}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){let e=this._renderer.limits.maxTextures;this._activeTextureLocation=-1,this._boundTextures.fill(null),this._integerUnits=e>=32?-1:(1<<e)-1,this._boundSamplers=Object.create(null);let t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}};lf.extension={type:[b.WebGLSystem],name:"texture"};lf.uploadExtensions=Object.create(null);cf=lf;H.handleByMap(b.TextureUploaderWebGL,cf.uploadExtensions)});var W1={};Fa(W1,{WebGLRenderer:()=>hf});var QP,JP,ek,U1,N1,H1,z1,hf,V1=f(()=>{P();oS();aS();lS();Ps();Bc();ar();uS();fS();yS();vS();SS();TS();wS();MS();RS();GS();JS();n1();u1();L1();QP=[...Hs,oa,_S,pS,sa,Jo,cf,aa,ta,ca,la,ia,h1,na,ra],JP=[...Rc],ek=[Zo,qo,jo],U1=[],N1=[],H1=[],z1=[];H.handleByNamedList(b.WebGLSystem,U1);H.handleByNamedList(b.WebGLPipes,N1);H.handleByNamedList(b.WebGLPipesAdaptor,H1);H.handleByNamedList(b.WebGLLoader,z1);H.add(...QP,...JP,...ek);hf=class extends cr{constructor(){let e={name:"webgl",type:He.WEBGL,systems:U1,renderPipes:N1,renderPipeAdaptors:H1,loaders:z1};super(e)}}});function $1(i,e,t,r,s,n,o,a){let l=i-t*s,c=e-r*s,h=i+t*n,u=e+r*n,d,p;o?(d=r,p=-t):(d=-r,p=t);let m=l+d,x=c+p,y=h+d,g=u+p;return a.push(m,x),a.push(y,g),2}function Ui(i,e,t,r,s,n,o,a){let l=t-i,c=r-e,h=Math.atan2(l,c),u=Math.atan2(s-i,n-e);a&&h<u?h+=Math.PI*2:!a&&h>u&&(u+=Math.PI*2);let d=h,p=u-h,m=Math.abs(p),x=Math.sqrt(l*l+c*c),y=(15*m*Math.sqrt(x)/Math.PI>>0)+1,g=p/y;if(d+=g,a){o.push(i,e),o.push(t,r);for(let v=1,_=d;v<y;v++,_+=g)o.push(i,e),o.push(i+Math.sin(_)*x,e+Math.cos(_)*x);o.push(i,e),o.push(s,n)}else{o.push(t,r),o.push(i,e);for(let v=1,_=d;v<y;v++,_+=g)o.push(i+Math.sin(_)*x,e+Math.cos(_)*x),o.push(i,e);o.push(s,n),o.push(i,e)}return y*2}function $s(i,e,t,r,s,n){let o=1e-4;if(i.length===0)return;let a=e,l=a.alignment;if(e.alignment!==.5){let L=jl(i);t&&(L*=-1),l=(l-.5)*L+.5}let c=new ne(i[0],i[1]),h=new ne(i[i.length-2],i[i.length-1]),u=r,d=Math.abs(c.x-h.x)<o&&Math.abs(c.y-h.y)<o;if(u){i=i.slice(),d&&(i.pop(),i.pop(),h.set(i[i.length-2],i[i.length-1]));let L=(c.x+h.x)*.5,re=(h.y+c.y)*.5;i.unshift(L,re),i.push(L,re)}let p=s,m=i.length/2,x=i.length,y=p.length/2,g=a.width/2,v=g*g,_=a.miterLimit*a.miterLimit,S=i[0],T=i[1],w=i[2],E=i[3],R=0,k=0,C=-(T-E),M=S-w,A=0,U=0,z=Math.sqrt(C*C+M*M);C/=z,M/=z,C*=g,M*=g;let J=l,D=(1-J)*2,N=J*2;u||(a.cap==="round"?x+=Ui(S-C*(D-N)*.5,T-M*(D-N)*.5,S-C*D,T-M*D,S+C*N,T+M*N,p,!0)+2:a.cap==="square"&&(x+=$1(S,T,C,M,D,N,!0,p))),p.push(S-C*D,T-M*D),p.push(S+C*N,T+M*N);for(let L=1;L<m-1;++L){S=i[(L-1)*2],T=i[(L-1)*2+1],w=i[L*2],E=i[L*2+1],R=i[(L+1)*2],k=i[(L+1)*2+1],C=-(T-E),M=S-w,z=Math.sqrt(C*C+M*M),C/=z,M/=z,C*=g,M*=g,A=-(E-k),U=w-R,z=Math.sqrt(A*A+U*U),A/=z,U/=z,A*=g,U*=g;let re=w-S,Se=T-E,Ae=w-R,pe=k-E,xe=re*Ae+Se*pe,Z=Se*Ae-pe*re,Lt=Z<0;if(Math.abs(Z)<.001*Math.abs(xe)){p.push(w-C*D,E-M*D),p.push(w+C*N,E+M*N),xe>=0&&(a.join==="round"?x+=Ui(w,E,w-C*D,E-M*D,w-A*D,E-U*D,p,!1)+4:x+=2,p.push(w-A*N,E-U*N),p.push(w+A*D,E+U*D));continue}let Ga=(-C+S)*(-M+E)-(-C+w)*(-M+T),hn=(-A+R)*(-U+E)-(-A+w)*(-U+k),un=(re*hn-Ae*Ga)/Z,dr=(pe*Ga-Se*hn)/Z,ui=(un-w)*(un-w)+(dr-E)*(dr-E),Ut=w+(un-w)*D,mt=E+(dr-E)*D,gt=w-(un-w)*N,Nt=E-(dr-E)*N,Br=Math.min(re*re+Se*Se,Ae*Ae+pe*pe),pr=Lt?D:N,dn=Br+pr*pr*v;ui<=dn?a.join==="bevel"||ui/v>_?(Lt?(p.push(Ut,mt),p.push(w+C*N,E+M*N),p.push(Ut,mt),p.push(w+A*N,E+U*N)):(p.push(w-C*D,E-M*D),p.push(gt,Nt),p.push(w-A*D,E-U*D),p.push(gt,Nt)),x+=2):a.join==="round"?Lt?(p.push(Ut,mt),p.push(w+C*N,E+M*N),x+=Ui(w,E,w+C*N,E+M*N,w+A*N,E+U*N,p,!0)+4,p.push(Ut,mt),p.push(w+A*N,E+U*N)):(p.push(w-C*D,E-M*D),p.push(gt,Nt),x+=Ui(w,E,w-C*D,E-M*D,w-A*D,E-U*D,p,!1)+4,p.push(w-A*D,E-U*D),p.push(gt,Nt)):(p.push(Ut,mt),p.push(gt,Nt)):(p.push(w-C*D,E-M*D),p.push(w+C*N,E+M*N),a.join==="round"?Lt?x+=Ui(w,E,w+C*N,E+M*N,w+A*N,E+U*N,p,!0)+2:x+=Ui(w,E,w-C*D,E-M*D,w-A*D,E-U*D,p,!1)+2:a.join==="miter"&&ui/v<=_&&(Lt?(p.push(gt,Nt),p.push(gt,Nt)):(p.push(Ut,mt),p.push(Ut,mt)),x+=2),p.push(w-A*D,E-U*D),p.push(w+A*N,E+U*N),x+=2)}S=i[(m-2)*2],T=i[(m-2)*2+1],w=i[(m-1)*2],E=i[(m-1)*2+1],C=-(T-E),M=S-w,z=Math.sqrt(C*C+M*M),C/=z,M/=z,C*=g,M*=g,p.push(w-C*D,E-M*D),p.push(w+C*N,E+M*N),u||(a.cap==="round"?x+=Ui(w-C*(D-N)*.5,E-M*(D-N)*.5,w-C*D,E-M*D,w+C*N,E+M*N,p,!1)+2:a.cap==="square"&&(x+=$1(w,E,C,M,D,N,!1,p)));let Y=1e-4*1e-4;for(let L=y;L<x+y-2;++L)S=p[L*2],T=p[L*2+1],w=p[(L+1)*2],E=p[(L+1)*2+1],R=p[(L+2)*2],k=p[(L+2)*2+1],!(Math.abs(S*(E-k)+w*(k-T)+R*(T-E))<Y)&&n.push(L,L+1,L+2)}var ih=f(()=>{pd();Wt()});function Y1(i,e){for(let t=0;t<e.length;t++){let r=e[t];i.addColorStop(r.offset,r.color)}}function K1(i,e){let t=W.get().createCanvas(i,e),r=t.getContext("2d");return{canvas:t,context:r}}function ik(i){let e=i[0]??{};return(typeof e=="number"||i[1])&&(B("8.5.2","use options object instead"),e={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??ot.defaultLinearOptions.textureSize}),e}var X1,df,ot,Ni=f(()=>{Je();we();oe();Vl();ye();Ue();de();Pu();X1=[{offset:0,color:"white"},{offset:1,color:"black"}],df=class uf{constructor(...e){this.uid=K("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=ik(e);t={...t.type==="radial"?uf.defaultRadialOptions:uf.defaultLinearOptions,...kl(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:q.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:r,y:s}=this.end,n=r-e,o=s-t,a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){let y=e;e=r,r=y,n*=-1}if(o<0){let y=t;t=s,s=y,o*=-1}}let l=this.colorStops.length?this.colorStops:X1,c=this._textureSize,{canvas:h,context:u}=K1(c,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Y1(d,l),u.fillStyle=d,u.fillRect(0,0,c,1),this.texture=new F({source:new or({resource:h,addressMode:this._wrapMode})});let p=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),x=new I;x.scale(p/c,1),x.rotate(m),x.translate(e,t),this.textureSpace==="local"&&x.scale(c,c),this.transform=x}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let e=this.colorStops.length?this.colorStops:X1,t=this._textureSize,{canvas:r,context:s}=K1(t,t),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,c=this.innerRadius,h=this.outerRadius,u=a-h,d=l-h,p=t/(h*2),m=(n-u)*p,x=(o-d)*p,y=s.createRadialGradient(m,x,c*p,(a-u)*p,(l-d)*p,h*p);Y1(y,e),s.fillStyle=e[e.length-1].color,s.fillRect(0,0,t,t),s.fillStyle=y,s.translate(m,x),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-m,-x),s.fillRect(0,0,t,t),this.texture=new F({source:new or({resource:r,addressMode:this._wrapMode})});let g=new I;this.textureSpace==="local"?g.scale(2*h,2*h):g.scale(1/p,1/p),g.translate(u,d),this.transform=g}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};df.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};df.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};ot=df});function sk(i){return i.texture!==void 0}var j1,jt,ha=f(()=>{oe();Ue();j1={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},jt=class{constructor(e,t){this.uid=K("fillPattern"),this._tick=0,this.transform=new I;let r=sk(e)?e:{texture:e,repetition:t};this.texture=r.texture,this.textureSpace=r.textureSpace??"global";let s=r.repetition;s&&(this.texture.source.style.addressModeU=j1[s].addressModeU,this.texture.source.style.addressModeV=j1[s].addressModeV)}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}});function q1(i,e,t,r,s,n,o,a=null){let l=0;t*=e,s*=n;let c=a.a,h=a.b,u=a.c,d=a.d,p=a.tx,m=a.ty;for(;l<o;){let x=i[t],y=i[t+1];r[s]=c*x+u*y+p,r[s+1]=h*x+d*y+m,s+=n,t+=e,l++}}function Z1(i,e,t,r){let s=0;for(e*=t;s<r;)i[e]=0,i[e+1]=0,e+=t,s++}var Q1=f(()=>{"use strict"});function pf(i,e,t,r,s){let n=e.a,o=e.b,a=e.c,l=e.d,c=e.tx,h=e.ty;t||(t=0),r||(r=2),s||(s=i.length/r-t);let u=t*r;for(let d=0;d<s;d++){let p=i[u],m=i[u+1];i[u]=n*p+a*m+c,i[u+1]=o*p+l*m+h,u+=r}}var J1=f(()=>{"use strict"});var nk,Hi,ff=f(()=>{oe();Bn();nk=new I,Hi=class{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){let e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,r=this.renderable;return r?tr(t,r.groupColor)+(this.alpha*r.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||nk}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}});var Xs,eT,tT,rT=f(()=>{P();Xs={extension:{type:b.ShapeBuilder,name:"circle"},build(i,e){let t,r,s,n,o,a;if(i.type==="circle"){let S=i;if(o=a=S.radius,o<=0)return!1;t=S.x,r=S.y,s=n=0}else if(i.type==="ellipse"){let S=i;if(o=S.halfWidth,a=S.halfHeight,o<=0||a<=0)return!1;t=S.x,r=S.y,s=n=0}else{let S=i,T=S.width/2,w=S.height/2;t=S.x+T,r=S.y+w,o=a=Math.max(0,Math.min(S.radius,Math.min(T,w))),s=T-o,n=w-a}if(s<0||n<0)return!1;let l=Math.ceil(2.3*Math.sqrt(o+a)),c=l*8+(s?4:0)+(n?4:0);if(c===0)return!1;if(l===0)return e[0]=e[6]=t+s,e[1]=e[3]=r+n,e[2]=e[4]=t-s,e[5]=e[7]=r-n,!0;let h=0,u=l*4+(s?2:0)+2,d=u,p=c,m=s+o,x=n,y=t+m,g=t-m,v=r+x;if(e[h++]=y,e[h++]=v,e[--u]=v,e[--u]=g,n){let S=r-x;e[d++]=g,e[d++]=S,e[--p]=S,e[--p]=y}for(let S=1;S<l;S++){let T=Math.PI/2*(S/l),w=s+Math.cos(T)*o,E=n+Math.sin(T)*a,R=t+w,k=t-w,C=r+E,M=r-E;e[h++]=R,e[h++]=C,e[--u]=C,e[--u]=k,e[d++]=k,e[d++]=M,e[--p]=M,e[--p]=R}m=s,x=n+a,y=t+m,g=t-m,v=r+x;let _=r-x;return e[h++]=y,e[h++]=v,e[--p]=_,e[--p]=y,s&&(e[h++]=g,e[h++]=v,e[--p]=_,e[--p]=g),!0},triangulate(i,e,t,r,s,n){if(i.length===0)return;let o=0,a=0;for(let h=0;h<i.length;h+=2)o+=i[h],a+=i[h+1];o/=i.length/2,a/=i.length/2;let l=r;e[l*t]=o,e[l*t+1]=a;let c=l++;for(let h=0;h<i.length;h+=2)e[l*t]=i[h],e[l*t+1]=i[h+1],h>0&&(s[n++]=l,s[n++]=c,s[n++]=l-1),l++;s[n++]=c+1,s[n++]=c,s[n++]=l-1}},eT={...Xs,extension:{...Xs.extension,name:"ellipse"}},tT={...Xs,extension:{...Xs.extension,name:"roundedRectangle"}}});function iT(i,e,t,r){let s=1e-4;if(i.length===0)return;let n=i[0],o=i[1],a=i[i.length-2],l=i[i.length-1],c=e||Math.abs(n-a)<s&&Math.abs(o-l)<s,h=t,u=i.length/2,d=h.length/2;for(let p=0;p<u;p++)h.push(i[p*2]),h.push(i[p*2+1]);for(let p=0;p<u-1;p++)r.push(d+p,d+p+1);c&&r.push(d+u-1,d)}var sT=f(()=>{});function sh(i,e,t,r,s,n,o){let a=pb(i,e,2);if(!a)return;for(let c=0;c<a.length;c+=3)n[o++]=a[c]+s,n[o++]=a[c+1]+s,n[o++]=a[c+2]+s;let l=s*r;for(let c=0;c<i.length;c+=2)t[l]=i[c],t[l+1]=i[c+1],l+=r}var mf=f(()=>{fb()});var ok,nT,oT=f(()=>{P();mf();ok=[],nT={extension:{type:b.ShapeBuilder,name:"polygon"},build(i,e){for(let t=0;t<i.points.length;t++)e[t]=i.points[t];return!0},triangulate(i,e,t,r,s,n){sh(i,ok,e,t,r,s,n)}}});var aT,lT=f(()=>{P();aT={extension:{type:b.ShapeBuilder,name:"rectangle"},build(i,e){let t=i,r=t.x,s=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=r,e[1]=s,e[2]=r+n,e[3]=s,e[4]=r+n,e[5]=s+o,e[6]=r,e[7]=s+o,!0):!1},triangulate(i,e,t,r,s,n){let o=0;r*=t,e[r+o]=i[0],e[r+o+1]=i[1],o+=t,e[r+o]=i[2],e[r+o+1]=i[3],o+=t,e[r+o]=i[6],e[r+o+1]=i[7],o+=t,e[r+o]=i[4],e[r+o+1]=i[5],o+=t;let a=r/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}}});var cT,hT=f(()=>{P();cT={extension:{type:b.ShapeBuilder,name:"triangle"},build(i,e){return e[0]=i.x,e[1]=i.y,e[2]=i.x2,e[3]=i.y2,e[4]=i.x3,e[5]=i.y3,!0},triangulate(i,e,t,r,s,n){let o=0;r*=t,e[r+o]=i[0],e[r+o+1]=i[1],o+=t,e[r+o]=i[2],e[r+o+1]=i[3],o+=t,e[r+o]=i[4],e[r+o+1]=i[5];let a=r/t;s[n++]=a,s[n++]=a+1,s[n++]=a+2}}});function nh(i,e,t,r){let s=e.matrix?i.copyFrom(e.matrix).invert():i.identity();if(e.textureSpace==="local"){let o=t.getBounds(lk);e.width&&o.pad(e.width);let{x:a,y:l}=o,c=1/o.width,h=1/o.height,u=-a*c,d=-l*h,p=s.a,m=s.b,x=s.c,y=s.d;s.a*=c,s.b*=c,s.c*=h,s.d*=h,s.tx=u*p+d*x+s.tx,s.ty=u*m+d*y+s.ty}else if(e.texture.rotate){let{uvs:o,orig:a}=e.texture;s.scale(1/a.width,1/a.height),s.prepend(ck.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);let n=e.texture.source.style;return!(e.fill instanceof ot)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),r&&s.append(ak.copyFrom(r).invert()),s}var ak,lk,ck,gf=f(()=>{oe();Ge();Ni();ak=new I,lk=new V,ck=new I});function dT(i,e){let{geometryData:t,batches:r}=e;r.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let s=0;s<i.instructions.length;s++){let n=i.instructions[s];if(n.action==="texture")dk(n.data,r,t);else if(n.action==="fill"||n.action==="stroke"){let o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,c=n.data.hole;o&&c&&uT(c.shapePath,l,!0,r,t),c&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=c.shapePath.shapePrimitives),uT(a,l,o,r,t)}}}function dk(i,e,t){let r=[],s=oi.rectangle,n=hk;n.x=i.dx,n.y=i.dy,n.width=i.dw,n.height=i.dh;let o=i.transform;if(!s.build(n,r))return;let{vertices:a,uvs:l,indices:c}=t,h=c.length,u=a.length/2;o&&pf(r,o),s.triangulate(r,a,2,u,c,h);let d=i.image,p=d.uvs;l.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);let m=Te.get(Hi);m.indexOffset=h,m.indexSize=c.length-h,m.attributeOffset=u,m.attributeSize=a.length/2-u,m.baseColor=i.style,m.alpha=i.alpha,m.texture=d,m.geometryData=t,e.push(m)}function uT(i,e,t,r,s){let{vertices:n,uvs:o,indices:a}=s;i.shapePrimitives.forEach(({shape:l,transform:c,holes:h})=>{let u=[],d=oi[l.type];if(!d.build(l,u))return;let p=a.length,m=n.length/2,x="triangle-list";if(c&&pf(u,c),t){let _=l.closePath??!0,S=e;S.pixelLine?(iT(u,_,n,a),x="line-list"):$s(u,S,!1,_,n,a)}else if(h){let _=[],S=u.slice();pk(h).forEach(w=>{_.push(S.length/2),S.push(...w)}),sh(S,_,n,2,m,a,p)}else d.triangulate(u,n,2,m,a,p);let y=o.length/2,g=e.texture;if(g!==F.WHITE){let _=nh(uk,e,l,c);q1(n,2,m,o,y,2,n.length/2-m,_)}else Z1(o,y,2,n.length/2-m);let v=Te.get(Hi);v.indexOffset=p,v.indexSize=a.length-p,v.attributeOffset=m,v.attributeSize=n.length/2-m,v.baseColor=e.color,v.alpha=e.alpha,v.texture=g,v.geometryData=s,v.topology=x,r.push(v)})}function pk(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t].shape,s=[];oi[r.type].build(r,s)&&e.push(s)}return e}var oi,hk,uk,oh=f(()=>{P();oe();Ge();Q1();J1();ye();br();ff();rT();ih();sT();oT();lT();hT();gf();mf();oi={};H.handleByMap(b.ShapeBuilder,oi);H.add(aT,nT,cT,Xs,eT,tT);hk=new V,uk=new I});function yk(i,e,t){i.beginPath();for(let r=0;r<t.length;r+=3){let s=t[r]*2,n=t[r+1]*2,o=t[r+2]*2;i.moveTo(e[s],e[s+1]),i.lineTo(e[n],e[n+1]),i.lineTo(e[o],e[o+1]),i.closePath()}i.fill()}function bk(i){return`#${(i&16777215).toString(16).padStart(6,"0")}`}function _k(i,e,t,r,s,n){n=Math.max(0,Math.min(n,Math.min(r,s)/2)),i.moveTo(e+n,t),i.lineTo(e+r-n,t),i.quadraticCurveTo(e+r,t,e+r,t+n),i.lineTo(e+r,t+s-n),i.quadraticCurveTo(e+r,t+s,e+r-n,t+s),i.lineTo(e+n,t+s),i.quadraticCurveTo(e,t+s,e,t+s-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function lh(i,e){switch(e.type){case"rectangle":{let t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{let t=e;_k(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{let t=e;i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{let t=e;i.ellipse?i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{let t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{let t=e,r=t.points;if(!r?.length)break;i.moveTo(r[0],r[1]);for(let s=2;s<r.length;s+=2)i.lineTo(r[s],r[s+1]);t.closePath&&i.closePath();break}}}function vk(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){let r=e[t];if(!r?.shape)continue;let s=r.transform,n=s&&!s.isIdentity();n&&(i.save(),i.transform(s.a,s.b,s.c,s.d,s.tx,s.ty)),lh(i,r.shape),n&&i.restore()}return!0}function Sk(i,e,t,r){let s=i.fill;if(s instanceof ot){s.buildGradient();let o=s.texture;if(o){let a=Q.getTintedPattern(o,e),l=t?xf.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):xf.copyFrom(s.transform);return r&&!i.textureSpace&&l.append(r),Q.applyPatternTransform(a,l),a}}if(s instanceof jt){let o=Q.getTintedPattern(s.texture,e);return Q.applyPatternTransform(o,s.transform,!1),o}let n=i.texture;if(n&&n!==F.WHITE){if(!n.source.resource)return fk;let o=Q.getTintedPattern(n,e),a=i.matrix;if(t){let{resolution:l}=n.source;if(a=xf.copyFrom(t),n.rotate){let{uvs:c,orig:h}=n;a.prepend(xk.set(c.x1-c.x0,c.y1-c.y0,c.x3-c.x0,c.y3-c.y0,c.x0,c.y0).invert()).scale(h.width*l,h.height*l)}else a.scale(n.source.pixelWidth,n.source.pixelHeight).translate(-n.frame.x*l,-n.frame.y*l)}return Q.applyPatternTransform(o,a),o}return bk(e)}var fk,ah,mk,gk,xf,xk,ua,pT=f(()=>{P();Gn();oe();_s();ye();Cl();Bn();ih();Ni();ha();oh();gf();fk="#808080",ah=new I,mk=new I,gk=new I,xf=new I,xk=new I;ua=class{constructor(){this.shader=null}contextChange(e){}execute(e,t){let r=e.renderer,s=r.canvasContext,n=s.activeContext,o=t.groupTransform,a=r.globalUniforms.globalUniformData?.worldColor??4294967295,l=t.groupColorAlpha,c=(a>>>24&255)/255,h=(l>>>24&255)/255,u=r.filter?.alphaMultiplier??1,d=c*h*u;if(d<=0)return;let p=a&16777215,m=l&16777215,x=vr(tr(m,p)),y=r._roundPixels|t._roundPixels;n.save(),s.setContextTransform(o,y===1),s.setBlendMode(t.groupBlendMode);let g=t.context.instructions;for(let v=0;v<g.length;v++){let _=g[v];if(_.action==="texture"){let M=_.data,A=M.image,U=A?Q.getCanvasSource(A):null;if(!U)continue;let z=M.alpha*d;if(z<=0)continue;let J=tr(M.style,x);n.globalAlpha=z;let D=U;J!==16777215&&(D=Q.getTintedCanvas({texture:A},J));let N=A.frame,Y=A.source._resolution??A.source.resolution??1,L=N.x*Y,re=N.y*Y,Se=N.width*Y,Ae=N.height*Y;D!==U&&(L=0,re=0);let pe=M.transform,xe=pe&&!pe.isIdentity(),Z=A.rotate;xe||Z?(ah.copyFrom(o),xe&&ah.append(pe),Z&&ee.matrixAppendRotationInv(ah,Z,M.dx,M.dy,M.dw,M.dh),s.setContextTransform(ah,y===1)):s.setContextTransform(o,y===1),n.drawImage(D,L,re,D===U?Se:D.width,D===U?Ae:D.height,Z?0:M.dx,Z?0:M.dy,M.dw,M.dh),(xe||Z)&&s.setContextTransform(o,y===1);continue}let S=_.data,T=S?.path?.shapePath;if(!T?.shapePrimitives?.length)continue;let w=S.style,E=tr(w.color,x),R=w.alpha*d;if(R<=0)continue;let k=_.action==="stroke";if(n.globalAlpha=R,k){let M=w;n.lineWidth=M.width,n.lineCap=M.cap,n.lineJoin=M.join,n.miterLimit=M.miterLimit}let C=T.shapePrimitives;if(!k&&S.hole?.shapePath?.shapePrimitives?.length){let M=C[C.length-1];M.holes=S.hole.shapePath.shapePrimitives}for(let M=0;M<C.length;M++){let A=C[M];if(!A?.shape)continue;let U=A.transform,z=U&&!U.isIdentity(),J=w.texture&&w.texture!==F.WHITE,D=w.textureSpace==="global"?U:null,N=J?nh(mk,w,A.shape,D):null,Y=z?gk.copyFrom(o).append(U):o,L=Sk(w,E,N,Y);if(z&&(n.save(),n.transform(U.a,U.b,U.c,U.d,U.tx,U.ty)),k){let re=w;if(re.alignment!==.5&&!re.pixelLine){let Ae=[],pe=[],xe=[];if(oi[A.shape.type]?.build(A.shape,Ae)){let Lt=A.shape.closePath??!0;$s(Ae,re,!1,Lt,pe,xe),n.fillStyle=L,yk(n,pe,xe)}else n.strokeStyle=L,n.beginPath(),lh(n,A.shape),n.stroke()}else n.strokeStyle=L,n.beginPath(),lh(n,A.shape),n.stroke()}else n.fillStyle=L,n.beginPath(),lh(n,A.shape),vk(n,A.holes)?n.fill("evenodd"):n.fill();z&&n.restore()}}n.restore()}destroy(){this.shader=null}};ua.extension={type:[b.CanvasPipesAdaptor],name:"graphics"}});var yf,fT,mT=f(()=>{P();Gn();oe();Cl();Bn();_s();yf=class zi{static _getPatternRepeat(e,t){let r=e&&e!=="clamp-to-edge",s=t&&t!=="clamp-to-edge";return r&&s?"repeat":r?"repeat-x":s?"repeat-y":"no-repeat"}start(e,t,r){}execute(e,t){let r=t.elements;if(!r||!r.length)return;let s=e.renderer,n=s.canvasContext,o=n.activeContext;for(let a=0;a<r.length;a++){let l=r[a];if(!l.packAsQuad)continue;let c=l,h=c.texture,u=h?Q.getCanvasSource(h):null;if(!u)continue;let d=h.source.style,p=n.smoothProperty,m=d.scaleMode!=="nearest";o[p]!==m&&(o[p]=m),n.setBlendMode(t.blendMode);let x=s.globalUniforms.globalUniformData?.worldColor??4294967295,y=c.color,g=(x>>>24&255)/255,v=(y>>>24&255)/255,_=s.filter?.alphaMultiplier??1,S=g*v*_;if(S<=0)continue;o.globalAlpha=S;let T=x&16777215,w=y&16777215,E=vr(tr(w,T)),R=h.frame,k=d.addressModeU??d.addressMode,C=d.addressModeV??d.addressMode,M=zi._getPatternRepeat(k,C),A=h.source._resolution??h.source.resolution??1,U=c.renderable?.renderGroup?.isCachedAsTexture,z=R.x*A,J=R.y*A,D=R.width*A,N=R.height*A,Y=c.bounds,L=s.renderTarget.renderTarget.isRoot,re=Y.minX,Se=Y.minY,Ae=Y.maxX-Y.minX,pe=Y.maxY-Y.minY,xe=h.rotate,Z=h.uvs,Lt=Math.min(Z.x0,Z.x1,Z.x2,Z.x3,Z.y0,Z.y1,Z.y2,Z.y3),Ga=Math.max(Z.x0,Z.x1,Z.x2,Z.x3,Z.y0,Z.y1,Z.y2,Z.y3),hn=M!=="no-repeat"&&(Lt<0||Ga>1),dr=xe&&!(!hn&&(E!==16777215||xe));dr?(zi._tempPatternMatrix.copyFrom(c.transform),ee.matrixAppendRotationInv(zi._tempPatternMatrix,xe,re,Se,Ae,pe),n.setContextTransform(zi._tempPatternMatrix,c.roundPixels===1,void 0,U&&L)):n.setContextTransform(c.transform,c.roundPixels===1,void 0,U&&L);let ui=Ae,Ut=pe,mt=dr?0:re,gt=dr?0:Se;if(!dr&&c.roundPixels===1&&(mt|=0,gt|=0),hn){let Nt=u,Br=E!==16777215&&!xe,pr=R.width<=h.source.width&&R.height<=h.source.height;Br&&pr&&(Nt=Q.getTintedCanvas({texture:h},E));let dn=o.createPattern(Nt,M);if(!dn)continue;let Nh=ui,vm=Ut;if(Nh===0||vm===0)continue;let Sm=1/Nh,Tm=1/vm,wm=(Z.x1-Z.x0)*Sm,Mm=(Z.y1-Z.y0)*Sm,Cm=(Z.x3-Z.x0)*Tm,Em=(Z.y3-Z.y0)*Tm,MM=Z.x0-wm*mt-Cm*gt,CM=Z.y0-Mm*mt-Em*gt,Hh=h.source.pixelWidth,zh=h.source.pixelHeight;zi._tempPatternMatrix.set(wm*Hh,Mm*zh,Cm*Hh,Em*zh,MM*Hh,CM*zh),Q.applyPatternTransform(dn,zi._tempPatternMatrix),o.fillStyle=dn,o.fillRect(mt,gt,ui,Ut)}else{let Br=E!==16777215||xe?Q.getTintedCanvas({texture:h},E):u,pr=Br!==u;o.drawImage(Br,pr?0:z,pr?0:J,pr?Br.width:D,pr?Br.height:N,mt,gt,ui,Ut)}}}};yf._tempPatternMatrix=new I;yf.extension={type:[b.CanvasPipesAdaptor],name:"batch"};fT=yf});var da,gT=f(()=>{P();da=class{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,r){this._renderer.renderPipes.batch.break(r);let s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&e.mask;let n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);let s=this._colorStack;this._colorStackIndex--;let n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}};da.extension={type:[b.CanvasPipes],name:"colorMask"}});function xT(i){let e=[];return i.replace(Tk,(t,r,s)=>{let n=r.toLowerCase(),o=r,a=Mk(s);for(n==="m"&&a.length>2&&(e.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===bf[n])return e.push([o,...a]),"";if(a.length<bf[n])throw new Error("malformed path data");e.push([o,...a.splice(0,bf[n])])}}),e}function Mk(i){let e=i.match(wk);return e?e.map(Number):[]}var bf,Tk,wk,yT=f(()=>{bf={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Tk=/([astvzqmhlc])([^astvzqmhlc]*)/gi,wk=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi});function bT(i,e){let t=xT(i),r=[],s=null,n=0,o=0;for(let a=0;a<t.length;a++){let l=t[a],c=l[0],h=l;switch(c){case"M":n=h[1],o=h[2],e.moveTo(n,o);break;case"m":n+=h[1],o+=h[2],e.moveTo(n,o);break;case"H":n=h[1],e.lineTo(n,o);break;case"h":n+=h[1],e.lineTo(n,o);break;case"V":o=h[1],e.lineTo(n,o);break;case"v":o+=h[1],e.lineTo(n,o);break;case"L":n=h[1],o=h[2],e.lineTo(n,o);break;case"l":n+=h[1],o+=h[2],e.lineTo(n,o);break;case"C":n=h[5],o=h[6],e.bezierCurveTo(h[1],h[2],h[3],h[4],n,o);break;case"c":e.bezierCurveTo(n+h[1],o+h[2],n+h[3],o+h[4],n+h[5],o+h[6]),n+=h[5],o+=h[6];break;case"S":n=h[3],o=h[4],e.bezierCurveToShort(h[1],h[2],n,o);break;case"s":e.bezierCurveToShort(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"Q":n=h[3],o=h[4],e.quadraticCurveTo(h[1],h[2],n,o);break;case"q":e.quadraticCurveTo(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"T":n=h[1],o=h[2],e.quadraticCurveToShort(n,o);break;case"t":n+=h[1],o+=h[2],e.quadraticCurveToShort(n,o);break;case"A":n=h[6],o=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"a":n+=h[6],o+=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"Z":case"z":e.closePath(),r.length>0&&(s=r.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:G(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&s===null&&(s={startX:n,startY:o},r.push(s))}return e}var _T=f(()=>{yT();ie()});var _f,vf,Tf,Ys,ch=f(()=>{P();xc();pp();Pl();Dt();de();br();oh();_f=class{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{Te.return(e)}),this.graphicsData&&Te.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}},vf=class{constructor(){this.instructions=new Hr}init(e){let t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Eo({maxTextures:t}),this.instructions.reset()}get geometry(){return B(_u,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}},Tf=class Sf{constructor(e){this._renderer=e,this._managedContexts=new Ee({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Sf.defaultOptions.bezierSmoothness=e?.bezierSmoothness??Sf.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){let t=!!e._gpuData[this._renderer.uid],r=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&r.reset(),dT(e,r);let s=e.batchMode;e.customShader||s==="no-batch"?r.isBatchable=!1:s==="auto"?r.isBatchable=r.geometryData.vertices.length<400:r.isBatchable=!0,e.dirty=!1}return r}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){let t=Te.get(vf,{maxTextures:this._renderer.limits.maxBatchableTextures}),r=e._gpuData[this._renderer.uid],{batches:s,geometryData:n}=r;r.graphicsData=t;let o=n.vertices.length,a=n.indices.length;for(let u=0;u<s.length;u++)s[u].applyTransform=!1;let l=t.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let u=0;u<s.length;u++){let d=s[u];l.add(d)}l.finish(t.instructions);let c=l.geometry;c.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),c.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);let h=l.batches;for(let u=0;u<l.batchIndex;u++){let d=h[u];d.bindGroup=ks(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){let t=new _f;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Tf.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"graphicsContext"};Tf.defaultOptions={bezierSmoothness:.5};Ys=Tf});function uh(i,e,t,r,s,n,o,a,l,c){let u=Math.min(.99,Math.max(0,c??Ys.defaultOptions.bezierSmoothness)),d=(Ek-u)/1;return d*=d,Pk(e,t,r,s,n,o,a,l,i,d),i}function Pk(i,e,t,r,s,n,o,a,l,c){Mf(i,e,t,r,s,n,o,a,l,c,0),l.push(o,a)}function Mf(i,e,t,r,s,n,o,a,l,c,h){if(h>Ck)return;let u=Math.PI,d=(i+t)/2,p=(e+r)/2,m=(t+s)/2,x=(r+n)/2,y=(s+o)/2,g=(n+a)/2,v=(d+m)/2,_=(p+x)/2,S=(m+y)/2,T=(x+g)/2,w=(v+S)/2,E=(_+T)/2;if(h>0){let R=o-i,k=a-e,C=Math.abs((t-o)*k-(r-a)*R),M=Math.abs((s-o)*k-(n-a)*R),A,U;if(C>hh&&M>hh){if((C+M)*(C+M)<=c*(R*R+k*k)){if(Ks<wf){l.push(w,E);return}let z=Math.atan2(n-r,s-t);if(A=Math.abs(z-Math.atan2(r-e,t-i)),U=Math.abs(Math.atan2(a-n,o-s)-z),A>=u&&(A=2*u-A),U>=u&&(U=2*u-U),A+U<Ks){l.push(w,E);return}if(Wi!==0){if(A>Wi){l.push(t,r);return}if(U>Wi){l.push(s,n);return}}}}else if(C>hh){if(C*C<=c*(R*R+k*k)){if(Ks<wf){l.push(w,E);return}if(A=Math.abs(Math.atan2(n-r,s-t)-Math.atan2(r-e,t-i)),A>=u&&(A=2*u-A),A<Ks){l.push(t,r),l.push(s,n);return}if(Wi!==0&&A>Wi){l.push(t,r);return}}}else if(M>hh){if(M*M<=c*(R*R+k*k)){if(Ks<wf){l.push(w,E);return}if(A=Math.abs(Math.atan2(a-n,o-s)-Math.atan2(n-r,s-t)),A>=u&&(A=2*u-A),A<Ks){l.push(t,r),l.push(s,n);return}if(Wi!==0&&A>Wi){l.push(s,n);return}}}else if(R=w-(i+o)/2,k=E-(e+a)/2,R*R+k*k<=c){l.push(w,E);return}}Mf(i,e,d,p,v,_,w,E,l,c,h+1),Mf(w,E,S,T,y,g,o,a,l,c,h+1)}var Ck,hh,Ek,wf,Ks,Wi,Cf=f(()=>{ch();Ck=8,hh=11920929e-14,Ek=1,wf=.01,Ks=0,Wi=0});function ST(i,e,t,r,s,n,o,a){let c=Math.min(.99,Math.max(0,a??Ys.defaultOptions.bezierSmoothness)),h=(Rk-c)/1;return h*=h,Ik(e,t,r,s,n,o,i,h),i}function Ik(i,e,t,r,s,n,o,a){Ef(o,i,e,t,r,s,n,a,0),o.push(s,n)}function Ef(i,e,t,r,s,n,o,a,l){if(l>kk)return;let c=Math.PI,h=(e+r)/2,u=(t+s)/2,d=(r+n)/2,p=(s+o)/2,m=(h+d)/2,x=(u+p)/2,y=n-e,g=o-t,v=Math.abs((r-n)*g-(s-o)*y);if(v>Ak){if(v*v<=a*(y*y+g*g)){if(vT<Bk){i.push(m,x);return}let _=Math.abs(Math.atan2(o-s,n-r)-Math.atan2(s-t,r-e));if(_>=c&&(_=2*c-_),_<vT){i.push(m,x);return}}}else if(y=m-(e+n)/2,g=x-(t+o)/2,y*y+g*g<=a){i.push(m,x);return}Ef(i,e,t,h,u,m,x,a,l+1),Ef(i,m,x,d,p,n,o,a,l+1)}var kk,Ak,Rk,Bk,vT,TT=f(()=>{ch();kk=8,Ak=11920929e-14,Rk=1,Bk=.01,vT=0});function dh(i,e,t,r,s,n,o,a){let l=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(r,1/3)*(l/Math.PI)))),a=Math.max(a,3);let c=l/a,h=s;c*=o?-1:1;for(let u=0;u<a+1;u++){let d=Math.cos(h),p=Math.sin(h),m=e+d*r,x=t+p*r;i.push(m,x),h+=c}}var Pf=f(()=>{"use strict"});function wT(i,e,t,r,s,n){let o=i[i.length-2],l=i[i.length-1]-t,c=o-e,h=s-t,u=r-e,d=Math.abs(l*u-c*h);if(d<1e-8||n===0){(i[i.length-2]!==e||i[i.length-1]!==t)&&i.push(e,t);return}let p=l*l+c*c,m=h*h+u*u,x=l*h+c*u,y=n*Math.sqrt(p)/d,g=n*Math.sqrt(m)/d,v=y*x/p,_=g*x/m,S=y*u+g*c,T=y*h+g*l,w=c*(g+v),E=l*(g+v),R=u*(y+_),k=h*(y+_),C=Math.atan2(E-T,w-S),M=Math.atan2(k-T,R-S);dh(i,S+e,T+t,n,C,M,c*h>u*l)}var MT=f(()=>{Pf()});function Gk(i,e){let t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=e===1.5707963267948966?.551915024494:t,s=Math.cos(i),n=Math.sin(i),o=Math.cos(i+e),a=Math.sin(i+e);return[{x:s-n*r,y:n+s*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}function ET(i,e,t,r,s,n,o,a=0,l=0,c=0){if(n===0||o===0)return;let h=Math.sin(a*pa/360),u=Math.cos(a*pa/360),d=u*(e-r)/2+h*(t-s)/2,p=-h*(e-r)/2+u*(t-s)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);let m=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),Fk(e,t,r,s,n,o,l,c,h,u,d,p,kf);let{ang1:x,ang2:y}=kf,{centerX:g,centerY:v}=kf,_=Math.abs(y)/(pa/4);Math.abs(1-_)<1e-7&&(_=1);let S=Math.max(Math.ceil(_),1);y/=S;let T=i[i.length-2],w=i[i.length-1],E={x:0,y:0};for(let R=0;R<S;R++){let k=Gk(x,y),{x:C,y:M}=Af(k[0],n,o,u,h,g,v,E),{x:A,y:U}=Af(k[1],n,o,u,h,g,v,E),{x:z,y:J}=Af(k[2],n,o,u,h,g,v,E);uh(i,T,w,C,M,A,U,z,J),T=z,w=J,x+=y}}var pa,kf,Af,CT,Fk,PT=f(()=>{Cf();pa=Math.PI*2,kf={centerX:0,centerY:0,ang1:0,ang2:0},Af=({x:i,y:e},t,r,s,n,o,a,l)=>{i*=t,e*=r;let c=s*i-n*e,h=n*i+s*e;return l.x=c+o,l.y=h+a,l};CT=(i,e,t,r)=>{let s=i*r-e*t<0?-1:1,n=i*t+e*r;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},Fk=(i,e,t,r,s,n,o,a,l,c,h,u,d)=>{let p=Math.pow(s,2),m=Math.pow(n,2),x=Math.pow(h,2),y=Math.pow(u,2),g=p*m-p*y-m*x;g<0&&(g=0),g/=p*y+m*x,g=Math.sqrt(g)*(o===a?-1:1);let v=g*s/n*u,_=g*-n/s*h,S=c*v-l*_+(i+t)/2,T=l*v+c*_+(e+r)/2,w=(h-v)/s,E=(u-_)/n,R=(-h-v)/s,k=(-u-_)/n,C=CT(1,0,w,E),M=CT(w,E,R,k);a===0&&M>0&&(M-=pa),a===1&&M<0&&(M+=pa),d.centerX=S,d.centerY=T,d.ang1=C,d.ang2=M}});function kT(i,e,t){let r=(o,a)=>{let l=a.x-o.x,c=a.y-o.y,h=Math.sqrt(l*l+c*c),u=l/h,d=c/h;return{len:h,nx:u,ny:d}},s=(o,a)=>{o===0?i.moveTo(a.x,a.y):i.lineTo(a.x,a.y)},n=e[e.length-1];for(let o=0;o<e.length;o++){let a=e[o%e.length],l=a.radius??t;if(l<=0){s(o,a),n=a;continue}let c=e[(o+1)%e.length],h=r(a,n),u=r(a,c);if(h.len<1e-4||u.len<1e-4){s(o,a),n=a;continue}let d=Math.asin(h.nx*u.ny-h.ny*u.nx),p=1,m=!1;h.nx*u.nx-h.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,p=-1,m=!0):d>0&&(p=-1,m=!0);let x=d/2,y,g=Math.abs(Math.cos(x)*l/Math.sin(x));g>Math.min(h.len/2,u.len/2)?(g=Math.min(h.len/2,u.len/2),y=Math.abs(g*Math.sin(x)/Math.cos(x))):y=l;let v=a.x+u.nx*g+-u.ny*y*p,_=a.y+u.ny*g+u.nx*y*p,S=Math.atan2(h.ny,h.nx)+Math.PI/2*p,T=Math.atan2(u.ny,u.nx)-Math.PI/2*p;o===0&&i.moveTo(v+Math.cos(S)*y,_+Math.sin(S)*y),i.arc(v,_,y,S,T,m),n=a}}function AT(i,e,t,r){let s=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,c)=>({x:a.x+(l.x-a.x)*c,y:a.y+(l.y-a.y)*c}),o=e.length;for(let a=0;a<o;a++){let l=e[(a+1)%o],c=l.radius??t;if(c<=0){a===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y);continue}let h=e[a],u=e[(a+2)%o],d=s(h,l),p;if(d<1e-4)p=l;else{let y=Math.min(d/2,c);p=n(l,h,y/d)}let m=s(u,l),x;if(m<1e-4)x=l;else{let y=Math.min(m/2,c);x=n(l,u,y/m)}a===0?i.moveTo(p.x,p.y):i.lineTo(p.x,p.y),i.quadraticCurveTo(l.x,l.y,x.x,x.y,r)}}var RT=f(()=>{"use strict"});var Dk,ph,BT=f(()=>{Z0();Q0();J0();Ge();ey();lt();Cf();TT();Pf();MT();PT();RT();Dk=new V,ph=class{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new fe,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let r=this._currentPoly.points,s=r[r.length-2],n=r[r.length-1];return(s!==e||n!==t)&&r.push(e,t),this}arc(e,t,r,s,n,o){this._ensurePoly(!1);let a=this._currentPoly.points;return dh(a,e,t,r,s,n,o),this}arcTo(e,t,r,s,n){this._ensurePoly();let o=this._currentPoly.points;return wT(o,e,t,r,s,n),this}arcToSvg(e,t,r,s,n,o,a){let l=this._currentPoly.points;return ET(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,r,s,n),this}bezierCurveTo(e,t,r,s,n,o,a){this._ensurePoly();let l=this._currentPoly;return uh(this._currentPoly.points,l.lastX,l.lastY,e,t,r,s,n,o,a),this}quadraticCurveTo(e,t,r,s,n){this._ensurePoly();let o=this._currentPoly;return ST(this._currentPoly.points,o.lastX,o.lastY,e,t,r,s,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));let r=this.shapePrimitives,s=r.length;for(let n=0;n<e.instructions.length;n++){let o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&r.length-s>1){let n=null;for(let o=s;o<r.length;o++){let a=r[o];if(a.shape.type==="polygon"){let l=a.shape,c=n?.shape;c&&c.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),r.copyWithin(o,o+1),r.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,r,s,n){return this.drawShape(new V(e,t,r,s),n),this}circle(e,t,r,s){return this.drawShape(new ql(e,t,r),s),this}poly(e,t,r){let s=new Ss(e);return s.closePath=t,this.drawShape(s,r),this}regularPoly(e,t,r,s,n=0,o){s=Math.max(s|0,3);let a=-1*Math.PI/2+n,l=Math.PI*2/s,c=[];for(let h=0;h<s;h++){let u=a-h*l;c.push(e+r*Math.cos(u),t+r*Math.sin(u))}return this.poly(c,!0,o),this}roundPoly(e,t,r,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(e,t,r,s,o);let l=r*Math.sin(Math.PI/s)-.001;n=Math.min(n,l);let c=-1*Math.PI/2+o,h=Math.PI*2/s,u=(s-2)*Math.PI/s/2;for(let d=0;d<s;d++){let p=d*h+c,m=e+r*Math.cos(p),x=t+r*Math.sin(p),y=p+Math.PI+u,g=p-Math.PI-u,v=m+n*Math.cos(y),_=x+n*Math.sin(y),S=m+n*Math.cos(g),T=x+n*Math.sin(g);d===0?this.moveTo(v,_):this.lineTo(v,_),this.quadraticCurveTo(m,x,S,T,a)}return this.closePath()}roundShape(e,t,r=!1,s){return e.length<3?this:(r?AT(this,e,t,s):kT(this,e,t),this.closePath())}filletRect(e,t,r,s,n){if(n===0)return this.rect(e,t,r,s);let o=Math.min(r,s)/2,a=Math.min(o,Math.max(-o,n)),l=e+r,c=t+s,h=a<0?-a:0,u=Math.abs(a);return this.moveTo(e,t+u).arcTo(e+h,t+h,e+u,t,u).lineTo(l-u,t).arcTo(l-h,t+h,l,t+u,u).lineTo(l,c-u).arcTo(l-h,c-h,e+r-u,c,u).lineTo(e+u,c).arcTo(e+h,c-h,e,c-u,u).closePath()}chamferRect(e,t,r,s,n,o){if(n<=0)return this.rect(e,t,r,s);let a=Math.min(n,Math.min(r,s)/2),l=e+r,c=t+s,h=[e+a,t,l-a,t,l,t+a,l,c-a,l-a,c,e+a,c,e,c-a,e,t+a];for(let u=h.length-1;u>=2;u-=2)h[u]===h[u-2]&&h[u-1]===h[u-3]&&h.splice(u-1,2);return this.poly(h,!0,o)}ellipse(e,t,r,s,n){return this.drawShape(new Zl(e,t,r,s),n),this}roundRect(e,t,r,s,n,o){return this.drawShape(new Jl(e,t,r,s,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let r=this._currentPoly;return r&&this.endPoly(),r=new Ss,r.points.push(e,t),this._currentPoly=r,this}endPoly(e=!1){let t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Ss,e)){let t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let r=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){let n=t.transform,o=r;r=n.a*r+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(r,s)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){let r=e.instructions[t];this[r.action](...r.data)}this.finish()}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let r=0;r<t.length;r++){let s=t[r],n=s.shape.getBounds(Dk);s.transform?e.addRect(n,s.transform):e.addRect(n)}return e}}});function js(i,e){return i?i.prepend(e):e.clone()}var Ot,fh=f(()=>{Wt();Ue();ie();_T();BT();Ot=class i{constructor(e,t=!1){this.instructions=[],this.uid=K("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?bT(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new ph(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,r,s,n){let o=this.instructions[this.instructions.length-1],a=this.getLastPoint(ne.shared),l=0,c=0;if(!o||o.action!=="bezierCurveTo")l=a.x,c=a.y;else{l=o.data[2],c=o.data[3];let h=a.x,u=a.y;l=h+(h-l),c=u+(u-c)}return this.instructions.push({action:"bezierCurveTo",data:[l,c,e,t,r,s,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,r){let s=this.instructions[this.instructions.length-1],n=this.getLastPoint(ne.shared),o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];let l=n.x,c=n.y;o=l+(l-o),a=c+(c-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,r]}),this._dirty=!0,this}rect(e,t,r,s,n){return this.instructions.push({action:"rect",data:[e,t,r,s,n]}),this._dirty=!0,this}circle(e,t,r,s){return this.instructions.push({action:"circle",data:[e,t,r,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,r,s,n,o,a){n||(n=s/2);let l=-1*Math.PI/2+o,c=r*2,h=Math.PI*2/c,u=[];for(let d=0;d<c;d++){let p=d%2?n:s,m=d*h+l;u.push(e+p*Math.cos(m),t+p*Math.sin(m))}return this.poly(u,!0,a),this}clone(e=!1){let t=new i;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let r=0;r<this.instructions.length;r++){let s=this.instructions[r];t.instructions.push({action:s.action,data:s.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;let t=e.a,r=e.b,s=e.c,n=e.d,o=e.tx,a=e.ty,l=0,c=0,h=0,u=0,d=0,p=0,m=0,x=0;for(let y=0;y<this.instructions.length;y++){let g=this.instructions[y],v=g.data;switch(g.action){case"moveTo":case"lineTo":l=v[0],c=v[1],v[0]=t*l+s*c+o,v[1]=r*l+n*c+a;break;case"bezierCurveTo":h=v[0],u=v[1],d=v[2],p=v[3],l=v[4],c=v[5],v[0]=t*h+s*u+o,v[1]=r*h+n*u+a,v[2]=t*d+s*p+o,v[3]=r*d+n*p+a,v[4]=t*l+s*c+o,v[5]=r*l+n*c+a;break;case"quadraticCurveTo":h=v[0],u=v[1],l=v[2],c=v[3],v[0]=t*h+s*u+o,v[1]=r*h+n*u+a,v[2]=t*l+s*c+o,v[3]=r*l+n*c+a;break;case"arcToSvg":l=v[5],c=v[6],m=v[0],x=v[1],v[0]=t*m+s*x,v[1]=r*m+n*x,v[5]=t*l+s*c+o,v[6]=r*l+n*c+a;break;case"circle":v[4]=js(v[3],e);break;case"rect":v[4]=js(v[4],e);break;case"ellipse":v[8]=js(v[8],e);break;case"roundRect":v[5]=js(v[5],e);break;case"addPath":v[0].transform(e);break;case"poly":v[2]=js(v[2],e);break;case"regularPoly":case"chamferRect":v[5]=js(v[5],e);break;case"closePath":break;default:G("unknown transform action",g.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,r=this.instructions[t];if(!r)return e.x=0,e.y=0,e;for(;r.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;r=this.instructions[t]}switch(r.action){case"moveTo":case"lineTo":e.x=r.data[0],e.y=r.data[1];break;case"quadraticCurveTo":e.x=r.data[2],e.y=r.data[3];break;case"bezierCurveTo":e.x=r.data[4],e.y=r.data[5];break;case"arc":case"arcToSvg":e.x=r.data[5],e.y=r.data[6];break;case"addPath":r.data[0].getLastPoint(e);break}return e}}});function Ve(i,e,t){let r=i.getAttribute(e);return r?Number(r):t}var Rf=f(()=>{"use strict"});function IT(i,e){let t=i.querySelectorAll("defs");for(let r=0;r<t.length;r++){let s=t[r];for(let n=0;n<s.children.length;n++){let o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=Ok(o);break;case"radialgradient":e.defs[o.id]=Lk(o);break;default:break}}}}function qt(i,e,t){let r=i.getAttribute(e);if(r?.trim().endsWith("%")){let s=Number(r.trim().slice(0,-1));return Number.isNaN(s)?t:s/100}return Ve(i,e,t)}function GT(i){return(i.getAttribute("gradientUnits")||"objectBoundingBox")==="objectBoundingBox"?"local":"global"}function FT(i){let e=[];for(let t=0;t<i.children.length;t++){let r=i.children[t],s=qt(r,"offset",0),n=q.shared.setValue(r.getAttribute("stop-color")).toNumber();e.push({offset:s,color:n})}return e}function Ok(i){let e=qt(i,"x1",0),t=qt(i,"y1",0),r=qt(i,"x2",1),s=qt(i,"y2",0);return new ot({type:"linear",start:{x:e,y:t},end:{x:r,y:s},textureSpace:GT(i),colorStops:FT(i)})}function Lk(i){let e=qt(i,"cx",.5),t=qt(i,"cy",.5),r=qt(i,"r",.5),s=qt(i,"fx",e),n=qt(i,"fy",t),o=qt(i,"fr",0);return new ot({type:"radial",center:{x:s,y:n},innerRadius:o,outerCenter:{x:e,y:t},outerRadius:r,textureSpace:GT(i),colorStops:FT(i)})}var DT=f(()=>{Je();Ni();Rf()});function Bf(i){let e=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}var OT=f(()=>{"use strict"});function If(i,e){let t=i.getAttribute("style"),r={},s={},n={strokeStyle:r,fillStyle:s,useFill:!1,useStroke:!1};for(let o in LT){let a=i.getAttribute(o);a&&UT(e,n,o,a.trim())}if(t){let o=t.split(";");for(let a=0;a<o.length;a++){let l=o[a].trim(),[c,h]=l.split(":");LT[c]&&UT(e,n,c,h.trim())}}return{strokeStyle:n.useStroke?r:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function UT(i,e,t,r){switch(t){case"stroke":if(r!=="none"){if(r.startsWith("url(")){let s=Bf(r);e.strokeStyle.fill=i.defs[s]}else e.strokeStyle.color=q.shared.setValue(r).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(r);break;case"fill":if(r!=="none"){if(r.startsWith("url(")){let s=Bf(r);e.fillStyle.fill=i.defs[s]}else e.fillStyle.color=q.shared.setValue(r).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(r);break;case"stroke-opacity":e.strokeStyle.alpha=Number(r);break;case"opacity":e.fillStyle.alpha=Number(r),e.strokeStyle.alpha=Number(r);break}}var LT,NT=f(()=>{Je();OT();LT={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}}});function HT(i){if(i.length<=2)return!0;let e=i.map(a=>a.area).sort((a,l)=>l-a),[t,r]=e,s=e[e.length-1],n=t/r,o=r/s;return!(n>3&&o<2)}var zT=f(()=>{"use strict"});function WT(i){return i.split(/(?=[Mm])/).filter(r=>r.trim().length>0)}function VT(i){let e=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;let t=e.map(Number),r=[],s=[];for(let h=0;h<t.length;h+=2)h+1<t.length&&(r.push(t[h]),s.push(t[h+1]));if(r.length===0||s.length===0)return 0;let n=Math.min(...r),o=Math.max(...r),a=Math.min(...s),l=Math.max(...s);return(o-n)*(l-a)}function Gf(i,e){let t=new Ot(i,!1);for(let r of t.instructions)e.instructions.push(r)}var $T=f(()=>{fh()});function XT(i,e){if(typeof i=="string"){let o=document.createElement("div");o.innerHTML=i.trim(),i=o.querySelector("svg")}let t={context:e,defs:{},path:new Ot};IT(i,t);let r=i.children,{fillStyle:s,strokeStyle:n}=If(i,t);for(let o=0;o<r.length;o++){let a=r[o];a.nodeName.toLowerCase()!=="defs"&&YT(a,t,s,n)}return e}function YT(i,e,t,r){let s=i.children,{fillStyle:n,strokeStyle:o}=If(i,e);n&&t?t={...t,...n}:n&&(t=n),o&&r?r={...r,...o}:o&&(r=o);let a=!t&&!r;a&&(t={color:0});let l,c,h,u,d,p,m,x,y,g,v,_,S,T,w,E,R;switch(i.nodeName.toLowerCase()){case"path":{T=i.getAttribute("d");let k=i.getAttribute("fill-rule"),C=WT(T),M=k==="evenodd",A=C.length>1;if(M&&A){let z=C.map(D=>({path:D,area:VT(D)}));if(z.sort((D,N)=>N.area-D.area),C.length>3||!HT(z))for(let D=0;D<z.length;D++){let N=z[D],Y=D===0;e.context.beginPath();let L=new Ot(void 0,!0);Gf(N.path,L),e.context.path(L),Y?(t&&e.context.fill(t),r&&e.context.stroke(r)):e.context.cut()}else for(let D=0;D<z.length;D++){let N=z[D],Y=D%2===1;e.context.beginPath();let L=new Ot(void 0,!0);Gf(N.path,L),e.context.path(L),Y?e.context.cut():(t&&e.context.fill(t),r&&e.context.stroke(r))}}else{let z=k?k==="evenodd":!0;w=new Ot(T,z),e.context.path(w),t&&e.context.fill(t),r&&e.context.stroke(r)}break}case"circle":m=Ve(i,"cx",0),x=Ve(i,"cy",0),y=Ve(i,"r",0),e.context.ellipse(m,x,y,y),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"rect":l=Ve(i,"x",0),c=Ve(i,"y",0),E=Ve(i,"width",0),R=Ve(i,"height",0),g=Ve(i,"rx",0),v=Ve(i,"ry",0),g||v?e.context.roundRect(l,c,E,R,g||v):e.context.rect(l,c,E,R),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"ellipse":m=Ve(i,"cx",0),x=Ve(i,"cy",0),g=Ve(i,"rx",0),v=Ve(i,"ry",0),e.context.beginPath(),e.context.ellipse(m,x,g,v),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"line":h=Ve(i,"x1",0),u=Ve(i,"y1",0),d=Ve(i,"x2",0),p=Ve(i,"y2",0),e.context.beginPath(),e.context.moveTo(h,u),e.context.lineTo(d,p),r&&e.context.stroke(r);break;case"polygon":S=i.getAttribute("points"),_=S.match(/-?\d+/g).map(k=>parseInt(k,10)),e.context.poly(_,!0),t&&e.context.fill(t),r&&e.context.stroke(r);break;case"polyline":S=i.getAttribute("points"),_=S.match(/-?\d+/g).map(k=>parseInt(k,10)),e.context.poly(_,!1),r&&e.context.stroke(r);break;case"g":case"svg":break;default:{G(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}a&&(t=null);for(let k=0;k<s.length;k++)YT(s[k],e,t,r)}var KT=f(()=>{ie();fh();DT();Rf();NT();zT();$T()});function Uk(i){return q.isColorLike(i)}function jT(i){return i instanceof jt}function qT(i){return i instanceof ot}function Nk(i){return i instanceof F}function Hk(i,e,t){let r=q.shared.setValue(e??0);return i.color=r.toNumber(),i.alpha=r.alpha===1?t.alpha:r.alpha,i.texture=F.WHITE,{...t,...i}}function zk(i,e,t){return i.texture=e,{...t,...i}}function ZT(i,e,t){return i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function QT(i,e,t){return e.buildGradient(),i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function Wk(i,e){let t={...e,...i},r=q.shared.setValue(t.color);return t.alpha*=r.alpha,t.color=r.toNumber(),t}function Pr(i,e){if(i==null)return null;let t={},r=i;return Uk(i)?Hk(t,i,e):Nk(i)?zk(t,i,e):jT(i)?ZT(t,i,e):qT(i)?QT(t,i,e):r.fill&&jT(r.fill)?ZT(r,r.fill,e):r.fill&&qT(r.fill)?QT(r,r.fill,e):Wk(r,e)}function qs(i,e){let{width:t,alignment:r,miterLimit:s,cap:n,join:o,pixelLine:a,...l}=e,c=Pr(i,l);return c?{width:t,alignment:r,miterLimit:s,cap:n,join:o,pixelLine:a,...c}:null}var Ff=f(()=>{Je();ye();Ni();ha()});function JT(i,e){let t=1,r=i.shapePath.shapePrimitives;for(let s=0;s<r.length;s++){let n=r[s].shape;if(n.type!=="polygon")continue;let o=n.points,a=o.length;if(a<6)continue;let l=n.closePath;for(let c=0;c<a;c+=2){if(!l&&(c===0||c===a-2))continue;let h=(c-2+a)%a,u=(c+2)%a,d=o[h],p=o[h+1],m=o[c],x=o[c+1],y=o[u],g=o[u+1],v=d-m,_=p-x,S=y-m,T=g-x,w=v*v+_*_,E=S*S+T*T;if(w<1e-12||E<1e-12)continue;let C=(v*S+_*T)/Math.sqrt(w*E);C<-1?C=-1:C>1&&(C=1);let M=Math.sqrt((1-C)*.5);if(M<1e-6)continue;let A=Math.min(1/M,e);A>t&&(t=A)}}return t}var e2=f(()=>{"use strict"});var Vk,t2,Df,Ct,Of=f(()=>{Oe();Je();oe();Wt();ye();Ue();de();lt();fh();KT();Ff();e2();Vk=new ne,t2=new I,Df=class ur extends le{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=K("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Ot,this._transform=new I,this._fillStyle={...ur.defaultFillStyle},this._strokeStyle={...ur.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new fe,this._boundsDirty=!0}clone(){let e=new ur;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Pr(e,ur.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=qs(e,ur.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Pr(e,ur.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Pr(e,ur.defaultStrokeStyle),this}texture(e,t,r,s,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:r||0,dy:s||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?q.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Ot,this}fill(e,t){let r,s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="stroke"?r=s.data.path:r=this._activePath.clone(),r?(e!=null&&(t!==void 0&&typeof e=="number"&&(B($,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Pr(e,ur.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint(ne.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t,r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="fill"?t=r.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=qs(e,ur.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){let t=this.instructions[this.instructions.length-1-e],r=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(r);else{t.data.hole=r;break}}return this._initNextPathLocation(),this}arc(e,t,r,s,n,o){this._tick++;let a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,r,s,n,o),this}arcTo(e,t,r,s,n){this._tick++;let o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*r+o.c*s+o.tx,o.b*r+o.d*s+o.ty,n),this}arcToSvg(e,t,r,s,n,o,a){this._tick++;let l=this._transform;return this._activePath.arcToSvg(e,t,r,s,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,r,s,n,o,a){this._tick++;let l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*t+l.tx,l.b*e+l.d*t+l.ty,l.a*r+l.c*s+l.tx,l.b*r+l.d*s+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,r,s){return this._tick++,this._activePath.ellipse(e,t,r,s,this._transform.clone()),this}circle(e,t,r){return this._tick++,this._activePath.circle(e,t,r,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;let r=this._transform;return this._activePath.lineTo(r.a*e+r.c*t+r.tx,r.b*e+r.d*t+r.ty),this}moveTo(e,t){this._tick++;let r=this._transform,s=this._activePath.instructions,n=r.a*e+r.c*t+r.tx,o=r.b*e+r.d*t+r.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,t,r,s,n){this._tick++;let o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*r+o.c*s+o.tx,o.b*r+o.d*s+o.ty,n),this}rect(e,t,r,s){return this._tick++,this._activePath.rect(e,t,r,s,this._transform.clone()),this}roundRect(e,t,r,s,n){return this._tick++,this._activePath.roundRect(e,t,r,s,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,r,s,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,r,s,n,o),this}roundPoly(e,t,r,s,n,o){return this._tick++,this._activePath.roundPoly(e,t,r,s,n,o),this}roundShape(e,t,r,s){return this._tick++,this._activePath.roundShape(e,t,r,s),this}filletRect(e,t,r,s,n){return this._tick++,this._activePath.filletRect(e,t,r,s,n),this}chamferRect(e,t,r,s,n,o){return this._tick++,this._activePath.chamferRect(e,t,r,s,n,o),this}star(e,t,r,s,n=0,o=0){return this._tick++,this._activePath.star(e,t,r,s,n,o,this._transform.clone()),this}svg(e){return this._tick++,XT(e,this),this}restore(){let e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,r,s,n,o){return e instanceof I?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,r,s,n,o),this)}transform(e,t,r,s,n,o){return e instanceof I?(this._transform.append(e),this):(t2.set(e,t,r,s,n,o),this._transform.append(t2),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){let r=this.instructions[t],s=r.action;if(s==="fill"){let n=r.data;e.addBounds(n.path.bounds)}else if(s==="texture"){let n=r.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){let n=r.data,o=n.style.alignment,a=n.style.width*(1-o);n.style.join==="miter"&&(a*=JT(n.path,n.style.miterLimit));let l=n.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;let t=this.instructions,r=!1;for(let s=0;s<t.length;s++){let n=t[s],o=n.data,a=o.path;if(!n.action||!a)continue;let l=o.style,c=a.shapePath.shapePrimitives;for(let h=0;h<c.length;h++){let u=c[h].shape;if(!l||!u)continue;let d=c[h].transform,p=d?d.applyInverse(e,Vk):e;if(n.action==="fill")r=u.contains(p.x,p.y);else{let x=l;r=u.strokeContains(p.x,p.y,x.width,x.alignment)}let m=o.hole;if(m){let x=m.shapePath?.shapePrimitives;if(x)for(let y=0;y<x.length;y++)x[y].shape.contains(p.x,p.y)&&(r=!1)}if(r)return!0}}return r}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){let r=typeof e=="boolean"?e:e?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(r)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(r))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Df.defaultFillStyle={color:16777215,alpha:1,texture:F.WHITE,matrix:null,fill:null,textureSpace:"local"};Df.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:F.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};Ct=Df});var Lf,Uf,Hf,r2,i2=f(()=>{P();Pl();Dt();Lf=class{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}},Uf=class{constructor(){this.instructions=new Hr}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}},Hf=class Nf{constructor(e){this._renderer=e,this._managedContexts=new Ee({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Nf.defaultOptions.bezierSmoothness=e?.bezierSmoothness??Nf.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){let t=e._gpuData,r=!!t[this._renderer.uid],s=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!r)&&(r&&s.reset(),s.isBatchable=!1,e.dirty=!1),s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){let t=new Uf,r=this.getGpuContext(e);return r.graphicsData=t,t.init(),t}_initContext(e){let t=new Lf;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Hf.extension={type:[b.CanvasSystem],name:"graphicsContext"};Hf.defaultOptions={bezierSmoothness:.5};r2=Hf});var fa,s2=f(()=>{P();Kt();Dt();fa=class{constructor(e,t){this.state=ze.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ee({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}};fa.extension={type:[b.CanvasPipes],name:"graphics"}});var zf,ma,n2=f(()=>{P();Kt();Dt();br();Pc();ff();zf=class{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{Te.return(e)}),this.batches.length=0}},ma=class{constructor(e,t){this.state=ze.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ee({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){let t=e.context,r=!!e._gpuData,n=this.renderer.graphicsContext.updateGpuContext(t);return!!(n.isBatchable||r!==n.isBatchable)}addRenderable(e,t){let s=this.renderer.graphicsContext.updateGpuContext(e.context);(e.didViewUpdate||!e._gpuData[this.renderer.uid])&&this._rebuild(e),s.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){let r=this._getGpuDataForRenderable(e).batches;for(let s=0;s<r.length;s++){let n=r[s];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;let t=this.renderer,r=e.context;if(!t.graphicsContext.getGpuContext(r).batches.length)return;let n=r.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;let o=n.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=t._roundPixels|e._roundPixels,Os(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){let t=this._getGpuDataForRenderable(e),s=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),s.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){let r=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(e).batches;for(let n=0;n<s.length;n++){let o=s[n];r.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){let t=new zf;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){let r=e.context,n=this.renderer.graphicsContext.getGpuContext(r),o=this.renderer._roundPixels|e._roundPixels;t.batches=n.batches.map(a=>{let l=Te.get(Hi);return a.copyTo(l),l.renderable=e,l.roundPixels=o,l})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}};ma.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"graphics"}});var o2=f(()=>{P();i2();s2();ch();n2();H.add(fa);H.add(ma);H.add(r2);H.add(Ys)});var pt,mh=f(()=>{de();Nn();Of();o2();pt=class i extends ir{constructor(e){e instanceof Ct&&(e={context:e});let{context:t,roundPixels:r,...s}=e||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new Ct,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=r??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||e?.context===!0)&&this._context.destroy(e),this._context?.off("update",this.onViewUpdate,this),this._context?.off("unload",this.unload,this),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new i(this._context.clone()):(this._ownedContext=null,new i(this._context))}lineStyle(e,t,r){B($,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");let s={};return e&&(s.width=e),t&&(s.color=t),r&&(s.alpha=r),this.context.strokeStyle=s,this}beginFill(e,t){B($,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");let r={};return e!==void 0&&(r.color=e),t!==void 0&&(r.alpha=t),this.context.fillStyle=r,this}endFill(){B($,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();let e=this.context.strokeStyle;return(e.width!==Ct.defaultStrokeStyle.width||e.color!==Ct.defaultStrokeStyle.color||e.alpha!==Ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return B($,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return B($,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return B($,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return B($,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return B($,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return B($,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}});function $k(i,e,t,r,s,n){n=Math.max(0,Math.min(n,Math.min(r,s)/2)),i.moveTo(e+n,t),i.lineTo(e+r-n,t),i.quadraticCurveTo(e+r,t,e+r,t+n),i.lineTo(e+r,t+s-n),i.quadraticCurveTo(e+r,t+s,e+r-n,t+s),i.lineTo(e+n,t+s),i.quadraticCurveTo(e,t+s,e,t+s-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function a2(i,e){switch(e.type){case"rectangle":{let t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{let t=e;$k(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{let t=e;i.moveTo(t.x+t.radius,t.y),i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{let t=e;i.ellipse?(i.moveTo(t.x+t.halfWidth,t.y),i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.moveTo(1,0),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{let t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{let t=e,r=t.points;if(!r?.length)break;i.moveTo(r[0],r[1]);for(let s=2;s<r.length;s+=2)i.lineTo(r[s],r[s+1]);t.closePath&&i.closePath();break}}}function Xk(i,e,t){let r=[],s=[],n=[];if(!oi[e.type]?.build(e,r))return!1;let a=e.closePath??!0;$s(r,t,!1,a,s,n);for(let l=0;l<n.length;l+=3){let c=n[l]*2,h=n[l+1]*2,u=n[l+2]*2;i.moveTo(s[c],s[c+1]),i.lineTo(s[h],s[h+1]),i.lineTo(s[u],s[u+1]),i.closePath()}return!0}function Yk(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){let r=e[t];if(!r?.shape)continue;let s=r.transform,n=s&&!s.isIdentity();n&&(i.save(),i.transform(s.a,s.b,s.c,s.d,s.tx,s.ty)),a2(i,r.shape),n&&i.restore()}return!0}var ga,l2=f(()=>{P();ih();mh();oh();ie();ga=class{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;let t=this._renderer,r=t.canvasContext,s=r?.activeContext;if(!s)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&s.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");let n=e.mask.mask;if(!(n instanceof pt)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}let o=n,a=o.context?.instructions;if(!a?.length){this._canvasMaskStack.push(!1);return}s.save(),r.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),s.beginPath();let l=!1,c=!1;for(let h=0;h<a.length;h++){let u=a[h],d=u.action;if(d!=="fill"&&d!=="stroke")continue;let p=u.data,m=p?.path?.shapePath;if(!m?.shapePrimitives?.length)continue;let x=d==="stroke",y=m.shapePrimitives;for(let g=0;g<y.length;g++){let v=y[g];if(!v?.shape)continue;let _=v.transform,S=_&&!_.isIdentity();S&&(s.save(),s.transform(_.a,_.b,_.c,_.d,_.tx,_.ty)),x&&p.style?l=Xk(s,v.shape,p.style)||l:(a2(s,v.shape),c=Yk(s,v.holes)||c,l=!0),S&&s.restore()}}if(!l){s.restore(),this._canvasMaskStack.push(!1);return}c?s.clip("evenodd"):s.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),G(t))}};ga.extension={type:[b.CanvasPipes],name:"stencilMask"}});function c2(){let i=Kl(),e=Object.create(null);return e.inherit=ve,e.none=ve,e.normal="source-over",e.add="lighter",e.multiply=i?"multiply":ve,e.screen=i?"screen":ve,e.overlay=i?"overlay":ve,e.darken=i?"darken":ve,e.lighten=i?"lighten":ve,e["color-dodge"]=i?"color-dodge":ve,e["color-burn"]=i?"color-burn":ve,e["hard-light"]=i?"hard-light":ve,e["soft-light"]=i?"soft-light":ve,e.difference=i?"difference":ve,e.exclusion=i?"exclusion":ve,e.saturation=i?"saturation":ve,e.color=i?"color":ve,e.luminosity=i?"luminosity":ve,e["linear-burn"]=i?"color-burn":ve,e["linear-dodge"]=i?"color-dodge":ve,e["linear-light"]=i?"hard-light":ve,e["pin-light"]=i?"hard-light":ve,e["vivid-light"]=i?"hard-light":ve,e["hard-mix"]=ve,e.negation=i?"difference":ve,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=ve,e.divide=ve,e.min=ve,e.max=ve,e}var ve,h2=f(()=>{hd();ve="source-over"});var Kk,xa,u2=f(()=>{Je();P();oe();h2();Kk=new I,xa=class{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=c2(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){let e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){let t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,r,s){let n=s?I.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||I.IDENTITY,o=Kk;o.copyFrom(n),o.append(e);let a=this._projTransform,l=this.activeResolution;if(r=r||l,a){let c=I.shared;c.copyFrom(o),c.prepend(a),o=c}t?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l,o.ty*l)}clear(e,t){let r=this.activeContext,s=this._renderer;if(r.clearRect(0,0,s.width,s.height),e){let n=q.shared.setValue(e);r.globalAlpha=t??n.alpha,r.fillStyle=n.toHex(),r.fillRect(0,0,s.width,s.height),r.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;let t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}};xa.extension={type:[b.CanvasSystem],name:"canvasContext"}});var ya,d2=f(()=>{P();ya=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}};ya.extension={type:[b.CanvasSystem],name:"limits"}});var gh,p2=f(()=>{Je();we();ie();Vr();gh=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){let t=e.colorTexture,{canvas:r,context:s}=this._ensureCanvas(t);return{canvas:r,context:s,width:r.width,height:r.height}}resizeGpuRenderTarget(e){let t=e.colorTexture,{canvas:r}=this._ensureCanvas(t);r.width=e.pixelWidth,r.height=e.pixelHeight}startRenderPass(e,t,r,s){let n=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,r,s)}clear(e,t,r,s){let o=this._renderTargetSystem.getGpuRenderTarget(e).context,a=s||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),r){let l=q.shared.setValue(r);l.alpha>0&&(o.globalAlpha=l.alpha,o.fillStyle=l.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,r,s,n){let a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,l=t.source,{context:c}=this._ensureCanvas(l),h=n?.x??0,u=n?.y??0;return c.drawImage(a,r.x,r.y,s.width,s.height,h,u,s.width,s.height),l.update(),t}copyDepthTexture(e,t,r,s,n){G("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Pe.test(t))&&(t=W.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);let r=t.getContext("2d");return{canvas:t,context:r}}}});var ba,f2=f(()=>{P();Oc();p2();ba=class extends si{constructor(e){super(e),this.adaptor=new gh,this.adaptor.init(e,this)}};ba.extension={type:[b.CanvasSystem],name:"renderTarget"}});var _a,m2=f(()=>{we();P();_s();_a=class{constructor(e){}init(){}initSource(e){}generateCanvas(e){let t=W.get().createCanvas(),r=t.getContext("2d"),s=Q.getCanvasSource(e);if(!s)return t;let n=e.frame,o=e.source._resolution??e.source.resolution??1,a=n.x*o,l=n.y*o,c=n.width*o,h=n.height*o;return t.width=Math.ceil(c),t.height=Math.ceil(h),r.drawImage(s,a,l,c,h,0,0,c,h),t}getPixels(e){let t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}};_a.extension={type:[b.CanvasSystem],name:"texture"}});var _2={};Fa(_2,{CanvasRenderer:()=>Wf});var jk,qk,Zk,g2,x2,y2,b2,Wf,v2=f(()=>{P();tp();ip();pT();op();mT();mp();yp();gT();l2();_p();Ps();Bc();ar();u2();d2();f2();m2();jk=[...Hs,xa,ya,_a,ba],qk=[Li,Po,Di,Fi,Oi,ga,da,Gi],Zk=[fT,ua],g2=[],x2=[],y2=[],b2=[];H.handleByNamedList(b.CanvasSystem,g2);H.handleByNamedList(b.CanvasPipes,x2);H.handleByNamedList(b.CanvasPipesAdaptor,y2);H.handleByNamedList(b.CanvasLoader,b2);H.add(...jk,...qk,...Zk);Wf=class extends cr{constructor(){let e={name:"canvas",type:He.CANVAS,systems:g2,renderPipes:x2,renderPipeAdaptors:y2,loaders:b2};super(e)}}});async function T2(i){let e=[];i.preference?Array.isArray(i.preference)?e=i.preference.slice():(e.push(i.preference),S2.forEach(n=>{n!==i.preference&&e.push(n)})):e=S2.slice();let t,r={};for(let n=0;n<e.length;n++){let o=e[n];if(o==="webgpu"&&await bb()){let{WebGPURenderer:a}=await Promise.resolve().then(()=>(nS(),sS));t=a,r={...i,...i.webgpu};break}else if(o==="webgl"&&xb(i.failIfMajorPerformanceCaveat??cr.defaultOptions.failIfMajorPerformanceCaveat)){let{WebGLRenderer:a}=await Promise.resolve().then(()=>(V1(),W1));t=a,r={...i,...i.webgl};break}else if(o==="canvas"){let{CanvasRenderer:a}=await Promise.resolve().then(()=>(v2(),_2));t=a,r={...i,...i.canvasOptions};break}}if(delete r.webgpu,delete r.webgl,delete r.canvasOptions,!t)throw new Error("No available renderer for the current environment");let s=new t;return await s.init(r),s}var S2,w2=f(()=>{yb();_b();Ps();S2=["webgl","webgpu","canvas"]});var va,M2=f(()=>{P();va=class{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,r;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,r=globalThis.innerHeight;else{let{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,r=n}this.renderer.resize(t,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}};va.extension=b.Application});var Sa,C2=f(()=>{P();On();gs();Sa=class{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,rr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?tt.shared:new tt,e.autoStart&&this.start()}static destroy(){if(this._ticker){let e=this._ticker;this.ticker=null,e.destroy()}}};Sa.extension=b.Application});var E2=f(()=>{P();M2();C2();H.add(va);H.add(Sa)});var P2,xh,k2=f(()=>{P();w2();Vt();lp();de();E2();P2=class Vf{constructor(...e){this.stage=new ge,e[0]!==void 0&&B($,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new ge),this.renderer=await T2(e),Vf._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return B($,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){return this.renderer.renderPipes.dom?._domElement}destroy(e=!1,t=!1){let r=Vf._plugins.slice(0);r.reverse(),r.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};P2._plugins=[];xh=P2;H.handleByList(b.Application,xh._plugins);H.add(yo)});var A2,B2,I2=f(()=>{Pi();Yr();ki();de();A2=class R2 extends ht{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(B($,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...R2.defaultOptions,...t};let r=t.positions||new Float32Array([0,0,1,0,1,1,0,1]),s=t.uvs;s||(t.positions?s=new Float32Array(r.length):s=new Float32Array([0,0,1,0,1,1,0,1]));let n=t.indices||new Uint32Array([0,1,2,0,2,3]),o=t.shrinkBuffersToFit,a=new Ye({data:r,label:"attribute-mesh-positions",shrinkToFit:o,usage:se.VERTEX|se.COPY_DST}),l=new Ye({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:se.VERTEX|se.COPY_DST}),c=new Ye({data:n,label:"index-mesh-buffer",shrinkToFit:o,usage:se.INDEX|se.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:8,offset:0},aUV:{buffer:l,format:"float32x2",stride:8,offset:0}},indexBuffer:c,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};A2.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};B2=A2});var yh,G2=f(()=>{"use strict";yh=class{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){this.texture!==e&&(this.texture=e,this._textureMatrixUpdateId=-1)}get uvs(){let t=this.geometry.getBuffer("aUV"),r=t.data,s=r,n=this.texture.textureMatrix;return n.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length<r.length)&&(s=this._transformedUvs=new Float32Array(r.length)),this._textureMatrixUpdateId=n._updateID,this._uvUpdateId=t._updateID,n.multiplyUvs(r,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}});var bh,Ta,F2=f(()=>{P();oe();Xr();Tt();hp();Pc();G2();bh=class{destroy(){}},Ta=class{constructor(e,t){this.localUniforms=new Me({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new qe({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=this._getMeshData(e),r=t.batched,s=e.batched;if(t.batched=s,r!==s)return!0;if(s){let n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;let o=this._getBatchableMesh(e);return o.texture.uid!==e._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,e._texture)}return!1}addRenderable(e,t){let r=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate&&(s.indexSize=e._geometry.indices?.length,s.vertexSize=e._geometry.positions?.length),s.batched){let n=this._getBatchableMesh(e);n.setTexture(e._texture),n.geometry=e._geometry,r.addToBatch(n,t)}else r.break(t),t.add(e)}updateRenderable(e){if(e.batched){let t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;e.state.blend&&(e.state.blendMode=So(e.groupBlendMode,e.texture._source));let t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),Os(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,r;return(t=e._gpuData)[r=this.renderer.uid]||(t[r]=new bh),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,r;return(t=e._gpuData)[r=this.renderer.uid]||(t[r]=new bh),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){let t=new yh;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}};Ta.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"mesh"}});var D2=f(()=>{P();F2();H.add(Ta)});var wa,O2=f(()=>{q0();ki();Kt();ye();de();Nn();I2();D2();wa=class extends ir{constructor(...e){let t=e[0];t instanceof ht&&(B($,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3]&&(B($,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]));let{geometry:r,shader:s,texture:n,roundPixels:o,state:a,...l}=t;super({label:"Mesh",...l}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=n??s?.texture??F.WHITE,this.state=a??ze.for2d(),this._geometry=r,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return B($,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){this._shader!==e&&(this._shader=e,this.onViewUpdate())}get shader(){return this._shader}set geometry(e){this._geometry!==e&&(this._geometry?.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate())}get geometry(){return this._geometry}set texture(e){e||(e=F.EMPTY);let t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=e),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||(this.state.data&12)!==0?!1:this._geometry instanceof B2?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){let{x:t,y:r}=e;if(!this.bounds.containsPoint(t,r))return!1;let s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){let o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){let c=o[l]*2,h=o[l+1]*2,u=o[l+2]*2;if(fd(t,r,s[c],s[c+1],s[h],s[h+1],s[u],s[u+1]))return!0}}else{let o=s.length/2;for(let a=0;a+2<o;a+=n){let l=a*2,c=(a+1)*2,h=(a+2)*2;if(fd(t,r,s[l],s[l+1],s[c],s[c+1],s[h],s[h+1]))return!0}}return!1}destroy(e){if(super.destroy(e),typeof e=="boolean"?e:e?.texture){let r=typeof e=="boolean"?e:e?.textureSource;this._texture.destroy(r)}this._geometry?.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}});function _h(i,e){let t=i[0]??{};return(typeof t=="string"||i[1])&&(B($,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:i[1]}),t}var Zs,$f=f(()=>{bl();de();Nn();Zs=class extends ir{constructor(e,t){let{text:r,resolution:s,style:n,anchor:o,width:a,height:l,roundPixels:c,...h}=e;super({...h}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=r??"",this.style=n,this.resolution=s??null,this.allowChildren=!1,this._anchor=new Le({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=c??!1,a!==void 0&&(this.width=a),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){e||(e={}),this._style?.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){let t=this.bounds.width,r=this.bounds.height,s=-t*this.anchor.x,n=0;return e.x>=s&&e.x<=s+t&&(n=-r*this.anchor.y,e.y>=n&&e.y<=n+r)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){this._style?.off("update",this.onViewUpdate,this),super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e?.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}});function Qk(i,e){Vi||(Vi=W.get().createCanvas(256,128),kr=Vi.getContext("2d",{willReadFrequently:!0}),kr.globalCompositeOperation="copy",kr.globalAlpha=1),(Vi.width<i||Vi.height<e)&&(Vi.width=Sr(i),Vi.height=Sr(e))}function L2(i,e,t){for(let r=0,s=4*t*e;r<e;++r,s+=4)if(i[s+3]!==0)return!1;return!0}function U2(i,e,t,r,s){let n=4*e;for(let o=r,a=r*n+4*t;o<=s;++o,a+=n)if(i[a+3]!==0)return!1;return!0}function N2(...i){let e=i[0];e.canvas||(e={canvas:i[0],resolution:i[1]});let{canvas:t}=e,r=Math.min(e.resolution??1,1),s=e.width??t.width,n=e.height??t.height,o=e.output;if(Qk(s,n),!kr)throw new TypeError("Failed to get canvas 2D context");kr.drawImage(t,0,0,s,n,0,0,s*r,n*r);let l=kr.getImageData(0,0,s,n).data,c=0,h=0,u=s-1,d=n-1;for(;h<n&&L2(l,s,h);)++h;if(h===n)return V.EMPTY;for(;L2(l,s,d);)--d;for(;U2(l,s,c,h,d);)++c;for(;U2(l,s,u,h,d);)--u;return++u,++d,kr.globalCompositeOperation="source-over",kr.strokeRect(c,h,u-c,d-h),kr.globalCompositeOperation="copy",o??(o=new V),o.set(c/r,h/r,(u-c)/r,(d-h)/r),o}var Vi,kr,H2=f(()=>{we();In();Ge();Vi=null,kr=null});function vh(i=1e3,e=0,t=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if(typeof t!="boolean")throw new TypeError("Invalid resetTtl value");return new Xf(i,e,t)}var Xf,Yf=f(()=>{Xf=class{constructor(e=0,t=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=r,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){let t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){let t=new Array(e.length);for(let r=0;r<e.length;r++){let s=e[r];t[r]=[s,this.get(s)]}return t}evict(e=!1){if(e||this.size>0){let t=this.first;delete this.items[t.key],--this.size===0?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){let e=new Array(this.size),t=this.first,r=0;for(;t!==null;)e[r++]=t.key,t=t.next;return e}setWithEvicted(e,t,r=this.resetTtl){let s=null;if(this.has(e))this.set(e,t,!0,r);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return s}set(e,t,r=!1,s=this.resetTtl){let n=this.items[e];return r||n!==void 0?(n.value=t,r===!1&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(e=this.keys()){let t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=this.get(e[r]);return t}}});function Kf(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function jf(i){return i.includes("<")}function Jk(i,e){return i.clone().assign(e)}function z2(i,e){let t=[],r=e.tagStyles;if(!Kf(e)||!jf(i))return t.push({text:i,style:e}),t;let s=[e],n=[],o="",a=0;for(;a<i.length;){let l=i[a];if(l==="<"){let c=i.indexOf(">",a);if(c===-1){o+=l,a++;continue}let h=i.indexOf("<",a+1);if(h!==-1&&h<c){o+=l,a++;continue}let u=i.slice(a+1,c);if(u.startsWith("/")){let d=u.slice(1).trim();if(n.length>0&&n[n.length-1]===d){o.length>0&&(t.push({text:o,style:s[s.length-1]}),o=""),s.pop(),n.pop(),a=c+1;continue}else{o+=i.slice(a,c+1),a=c+1;continue}}else{let d=u.trim();if(r[d]){o.length>0&&(t.push({text:o,style:s[s.length-1]}),o="");let p=s[s.length-1],m=Jk(p,r[d]);s.push(m),n.push(d),a=c+1;continue}else{o+=i.slice(a,c+1),a=c+1;continue}}}else o+=l,a++}return o.length>0&&t.push({text:o,style:s[s.length-1]}),t}var qf=f(()=>{"use strict"});function Qs(i){return typeof i!="string"?!1:tA.has(i.charCodeAt(0))}function it(i,e){return typeof i!="string"?!1:iA.has(i.charCodeAt(0))}function Zf(i){return typeof i!="string"?!1:nA.has(i.charCodeAt(0))}function Qf(i){return typeof i!="string"?!1:aA.has(i.charCodeAt(0))}function Js(i){return i==="normal"||i==="pre-line"}function en(i){return i==="normal"}function Zt(i){if(typeof i!="string")return"";let e=i.length-1;for(;e>=0&&it(i[e]);)e--;return e<i.length-1?i.slice(0,e+1):i}function Sh(i){let e=[],t=[];if(typeof i!="string")return e;for(let r=0;r<i.length;r++){let s=i[r],n=i[r+1];if(it(s,n)||Qs(s)){t.length>0&&(e.push(t.join("")),t.length=0),s==="\r"&&n===`
`?(e.push(`\r
`),r++):e.push(s);continue}t.push(s),Qf(s)&&n&&!it(n)&&!Qs(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function Th(i,e,t,r){let s=t(i),n=[];for(let o=0;o<s.length;o++){let a=s[o],l=a,c=1;for(;s[o+c];){let h=s[o+c];if(!r(l,h,i,o,e))a+=h,l=h,c++;else break}o+=c-1,n.push(a)}return n}var eA,tA,rA,iA,sA,nA,oA,aA,W2,V2,Ma=f(()=>{"use strict";eA=[10,13],tA=new Set(eA),rA=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],iA=new Set(rA),sA=[9,32],nA=new Set(sA),oA=[45,8208,8211,8212,173],aA=new Set(oA),W2=/(\r\n|\r|\n)/,V2=/(?:\r\n|\r|\n)/});function $2(i,e,t,r,s,n,o,a,l){let c=z2(i,e);if(en(e.whiteSpace))for(let z=0;z<c.length;z++){let J=c[z];c[z]={text:J.text.replace(lA," "),style:J.style}}let u=[],d=[];for(let z of c){let J=z.text.split(W2);for(let D=0;D<J.length;D++){let N=J[D];N===`\r
`||N==="\r"||N===`
`?(u.push(d),d=[]):N.length>0&&d.push({text:N,style:z.style})}}(d.length>0||u.length===0)&&u.push(d);let p=t?cA(u,e,r,n,a,l):u,m=[],x=[],y=[],g=[],v=[],_=0,S=e._fontString,T=o(S);T.fontSize===0&&(T.fontSize=e.fontSize,T.ascent=e.fontSize);let w="",E=!!e.dropShadow,R=e._stroke?.width||0;for(let z of p){let J=0,D=T.ascent,N=T.descent,Y="";for(let re of z){let Se=re.style._fontString,Ae=o(Se);Se!==w&&(r.font=Se,w=Se);let pe=s(re.text,re.style.letterSpacing,r);J+=pe,D=Math.max(D,Ae.ascent),N=Math.max(N,Ae.descent),Y+=re.text;let xe=re.style._stroke?.width||0;xe>R&&(R=xe),!E&&re.style.dropShadow&&(E=!0)}z.length===0&&(D=T.ascent,N=T.descent),m.push(J),x.push(D),y.push(N),v.push(Y);let L=e.lineHeight||D+N;g.push(L+e.leading),_=Math.max(_,J)}let k=R,C=_+k+(e.dropShadow?e.dropShadow.distance:0),M=0;for(let z=0;z<g.length;z++)M+=g[z];M=Math.max(M,g[0]+k);let A=M+(e.dropShadow?e.dropShadow.distance:0),U=e.lineHeight||T.fontSize;return{width:C,height:A,lines:v,lineWidths:m,lineHeight:U+e.leading,maxLineWidth:_,fontProperties:T,runsByLine:p,lineAscents:x,lineDescents:y,lineHeights:g,hasDropShadow:E}}function cA(i,e,t,r,s,n){let{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:c}=e,h=Js(a),u=l+o,d={},p="",m=(y,g)=>{let v=`${y}|${g.styleKey}`,_=d[v];if(_===void 0){let S=g._fontString;S!==p&&(t.font=S,p=S),_=r(y,g.letterSpacing,t)+g.letterSpacing,d[v]=_}return _},x=[];for(let y of i){let g=hA(y),v=x.length,_=M=>{let A=0,U=M;do{let{token:z,style:J}=g[U];A+=m(z,J),U++}while(U<g.length&&g[U].continuesFromPrevious);return A},S=M=>{let A=[],U=M;do A.push({token:g[U].token,style:g[U].style}),U++;while(U<g.length&&g[U].continuesFromPrevious);return A},T=[],w=0,E=!h,R=null,k=()=>{R&&R.text.length>0&&T.push(R),R=null},C=()=>{if(k(),T.length>0){let M=T[T.length-1];M.text=Zt(M.text),M.text.length===0&&T.pop()}x.push(T),T=[],w=0,E=!1};for(let M=0;M<g.length;M++){let{token:A,style:U,continuesFromPrevious:z}=g[M],J=m(A,U);if(h){let Y=it(A),L=R?.text[R.text.length-1]??T[T.length-1]?.text.slice(-1)??"",re=L?it(L):!1;if(Y&&re)continue}let D=!z,N=D?_(M):J;if(N>u&&D)if(w>0&&C(),c){let Y=S(M);for(let L=0;L<Y.length;L++){let re=Y[L].token,Se=Y[L].style,Ae=Th(re,c,n,s);for(let pe of Ae){let xe=m(pe,Se);xe+w>u&&C(),!R||R.style!==Se?(k(),R={text:pe,style:Se}):R.text+=pe,w+=xe}}M+=Y.length-1}else{let Y=S(M);k(),x.push(Y.map(L=>({text:L.token,style:L.style}))),E=!1,M+=Y.length-1}else if(N+w>u&&D){if(it(A)){E=!1;continue}C(),R={text:A,style:U},w=J}else if(z&&!c)!R||R.style!==U?(k(),R={text:A,style:U}):R.text+=A,w+=J;else{let Y=it(A);if(w===0&&Y&&!E)continue;!R||R.style!==U?(k(),R={text:A,style:U}):R.text+=A,w+=J}}if(k(),T.length>0){let M=T[T.length-1];M.text=Zt(M.text),M.text.length===0&&T.pop()}(T.length>0||x.length===v)&&x.push(T)}return x}function hA(i){let e=[],t=!1;for(let r of i){let s=Sh(r.text),n=!0;for(let o of s){let a=it(o)||Qs(o),l=n&&t&&!a;e.push({token:o,style:r.style,continuesFromPrevious:l}),t=!a,n=!1}}return e}var lA,X2=f(()=>{qf();Ma();lA=/\r\n|\r|\n/g});function Y2(i,e,t,r,s){let n=t[i];return typeof n!="number"&&(n=s(i,e,r)+e,t[i]=n),n}function K2(i,e,t,r,s,n,o){let a=t.getContext("2d",uA);a.font=e._fontString;let l=0,c="",h=[],u=Object.create(null),{letterSpacing:d,whiteSpace:p}=e,m=Js(p),x=en(p),y=!m,g=e.wordWrapWidth+d,v=Sh(i);for(let S=0;S<v.length;S++){let T=v[S];if(Qs(T)){if(!x){h.push(Zt(c)),y=!m,c="",l=0;continue}T=" "}if(m){let E=it(T),R=it(c[c.length-1]);if(E&&R)continue}let w=Y2(T,d,u,a,r);if(w>g)if(c!==""&&(h.push(Zt(c)),c="",l=0),s(T,e.breakWords)){let E=Th(T,e.breakWords,o,n);for(let R of E){let k=Y2(R,d,u,a,r);k+l>g&&(h.push(Zt(c)),y=!1,c="",l=0),c+=R,l+=k}}else c.length>0&&(h.push(Zt(c)),c="",l=0),h.push(Zt(T)),y=!1,c="",l=0;else w+l>g&&(y=!1,h.push(Zt(c)),c="",l=0),(c.length>0||!it(T)||y)&&(c+=T,l+=w)}let _=Zt(c);return _.length>0&&h.push(_),h.join(`
`)}var uA,j2=f(()=>{Ma();uA={willReadFrequently:!0}});var q2,Ar,Ze,tn=f(()=>{Yf();we();X2();qf();Ma();j2();q2={willReadFrequently:!0},Ar=class X{static get experimentalLetterSpacingSupported(){let e=X._experimentalLetterSpacingSupported;if(e===void 0){let t=W.get().getCanvasRenderingContext2D().prototype;e=X._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,r,s,n,o,a,l,c,h){this.text=e,this.style=t,this.width=r,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=c,h&&(this.runsByLine=h.runsByLine,this.lineAscents=h.lineAscents,this.lineDescents=h.lineDescents,this.lineHeights=h.lineHeights,this.hasDropShadow=h.hasDropShadow)}static measureText(e=" ",t,r=X._canvas,s=t.wordWrap){let n=`${e}-${t.styleKey}-wordWrap-${s}`;if(X._measurementCache.has(n))return X._measurementCache.get(n);if(Kf(t)&&jf(e)){let S=$2(e,t,s,X._context,X._measureText,X._measureTextAdvance,X.measureFont,X.canBreakChars,X.wordWrapSplit),T=new X(e,t,S.width,S.height,S.lines,S.lineWidths,S.lineHeight,S.maxLineWidth,S.fontProperties,{runsByLine:S.runsByLine,lineAscents:S.lineAscents,lineDescents:S.lineDescents,lineHeights:S.lineHeights,hasDropShadow:S.hasDropShadow});return X._measurementCache.set(n,T),T}let a=t._fontString,l=X.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);let c=X._context;c.font=a;let u=(s?X._wordWrap(e,t,r):e).split(V2),d=new Array(u.length),p=0;for(let S=0;S<u.length;S++){let T=X._measureText(u[S],t.letterSpacing,c);d[S]=T,p=Math.max(p,T)}let m=t._stroke?.width??0,x=t.lineHeight||l.fontSize,y=X._adjustWidthForStyle(p,t),g=Math.max(x,l.fontSize+m)+(u.length-1)*(x+t.leading),v=X._adjustHeightForStyle(g,t),_=new X(e,t,y,v,u,d,x+t.leading,p,l);return X._measurementCache.set(n,_),_}static _adjustWidthForStyle(e,t){let r=t._stroke?.width||0,s=e+r;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _adjustHeightForStyle(e,t){let r=e;return t.dropShadow&&(r+=t.dropShadow.distance),r}static _measureText(e,t,r){let{metricWidth:s,metrics:n,letterSpacingVal:o}=X._measureTextCore(e,t,r),a=-(n.actualBoundingBoxLeft??0),c=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(c+=o),Math.max(s,c)}static _measureTextAdvance(e,t,r){return X._measureTextCore(e,t,r).metricWidth}static _measureTextCore(e,t,r){let s=!1;X.experimentalLetterSpacingSupported&&(X.experimentalLetterSpacing?(r.letterSpacing=`${t}px`,r.textLetterSpacing=`${t}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(e),o=n.width,a=0;return o>0&&(s?a=-t:a=(X.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,r=X._canvas){return K2(e,t,r,X._measureTextAdvance,X.canBreakWords,X.canBreakChars,X.wordWrapSplit)}static isBreakingSpace(e,t){return it(e,t)}static canBreakWords(e,t){return t}static canBreakChars(e,t,r,s,n){return!0}static wordWrapSplit(e){return X.graphemeSegmenter(e)}static measureFont(e){if(X._fonts[e])return X._fonts[e];let t=X._context;t.font=e;let r=t.measureText(X.METRICS_STRING+X.BASELINE_SYMBOL),s=r.actualBoundingBoxAscent??0,n=r.actualBoundingBoxDescent??0,o={ascent:s,descent:n,fontSize:s+n};return X._fonts[e]=o,o}static clearMetrics(e=""){e?delete X._fonts[e]:X._fonts={}}static get _canvas(){if(!X.__canvas){let e;try{let t=new OffscreenCanvas(0,0);if(t.getContext("2d",q2)?.measureText)return X.__canvas=t,t;e=W.get().createCanvas()}catch{e=W.get().createCanvas()}e.width=e.height=10,X.__canvas=e}return X.__canvas}static get _context(){return X.__context||(X.__context=X._canvas.getContext("2d",q2)),X.__context}};Ar.METRICS_STRING="|\xC9q\xC5";Ar.BASELINE_SYMBOL="M";Ar.BASELINE_MULTIPLIER=1.4;Ar.HEIGHT_MULTIPLIER=2;Ar.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){let i=new Intl.Segmenter;return e=>{let t=i.segment(e),r=[],s=0;for(let n of t)r[s++]=n.segment;return r}}return i=>[...i]})();Ar.experimentalLetterSpacing=!1;Ar._fonts={};Ar._measurementCache=vh(1e3);Ze=Ar});function ai(i){let e=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize,t=i.fontFamily;Array.isArray(i.fontFamily)||(t=i.fontFamily.split(","));for(let r=t.length-1;r>=0;r--){let s=t[r].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!dA.includes(s)&&(s=`"${s}"`),t[r]=s}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${e} ${t.join(",")}`}var dA,wh=f(()=>{"use strict";dA=["serif","sans-serif","monospace","cursive","fantasy","system-ui"]});function li(i,e,t,r=0,s=0,n=0){if(i.texture===F.WHITE&&!i.fill)return q.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof jt){let o=i.fill,a=e.createPattern(o.texture.source.resource,"repeat");return Q.applyPatternTransform(a,o.transform,!1),a}else if(i.fill instanceof ot){let o=i.fill,a=o.type==="linear",l=o.textureSpace==="local",c=1,h=1;l&&t&&(c=t.width+r,h=t.height+r);let u,d=!1;if(a){let{start:p,end:m}=o;u=e.createLinearGradient(p.x*c+s,p.y*h+n,m.x*c+s,m.y*h+n),d=Math.abs(m.x-p.x)<Math.abs((m.y-p.y)*.1)}else{let{center:p,innerRadius:m,outerCenter:x,outerRadius:y}=o;u=e.createRadialGradient(p.x*c+s,p.y*h+n,m*c,x.x*c+s,x.y*h+n,y*c)}if(d&&l&&t){let p=t.lineHeight/h;for(let m=0;m<t.lines.length;m++){let x=(m*t.lineHeight+r/2)/h;o.colorStops.forEach(y=>{let g=x+y.offset*p;g=Math.max(0,Math.min(1,g)),u.addColorStop(Math.floor(g*Z2)/Z2,q.shared.setValue(y.color).toHex())})}}else o.colorStops.forEach(p=>{u.addColorStop(p.offset,q.shared.setValue(p.color).toHex())});return u}}else{let o=e.createPattern(i.texture.source.resource,"repeat"),a=i.matrix.copyTo(I.shared);return a.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),o.setTransform(a),o}return G("FillStyle not recognised",i),"red"}var Z2,Jf=f(()=>{Je();oe();_s();ye();ie();Ni();ha();Z2=1e5});function rn(i){let e=0;for(let t=0;t<i.length;t++)i.charCodeAt(t)===32&&e++;return e}var Q2,em,ci,tm=f(()=>{Je();Ge();vs();H2();tn();wh();Jf();Q2=new V;em=class{getCanvasAndContext(e){let{text:t,style:r,resolution:s=1}=e,n=r._getFinalPadding(),o=Ze.measureText(t||" ",r),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),c=ct.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(r,n,s,c,o);let h=r.trim?N2({canvas:c.canvas,width:a,height:l,resolution:1,output:Q2}):Q2.set(0,0,a,l);return{canvasAndContext:c,frame:h}}returnCanvasAndContext(e){ct.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,r,s,n){if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,r,s);return}let{canvas:o,context:a}=s,l=ai(e),c=n.lines,h=n.lineHeight,u=n.lineWidths,d=n.maxLineWidth,p=n.fontProperties,m=o.height;if(a.resetTransform(),a.scale(r,r),a.textBaseline=e.textBaseline,e._stroke?.width){let T=e._stroke;a.lineWidth=T.width,a.miterLimit=T.miterLimit,a.lineJoin=T.join,a.lineCap=T.cap}a.font=l;let x,y,g=e.dropShadow?2:1,_=(e._stroke?.width??0)/2,S=(h-p.fontSize)/2;h-p.fontSize<0&&(S=0);for(let T=0;T<g;++T){let w=e.dropShadow&&T===0,E=w?Math.ceil(Math.max(1,m)+t*2):0,R=E*r;if(w)this._setupDropShadow(a,e,r,R);else{let k=e._gradientBounds,C=e._gradientOffset;if(k){let M={width:k.width,height:k.height,lineHeight:k.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,M,t,_,C?.x??0,C?.y??0)}else C?this._setFillAndStrokeStyles(a,e,n,t,_,C.x,C.y):this._setFillAndStrokeStyles(a,e,n,t,_);a.shadowColor="rgba(0,0,0,0)"}for(let k=0;k<c.length;k++){x=_,y=_+k*h+p.ascent+S,x+=this._getAlignmentOffset(u[k],d,e.align);let C=0;if(e.align==="justify"&&e.wordWrap&&k<c.length-1){let M=rn(c[k]);M>0&&(C=(d-u[k])/M)}e._stroke?.width&&this._drawLetterSpacing(c[k],e,s,x+t,y+t-E,!0,C),e._fill!==void 0&&this._drawLetterSpacing(c[k],e,s,x+t,y+t-E,!1,C)}}}_renderTaggedTextToCanvas(e,t,r,s,n){let{canvas:o,context:a}=n,{runsByLine:l,lineWidths:c,maxLineWidth:h,lineAscents:u,lineHeights:d,hasDropShadow:p}=e,m=o.height;a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline;let x=p?2:1,y=t._stroke?.width??0;for(let _ of l)for(let S of _){let T=S.style._stroke?.width??0;T>y&&(y=T)}let g=y/2,v=[];for(let _=0;_<l.length;_++){let S=l[_],T=[];for(let w of S){let E=ai(w.style);a.font=E,T.push({width:Ze._measureText(w.text,w.style.letterSpacing,a),font:E})}v.push(T)}for(let _=0;_<x;++_){let S=p&&_===0,T=S?Math.ceil(Math.max(1,m)+r*2):0,w=T*s;S||(a.shadowColor="rgba(0,0,0,0)");let E=g;for(let R=0;R<l.length;R++){let k=l[R],C=c[R],M=u[R],A=d[R],U=v[R],z=g;z+=this._getAlignmentOffset(C,h,t.align);let J=0;if(t.align==="justify"&&t.wordWrap&&R<l.length-1){let Y=0;for(let L of k)Y+=rn(L.text);Y>0&&(J=(h-C)/Y)}let D=E+M,N=z+r;for(let Y=0;Y<k.length;Y++){let L=k[Y],{width:re,font:Se}=U[Y];if(a.font=Se,a.textBaseline=L.style.textBaseline,L.style._stroke?.width){let pe=L.style._stroke;if(a.lineWidth=pe.width,a.miterLimit=pe.miterLimit,a.lineJoin=pe.join,a.lineCap=pe.cap,S)if(L.style.dropShadow)this._setupDropShadow(a,L.style,s,w);else{let xe=rn(L.text);N+=re+xe*J;continue}else{let xe=Ze.measureFont(Se),Z=L.style.lineHeight||xe.fontSize,Lt={width:re,height:Z,lineHeight:Z,lines:[L.text]};a.strokeStyle=li(pe,a,Lt,r*2,N-r,E)}this._drawLetterSpacing(L.text,L.style,n,N,D+r-T,!0,J)}let Ae=rn(L.text);N+=re+Ae*J}N=z+r;for(let Y=0;Y<k.length;Y++){let L=k[Y],{width:re,font:Se}=U[Y];if(a.font=Se,a.textBaseline=L.style.textBaseline,L.style._fill!==void 0){if(S)if(L.style.dropShadow)this._setupDropShadow(a,L.style,s,w);else{let pe=rn(L.text);N+=re+pe*J;continue}else{let pe=Ze.measureFont(Se),xe=L.style.lineHeight||pe.fontSize,Z={width:re,height:xe,lineHeight:xe,lines:[L.text]};a.fillStyle=li(L.style._fill,a,Z,r*2,N-r,E)}this._drawLetterSpacing(L.text,L.style,n,N,D+r-T,!1,J)}let Ae=rn(L.text);N+=re+Ae*J}E+=A}}}_setFillAndStrokeStyles(e,t,r,s,n,o=0,a=0){if(e.fillStyle=t._fill?li(t._fill,e,r,s*2,o,a):null,t._stroke?.width){let l=n+s*2;e.strokeStyle=li(t._stroke,e,r,l,o,a)}}_setupDropShadow(e,t,r,s){e.fillStyle="black",e.strokeStyle="black";let n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=q.shared.setValue(o).setAlpha(a).toRgbaString();let l=n.blur*r,c=n.distance*r;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*c,e.shadowOffsetY=Math.sin(n.angle)*c+s}_getAlignmentOffset(e,t,r){return r==="right"?t-e:r==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,r,s,n,o=!1,a=0){let{context:l}=r,c=t.letterSpacing,h=!1;if(Ze.experimentalLetterSpacingSupported&&(Ze.experimentalLetterSpacing?(l.letterSpacing=`${c}px`,l.textLetterSpacing=`${c}px`,h=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(c===0||h)&&a===0){o?l.strokeText(e,s,n):l.fillText(e,s,n);return}if(a!==0&&(c===0||h)){let x=e.split(" "),y=s,g=l.measureText(" ").width;for(let v=0;v<x.length;v++)o?l.strokeText(x[v],y,n):l.fillText(x[v],y,n),y+=l.measureText(x[v]).width+g+a;return}let u=s,d=Ze.graphemeSegmenter(e),p=l.measureText(e).width,m=0;for(let x=0;x<d.length;++x){let y=d[x];o?l.strokeText(y,u,n):l.fillText(y,u,n);let g="";for(let v=x+1;v<d.length;++v)g+=d[v];m=l.measureText(g).width,u+=p-m+c,y===" "&&(u+=a),p=m}}},ci=new em});function pA(i){let e=i;if(typeof e.dropShadow=="boolean"&&e.dropShadow){let t=Et.defaultDropShadow;i.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){B($,"strokeThickness is now a part of stroke");let t=e.stroke,r={};if(q.isColorLike(t))r.color=t;else if(t instanceof ot||t instanceof jt)r.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))r=t;else throw new Error("Invalid stroke value.");i.stroke={...r,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(B($,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&G("The number of fill colors must match the number of fill gradient stops.");let t=new ot({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),r=e.fillGradientStops.slice(),s=e.fill.map(n=>q.shared.setValue(n).toNumber());r.forEach((n,o)=>{t.addColorStop(n,s[o])}),i.fill={fill:t}}}var rm,Et,sn=f(()=>{Oe();Je();Ue();de();ie();Ni();ha();Of();Ff();wh();rm=class $i extends le{constructor(e={}){super(),this.uid=K("textStyle"),this._tick=0,this._cachedFontString=null,pA(e),e instanceof $i&&(e=e._toObject());let s={...$i.defaultTextStyle,...e};for(let n in s){let o=n;this[o]=s[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...$i.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...$i.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Ct.defaultFillStyle,...e},()=>{this._fill=Pr({...this._originalFill},Ct.defaultFillStyle)})),this._fill=Pr(e===0?"black":e,Ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ct.defaultStrokeStyle,...e},()=>{this._stroke=qs({...this._originalStroke},Ct.defaultStrokeStyle)})),this._stroke=qs(e,Ct.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){let e=$i.defaultTextStyle;for(let t in e)this[t]=e[t]}assign(e){for(let t in e){let r=t;this[r]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=ai(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new $i(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){let r=typeof e=="boolean"?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(r),this._originalFill?.texture&&this._originalFill.texture.destroy(r),this._stroke?.texture&&this._stroke.texture.destroy(r),this._originalStroke?.texture&&this._originalStroke.texture.destroy(r)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(r,s,n)=>(r[s]===n||(r[s]=n,t?.(s,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(q.isColorLike(e)||e instanceof ot||e instanceof jt)}};rm.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};rm.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};Et=rm});function ew(i){if(J2)return;let e=new dt({scaleMode:i.scaleMode});i._resourceId!==e._resourceId&&(J2=!0,G("Text textureStyle: only scaleMode is applied to a text texture, the other fields are ignored"))}var J2,tw=f(()=>{us();ie();J2=!1});function rw(i,e){let{texture:t,bounds:r}=i,s=e._style._getFinalPadding();Nl(r,e._anchor,t);let n=e._anchor._x*s*2,o=e._anchor._y*s*2;r.minX-=s-n,r.minY-=s-o,r.maxX-=s-n,r.maxY-=s-o}var iw=f(()=>{id()});var Mh,sw=f(()=>{_c();Mh=class extends Jr{}});var Ca,nw=f(()=>{P();Dt();iw();sw();Ca=class{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),e.runners.contextChange.add(this),this._managedTexts=new Ee({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(let e in this._managedTexts.items){let t=this._managedTexts.items[e];t?._autoResolution&&t.onViewUpdate()}}contextChange(){for(let e in this._managedTexts.items)this._managedTexts.items[e]?.unload()}validateRenderable(e){let t=this._getGpuText(e),r=e.styleKey;return t.currentKey!==r?!0:e._didTextUpdate}addRenderable(e,t){let r=this._getGpuText(e);if(e._didTextUpdate||r.currentKey!==e.styleKey){let s=e._autoResolution?this._renderer.resolution:e.resolution;(r.currentKey!==e.styleKey||e._resolution!==s)&&this._updateGpuText(e),e._didTextUpdate=!1,rw(r,e)}this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){let t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){let t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){let t=new Mh;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){let t=e._gpuData[this._renderer.uid];if(!t)return;let{canvasText:r}=this._renderer;r.getReferenceCount(t.currentKey)>0?r.decreaseReferenceCount(t.currentKey):t.texture&&r.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}};Ca.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"text"}});var nn,im=f(()=>{wr();de();tm();sn();gd();nn=class{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,r,s){typeof e=="string"&&(B("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:r,resolution:t}),e.style instanceof Et||(e.style=new Et(e.style)),typeof e.text!="string"&&(e.text=e.text.toString());let{text:n,style:o,textureStyle:a,autoGenerateMipmaps:l}=e,c=e.resolution??this._renderer.resolution,{frame:h,canvasAndContext:u}=ci.getCanvasAndContext({text:n,style:o,resolution:c}),d=tc(u.canvas,h.width,h.height,c,l,a?.scaleMode);if(o.trim&&(h.pad(o.padding),d.frame.copyFrom(h),d.frame.scale(1/c),d.updateUvs()),o.filters){let p=this._applyFilters(d,o.filters);return this.returnTexture(d),ci.returnCanvasAndContext(u),p}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||ci.returnCanvasAndContext(u),d}returnTexture(e){let t=e.source,r=t.resource;if(this._retainCanvasContext&&r?.getContext){let s=r.getContext("2d");s&&ci.returnCanvasAndContext({canvas:r,context:s})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",ce.returnTexture(e)}renderTextToCanvas(){B("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;let t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;let r=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[t]={texture:r,usageCount:1},r}decreaseReferenceCount(e){let t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){return this._activeTextures[e]?.usageCount??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){let r=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind({target:r,clear:!1}),s}destroy(){this._renderer=null;for(let e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}});var Ea,ow=f(()=>{P();im();Ea=class extends nn{constructor(e){super(e,!0)}};Ea.extension={type:[b.CanvasSystem],name:"canvasText"}});var Pa,aw=f(()=>{P();im();Pa=class extends nn{constructor(e){super(e,!1)}};Pa.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"canvasText"}});var lw=f(()=>{P();nw();ow();aw();H.add(Ea);H.add(Pa);H.add(Ca)});var ka,cw=f(()=>{et();us();$f();tm();tn();sn();tw();lw();ka=class extends Zs{constructor(...e){let t=_h(e,"Text");super(t,Et),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof dt?t.textureStyle:new dt(t.textureStyle),ew(this.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??te.defaultOptions.autoGenerateMipmaps}updateBounds(){let e=this._bounds,t=this._anchor,r=0,s=0;if(this._style.trim){let{frame:n,canvasAndContext:o}=ci.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ci.returnCanvasAndContext(o),r=n.width,s=n.height}else{let n=Ze.measureText(this._text,this._style);r=n.width,s=n.height}e.minX=-t._x*r,e.maxX=e.minX+r,e.minY=-t._y*s,e.maxY=e.minY+s}}});var Ch,hw=f(()=>{Oe();de();Ch=class extends le{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return B($,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return B($,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return B($,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return B($,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return B($,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners();for(let t in this.chars)this.chars[t].texture?.destroy();this.chars=null,e&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}});var uw,sm,pw=f(()=>{Je();Ge();vs();Vl();ye();us();de();tn();wh();Jf();sn();hw();uw=class dw extends Ch{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;let t={...dw.defaultOptions,...e};this._textureSize=t.textureSize,this._mipmap=t.mipmap;let r=t.style.clone();t.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=F.WHITE,r._fill.fill=null),this.applyFillAsTint=t.overrideFill;let s=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let n=ai(r);t.overrideSize?(r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/s),r.dropShadow&&(r.dropShadow.blur*=this.baseRenderedFontSize/s,r.dropShadow.distance*=this.baseRenderedFontSize/s)):r.fontSize=this.baseRenderedFontSize=s,this._style=r,this._skipKerning=t.skipKerning??!1,this.resolution=t.resolution??1,this._padding=t.padding??4,t.textureStyle&&(this._textureStyle=t.textureStyle instanceof dt?t.textureStyle:new dt(t.textureStyle)),this.fontMetrics=Ze.measureFont(n),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(e){let t=Ze.graphemeSegmenter(e).filter(g=>!this._currentChars.includes(g)).filter((g,v,_)=>_.indexOf(g)===v);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let r;this._currentPageIndex===-1?r=this._nextPage():r=this.pages[this._currentPageIndex];let{canvas:s,context:n}=r.canvasAndContext,o=r.texture.source,a=this._style,l=this._currentX,c=this._currentY,h=this._currentMaxCharHeight,u=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=(a.dropShadow?.distance??0)+(a._stroke?.width??0),p=this._padding+d,m=!1,x=s.width/this.resolution,y=s.height/this.resolution;for(let g=0;g<t.length;g++){let v=t[g],_=Ze.measureText(v,a,s,!1);_.lineHeight=_.height;let S=_.width*u,T=Math.ceil((a.fontStyle==="italic"?2:1)*S),w=_.height*u,E=T+p*2,R=w+p*2;if(m=!1,v!==`
`&&v!=="\r"&&v!=="	"&&v!==" "&&(m=!0,h=Math.ceil(Math.max(R,h))),l+E>x&&(c+=h,h=R,l=0,c+h>y)){o.update();let C=this._nextPage();s=C.canvasAndContext.canvas,n=C.canvasAndContext.context,o=C.texture.source,l=0,c=0,h=0}let k=n.measureText(v).width/u;if(this.chars[v]={id:v.codePointAt(0),xOffset:-(p/u),yOffset:-(p/u),xAdvance:k,kerning:{}},m){this._drawGlyph(n,_,l+p,c+p,u,a);let C=o.width*u,M=o.height*u,A=new V(l/C*o.width,c/M*o.height,E/C*o.width,R/M*o.height);this.chars[v].texture=new F({source:o,frame:A}),l+=Math.ceil(E)}}o.update(),this._currentX=l,this._currentY=c,this._currentMaxCharHeight=h,this._skipKerning||this._applyKerning(t,n,u)}get pageTextures(){return B($,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(e,t,r){let s=this._measureCache;for(let n=0;n<e.length;n++){let o=e[n];for(let a=0;a<this._currentChars.length;a++){let l=this._currentChars[a],c=s[o];c||(c=s[o]=t.measureText(o).width);let h=s[l];h||(h=s[l]=t.measureText(l).width);let u=t.measureText(o+l).width,d=u-(c+h);d&&this.chars[o]&&(this.chars[o].kerning[l]=d/r),u=t.measureText(o+l).width,d=u-(c+h),d&&this.chars[l]&&(this.chars[l].kerning[o]=d/r)}}}_nextPage(){this._currentPageIndex++;let e=this.resolution,t=ct.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);let r=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new F({source:new or({resource:t.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);let n={canvasAndContext:t,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(e,t,r){t.fontSize=this.baseRenderedFontSize,e.scale(r,r),e.font=ai(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;let s=t._stroke,n=s?.width??0;if(s&&(e.lineWidth=n,e.lineJoin=s.join,e.miterLimit=s.miterLimit,e.strokeStyle=li(s,e)),t._fill&&(e.fillStyle=li(t._fill,e)),t.dropShadow){let o=t.dropShadow,a=q.shared.setValue(o.color).toArray(),l=o.blur*r,c=o.distance*r;e.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,e.shadowBlur=l,e.shadowOffsetX=Math.cos(o.angle)*c,e.shadowOffsetY=Math.sin(o.angle)*c}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,r,s,n,o){let a=t.text,l=t.fontProperties,h=(o._stroke?.width??0)*n,u=r+h/2,d=s-h/2,p=l.descent*n,m=t.lineHeight*n,x=!1;o.stroke&&h&&(x=!0,e.strokeText(a,u,d+m-p));let{shadowBlur:y,shadowOffsetX:g,shadowOffsetY:v}=e;o._fill&&(x&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.fillText(a,u,d+m-p)),x&&(e.shadowBlur=y,e.shadowOffsetX=g,e.shadowOffsetY=v)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{canvasAndContext:t,texture:r}=this.pages[e];ct.returnCanvasAndContext(t),r.destroy(!0)}this.pages=null}};uw.defaultOptions={textureSize:512,style:new Et,mipmap:!0};sm=uw});function Eh(i,e,t,r){let s={width:0,height:0,offsetY:0,scale:e.fontSize/t.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=t.baseLineOffset;let n=s.lines[0],o=null,a=!0,l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=t.baseMeasurementFontSize/e.fontSize,h=e.letterSpacing*c,u=e.wordWrapWidth*c,d=e.lineHeight?e.lineHeight*c:t.lineHeight,p=e.wordWrap&&e.breakWords,m=Js(e.whiteSpace),x=en(e.whiteSpace);if(m||x){let _=[],S=m;for(let T=0;T<i.length;T++){let w=i[T];if(w==="\r"||w===`
`)if(x)w==="\r"&&i[T+1]===`
`&&T++,w=" ";else{m&&(S=!0),_.push(w);continue}if(it(w))if(m&&Zf(w)){if(S)continue;S=!0,_.push(" ")}else S=!1,_.push(w);else S=!1,_.push(w)}i=_}let y=_=>{let S=n.width;for(let T=0;T<l.index;T++){let w=_.positions[T];n.chars.push(_.chars[T]),n.charPositions.push(w+S)}n.width+=_.width,(l.index>0||!m)&&(a=!1),l.width=0,l.index=0,l.chars.length=0},g=()=>{let _=n.chars.length-1;if(r){let S=n.chars[_];for(;Zf(S);)n.width-=t.chars[S].xAdvance,n.spacesIndex.pop(),S=n.chars[--_]}s.width=Math.max(s.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(n),s.height+=d},v=_=>_-h>u;for(let _=0;_<i.length+1;_++){let S,T=_===i.length;T||(S=i[_]);let w=t.chars[S];if(/(?:\s)/.test(S)||S==="\r"||S===`
`||T){if(!a&&e.wordWrap&&v(n.width+l.width)?(g(),y(l),!T&&w&&n.charPositions.push(0)):(l.start=n.width,y(l),!T&&w&&n.charPositions.push(0)),S==="\r"||S===`
`)g();else if(!T&&w){let C=w.xAdvance+(w.kerning?.[o]||0)+h;n.width+=C,n.spaceWidth=C,n.spacesIndex.push(n.charPositions.length),n.chars.push(S)}}else if(w){let k=w.kerning?.[o]||0,C=w.xAdvance+k+h;p&&v(l.width+C)&&(a||g(),y(l),g()),l.positions[l.index++]=l.width+k,l.chars.push(S),l.width+=C,Qf(S)&&(!a&&e.wordWrap&&v(n.width+l.width)&&g(),y(l))}o=S}return g(),e.align==="center"?fA(s):e.align==="right"?mA(s):e.align==="justify"&&gA(s),s}function fA(i){for(let e=0;e<i.lines.length;e++){let t=i.lines[e],r=i.width/2-t.width/2;for(let s=0;s<t.charPositions.length;s++)t.charPositions[s]+=r}}function mA(i){for(let e=0;e<i.lines.length;e++){let t=i.lines[e],r=i.width-t.width;for(let s=0;s<t.charPositions.length;s++)t.charPositions[s]+=r}}function gA(i){let e=i.width;for(let t=0;t<i.lines.length-2;t++){let r=i.lines[t],s=0,n=r.spacesIndex[s++],o=0,a=r.spacesIndex.length,c=(e-r.width)/a;for(let h=0;h<r.charPositions.length;h++)h===n&&(n=r.spacesIndex[s++],o+=c),r.charPositions[h]+=o}}var nm=f(()=>{Ma()});function fw(i){if(i==="")return[];typeof i=="string"&&(i=[i]);let e=[];for(let t=0,r=i.length;t<r;t++){let s=i[t];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(s[0].length===0||s[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");let n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...Array.from(s))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}var mw=f(()=>{"use strict"});var Ph,om,kh,am=f(()=>{Yf();Xl();de();ie();tn();sn();pw();nm();mw();Ph=0,om=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=vh(1e3)}getFont(e,t){let r=`${t.fontFamily}-bitmap`,s=!0;if($e.has(r)){let o=$e.get(r);return o.ensureCharacters?.(e),o}if(t._fill.fill&&!t._stroke?(r+=t._fill.fill.styleKey,s=!1):(t._stroke||t.dropShadow)&&(r=`${t.styleKey}-bitmap`,s=!1),r+=`-${t.fontStyle}`,r+=`-${t.fontVariant}`,r+=`-${t.fontWeight}`,!$e.has(r)){let o=Object.create(t);o._lineHeight=0;let a=new sm({style:o,overrideFill:s,overrideSize:!0,...this.defaultOptions});Ph++,Ph>50&&G("BitmapText",`You have dynamically created ${Ph} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{Ph--,$e.remove(r)}),$e.set(r,a)}let n=$e.get(r);return n.ensureCharacters?.(e),n}getLayout(e,t,r=!0){let s=this.getFont(e,t),n=`${e}-${t.styleKey}-${r}`;if(this.measureCache.has(n))return this.measureCache.get(n);let o=Ze.graphemeSegmenter(e),a=Eh(o,t,s,r);return this.measureCache.set(n,a),a}measureText(e,t,r=!0){return this.getLayout(e,t,r)}install(...e){let t=e[0];typeof t=="string"&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},B($,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));let r=t?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};let s=t.style,n=s instanceof Et?s:new Et(s),o=t.dynamicFill??this._canUseTintForStyle(n),a=new sm({style:n,overrideFill:o,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1,textureStyle:t.textureStyle}),l=fw(t.chars);return a.ensureCharacters(l.join("")),$e.set(`${r}-bitmap`,a),a.once("destroy",()=>$e.remove(`${r}-bitmap`)),a}uninstall(e){let t=`${e}-bitmap`,r=$e.get(t);r&&r.destroy()}_canUseTintForStyle(e){return!e._stroke&&(!e.dropShadow||e.dropShadow.color===0)&&!e._fill.fill&&e._fill.color===16777215}},kh=new om});function gw(i,e){e.groupTransform=i.groupTransform,e.groupColorAlpha=i.groupColorAlpha,e.groupColor=i.groupColor,e.groupBlendMode=i.groupBlendMode,e.globalDisplayStatus=i.globalDisplayStatus,e.groupTransform=i.groupTransform,e.localDisplayStatus=i.localDisplayStatus,e.groupAlpha=i.groupAlpha,e._roundPixels=i._roundPixels}var lm,on,cm=f(()=>{Xl();Dt();mh();tn();am();nm();lm=class extends pt{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}},on=class{constructor(e){this._renderer=e,this._managedBitmapTexts=new Ee({renderer:e,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(e){let t=this._getGpuBitmapText(e);return this._renderer.renderPipes.graphics.validateRenderable(t)}addRenderable(e,t){let r=this._getGpuBitmapText(e);gw(e,r),e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,r)),this._renderer.renderPipes.graphics.addRenderable(r,t),r.context.customShader&&this._updateDistanceField(e)}updateRenderable(e){let t=this._getGpuBitmapText(e);gw(e,t),this._renderer.renderPipes.graphics.updateRenderable(t),t.context.customShader&&this._updateDistanceField(e)}_updateContext(e,t){let{context:r}=t,s=kh.getFont(e.text,e._style);if(r.clear(),s.distanceField.type!=="none"){let g=this.getSdfShader();g&&(r.customShader||(r.customShader=g))}let n=Ze.graphemeSegmenter(e.text),o=e._style,a=s.baseLineOffset,l=Eh(n,o,s,!0),c=o.padding,h=l.scale,u=l.width,d=l.height+l.offsetY;o._stroke&&(u+=o._stroke.width/h,d+=o._stroke.width/h),r.translate(-e._anchor._x*u-c,-e._anchor._y*d-c).scale(h,h);let p=s.applyFillAsTint?o._fill.color:16777215,m=s.fontMetrics.fontSize,x=s.lineHeight;o.lineHeight&&(m=o.fontSize/h,x=o.lineHeight/h);let y=(x-m)/2;y-s.baseLineOffset<0&&(y=0);for(let g=0;g<l.lines.length;g++){let v=l.lines[g];for(let _=0;_<v.charPositions.length;_++){let S=v.chars[_],T=s.chars[S];if(T?.texture){let w=T.texture;r.texture(w,p,Math.round(v.charPositions[_]+T.xOffset),Math.round(a+T.yOffset+y),w.orig.width,w.orig.height)}}a+=x}}_getGpuBitmapText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){let t=new lm;return e._gpuData[this._renderer.uid]=t,this._updateContext(e,t),this._managedBitmapTexts.add(e),t}_updateDistanceField(e){let t=this._getGpuBitmapText(e).context,r=e._style.fontFamily,s=$e.get(`${r}-bitmap`),{a:n,b:o,c:a,d:l}=e.groupTransform,c=Math.sqrt(n*n+o*o),h=Math.sqrt(a*a+l*l),u=(Math.abs(c)+Math.abs(h))/2,d=s.baseRenderedFontSize/e._style.fontSize,p=u*s.distanceField.range*(1/d);t.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){this._managedBitmapTexts.destroy(),this._renderer=null,this._managedBitmapTexts=null}}});var Aa,xw=f(()=>{P();cm();Aa=class extends on{getSdfShader(){return null}};Aa.extension={type:[b.CanvasPipes],name:"bitmapText"}});var yw,bw,_w=f(()=>{"use strict";yw={name:"local-uniform-msdf-bit",vertex:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32,
                uRound:f32,
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `},fragment:{header:`
            struct LocalUniforms {
                uColor:vec4<f32>,
                uTransformMatrix:mat3x3<f32>,
                uDistance: f32
            }

            @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
         `,main:`
            outColor = vec4<f32>(calculateMSDFAlpha(outColor, vColor, localUniforms.uDistance));
        `}},bw={name:"local-uniform-msdf-bit",vertex:{header:`
            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix *= uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `},fragment:{header:`
            uniform float uDistance;
         `,main:`
            outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
        `}}});var vw,Sw,Tw=f(()=>{"use strict";vw={name:"msdf-bit",fragment:{header:`
            fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {

                // MSDF
                var median = msdfColor.r + msdfColor.g + msdfColor.b -
                    min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                    max(msdfColor.r, max(msdfColor.g, msdfColor.b));

                // SDF
                median = min(median, msdfColor.a);

                var screenPxDistance = distance * (median - 0.5);
                var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
                var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
                var coverage: f32 = pow(shapeColor.a * alpha, gamma);

                return coverage;

            }
        `}},Sw={name:"msdf-bit",fragment:{header:`
            float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {

                // MSDF
                float median = msdfColor.r + msdfColor.g + msdfColor.b -
                                min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
                                max(msdfColor.r, max(msdfColor.g, msdfColor.b));

                // SDF
                median = min(median, msdfColor.a);

                float screenPxDistance = distance * (median - 0.5);
                float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);

                if (median < 0.01) {
                    alpha = 0.0;
                } else if (median > 0.99) {
                    alpha = 1.0;
                }

                // Gamma correction for coverage-like alpha
                float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
                float gamma = mix(1.0, 1.0 / 2.2, luma);
                float coverage = pow(shapeColor.a * alpha, gamma);

                return coverage;
            }
        `}}});var hm,um,Ah,ww=f(()=>{oe();Bi();ao();lo();Ii();Mc();lr();Tt();_w();Tw();Ah=class extends De{constructor(e){let t=new Me({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});hm??(hm=jr({name:"sdf-shader",bits:[As,Bs(e),yw,vw,Zr]})),um??(um=qr({name:"sdf-shader",bits:[Rs,Is(e),bw,Sw,Qr]})),super({glProgram:um,gpuProgram:hm,resources:{localUniforms:t,batchSamplers:Ds(e)}})}}});var Ra,Mw=f(()=>{P();ww();cm();Ra=class extends on{getSdfShader(){return new Ah(this._renderer.limits.maxBatchableTextures)}};Ra.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:"bitmapText"}});var Cw=f(()=>{P();xw();Mw();H.add(Aa);H.add(Ra)});var Ba,Ew=f(()=>{ie();$f();sn();am();Cw();Ba=class extends Zs{constructor(...e){var t;let r=_h(e,"BitmapText");r.style??(r.style=r.style||{}),(t=r.style).fill??(t.fill=16777215),super(r,Et),this.renderPipeId="bitmapText"}_onTouch(e){this._gcLastUsed=e;for(let t in this._gpuData)this._gpuData[t]?._onTouch(e)}updateBounds(){let e=this._bounds,t=this._anchor,r=kh.measureText(this.text,this._style),s=r.scale,n=r.offsetY*s,o=r.width*s,a=r.height*s,l=this._style._stroke;l&&(o+=l.width,a+=l.width),e.minX=-t._x*o,e.maxX=e.minX+o,e.minY=-t._y*(a+n),e.maxY=e.minY+a}set resolution(e){e!==null&&G("[BitmapText] dynamically updating the resolution is not supported. Resolution should be managed by the BitmapFont.")}get resolution(){return this._resolution}}});var hi=f(()=>{Qy();tb();P();Yl();Ul();k2();ac();Ge();$r();Ei();ki();lr();Vr();ye();wr();cd();Vt();mh();O2();Hl();Ew();cw();Oe();de();H.add(Zy,eb)});var Pw,kw=f(()=>{"use strict";Pw={shake:1,flash:1,reducedMotion:!1,contrast:!1}});var Rw,Aw=f(()=>{Rw=`in vec2 aPosition;
out vec2 vWorld;

uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform mat3 uTransformMatrix;

uniform vec4 uRect; // world-space x, y, w, h of the quad

void main() {
    mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
    gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
    vWorld = uRect.xy + aPosition * uRect.zw;
}
`});var Iw,Bw=f(()=>{Iw=`// Top-down canyon at golden hour. Everything is computed per pixel from the
// wall edges (packed into uData, one row per 4 world units) and ground noise.
// Sun is low at the lower-left: shadows fall up and to the right.

in vec2 vWorld;
out vec4 finalColor;

uniform sampler2D uData;
uniform float uRowTop;
uniform float uRowStep;
uniform float uRows;
uniform float uDist;      // ground distance, wrapped to PERIOD
uniform float uViewH;
uniform vec3 uSun;        // sector light: sunlit multiplier
uniform vec3 uShadowTint; // sector light: shadow colour
uniform float uShadowLen; // sector light: shadow length scale

const float PERIOD = 4096.0;
const vec2 SUN = vec2(-0.862, 0.507);

// ---------------------------------------------------------------- data
float decode16(vec2 hiLo) {
    vec2 b = floor(hiLo * 255.0 + 0.5);
    return (b.x * 256.0 + b.y) / 65535.0 * 2048.0 - 512.0;
}

vec3 rowAt(float r) {
    float v = (clamp(r, 0.0, uRows - 1.0) + 0.5) / uRows;
    vec4 a = texture(uData, vec2(0.25, v));
    vec4 b = texture(uData, vec2(0.75, v));
    return vec3(decode16(a.rg), decode16(b.rg), a.b);
}

// left, right, height at world row y (linearly interpolated between rows)
vec3 walls(float y) {
    float r = (y - uRowTop) / uRowStep - 0.5;
    float r0 = floor(r);
    return mix(rowAt(r0), rowAt(r0 + 1.0), r - r0);
}

// ---------------------------------------------------------------- noise (periodic in y so the wrap is seamless)
float hash(vec2 p) {
    p = fract(p * vec2(123.34, 456.21));
    p += dot(p, p + 45.32);
    return fract(p.x * p.y);
}

float vnoise(vec2 p, float period) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    float y0 = mod(i.y, period), y1 = mod(i.y + 1.0, period);
    float a = hash(vec2(i.x, y0)), b = hash(vec2(i.x + 1.0, y0));
    float c = hash(vec2(i.x, y1)), d = hash(vec2(i.x + 1.0, y1));
    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}

// scale must divide PERIOD
float fbm(vec2 g, float scale) {
    vec2 p = g / scale;
    float period = PERIOD / scale;
    float s = 0.0, amp = 0.5;
    for (int k = 0; k < 4; k++) {
        s += amp * vnoise(p, period);
        p *= 2.0;
        period *= 2.0;
        amp *= 0.5;
    }
    return s;
}

// ---------------------------------------------------------------- palette
const vec3 SAND_DEEP  = vec3(0.478, 0.227, 0.110);
const vec3 SAND_MID   = vec3(0.690, 0.376, 0.180);
const vec3 SAND_LIGHT = vec3(0.851, 0.541, 0.310);
const vec3 SAND_HOT   = vec3(0.937, 0.698, 0.478);
const vec3 ROCK_DARK  = vec3(0.227, 0.110, 0.063);
const vec3 ROCK_MID   = vec3(0.353, 0.165, 0.094);
const vec3 ROCK_LIGHT = vec3(0.490, 0.247, 0.133);
const vec3 ROCK_TAN   = vec3(0.612, 0.290, 0.149);
const vec3 SHADOW     = vec3(0.290, 0.215, 0.420);
const vec3 VIOLET     = vec3(0.165, 0.094, 0.220);
const vec3 RIM        = vec3(1.000, 0.811, 0.541);

vec3 floorColor(vec2 g, float x, float L, float R) {
    float n = fbm(g, 64.0);
    vec3 col = mix(SAND_MID, SAND_LIGHT, smoothstep(0.25, 0.75, n));

    // wind ripples: contour lines of stretched noise
    float rip = fbm(vec2(g.x * 1.6, g.y * 0.55), 32.0);
    float lines = abs(fract(rip * 7.0) - 0.5);
    col *= 0.97 + 0.04 * smoothstep(0.02, 0.3, lines);

    // dry riverbed meandering down the middle
    float mid = 0.5 * (L + R);
    float wander = (fbm(vec2(7.0, g.y), 256.0) - 0.5) * (R - L) * 0.7;
    float cw = 6.0 + 10.0 * fbm(vec2(3.0, g.y), 128.0);
    float ch = 1.0 - smoothstep(cw * 0.6, cw, abs(x - (mid + wander)));
    float mud = fbm(g, 8.0);
    vec3 bed = mix(SAND_DEEP, SAND_MID, smoothstep(0.3, 0.7, mud)) * (0.92 + 0.12 * smoothstep(0.4, 0.6, fract(mud * 3.0)));
    col = mix(col, bed, ch * 0.6);

    // scattered pebbles with a lit lower-left edge
    vec2 cell = floor(g / 7.0);
    vec2 cellY = vec2(cell.x, mod(cell.y, PERIOD / 7.0));
    float h = hash(cellY);
    if (h > 0.93) {
        vec2 c = (cell + 0.25 + 0.5 * vec2(hash(cellY + 3.1), hash(cellY + 7.7))) * 7.0;
        float d = length(g - c);
        float pr = 0.8 + 1.4 * hash(cellY + 1.3);
        if (d < pr) {
            float lit = dot(normalize(g - c + 0.001), vec2(SUN.x, -SUN.y));
            col = mix(col, mix(ROCK_MID, SAND_HOT, 0.5 + 0.5 * lit), 0.8);
        }
    }
    return col;
}

vec3 mesaColor(vec2 g, float e, float H, vec2 normal, bool sunFacing) {
    float faceW = 6.0 + 14.0 * H;
    float lambert = max(dot(normal, SUN), 0.0);

    if (e < faceW) {
        // cliff face seen from above: strata run parallel to the edge
        float t = e / faceW; // 0 at base, 1 at the lip
        float wob = (vnoise(vec2(e * 0.1, g.y / 24.0), PERIOD / 24.0) - 0.5) * 2.2;
        float band = fract(t * (3.0 + 3.0 * H) + wob * 0.3);
        vec3 strata = band < 0.33 ? ROCK_TAN : band < 0.66 ? ROCK_LIGHT : ROCK_MID;
        strata *= 0.85 + 0.3 * fbm(vec2(g.x * 0.5, g.y * 2.0), 16.0);
        vec3 lit = strata * (0.45 + 1.15 * lambert) + RIM * 0.35 * pow(lambert, 3.0) * t;
        vec3 shade = mix(strata * 0.35, SHADOW * 0.55, 0.55);
        vec3 col = mix(shade, lit, smoothstep(0.05, 0.35, lambert));
        col *= mix(0.55, 1.0, smoothstep(0.0, 0.5, t)); // base occlusion
        // lip highlight
        float lip = smoothstep(0.8, 1.0, t) * (1.0 - smoothstep(0.97, 1.0, t));
        col += RIM * lip * (sunFacing ? 0.55 : 0.12);
        return col;
    }

    // mesa top
    float n = fbm(g, 128.0);
    vec3 col = mix(ROCK_DARK, ROCK_LIGHT, smoothstep(0.2, 0.8, n));
    float crack = abs(fbm(g * 1.3, 32.0) - 0.5);
    col *= 0.75 + 0.25 * smoothstep(0.0, 0.035, crack);
    // sparse desert scrub: small round dark tufts
    vec2 sc = floor(g / 8.0);
    vec2 scY = vec2(sc.x, mod(sc.y, PERIOD / 8.0));
    if (hash(scY) > 0.9) {
        vec2 c = (sc + 0.3 + 0.4 * vec2(hash(scY + 2.3), hash(scY + 5.1))) * 8.0;
        float r = 0.8 + 1.2 * hash(scY + 9.7);
        col = mix(col, vec3(0.16, 0.13, 0.07), 0.7 * (1.0 - smoothstep(r * 0.6, r, length(g - c))));
    }
    col *= 0.72 + 0.25 * fbm(g, 512.0);
    // haze into the distance away from the corridor so the eye stays in the canyon
    float far = smoothstep(faceW + 30.0, faceW + 320.0, e);
    return mix(col, VIOLET, far * 0.55);
}

void main() {
    float x = vWorld.x;
    float y = vWorld.y;
    vec3 w = walls(y);
    vec3 wn = walls(y + 4.0);
    float L = w.x, R = w.y, H = w.z;
    vec2 g = vec2(x, uDist + uViewH - y);

    vec3 col;
    if (x >= L && x <= R) {
        col = floorColor(g, x, L, R);

        // long raking shadow from the west wall, sampled from a row nearer the sun
        vec3 ws = walls(y + 30.0);
        float edge = ws.x + (18.0 + 120.0 * ws.z * ws.z) * uShadowLen;
        edge += (vnoise(vec2(0.0, g.y / 16.0), PERIOD / 16.0) - 0.5) * 12.0;
        float shadow = 1.0 - smoothstep(edge - 7.0, edge + 7.0, x);

        vec3 lit = col * uSun;
        vec3 shaded = col * uShadowTint * 1.35 + vec3(0.05, 0.02, 0.0) * smoothstep(L, R, x); // warm bounce from the lit east wall
        col = mix(lit, shaded, shadow);

        // occlusion at the wall bases
        float ao = smoothstep(0.0, 16.0, x - L) * smoothstep(0.0, 12.0, R - x);
        col *= mix(0.55, 1.0, ao);
    } else if (x < L) {
        vec2 n = normalize(vec2(1.0, -(wn.x - L) / 4.0));
        col = mesaColor(g, L - x, H, n, false) * mix(vec3(1.0), uSun, 0.7);
    } else {
        vec2 n = normalize(vec2(-1.0, (wn.y - R) / 4.0));
        col = mesaColor(g, x - R, H, n, true) * mix(vec3(1.0), uSun, 0.7);
    }

    finalColor = vec4(col, 1.0);
}
`});function Gw(i){return Math.max(0,Math.min(65535,Math.round((i-bA)/_A*65535)))}var dm,Rh,bA,_A,pm,Bh,Fw=f(()=>{"use strict";hi();At();Aw();Bw();dm=4,Rh=72,bA=-512,_A=2048,pm=4096,Bh=class{mesh;data;dctx;img;tex;rows=0;uniforms;c={left:0,right:0};constructor(){this.data=document.createElement("canvas"),this.data.width=2,this.data.height=1,this.dctx=this.data.getContext("2d",{willReadFrequently:!0}),this.img=this.dctx.createImageData(2,1),this.tex=F.from(this.data);let e=new ht({attributes:{aPosition:new Float32Array([0,0,1,0,1,1,0,1])},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),t=De.from({gl:{vertex:Rw,fragment:Iw,name:"terrain"},resources:{terrainUniforms:{uRect:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uRowTop:{value:0,type:"f32"},uRowStep:{value:dm,type:"f32"},uRows:{value:1,type:"f32"},uDist:{value:0,type:"f32"},uViewH:{value:j,type:"f32"},uSun:{value:new Float32Array([1.08,1,.92]),type:"vec3<f32>"},uShadowTint:{value:new Float32Array([.29,.215,.42]),type:"vec3<f32>"},uShadowLen:{value:1,type:"f32"}},uData:this.tex.source}});this.uniforms=t.resources.terrainUniforms.uniforms,this.mesh=new wa({geometry:e,shader:t})}setLight(e,t,r){this.uniforms.uSun.set(e),this.uniforms.uShadowTint.set(t),this.uniforms.uShadowLen=r}update(e,t,r){let s=r.x-Rh,n=r.y-Rh,o=r.w+Rh*2,a=r.h+Rh*2;this.mesh.position.set(s,n),this.mesh.scale.set(o,a);let l=this.uniforms.uRect;l[0]=s,l[1]=n,l[2]=o,l[3]=a;let c=n-48,h=Math.ceil((a+96)/dm)+2;h!==this.rows&&(this.rows=h,this.data.height=h,this.tex.source.resize(2,h),this.img=this.dctx.createImageData(2,h));let u=this.img.data;for(let d=0;d<h;d++){let p=c+(d+.5)*dm,m=t+(j-p);e.at(m,this.c);let x=Gw(this.c.left),y=Gw(this.c.right),g=d*8;u[g]=x>>8,u[g+1]=x&255,u[g+2]=Math.round(e.height(m)*255),u[g+3]=255,u[g+4]=y>>8,u[g+5]=y&255,u[g+6]=0,u[g+7]=255}this.dctx.putImageData(this.img,0,0),this.tex.source.update(),this.uniforms.uRowTop=c,this.uniforms.uRows=h,this.uniforms.uDist=(t%pm+pm)%pm}}});function vA(i,e){let t=document.createElement("canvas");t.width=Math.ceil(i*Xi),t.height=Math.ceil(e*Xi);let r=t.getContext("2d");return r.scale(Xi,Xi),[t,r]}function ft(i){return new F({source:new Pe({resource:i,resolution:Xi})})}function Qt(i,e,t){let[r,s]=vA(i,e);return t(s,i,e),r}function SA(i){let e=document.createElement("canvas");e.width=i.width,e.height=i.height;let t=e.getContext("2d");return t.drawImage(i,0,0),t.globalCompositeOperation="source-in",t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),e}function TA(i,e=1.6){let t=Math.ceil(e*Xi*3),r=document.createElement("canvas");r.width=i.width+t*2,r.height=i.height+t*2;let s=r.getContext("2d");return s.filter=`blur(${e*Xi}px)`,s.drawImage(i,t,t),s.filter="none",s.globalCompositeOperation="source-in",s.fillStyle="#000000",s.fillRect(0,0,r.width,r.height),r}function Pt(i,e,t,r,s){let n=i.createLinearGradient(e,t*.6,t,-t*.2);return n.addColorStop(0,r),n.addColorStop(1,s),n}function ke(i,e,t,r=1.6){let s=Qt(i,e,t);return{tex:ft(s),white:ft(SA(s)),shadow:ft(TA(s,r))}}function Ow(i,e,t){let r=e/2;i.lineJoin="round",i.fillStyle=Pt(i,r-3,r+3,fm,Ih),i.beginPath(),i.moveTo(r-1.8,18),i.lineTo(r+1.8,18),i.lineTo(r+1.1,t-4),i.lineTo(r-1.1,t-4),i.closePath(),i.fill(),i.beginPath(),i.roundRect(r-5.5,t-8,11,2.6,1),i.fill(),i.fillStyle=Ih,i.fillRect(r+.6,t-5.5,1.2,4),i.fillStyle=Pt(i,r-10,r+10,fm,Ih),i.beginPath(),i.roundRect(r-10,15,20,3.4,1),i.fill();for(let o of[-1,1]){let a=r+o*9.5,l=i.createLinearGradient(a-1.8,0,a+1.8,0);l.addColorStop(0,o<0?"#6e5038":"#3a2a20"),l.addColorStop(1,"#181216"),i.fillStyle=l,i.beginPath(),i.roundRect(a-1.8,12.6,3.6,8.2,1.6),i.fill(),i.fillStyle="#0d0a0c";for(let c=0;c<3;c++)i.beginPath(),i.arc(a-.9+c*.9,13.4,.35,0,Math.PI*2),i.fill()}i.fillStyle="#2a201c";for(let o of[-1,1])i.fillRect(r+o*6-.8,13.5,1.6,6);let s=i.createLinearGradient(r-4.5,0,r+4.5,0);s.addColorStop(0,fm),s.addColorStop(.35,wA),s.addColorStop(1,Ih),i.fillStyle=s,i.beginPath(),i.moveTo(r,1.5),i.bezierCurveTo(r+3.6,2.5,r+4.4,7,r+4.2,13),i.bezierCurveTo(r+4,18,r+2.6,21,r+1.8,22),i.lineTo(r-1.8,22),i.bezierCurveTo(r-2.6,21,r-4,18,r-4.2,13),i.bezierCurveTo(r-4.4,7,r-3.6,2.5,r,1.5),i.fill(),i.fillStyle="#2a1f1c";for(let o of[-1,1])i.beginPath(),i.roundRect(r+o*3.4-1.3,12,2.6,6.5,1.2),i.fill();i.fillStyle="#120d10";for(let o of[-1,1])i.fillRect(r+o*3.4-.7,17.6,1.4,1);let n=i.createLinearGradient(r-2.5,3,r+2.5,10);n.addColorStop(0,"#ffd9a0"),n.addColorStop(.25,"#6a4a52"),n.addColorStop(1,"#141020"),i.fillStyle=n,i.beginPath(),i.ellipse(r,5.2,2.1,2.6,0,0,Math.PI*2),i.fill(),i.beginPath(),i.ellipse(r,9.4,2.4,2.4,0,0,Math.PI*2),i.fill(),i.strokeStyle="#100c10",i.lineWidth=.35,i.beginPath(),i.moveTo(r-2.3,7.3),i.lineTo(r+2.3,7.3),i.stroke(),i.fillStyle="#100c0e",i.beginPath(),i.arc(r,2.6,1,0,Math.PI*2),i.fill(),i.fillRect(r-.3,-.5,.6,2.5),i.strokeStyle=Rr,i.globalAlpha=.85,i.lineWidth=.55,i.beginPath(),i.moveTo(r-.5,1.7),i.bezierCurveTo(r-3.6,2.5,r-4.4,7,r-4.2,13),i.bezierCurveTo(r-4,18,r-2.6,21,r-1.8,22),i.stroke(),i.beginPath(),i.moveTo(r-10,18.2),i.lineTo(r-4,18.2),i.stroke(),i.beginPath(),i.moveTo(r-1.7,18.5),i.lineTo(r-1.1,t-4),i.stroke(),i.globalAlpha=1}function MA(i,e){let t=e/2,r=e/2-.5,s=i.createRadialGradient(t,t,0,t,t,r);s.addColorStop(0,"rgba(40,30,30,0.05)"),s.addColorStop(.85,"rgba(60,45,40,0.13)"),s.addColorStop(1,"rgba(255,207,138,0.18)"),i.fillStyle=s,i.beginPath(),i.arc(t,t,r,0,Math.PI*2),i.fill();for(let n of[0,Math.PI]){for(let o=0;o<14;o++){let a=n-o*.045;i.strokeStyle=`rgba(20,14,16,${(.5*(1-o/14)).toFixed(3)})`,i.lineWidth=1.1,i.beginPath(),i.moveTo(t+Math.cos(a)*2,t+Math.sin(a)*2),i.lineTo(t+Math.cos(a)*r,t+Math.sin(a)*r),i.stroke()}i.strokeStyle="rgba(255,207,138,0.5)",i.lineWidth=.6,i.beginPath(),i.arc(t,t,r-.6,n-.5,n),i.stroke()}i.fillStyle="#1a1214",i.beginPath(),i.arc(t,t,1.6,0,Math.PI*2),i.fill()}function CA(i,e){let t=e/2;i.strokeStyle=Lw,i.lineWidth=2,i.lineCap="round",i.beginPath(),i.moveTo(5,5),i.lineTo(e-5,e-5),i.moveTo(e-5,5),i.lineTo(5,e-5),i.stroke();for(let[r,s]of[[5,5],[e-5,5],[5,e-5],[e-5,e-5]]){let n=i.createRadialGradient(r,s,0,r,s,4.6);n.addColorStop(0,"rgba(30,20,20,0.7)"),n.addColorStop(.7,"rgba(60,40,36,0.35)"),n.addColorStop(1,"rgba(255,190,130,0.35)"),i.fillStyle=n,i.beginPath(),i.arc(r,s,4.6,0,Math.PI*2),i.fill()}i.fillStyle=Pt(i,t-5,t+5,gm,Gh),i.beginPath(),i.roundRect(t-4.5,t-4.5,9,9,2.5),i.fill(),i.strokeStyle="#d9502f",i.lineWidth=.6,i.stroke(),i.strokeStyle=Rr,i.globalAlpha=.7,i.lineWidth=.5,i.beginPath(),i.moveTo(t-4.3,t-2),i.lineTo(t-4.3,t+4.3),i.lineTo(t+2,t+4.3),i.stroke(),i.globalAlpha=1,i.fillStyle=Uw,i.beginPath(),i.arc(t,t+1.5,1.4,0,Math.PI*2),i.fill()}function EA(i,e,t){let r=e/2;i.fillStyle=Pt(i,0,e,gm,Gh),i.beginPath(),i.moveTo(r,t-1),i.lineTo(e-1,5),i.lineTo(r+3,7),i.lineTo(r,2),i.lineTo(r-3,7),i.lineTo(1,5),i.closePath(),i.fill(),i.strokeStyle="#d9502f",i.lineWidth=.6,i.stroke(),i.fillStyle=Gh,i.fillRect(r-4,2,1.2,5),i.fillRect(r+2.8,2,1.2,5),i.fillStyle="#4a3430",i.beginPath(),i.roundRect(r-1.6,4,3.2,t-8,1.5),i.fill(),i.strokeStyle=Rr,i.globalAlpha=.8,i.lineWidth=.6,i.beginPath(),i.moveTo(1.3,5.4),i.lineTo(r-.4,t-1.5),i.stroke(),i.globalAlpha=1,i.fillStyle=Uw,i.beginPath(),i.arc(r,t-6,1.3,0,Math.PI*2),i.fill()}function PA(i,e){let t=e/2,r=e/2-4;i.fillStyle="#2a1e1c";for(let n=0;n<8;n++){let o=n/8*Math.PI*2;i.beginPath(),i.moveTo(t+Math.cos(o-.22)*r,t+Math.sin(o-.22)*r),i.lineTo(t+Math.cos(o)*(r+3.6),t+Math.sin(o)*(r+3.6)),i.lineTo(t+Math.cos(o+.22)*r,t+Math.sin(o+.22)*r),i.fill()}let s=i.createRadialGradient(t-r*.4,t+r*.4,.5,t,t,r);s.addColorStop(0,"#9a6a4a"),s.addColorStop(.4,"#4a3028"),s.addColorStop(1,"#120a10"),i.fillStyle=s,i.beginPath(),i.arc(t,t,r,0,Math.PI*2),i.fill(),i.strokeStyle="#d9502f",i.lineWidth=.5,i.beginPath(),i.arc(t,t,r*.55,0,Math.PI*2),i.stroke()}function Ia(i){return(e,t)=>{let r=t/2,s=8,n=8;e.strokeStyle="rgba(40,30,25,0.8)",e.lineWidth=.35;for(let u of[r-4,r-1.5,r+1.5,r+4])e.beginPath(),e.moveTo(u,s),e.lineTo(r+(u-r)*.5,19),e.stroke();for(let u=0;u<8;u++)e.fillStyle=u%2===0?"#e8763a":"#f4e2c4",e.beginPath(),e.moveTo(r,s),e.arc(r,s,n,u/8*Math.PI*2,(u+1)/8*Math.PI*2),e.closePath(),e.fill();let o=e.createRadialGradient(r-3,s+3,1,r,s,n);o.addColorStop(0,"rgba(255,230,190,0.25)"),o.addColorStop(1,"rgba(40,20,40,0.45)"),e.fillStyle=o,e.beginPath(),e.arc(r,s,n,0,Math.PI*2),e.fill();let a=r-5,l=18;e.fillStyle=Pt(e,a,a+10,"#9a7040","#3a2818"),e.fillRect(a,l,10,10),e.strokeStyle="#1c1208",e.lineWidth=.5,e.strokeRect(a+.25,l+.25,9.5,9.5),e.strokeStyle=Rr,e.globalAlpha=.7,e.beginPath(),e.moveTo(a+.3,l+.5),e.lineTo(a+.3,l+9.7),e.lineTo(a+9.5,l+9.7),e.stroke(),e.globalAlpha=1,e.fillStyle="#ffc36b",e.strokeStyle="#ffc36b";let c=r,h=l+5;if(i==="fuel")e.beginPath(),e.roundRect(c-2.4,h-3,4.8,6,.8),e.fill(),e.fillStyle="#3a2818",e.fillRect(c-1.4,h-1.2,2.8,.7),e.fillRect(c-1.4,h+.4,2.8,.7);else if(i==="shield")e.beginPath(),e.moveTo(c,h-3.2),e.lineTo(c+2.8,h-2),e.lineTo(c+2.4,h+1),e.lineTo(c,h+3.2),e.lineTo(c-2.4,h+1),e.lineTo(c-2.8,h-2),e.closePath(),e.fill();else if(i==="flare"){for(let u=0;u<8;u++){let d=u/8*Math.PI*2;e.fillRect(c+Math.cos(d)*1.2-.4,h+Math.sin(d)*1.2-.4,Math.cos(d)*2.2+.8,Math.sin(d)*2.2+.8)}e.beginPath(),e.arc(c,h,1.3,0,Math.PI*2),e.fill()}else if(i==="spread"){e.lineWidth=.9;for(let u of[-.45,0,.45])e.beginPath(),e.moveTo(c,h+3),e.lineTo(c+Math.sin(u)*4,h+3-Math.cos(u)*6),e.stroke()}else e.fillRect(c-.8,h-2,1.6,4.6),e.beginPath(),e.moveTo(c-.8,h-2),e.lineTo(c,h-3.4),e.lineTo(c+.8,h-2),e.fill(),e.fillRect(c-2,h+1.6,4,1)}}function kA(i,e,t){let r=e/2;i.fillStyle="#d8c8b0",i.beginPath(),i.roundRect(r-1,1.5,2,t-3,1),i.fill(),i.fillStyle="#2a2020",i.beginPath(),i.moveTo(r-1,1.6),i.lineTo(r,0),i.lineTo(r+1,1.6),i.fill(),i.fillRect(r-2.2,t-3.5,4.4,1.2),i.fillStyle="#ffcf8a",i.fillRect(r-1,2,.5,t-5)}function AA(i,e){let t=e/2;i.fillStyle=Pt(i,0,e,"#6a4a3a","#140c12"),i.beginPath();for(let r=0;r<6;r++){let s=r/6*Math.PI*2+Math.PI/6,n=t+Math.cos(s)*(e/2-.5),o=t+Math.sin(s)*(e/2-.5);r===0?i.moveTo(n,o):i.lineTo(n,o)}i.closePath(),i.fill(),i.strokeStyle="#f0a44c",i.lineWidth=.6,i.stroke(),i.fillStyle="#ffc36b",i.beginPath(),i.arc(t,t,1.8,0,Math.PI*2),i.fill()}function RA(i,e,t){let r=e/2,s=t/2;i.strokeStyle=Lw,i.lineWidth=2.4,i.beginPath(),i.moveTo(4,s),i.lineTo(e-4,s),i.stroke();for(let n of[5.5,e-5.5]){let o=i.createRadialGradient(n,s,0,n,s,5.5);o.addColorStop(0,"rgba(30,20,20,0.75)"),o.addColorStop(.7,"rgba(60,40,36,0.35)"),o.addColorStop(1,"rgba(255,190,130,0.4)"),i.fillStyle=o,i.beginPath(),i.arc(n,s,5.5,0,Math.PI*2),i.fill()}i.fillStyle=Pt(i,r-6,r+6,gm,Gh),i.beginPath(),i.roundRect(r-5.5,s-6,11,12,3),i.fill(),i.strokeStyle="#d9502f",i.lineWidth=.6,i.stroke(),i.fillStyle="#120c10",i.fillRect(r-3.4,s+4,1.6,5),i.fillRect(r+1.8,s+4,1.6,5),i.strokeStyle=Rr,i.globalAlpha=.7,i.lineWidth=.5,i.beginPath(),i.moveTo(r-5.3,s-3),i.lineTo(r-5.3,s+5.8),i.lineTo(r+1,s+5.8),i.stroke(),i.globalAlpha=1}function xm(i,e){let t=e/2,r=e/2-.5;i.fillStyle=Pt(i,0,e,"#6a5040","#1c1418"),i.beginPath();for(let s=0;s<8;s++){let n=s/8*Math.PI*2+Math.PI/8;s===0?i.moveTo(t+Math.cos(n)*r,t+Math.sin(n)*r):i.lineTo(t+Math.cos(n)*r,t+Math.sin(n)*r)}i.closePath(),i.fill(),i.strokeStyle="#120c0e",i.lineWidth=.5,i.stroke(),i.fillStyle="#d9502f";for(let s=0;s<4;s++){let n=s/4*Math.PI*2+Math.PI/4;i.beginPath(),i.arc(t+Math.cos(n)*r*.7,t+Math.sin(n)*r*.7,.6,0,Math.PI*2),i.fill()}}function BA(i,e){let t=e/2;for(let r=0;r<12;r++){let s=r/12*Math.PI*2,n=t+Math.cos(s)*(e/2-2.6),o=t+Math.sin(s)*(e/2-2.6),a=Math.cos(s-2.6)*.5+.5;i.fillStyle=`rgb(${Math.round(90+a*70)},${Math.round(70+a*50)},${Math.round(50+a*30)})`,i.beginPath(),i.ellipse(n,o,2.6,1.7,s+Math.PI/2,0,Math.PI*2),i.fill(),i.strokeStyle="rgba(20,12,10,0.6)",i.lineWidth=.3,i.stroke()}i.fillStyle="#2a201c",i.beginPath(),i.arc(t,t,e/2-5,0,Math.PI*2),i.fill()}function mm(i,e,t=!1){return(r,s,n)=>{let o=n/2;r.fillStyle="#2a2020",r.beginPath(),r.arc(2.5,o,e+1.2,0,Math.PI*2),r.fill();let a=t?[-e*.9,e*.9]:[0];for(let l of a){let c=r.createLinearGradient(0,o+l-e/2,0,o+l+e/2);c.addColorStop(0,"#1a1214"),c.addColorStop(1,"#6a5244"),r.fillStyle=c,r.fillRect(2,o+l-e/2,i,e),r.fillStyle="#0a0608",r.fillRect(2+i-1,o+l-e/2,1,e)}}}function IA(i,e){xm(i,e);let t=e/2;for(let r of[-4.5,-1.5,1.5,4.5])i.fillStyle="#3a3030",i.fillRect(t-5,t+r-1.2,11,2.4),i.fillStyle="#e8dccc",i.fillRect(t+5,t+r-.9,2,1.8),i.fillStyle="#d9502f",i.fillRect(t+6.4,t+r-.9,.7,1.8)}function GA(i,e,t){i.fillStyle="#1a1414",i.fillRect(.5,1,4,t-2),i.fillRect(e-4.5,1,4,t-2),i.fillStyle="#3a3030";for(let r=2;r<t-2;r+=2)i.fillRect(.8,r,3.4,.6),i.fillRect(e-4.2,r,3.4,.6);i.fillStyle=Pt(i,4,e-4,"#7a6040","#2a2018"),i.beginPath(),i.roundRect(3.5,2,e-7,t-4,1.5),i.fill(),i.strokeStyle="#120c0a",i.lineWidth=.4,i.stroke(),i.strokeStyle=Rr,i.globalAlpha=.6,i.lineWidth=.5,i.beginPath(),i.moveTo(3.8,3),i.lineTo(3.8,t-2.5),i.stroke(),i.globalAlpha=1,i.fillStyle="#1a1210";for(let r=0;r<3;r++)i.fillRect(6,3.5+r*1.4,e-12,.6)}function FA(i,e,t){mm(13,1.8)(i,e,t);let r=t/2;i.fillStyle=Pt(i,0,10,"#8a6e48","#2a2018"),i.beginPath(),i.ellipse(4,r,4.6,4,0,0,Math.PI*2),i.fill(),i.strokeStyle="#120c0a",i.lineWidth=.4,i.stroke(),i.fillStyle="#1a1210",i.beginPath(),i.arc(3,r-1.2,1.1,0,Math.PI*2),i.fill()}function DA(i,e,t){i.save(),i.translate(e/2,t/2),i.rotate(Math.PI),i.scale(e/24,t/34),i.translate(-12,-17),Ow(i,24,34),i.restore(),i.globalCompositeOperation="source-atop",i.fillStyle="rgba(120,20,20,0.45)",i.fillRect(0,0,e,t),i.globalCompositeOperation="source-over"}function OA(i,e){i.fillStyle="#2a201a",i.fillRect(1,1,e-2,e-2),i.strokeStyle="#4a3a2c",i.lineWidth=1,i.beginPath(),i.moveTo(5,5),i.lineTo(e-5,e-5),i.moveTo(e-5,5),i.lineTo(5,e-5),i.stroke();for(let[t,r,s]of[[5.5,6,4],[e-5.5,7,3.6],[e/2,e-5.5,4.2]]){let n=i.createRadialGradient(t-s*.4,r+s*.4,.3,t,r,s);n.addColorStop(0,"#f0e0c0"),n.addColorStop(.5,"#b09070"),n.addColorStop(1,"#3a2a20"),i.fillStyle=n,i.beginPath(),i.arc(t,r,s,0,Math.PI*2),i.fill(),i.fillStyle="#d9502f",i.beginPath(),i.arc(t,r,s*.3,0,Math.PI*2),i.fill()}}function LA(i,e,t){i.fillStyle=Pt(i,0,e,"#8a8070","#2a2622"),i.fillRect(.5,.5,e-1,t-1),i.save(),i.beginPath(),i.rect(1,t-4,e-2,3),i.clip();for(let r=-t;r<e+t;r+=3)i.fillStyle=r/3%2?"#1a1410":"#e8a030",i.beginPath(),i.moveTo(r,t),i.lineTo(r+1.5,t),i.lineTo(r+4.5,t-4),i.lineTo(r+3,t-4),i.fill();i.restore(),i.fillStyle="#141010";for(let r=0;r<3;r++)i.fillRect(3+r*((e-6)/3),2,(e-6)/3-1.5,t-7);i.strokeStyle=Rr,i.globalAlpha=.6,i.lineWidth=.5,i.strokeRect(.7,.7,e-1.4,t-1.4),i.globalAlpha=1}function UA(i,e,t){i.fillStyle="#121010",i.fillRect(2,1,2,t-2),i.fillRect(e-4,1,2,t-2),i.fillStyle=Pt(i,0,e,"#7a6650","#241c18"),i.beginPath(),i.roundRect(3,2,e-6,t-4,1.5),i.fill(),i.strokeStyle="#100c0a",i.lineWidth=.4,i.stroke(),i.fillStyle="rgba(0,0,0,0.25)";for(let r=5;r<t-4;r+=6)i.fillRect(4,r,e-8,.6);i.fillStyle="#2a2220",i.beginPath(),i.arc(e/2,t/2,5,0,Math.PI*2),i.fill(),i.strokeStyle=Rr,i.globalAlpha=.6,i.lineWidth=.5,i.beginPath(),i.moveTo(3.3,3),i.lineTo(3.3,t-3),i.stroke(),i.globalAlpha=1}function NA(i,e,t){i.fillStyle="#121010",i.fillRect(1.5,2,2.4,t-4),i.fillRect(e-3.9,2,2.4,t-4),i.fillStyle=Pt(i,0,e,"#9a5a3a","#2a1410"),i.beginPath(),i.moveTo(e/2,.5),i.lineTo(e-3,7),i.lineTo(e-3,t-2),i.lineTo(3,t-2),i.lineTo(3,7),i.closePath(),i.fill(),i.strokeStyle="#100808",i.lineWidth=.5,i.stroke(),i.fillStyle="#3a2420",i.fillRect(5,t-13,e-10,9),i.fillStyle="#ffcf8a",i.fillRect(6.5,t-11.5,e-13,1.6),i.fillStyle="#1a1010",i.beginPath(),i.arc(e/2,12,3,0,Math.PI*2),i.fill(),i.fillStyle="#d9502f",i.fillRect(e/2-4,3,8,1.2),i.strokeStyle=Rr,i.globalAlpha=.7,i.lineWidth=.5,i.beginPath(),i.moveTo(e/2,.8),i.lineTo(3.3,7),i.lineTo(3.3,t-2.5),i.stroke(),i.globalAlpha=1}function HA(i,e){let t=e/2,r=e/2-1,s=i.createRadialGradient(t-r*.35,t+r*.35,1,t,t,r);s.addColorStop(0,"#e8e0d0"),s.addColorStop(.55,"#8a8478"),s.addColorStop(1,"#2a2826"),i.fillStyle=s,i.beginPath(),i.arc(t,t,r,0,Math.PI*2),i.fill(),i.strokeStyle="rgba(30,26,24,0.55)",i.lineWidth=.4;for(let n=0;n<12;n++){let o=n/12*Math.PI*2;i.beginPath(),i.moveTo(t,t),i.lineTo(t+Math.cos(o)*r,t+Math.sin(o)*r),i.stroke()}for(let n of[.35,.7])i.beginPath(),i.arc(t,t,r*n,0,Math.PI*2),i.stroke();i.strokeStyle="#1a1614",i.lineWidth=.8,i.beginPath(),i.moveTo(t+r*.6,t-2),i.lineTo(t+r*1,t),i.lineTo(t+r*.6,t+2),i.stroke(),i.fillStyle="#d9502f",i.beginPath(),i.arc(t+r*.95,t,1.6,0,Math.PI*2),i.fill()}function zA(i,e){xm(i,e);let t=e/2;for(let r of[4.2,2.8])i.strokeStyle="#9fe8ff",i.lineWidth=.8,i.beginPath(),i.arc(t,t,r,0,Math.PI*2),i.stroke();i.fillStyle="#e8fbff",i.beginPath(),i.arc(t,t,1.4,0,Math.PI*2),i.fill()}function Dw(i,e){return Qt(i,i,t=>{let r=i/2,s=t.createRadialGradient(r,r,0,r,r,r);for(let[n,o]of e)s.addColorStop(n,`rgba(255,255,255,${o})`);t.fillStyle=s,t.fillRect(0,0,i,i)})}function WA(i,e){return Qt(i,i,t=>{let r=e*9301+49297,s=()=>(r=(r*9301+49297)%233280)/233280,n=i/2;for(let o=0;o<7;o++){let a=s()*Math.PI*2,l=s()*i*.18,c=n+Math.cos(a)*l,h=n+Math.sin(a)*l,u=i*(.22+s()*.16),d=t.createRadialGradient(c-u*.3,h+u*.3,0,c,h,u);d.addColorStop(0,"rgba(255,255,255,0.55)"),d.addColorStop(.6,"rgba(255,255,255,0.3)"),d.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=d,t.beginPath(),t.arc(c,h,u,0,Math.PI*2),t.fill()}})}function VA(){return Qt(16,4,i=>{let e=i.createLinearGradient(0,0,16,0);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.7,"rgba(255,255,255,0.8)"),e.addColorStop(1,"rgba(255,255,255,1)"),i.fillStyle=e,i.beginPath(),i.ellipse(8,2,8,1.2,0,0,Math.PI*2),i.fill()})}function $A(){return Qt(32,32,i=>{let e=i.createRadialGradient(16,16,10,16,16,16);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.75,"rgba(255,255,255,0.9)"),e.addColorStop(1,"rgba(255,255,255,0)"),i.fillStyle=e,i.fillRect(0,0,32,32)})}function XA(){return Qt(32,32,i=>{for(let e=0;e<18;e++){let t=Math.random()*Math.PI*2,r=Math.random()*7,s=16+Math.cos(t)*r,n=16+Math.sin(t)*r,o=4+Math.random()*7,a=i.createRadialGradient(s,n,0,s,n,o);a.addColorStop(0,"rgba(20,10,12,0.35)"),a.addColorStop(1,"rgba(20,10,12,0)"),i.fillStyle=a,i.beginPath(),i.arc(s,n,o,0,Math.PI*2),i.fill()}i.strokeStyle="rgba(15,8,10,0.35)",i.lineWidth=.6;for(let e=0;e<14;e++){let t=Math.random()*Math.PI*2;i.beginPath(),i.moveTo(16+Math.cos(t)*5,16+Math.sin(t)*5),i.lineTo(16+Math.cos(t)*(10+Math.random()*5),16+Math.sin(t)*(10+Math.random()*5)),i.stroke()}})}function YA(){return Qt(6,6,i=>{i.fillStyle="#1a1210",i.beginPath(),i.moveTo(1,2),i.lineTo(4,.5),i.lineTo(5.5,3),i.lineTo(3.5,5.5),i.lineTo(.5,4.5),i.closePath(),i.fill(),i.fillStyle="#c08050",i.fillRect(1,3,2,1)})}function Nw(){return{gunship:ke(24,34,Ow,1.4),rotor:ft(Qt(38,38,(i,e)=>MA(i,e))),drone:ke(24,24,(i,e)=>CA(i,e)),uav:ke(26,22,EA),mine:ke(22,22,(i,e)=>PA(i,e)),pickups:{fuel:ke(20,30,Ia("fuel")),shield:ke(20,30,Ia("shield")),missile:ke(20,30,Ia("missile")),flare:ke(20,30,Ia("flare")),spread:ke(20,30,Ia("spread"))},gunner:ke(26,22,RA),pad:ke(16,16,(i,e)=>xm(i,e),.8),sandbags:ke(20,20,(i,e)=>BA(i,e),.8),barrel:ft(Qt(14,8,mm(10,2))),flakBarrel:ft(Qt(16,10,mm(12,1.6,!0))),sam:ke(22,22,(i,e)=>IA(i,e),.8),tankHull:ke(18,24,GA,.8),tankTurret:ke(20,10,FA,.8),rival:ke(32,44,DA,1.8),depot:ke(20,20,(i,e)=>OA(i,e),.8),sluice:ke(20,14,LA,.6),trainCar:ke(22,36,UA,.8),engine:ke(24,42,NA,.8),dish:ke(40,40,(i,e)=>HA(i,e),1),shieldGen:ke(16,16,(i,e)=>zA(i,e),.6),missile:ke(5,13,kA,.8),pylon:ft(Qt(12,12,(i,e)=>AA(i,e))),glow:ft(Dw(32,[[0,1],[.25,.6],[1,0]])),softGlow:ft(Dw(32,[[0,.5],[.5,.18],[1,0]])),puffs:[0,1,2,3].map(i=>ft(WA(24,i+1))),streak:ft(VA()),ring:ft($A()),scorch:[0,1].map(()=>ft(XA())),chunk:ft(YA())}}var Xi,fm,wA,Ih,Rr,gm,Lw,Gh,Uw,Hw=f(()=>{"use strict";hi();Xi=4;fm="#7a5a40",wA="#3b2c22",Ih="#1d1520",Rr="#ffcf8a";gm="#6a4a40",Lw="#30201e",Gh="#140c12",Uw="#ff3b2f"});var an,Fh=f(()=>{an=`in vec2 aPosition;
out vec2 vTextureCoord;

uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;

vec4 filterVertexPosition( void )
{
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
    
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aPosition * (uOutputFrame.zw * uInputSize.zw);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
}
`});var ln,Dh=f(()=>{ln=`struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;

struct VSOutput {
    @builtin(position) position: vec4<f32>,
    @location(0) uv : vec2<f32>
  };

fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;

    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;

    return vec4(position, 0.0, 1.0);
}

fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}

fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  
}

fn getSize() -> vec2<f32>
{
  return gfu.uGlobalFrame.zw;
}
  
@vertex
fn mainVertex(
  @location(0) aPosition : vec2<f32>, 
) -> VSOutput {
  return VSOutput(
   filterVertexPosition(aPosition),
   filterTextureCoord(aPosition)
  );
}`});var zw,Ww=f(()=>{zw=`
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform vec2 uOffset;

void main(void)
{
    vec4 color = vec4(0.0);

    // Sample top left pixel
    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));

    // Sample top right pixel
    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));

    // Sample bottom right pixel
    color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));

    // Sample bottom left pixel
    color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));

    // Average
    color *= 0.25;

    finalColor = color;
}`});var Vw,$w=f(()=>{Vw=`struct KawaseBlurUniforms {
  uOffset:vec2<f32>,
};

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  let uOffset = kawaseBlurUniforms.uOffset;
  var color: vec4<f32> = vec4<f32>(0.0);

  // Sample top left pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y));
  // Sample top right pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y));
  // Sample bottom right pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y));
  // Sample bottom left pixel
  color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y));
  // Average
  color *= 0.25;

  return color;
}`});var Xw,Yw=f(()=>{Xw=`
precision highp float;
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform vec2 uOffset;

uniform vec4 uInputClamp;

void main(void)
{
    vec4 color = vec4(0.0);

    // Sample top left pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample top right pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample bottom right pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Sample bottom left pixel
    color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));

    // Average
    color *= 0.25;

    finalColor = color;
}
`});var Kw,jw=f(()=>{Kw=`struct KawaseBlurUniforms {
  uOffset:vec2<f32>,
};

struct GlobalFilterUniforms {
  uInputSize:vec4<f32>,
  uInputPixel:vec4<f32>,
  uInputClamp:vec4<f32>,
  uOutputFrame:vec4<f32>,
  uGlobalFrame:vec4<f32>,
  uOutputTexture:vec4<f32>,
};

@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  let uOffset = kawaseBlurUniforms.uOffset;
  var color: vec4<f32> = vec4(0.0);

  // Sample top left pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample top right pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample bottom right pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Sample bottom left pixel
  color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));
  // Average
  color *= 0.25;
    
  return color;
}`});var KA,jA,Yi,qw,Qw,Jw=f(()=>{hi();Fh();Dh();Ww();$w();Yw();jw();KA=Object.defineProperty,jA=(i,e,t)=>e in i?KA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Yi=(i,e,t)=>(jA(i,typeof e!="symbol"?e+"":e,t),t),qw=class Zw extends wt{constructor(...e){let t=e[0]??{};(typeof t=="number"||Array.isArray(t))&&(B("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),t={strength:t},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.clamp=e[2])),t={...Zw.DEFAULT_OPTIONS,...t};let r=Xe.from({vertex:{source:ln,entryPoint:"mainVertex"},fragment:{source:t?.clamp?Kw:Vw,entryPoint:"mainFragment"}}),s=Fe.from({vertex:an,fragment:t?.clamp?Xw:zw,name:"kawase-blur-filter"});super({gpuProgram:r,glProgram:s,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Yi(this,"uniforms"),Yi(this,"_pixelSize",{x:0,y:0}),Yi(this,"_clamp"),Yi(this,"_kernels",[]),Yi(this,"_blur"),Yi(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=t.pixelSize??{x:1,y:1},Array.isArray(t.strength)?this.kernels=t.strength:typeof t.strength=="number"&&(this._blur=t.strength,this.quality=t.quality??3),this._clamp=!!t.clamp}apply(e,t,r,s){let n=this.pixelSizeX/t.source.width,o=this.pixelSizeY/t.source.height,a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,t,r,s);else{let l=ce.getSameSizeTexture(t),c=t,h=l,u,d=this._quality-1;for(let p=0;p<d;p++)a=this._kernels[p]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,c,h,!0),u=c,c=h,h=u;a=this._kernels[d]+.5,this.uniforms.uOffset[0]=a*n,this.uniforms.uOffset[1]=a*o,e.applyFilter(this,c,r,s),ce.returnTexture(l)}}get strength(){return this._blur}set strength(e){this._blur=e,this._generateKernels()}get quality(){return this._quality}set quality(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()}get kernels(){return this._kernels}set kernels(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max(...e)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(e){if(typeof e=="number"){this.pixelSizeX=this.pixelSizeY=e;return}if(Array.isArray(e)){this.pixelSizeX=e[0],this.pixelSizeY=e[1];return}this._pixelSize=e}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(e){this.pixelSize.x=e}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(e){this.pixelSize.y=e}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((e,t)=>e+t+.5,0))}_generateKernels(){let e=this._blur,t=this._quality,r=[e];if(e>0){let s=e,n=e/t;for(let o=1;o<t;o++)s-=n,r.push(s)}this._kernels=r,this._updatePadding()}};Yi(qw,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:!1,pixelSize:{x:1,y:1}});Qw=qw});var eM,tM=f(()=>{eM=`in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform sampler2D uMapTexture;
uniform float uBloomScale;
uniform float uBrightness;

void main() {
    vec4 color = texture(uTexture, vTextureCoord);
    color.rgb *= uBrightness;
    vec4 bloomColor = vec4(texture(uMapTexture, vTextureCoord).rgb, 0.0);
    bloomColor.rgb *= uBloomScale;
    finalColor = color + bloomColor;
}
`});var rM,iM=f(()=>{rM=`struct AdvancedBloomUniforms {
  uBloomScale: f32,
  uBrightness: f32,
};

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> advancedBloomUniforms : AdvancedBloomUniforms;
@group(1) @binding(1) var uMapTexture: texture_2d<f32>;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  var color = textureSample(uTexture, uSampler, uv);
  color = vec4<f32>(color.rgb * advancedBloomUniforms.uBrightness, color.a);

  var bloomColor = vec4<f32>(textureSample(uMapTexture, uSampler, uv).rgb, 0.0);
  bloomColor = vec4<f32>(bloomColor.rgb * advancedBloomUniforms.uBloomScale, bloomColor.a);
  
  return color + bloomColor;
}
`});var sM,nM=f(()=>{sM=`
in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
uniform float uThreshold;

void main() {
    vec4 color = texture(uTexture, vTextureCoord);

    // A simple & fast algorithm for getting brightness.
    // It's inaccuracy , but good enought for this feature.
    float _max = max(max(color.r, color.g), color.b);
    float _min = min(min(color.r, color.g), color.b);
    float brightness = (_max + _min) * 0.5;

    if(brightness > uThreshold) {
        finalColor = color;
    } else {
        finalColor = vec4(0.0, 0.0, 0.0, 0.0);
    }
}
`});var oM,aM=f(()=>{oM=`struct ExtractBrightnessUniforms {
  uThreshold: f32,
};

@group(0) @binding(1) var uTexture: texture_2d<f32>; 
@group(0) @binding(2) var uSampler: sampler;
@group(1) @binding(0) var<uniform> extractBrightnessUniforms : ExtractBrightnessUniforms;

@fragment
fn mainFragment(
  @builtin(position) position: vec4<f32>,
  @location(0) uv : vec2<f32>
) -> @location(0) vec4<f32> {
  let color: vec4<f32> = textureSample(uTexture, uSampler, uv);

  // A simple & fast algorithm for getting brightness.
  // It's inaccurate, but good enough for this feature.
  let max: f32 = max(max(color.r, color.g), color.b);
  let min: f32 = min(min(color.r, color.g), color.b);
  let brightness: f32 = (max + min) * 0.5;

  return select(vec4<f32>(0.), color, brightness > extractBrightnessUniforms.uThreshold);
}
`});var qA,ZA,lM,cM,uM,dM=f(()=>{hi();Fh();Dh();nM();aM();qA=Object.defineProperty,ZA=(i,e,t)=>e in i?qA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,lM=(i,e,t)=>(ZA(i,typeof e!="symbol"?e+"":e,t),t),cM=class hM extends wt{constructor(e){e={...hM.DEFAULT_OPTIONS,...e};let t=Xe.from({vertex:{source:ln,entryPoint:"mainVertex"},fragment:{source:oM,entryPoint:"mainFragment"}}),r=Fe.from({vertex:an,fragment:sM,name:"extract-brightness-filter"});super({gpuProgram:t,glProgram:r,resources:{extractBrightnessUniforms:{uThreshold:{value:e.threshold,type:"f32"}}}}),lM(this,"uniforms"),this.uniforms=this.resources.extractBrightnessUniforms.uniforms}get threshold(){return this.uniforms.uThreshold}set threshold(e){this.uniforms.uThreshold=e}};lM(cM,"DEFAULT_OPTIONS",{threshold:.5});uM=cM});var QA,JA,cn,pM,ym,mM=f(()=>{hi();Fh();Dh();Jw();tM();iM();dM();QA=Object.defineProperty,JA=(i,e,t)=>e in i?QA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,cn=(i,e,t)=>(JA(i,typeof e!="symbol"?e+"":e,t),t),pM=class fM extends wt{constructor(e){e={...fM.DEFAULT_OPTIONS,...e};let t=Xe.from({vertex:{source:ln,entryPoint:"mainVertex"},fragment:{source:rM,entryPoint:"mainFragment"}}),r=Fe.from({vertex:an,fragment:eM,name:"advanced-bloom-filter"});super({gpuProgram:t,glProgram:r,resources:{advancedBloomUniforms:{uBloomScale:{value:e.bloomScale,type:"f32"},uBrightness:{value:e.brightness,type:"f32"}},uMapTexture:F.WHITE}}),cn(this,"uniforms"),cn(this,"bloomScale",1),cn(this,"brightness",1),cn(this,"_extractFilter"),cn(this,"_blurFilter"),this.uniforms=this.resources.advancedBloomUniforms.uniforms,this._extractFilter=new uM({threshold:e.threshold}),this._blurFilter=new Qw({strength:e.kernels??e.blur,quality:e.kernels?void 0:e.quality}),Object.assign(this,e)}apply(e,t,r,s){let n=ce.getSameSizeTexture(t);this._extractFilter.apply(e,t,n,!0);let o=ce.getSameSizeTexture(t);this._blurFilter.apply(e,n,o,!0),this.uniforms.uBloomScale=this.bloomScale,this.uniforms.uBrightness=this.brightness,this.resources.uMapTexture=o.source,e.applyFilter(this,t,r,s),ce.returnTexture(o),ce.returnTexture(n)}get threshold(){return this._extractFilter.threshold}set threshold(e){this._extractFilter.threshold=e}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}};cn(pM,"DEFAULT_OPTIONS",{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSize:{x:1,y:1}});ym=pM});var gM=f(()=>{mM()});var yM,xM=f(()=>{yM=`// Final grade: heat haze \u2192 chromatic aberration \u2192 split-tone grade \u2192
// low-sun glow \u2192 vignette (+ red critical pulse) \u2192 film grain.

in vec2 vTextureCoord;
out vec4 finalColor;

uniform sampler2D uTexture;
// shared with the vertex stage, which is highp: precisions must match to link
uniform highp vec4 uInputSize;
uniform highp vec4 uOutputFrame;
uniform vec4 uInputClamp;

uniform float uTime;
uniform float uHurt;       // 0..1 recent damage
uniform float uCritical;   // 0..1 low fuel/shields
uniform vec4 uHaze[4];     // screen uv xy, radius (uv), strength
// sector light (blended between sectors by the renderer)
uniform float uExposure;
uniform vec3 uLow;         // added to dark tones
uniform vec3 uHigh;        // multiplied into bright tones
uniform vec3 uGlow;        // low-sun corner glow colour
uniform float uGlowStrength;
uniform float uNight;      // 0..1 darkness; the gunship's searchlight pools light
uniform float uNvg;        // 0..1 green night vision
uniform float uDust;       // 0..1 blowing sand
uniform vec2 uPlayer;      // player position, screen uv

float hash(vec2 p) {
    p = fract(p * vec2(443.897, 441.423));
    p += dot(p, p.yx + 19.19);
    return fract((p.x + p.y) * p.x);
}

float vnoise(vec2 p) {
    vec2 i = floor(p), f = fract(p);
    vec2 u = f * f * (3.0 - 2.0 * f);
    return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x), mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
}

void main() {
    // 0..1 across the output frame
    vec2 uv = vTextureCoord * uInputSize.xy / uOutputFrame.zw;
    vec2 toTex = uOutputFrame.zw * uInputSize.zw;

    // heat shimmer: gentle everywhere near the bottom, strong over fresh explosions
    float shimmer = 0.0006 * smoothstep(0.55, 1.0, uv.y);
    for (int i = 0; i < 4; i++) {
        vec4 h = uHaze[i];
        float d = length((uv - h.xy) * vec2(uOutputFrame.z / uOutputFrame.w, 1.0));
        shimmer += h.w * 0.006 * (1.0 - smoothstep(0.0, h.z, d));
    }
    vec2 wob = vec2(sin(uv.y * 90.0 + uTime * 6.0), cos(uv.x * 70.0 + uTime * 5.0)) * shimmer;

    // chromatic aberration grows with damage and toward the edges
    vec2 fromC = uv - 0.5;
    float ca = (0.0008 + 0.006 * uHurt) * dot(fromC, fromC) * 4.0;
    vec2 base = (uv + wob) * toTex;
    vec2 off = fromC * ca * toTex;
    vec3 col;
    col.r = texture(uTexture, clamp(base + off, uInputClamp.xy, uInputClamp.zw)).r;
    col.g = texture(uTexture, clamp(base, uInputClamp.xy, uInputClamp.zw)).g;
    col.b = texture(uTexture, clamp(base - off, uInputClamp.xy, uInputClamp.zw)).b;

    col *= uExposure;
    // split-tone grade: sector-tinted shadows and highlights, slight S-curve
    float luma = dot(col, vec3(0.299, 0.587, 0.114));
    col = mix(col + uLow * (1.0 - smoothstep(0.0, 0.35, luma)) * 0.6, col * uHigh, smoothstep(0.35, 0.9, luma));
    col = mix(col, col * col * (3.0 - 2.0 * col), 0.35);

    // night: everything falls dark except the searchlight pool and anything bright enough to glow
    vec2 asp = vec2(uOutputFrame.z / uOutputFrame.w, 1.0);
    if (uNight > 0.0) {
        float dp = length((uv - uPlayer) * asp);
        float pool = 1.0 - smoothstep(0.04, 0.3, dp);
        vec2 cone = (uv - (uPlayer + vec2(0.0, -0.2))) * asp / vec2(0.13, 0.22);
        float beam = (1.0 - smoothstep(0.6, 1.0, length(cone))) * 0.9;
        float light = max(pool, beam);
        float keep = smoothstep(0.62, 0.95, luma);
        col *= mix(1.0, mix(0.16 + light * 0.95, 1.0, keep), uNight);
    }
    if (uNvg > 0.0) {
        float l = dot(col, vec3(0.299, 0.587, 0.114));
        vec3 nv = vec3(0.32, 1.0, 0.42) * (l * 1.5 + 0.035);
        nv *= 0.92 + 0.08 * sin(uv.y * uInputSize.y * 1.4);
        col = mix(col, nv, uNvg);
    }
    // blowing sand: streaky haze that thickens away from the gunship
    if (uDust > 0.0) {
        // wind-stretched smooth noise: long streaks racing across the screen
        vec2 q = vec2(uv.x * 3.0 - uTime * 1.6, uv.y * 26.0);
        float streak = vnoise(q) * 0.65 + vnoise(q * 2.3 + 7.0) * 0.35;
        float far = smoothstep(0.08, 0.55, length((uv - uPlayer) * asp));
        float amt = uDust * (0.14 + 0.36 * far) * (0.7 + 0.6 * streak);
        col = mix(col, vec3(0.74, 0.54, 0.34) * (0.88 + 0.2 * streak), clamp(amt, 0.0, 0.8));
    }

    // low sun glow from the lower-left corner
    float sun = 1.0 - smoothstep(0.0, 0.85, length((uv - vec2(-0.05, 1.08)) * vec2(1.2, 1.0)));
    col += uGlow * sun * sun * uGlowStrength;

    // vignette, pulsing red when critical or freshly hit
    float vig = smoothstep(0.95, 0.35, length(fromC * vec2(1.1, 1.0)));
    col *= mix(0.55, 1.0, vig);
    float pulse = max(uCritical * (0.5 + 0.5 * sin(uTime * 11.0)), uHurt);
    col = mix(col, vec3(0.85, 0.18, 0.1), (1.0 - vig) * pulse * 0.55);

    // grain
    float n = hash(uv * uInputSize.xy + fract(uTime * 13.7) * 100.0) - 0.5;
    col += n * 0.035;

    finalColor = vec4(col, 1.0);
}
`});function bM(){return new ym({threshold:.74,bloomScale:.9,brightness:1,blur:5,quality:5})}var tR,Oh,_M=f(()=>{"use strict";hi();gM();xM();tR=`
in vec2 aPosition;
out vec2 vTextureCoord;
uniform vec4 uInputSize;
uniform vec4 uOutputFrame;
uniform vec4 uOutputTexture;
void main(void) {
    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
    position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
    gl_Position = vec4(position, 0.0, 1.0);
    vTextureCoord = aPosition * (uOutputFrame.zw * uInputSize.zw);
}`,Oh=class extends wt{u;constructor(){super({glProgram:Fe.from({vertex:tR,fragment:yM,name:"dusk-grade"}),resources:{gradeUniforms:{uTime:{value:0,type:"f32"},uHurt:{value:0,type:"f32"},uCritical:{value:0,type:"f32"},uHaze:{value:new Float32Array(16),type:"vec4<f32>",size:4},uExposure:{value:1,type:"f32"},uLow:{value:new Float32Array([.1,.04,.16]),type:"vec3<f32>"},uHigh:{value:new Float32Array([1.06,.98,.86]),type:"vec3<f32>"},uGlow:{value:new Float32Array([1,.62,.28]),type:"vec3<f32>"},uGlowStrength:{value:.22,type:"f32"},uNight:{value:0,type:"f32"},uNvg:{value:0,type:"f32"},uDust:{value:0,type:"f32"},uPlayer:{value:new Float32Array([.5,.7]),type:"vec2<f32>"}}}}),this.u=this.resources.gradeUniforms.uniforms}setLight(e,t,r){let s=this.u;s.uExposure=e.exposure,s.uLow.set(e.gradeLow),s.uHigh.set(e.gradeHigh),s.uGlow.set(e.glow),s.uGlowStrength=e.glowStrength,s.uNight=e.night,s.uNvg=e.nvg,s.uDust=e.dust;let n=s.uPlayer;n[0]=t,n[1]=r}set(e,t,r,s){this.u.uTime=e,this.u.uHurt=t,this.u.uCritical=r;let n=this.u.uHaze;n.fill(0);for(let o=0;o<Math.min(4,s.length);o++)n[o*4]=s[o].x,n[o*4+1]=s[o].y,n[o*4+2]=s[o].radius,n[o*4+3]=s[o].strength}}});var TM={};Fa(TM,{PixiRenderer:()=>_m});function Uh(i){return Math.min(1,i*8)*(1-i)}var vM,SM,kt,rR,Lh,bm,_m,wM=f(()=>{"use strict";hi();At();Gr();Va();bn();ja();Qi();ou();kw();Fw();Hw();_M();vM=2,SM=520,kt=class{constructor(e,t){this.parent=e;this.blend=t}items=[];used=0;begin(){this.used=0}get(e,t,r){let s=this.items[this.used];return s||(s=new nr(e),this.blend&&(s.blendMode=this.blend),this.parent.addChild(s),this.items.push(s)),this.used++,s.texture=e,s.visible=!0,s.anchor.set(.5),s.position.set(t,r),s.alpha=1,s.tint=16777215,s.rotation=0,s.scale.set(1),s}end(){for(let e=this.used;e<this.items.length;e++)this.items[e].visible=!1}},rR=(i,e,t)=>Math.round(i)<<16|Math.round(e)<<8|Math.round(t),Lh=(i,e,t)=>rR(Rt(i>>16&255,e>>16&255,t),Rt(i>>8&255,e>>8&255,t),Rt(i&255,e&255,t)),bm=(i,e)=>(Math.sin(i*.91+e*7.3)+Math.sin(i*1.73+e*3.1)*.6+Math.sin(i*2.97+e)*.3)/1.9,_m=class i{constructor(e){this.app=e;this.art=Nw(),e.stage.addChild(this.root),this.root.addChild(this.world);let t=()=>this.world.addChild(new ge);this.world.addChild(this.terrain.mesh),this.decals=new kt(t()),this.world.addChild(this.structGfx),this.groundUnits=new kt(t()),this.shadows=new kt(t()),this.groundFx=new kt(t()),this.world.addChild(this.tele),this.tele.blendMode="add",this.world.addChild(this.gateGfx),this.gateGfx.blendMode="add",this.gates=new kt(t()),this.pickups=new kt(t()),this.units=new kt(t()),this.unitFlash=new kt(t()),this.smoke=new kt(t()),this.player=new kt(t()),this.world.addChild(this.overGfx),this.additive=new kt(t(),"add"),this.world.addChild(this.hud),this.world.addChild(this.popupLayer),this.world.addChild(this.debugGfx),this.warning=new ka({text:"",style:{fontFamily:"Share Tech Mono, monospace",fontSize:40,fill:16761707,letterSpacing:6,align:"center"}}),this.warning.anchor.set(.5),this.warning.scale.set(.25),this.world.addChild(this.warning)}root=new ge;world=new ge;terrain=new Bh;art;grade=new Oh;bloom=bM();quality="high";access={...Pw};dynRes=1;frameEma=16.7;lastFrame=0;framesSinceRes=0;lastScale=1;portraitX=be/2;decals;groundUnits;tele=new pt;structGfx=new pt;overGfx=new pt;light=structuredClone(Ke[0].light);popupLayer=new ge;popupPool=[];shadows;groundFx;pickups;gateGfx=new pt;gates;units;unitFlash;smoke;additive;player;hud=new pt;debugGfx=new pt;warning;cssW=1;cssH=1;bank=0;rotorAngle=0;time=0;haze=[];inspectZoom=Math.max(1,Math.min(8,Number(new URLSearchParams(location.search).get("zoom"))||1));static async create(e){let t=new xh,r=e.getBoundingClientRect();await t.init({canvas:e,width:Math.max(100,r.width),height:Math.max(100,r.height),resolution:Math.min(window.devicePixelRatio||1,vM),autoDensity:!0,antialias:!1,background:1313544,preference:"webgl",autoStart:!1,sharedTicker:!1,powerPreference:"high-performance"});let s=new i(t);return s.resize(),s}setQuality(e){this.quality=e,this.dynRes=1,this.bloom.quality=e==="high"?5:3,this.resize()}setAccess(e){this.access={...e}}worldScale(){return this.lastScale}baseRes(){let e=window.devicePixelRatio||1;return this.quality==="high"?Math.min(e,vM):this.quality==="balanced"?Math.min(e,1.5):1}adaptResolution(){let e=performance.now();if(this.lastFrame&&(this.frameEma=this.frameEma*.95+Math.min(100,e-this.lastFrame)*.05),this.lastFrame=e,this.quality==="performance"||document.hidden||++this.framesSinceRes<120)return;let t=this.dynRes;this.frameEma>21&&this.dynRes>.6?t=Math.max(.6,this.dynRes-.15):this.frameEma<14&&this.dynRes<1&&(t=Math.min(1,this.dynRes+.1)),t!==this.dynRes&&(this.dynRes=t,this.app.renderer.resize(this.cssW,this.cssH,Math.max(.75,this.baseRes()*this.dynRes))),this.framesSinceRes=0}get resolutionInfo(){return`${this.quality} \xB7 res ${(this.baseRes()*this.dynRes).toFixed(2)} (${Math.round(this.dynRes*100)}%)`}resize(){let e=this.app.canvas;e.style.width="",e.style.height="";let t=e.getBoundingClientRect();this.cssW=Math.max(100,t.width),this.cssH=Math.max(100,t.height),this.app.renderer.resize(this.cssW,this.cssH,Math.max(.75,this.baseRes()*this.dynRes)),this.root.filterArea=new V(0,0,this.cssW,this.cssH),this.root.filters=this.quality==="performance"?[]:[this.bloom,this.grade]}render(e){let{sim:t,fx:r,alpha:s}=e;this.time+=1/60,this.adaptResolution();let n=this.access.reducedMotion,o=r.camera,a=this.cssH>this.cssW*1.15,c=(a?this.cssW/SM:Math.min(this.cssW/be,this.cssH/j))*(1-o.zoomOut)*this.inspectZoom;this.lastScale=c;let h=o.trauma*o.trauma,u=o.t*.9,d=bm(u,1)*14*h,p=bm(u,2)*14*h+o.kickY,m=n?0:bm(u,3)*.025*h,x=be/2+o.leadX,y=j/2;if(a){let C=t.player.x+t.player.w/2,M=SM/2;this.portraitX+=(Math.min(be-M,Math.max(M,C))-this.portraitX)*.08,x=this.portraitX,y=this.cssH/2/c}this.inspectZoom>1&&(x=t.player.x+t.player.w/2,y=t.player.y+t.player.h/2-40/this.inspectZoom),this.world.pivot.set(x,y),this.world.position.set(this.cssW/2+d*c,this.cssH/2+p*c),this.world.scale.set(c),this.world.rotation=m;let g=this.cssW/2/c,v=this.cssH/2/c,_=Math.abs(m)*Math.max(g,v)+24,S={x:x-g-_,y:y-v-_,w:(g+_)*2,h:(v+_)*2},T=(C,M)=>{let A=(C-x)*c,U=(M-y)*c,z=Math.cos(m),J=Math.sin(m);return[this.cssW/2+d*c+A*z-U*J,this.cssH/2+p*c+A*J+U*z]},w=Rt(t.prevDist,t.dist,s);this.terrain.update(t.canyon,w,S);for(let C of[this.decals,this.groundUnits,this.shadows,this.groundFx,this.gates,this.pickups,this.units,this.unitFlash,this.smoke,this.player,this.additive])C.begin();this.gateGfx.clear(),this.tele.clear(),this.structGfx.clear(),this.overGfx.clear(),this.hud.clear(),this.debugGfx.clear(),this.drawParticles(e),this.drawMotes(e),this.drawBridges(e),this.drawHazards(e);for(let C of t.hostiles)C.kind==="gate"&&this.drawGate(t,C,s);this.drawPickups(e);for(let C of t.hostiles)C.kind!=="gate"&&this.drawHostile(t,C,s);this.drawProjectiles(e),this.drawEnemyShots(e),this.drawFlares(e),this.drawPlayer(e),this.drawPopups(e),e.screen==="playing"||e.screen==="paused"?this.drawHud(e):this.warning.visible=!1,e.debug&&this.drawHitboxes(e);for(let C of[this.decals,this.groundUnits,this.shadows,this.groundFx,this.gates,this.pickups,this.units,this.unitFlash,this.smoke,this.player,this.additive])C.end();let E=Ke[t.course.sector].light,R=e.screen==="title"&&this.idle(e)?1:.015,k=this.light;for(let[C,M]of Object.entries(E))Array.isArray(M)?k[C].forEach((A,U,z)=>z[U]=A+(M[U]-A)*R):k[C]=k[C]+(M-k[C])*R;if(this.terrain.setLight(this.light.sun,this.light.shadow,this.light.shadowLen),this.quality==="high"){let C=t.player,[M,A]=T(C.x+C.w/2,C.y+C.h/2);this.grade.setLight(this.light,M/this.cssW,A/this.cssH),this.haze.length=0;for(let z of r.particles){if(z.kind!=="ring"||this.haze.length>=4)continue;let[J,D]=T(z.x,z.y);this.haze.push({x:J/this.cssW,y:D/this.cssH,radius:z.size*c*3/this.cssH,strength:z.life/z.maxLife})}let U=e.screen==="playing"&&(t.fuel<25||t.shields<25)?1:0;this.grade.set(this.time,r.hurt*this.access.flash,U*(n?.4:1),this.haze)}this.app.render()}lastSector=-1;idle(e){let t=e.sim.course.sector!==this.lastSector;return this.lastSector=e.sim.course.sector,t}drawBridges(e){let t=e.sim;for(let r of t.features){let s=Rt(r.py,r.y,e.alpha),n=t.corridorAt(s),o=n.left-30,a=n.right+30;this.structGfx.rect(o+14,s-16,a-o,12).fill({color:0,alpha:.32});let l=this.overGfx;l.rect(o,s-7,a-o,14).fill({color:3811874,alpha:.96}),l.rect(o,s+5,a-o,2).fill({color:16764810,alpha:.55}),l.rect(o,s-7,a-o,1.5).fill({color:1313802,alpha:.9});for(let c=o+6;c<a;c+=12)l.moveTo(c,s-6).lineTo(c+6,s+5).stroke({width:1,color:1708558,alpha:.8}),l.moveTo(c+6,s-6).lineTo(c,s+5).stroke({width:1,color:1708558,alpha:.8});for(let c=n.left+10;c<n.right;c+=40)this.glow(c,s,8,16724e3,Math.floor(this.time*2+c)%2?.7:.2)}}pos(e,t){return[Rt(e.px,e.x,t)+e.w/2,Rt(e.py,e.y,t)+e.h/2]}shadow(e,t,r,s=.5,n=.5,o=1,a=1){let l=e.tex.width,c=e.tex.height,h=(e.shadow.width-l)/2,u=(e.shadow.height-c)/2,d=this.shadows.get(e.shadow,t+xr.x*o,r+xr.y*o);return d.anchor.set((h+s*l)/e.shadow.width,(u+n*c)/e.shadow.height),d.alpha=.42*a,d}glow(e,t,r,s,n){let o=this.additive.get(this.art.glow,e,t);return o.scale.set(r/32),o.tint=s,o.alpha=n,o}drawParticles(e){let t=this.art;for(let r of e.fx.particles){if(r.delay>0)continue;let s=1-r.life/r.maxLife;switch(r.kind){case"scorch":{let n=this.decals.get(t.scorch[r.seed<.5?0:1],r.x,r.y);n.scale.set(r.size*2/32),n.rotation=r.rot,n.alpha=r.alpha*Math.min(1,r.life/120);break}case"debris":{let n=this.groundFx.get(t.chunk,r.x,r.y);n.scale.set(r.size/3),n.rotation=r.rot,n.alpha=Math.min(1,r.life/40);break}case"dust":{let n=this.groundFx.get(t.puffs[Math.floor(r.seed*4)],r.x,r.y);n.scale.set(r.size*2/24),n.rotation=r.rot,n.tint=14262384,n.alpha=r.alpha*Uh(s);break}case"smoke":{let n=this.smoke.get(t.puffs[Math.floor(r.seed*4)],r.x,r.y);if(n.scale.set(r.size*2/24),n.rotation=r.rot,n.tint=Lh(4863024,10125456,Math.min(1,s*1.4)),n.alpha=r.alpha*Uh(s),r.size>6){let o=this.shadows.get(t.puffs[Math.floor(r.seed*4)],r.x+8,r.y-6);o.scale.set(r.size*2/24),o.tint=0,o.alpha=r.alpha*Uh(s)*.25}break}case"fire":{let n=this.additive.get(t.puffs[Math.floor(r.seed*4)],r.x,r.y);n.scale.set(r.size*2/24),n.rotation=r.rot,n.tint=s<.3?Lh(16773312,16752704,s/.3):Lh(16752704,8396816,(s-.3)/.7),n.alpha=(1-s)*1.1;break}case"flash":{this.glow(r.x,r.y,r.size*2*(1+s*.5),16773328,r.alpha*(1-s)*(1-s)*(.3+.7*this.access.flash));break}case"ring":{let n=this.additive.get(t.ring,r.x,r.y);n.scale.set(r.size*2/32),n.tint=16757844,n.alpha=r.alpha*(1-s)*.7;break}case"spark":{let n=this.additive.get(t.streak,r.x,r.y),o=Math.hypot(r.vx,r.vy);n.rotation=Math.atan2(r.vy,r.vx),n.scale.set(Math.max(.25,o*.22),.6),n.tint=Lh(16773312,16744496,s),n.alpha=1-s;break}case"shock":{let n=this.additive.get(t.ring,r.x,r.y);n.scale.set(r.size*2/32),n.tint=10479871,n.alpha=r.alpha*(1-s);break}case"streak":{let n=this.additive.get(t.streak,r.x,r.y);n.rotation=Math.atan2(r.vy,r.vx),n.scale.set(Math.hypot(r.vx,r.vy)*.18,.5),n.tint=r.seed>.5?16769200:14262384,n.alpha=r.alpha*Uh(s);break}case"ember":{let n=.6+.4*Math.sin(r.seed*50+r.life*.7);this.glow(r.x,r.y,5+r.size*2,16748608,(1-s)*n);break}}}}drawMotes(e){for(let t of e.fx.motes){let r=.5+Math.sin(t.phase)*.5;this.glow(t.x,t.y,t.size*4,16765078,t.alpha*r*.6)}}drawGate(e,t,r){let[s,n]=this.pos(t,r),o=Qh(e,{...t,y:n-t.h/2}),a=this.gateGfx,l=t.flash>0,c=t.hp/t.maxHp,h=o.y+o.h/2,u=Zh(e,t),d=Fm(e,t)<18;if(!u||d&&Math.floor(this.time*30)%2===0){for(let g=o.x;g<o.x+o.w;g+=10)a.moveTo(g,h).lineTo(Math.min(g+5,o.x+o.w),h);a.stroke({width:1,color:16761707,alpha:u?.5:.3})}if(u&&!(d&&Math.floor(this.time*30)%2===0)){a.rect(o.x,h-5,o.w,10).fill({color:15770700,alpha:.06+.04*Math.sin(this.time*9)});for(let g=0;g<3;g++){a.moveTo(o.x,h);let v=Math.max(4,Math.floor(o.w/10));for(let _=1;_<=v;_++){let S=o.x+o.w*_/v;a.lineTo(S,h+(_===v?0:Math.sin(_*2.3+g*1.9+this.time*24)*3.2*(.5+c)))}a.stroke({width:1.1,color:l?16777215:16761707,alpha:.5+.35*Math.sin(this.time*31+g)})}}let p=s,m=t.side<0?o.x+o.w-6:o.x+6,x=this.gates.get(this.art.pylon,m,h);x.alpha=.7;let y=this.gates.get(this.art.pylon,p,h);y.scale.set(1.25),y.rotation=this.time*2,l&&(y.tint=16777215),this.glow(p,h,26+Math.sin(this.time*8)*4,16757844,.8),this.glow(m,h,12,16757844,.4),this.brackets(this.tele,p,h,10+Math.sin(this.time*6)*1.5,16769136,.8)}drawPickups(e){for(let t of e.sim.pickups){let[r,s]=this.pos(t,e.alpha),n=this.art.pickups[t.kind],o=Math.sin(t.rot*.6)*.12;this.shadow(n,r,s,.5,.75,1.8).rotation=o;let a=this.pickups.get(n.tex,r,s);a.anchor.set(.5,.75),a.rotation=o;let l=Math.sin(t.rot*2)>.6;this.glow(r,s,l?14:9,16761707,l?.9:.35)}}drawHostile(e,t,r){let[s,n]=this.pos(t,r),o=this.art,a=this.time,l=this.tele,c=.6+.4*Math.sin(a*5+t.id),h=(u,d,p=.5,m=.5,x=this.unitFlash)=>{if(t.flash<=0)return;let y=x.get(u,s,n);y.anchor.set(p,m),y.rotation=d,y.alpha=t.flash/4*this.access.flash};switch(t.kind){case"drone":case"uav":case"mine":{let u=t.kind==="drone"?o.drone:t.kind==="uav"?o.uav:o.mine,d=t.kind==="drone"?Math.sin(a*4+t.id)*.6:0,p=t.kind==="mine"?a*(t.state===1?4:.8)+t.id:t.kind==="uav"?t.vx*.15:Math.sin(a*2+t.id)*.08;this.shadow(u,s,n,.5,.5,t.kind==="mine"?.6:1.1).rotation=p,this.units.get(u.tex,s,n+d).rotation=p,h(u.white,p);let m=t.kind==="uav"?5:t.kind==="drone"?1.5:0;if(t.kind==="mine"&&t.state===1){let x=Math.floor(a*(8+t.charge*20))%2===0;this.glow(s,n,22,16726831,x?1:.2),l.circle(s,n,Tn).stroke({width:1.2,color:16726831,alpha:.25+.5*t.charge}),l.circle(s,n,Tn*t.charge).fill({color:16726831,alpha:.06+.08*t.charge})}else{let x=t.kind==="drone"&&t.state===1?t.charge:0;this.glow(s,n+d+m,(t.kind==="mine"?16:10)*(1+x*2.2),16726831,Math.max(c,x))}break}case"gunner":{this.shadow(o.gunner,s,n,.5,.5,1.2);let u=this.units.get(o.gunner.tex,s,n);if(u.rotation=t.vx*.1,h(o.gunner.white,u.rotation),t.state===2){let d=t.charge;this.glow(s,n+7,6+d*26,16724e3,.5+d*.5),this.glow(s,n+7,3+d*6,16777215,d),d>.5&&this.ray(s,n+7,t.aim,220,16724e3,(d-.5)*.6,1)}else this.glow(s,n+2,8,16726831,c*.6);break}case"turret":{this.groundUnits.get(o.pad.tex,s,n);let u=this.groundUnits.get(o.barrel,s,n);if(u.anchor.set(2.5/14,.5),u.rotation=t.aim,h(o.pad.white,0,.5,.5,this.groundUnits),t.state===1){let d=t.charge>.7454545454545455,p=!d||Math.floor(a*20)%2===0;this.ray(s+Math.cos(t.aim)*10,n+Math.sin(t.aim)*10,t.aim,700,16722458,p?.2+t.charge*.6:.1,d?1.4:.8)}this.glow(s,n,7,16726831,t.state===1?1:c*.5);break}case"flak":{this.groundUnits.get(o.sandbags.tex,s,n);let u=this.groundUnits.get(o.flakBarrel,s,n);u.anchor.set(2.5/16,.5),u.rotation=t.aim,h(o.sandbags.white,0,.5,.5,this.groundUnits);break}case"sam":{let u=this.groundUnits.get(o.sam.tex,s,n);if(u.rotation=t.aim,h(o.sam.white,t.aim,.5,.5,this.groundUnits),t.state===1){let d=e.player,p=d.x+d.w/2,m=d.y+d.h/2;this.tele.moveTo(s,n).lineTo(p,m).stroke({width:.8,color:16724e3,alpha:.12+t.charge*.3}),this.glow(s,n,14+t.charge*10,16724e3,.5+.5*Math.sin(a*(6+t.charge*20)))}break}case"tank":{this.groundUnits.get(o.tankHull.tex,s,n);let u=this.groundUnits.get(o.tankTurret.tex,s,n-1);if(u.anchor.set(4/20,.5),u.rotation=t.aim,h(o.tankHull.white,0,.5,.5,this.groundUnits),t.state===1){let d=s+Math.cos(t.aim)*15,p=n-1+Math.sin(t.aim)*15;this.glow(d,p,6+t.charge*16,16740384,.4+t.charge*.6)}break}case"depot":{this.groundUnits.get(o.depot.tex,s,n),h(o.depot.white,0,.5,.5,this.groundUnits),this.glow(s,n,8,16761707,.3+.2*Math.sin(a*3+t.id));break}case"dam":{let u=n-t.h/2,d=s-t.w/2,p=this.structGfx;p.rect(d+12,u-10,t.w,t.h).fill({color:0,alpha:.35}),p.rect(d,u,t.w,t.h).fill({color:t.flash>0?14207152:6969930}),p.rect(d,u+t.h-6,t.w,6).fill({color:3813416}),p.rect(d,u,t.w,2).fill({color:16764810,alpha:.6});for(let m=d+8;m<d+t.w;m+=16)p.rect(m,u+3,1,t.h-10).fill({color:3813416,alpha:.6});if(t.shielded){let m=.35+.2*Math.sin(a*6);this.tele.rect(d,u+t.h+2,t.w,2).fill({color:10479871,alpha:m}),this.tele.rect(d,u-3,t.w,1.5).fill({color:10479871,alpha:m*.6})}break}case"sluice":{this.groundUnits.get(o.sluice.tex,s,n),h(o.sluice.white,0,.5,.5,this.groundUnits),this.brackets(this.tele,s,n,12+Math.sin(a*6)*1.2,16769136,.8),this.glow(s,n+3,6,16724e3,c);break}case"traincar":{this.groundUnits.get(o.trainCar.tex,s,n);let u=this.groundUnits.get(o.barrel,s,n);u.anchor.set(2.5/14,.5),u.rotation=t.aim,h(o.trainCar.white,0,.5,.5,this.groundUnits),t.state===1&&this.ray(s+Math.cos(t.aim)*10,n+Math.sin(t.aim)*10,t.aim,600,16722458,.15+t.charge*.5,t.charge>.75?1.4:.8);break}case"engine":{this.groundUnits.get(o.engine.tex,s,n),h(o.engine.white,0,.5,.5,this.groundUnits),t.state===1&&this.glow(s,n-16,8+t.charge*18,16740384,.4+t.charge*.6),Math.random()<.4&&this.glow(s,n-9,6,16756832,.3);break}case"dish":{let u=this.groundUnits.get(o.dish.tex,s,n);if(u.rotation=t.aim,h(o.dish.white,t.aim,.5,.5,this.groundUnits),t.shielded){let d=.25+.15*Math.sin(a*5);this.tele.circle(s,n,30).stroke({width:1.6,color:10479871,alpha:d}),this.tele.circle(s,n,30).fill({color:10479871,alpha:d*.18})}else this.brackets(this.tele,s,n,24,16769136,.8,a);break}case"shieldgen":{this.groundUnits.get(o.shieldGen.tex,s,n),h(o.shieldGen.white,0,.5,.5,this.groundUnits),this.glow(s,n,14,10479871,.5+.3*Math.sin(a*8+t.id)),this.brackets(this.tele,s,n,11,16769136,.7);let u=e.hostiles.find(d=>d.kind==="dish"&&d.group===t.group);if(u){let[d,p]=this.pos(u,r);this.tele.moveTo(s,n).lineTo(d,p).stroke({width:1,color:10479871,alpha:.35+.2*Math.sin(a*12+t.id)})}break}case"gunship":{let u=t.w/30;this.shadow(o.rival,s,n,.5,.5,1.6).scale.set(u);let d=this.units.get(o.rival.tex,s,n);d.scale.set(u),t.variant===2&&(d.tint=16765088),t.variant===1&&(d.tint=13696976),d.rotation=(t.vx||0)*.05,h(o.rival.white,d.rotation),this.glow(s,n,70,16724e3,.18+.06*Math.sin(a*3));let p=this.units.get(o.rotor,s,n+4);if(p.scale.set(1.35*u),p.rotation=-a*50,this.glow(s-13,n-2,5,16724e3,Math.floor(a*3)%2?.9:.3),this.glow(s+13,n-2,5,16724e3,Math.floor(a*3)%2?.3:.9),t.state>=2&&t.state<=4&&t.charge>0&&(this.glow(s,n+16,8+t.charge*26,16728096,.4+t.charge*.6),t.state===2))for(let m=-3;m<=3;m++)this.ray(s,n+16,t.aim+m*.2,160,16724e3,t.charge*.25,1);break}}}ray(e,t,r,s,n,o,a){if(this.access.contrast){let l=Math.cos(r),c=Math.sin(r);for(let h=0;h<s;h+=14)this.tele.moveTo(e+l*h,t+c*h).lineTo(e+l*Math.min(s,h+8),t+c*Math.min(s,h+8)),this.tele.stroke({width:a+.6,color:h/14%2?16777215:16769088,alpha:Math.min(1,o*1.8+.2)});return}this.tele.moveTo(e,t).lineTo(e+Math.cos(r)*s,t+Math.sin(r)*s).stroke({width:a,color:n,alpha:o})}brackets(e,t,r,s,n,o,a=0){let l=s*.45;for(let c=0;c<4;c++){let h=a+c*Math.PI/2+Math.PI/4,u=t+Math.cos(h)*s,d=r+Math.sin(h)*s,p=h+Math.PI*.75,m=h-Math.PI*.75;e.moveTo(u+Math.cos(p)*l,d+Math.sin(p)*l).lineTo(u,d).lineTo(u+Math.cos(m)*l,d+Math.sin(m)*l),e.stroke({width:1.2,color:n,alpha:o})}}drawEnemyShots(e){for(let t of e.sim.enemyShots){let[r,s]=this.pos(t,e.alpha);if(t.kind==="sam"||t.kind==="rocket"){let n=Math.atan2(t.vy,t.vx)+Math.PI/2;this.shadow(this.art.missile,r,s,.5,.5,.8).rotation=n;let o=this.units.get(this.art.missile.tex,r,s);o.rotation=n,o.tint=t.kind==="sam"?16756896:12624016,o.scale.set(t.kind==="sam"?1.3:1);let a=r-Math.sin(n)*8,l=s+Math.cos(n)*8;this.glow(a,l,18*(.8+Math.random()*.2),16732192,1),this.glow(a,l,6,16773328,1),t.kind==="sam"&&t.decoy===null&&this.glow(r,s,26,16719888,.25+.2*Math.sin(this.time*30))}else{let n=t.kind==="shell";this.glow(r,s,n?20:13,n?16738848:16726554,.95),this.glow(r,s,n?7:4.5,16773328,1)}if(this.access.contrast){let n=this.hud;if(t.kind==="bullet")n.circle(r,s,5).stroke({width:2.2,color:0}).circle(r,s,5).stroke({width:1,color:16777215});else if(t.kind==="shell")n.rect(r-6,s-6,12,12).stroke({width:2.2,color:0}).rect(r-6,s-6,12,12).stroke({width:1,color:16769088});else{let o=Math.atan2(t.vy,t.vx),a=(m,x)=>[r+Math.cos(o+x)*m,s+Math.sin(o+x)*m],[l,c]=a(10,0),[h,u]=a(8,2.5),[d,p]=a(8,-2.5);n.moveTo(h,u).lineTo(l,c).lineTo(d,p).stroke({width:2.6,color:0}),n.moveTo(h,u).lineTo(l,c).lineTo(d,p).stroke({width:1.2,color:16777215})}}}}drawHazards(e){let t=this.tele;for(let r of e.sim.hazards){let s=r.timer/r.maxTimer,n=s<.3&&Math.floor(this.time*16)%2===0;if(t.circle(r.x,r.y,r.r).fill({color:16724e3,alpha:.05+(1-s)*.1}),t.circle(r.x,r.y,r.r).stroke({width:1.4,color:16724e3,alpha:n?.95:.55}),t.circle(r.x,r.y,r.r*s).stroke({width:1,color:16757844,alpha:.8}),t.moveTo(r.x-r.r-5,r.y).lineTo(r.x-r.r+6,r.y).moveTo(r.x+r.r-6,r.y).lineTo(r.x+r.r+5,r.y),t.moveTo(r.x,r.y-r.r-5).lineTo(r.x,r.y-r.r+6).moveTo(r.x,r.y+r.r-6).lineTo(r.x,r.y+r.r+5),t.stroke({width:1,color:16724e3,alpha:.8}),this.access.contrast){for(let o=-r.r;o<r.r;o+=8)t.moveTo(r.x+o,r.y-r.r*.7).lineTo(r.x+o+r.r*.5,r.y+r.r*.7);t.stroke({width:1,color:16777215,alpha:.6}),t.circle(r.x,r.y,r.r).stroke({width:2,color:16769088,alpha:.9})}}}drawFlares(e){for(let t of e.sim.flareObjs){let[r,s]=this.pos(t,e.alpha),n=.75+Math.random()*.25;this.glow(r,s,22*n*Math.min(1,t.life/20+.3),16765168,.9),this.glow(r,s,6,16777215,1)}}drawPopups(e){let t=0;for(let r of e.fx.popups){let s=this.popupPool[t];s||(s=new Ba({text:"",style:{fontFamily:"Share Tech Mono, monospace",fontSize:40,fill:16777215,letterSpacing:2}}),s.anchor.set(.5),this.popupLayer.addChild(s),this.popupPool.push(s)),t++,s.visible=!0,s.text!==r.text&&(s.text=r.text),s.position.set(r.x,r.y);let n=1-r.life/r.maxLife,o=n<.12?1+(.12-n)*3:1;s.scale.set(.2*r.size*o),s.tint=r.color,s.alpha=Math.min(1,r.life/r.maxLife*2.2)}for(;t<this.popupPool.length;t++)this.popupPool[t].visible=!1}drawProjectiles(e){let t=this.art;for(let r of e.sim.bullets){let[s,n]=this.pos(r,e.alpha),o=this.additive.get(t.streak,s,n);o.rotation=-Math.PI/2,o.scale.set(1.1,.9),o.tint=16773312,this.glow(s,n-4,9,16757844,.55)}for(let r of e.sim.playerMissiles){let[s,n]=this.pos(r,e.alpha),o=Math.atan2(r.vy,r.vx)+Math.PI/2;this.shadow(t.missile,s,n,.5,.5,.9).rotation=o;let a=this.units.get(t.missile.tex,s,n);a.rotation=o;let l=s-Math.sin(o)*7,c=n+Math.cos(o)*7,h=.75+Math.random()*.25;this.glow(l,c,16*h,16748608,.95),this.glow(l,c,6,16773328,1)}}drawPlayer(e){let t=e.sim.player,r=this.art,[s,n]=this.pos(t,e.alpha);this.bank+=(t.steer-this.bank)*.18,this.rotorAngle+=.9;let a=!(t.invuln>0&&Math.floor(t.invuln/5)%2===0)?1:.35,l=12/34,c=this.shadow(r.gunship,s,n,.5,l,1.4,a);c.rotation=this.bank*.1,c.scale.x=1-Math.abs(this.bank)*.1;let h=this.shadows.get(r.softGlow,s+xr.x*1.4,n+xr.y*1.4);h.scale.set(38/32),h.tint=0,h.alpha=.35*a;let u=this.player.get(r.gunship.tex,s,n);if(u.anchor.set(.5,l),u.rotation=this.bank*.1,u.scale.x=1-Math.abs(this.bank)*.12,u.alpha=a,t.flash>0){let T=this.player.get(r.gunship.white,s,n);T.anchor.set(.5,l),T.rotation=u.rotation,T.scale.x=u.scale.x,T.alpha=t.flash/6*this.access.flash,T.tint=16756896}let d=this.player.get(r.rotor,s,n);d.rotation=this.rotorAngle,d.alpha=a;let p=Math.cos(u.rotation),m=Math.sin(u.rotation),x=(T,w)=>[s+T*p-w*m,n+T*m+w*p],y=Math.floor(this.time*2)%2===0,[g,v]=x(-9.5*u.scale.x,5),[_,S]=x(9.5*u.scale.x,5);if(this.glow(g,v,4,16724e3,y?.8:.25),this.glow(_,S,4,4259712,y?.8:.25),Math.floor(this.time*10)%12===0){let[T,w]=x(0,18);this.glow(T,w,5,16777215,.7)}if(t.muzzle>0){let T=t.muzzle/4,[w,E]=x(0,-13);this.glow(w,E,7*T,16773312,.9),this.glow(w,E,15*T,16752704,.35)}}drawHud(e){let t=e.sim,r=t.player,[s,n]=this.pos(r,e.alpha),o=this.hud,a=Math.floor(this.time*5)%2===0,l=(_,S,T,w)=>{if(o.moveTo(s+Math.cos(_)*25,n+Math.sin(_)*25),o.arc(s,n,25,_,S,S<_),o.stroke({width:1.4,color:0,alpha:.35}),T<=0)return;let R=_+(S-_)*Math.max(0,Math.min(1,T));o.moveTo(s+Math.cos(_)*25,n+Math.sin(_)*25),o.arc(s,n,25,_,R,S<_),o.stroke({width:1.6,color:w?16730666:16761707,alpha:w?a?.95:.4:.65})};l(Math.PI*.72,Math.PI*1.28,t.shields/t.maxShields,t.shields<t.maxShields*.3),l(Math.PI*.28,-Math.PI*.28,t.fuel/100,t.fuel<30);let c=Math.min(t.missiles,12);for(let _=0;_<c;_++)o.rect(s-c*1.25+_*2.5,n+29,1.4,3).fill({color:16761707,alpha:.7});let h=30,u=n+35;o.rect(s-h/2,u,h,2.2).fill({color:0,alpha:.45});let d=r.heat/100,p=r.overheated?a?16724e3:8396816:d>er[1]/100?16738858:16761707;o.rect(s-h/2,u,h*d,2.2).fill({color:p,alpha:.85});let m=r.heat>=er[0]&&r.heat<=er[1]&&!r.overheated;for(let _ of er)o.rect(s-h/2+h*_/100-.4,u-1.2,.8,4.6).fill({color:10479871,alpha:m?1:.5});for(let _ of r.locks){let S=t.hostiles.find(T=>T.id===_);if(S){let[T,w]=this.pos(S,e.alpha);this.brackets(o,T,w,Math.max(S.w,S.h)*.8+3,16769136,.95,this.time*2)}}if(r.missileHold>=_n)for(let S of[-1,1])o.moveTo(s,n-10).lineTo(s+S*(260*.8+40),n-10-260).stroke({width:.8,color:16769136,alpha:.18});let x=t.samLock;if(x>0){let _=34-20*x;this.brackets(o,s,n,_,16724e3,.5+.5*Math.sin(this.time*(8+x*30)),x*Math.PI)}let y="",g=t.corridorAt(r.y+r.h/2);t.enemyShots.some(_=>_.kind==="sam"&&_.decoy===null)?y="MISSILE \u2014 FLARE [C]":x>0?y="MISSILE LOCK":r.overheated?y="GUN OVERHEAT":t.shields<t.maxShields*.3?y="SHIELD LOW":t.fuel<30?y="FUEL LOW":(r.x-g.left<18||g.right-(r.x+r.w)<18)&&(y="TERRAIN"),this.warning.visible=y!==""&&(a||y==="TERRAIN"),y&&(this.warning.text=y,this.warning.position.set(s,n-34),this.warning.tint=y==="TERRAIN"?16761707:16738890,this.warning.position.set(s,n-44))}drawHitboxes(e){let t=this.debugGfx,r=e.sim.player;t.rect(r.x,r.y,r.w,r.h).stroke({width:1,color:65416});for(let s of e.sim.hostiles)t.rect(s.x,s.y,s.w,s.h).stroke({width:1,color:16724838});for(let s of e.sim.pickups)t.rect(s.x,s.y,s.w,s.h).stroke({width:1,color:6737151})}}});var Da=16.666666666666668,Pm=5,Oa=class{constructor(e){this.cb=e}accumulator=0;last=null;ticks=0;frame(e){this.last===null&&(this.last=e);let t=Math.min(e-this.last,250);this.last=e,this.accumulator+=t;let r=0;for(;this.accumulator>=Da&&r<Pm;)this.cb.tick(),this.ticks++,this.accumulator-=Da,r++;r===Pm&&(this.accumulator=Math.min(this.accumulator,Da)),this.cb.render(this.accumulator/Da,t)}resetClock(){this.last=null,this.accumulator=0}};function km(i){let e=0,t=r=>{i.frame(r),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)}pn();pn();At();var Ua=class{constructor(e=64){this.cellSize=e}cells=new Map;pool=[];out=[];stamp=new Set;key(e,t){return e+512<<11|t+1024}rebuild(e){for(let t of this.cells.values())t.length=0,this.pool.push(t);this.cells.clear();for(let t of e){let r=Math.floor(t.x/this.cellSize),s=Math.floor((t.x+t.w)/this.cellSize),n=Math.floor(t.y/this.cellSize),o=Math.floor((t.y+t.h)/this.cellSize);for(let a=r;a<=s;a++)for(let l=n;l<=o;l++){let c=this.key(a,l),h=this.cells.get(c);h||(h=this.pool.pop()??[],this.cells.set(c,h)),h.push(t)}}}query(e,t,r,s){this.out.length=0,this.stamp.clear();let n=Math.floor(e/this.cellSize),o=Math.floor((e+r)/this.cellSize),a=Math.floor(t/this.cellSize),l=Math.floor((t+s)/this.cellSize);for(let c=n;c<=o;c++)for(let h=a;h<=l;h++){let u=this.cells.get(this.key(c,h));if(u)for(let d of u)this.stamp.has(d)||(this.stamp.add(d),this.out.push(d))}return this.out}};bn();fr();di();pi();pi();function fi(i,e){for(let t of e){let r=xt[t.kind],s=-r.h-10-t.dy,n=i.corridorAt(s+r.h/2),o=16,a;t.kind==="turret"?a=t.side<0?n.left+1:n.right-r.w-1:t.kind==="gate"?a=t.side<0?n.left+Zi:n.right-r.w-Zi:a=n.left+o+(n.right-n.left-2*o-r.w)*t.f;let l=vn(i,t.kind,a,s);t.side&&(l.side=t.side),t.timer!==void 0&&(l.timer=t.timer),l.vx=0,i.hostiles.push(l)}}var $m={droneV:i=>fi(i,[.5,.35,.65,.2,.8].map((e,t)=>({kind:"drone",f:e,dy:Math.ceil(t/2)*26,timer:60+t*18}))),mineField:i=>{let e=i.rng.next()<.5?.25:.75,t=[];for(let r=0;r<3;r++)for(let s of[.1,.3,.5,.7,.9])Math.abs(s-(r===1?1-e:e))>.15&&t.push({kind:"mine",f:s,dy:r*70});fi(i,t)},turretAlley:i=>fi(i,[0,1,2,3].map(e=>({kind:"turret",f:0,dy:e*90,side:e%2?1:-1,timer:20+e*25}))),gunnerPincer:i=>fi(i,[{kind:"gunner",f:.12,dy:0},{kind:"gunner",f:.88,dy:0}]),tankColumn:i=>fi(i,[0,1,2].map(e=>({kind:"tank",f:.5+(e-1)*.12,dy:e*46,timer:80+e*30}))),samTrap:i=>fi(i,[{kind:"sam",f:.5,dy:20,timer:10},{kind:"flak",f:.15,dy:0},{kind:"flak",f:.85,dy:40}]),depotRun:i=>fi(i,[{kind:"depot",f:.2,dy:0},{kind:"depot",f:.8,dy:60},{kind:"depot",f:.5,dy:120},{kind:"drone",f:.5,dy:30},{kind:"drone",f:.3,dy:140}])};Qi();At();fr();ji();pi();di();ji();var eC=99,Xm=84,tC=za+(fn+20-Xm)+40,rC=50;function yt(i,e,t,r,s,n={}){let o=vn(i,e,0,-120);return Object.assign(o,{group:t,ox:r,oy:s,vx:0,vy:0},n),o.maxHp=o.hp=n.hp??xt[e].hp,i.hostiles.push(o),o}function Xa(i,e,t,r,s){let n=Dr(i,"gunship");return n.group=e,n.variant=t,n.side=r,n.hp=n.maxHp=s,t===2&&(n.w=36,n.h=36),r!==0&&(n.x+=r*60,n.px=n.x),n}function Ym(i,e){let t=i.nextId++,r={kind:e.boss,name:e.bossName,group:t,t:0,anchorY:-(Ha+tC),hold:!1,anchored:!1,escaped:!1,core:"gunship"};switch(i.bossState=r,e.boss){case"dustDevil":Xa(i,t,0,0,xt.gunship.hp);break;case"twinVipers":Xa(i,t,1,-1,55),Xa(i,t,1,1,55);break;case"sunhammer":Xa(i,t,2,0,220);break;case"dam":{r.core="dam",yt(i,"dam",t,0,0,{shielded:!0});for(let s of[.2,.5,.8])yt(i,"sluice",t,s,22);yt(i,"turret",t,.06,30,{side:-1,timer:60}),yt(i,"turret",t,.94,30,{side:1,timer:120});break}case"train":{r.core="engine",r.anchorY=-240,yt(i,"engine",t,0,0);for(let s=0;s<4;s++)yt(i,"traincar",t,0,44+s*40,{timer:40+s*35});break}case"radar":{r.core="dish",yt(i,"dish",t,0,0,{shielded:!0}),yt(i,"shieldgen",t,-64,26),yt(i,"shieldgen",t,64,26),yt(i,"shieldgen",t,0,-46),yt(i,"sam",t,-96,-18,{timer:120}),yt(i,"sam",t,96,-18,{timer:420}),yt(i,"flak",t,0,64,{timer:200});break}}i.emit({type:"bossEnter",name:e.bossName})}function Km(i){let e=i.bossState;if(!e)return"defeated";e.t++;let t=i.hostiles.filter(o=>o.group===e.group),r={left:0,right:0};switch(e.kind){case"dam":case"radar":{e.anchorY+=i.scrollSpeed;let o=Xm+(e.kind==="radar"?40:0);!e.hold&&e.anchorY>=o-rC&&(e.hold=!0),e.anchored=e.hold,i.corridorAt(e.anchorY+14,r);let a=r.right-r.left,l=(r.left+r.right)/2;for(let h of t)if(h.kind==="dam")h.x=r.left-6,h.w=a+12,h.y=e.anchorY;else if(e.kind==="dam")h.x=r.left+a*h.ox-h.w/2,h.y=e.anchorY+h.oy;else{let u=Math.min(1,a/300);h.x=l+h.ox*u-h.w/2,h.y=e.anchorY+h.oy-h.h/2+18}let c=t.filter(h=>h.kind==="sluice"||h.kind==="shieldgen").length;for(let h of t)(h.kind==="dam"||h.kind==="dish")&&h.shielded&&c===0&&(h.shielded=!1,i.emit({type:"shieldDown",x:h.x+h.w/2,y:h.y+h.h/2}));break}case"train":{let o=96+Math.sin(e.t*.008)*46;e.anchorY+=Math.max(-1.2,Math.min(2.2,(o-e.anchorY)*.05+(e.anchorY<0?2:0)));for(let a of t){a.y=e.anchorY+a.oy,i.corridorAt(a.y+a.h/2,r);let l=Math.sin((i.dist-a.oy)*.0016)*(r.right-r.left)*.22;a.x=(r.left+r.right)/2+l-a.w/2}break}default:for(let o of t)o.kind==="gunship"&&o.state===5&&(e.escaped=!0)}if(t.some(o=>o.kind===e.core))return"active";for(let o of t)i.emit({type:"explode",x:o.x+o.w/2,y:o.y+o.h/2,particles:18,big:!0,shake:6}),o.state=eC;i.hostiles=i.hostiles.filter(o=>o.group!==e.group);let n=e.escaped&&e.kind!=="sunhammer"&&!i.stats.bossKills.includes(e.group);return n||i.stats.bossesDefeated++,i.emit({type:"bossDown",name:e.name,escaped:n}),i.bossState=null,n?"escaped":"defeated"}xn();pi();var iC=1600,sC={width:360,amp:.4,narrow:.3,height:1.1},jm=i=>i===Yh?sC:Ke[i]?.canyon??$h,nC=200,qm=2e3;function Zm(i,e){return{mode:i,sector:e,lap:0,phase:"run",sectorTick:0,sectorStartDist:0,phaseTimer:0,nextSetPiece:0,segments:[{fromD:-1e9,sector:e}],reached:[e],sectorDamage:0}}var Ji=i=>Ke[i.course.sector],Ya=(i,e,t)=>i+(e-i)*t;function Qm(i,e){let t=i.segments,r=t.length-1;for(;r>0&&t[r].fromD>e;)r--;let s=jm(t[r].sector);if(r===0)return s;let n=jm(t[r-1].sector),o=Math.min(1,(e-t[r].fromD)/(t[r].blend??iC));if(o>=1)return s;let a=o*o*(3-2*o);return{width:Ya(n.width,s.width,a),amp:Ya(n.amp,s.amp,a),narrow:Ya(n.narrow,s.narrow,a),height:Ya(n.height,s.height,a)}}function Sn(i){let e=i.course;return e.phase!=="run"?1:Math.min(1,(i.dist-e.sectorStartDist)/Ji(i).length)}function ru(i){let e=i.course,t=Math.min(3,Math.floor(e.sectorTick/O.speed.every))*O.speed.step,r=O.speed.max+e.lap*.5;return Math.min(r,O.speed.start+e.sector*.22+e.lap*.4+t)}function oC(i,e){let t=i.course;t.sector=e,t.phase="run",t.sectorTick=0,t.sectorStartDist=i.dist,t.nextSetPiece=0,t.sectorDamage=0,t.reached.includes(e)||t.reached.push(e),t.segments.push({fromD:i.dist+j+120,sector:e}),i.spawnTimers={};let r=Ke[e];i.emit({type:"sectorStart",index:e,name:r.name,subtitle:r.subtitle})}function Jm(i){let e=i.course;if(e.sectorTick++,e.phase==="run"){i.dist-e.sectorStartDist>=Ji(i).length&&(e.phase="boss",e.phaseTimer=0,e.segments.push({fromD:i.dist+j+Ha,sector:Yh,blend:za}),Ym(i,Ji(i)));return}if(e.phase==="boss"){e.phaseTimer++;let r=Km(i);if(r==="active")return;i.stats.sectorsCleared++,e.sectorDamage===0&&i.stats.untouchedSectors++;let s=i.player;Fr(i,r==="defeated"?qm:qm/4,s.x+s.w/2,s.y-50,"SECTOR CLEAR"),i.emit({type:"sectorClear",index:e.sector,name:Ji(i).name});for(let n of["shield","fuel","missile"])$a(i,n);e.phase="clear",e.phaseTimer=nC;return}if(--e.phaseTimer>0)return;let t=e.sector===Ke.length-1;if(e.mode==="practice"||e.mode==="campaign"&&t){i.status="complete",i.emit({type:"runComplete"});return}t&&e.lap++,oC(i,t?0:e.sector+1)}function eg(i){let e=i.course;e.sectorStartDist=i.dist;let t=Ke[e.sector];i.emit({type:"sectorStart",index:e.sector,name:t.name,subtitle:t.subtitle})}pi();function tg(i){let e=Ji(i),t=i.course,r=t.sectorTick/60,s=t.phase==="boss",n=(1-Math.min(O.director.paceMax,r/O.director.paceSeconds*O.director.paceMax))*Math.pow(.85,t.lap),o=i.sinceHit<O.director.reliefTicks||i.shields<i.maxShields*.3?O.director.reliefRate:1;if(t.phase!=="clear")for(let a of e.rules){if(r<a.from||s&&!a.duringBoss)continue;let l=a.kind;if(i.spawnTimers[l]===void 0&&(i.spawnTimers[l]=i.rng.int(a.every[0])),i.spawnTimers[l]-=o,i.spawnTimers[l]>0)continue;let c=0;for(let h of i.hostiles)h.kind===a.kind&&h.group===0&&c++;c<a.max&&Dr(i,a.kind),i.spawnTimers[l]=i.rng.range(a.every[0],a.every[1])*n*(s?2:1)}if(t.phase==="run"){let a=e.setPieces[t.nextSetPiece];a&&Sn(i)>=a.at&&($m[a.wave]?.(i),t.nextSetPiece++),i.rng.next()<e.depots/3600&&Dr(i,"depot"),i.rng.next()<e.bridges/3600&&!i.features.some(l=>l.y<120)&&i.features.push({id:i.nextId++,kind:"bridge",y:-40,py:-40,passed:!1})}if(i.pickupSpawnTimer++,i.pickupSpawnTimer>O.economy.pickupInterval){let a=Object.entries({...O.economy.pickups,...e.pickups??{}}),l=a.reduce((u,[,d])=>u+d,0),c=i.rng.next()*l,h="fuel";for(let[u,d]of a){if(c<d){h=u;break}c-=d}$a(i,h),i.pickupSpawnTimer=0}}Va();ja();Gr();At();ja();xn();fr();var cC=180,hC=24,uC=50;function dC(i){let e=i.player;return{x:e.x+2,y:e.y+2,w:e.w-4,h:e.h-4}}function pC(i,e,t,r){let s=null,n=r;for(let o of i.flareObjs){let a=Math.hypot(o.x-e,o.y-t);a<n&&(n=a,s=o)}return s}function ag(i){let e=i.player,t=e.x+e.w/2,r=e.y+e.h/2,s=dC(i);st(i.enemyShots,n=>{let o=n.x+n.w/2,a=n.y+n.h/2;if(n.kind==="sam"||n.kind==="rocket"){if(n.kind==="sam"&&n.decoy===null){let p=pC(i,o,a,cC);p&&(n.decoy=p.id,i.emit({type:"decoyed",x:o,y:a}))}let l=t,c=r;if(n.decoy!==null){let p=i.flareObjs.find(m=>m.id===n.decoy);if(!p||Math.hypot(p.x-o,p.y-a)<8)return i.emit({type:"explode",x:o,y:a,particles:10,big:!1,shake:2}),!1;l=p.x,c=p.y}let h=Math.hypot(n.vx,n.vy),u=rs(Math.atan2(n.vy,n.vx),Math.atan2(c-a,l-o),n.kind==="sam"?.05:.02),d=n.kind==="sam"?Math.min(4.4,h*1.02):h;n.vx=Math.cos(u)*d,n.vy=Math.sin(u)*d}if(n.x+=n.vx,n.y+=n.vy,n.life--,n.kind==="sam"||n.kind==="rocket")for(let l=0;l<i.bullets.length;l++){let c=i.bullets[l];if(c.x>=n.x-3&&c.x<=n.x+n.w+3&&c.y>=n.y-3&&c.y<=n.y+n.h+3)return i.bullets.splice(l,1),i.emit({type:"explode",x:o,y:a,particles:10,big:!1,shake:3}),Fr(i,uC,o,a,"SHOT DOWN"),!1}if(e.invuln===0&&n.decoy===null&&qi(n,s))return i.emit({type:"explode",x:o,y:a,particles:n.kind==="bullet"?6:14,big:!1,shake:n.damage/3,damage:!0}),i.damagePlayer(n.damage,`shot:${n.kind}:${n.source}`),!1;if(!n.grazed&&e.invuln===0){let l=t-(n.x+n.w/2),c=r-(n.y+n.h/2);l*n.vx+c*n.vy<0&&Math.hypot(l,c)<hC&&(n.grazed=!0,Fr(i,50,n.x,n.y,"NEAR MISS"),i.stats.nearMisses++,jh(i),gn(i,4))}return n.life>0&&n.y<j+20&&n.y>-40&&n.x>-40&&n.x<be+40})}function lg(i){let e=i.player;st(i.hazards,t=>--t.timer>0?!0:(i.emit({type:"airburst",x:t.x,y:t.y,r:t.r}),e.invuln===0&&Math.hypot(e.x+e.w/2-t.x,e.y+e.h/2-t.y)<t.r+4&&i.damagePlayer(O.damage.flak,"flak"),!1))}function cg(i){st(i.flareObjs,e=>(e.x+=e.vx,e.y+=e.vy,e.vx*=.96,--e.life>0))}xn();fr();var gr={apache:{id:"apache",name:'AH-D "DUSK"',blurb:"Balanced attack gunship.",cost:0,agility:1,maxShields:100,missiles:10,heat:1},kestrel:{id:"kestrel",name:'LH-7 "KESTREL"',blurb:"Light scout: quicker and cooler-running, but thin armour.",cost:400,agility:1.2,maxShields:75,missiles:8,heat:.8},warthog:{id:"warthog",name:'HG-2 "WARTHOG"',blurb:"Heavy gunship: armoured, extra missiles, sluggish.",cost:400,agility:.85,maxShields:135,missiles:14,heat:1.15}},is={flarePack:{id:"flarePack",name:"FLARE PACK",blurb:"+2 flares at launch.",cost:150},missileRack:{id:"missileRack",name:"MISSILE RACK",blurb:"+5 missiles at launch.",cost:150},coolant:{id:"coolant",name:"COOLANT LOOP",blurb:"Active-cooling window 10 heat wider.",cost:200},reserveTank:{id:"reserveTank",name:"RESERVE TANK",blurb:"Burns 12% less fuel.",cost:250},magnet:{id:"magnet",name:"TOW HOOK",blurb:"Pickups drift toward you from further away.",cost:250}},wn=2,qa={airframe:"apache",perks:[]};function hg(i){return Math.floor(i.score/400)+i.sectorsCleared*25+i.bossesDefeated*60+i.medals*30}ji();ji();var I3=O.player.invulnTicks,fC=0,mC=()=>({shotsFired:0,shotsHit:0,missilesFired:0,kills:{},grazeTicks:0,nearMisses:0,flaresUsed:0,empsUsed:0,damageTaken:0,sectorsCleared:0,bossesDefeated:0,bossKills:[],untouchedSectors:0,bridges:0}),ss=class{constructor(e,t={}){this.seed=e;this.options={mode:t.mode??"endless",startSector:t.startSector??0,loadout:t.loadout??qa,assist:t.assist??!1},this.rng=new Ir(e),this.canyon=new La(e),this.course=Zm(this.options.mode,this.options.startSector),this.canyon.profileAt=r=>Qm(this.course,r),this.airframe=gr[this.options.loadout.airframe]??gr.apache,this.maxShields=this.shields=this.airframe.maxShields,this.options.assist&&(this.lives+=1),this.missiles=this.airframe.missiles,this.mods.agility=this.airframe.agility,this.mods.heat=this.airframe.heat;for(let r of this.options.loadout.perks)r==="flarePack"&&(this.flares+=2),r==="missileRack"&&(this.missiles+=5),r==="coolant"&&(this.mods.coolWiden=10),r==="reserveTank"&&(this.mods.fuelBurn=.88),r==="magnet"&&(this.mods.magnet=70);this.player={x:0,y:Na,w:16,h:16,px:0,py:Na,speed:4,invuln:0,flash:0,hurtGrace:0,muzzle:0,fireCooldown:0,heat:0,overheated:!1,fireHeld:!1,missileHold:0,missileHeld:!1,locks:[],ripple:[],rippleTimer:0,flareCooldown:0,spread:0,boosting:!1,steer:0},this.centerPlayer(),this.baseSpeed=this.scrollSpeed=ru(this),eg(this)}rng;canyon;events=[];hostileGrid=new Ua(64);options;airframe;status="running";tick=0;dist=0;prevDist=0;baseSpeed=O.speed.start;scrollSpeed=O.speed.start;score=0;lives=O.player.lives;fuel=100;maxShields=100;shields=100;missiles=O.player.missiles;flares=O.player.flares;emp=0;combo={count:0,timer:0,mult:1};grazeTicks=0;distScoreAcc=0;sinceHit=9999;course;bossState=null;stats=mC();mods={agility:1,heat:1,coolWiden:0,fuelBurn:1,magnet:0};player;hostiles=[];bullets=[];playerMissiles=[];pickups=[];enemyShots=[];hazards=[];flareObjs=[];features=[];spawnTimers={};pickupSpawnTimer=0;nextId=1;scratch={left:0,right:0};get timeSeconds(){return Math.floor(this.tick/60)}get boss(){let e=this.bossState;if(e)return this.hostiles.find(t=>t.group===e.group&&t.kind===e.core)}get bossBar(){let e=this.bossState;if(!e)return null;let t=0,r=0,s=!1;for(let n of this.hostiles)n.group===e.group&&(t+=Math.max(0,n.hp),r+=n.maxHp,s||=n.shielded);return{name:e.name,hp:t,maxHp:Math.max(1,r),shielded:s}}get samLock(){let e=0;for(let t of this.hostiles)t.kind==="sam"&&t.state===1&&(e=Math.max(e,t.charge));return e}distAt(e){return this.dist+(j-e)}corridorAt(e,t=this.scratch){return this.canyon.at(this.distAt(e),t)}centerPlayer(){let e=this.corridorAt(this.player.y+this.player.h/2);this.player.x=this.player.px=(e.left+e.right)/2-this.player.w/2}emit(e){this.events.push(e)}step(e){if(this.status!=="running")return;this.tick++,this.sinceHit++,this.prevDist=this.dist;let t=this.player;t.px=t.x,t.py=t.y;for(let s of[this.hostiles,this.bullets,this.playerMissiles,this.pickups,this.enemyShots,this.flareObjs])for(let n of s)n.px=n.x,n.py=n.y;for(let s of this.hazards)s.px=s.x,s.py=s.y;for(let s of this.features)s.py=s.y;this.baseSpeed=ru(this)*(this.options.assist?.8:1),t.boosting=e.boost&&this.fuel>5;let r=this.bossState?.hold?fC:this.baseSpeed+(t.boosting?O.speed.boost:0);this.scrollSpeed+=(r-this.scrollSpeed)*.06,this.dist+=this.scrollSpeed,Wm(this,e),this.status==="running"&&(Dm(this),Jm(this),this.status==="running"&&(tg(this),ng(this),ag(this),this.status==="running"&&(lg(this),this.status==="running"&&(Om(this),this.status==="running"&&(Lm(this),cg(this),gC(this),Im(this),this.fuel-=(O.economy.fuelBurn+(t.boosting?O.economy.boostFuelBurn:0))*this.mods.fuelBurn,this.fuel<=0&&this.loseLife(),(this.fuel<25||this.shields<this.maxShields*.25)&&this.tick%40===0&&this.emit({type:"alarm"}))))))}damagePlayer(e,t="unknown"){if(this.player.invuln>0||this.status!=="running")return!1;if(e>=5){if(this.player.hurtGrace>0)return!1;this.player.hurtGrace=O.player.hurtGrace}return this.shields-=e,this.stats.damageTaken+=e,this.course.sectorDamage+=e,e>=5&&(this.sinceHit=0,this.player.flash=6,this.emit({type:"playerHit",x:this.player.x+this.player.w/2,y:this.player.y+this.player.h/2,cause:t}),Wa(this)),this.shields<=0&&this.loseLife(),!0}loseLife(){if(this.lives--,this.emit({type:"lifeLost"}),Wa(this),this.lives<=0){this.lives=0,this.shields=Math.max(0,this.shields),this.status="over",this.emit({type:"gameOver"});return}this.shields=this.maxShields,this.fuel=100,this.hostiles=this.hostiles.filter(t=>t.group!==0),this.bullets=[],this.playerMissiles=[],this.enemyShots=[],this.hazards=[];let e=this.player;e.invuln=O.player.invulnTicks,e.locks.length=0,e.ripple.length=0,e.heat=0,e.overheated=!1,this.emit({type:"lockEnd"}),this.centerPlayer()}fingerprint(){let e=r=>r.toFixed(4),t=[this.tick,this.score,this.lives,e(this.fuel),e(this.shields),this.missiles,this.flares,e(this.emp),e(this.dist),e(this.player.x),e(this.player.y),e(this.player.heat),this.course.sector,this.course.phase];for(let r of this.hostiles)t.push(`${r.kind}:${e(r.x)},${e(r.y)},${r.hp},${r.state}`);for(let r of this.enemyShots)t.push(`${r.kind}:${e(r.x)},${e(r.y)}`);return t.join("|")}};function gC(i){let e=i.player,t=e.y+e.h/2;for(let r of i.features){let s=r.y;r.y+=i.scrollSpeed,!r.passed&&s<t&&r.y>=t&&(r.passed=!0,i.stats.bridges++,i.emit({type:"bridge",x:e.x+e.w/2,y:t}),i.score+=Math.round(250*i.combo.mult),i.emit({type:"score",x:e.x+e.w/2,y:t-20,amount:Math.round(250*i.combo.mult),label:"UNDER THE BRIDGE"}))}i.features=i.features.filter(r=>r.y<j+60)}var mi={master:.8,music:.6,sfx:.85,ambience:.6},Mn=i=>Math.max(0,Math.min(1,i))**2,Za=class{constructor(e){this.ctx=e;this.comp=e.createDynamicsCompressor(),this.comp.threshold.value=-18,this.comp.knee.value=12,this.comp.ratio.value=4,this.comp.attack.value=.004,this.comp.release.value=.2;let t=e.createGain();t.gain.value=.9,this.comp.connect(t).connect(e.destination),this.master=e.createGain(),this.master.connect(this.comp),this.duckNode=e.createGain(),this.duckNode.connect(this.master),this.buses={sfx:e.createGain(),ui:e.createGain(),music:e.createGain(),ambience:e.createGain()},this.buses.sfx.connect(this.master),this.buses.ui.connect(this.master),this.buses.music.connect(this.duckNode),this.buses.ambience.connect(this.duckNode),this.apply(0)}master;buses;duckNode;comp;muted=!1;vol={...mi};get now(){return this.ctx.currentTime}setVolumes(e){this.vol={...e},this.apply(.05)}setMuted(e){this.muted=e,this.apply(.05)}apply(e){let t=this.ctx.currentTime,r=(s,n)=>e?s.gain.setTargetAtTime(n,t,e):s.gain.value=n;r(this.master,this.muted?0:Mn(this.vol.master)),r(this.buses.sfx,Mn(this.vol.sfx)),r(this.buses.ui,Mn(this.vol.sfx)*.8),r(this.buses.music,Mn(this.vol.music)*2.2),r(this.buses.ambience,Mn(this.vol.ambience)*.8)}duck(e,t=.6){let r=this.duckNode.gain,s=this.ctx.currentTime;r.cancelScheduledValues(s),r.setValueAtTime(r.value,s),r.linearRampToValueAtTime(Math.max(.15,1-e),s+.02),r.setTargetAtTime(1,s+.08,t/3)}};var Qa=class{constructor(e){this.mix=e;let t=e.ctx,r=t.sampleRate*2;this.white=t.createBuffer(1,r,t.sampleRate),this.brown=t.createBuffer(1,r,t.sampleRate);let s=this.white.getChannelData(0),n=this.brown.getChannelData(0),o=0;for(let a=0;a<r;a++)s[a]=Math.random()*2-1,o=(o+.02*s[a])/1.02,n[a]=o*3.5}white;brown;voices=new Map;get noiseBuffers(){return{white:this.white,brown:this.brown}}allow(e,t,r){let s=this.mix.now,n=(this.voices.get(e)??[]).filter(o=>o>s);return n.length>=t?!1:(n.push(s+r),this.voices.set(e,n),!0)}out(e="sfx",t,r){let s=this.mix.ctx,n=this.mix.buses[e];if(t!==void 0){let o=s.createStereoPanner();o.pan.value=Math.max(-.85,Math.min(.85,t/800*2-1)),o.connect(n),n=o}if(r!==void 0){let o=s.createBiquadFilter();o.type="lowpass",o.frequency.value=r,o.connect(n),n=o}return n}tone(e){let t=this.mix.ctx,r=this.mix.now+(e.at??0),s=t.createOscillator(),n=t.createGain();s.type=e.type??"sine",s.frequency.setValueAtTime(e.freq,r),e.detune&&(s.detune.value=e.detune),e.to&&s.frequency.exponentialRampToValueAtTime(Math.max(20,e.to),r+e.dur);let o=e.vol??.2,a=e.attack??.004;n.gain.setValueAtTime(1e-4,r),n.gain.exponentialRampToValueAtTime(o,r+a),n.gain.exponentialRampToValueAtTime(1e-4,r+e.dur),s.connect(n).connect(this.out(e.bus,e.x,e.lp)),s.start(r),s.stop(r+e.dur+.05)}noise(e){let t=this.mix.ctx,r=this.mix.now+(e.at??0),s=t.createBufferSource();s.buffer=e.brown?this.brown:this.white,s.loop=!0;let n=s,o=(c,h,u=.7)=>{let d=t.createBiquadFilter();return d.type=c,d.frequency.setValueAtTime(h,r),d.Q.value=u,n.connect(d),n=d,d};if(e.hp&&o("highpass",e.hp),e.bp){let c=o("bandpass",e.bp,e.q??1.2);e.bpTo&&c.frequency.exponentialRampToValueAtTime(e.bpTo,r+e.dur)}e.lp&&o("lowpass",e.lp);let a=t.createGain(),l=e.vol??.2;a.gain.setValueAtTime(1e-4,r),a.gain.exponentialRampToValueAtTime(l,r+(e.attack??.003)),a.gain.exponentialRampToValueAtTime(1e-4,r+e.dur),n.connect(a).connect(this.out(e.bus,e.x)),s.start(r,Math.random()*1.5),s.stop(r+e.dur+.05)}gun(e){if(!this.allow("gun",3,.06))return;let t=1+(Math.random()-.5)*.08;this.noise({dur:.05,vol:.16,bp:2600*t,q:.9,x:e}),this.tone({freq:140*t,to:70,dur:.06,type:"sine",vol:.18,x:e})}missile(e){this.noise({dur:.5,vol:.18,bp:600,bpTo:2400,q:.8,x:e,attack:.02}),this.tone({freq:180,to:70,dur:.35,type:"sawtooth",vol:.07,x:e,lp:900})}explosion(e,t,r){if(!this.allow("boom",6,.4))return;let s=1/(1+r/180),n=280+3200*s,o=(.2+.25*Math.min(1.5,e)*(.5+.5*s))*2.2;this.noise({dur:.02,vol:o*.6*s,hp:2500,x:t}),this.noise({dur:.35+.35*e,vol:o,lp:n,brown:!0,x:t,attack:.006}),this.tone({freq:70+40*s,to:28,dur:.3+.3*e,type:"sine",vol:Math.min(.9,o*.6),x:t}),e>=1.4&&this.noise({dur:1.2,vol:o*.35,lp:500,brown:!0,x:t,at:.08,attack:.1})}armourHit(e){this.allow("ping",3,.05)&&(this.tone({freq:1500+Math.random()*600,to:900,dur:.05,type:"square",vol:.05,x:e}),this.noise({dur:.03,vol:.06,hp:3500,x:e}))}block(e){this.allow("block",2,.05)&&this.tone({freq:2400,to:1100,dur:.05,type:"sawtooth",vol:.04,x:e,lp:4e3})}enemyShot(e,t){e==="shell"?this.tone({freq:150,to:55,dur:.22,type:"square",vol:.09,x:t,lp:700}):e==="bullet"&&this.allow("epew",3,.08)&&this.tone({freq:760,to:360,dur:.07,type:"triangle",vol:.06,x:t})}telegraph(e,t){switch(e){case"drone":this.tone({freq:1200,to:1900,dur:.12,vol:.06,x:t});break;case"gunner":this.tone({freq:500,to:1500,dur:.6,type:"triangle",vol:.07,x:t,attack:.3});break;case"turret":case"traincar":this.tone({freq:1500,dur:.6,type:"sine",vol:.04,x:t,attack:.1});break;case"tank":case"engine":this.noise({dur:.18,vol:.12,bp:380,q:3,x:t}),this.tone({freq:110,dur:.12,type:"square",vol:.05,x:t,lp:500});break;case"mine":this.tone({freq:1900,dur:.07,type:"square",vol:.05,x:t});break;case"gunship":this.tone({freq:196,dur:.45,type:"sawtooth",vol:.08,x:t,lp:1400,detune:8}),this.tone({freq:294,dur:.45,type:"sawtooth",vol:.06,x:t,lp:1400,detune:-8});break;case"dish":this.tone({freq:400,to:1600,dur:.5,vol:.05,x:t});break}}samLaunch(e){this.noise({dur:.9,vol:.22,lp:1100,brown:!0,x:e,attack:.03}),this.tone({freq:260,to:900,dur:.7,type:"sawtooth",vol:.06,x:e,lp:1800})}flakMark(e){this.tone({freq:90,to:48,dur:.16,vol:.18,x:e})}shieldDown(e){this.tone({freq:900,to:70,dur:.9,type:"sawtooth",vol:.09,x:e,lp:2200}),this.noise({dur:.6,vol:.06,hp:4e3,x:e})}pickup(e,t){let r=e==="fuel"?523:e==="shield"?659:e==="missile"?587:e==="flare"?784:698;[1,1.25,1.5].forEach((s,n)=>this.tone({freq:r*s,dur:.12,type:"sine",vol:.12,x:t,at:n*.05}))}scrape(e){this.allow("scrape",2,.1)&&this.noise({dur:.1,vol:.08,bp:2600,q:.6,x:e})}nearMiss(e){this.allow("whoosh",2,.16)&&this.noise({dur:.16,vol:.09,bp:3200,bpTo:700,q:1.5,x:e})}bridge(e){this.noise({dur:.5,vol:.18,bp:260,bpTo:900,q:1,brown:!0,x:e,attack:.08})}flare(e){this.tone({freq:300,to:120,dur:.06,vol:.12,x:e}),this.noise({dur:.45,vol:.12,hp:4500,x:e,attack:.02})}decoyed(e){this.tone({freq:1100,to:420,dur:.22,vol:.08,x:e})}overheat(e){this.noise({dur:.6,vol:.13,hp:5e3,x:e,attack:.02}),this.tone({freq:150,to:90,dur:.12,type:"square",vol:.08,x:e,lp:600})}coolPerfect(e){this.tone({freq:1319,dur:.09,vol:.09,x:e}),this.tone({freq:1760,dur:.14,vol:.08,x:e,at:.05})}paint(e,t){let r=[0,2,4,7,9,12];this.tone({freq:880*Math.pow(2,r[Math.min(e,r.length-1)]/12),dur:.07,type:"square",vol:.06,x:t,lp:3500})}emp(e){this.tone({freq:2200,to:120,dur:.8,vol:.12,x:e}),this.tone({freq:70,to:30,dur:1,vol:.25,x:e}),this.noise({dur:.9,vol:.18,lp:900,brown:!0,x:e,attack:.02})}combo(e){this.tone({freq:660*(1+e/6),to:660*(1+e/6)*1.5,dur:.12,type:"triangle",vol:.08,bus:"ui"})}comboBreak(){this.tone({freq:420,to:160,dur:.28,type:"triangle",vol:.08,bus:"ui"})}alarm(){this.tone({freq:660,to:560,dur:.1,type:"square",vol:.06,bus:"ui",lp:2500})}ui(e){switch(e){case"move":this.tone({freq:1400,dur:.03,type:"square",vol:.03,bus:"ui",lp:3e3});break;case"select":this.tone({freq:880,to:1320,dur:.08,type:"triangle",vol:.08,bus:"ui"});break;case"back":this.tone({freq:700,to:440,dur:.08,type:"triangle",vol:.07,bus:"ui"});break;case"buy":[523,659,784,1047].forEach((t,r)=>this.tone({freq:t,dur:.12,vol:.08,bus:"ui",at:r*.05}));break;case"start":this.tone({freq:440,to:880,dur:.15,type:"square",vol:.08,bus:"ui",lp:3e3});break}}};var Ja=class{constructor(e,t){this.mix=e;let r=e.ctx;this.out=r.createGain(),this.out.gain.value=0,this.pan=r.createStereoPanner(),this.out.connect(this.pan).connect(e.buses.sfx);let s=r.createBufferSource();s.buffer=t,s.loop=!0,this.bp=r.createBiquadFilter(),this.bp.type="bandpass",this.bp.frequency.value=180,this.bp.Q.value=.9;let n=r.createGain();n.gain.value=.5,this.lfo=r.createOscillator(),this.lfo.frequency.value=5;let o=r.createWaveShaper(),a=new Float32Array(256);for(let u=0;u<256;u++){let d=u/127.5-1;a[u]=Math.pow(Math.max(0,d),3)*.9}o.curve=a,this.lfo.connect(o).connect(n.gain);let l=r.createGain();l.gain.value=.55,s.connect(this.bp).connect(n).connect(l).connect(this.out),this.hum=r.createOscillator(),this.hum.type="sawtooth",this.hum.frequency.value=62;let c=r.createBiquadFilter();c.type="lowpass",c.frequency.value=220;let h=r.createGain();h.gain.value=.09,this.hum.connect(c).connect(h).connect(this.out),this.whine=r.createOscillator(),this.whine.frequency.value=2100,this.whineGain=r.createGain(),this.whineGain.gain.value=.004,this.whine.connect(this.whineGain).connect(this.out),s.start(),this.lfo.start(),this.hum.start(),this.whine.start()}out;pan;lfo;hum;whine;whineGain;bp;update(e,t,r,s){let n=this.mix.now,o=4.2+t*.75+(s?1.4:0);this.lfo.frequency.setTargetAtTime(o,n,.3),this.bp.frequency.setTargetAtTime(150+t*22,n,.3),this.hum.frequency.setTargetAtTime(55+t*9+(s?12:0),n,.3),this.whine.frequency.setTargetAtTime(1900+t*120+(s?500:0),n,.2),this.whineGain.gain.setTargetAtTime(s?.012:.004,n,.2),this.pan.pan.setTargetAtTime(Math.max(-.6,Math.min(.6,r/800*2-1)),n,.08),this.out.gain.setTargetAtTime(e?.24:0,n,e?.3:.5)}},el=class{constructor(e){this.mix=e;let t=e.ctx;this.osc=t.createOscillator(),this.osc.type="square",this.osc.frequency.value=1e3;let r=t.createBiquadFilter();r.type="lowpass",r.frequency.value=3200,this.out=t.createGain(),this.out.gain.value=0;let s=t.createGain();s.gain.value=.5,this.lfo=t.createOscillator(),this.lfo.type="square",this.lfo.frequency.value=6,this.depth=t.createGain(),this.depth.gain.value=.5,this.lfo.connect(this.depth).connect(s.gain),this.osc.connect(r).connect(s).connect(this.out).connect(e.buses.ui),this.osc.start(),this.lfo.start()}osc;lfo;depth;out;update(e,t){let r=this.mix.now,s=t?1:e;this.out.gain.setTargetAtTime(s>0?.05:0,r,.03),this.lfo.frequency.setTargetAtTime(t?22:5+e*13,r,.05),this.osc.frequency.setTargetAtTime(t?1450:1e3+e*300,r,.05)}};var su=[{wind:.35,gust:.4,hiss:0,insects:0,birds:0,hawk:.6},{wind:.5,gust:.6,hiss:0,insects:0,birds:0,hawk:.3},{wind:.3,gust:.2,hiss:.05,insects:0,birds:0,hawk:.2},{wind:.9,gust:1,hiss:.6,insects:0,birds:0,hawk:0},{wind:.25,gust:.3,hiss:0,insects:.8,birds:0,hawk:0},{wind:.3,gust:.3,hiss:0,insects:.1,birds:.8,hawk:.3}],tl=class{constructor(e,t,r){this.mix=e;let s=e.ctx,n=e.buses.ambience,o=s.createBufferSource();o.buffer=r,o.loop=!0,this.windBp=s.createBiquadFilter(),this.windBp.type="bandpass",this.windBp.frequency.value=400,this.windBp.Q.value=.6,this.windGain=s.createGain(),this.windGain.gain.value=0,o.connect(this.windBp).connect(this.windGain).connect(n);let a=s.createBufferSource();a.buffer=t,a.loop=!0;let l=s.createBiquadFilter();l.type="highpass",l.frequency.value=3500,this.hissGain=s.createGain(),this.hissGain.gain.value=0,a.connect(l).connect(this.hissGain).connect(n),o.start(),a.start(0,.7)}windGain;windBp;hissGain;profile=su[0];phase=0;setSector(e){this.profile=su[Math.max(0,Math.min(su.length-1,e))]}update(e){let t=this.profile,r=this.mix.now;this.phase+=1/60;let s=.5+.5*Math.sin(this.phase*.31)*Math.sin(this.phase*.13+1.7),n=e?t.wind*(1-t.gust*.6+t.gust*.6*s):0;this.windGain.gain.setTargetAtTime(n*.5,r,.4),this.windBp.frequency.setTargetAtTime(260+500*s*(.4+t.gust),r,.6),this.hissGain.gain.setTargetAtTime(e?t.hiss*(.04+.05*s):0,r,.4),e&&(Math.random()<t.insects*.02&&this.insect(),Math.random()<t.birds*.006&&this.bird(),Math.random()<t.hawk*.0015&&this.hawk())}chirp(e,t,r,s,n,o){let a=this.mix.ctx,l=this.mix.now+n,c=a.createOscillator(),h=a.createGain(),u=a.createStereoPanner();c.frequency.setValueAtTime(e,l),c.frequency.exponentialRampToValueAtTime(t,l+r),h.gain.setValueAtTime(1e-4,l),h.gain.exponentialRampToValueAtTime(s,l+r*.2),h.gain.exponentialRampToValueAtTime(1e-4,l+r),u.pan.value=o,c.connect(h).connect(u).connect(this.mix.buses.ambience),c.start(l),c.stop(l+r+.02)}insect(){let e=4200+Math.random()*1500,t=Math.random()*1.6-.8;for(let r=0;r<3+Math.floor(Math.random()*4);r++)this.chirp(e,e*.97,.03,.012,r*.06,t)}bird(){let e=2400+Math.random()*1200,t=Math.random()*1.6-.8;this.chirp(e,e*1.4,.08,.015,0,t),this.chirp(e*1.2,e*.8,.12,.012,.12,t)}hawk(){let e=Math.random()*1.6-.8;this.chirp(2600,1700,1.1,.012,0,e)}};var Ur=i=>440*Math.pow(2,(i-69)/12),xC={minor:[0,2,3,5,7,8,10],phrygian:[0,1,3,5,7,8,10],phrygianDominant:[0,1,4,5,7,8,10],dorian:[0,2,3,5,7,9,10],major:[0,2,4,5,7,9,11]};function Ht(i,e){let t=xC[i.mode],r=Math.floor(e/t.length),s=(e%t.length+t.length)%t.length;return i.root+r*12+t[s]}function yC(i){let e=i>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}var rl=[[0,5,6,0],[0,3,1,0],[0,6,5,4]];function ug(i,e,t){let r=Ht(i,e),s=Ht(i,e+4),n=new Array(16).fill(null);for(let o=0;o<16;o+=4)n[o]=r;return t>.3&&(n[6]=r,n[14]=r+12),t>.6&&(n[3]=s,n[10]=r,n[11]=r+12),n}function dg(i,e,t,r){let s=yC(t*977+e*131),n=new Array(16).fill(null),o=[0,2,4,7].map(c=>e+c),a=r>.5?[0,3,6,8,10,12,14]:[0,6,8,12],l=o[0];for(let c of a){if(s()<.2)continue;let h=s()<.7?o[Math.min(o.length-1,Math.max(0,o.indexOf(l)+(s()<.5?-1:1)))]:o[Math.floor(s()*o.length)];l=h,n[c]=Ht(i,h)+24}return n}function pg(i,e){let t=Array.from({length:16},()=>[]);t[0].push("k"),t[6].push("k"),t[8].push("s"),(i>.55||e)&&(t[10].push("k"),t[12].push("s")),e&&(t[4].push("t"),t[14].push("t"),t[15].push("t"));for(let r=0;r<16;r+=i>.7||e?1:2)t[r].push("h");return t}function fg(i,e){let t=(r,s)=>Math.max(0,Math.min(1,(i-r)/(s-r)));return{drone:.6+.4*(1-t(.6,1)),bass:e?1:t(.15,.35),drums:e?1:t(.4,.6),lead:e?.8:t(.6,.8)}}var mg=[{root:38,mode:"minor",bpm:84},{root:40,mode:"phrygian",bpm:90},{root:45,mode:"minor",bpm:96},{root:37,mode:"phrygianDominant",bpm:100},{root:41,mode:"minor",bpm:78},{root:38,mode:"major",bpm:104}],nu={root:38,mode:"dorian",bpm:72},il=class{constructor(e,t){this.mix=e;this.noise=t;let r=e.ctx;this.out=r.createGain(),this.out.gain.value=0,this.out.connect(e.buses.music);let s=()=>{let u=r.createGain();return u.gain.value=0,u.connect(this.out),u};this.layers={drone:s(),bass:s(),drums:s(),lead:s()},this.echoIn=r.createGain();let n=r.createDelay(2);n.delayTime.value=.32;let o=r.createGain();o.gain.value=.38;let a=r.createBiquadFilter();a.type="lowpass",a.frequency.value=2200,this.echoIn.connect(n).connect(a).connect(o).connect(n),a.connect(this.layers.lead),this.droneLp=r.createBiquadFilter(),this.droneLp.type="lowpass",this.droneLp.frequency.value=500,this.droneLp.Q.value=2;let l=r.createGain();l.gain.value=.018,this.droneLp.connect(l).connect(this.layers.drone);for(let[u,d]of[[0,-6],[0,7],[7,3],[12,-4]]){let p=r.createOscillator();p.type="sawtooth",p.detune.value=d,p.frequency.value=Ur(this.key.root+u-12),p.connect(this.droneLp),p.start(),this.droneOscs.push(p)}let c=r.createOscillator();c.frequency.value=.07;let h=r.createGain();h.gain.value=260,c.connect(h).connect(this.droneLp.frequency),c.start()}layers;out;echoIn;droneOscs=[];droneLp;key=nu;nextTime=0;step=0;bar=0;progression=rl[0];bass=[];lead=[];drums=[];intensity=0;boss=!1;menu=!0;playing=!1;timer=null;seed=1;start(){this.playing||(this.playing=!0,this.nextTime=this.mix.now+.1,this.out.gain.setTargetAtTime(1,this.mix.now,.8),typeof setInterval<"u"&&(this.timer=setInterval(()=>this.scheduleUntil(this.mix.now+.15),25)))}setPaused(e){this.out.gain.setTargetAtTime(e?.25:1,this.mix.now,.3)}stop(){this.playing=!1,this.timer&&clearInterval(this.timer),this.timer=null,this.out.gain.setTargetAtTime(0,this.mix.now,.5)}setKey(e,t,r=!1){this.key=e,this.seed=t,this.menu=r,this.progression=rl[t%rl.length];let s=this.mix.now;this.droneOscs.forEach((n,o)=>n.frequency.setTargetAtTime(Ur(e.root+[0,0,7,12][o]-12),s,1.2))}setIntensity(e,t){this.intensity=e,this.boss=t;let r=this.menu?{drone:.9,bass:0,drums:0,lead:.55}:fg(e,t),s=this.mix.now;for(let n of Object.keys(r))this.layers[n].gain.setTargetAtTime(r[n],s,.8)}scheduleUntil(e){for(this.nextTime<this.mix.now-.2&&(this.nextTime=this.mix.now+.05);this.nextTime<e;)this.step===0&&this.newBar(),this.playStep(this.step,this.nextTime),this.nextTime+=60/this.key.bpm/4,this.step=(this.step+1)%16}newBar(){let e=this.progression[this.bar%this.progression.length];this.bass=ug(this.key,e,this.intensity),this.lead=dg(this.key,e,this.seed+Math.floor(this.bar/4),this.menu?.2:this.intensity),this.drums=pg(this.intensity,this.boss),this.bar++}playStep(e,t){let r=this.bass[e];r!=null&&!this.menu&&this.pluckBass(Ur(r),t);let s=this.lead[e];if(s!=null&&this.twang(Ur(s),t,this.menu?.9:.45),!this.menu)for(let n of this.drums[e]??[])this.drum(n,t)}pluckBass(e,t){let r=this.mix.ctx,s=r.createOscillator();s.type="sawtooth",s.frequency.value=e;let n=r.createBiquadFilter();n.type="lowpass",n.frequency.setValueAtTime(900,t),n.frequency.exponentialRampToValueAtTime(160,t+.22);let o=r.createGain();o.gain.setValueAtTime(1e-4,t),o.gain.exponentialRampToValueAtTime(.16,t+.01),o.gain.exponentialRampToValueAtTime(1e-4,t+.3),s.connect(n).connect(o).connect(this.layers.bass),s.start(t),s.stop(t+.32)}twang(e,t,r){let s=this.mix.ctx,n=s.createOscillator();n.type="sawtooth",n.frequency.value=e;let o=s.createOscillator();o.frequency.value=5.5;let a=s.createGain();a.gain.setValueAtTime(0,t),a.gain.linearRampToValueAtTime(e*.006,t+r*.6),o.connect(a).connect(n.frequency);let l=s.createBiquadFilter();l.type="bandpass",l.frequency.setValueAtTime(e*3.2,t),l.frequency.exponentialRampToValueAtTime(e*1.6,t+r),l.Q.value=1.6;let c=s.createGain();c.gain.setValueAtTime(1e-4,t),c.gain.exponentialRampToValueAtTime(.13,t+.006),c.gain.exponentialRampToValueAtTime(1e-4,t+r),n.connect(l).connect(c),c.connect(this.layers.lead),c.connect(this.echoIn),n.start(t),o.start(t),n.stop(t+r+.05),o.stop(t+r+.05)}drum(e,t){let r=this.mix.ctx,s=this.layers.drums,n=(a,l,c,h)=>{let u=r.createOscillator();u.frequency.setValueAtTime(a,t),u.frequency.exponentialRampToValueAtTime(l,t+c);let d=r.createGain();d.gain.setValueAtTime(h,t),d.gain.exponentialRampToValueAtTime(1e-4,t+c),u.connect(d).connect(s),u.start(t),u.stop(t+c+.02)},o=(a,l,c,h=0)=>{let u=r.createBufferSource();u.buffer=this.noise;let d=r.createBiquadFilter();d.type=h?"bandpass":"highpass",d.frequency.value=h||a;let p=r.createGain();p.gain.setValueAtTime(c,t),p.gain.exponentialRampToValueAtTime(1e-4,t+l),u.connect(d).connect(p).connect(s),u.start(t,Math.random()),u.stop(t+l+.02)};switch(e){case"k":n(120,42,.28,.32);break;case"s":o(0,.09,.14,1900),n(330,220,.05,.05);break;case"t":n(170,95,.22,.2);break;case"h":o(6500,.035,.035);break}}chord(e,t,r,s,n="sawtooth",o=1800){let a=this.mix.ctx,l=a.createBiquadFilter();l.type="lowpass",l.frequency.setValueAtTime(o*.3,t),l.frequency.exponentialRampToValueAtTime(o,t+r*.3);let c=a.createGain();c.gain.setValueAtTime(1e-4,t),c.gain.exponentialRampToValueAtTime(s,t+.04),c.gain.exponentialRampToValueAtTime(1e-4,t+r),l.connect(c).connect(this.out);for(let h of e)for(let u of[-7,7]){let d=a.createOscillator();d.type=n,d.detune.value=u,d.frequency.value=Ur(h),d.connect(l),d.start(t),d.stop(t+r+.05)}}bossEnter(){let e=this.mix.now+.02,t=this.key;this.chord([Ht(t,0),Ht(t,0)+1,Ht(t,4)],e,2.2,.12,"sawtooth",1200);for(let r=0;r<12;r++){let s=e+r*.06,n=this.mix.ctx,o=n.createOscillator(),a=n.createGain();o.frequency.setValueAtTime(110,s),o.frequency.exponentialRampToValueAtTime(70,s+.15),a.gain.setValueAtTime(.04+r*.012,s),a.gain.exponentialRampToValueAtTime(1e-4,s+.15),o.connect(a).connect(this.out),o.start(s),o.stop(s+.17)}}bossDown(){let e=this.mix.now+.05,t=this.key;this.chord([Ht(t,7),Ht(t,9)+12,Ht(t,11)+12],e,2.6,.1,"triangle",3e3)}sectorClear(){let e=this.mix.now+.05,t=this.key;[0,2,4,7].forEach((r,s)=>this.twang(Ur(Ht(t,r)+24),e+s*.12,.9))}gameOver(){let e=this.mix.now+.05;[62,60,57,53].forEach((t,r)=>this.twang(Ur(t),e+r*.28,1.2))}complete(){let e=this.mix.now+.05;this.chord([50,54,57,62,66],e,4,.1,"triangle",3500)}};function gg(i){if(i.bossState)return 1;let e=0;for(let n of i.hostiles)n.y>-10&&(e+=n.kind==="drone"||n.kind==="mine"||n.kind==="depot"?.07:.14);e+=i.enemyShots.length*.03+i.hazards.length*.08+i.samLock*.3;let t=i.shields<i.maxShields*.3?.25:0,r=Math.min(.2,(i.combo.mult-1)*.08),s=.12+i.course.sector*.04;return Math.max(0,Math.min(1,s+e+t+r))}function xg(i,e){let t=e>i?.04:.006;return i+(e-i)*t}function bC(i){let e=new Za(i),t=new Qa(e),{white:r,brown:s}=t.noiseBuffers;return{mixer:e,sfx:t,rotor:new Ja(e,r),lock:new el(e),ambience:new tl(e,r,s),music:new il(e,r)}}var sl=class{constructor(e=!1,t=mi){this.muted=e;this.volumes=t}ctx=null;g=null;intensity=0;keyFor=-2;tick=0;init(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}try{let e=window.AudioContext??window.webkitAudioContext;this.ctx=new e({latencyHint:"interactive"})}catch{return}this.g=bC(this.ctx),this.g.mixer.setVolumes(this.volumes),this.g.mixer.setMuted(this.muted),this.g.music.start()}setMuted(e){this.muted=e,this.g?.mixer.setMuted(e)}setVolumes(e){this.volumes=e,this.g?.mixer.setVolumes(e)}ui(e){this.g?.sfx.ui(e)}runEnd(e){this.g&&(e==="over"&&this.g.music.gameOver(),e==="complete"&&this.g.music.complete())}handle(e,t){let r=this.g;if(!r)return;let s=r.sfx,n=t.player,o=n.x+n.w/2,a=n.y+n.h/2,l=(c,h)=>Math.hypot(c-o,h-a);switch(e.type){case"shoot":s.gun(e.x);break;case"missile":s.missile(e.x);break;case"hit":s.armourHit(e.x);break;case"explode":{let c=e.big?1.5:e.damage?1.1:1;s.explosion(c,e.x,e.damage?0:l(e.x,e.y)),(e.big||e.damage)&&r.mixer.duck(e.damage?.5:.35,.6);break}case"airburst":s.explosion(1,e.x,l(e.x,e.y));break;case"pickup":s.pickup(e.kind,e.x);break;case"scrape":s.scrape(e.x);break;case"lifeLost":s.explosion(2,o,0),r.mixer.duck(.85,1.4);break;case"alarm":s.alarm();break;case"enemyShot":s.enemyShot(e.kind,e.x);break;case"telegraph":s.telegraph(e.kind,e.x);break;case"samLaunch":s.samLaunch(e.x);break;case"flakMark":s.flakMark(e.x);break;case"flare":s.flare(e.x);break;case"decoyed":s.decoyed(e.x);break;case"paint":s.paint(e.count,e.x);break;case"overheat":s.overheat(o);break;case"coolPerfect":s.coolPerfect(e.x);break;case"block":s.block(e.x);break;case"emp":s.emp(e.x),r.mixer.duck(.7,1);break;case"combo":s.combo(e.mult);break;case"comboBreak":s.comboBreak();break;case"score":e.label==="NEAR MISS"&&s.nearMiss(e.x);break;case"bridge":s.bridge(e.x);break;case"shieldDown":s.shieldDown(e.x);break;case"bossEnter":r.music.bossEnter(),r.mixer.duck(.3,2);break;case"bossDown":r.music.bossDown();break;case"sectorClear":r.music.sectorClear();break;case"runComplete":r.music.complete();break}}update(e,t){let r=this.g;if(!r)return;this.tick++;let s=t==="run",n=e.player;r.rotor.update(s,e.scrollSpeed,n.x+n.w/2,n.boosting),r.lock.update(s?e.samLock:0,s&&e.enemyShots.some(a=>a.kind==="sam"&&a.decoy===null)),r.ambience.setSector(e.course.sector),r.ambience.update(t!=="off");let o=t==="menu"?-1:e.course.sector;o!==this.keyFor&&(this.keyFor=o,o===-1?r.music.setKey(nu,7,!0):r.music.setKey(mg[o],e.seed+o,!1)),this.intensity=s?xg(this.intensity,gg(e)):this.intensity*.99,this.tick%10===0&&r.music.setIntensity(this.intensity,s&&!!e.bossState),r.music.setPaused(t==="paused")}get debugIntensity(){return this.intensity}};var _C={left:!1,right:!1,up:!1,down:!1,fire:!1,missile:!1,flare:!1,emp:!1,boost:!1},Nr=()=>({..._C});var al={left:["ArrowLeft","KeyA","Comma"],right:["ArrowRight","KeyD","Period"],up:["ArrowUp","KeyW"],down:["ArrowDown","KeyS"],fire:["KeyZ","KeyJ"],missile:["KeyX","KeyK"],flare:["KeyC","KeyL"],emp:["KeyV","Semicolon"],boost:["ShiftLeft","ShiftRight"],start:["Space","Enter"],pause:["Escape","KeyP"],mute:["KeyM"],debug:["Backquote"],quality:["KeyQ"]},Ie={a:0,b:1,x:2,y:3,lb:4,rb:5,lt:6,rt:7,select:8,start:9,l3:10,up:12,down:13,left:14,right:15},nl=.35,ol=class{constructor(e,t){this.onPress=t;this.setBindings(e),window.addEventListener("keydown",this.handleDown),window.addEventListener("keyup",this.handleUp),window.addEventListener("blur",this.clear),document.addEventListener("visibilitychange",this.clear)}down=new Set;capture=null;tapped=new Set;byCode=new Map;padPrev=[];state=Nr();setBindings(e){this.byCode.clear();for(let[t,r]of Object.entries(e))for(let s of r)this.byCode.set(s,[...this.byCode.get(s)??[],t])}captureNext(e){this.capture=e}handleDown=e=>{if(this.capture){e.preventDefault();let r=this.capture;this.capture=null,r(e.code);return}let t=this.byCode.get(e.code);if(t&&(e.preventDefault(),!e.repeat)){this.down.add(e.code),this.tapped.add(e.code);for(let r of t)this.onPress(r)}};handleUp=e=>{this.down.delete(e.code)};clear=()=>{this.down.clear(),this.tapped.clear()};held(e){for(let t of this.down)if(this.byCode.get(t)?.includes(e))return!0;for(let t of this.tapped)if(this.byCode.get(t)?.includes(e))return!0;return!1}sample(){let e=this.state;e.left=this.held("left"),e.right=this.held("right"),e.fire=this.held("fire"),e.missile=this.held("missile"),e.up=this.held("up"),e.down=this.held("down"),e.flare=this.held("flare"),e.emp=this.held("emp"),e.boost=this.held("boost"),this.tapped.clear();let t=navigator.getGamepads?.()??[];for(let r of t){if(!r||!r.connected)continue;let s=l=>!!r.buttons[l]?.pressed,n=r.axes[0]??0;e.left||=s(Ie.left)||n<-nl,e.right||=s(Ie.right)||n>nl;let o=r.axes[1]??0;e.up||=s(Ie.up)||o<-nl,e.down||=s(Ie.down)||o>nl,e.fire||=s(Ie.a)||s(Ie.rt),e.missile||=s(Ie.x)||s(Ie.rb),e.flare||=s(Ie.y)||s(Ie.lb),e.emp||=s(Ie.b),e.boost||=s(Ie.lt)||s(Ie.l3);let a=[[Ie.start,"start"],[Ie.select,"pause"],[Ie.a,"fire"],[Ie.b,"emp"],[Ie.up,"up"],[Ie.down,"down"],[Ie.left,"left"],[Ie.right,"right"]];for(let[l,c]of a){let h=r.index*32+l,u=s(l);u&&!this.padPrev[h]&&this.onPress(c),this.padPrev[h]=u}}return e}};function yg(i){return i==="start"||i==="pause"||i==="mute"||i==="debug"||i==="quality"}Qi();var vC="linear-gradient(to right, #6b2f1a, #d9502f)",SC="linear-gradient(to right, #d9502f, #f0a44c)",me=i=>document.getElementById(i),ll=class{cache=new Map;els={score:me("score"),hiscore:me("hiscore"),lives:me("lives"),missiles:me("missiles"),time:me("time"),speed:me("speed"),fuelBar:me("fuelBar"),fuelValue:me("fuelValue"),shieldsBar:me("shieldsBar"),shieldsValue:me("shieldsValue"),container:me("gameContainer"),message:me("message"),mute:me("muteStatus"),quality:me("qualityStatus"),mult:me("mult"),flares:me("flares"),empBar:me("empBar"),empValue:me("empValue"),empItem:me("empItem"),boss:me("boss"),bossFill:me("bossFill"),bossName:me("bossName"),bossBanner:me("bossBanner"),hint:me("hint"),progress:me("progress"),progressFill:me("progressFill"),progressLabel:me("progressLabel"),card:me("sectorCard")};constructor(){let e=()=>document.documentElement.style.setProperty("--hud-h",`${me("hud").offsetHeight}px`);e(),window.addEventListener("resize",e),new ResizeObserver(e).observe(me("hud"))}set(e,t,r){this.cache.get(e)!==t&&(this.cache.set(e,t),r(t))}text(e,t,r){this.set(t,r,s=>e.textContent=s)}update(e,t,r){let s=this.els;this.text(s.score,"score",String(e.score).padStart(6,"0")),this.text(s.hiscore,"hiscore",String(t).padStart(6,"0")),this.text(s.lives,"lives",String(e.lives).padStart(2,"0")),this.text(s.missiles,"missiles",String(e.missiles).padStart(2,"0")),this.text(s.time,"time",String(e.timeSeconds).padStart(3,"0")),this.text(s.speed,"speed",e.scrollSpeed.toFixed(1)),this.bar("fuel",e.fuel,s.fuelBar,s.fuelValue),this.text(s.mult,"mult",`\xD7${e.combo.mult.toFixed(1)}`),this.set("multHot",String(e.combo.mult>=2),h=>s.mult.classList.toggle("hot",h==="true")),this.text(s.flares,"flares",String(e.flares));let n=Math.floor(e.emp);this.set("empW",String(n),h=>s.empBar.style.width=h+"%"),this.text(s.empValue,"empL",n>=100?"READY":n+"%"),this.set("empReady",String(n>=100),h=>s.empItem.classList.toggle("ready",h==="true"));let o=e.bossBar;this.set("boss",String(!!o&&r),h=>s.boss.style.display=h==="true"?"block":"none"),o&&(this.text(s.bossName,"bossName",o.shielded?`${o.name} \xB7 SHIELDED`:o.name),this.set("bossW",String(Math.ceil(o.hp/o.maxHp*100)),h=>s.bossFill.style.width=h+"%"));let a=e.course,l=a.phase==="run"?Math.min(1,(e.dist-a.sectorStartDist)/Ke[a.sector].length):1;this.set("progW",String(Math.floor(l*100)),h=>s.progressFill.style.width=h+"%"),this.text(s.progressLabel,"progL",a.phase==="run"?`S${a.sector+1} \u25B8 BOSS`:a.phase==="boss"?`S${a.sector+1} \u25B8 BOSS ENGAGED`:`S${a.sector+1} \u25B8 CLEAR`),this.bar("shields",e.shields/e.maxShields*100,s.shieldsBar,s.shieldsValue);let c=r&&(e.fuel<25||e.shields<e.maxShields*.25);this.set("critical",String(c),h=>s.container.classList.toggle("critical",h==="true"))}bar(e,t,r,s){let n=Math.max(0,Math.floor(t));this.set(e+"W",String(n),a=>r.style.width=a+"%"),this.text(s,e+"L",n+"%");let o=t<30;this.set(e+"Low",String(o),()=>{r.style.background=o?vC:SC,s.style.color=o?"#ffb454":"#ffc36b"})}hintTimer=0;hintQueue=[];showHint(e){this.hintQueue.push(e),this.hintQueue.length===1&&this.nextHint()}nextHint(){let e=this.hintQueue[0],t=this.els.hint;if(!e){t.classList.remove("on");return}t.textContent=e,t.classList.add("on"),clearTimeout(this.hintTimer),this.hintTimer=window.setTimeout(()=>{t.classList.remove("on"),this.hintQueue.shift(),this.hintTimer=window.setTimeout(()=>this.nextHint(),400)},4800)}captionTimes=new Map;caption(e,t){let r=performance.now();if((this.captionTimes.get(e)??0)>r-1200)return;this.captionTimes.set(e,r);let s=document.getElementById("captions");if(!s)return;let n=document.createElement("div");for(n.textContent=t,s.append(n);s.children.length>4;)s.firstElementChild?.remove();window.setTimeout(()=>n.remove(),2600)}bannerTimer=0;bossBanner(e,t="HOSTILE GUNSHIP"){clearTimeout(this.bannerTimer),this.els.bossBanner.style.display=e?"block":"none",e&&(this.els.bossBanner.textContent=`\u26A0 ${t} \u26A0`),e&&(this.bannerTimer=window.setTimeout(()=>this.bossBanner(!1),2800))}cardTimer=0;sectorCard(e,t){let r=this.els.card;r.querySelector(".sc-title").textContent=e,r.querySelector(".sc-sub").textContent=t,r.classList.add("on"),clearTimeout(this.cardTimer),this.cardTimer=window.setTimeout(()=>r.classList.remove("on"),2800)}setPlaying(e){this.els.progress.classList.toggle("on",e),e||(this.hintQueue.length=0,clearTimeout(this.hintTimer),this.els.hint.classList.remove("on"),this.els.boss.style.display="none",this.cache.delete("boss"),this.els.container.classList.remove("critical"),this.cache.delete("critical"))}setMuted(e){this.els.mute.textContent=`[M]: MUTE (${e?"ON":"OFF"})`}setQuality(e){this.els.quality.textContent=`[Q] QUALITY: ${e.toUpperCase()}`}showMessage(e){let t=this.els.message;t.replaceChildren();let r=document.createElement("div");r.className="title-screen";for(let s of e){let n=document.createElement("div");s.cls&&(n.className=s.cls),n.textContent=s.text,r.append(n)}t.append(r),t.style.display="block"}hideMessage(){this.els.message.style.display="none"}};var Cn=class{constructor(e){this.el=e}items=[];index=0;onBack=null;set(e,t=!1){this.items=e,t||(this.index=e.findIndex(r=>!r.disabled)),this.index=Math.max(0,Math.min(e.length-1,this.index)),this.render()}render(){this.el.replaceChildren(),this.items.forEach((e,t)=>{let r=document.createElement("button");if(r.type="button",r.className="menu-item"+(t===this.index?" sel":"")+(e.disabled?" off":"")+(e.tone?` ${e.tone}`:""),e.tag){let n=document.createElement("span");n.className="menu-tag",n.textContent=e.tag,r.append(n)}let s=document.createElement("span");if(s.className="menu-label",s.textContent=e.label,r.append(s),e.detail){let n=document.createElement("span");n.className="menu-detail",n.textContent=e.detail,r.append(n)}r.addEventListener("mouseenter",()=>{e.disabled||(this.index=t,this.highlight())}),r.addEventListener("click",()=>{e.disabled||(this.index=t,e.onSelect?.())}),this.el.append(r)})}highlight(){Array.from(this.el.children).forEach((e,t)=>e.classList.toggle("sel",t===this.index))}move(e){if(!this.items.length)return;let t=this.index;for(let r=0;r<this.items.length&&(t=(t+e+this.items.length)%this.items.length,!!this.items[t].disabled);r++);this.index=t,this.highlight()}nav(e){let t=this.items[this.index];switch(e){case"up":return this.move(-1),!0;case"down":return this.move(1),!0;case"left":return t?.onLeft?.(),!0;case"right":return t?.onRight?.(),!0;case"fire":case"start":return t&&!t.disabled&&t.onSelect?.(),!0;case"pause":case"emp":return this.onBack?.(),!0}return!1}};ou();var _g="apache-canyon:save",vg=6,TC=()=>{try{return!!globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}},wC=()=>({shake:1,flash:1,reducedMotion:TC(),contrast:!1,captions:!1,assist:!1});function Sg(){return{version:vg,hiscore:0,best:{campaign:0,endless:0,daily:0,practice:0},seen:[],salvage:0,unlocked:{airframes:["apache"],perks:[]},loadout:structuredClone(qa),medals:[],reached:[0],campaignCleared:!1,daily:{date:"",played:!1,score:0},runs:0,settings:{muted:!1,quality:"high",volumes:{...mi},access:wC(),touch:{autoFire:!0,haptics:!0},bindings:structuredClone(al)}}}var En=i=>Array.isArray(i)?i.filter(e=>typeof e=="string"):[],ns=(i,e=0)=>typeof i=="number"&&Number.isFinite(i)?i:e;function MC(i){let e=Sg();if(!i||typeof i!="object")return e;let t=i,r=Math.max(0,Math.floor(ns(t.hiscore))),s=En(t.unlocked?.airframes).filter(d=>d in gr),n=En(t.unlocked?.perks).filter(d=>d in is),o={airframes:Array.from(new Set(["apache",...s])),perks:Array.from(new Set(n))},a=t.loadout,l={airframe:a&&o.airframes.includes(a.airframe)?a.airframe:"apache",perks:En(a?.perks).filter(d=>o.perks.includes(d)).slice(0,wn)},c={...e.best};for(let d of Object.keys(c))c[d]=Math.max(0,Math.floor(ns(t.best?.[d])));ns(t.version)<4&&(c.endless=Math.max(c.endless,r));let h=Array.isArray(t.reached)?t.reached.filter(d=>Number.isInteger(d)&&d>=0&&d<6):[],u=Array.from(new Set([0,...h])).sort((d,p)=>d-p);return{version:vg,hiscore:r,best:c,seen:En(t.seen),salvage:Math.max(0,Math.floor(ns(t.salvage))),unlocked:o,loadout:l,medals:En(t.medals),reached:u,campaignCleared:t.campaignCleared===!0,daily:{date:typeof t.daily?.date=="string"?t.daily.date:"",played:t.daily?.played===!0,score:Math.max(0,ns(t.daily?.score))},runs:Math.max(0,Math.floor(ns(t.runs))),settings:{muted:typeof t.settings?.muted=="boolean"?t.settings.muted:e.settings.muted,quality:t.settings?.quality==="performance"||t.settings?.quality==="balanced"?t.settings.quality:"high",volumes:Object.fromEntries(Object.keys(mi).map(d=>{let p=t.settings?.volumes?.[d];return[d,typeof p=="number"&&p>=0&&p<=1?p:mi[d]]})),access:(()=>{let d=t.settings?.access,p=e.settings.access,m=(y,g)=>typeof y=="number"&&y>=0&&y<=1?y:g,x=(y,g)=>typeof y=="boolean"?y:g;return{shake:m(d?.shake,p.shake),flash:m(d?.flash,p.flash),reducedMotion:x(d?.reducedMotion,p.reducedMotion),contrast:x(d?.contrast,p.contrast),captions:x(d?.captions,p.captions),assist:x(d?.assist,p.assist)}})(),touch:{autoFire:t.settings?.touch?.autoFire!==!1,haptics:t.settings?.touch?.haptics!==!1},bindings:{...e.settings.bindings,...t.settings?.bindings??{}}}}}function Tg(){try{return globalThis.localStorage??null}catch{return null}}function wg(i=Tg()){try{let e=i?.getItem(_g);return MC(e?JSON.parse(e):null)}catch{return Sg()}}function bt(i,e=Tg()){try{e?.setItem(_g,JSON.stringify(i))}catch{}}function au(i=new Date){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function Mg(i){let e=2166136261;for(let t=0;t<i.length;t++)e=Math.imul(e^i.charCodeAt(t),16777619);return e>>>0}pn();bn();var CC={novice:{name:"novice",reaction:14,lookahead:30,wallMargin:12,threatHorizon:90,noise:14,rhythmCool:!1,usesLocks:!1,flareAt:1/0,empAt:1/0,seeksPickups:!1,handlesGates:!1,hunts:!1},average:{name:"average",reaction:7,lookahead:60,wallMargin:16,threatHorizon:130,noise:6,rhythmCool:!1,usesLocks:!1,flareAt:.85,empAt:5,seeksPickups:!0,handlesGates:!0,hunts:!0},skilled:{name:"skilled",reaction:3,lookahead:60,wallMargin:18,threatHorizon:170,noise:2,rhythmCool:!0,usesLocks:!0,flareAt:.6,empAt:3,seeksPickups:!0,handlesGates:!0,hunts:!0}};function EC(i,e=1){let t=new Ir(e^659918),r=NaN,s=0,n=0;return(o,a=Nr())=>{let l=o.player,c=l.x+l.w/2,h=l.y+l.h/2,u=-1/0,d=1/0;for(let m=0;m<=i.lookahead;m+=15){let x=o.corridorAt(h-m);u=Math.max(u,x.left+10+l.w/2+i.wallMargin),d=Math.min(d,x.right-10-l.w/2-i.wallMargin)}if(u>d&&(u=d=(u+d)/2),o.tick%i.reaction===0||Number.isNaN(r)){let m=(u+d)/2,x=i.handlesGates?o.hostiles.find(g=>g.kind==="gate"&&g.y<l.y&&g.y>-20):void 0;if(x){let g=o.corridorAt(h);m=x.x+x.w/2,u=Math.min(u,g.left+10+l.w/2+6),d=Math.max(d,g.right-10-l.w/2-6)}else{let g=i.seeksPickups?o.pickups.find(_=>_.y<l.y&&_.y>l.y-260):void 0,v=i.hunts?PC(o,c,h):null;g?m=g.x+g.w/2:v&&(m=v.x+v.w/2)}let y=0;for(let g of o.enemyShots){let v=h-(g.y+g.h/2);if(v>0&&v<i.threatHorizon&&g.vy>0){let _=g.x+g.w/2+g.vx*(v/g.vy);Math.abs(_-c)<18&&(y=_<c?1:-1)}}for(let g of o.hazards)Math.hypot(g.x-c,g.y-h)<g.r+14&&(y=g.x<c?1:-1);for(let g of o.hostiles){if(g.ground)continue;let v=l.y-(g.y+g.h);if(v>0&&v<i.threatHorizon*.8&&Math.abs(g.x+g.w/2-c)<26){y=g.x+g.w/2<c?1:-1;break}}y!==0&&(m=c+y*60,(m>d+20||m<u-20)&&(m=c-y*60)),s=(t.next()-.5)*2*i.noise,r=Math.min(d,Math.max(u,m+s))}a.left=c>r+3,a.right=c<r-3,a.up=!1,a.down=!1,a.fire=i.rhythmCool?!(l.heat>=er[0]+5&&l.heat<=er[1]&&l.fireHeld)&&!l.overheated:!0;let p=o.hostiles.filter(m=>m.y>0&&m.y<l.y-40&&m.kind!=="mine").length;return i.usesLocks&&p>=2&&o.missiles>0&&n===0&&(n=o.tick+40),n?(a.missile=o.tick<n,a.missile||(n=0)):a.missile=p>0&&o.tick%200<2,a.flare=o.samLock>i.flareAt||i.flareAt<1&&o.enemyShots.some(m=>m.kind==="sam"&&m.decoy===null&&Math.hypot(m.x-c,m.y-h)<150),a.emp=o.emp>=100&&o.enemyShots.length>=i.empAt,a.boost=!1,a}}function PC(i,e,t){let r=null,s=1/0;for(let n of i.hostiles){if(n.kind==="mine"||n.y<0||n.shielded)continue;let o=t-(n.y+n.h/2);if(o<60||o>400)continue;let a=o+Math.abs(n.x+n.w/2-e)*2;a<s&&(s=a,r=n)}return r}var Cg=new WeakMap;function Eg(i,e=Nr()){let t=Cg.get(i);return t||(t=EC(CC.average,i.seed),Cg.set(i,t)),t(i,e)}var lu={drone:"SCOUT DRONE \xB7 a red eye flare means a shot is coming: sidestep",uav:"UAV \xB7 it rams you. Shoot it before it commits to your line",mine:"MINE \xB7 arms when you get close. Shoot it, or leave the red ring",gunner:"GUNNER \xB7 red glint, then a 3-round burst. Strafe during the glint",gate:"GATE \xB7 shoot the bracketed node, or slip through when the beam drops",turret:"WALL TURRET \xB7 its laser blinks when it locks. Move off the line",flak:"FLAK \xB7 get out of the red circle before the fuse ring closes",sam:"SAM SITE \xB7 lock tone means FLARES [C], or shoot the missile down",tank:"TANK \xB7 slow, heavy shells. Hold [X] to lock missiles on it",gunship:"RIVAL GUNSHIP \xB7 nose glow before every volley; fan lines show the spread",overheat:"GUN OVERHEAT \xB7 let go of [Z] while the heat bar is in the blue window to cool fast",emp:"EMP READY \xB7 press [V] to wipe enemy fire off the screen",graze:"GRAZE \xB7 flying close to the rock without touching it keeps your chain alive"},Pg={drone:"SCOUT DRONE",uav:"UAV",mine:"MINE",gunner:"GUNNER",turret:"WALL TURRET",flak:"FLAK",sam:"SAM",tank:"TANK",gunship:"RIVAL GUNSHIP",gate:"GATE BEAM"};function kg(i){let e=i.split(":");return e[0]==="shot"?`${Pg[e[2]]??e[2].toUpperCase()} ${e[1]==="sam"?"MISSILE":e[1]==="rocket"?"ROCKETS":e[1]==="shell"?"SHELL":"FIRE"}`:e[0]==="contact"?`${Pg[e[1]]??e[1].toUpperCase()} RAM`:i==="flak"?"FLAK AIRBURST":i==="mine"?"MINE BLAST":i==="gate"?"GATE BEAM":i==="scrape"?"CANYON WALL":i==="fuel"?"EMPTY TANK":i.toUpperCase()}var kC={drone:"Scout drone",gunner:"Gunner",turret:"Turret",traincar:"Train turret",tank:"Tank",engine:"Locomotive",mine:"Mine",gunship:"Gunship",dish:"Radar",sam:"SAM site"};function hl(i,e,t){let r=i.player,s=e-(r.x+r.w/2),n=t-(r.y+r.h/2);return Math.abs(s)<40?n<0?"\u2191":"\u2193":n<-60?s<0?"\u2196":"\u2197":s<0?"\u2190":"\u2192"}function Ag(i,e){switch(i.type){case"telegraph":{let t=kC[i.kind];if(!t)return null;let r=i.kind==="mine"?"arming":i.kind==="dish"?"calling drones":"charging";return{key:`tel-${i.kind}`,text:`[${t} ${r} ${hl(e,i.x,i.y)}]`}}case"enemyShot":return i.kind==="shell"?{key:"shell",text:`[Shell fired ${hl(e,i.x,i.y)}]`}:null;case"lockStart":return{key:"lock",text:"[Missile lock tone]"};case"samLaunch":return{key:"sam",text:`[Missile launch ${hl(e,i.x,i.y)}: use flares]`};case"flakMark":return{key:"flak",text:`[Flak shell incoming ${hl(e,i.x,i.y)}]`};case"overheat":return{key:"heat",text:"[Gun overheating]"};case"alarm":return{key:"alarm",text:e.fuel<25?"[Low fuel alarm]":"[Low shields alarm]"};case"bossEnter":return{key:"boss",text:`[Alarm: ${i.name??"boss"} inbound]`};case"shieldDown":return{key:"shield",text:"[Shield generator collapses]"};case"comboBreak":return{key:"chain",text:"[Chain lost]"};case"emp":return{key:"emp",text:"[EMP discharge]"};default:return null}}var ul=class{constructor(e,t,r){this.opts=t;this.onPause=r;this.root=document.createElement("div"),this.root.id="touch",this.root.innerHTML=`
      <div class="t-zone"></div>
      <div class="t-buttons">
        <button data-b="missile">MSL<small>hold</small></button>
        <button data-b="flare">FLR</button>
        <button data-b="emp">EMP</button>
        <button data-b="boost">BST<small>hold</small></button>
      </div>
      <button class="t-fire" data-b="fire">FIRE</button>
      <button class="t-pause" aria-label="Pause">\u275A\u275A</button>`,e.append(this.root),this.fireBtn=this.root.querySelector(".t-fire");let s=this.root.querySelector(".t-zone");s.addEventListener("touchstart",this.onStart,{passive:!1}),s.addEventListener("touchmove",this.onMove,{passive:!1}),s.addEventListener("touchend",this.onEnd),s.addEventListener("touchcancel",this.onEnd);for(let n of Array.from(this.root.querySelectorAll("[data-b]"))){let o=n.dataset.b,a=c=>{c.preventDefault(),this.held[o]=!0,this.tapped[o]=!0,n.classList.add("on")},l=c=>{c.preventDefault(),this.held[o]=!1,n.classList.remove("on")};n.addEventListener("touchstart",a,{passive:!1}),n.addEventListener("touchend",l),n.addEventListener("touchcancel",l)}this.root.querySelector(".t-pause").addEventListener("touchstart",n=>{n.preventDefault(),this.onPause()},{passive:!1})}root;steerId=null;fingerStart={x:0,y:0};finger={x:0,y:0};worldStart=null;held={fire:!1,missile:!1,flare:!1,emp:!1,boost:!1};tapped={fire:!1,missile:!1,flare:!1,emp:!1,boost:!1};fireBtn;setVisible(e){this.root.classList.toggle("on",e),this.fireBtn.style.display=this.opts().autoFire?"none":"",e||this.release()}release(){this.steerId=null,this.worldStart=null;for(let e of Object.keys(this.held))this.held[e]=!1;this.root.querySelectorAll(".on").forEach(e=>e.classList.remove("on"))}onStart=e=>{if(e.preventDefault(),this.steerId!==null)return;let t=e.changedTouches[0];this.steerId=t.identifier,this.fingerStart={x:t.clientX,y:t.clientY},this.finger={...this.fingerStart},this.worldStart=null};onMove=e=>{e.preventDefault();for(let t of Array.from(e.changedTouches))t.identifier===this.steerId&&(this.finger={x:t.clientX,y:t.clientY})};onEnd=e=>{for(let t of Array.from(e.changedTouches))t.identifier===this.steerId&&(this.steerId=null,this.worldStart=null)};apply(e,t,r){let s=t.player;if(this.steerId!==null){this.worldStart||(this.worldStart={x:s.x,y:s.y});let n=this.worldStart.x+(this.finger.x-this.fingerStart.x)/r,o=this.worldStart.y+(this.finger.y-this.fingerStart.y)/r,a=3;e.left||=s.x>n+a,e.right||=s.x<n-a,e.up||=s.y>o+a,e.down||=s.y<o-a,this.opts().autoFire&&(e.fire=!0)}for(let n of Object.keys(this.held))e[n]||=this.held[n]||this.tapped[n],this.tapped[n]=!1}};var AC=["left","right","up","down","fire","missile","flare","emp","boost"],RC=i=>AC.reduce((e,t,r)=>i[t]?e|1<<r:e,0);var dl=class{runs=[];push(e){let t=RC(e),r=this.runs[this.runs.length-1];r&&r[0]===t?r[1]++:this.runs.push([t,1])}get inputs(){return this.runs.map(([e,t])=>[e,t])}reset(){this.runs=[]}};Qi();var gi=[{id:"sharpshooter",name:"SHARPSHOOTER",blurb:"55% accuracy over 200+ rounds",earned:i=>i.shotsFired>=200&&i.shotsHit/i.shotsFired>=.55},{id:"wallHugger",name:"WALL HUGGER",blurb:"30 s of grazing in one run",earned:i=>i.grazeTicks>=1800},{id:"closeCall",name:"CLOSE CALLS",blurb:"25 near misses",earned:i=>i.nearMisses>=25},{id:"untouchable",name:"UNTOUCHABLE",blurb:"Clear a sector without a scratch",earned:i=>i.untouchedSectors>=1},{id:"bridgeRunner",name:"BRIDGE RUNNER",blurb:"Fly under 5 bridges",earned:i=>i.bridges>=5},{id:"bossHunter",name:"BOSS HUNTER",blurb:"Destroy 3 bosses in one run",earned:i=>i.bossesDefeated>=3},{id:"dawnPatrol",name:"DAWN PATROL",blurb:"Complete the campaign",earned:(i,e)=>e.mode==="campaign"&&e.status==="complete"},{id:"ironWill",name:"IRON WILL",blurb:"Complete the campaign without losing a life",earned:(i,e)=>e.mode==="campaign"&&e.status==="complete"&&e.livesLost===0}];var BC={drone:"scouts",uav:"UAVs",mine:"mines",gunner:"gunners",turret:"turrets",flak:"flak guns",sam:"SAM sites",tank:"tanks",gate:"gate nodes",depot:"depots",gunship:"gunships",sluice:"sluices",traincar:"train cars",shieldgen:"generators"},Qe=i=>document.getElementById(i),pl=class{constructor(e,t,r){this.renderer=e;this.fixedSeed=t;this.rendererName=r;this.save=wg(),this.audio=new sl(this.save.settings.muted,this.save.settings.volumes),this.hud.setMuted(this.save.settings.muted),this.hud.setQuality(this.save.settings.quality),this.renderer.setQuality?.(this.save.settings.quality),this.input=new ol(this.save.settings.bindings,n=>this.onAction(n)),this.applyAccess(),this.touch=new ul(Qe("gameContainer"),()=>this.save.settings.touch,()=>{this.screen==="playing"&&this.pause()}),window.addEventListener("touchstart",()=>{this.touchActive||(this.touchActive=!0,document.body.classList.add("touch")),this.audio.init()},{passive:!0}),window.addEventListener("pointerdown",()=>this.audio.init()),this.sim=this.newAttractSim(),this.stepper=new Oa({tick:()=>this.tick(),render:(n,o)=>this.render(n,o)}),this.panelMenu.onBack=()=>this.backFromPanel();let s=()=>{this.screen==="playing"&&this.pause(),this.stepper.resetClock()};window.addEventListener("blur",s),document.addEventListener("visibilitychange",()=>document.hidden&&s())}screen="menu";sim;fx=new cl;audio;hud=new ll;input;save;stepper;attractInput=Nr();menu=new Cn(Qe("menu"));panelMenu=new Cn(Qe("panelMenu"));mode="endless";practiceSector=0;idle=0;touchActive=!1;touch;recorder=new dl;lastCause="scrape";hitThisTick=null;livesLost=0;debugOn=!1;stats={fps:0,frameMs:16.7,tickMs:0};start(){this.showMenu(),km(this.stepper)}newAttractSim(){let e=new ss(Vh(),{mode:"endless",startSector:Math.floor(Math.random()*Ke.length)});return e.missiles=99,e}onAction(e){if(e==="mute"){this.save.settings.muted=!this.save.settings.muted,this.audio.setMuted(this.save.settings.muted),this.hud.setMuted(this.save.settings.muted),bt(this.save);return}if(e==="quality"){let t=["high","balanced","performance"];this.save.settings.quality=t[(t.indexOf(this.save.settings.quality)+1)%t.length],this.renderer.setQuality?.(this.save.settings.quality),this.hud.setQuality(this.save.settings.quality),bt(this.save);return}if(e==="debug"){this.debugOn=!this.debugOn,Qe("debug").style.display=this.debugOn?"block":"none";return}switch(this.audio.init(),this.screen){case"menu":this.menu.nav(e)&&this.menuSound(e);break;case"practice":case"hangar":case"medals":case"options":case"access":case"controls":case"paused":case"debrief":this.panelMenu.nav(e)&&this.menuSound(e);break;case"playing":yg(e)&&(e==="start"||e==="pause")&&this.pause();break}}isMenu(){return this.screen==="menu"||this.screen==="practice"||this.screen==="hangar"||this.screen==="medals"||this.screen==="options"||this.screen==="access"||this.screen==="controls"}menuSound(e){e==="up"||e==="down"||e==="left"||e==="right"?this.audio.ui("move"):e==="pause"||e==="emp"?this.audio.ui("back"):this.audio.ui("select")}backFromPanel(){if(this.screen==="access"||this.screen==="controls")return this.showOptions();this.screen==="paused"?this.resume():this.screen==="debrief"?this.showMenu():this.showMenu()}setPanel(e,t="",r=[]){Qe("panel").style.display=e?"flex":"none",Qe("panelTitle").textContent=t,Qe("panelBody").replaceChildren(...r.map(s=>{if(typeof s!="string")return s;let n=document.createElement("div");return n.textContent=s,n}))}showMenu(){this.screen="menu",this.setPanel(!1),this.hud.hideMessage(),this.hud.setPlaying(!1),Qe("title").style.display="flex";let e=this.save,t=au(),r=e.daily.date===t&&e.daily.played,s=o=>String(o).padStart(6,"0");this.menu.set([{label:"CAMPAIGN",detail:e.campaignCleared?`cleared \xB7 best ${s(e.best.campaign)}`:"6 sectors, dusk to dawn",onSelect:()=>this.startRun("campaign")},{label:"ENDLESS",detail:`best ${s(e.best.endless)}`,onSelect:()=>this.startRun("endless")},{label:"DAILY OP",detail:r?`flown today \xB7 ${s(e.daily.score)}`:`${t} \xB7 one attempt`,disabled:r,onSelect:()=>this.startRun("daily")},{label:"PRACTICE",detail:`${e.reached.length}/6 sectors`,onSelect:()=>this.showPractice()},{label:"HANGAR",detail:`${e.salvage} salvage`,onSelect:()=>this.showHangar()},{label:"MEDALS",detail:`${gi.filter(o=>e.medals.includes(o.id)).length}/${gi.length} earned`,onSelect:()=>this.showMedals()},{label:"OPTIONS",detail:"audio \xB7 quality",onSelect:()=>this.showOptions()}],!0);let n=Qe("title").querySelector("[data-hiscore]");n&&(n.textContent=s(e.hiscore))}showPractice(){this.screen="practice",Qe("title").style.display="none",this.setPanel(!0,"PRACTICE",["Fly one sector and its boss. Reach sectors in Campaign or Endless to unlock them."]),this.panelMenu.set([...Ke.map((e,t)=>{let r=this.save.reached.includes(t);return{tag:String(t+1),label:r?e.name:"\u2014 LOCKED \u2014",detail:r?e.subtitle:"",disabled:!r,onSelect:()=>{this.practiceSector=t,this.startRun("practice")}}}),{label:"BACK",onSelect:()=>this.showMenu()}])}showMedals(){this.screen="medals",Qe("title").style.display="none";let e=gi.filter(t=>this.save.medals.includes(t.id)).length;this.setPanel(!0,"MEDALS",[`${e} of ${gi.length} earned \xB7 each pays salvage when you earn it in a run`]),this.panelMenu.set([...gi.map(t=>{let r=this.save.medals.includes(t.id);return{tag:r?"\u2605 EARNED":"\u2606",label:t.name,detail:t.blurb,tone:r?"gold":"dim",onSelect:()=>{}}}),{label:"BACK",onSelect:()=>this.showMenu()}],!1)}showHangar(e=!1){this.screen="hangar",Qe("title").style.display="none";let t=this.save,r=t.loadout;this.setPanel(!0,"HANGAR",[`SALVAGE  ${t.salvage}`,`Perk slots: ${r.perks.length}/${wn}`]);let s=[];for(let n of Object.values(gr)){let o=t.unlocked.airframes.includes(n.id),a=r.airframe===n.id;s.push({tag:a?"FLYING":o?"OWNED":`${n.cost}`,label:n.name,detail:n.blurb,disabled:!o&&t.salvage<n.cost,onSelect:()=>this.hangarAirframe(n.id)})}for(let n of Object.values(is)){let o=t.unlocked.perks.includes(n.id),a=r.perks.includes(n.id);s.push({tag:a?"ON":o?"OFF":`${n.cost}`,label:n.name,detail:n.blurb,disabled:!o&&t.salvage<n.cost,onSelect:()=>this.hangarPerk(n.id)})}s.push({label:"BACK",onSelect:()=>this.showMenu()}),this.panelMenu.set(s,e)}showOptions(e=!1){this.screen="options",Qe("title").style.display="none",this.setPanel(!0,"OPTIONS",["\u2190/\u2192 to adjust"]);let t=this.save.settings.volumes,r=n=>"\u25AE".repeat(Math.round(n*10))+"\u25AF".repeat(10-Math.round(n*10))+`  ${Math.round(n*100)}%`,s=(n,o)=>{let a=l=>{t[n]=Math.round(Math.max(0,Math.min(1,t[n]+l))*10)/10,this.audio.setVolumes(t),bt(this.save),this.showOptions(!0),n!=="music"&&n!=="ambience"&&this.audio.ui("select")};return{label:o,detail:r(t[n]),onLeft:()=>a(-.1),onRight:()=>a(.1),onSelect:()=>a(t[n]>=1?-1:.1)}};this.panelMenu.set([s("master","MASTER"),s("music","MUSIC"),s("sfx","EFFECTS"),s("ambience","AMBIENCE"),{label:"MUTE",detail:this.save.settings.muted?"ON":"OFF",onSelect:()=>{this.onAction("mute"),this.showOptions(!0)}},{label:"QUALITY",detail:this.save.settings.quality.toUpperCase(),onSelect:()=>{this.onAction("quality"),this.showOptions(!0)}},{label:"ACCESSIBILITY \u25B8",detail:"motion \xB7 flashes \xB7 contrast \xB7 captions \xB7 assist",onSelect:()=>this.showAccess()},{label:"CONTROLS \u25B8",detail:"rebind keys",onSelect:()=>this.showControls()},{label:"BACK",onSelect:()=>this.showMenu()}],e)}applyAccess(){let e=this.save.settings.access;this.renderer.setAccess?.({shake:e.shake,flash:e.flash,reducedMotion:e.reducedMotion,contrast:e.contrast}),this.fx.shakeScale=e.shake,this.fx.reducedMotion=e.reducedMotion,document.body.classList.toggle("reduced-motion",e.reducedMotion)}showAccess(e=!1){this.screen="access",Qe("title").style.display="none";let t=this.save.settings.access,r=this.save.settings.touch;this.setPanel(!0,"ACCESSIBILITY",["\u2190/\u2192 to adjust \xB7 fire/space to toggle"]);let s=l=>"\u25AE".repeat(Math.round(l*10))+"\u25AF".repeat(10-Math.round(l*10))+`  ${Math.round(l*100)}%`,n=()=>{bt(this.save),this.applyAccess(),this.showAccess(!0)},o=(l,c,h)=>{let u=d=>{t[l]=Math.round(Math.max(0,Math.min(1,t[l]+d))*10)/10,n()};return{label:c,detail:`${s(t[l])} \xB7 ${h}`,onLeft:()=>u(-.1),onRight:()=>u(.1),onSelect:()=>u(t[l]>=1?-1:.1)}},a=(l,c,h,u)=>({label:h,detail:`${l()?"ON":"OFF"} \xB7 ${u}`,onSelect:()=>{c(!l()),n()},onLeft:()=>{c(!1),n()},onRight:()=>{c(!0),n()}});this.panelMenu.set([o("shake","SCREEN SHAKE","camera shake strength"),o("flash","FLASHES","hit flashes and damage pulse"),a(()=>t.reducedMotion,l=>t.reducedMotion=l,"REDUCED MOTION","no shake, freeze-frames or flicker"),a(()=>t.contrast,l=>t.contrast=l,"HIGH-CONTRAST THREATS","shape-coded shots, dashed white aim lines"),a(()=>t.captions,l=>t.captions=l,"SOUND CAPTIONS","subtitles for warning sounds"),a(()=>t.assist,l=>t.assist=l,"ASSIST MODE","slower, no wall damage, +1 life (no best scores)"),a(()=>r.autoFire,l=>r.autoFire=l,"TOUCH AUTO-FIRE","gun fires while you steer"),a(()=>r.haptics,l=>r.haptics=l,"HAPTICS","vibrate on hits (touch devices)"),{label:"BACK",onSelect:()=>this.showOptions()}],e)}showControls(e=!1,t=null){this.screen="controls",Qe("title").style.display="none";let r=this.save.settings.bindings,s=o=>o.replace(/^Key/,"").replace(/^Digit/,"").replace("Arrow","").replace("Left","\u2190").replace("Right","\u2192").replace("Up","\u2191").replace("Down","\u2193").replace("Shift","SHIFT ").replace("Backquote","`").replace("Semicolon",";").replace("Comma",",").replace("Period",".").toUpperCase(),n=[["left","LEFT"],["right","RIGHT"],["up","UP"],["down","DOWN"],["fire","FIRE"],["missile","MISSILE"],["flare","FLARE"],["emp","EMP"],["boost","BOOST"],["pause","PAUSE"],["mute","MUTE"],["quality","QUALITY"]];this.setPanel(!0,"CONTROLS",[t?`Press a key for ${t} (Esc cancels)`:"Select an action, then press the new key. Gamepads use the standard layout."]),this.panelMenu.set([...n.map(([o,a])=>({label:a,detail:r[o].map(s).join("  /  "),onSelect:()=>{this.showControls(!0,a),this.input.captureNext(l=>{if(l!=="Escape"){for(let c of Object.keys(r))r[c]=r[c].filter(h=>h!==l);r[o]=[l,...r[o]].slice(0,3),this.input.setBindings(r),bt(this.save)}this.showControls(!0)})}})),{label:"RESET DEFAULTS",onSelect:()=>{this.save.settings.bindings=structuredClone(al),this.input.setBindings(this.save.settings.bindings),bt(this.save),this.showControls(!0)}},{label:"BACK",onSelect:()=>this.showOptions()}],e)}hangarAirframe(e){let t=this.save;if(!t.unlocked.airframes.includes(e)){if(t.salvage<gr[e].cost)return;t.salvage-=gr[e].cost,t.unlocked.airframes.push(e),this.audio.ui("buy")}t.loadout.airframe=e,bt(t),this.showHangar(!0)}hangarPerk(e){let t=this.save;if(!t.unlocked.perks.includes(e)){if(t.salvage<is[e].cost)return;t.salvage-=is[e].cost,t.unlocked.perks.push(e),this.audio.ui("buy")}t.loadout.perks.includes(e)?t.loadout.perks=t.loadout.perks.filter(s=>s!==e):(t.loadout.perks.length<wn||t.loadout.perks.shift(),t.loadout.perks.push(e)),bt(t),this.showHangar(!0)}startRun(e){let t=au();if(e==="daily"){if(this.save.daily.date===t&&this.save.daily.played)return;this.save.daily={date:t,played:!0,score:0},bt(this.save)}this.mode=e;let r=e==="daily"?Mg(t):this.fixedSeed??Vh();this.sim=new ss(r,{mode:e==="daily"?"endless":e,startSector:e==="practice"?this.practiceSector:0,loadout:this.save.loadout,assist:this.save.settings.access.assist}),this.lastCause="scrape",this.livesLost=0,this.recorder.reset(),this.fx.reset(),this.audio.ui("start"),this.hud.hideMessage(),this.setPanel(!1),Qe("title").style.display="none",this.hud.setPlaying(!0),this.screen="playing";for(let s of this.sim.events)this.onEvent(s);this.sim.events.length=0}pause(){this.screen="paused",this.input.clear(),this.setPanel(!0,"PAUSED",[`${Ke[this.sim.course.sector].name} \xB7 ${Math.round(Sn(this.sim)*100)}%`]),this.panelMenu.set([{label:"RESUME",onSelect:()=>this.resume()},{label:"ABANDON RUN",detail:"go to debrief",onSelect:()=>this.finishRun()}])}resume(){this.screen="playing",this.setPanel(!1)}finishRun(){let e=this.sim,t=this.save,r=e.status==="complete";this.audio.runEnd(e.status==="over"?"over":r?"complete":"abandon");let s=gi.filter(g=>g.earned(e.stats,{status:e.status,mode:e.course.mode,livesLost:this.livesLost})),n=s.filter(g=>!t.medals.includes(g.id)),o=hg({score:e.score,sectorsCleared:e.stats.sectorsCleared,bossesDefeated:e.stats.bossesDefeated,medals:s.length}),a=e.options.assist,l=!a&&e.score>t.best[this.mode];a||(t.best[this.mode]=Math.max(t.best[this.mode],e.score),t.hiscore=Math.max(t.hiscore,e.score)),t.salvage+=o,t.medals.push(...n.map(g=>g.id));for(let g of e.course.reached)t.reached.includes(g)||t.reached.push(g);t.reached.sort((g,v)=>g-v),this.mode==="campaign"&&r&&(t.campaignCleared=!0),this.mode==="daily"&&(t.daily.score=e.score),t.runs++,bt(t);let c=e.stats,h=c.shotsFired?Math.round(c.shotsHit/c.shotsFired*100):0,u=Object.entries(c.kills).sort((g,v)=>v[1]-g[1]),d=u.reduce((g,[,v])=>g+v,0),p=Math.floor(e.tick/3600),m=Math.floor(e.tick/60%60),x=(g,v,_="")=>{let S=document.createElement("div");S.className="deb-row "+_;let T=document.createElement("span");T.textContent=g;let w=document.createElement("span");return w.textContent=v,S.append(T,w),S},y=[e.status==="over"?x("DOWNED BY",kg(this.lastCause),"warn"):x("RESULT",r?this.mode==="campaign"?"CAMPAIGN COMPLETE":"SECTOR CLEARED":"RUN ABANDONED",r?"gold":"warn"),x("MODE",this.mode.toUpperCase()+(e.course.lap?` \xB7 LAP ${e.course.lap+1}`:"")+(a?" \xB7 ASSIST":"")),x("REACHED",`${e.course.sector+1} \xB7 ${Ke[e.course.sector].name}`),x("SCORE",`${String(e.score).padStart(6,"0")}${l?"  NEW BEST":""}`,l?"gold":""),x("TIME",`${p}:${String(m).padStart(2,"0")}`),x("BOSSES",`${c.bossesDefeated} destroyed \xB7 ${c.sectorsCleared} sectors cleared`),x("KILLS",`${d}${u.length?" \xB7 "+u.slice(0,3).map(([g,v])=>`${v} ${BC[g]??g}`).join(", "):""}`),x("ACCURACY",`${h}% \xB7 ${c.missilesFired} missiles`),x("STYLE",`${(c.grazeTicks/60).toFixed(0)}s grazing \xB7 ${c.nearMisses} near misses \xB7 ${c.bridges} bridges`),x("MEDALS",s.length?s.map(g=>n.includes(g)?`\u2605 ${g.name}`:g.name).join(", "):"\u2014",n.length?"gold":""),x("SALVAGE",`+${o}  (total ${t.salvage})`,"gold")];this.screen="debrief",this.hud.setPlaying(!1),this.setPanel(!0,r?"MISSION DEBRIEF":e.status==="over"?"SYSTEM FAILURE":"RUN ENDED",y),this.panelMenu.set([{label:"CONTINUE",onSelect:()=>this.showMenu()},{label:"FLY AGAIN",disabled:this.mode==="daily",onSelect:()=>this.startRun(this.mode)},{label:"HANGAR",onSelect:()=>this.showHangar()}])}exportReplay(e="recorded"){let t=this.sim;return{name:e,seed:t.seed,options:t.options,inputs:this.recorder.inputs,expect:{tick:t.tick,score:t.score,fingerprint:t.fingerprint(),status:t.status}}}hint(e){this.save.seen.includes(e)||!lu[e]||(this.save.seen.push(e),bt(this.save),this.hud.showHint(lu[e]))}tick(){let e=this.input.sample();if(this.isMenu()){this.audio.update(this.sim,"menu"),this.sim.step(Eg(this.sim,this.attractInput)),this.sim.fuel=Math.max(this.sim.fuel,60),this.sim.shields=Math.max(this.sim.shields,60);for(let r of this.sim.events)this.fx.handle(r,this.sim);this.sim.events.length=0,this.sim.status!=="running"&&(this.sim=this.newAttractSim()),this.fx.tick(this.sim,!0);return}let t=this.screen==="playing";if(t)if(this.fx.hitStop>0)this.fx.hitStop--;else{this.touchActive&&this.touch.apply(e,this.sim,this.renderer.worldScale?.()??1),this.recorder.push(e);let r=performance.now();this.sim.step(e),this.stats.tickMs=performance.now()-r,this.hitThisTick=null;for(let s of this.sim.events)this.onEvent(s);this.sim.events.length=0;for(let s of this.sim.hostiles)s.y>-10&&s.group===0&&!this.save.seen.includes(s.kind)&&this.hint(s.kind);this.sim.emp>=100&&this.hint("emp"),this.sim.grazeTicks===30&&this.hint("graze"),this.sim.status!=="running"&&this.finishRun()}this.audio.update(this.sim,this.screen==="playing"?"run":this.screen==="paused"?"paused":"menu"),this.screen!=="paused"&&this.fx.tick(this.sim,t),(this.screen==="playing"||this.screen==="paused")&&this.hud.update(this.sim,Math.max(this.save.hiscore,this.sim.score),this.screen==="playing")}onEvent(e){if(this.fx.handle(e,this.sim),e.type==="playerHit"&&(this.hitThisTick=e.cause),e.type==="lifeLost"&&(this.lastCause=this.hitThisTick??(this.sim.fuel<=0?"fuel":"scrape"),this.livesLost++),e.type==="overheat"&&this.hint("overheat"),this.audio.handle(e,this.sim),this.save.settings.access.captions){let t=Ag(e,this.sim);t&&this.hud.caption(t.key,t.text)}switch(this.save.settings.touch.haptics&&this.touchActive&&navigator.vibrate&&(e.type==="playerHit"?navigator.vibrate(30):e.type==="lifeLost"?navigator.vibrate(140):e.type==="bossEnter"&&navigator.vibrate([60,40,60])),e.type){case"bossEnter":this.hud.bossBanner(!0,e.name);break;case"bossDown":this.hud.sectorCard(e.escaped?"TARGET ESCAPED":"TARGET DESTROYED",e.name??"");break;case"sectorStart":this.hud.sectorCard(`SECTOR ${e.index+1} \xB7 ${e.name}`,e.subtitle),this.save.reached.includes(e.index)||(this.save.reached.push(e.index),this.save.reached.sort((t,r)=>t-r),bt(this.save));break;case"shieldDown":this.hud.sectorCard("SHIELDS DOWN","hit the core");break}}render(e,t){this.idle++,this.touch.setVisible(this.touchActive&&this.screen==="playing"),t>0&&(this.stats.frameMs=this.stats.frameMs*.92+t*.08,this.stats.fps=1e3/this.stats.frameMs);let r=this.isMenu(),s=r?"title":this.screen==="debrief"?"over":this.screen,n=this.screen==="playing"||r,o=performance.now();if(this.renderer.render({sim:this.sim,fx:this.fx,alpha:n&&this.fx.hitStop===0?e:1,screen:s,idle:this.idle,debug:this.debugOn}),this.debugOn&&this.idle%6===0){let a=this.sim;Qe("debug").textContent=[`${this.rendererName} \xB7 ${this.renderer.resolutionInfo??this.save.settings.quality} \xB7 FPS ${this.stats.fps.toFixed(0)} \xB7 frame ${this.stats.frameMs.toFixed(1)}ms`,`render ${(performance.now()-o).toFixed(2)}ms \xB7 sim ${this.stats.tickMs.toFixed(2)}ms`,`sector ${a.course.sector+1} ${a.course.phase} ${(Sn(a)*100).toFixed(0)}% \xB7 lap ${a.course.lap} \xB7 speed ${a.scrollSpeed.toFixed(1)}`,`hostiles ${a.hostiles.length} \xB7 bullets ${a.bullets.length} \xB7 shots ${a.enemyShots.length} \xB7 pickups ${a.pickups.length}`,`particles ${this.fx.particles.length} \xB7 trauma ${this.fx.camera.trauma.toFixed(2)} \xB7 music intensity ${this.audio.debugIntensity.toFixed(2)}`,`seed ${a.seed}`].join(`
`)}}};Gr();var ae={skyTop:"#1e1330",skyMid:"#7a2f3d",skyHorizon:"#e8763a",sunCore:"#ffe9b8",sunGlow:"#ffb454",sandShadow:"#3a1c10",sandDark:"#6b2f1a",sandMid:"#9c4a26",sandLight:"#d98a4f",rim:"#ffcf8a",amber:"#f0a44c",amberBright:"#ffc36b",rust:"#d9502f",dust:"#c9a67a",hot:"#fff5e0"};At();var fl=4,Rg=56,Bg=40,IC=2,cu=class{cache=new Map;get(e){let t=this.cache.get(e);if(t)return t;t=document.createElement("canvas"),t.width=t.height=64;let r=t.getContext("2d"),s=r.createRadialGradient(32,32,0,32,32,32);return s.addColorStop(0,e),s.addColorStop(.35,e+"88"),s.addColorStop(1,e+"00"),r.fillStyle=s,r.fillRect(0,0,64,64),this.cache.set(e,t),t}},ml=class{constructor(e){this.canvas=e;this.ctx=e.getContext("2d",{alpha:!1}),this.ridges=[0,1].map(t=>{let r=[],s=j*(t===0?.42:.5);for(let n=-600;n<=be+600;n+=40)s+=(Math.random()-.5)*(t===0?24:34),s=Math.max(j*.25,Math.min(j*.6,s)),r.push({x:n,y:s});return r}),this.resize()}ctx;dpr=1;cssW=0;cssH=0;scale=1;offX=0;offY=0;vis={x0:0,y0:0,x1:be,y1:j};bg=document.createElement("canvas");glow=new cu;ridges;lx=new Float32Array(0);rx=new Float32Array(0);ry=new Float32Array(0);rows=0;resize(){let e=this.canvas.getBoundingClientRect();this.cssW=Math.max(100,e.width),this.cssH=Math.max(100,e.height),this.dpr=Math.min(window.devicePixelRatio||1,IC),this.canvas.width=Math.round(this.cssW*this.dpr),this.canvas.height=Math.round(this.cssH*this.dpr),this.scale=Math.min(this.cssW/be,this.cssH/j),this.offX=(this.cssW-be*this.scale)/2,this.offY=(this.cssH-j*this.scale)/2,this.vis={x0:-this.offX/this.scale,y0:-this.offY/this.scale,x1:(this.cssW-this.offX)/this.scale,y1:(this.cssH-this.offY)/this.scale},this.rows=Math.ceil((this.vis.y1-this.vis.y0+32)/fl)+1,this.lx=new Float32Array(this.rows),this.rx=new Float32Array(this.rows),this.ry=new Float32Array(this.rows),this.buildBackground()}buildBackground(){let e=this.bg;e.width=this.canvas.width,e.height=this.canvas.height;let t=e.getContext("2d");this.applyWorldTransform(t,0,0);let{x0:r,y0:s,x1:n,y1:o}=this.vis,a=t.createLinearGradient(0,s,0,j*.7);a.addColorStop(0,ae.skyTop),a.addColorStop(.45,ae.skyMid),a.addColorStop(1,ae.skyHorizon),t.fillStyle=a,t.fillRect(r,s,n-r,o-s);let l=be/2,c=j*.44,h=70,u=t.createRadialGradient(l,c,0,l,c,h*3.2);u.addColorStop(0,"rgba(255,233,184,0.55)"),u.addColorStop(.4,"rgba(255,180,84,0.22)"),u.addColorStop(1,"rgba(255,180,84,0)"),t.fillStyle=u,t.fillRect(l-h*3.2,c-h*3.2,h*6.4,h*6.4),t.fillStyle=ae.sunCore,t.beginPath(),t.arc(l,c,h,0,Math.PI*2),t.fill();let d=["rgba(58, 28, 16, 0.75)","rgba(107, 47, 26, 0.6)"];this.ridges.forEach((p,m)=>{t.fillStyle=d[m],t.beginPath(),t.moveTo(p[0].x,j*.65);for(let x of p)t.lineTo(x.x,x.y);t.lineTo(p[p.length-1].x,j*.65),t.closePath(),t.fill()})}applyWorldTransform(e,t,r){let s=this.dpr*this.scale;e.setTransform(s,0,0,s,this.dpr*(this.offX+t),this.dpr*(this.offY+r))}render(e){let t=this.ctx,{sim:r,fx:s,alpha:n}=e;t.setTransform(1,0,0,1,0,0),t.drawImage(this.bg,0,0);let o=s.shake,a=o>.1?(Math.random()-.5)*o*this.scale:0,l=o>.1?(Math.random()-.5)*o*this.scale:0;this.applyWorldTransform(t,a,l),this.drawHaze(e.idle),this.drawDust(e);let c=Rt(r.prevDist,r.dist,n);this.sampleWalls(e,c),this.drawWalls(c),t.save(),this.clipCorridor();for(let h of r.hostiles)h.kind==="gate"&&this.drawField(h,n);this.drawPickups(e);for(let h of r.hostiles)h.kind!=="gate"&&this.drawEnemy(h,n);this.drawProjectiles(e),this.drawParticles(e),this.drawPlayer(e),e.debug&&this.drawHitboxes(e),t.restore()}drawHaze(e){let t=this.ctx,{x0:r,x1:s}=this.vis;t.save(),t.globalAlpha=.25,t.strokeStyle="rgba(255,207,138,0.5)",t.lineWidth=1;for(let n=0;n<4;n++){let o=j*.6+n*6;t.beginPath(),t.moveTo(r,o+Math.sin(e*.05+n)*3);for(let a=r;a<=s;a+=20)t.lineTo(a,o+Math.sin(a*.03+e*.06+n)*3);t.stroke()}t.restore()}drawDust(e){let t=this.ctx;for(let r of e.fx.motes){let s=.5+Math.sin(r.phase)*.5;t.fillStyle=`rgba(255,208,150,${(r.alpha*s).toFixed(3)})`,t.fillRect(r.x,r.y,r.size,r.size)}}sampleWalls(e,t){let r={left:0,right:0},s=this.vis.y0-16;for(let n=0;n<this.rows;n++){let o=s+n*fl;e.sim.canyon.at(t+(j-o),r),this.lx[n]=r.left,this.rx[n]=r.right,this.ry[n]=o}}wallPath(e,t){let r=this.ctx,s=this.rows;r.beginPath(),r.moveTo(t,this.ry[0]);for(let n=0;n<s;n++)r.lineTo(e[n],this.ry[n]);r.lineTo(t,this.ry[s-1]),r.closePath()}edgePath(e){let t=this.ctx;t.beginPath(),t.moveTo(e[0],this.ry[0]);for(let r=1;r<this.rows;r++)t.lineTo(e[r],this.ry[r])}drawWalls(e){let t=this.ctx,{x0:r,x1:s,y0:n,y1:o}=this.vis,a=t.createLinearGradient(0,n,0,o);a.addColorStop(0,ae.sandDark),a.addColorStop(1,ae.sandShadow),t.fillStyle=a,this.wallPath(this.lx,r),t.fill(),this.wallPath(this.rx,s),t.fill();let l=this.ry[0];t.save(),t.globalAlpha=.35,t.lineWidth=2;let c=e+(j-l);for(let u=Math.floor(c/Rg);;u--){let d=j-(u*Rg-e);if(d>o+8)break;let p=Math.round((d-l)/fl);p<0||p>=this.rows||(t.strokeStyle=u%2===0?ae.sandLight:ae.sandMid,t.beginPath(),t.moveTo(r,d),t.lineTo(this.lx[p],d),t.moveTo(s,d),t.lineTo(this.rx[p],d),t.stroke())}t.restore(),t.save(),t.strokeStyle=ae.rim,t.lineJoin="round",t.globalAlpha=.18,t.lineWidth=7,this.edgePath(this.lx),t.stroke(),this.edgePath(this.rx),t.stroke(),t.globalAlpha=1,t.lineWidth=1.5,this.edgePath(this.lx),t.stroke(),this.edgePath(this.rx),t.stroke(),t.restore(),t.strokeStyle="rgba(58, 28, 16, 0.6)",t.lineWidth=1,t.beginPath();for(let u=Math.floor(c/Bg);;u--){let d=j-(u*Bg-e);if(d>o+8)break;let p=Math.round((d-l)/fl);p<0||p>=this.rows||(t.moveTo(this.lx[p],d),t.lineTo(this.lx[p]+10,d+6),t.moveTo(this.rx[p],d),t.lineTo(this.rx[p]-10,d+6))}t.stroke();let h=t.createLinearGradient(0,j*.75,0,o);h.addColorStop(0,"rgba(217,138,79,0)"),h.addColorStop(1,"rgba(217,138,79,0.08)"),t.fillStyle=h,t.fillRect(r,j*.75,s-r,o-j*.75)}clipCorridor(){let e=this.ctx;e.beginPath(),e.moveTo(this.lx[0],this.ry[0]);for(let t=1;t<this.rows;t++)e.lineTo(this.lx[t],this.ry[t]);for(let t=this.rows-1;t>=0;t--)e.lineTo(this.rx[t],this.ry[t]);e.closePath(),e.clip()}glowAt(e,t,r,s,n=1){let o=this.ctx,a=o.globalCompositeOperation,l=o.globalAlpha;o.globalCompositeOperation="lighter",o.globalAlpha=n,o.drawImage(this.glow.get(e),t-s,r-s,s*2,s*2),o.globalCompositeOperation=a,o.globalAlpha=l}pos(e,t){return[Rt(e.px,e.x,t),Rt(e.py,e.y,t)]}drawEnemy(e,t){let r=this.ctx,[s,n]=this.pos(e,t),o=e.flash>0,a=s+e.w/2,l=n+e.h/2;if(this.glowAt(o?ae.hot:ae.rust,a,l,e.w*(o?1.4:1),o?.8:.45),r.strokeStyle=o?ae.hot:ae.rust,r.fillStyle=o?"rgba(255,245,224,0.5)":"rgba(30,15,8,0.85)",r.lineWidth=1,r.beginPath(),e.kind==="drone")r.rect(s,n,e.w,e.h),r.fill(),r.stroke(),r.beginPath(),r.moveTo(s,n),r.lineTo(s+e.w,n+e.h),r.moveTo(s+e.w,n),r.lineTo(s,n+e.h),r.stroke();else if(e.kind==="uav"){for(let h=0;h<6;h++){let u=h*Math.PI/3,d=a+Math.cos(u)*e.w/2,p=l+Math.sin(u)*e.h/2;h===0?r.moveTo(d,p):r.lineTo(d,p)}r.closePath(),r.fill(),r.stroke()}else e.kind==="mine"?(r.arc(a,l,e.w/2,0,Math.PI*2),r.fill(),r.stroke()):(r.rect(s,n,e.w,e.h),r.fill(),r.stroke());r.fillStyle=o?"#ffffff":ae.amberBright,r.beginPath(),r.arc(a,l,2,0,Math.PI*2),r.fill();let c=e.hp/e.maxHp;r.fillStyle=c>.5?ae.amberBright:c>.2?"#ffcf3a":ae.rust,r.fillRect(s,n-4,e.w*c,2)}drawField(e,t){let r=this.ctx,[s,n]=this.pos(e,t);r.save(),r.strokeStyle=e.flash>0?ae.hot:ae.amber,r.lineWidth=2,r.globalAlpha=.3+Math.sin(e.pulse)*.2,r.beginPath();for(let o=0;o<e.w;o+=8){let a=Math.sin(e.pulse+o*.2)*4;r.moveTo(s+o,n),r.lineTo(s+o+a,n+e.h)}r.stroke(),r.globalAlpha=1,r.strokeRect(s,n,e.w,e.h),r.fillStyle=ae.amberBright;for(let o=0;o<3;o++)for(let a=0;a<6;a++){let l=Math.sin(e.pulse+o+a)*2;r.fillRect(s+(o+1)*e.w/4+l,n+(a+1)*e.h/7+l,2,2)}r.restore()}drawPickups(e){let t=this.ctx;t.font='8px "Share Tech Mono", monospace',t.textAlign="center",t.textBaseline="middle";for(let r of e.sim.pickups){let[s,n]=this.pos(r,e.alpha),o=s+r.w/2,a=n+r.h/2;this.glowAt(ae.amberBright,o,a,14,.5),t.save(),t.translate(o,a),t.rotate(r.rot),t.strokeStyle=ae.amberBright,t.lineWidth=1,t.fillStyle="rgba(240, 164, 76, 0.25)",t.beginPath(),t.moveTo(0,-r.h/2),t.lineTo(r.w/2,0),t.lineTo(0,r.h/2),t.lineTo(-r.w/2,0),t.closePath(),t.fill(),t.stroke(),t.fillStyle=ae.amberBright,t.fillText(r.kind==="fuel"?"F":r.kind==="shield"?"S":"M",0,0),t.restore()}}drawProjectiles(e){let t=this.ctx;for(let r of e.sim.enemyShots){let[s,n]=this.pos(r,e.alpha);this.glowAt(ae.rust,s+r.w/2,n+r.h/2,r.w*1.6,.9),t.fillStyle=ae.hot,t.beginPath(),t.arc(s+r.w/2,n+r.h/2,r.w/3,0,Math.PI*2),t.fill()}t.strokeStyle=ae.rust,t.lineWidth=1.2;for(let r of e.sim.hazards)t.beginPath(),t.arc(r.x,r.y,r.r,0,Math.PI*2),t.stroke(),t.beginPath(),t.arc(r.x,r.y,r.r*(r.timer/r.maxTimer),0,Math.PI*2),t.stroke();for(let r of e.sim.flareObjs)this.glowAt("#ffd0f0",r.x,r.y,10,1);for(let r of e.sim.bullets){let[s,n]=this.pos(r,e.alpha);this.glowAt(ae.amberBright,s+1,n+4,7,.6),t.fillStyle=ae.hot,t.fillRect(s,n,r.w,r.h)}for(let r of e.sim.playerMissiles){let[s,n]=this.pos(r,e.alpha);this.glowAt(ae.rust,s+2,n+6,12,.7),t.fillStyle=ae.amberBright,t.fillRect(s,n,r.w,r.h);for(let o=0;o<3;o++)t.fillStyle=`rgba(217, 80, 47, ${.5-o*.15})`,t.fillRect(s,n+r.h+o*3,r.w,2)}}drawParticles(e){let t=this.ctx;for(let r of e.fx.particles){if(r.delay>0)continue;let s=1-r.life/r.maxLife,n=Math.max(0,Math.min(1,r.alpha*(1-s))),o=r.kind==="smoke"?`rgba(90,70,80,${(n*.6).toFixed(3)})`:r.kind==="dust"?`rgba(217,160,112,${(n*.5).toFixed(3)})`:r.kind==="scorch"||r.kind==="debris"?`rgba(20,10,12,${(n*.5).toFixed(3)})`:`rgba(255,${Math.round(220-s*140)},${Math.round(150-s*120)},${n.toFixed(3)})`;r.kind==="ring"?(t.strokeStyle=o,t.lineWidth=2,t.beginPath(),t.arc(r.x,r.y,r.size,0,Math.PI*2),t.stroke()):r.kind==="spark"?(t.strokeStyle=o,t.lineWidth=1,t.beginPath(),t.moveTo(r.x,r.y),t.lineTo(r.x-r.vx*2,r.y-r.vy*2),t.stroke()):(t.fillStyle=o,t.beginPath(),t.arc(r.x,r.y,Math.max(.5,r.kind==="flash"?r.size*.5:r.size),0,Math.PI*2),t.fill())}}drawPlayer(e){let t=this.ctx,r=e.sim.player;if(r.invuln>0&&Math.floor(r.invuln/5)%2===0)return;let[s,n]=this.pos(r,e.alpha),o=e.sim.tick;if(t.save(),t.globalAlpha=(.6+Math.sin(o*.4)*.15)*.45,t.fillStyle=ae.dust,t.beginPath(),t.ellipse(s+8,n+15,5,3,0,0,Math.PI*2),t.fill(),t.restore(),this.glowAt(ae.rust,s+8,n+9,14,.35),t.save(),t.translate(s+8,n+9),t.rotate(r.steer*.12),t.translate(-8,-9),t.fillStyle="#241108",t.save(),t.globalAlpha=.3,t.fillRect(-8,2,32,1),t.restore(),Math.floor(o/2)%2===0?t.fillRect(-6,2,28,2):t.fillRect(6,0,2,6),t.fillRect(4,6,8,6),t.fillRect(2,8,12,4),t.fillRect(12,9,4,2),t.fillRect(15,7,2,6),t.fillRect(2,12,2,2),t.fillRect(10,12,2,2),t.strokeStyle=ae.rim,t.lineWidth=1,t.strokeRect(2,8,12,4),t.fillStyle=ae.amberBright,t.fillRect(5,7,2,1.5),t.restore(),r.muzzle>0){let a=r.muzzle/4;this.glowAt(ae.hot,s+r.w/2,n-2,10*a,1),t.fillStyle=`rgba(255,230,180,${a})`,t.beginPath(),t.arc(s+r.w/2,n-2,5*a,0,Math.PI*2),t.fill()}r.flash>0&&(t.strokeStyle=`rgba(217,80,47,${r.flash/6})`,t.lineWidth=3,t.beginPath(),t.arc(s+r.w/2,n+r.h/2,16,0,Math.PI*2),t.stroke())}drawHitboxes(e){let t=this.ctx;t.lineWidth=1,t.strokeStyle="#00ff88";let r=e.sim.player;t.strokeRect(r.x,r.y,r.w,r.h),t.strokeStyle="#ff3366";for(let s of e.sim.hostiles)t.strokeRect(s.x,s.y,s.w,s.h);t.strokeStyle="#66ccff";for(let s of e.sim.pickups)t.strokeRect(s.x,s.y,s.w,s.h)}};async function iR(i){if(!new URLSearchParams(location.search).has("canvas2d"))try{let{PixiRenderer:t}=await Promise.resolve().then(()=>(wM(),TM));return[await t.create(i),"webgl"]}catch(t){console.warn("WebGL renderer unavailable, falling back to Canvas2D",t)}return[new ml(i),"canvas2d"]}async function sR(){matchMedia("(pointer: coarse)").matches&&document.body.classList.add("touch"),await(document.fonts?.ready??Promise.resolve()).catch(()=>{});let i=document.getElementById("gameCanvas"),[e,t]=await iR(i),r=0;new ResizeObserver(()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>e.resize())}).observe(i.parentElement??i);let s=new URLSearchParams(location.search).get("seed"),n=s!==null&&/^\d+$/.test(s)?Number(s)>>>0:null;new pl(e,n,t).start()}sR();document.addEventListener("contextmenu",i=>i.preventDefault());})();
/*! Bundled license information:

tiny-lru/dist/tiny-lru.js:
  (**
   * tiny-lru
   *
   * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
   * @license BSD-3-Clause
   * @version 11.4.7
   *)
*/
</script>
  <script>
  (() => {
    document.querySelectorAll("[data-back-to-games]").forEach(link => {
      link.addEventListener("pointerdown", e => e.stopPropagation());
      link.addEventListener("click", e => {
        e.stopPropagation();
        try {
          localStorage.setItem("archive_menu_hidden", "false");
          window.parent?.dispatchEvent(new Event("archive-menu-toggle"));
        } catch {}
      });
    });
    document.querySelectorAll("[data-github-link]").forEach(link => {
      link.addEventListener("pointerdown", e => e.stopPropagation());
      link.addEventListener("click", e => e.stopPropagation());
    });
    async function toggleFull() {
      try {
        const pDoc = window.parent?.document;
        const fsEl = pDoc?.fullscreenElement || document.fullscreenElement;
        if (!fsEl) {
          const target = window.frameElement || document.documentElement;
          await target.requestFullscreen();
        } else if (pDoc?.fullscreenElement) {
          await pDoc.exitFullscreen();
        } else if (document.fullscreenElement) {
          await document.exitFullscreen();
        }
      } catch {
        try {
          if (!document.fullscreenElement) await document.documentElement.requestFullscreen();
          else await document.exitFullscreen();
        } catch {}
      }
    }
    document.querySelectorAll("[data-fullscreen-toggle]").forEach(btn => {
      btn.addEventListener("pointerdown", e => e.stopPropagation());
      btn.addEventListener("click", e => {
        e.stopPropagation();
        btn.blur();
        void toggleFull();
      });
    });
  })();
  </script>
</body>
</html>
MikeHiggins.me.uk LinkedIn GitHub Bluesky Contra Upwork
© 2026 Mike Higgins. All rights reserved.