Back to Underwatch Daily Rescue
SOURCE / PINNED RELEASE

Made of little things.

Underwatch Daily Rescue

Release
d1f3cd139f6b…
Author-recorded commit
Not provided
License
Check the original source

The hash-verified playable HTML, which may contain bundled or minified code. This view does not execute it.

index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Underwatch Daily Rescue</title>
  <meta name="description" content="Pick one gift before the Stone Maw strikes. A new free dungeon puzzle opens at midnight UTC.">
  <meta name="napplet-id" content="underwatch-daily-rescue">
  <style>
    :root { color-scheme: dark; font-family: system-ui, sans-serif; --text: #f9f1fd; --muted: #d4bfe2; --serif: Georgia, serif; --mono: monospace; }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body { margin: 0; background: #110d1a; color: var(--text); }
    main { max-width: 40rem; margin: 8vh auto; padding: 1rem; }
    h1, h2 { font-family: var(--serif); font-weight: 400; }
    h1 { font-size: clamp(1.8rem, 5vw, 3rem); margin: .4rem 0; }
    p { line-height: 1.4; }
    button { background: #342145; border: 1px solid #785590; border-radius: .4rem; color: inherit; cursor: pointer; min-height: 2.75rem; padding: .6rem .75rem; font: inherit; }
    button:hover:not(:disabled) { background: #50316a; }
    button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #ddb1ff; outline-offset: 2px; }
    .eyebrow { margin: 0; color: #d7a9ee; font: 600 .8rem/1.3 var(--mono); letter-spacing: .05em; }
    .season-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
    .dialog { width: min(calc(100% - .75rem), 42rem); max-height: calc(100% - .75rem); padding: 0; overflow: auto; color: var(--text); background: #1b1527; border: 1px solid #61477c; border-radius: .65rem; }
    .dialog::backdrop { background: #0d0815de; }
    .dialog-shell { position: relative; padding: clamp(.7rem, 3vw, 1.35rem); }
    .dialog-close { position: absolute; right: .6rem; top: .55rem; }
    .dialog-close button { padding: .25rem .5rem; min-height: 2rem; }
    .dialog h2 { margin: .3rem 0; font-size: 1.9rem; }
    .rescue-canvas { display: block; width: 100%; height: auto; border: 1px solid #513960; border-radius: .4rem; }
    .rescue-objective, .rescue-note { color: var(--muted); }
    .rescue-note { font-size: .875rem; }
    .rescue-gifts { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); }
    .rescue-gifts button { text-align: left; }
    .rescue-gifts span { display: block; margin-top: .2rem; font-size: .875rem; color: var(--muted); }
    input, textarea { width: 100%; padding: .55rem; border: 1px solid #785590; border-radius: .35rem; background: #241a30; color: var(--text); font: .875rem/1.4 var(--mono); }
  </style>
</head>
<body>
  <main>
    <p class="eyebrow">UNDERWATCH</p>
    <h1>Daily Rescue</h1>
    <p>Pick one gift for Brakka before the Stone Maw strikes. A new free puzzle opens at midnight UTC.</p>
    <div class="season-actions">
      <button type="button" id="play">Play today’s puzzle</button>
      <button type="button" id="watch">Watch the live fight</button>
      <button type="button" id="sponsor">Sponsor a crawler · $3</button>
    </div>
    <p id="launch-status" role="status"></p>
    <input id="launch-url" aria-label="Underwatch address" readonly hidden>
  </main>
  <dialog id="rescue" class="dialog rescue-dialog" aria-labelledby="rescue-title">
    <div class="dialog-shell">
      <div class="dialog-close"><button type="button">Close</button></div>
      <p class="eyebrow">PRACTICE SCENE</p>
      <h2 id="rescue-title">Can Brakka survive?</h2>
      <p id="rescue-objective" class="rescue-objective" hidden></p>
      <canvas class="rescue-canvas" width="680" height="240" aria-hidden="true"></canvas>
      <p class="rescue-status" role="status"></p>
      <div class="season-actions" id="rescue-choices">
        <button type="button" class="scene-button" id="rescue-tonic">Send a free tonic</button>
        <button type="button" class="scene-button" id="rescue-wait">Let the strike land</button>
      </div>
      <div class="rescue-gifts" id="rescue-daily-choices" role="group" aria-label="Choose one free gift" hidden>
        <button type="button" class="scene-button"><strong>Vitality tonic</strong><span>Restore up to 30 HP</span></button>
        <button type="button" class="scene-button"><strong>Field training</strong><span>45 XP. Level up for +2 attack.</span></button>
        <button type="button" class="scene-button"><strong>Runeforged charm</strong><span>+3 attack and +8 HP</span></button>
      </div>
      <div class="season-actions" id="rescue-result" hidden>
        <button type="button" class="scene-button" id="rescue-again">Try again</button>
        <button type="button" class="scene-button" id="rescue-share" hidden>Copy result</button>
        <button type="button" class="scene-button" id="rescue-sponsor" hidden>Sponsor a live crawler · $3</button>
      </div>
      <p class="rescue-note" id="rescue-share-status" role="status" hidden></p>
      <textarea id="rescue-share-text" class="rescue-share-text" aria-label="Daily rescue result" rows="4" readonly hidden></textarea>
      <p class="rescue-note">Practice gifts are free. Use sponsor credits to send gifts in the shared run.</p>
    </div>
  </dialog>
  <script>(()=>{var v=[{id:"brakka",name:"Brakka Ironhand",role:"Warrior",style:"Bold",color:"#f1a16f",hp:110,attack:16,bio:"A forge guard who volunteered after her crew vanished below. She takes the first hit and remembers who stood beside her."},{id:"nyx",name:"Nyx the Unlucky",role:"Rogue",style:"Opportunist",color:"#75dfc3",hp:85,attack:14,bio:"A lockpicker with a talent for opening the wrong door. She eyes every supply cache, especially the ones someone else reached first."},{id:"vesper",name:"Vesper Hollow",role:"Mystic",style:"Cautious",color:"#bf9cf7",hp:90,attack:18,bio:"The only contestant who heard the Hollow calling by name. Behind a mask of bronze, he weighs every fight against the way out."},{id:"rook",name:"Rook Gamble",role:"Rogue",style:"Opportunist",color:"#efd17c",hp:85,attack:14,bio:"A cardsharp who treats every room like a wager. A good supply cache can make him forget which side he was on."},{id:"kestrel",name:"Kestrel Vane",role:"Warrior",style:"Loyal",color:"#8fb8f6",hp:105,attack:15,bio:"A caravan sentinel on his last tour. He gets between danger and an ally whenever he can reach them."},{id:"ilyra",name:"Ilyra of Ash",role:"Mystic",style:"Bold",color:"#ac9be8",hp:90,attack:17,bio:"An apprentice exorcist collecting proof that the Hollow can be killed. She prefers a decisive blow to a safe retreat."},{id:"sable",name:"Sable Renn",role:"Rogue",style:"Cautious",color:"#ed8a9c",hp:85,attack:15,bio:"A courier who crossed the salt desert alone. She keeps a clear route to the stairs and trusts anyone who shares their last tonic."},{id:"moss",name:"Moss Flint",role:"Warrior",style:"Loyal",color:"#a3d598",hp:105,attack:15,bio:"A veteran of the deep roads. He watches the wounded and would rather spend a tonic than leave someone behind."}],P=[{name:"The Gatehouse",color:"#a07be8",exit:[23,2]},{name:"The Drowned Vault",color:"#62a8cb",exit:[2,11]},{name:"The Bone Orchard",color:"#8fb481",exit:[23,11]},{name:"The Cinder Court",color:"#ce8c66",exit:[2,2]},{name:"The Hollow Heart",color:"#cc71ac",exit:[23,2]}],Q=[{id:"tonic",title:"Vitality tonic",desc:"Restore up to 30 health immediately.",cost:2,icon:"tonic"},{id:"training",title:"Field training",desc:"Grant 45 XP toward the next level.",cost:3,icon:"level"},{id:"relic",title:"Runeforged charm",desc:"Add 3 attack and 8 maximum health.",cost:5,icon:"diamond"}],tt=[[1,1,6,5],[9,1,15,4],[19,1,24,5],[2,8,8,12],[11,7,16,12],[20,8,24,12]],ne=Array.from({length:14},()=>Array(26).fill(!1));function Re(e,t,o,i){for(let s=t;s<=i;s++)for(let a=e;a<=o;a++)ne[s][a]=!0}for(let e of tt)Re(...e);for(let e of[[6,3,9,3],[15,2,19,2],[4,5,4,8],[12,4,12,7],[22,5,22,8],[8,10,11,10],[16,9,20,9]])Re(...e);var re=P.map((e,t)=>ne.map((o,i)=>o.map((s,a)=>ne[t%2?14-i-1:i][t===2||t===3?26-a-1:a])));function N(e){return re[e.floor]}var b=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),ee=e=>e.interval??3600,$e=e=>ee(e)===3600;function He([e,t]){return{x:e,y:t}}function g([e,t],o){return{x:o===2||o===3?26-e-1:e,y:o%2?14-t-1:t}}function G(e){return e.seed=Math.imul(e.seed,1664525)+1013904223>>>0,e.seed/4294967296}function S(e,t,o,i=[],s=1){let a={id:++e.eventId,kind:t,text:o,people:i,weight:s,time:e.clock,floor:e.floor};if(e.events.unshift(a),e.events.length=Math.min(e.events.length,96),s>=2)for(let r of e.agents.filter(l=>i.includes(l.id)))r.memories=[a,...r.memories??[]].slice(0,8)}var D=[[4,3],[10,3],[13,8],[6,10],[4,10],[14,3],[21,11],[20,3]],Ce=[{kind:"wraith",name:"Rift Wraith",hp:48,attack:12},{kind:"maw",name:"Stone Maw",hp:66,attack:16}];function Z(e,t,o){let i=Ce[t],s=i.hp+e.floor*11,a={...i,...o,hp:s,maxHp:s,id:`enemy-${++e.enemyId}`,attack:i.attack+e.floor*2};e.monsters.push(a),e.frame?.floor===e.floor&&e.frame.turn===e.turn&&O(e,{type:"spawn",unit:Ie(a)})}function xe(e){e.turn=0,e.monsters=[],e.caches=[[2,4],[14,2],[3,11],[15,11],[23,10]].map((t,o)=>({...g(t,e.floor),loot:["tonic","blade","tonic","ward","tonic"][o]}));for(let[t,o]of e.agents.entries())o.hp&&(Object.assign(o,g(D[t],e.floor)),o.hp=Math.min(o.maxHp,o.hp+(e.floor?23:0)),o.escaped=!1,o.goal=null,o.activity="Exploring");Z(e,0,g([11,2],e.floor)),Z(e,1,g([15,9],e.floor)),Z(e,0,g([22,10],e.floor)),S(e,"floor",`${P[e.floor].name} is open. ${e.agents.filter(t=>t.hp).length} crawlers enter.`,[],3)}function Ae(e,t=1,o=(e^e/4294967296)>>>0,i=[],s=12e3){let a={version:1,number:t,clock:e,interval:s,seed:o,floor:0,turn:0,enemyId:0,completed:!1,eventId:0,events:[],recaps:[],history:i,agents:v.map((r,l)=>({id:r.id,index:l,hp:r.hp,maxHp:r.hp,attack:r.attack,level:1,xp:0,tonic:l%2===0?1:0,gear:[],relationships:{},kills:0,sponsoredFloor:-1}))};return xe(a),a}function Le(e,{x:t,y:o}){return[[t+1,o],[t-1,o],[t,o+1],[t,o-1]].filter(([i,s])=>e[s]?.[i]).map(He)}function ot(e,t,o){let i=t.y*26+t.x,s=o.y*26+o.x;if(i===s)return null;let a=it.get(e);if(!a[s]){let f=new Int16Array(364).fill(-1),n=[s];f[s]=0;for(let c=0;c<n.length;c++){let d=n[c];for(let h of Se.get(e)[d])f[h]===-1&&(f[h]=f[d]+1,n.push(h))}a[s]=f}let r=a[s],l=Se.get(e)[i].find(f=>r[f]>=0&&r[f]<r[i]);return l===void 0?null:{x:l%26,y:Math.floor(l/26)}}var Se=new Map(re.map(e=>[e,e.flatMap((t,o)=>t.map((i,s)=>i?Le(e,{x:s,y:o}).map(a=>a.y*26+a.x):[]))])),it=new Map(re.map(e=>[e,Array(364)]));function O(e,t){e.frame?.time===e.clock&&e.frame.actions.push(t)}function Ie(e,t){return{id:e.id??t,x:e.x,y:e.y,hp:e.hp,maxHp:e.maxHp??e.hp,index:e.index,kind:e.kind,escaped:e.escaped,direction:e.direction}}function st(e){e.enemyId??=0;for(let o of e.monsters)o.id??=`enemy-${++e.enemyId}`,o.maxHp??=(Ce.find(i=>i.kind===o.kind)?.hp??o.hp)+e.floor*11;let t=_(e);e.frame={floor:e.floor,turn:e.turn,time:e.clock,units:[...e.agents.filter(o=>o.hp),...e.monsters].map(o=>Ie(o)),caches:e.caches.map(o=>({...o})),threat:t?{actor:t.monster.id,target:t.crawler.id}:null,actions:[]}}function Oe(e,t,o,i){t.direction=Math.atan2(o.y-t.y,o.x-t.x),Object.assign(t,o),O(e,{type:i,actor:t.id,x:o.x,y:o.y})}function z(e,t,o,i){let s=ot(N(e),t,o);return s&&Oe(e,t,s,i&&b(i,t)<=1&&b(i,s)>1?"dodge":"walk"),!!s}function J(e,t,o){t.xp+=o,!(t.xp<ve(t))&&(t.xp-=ve(t),t.level++,t.maxHp+=7,t.hp=Math.min(t.maxHp,t.hp+7),t.attack+=2,S(e,"level",`${v[t.index].name} reached level ${t.level}.`,[t.id],3))}function ve(e){return 25+e.level*15}function le(e,t,o){let i=Math.max(-4,Math.min(4,(e.relationships[t.id]??0)+o));e.relationships[t.id]=i,t.relationships[e.id]=i}function Me(e,t,o=t){t.tonic--;let i=o.hp;o.hp=Math.min(o.maxHp,o.hp+24),O(e,{type:"heal",actor:t.id,target:o.id,hp:o.hp,amount:o.hp-i});let s=v[t.index].name;if(t===o){t.activity="Recovering",S(e,"loot",`${s} drank a tonic and recovered health.`,[t.id]);return}t.activity="Helping an ally",le(t,o,2),S(e,"bond",`${s} shared a tonic with ${v[o.index].name}.`,[t.id,o.id],3)}function at(e,t,o,i){let s=t.attack+Math.floor(G(e)*7);t.direction=Math.atan2(o.y-t.y,o.x-t.x),o.hp=Math.max(0,o.hp-s),O(e,{type:"strike",actor:t.id,target:o.id,x:o.x,y:o.y,damage:s,hp:o.hp}),t.activity="In combat";let a=v[t.index].name;if(o.hp){S(e,"combat",`${a} struck a ${o.name} for ${s} damage.`,[t.id]);return}if(t.kills++,S(e,"combat",`${a} defeated a ${o.name}.`,[t.id],3),o.windup){let l=v.find(f=>f.id===o.windup.crawler);S(e,"outcome",`${a} stopped the ${o.name} before it could strike ${l.name}.`,[...new Set([l.id,t.id])],5)}J(e,t,24);let r=i.find(l=>b(t,l)<=2);if(r){let l=t.relationships[r.id]??0;le(t,r,1),l===1&&S(e,"bond",`${a} and ${v[r.index].name} formed an alliance.`,[t.id,r.id],3),J(e,r,9)}}function nt(e,t,o,i){let s;o.loot==="tonic"&&(s="a vitality tonic",t.tonic++),o.loot==="blade"&&(s="a glassblade",t.attack+=2,t.gear.push("Glassblade")),o.loot==="ward"&&(s="a stoneward",t.maxHp+=6,t.hp+=6,t.gear.push("Stoneward"));let a=i.find(l=>l.goal&&b(l.goal,o)===0&&b(l,o)<=2),r=v[t.index].name;a&&v[t.index].style==="Opportunist"?(le(t,a,-2),S(e,"bond",`${r} snatched ${s} from under ${v[a.index].name}\u2019s nose.`,[t.id,a.id],3)):S(e,"loot",`${r} recovered ${s} from a supply cache.`,[t.id],2),e.caches.splice(e.caches.indexOf(o),1),O(e,{type:"loot",actor:t.id,x:o.x,y:o.y}),J(e,t,13),t.goal=null,t.activity="Scavenging"}function rt(e,t){let o=e.agents.filter(c=>c!==t&&c.hp&&!c.escaped),{name:i,style:s}=v[t.index];if(t.tonic&&t.hp<=t.maxHp*.52)return Me(e,t);let a=o.find(c=>b(t,c)<=2&&c.hp<c.maxHp*.5&&(s==="Loyal"||t.relationships[c.id]>=2));if(t.tonic&&a)return Me(e,t,a);let r=He(P[e.floor].exit);if(e.turn>=22||e.turn>=15&&t.hp<t.maxHp*.35){let c=e.monsters.find(d=>d.windup?.crawler===t.id);for(let d=0;d<2;d++)z(e,t,r,c);if(t.activity="Heading to exit",b(t,r)===0){if(e.turn<22&&!$e(e)){t.activity="At the locked stairs";return}t.escaped=!0,O(e,{type:"exit",actor:t.id}),t.activity="Reached exit",S(e,"floor",`${i} reached the exit.`,[t.id],2)}return}let f=e.monsters.filter(c=>c.hp).sort((c,d)=>b(t,c)-b(t,d))[0];if(s==="Cautious"&&f&&b(t,f)<=2&&t.hp<t.maxHp*.42){let c=Le(N(e),t).find(d=>b(d,f)>b(t,f));if(c){Oe(e,t,c,"dodge"),t.activity="Retreating";return}}if(f&&b(t,f)<=1)return at(e,t,f,o);let n=e.caches.slice().sort((c,d)=>b(t,c)-b(t,d))[0];if(n&&b(t,n)===0)return nt(e,t,n,o);if(f&&b(t,f)<=(s==="Bold"?11:4)&&(s==="Bold"||!n||b(t,n)>=4)){t.activity="Hunting",z(e,t,f);return}n&&(s==="Opportunist"||b(t,n)<11)?t.goal=n:(!t.goal||!N(e)[t.goal.y]?.[t.goal.x]||b(t,t.goal)<=1||e.turn%6===0)&&(t.goal=g(D[Math.floor(G(e)*D.length)],e.floor)),t.activity="Exploring",z(e,t,t.goal)}function _(e){if(e.completed)return null;for(let t of e.monsters){if(!t.hp||!t.windup)continue;let o=e.agents.find(i=>i.id===t.windup.crawler&&i.hp&&!i.escaped);if(o)return{monster:t,crawler:o,damage:t.windup.damage,at:e.clock+(t.windup.turn-e.turn)*ee(e)}}return null}function Te(e,t,o,i,s){t.direction=Math.atan2(o.y-t.y,o.x-t.x),o.hp=Math.max(0,o.hp-i),O(e,{type:"strike",actor:t.id,target:o.id,x:o.x,y:o.y,damage:i,hp:o.hp,heavy:!!s});let a=v[o.index].name;if(!o.hp)o.activity="Fallen",S(e,"fallen",s?`The ${t.name}\u2019s charged strike felled ${a}.`:`${a} fell to a ${t.name}.`,[o.id],5);else if(s){let r=s.giftHp?`A sponsor restored ${s.giftHp} HP before the blow. `:"";S(e,"outcome",`${r}${a} took the ${t.name}\u2019s strike and held on with ${o.hp} HP.`,[o.id],5)}else S(e,"combat",`A ${t.name} hit ${a} for ${i} damage.`,[o.id])}function lt(e){let t=e.agents.filter(o=>o.hp&&!o.escaped);for(let o of e.monsters){if(!o.hp)continue;if(o.windup){let r=o.windup,l=t.find(f=>f.id===r.crawler&&f.hp);if(!l){delete o.windup;continue}if(e.turn<r.turn)continue;delete o.windup,b(o,l)<=1?Te(e,o,l,r.damage,r):(O(e,{type:"strike",actor:o.id,target:l.id,x:r.x??l.x,y:r.y??l.y,heavy:!0,missed:!0}),S(e,"outcome",`${v[l.index].name} stepped clear. The ${o.name}\u2019s strike missed.`,[l.id],5));continue}t.sort((r,l)=>b(o,r)-b(o,l)||r.hp-l.hp);let i=t.find(r=>r.hp);if(!i)break;let s=b(o,i);if(s>1){s<=10&&z(e,o,i);continue}if(!$e(e)&&e.turn<34&&!e.monsters.some(r=>r.windup)&&e.turn>=(o.chargeAfter??0)&&(o.kind==="maw"||i.hp<=o.attack+8)){let r=o.attack+(o.kind==="maw"?12:8);o.windup={crawler:i.id,x:i.x,y:i.y,turn:e.turn+2,damage:r},o.direction=Math.atan2(i.y-o.y,i.x-o.x),o.chargeAfter=e.turn+7,O(e,{type:"charge",actor:o.id,target:i.id}),S(e,"danger",`The ${o.name} takes aim at ${v[i.index].name}. A ${r}-damage strike is coming.`,[i.id],4);continue}Te(e,o,i,o.attack+Math.floor(G(e)*5))}}function ct(e){for(let i of e.agents)!i.hp||i.escaped||(i.hp=0,O(e,{type:"fall",actor:i.id}),i.activity="Fallen",S(e,"fallen",`${v[i.index].name} was trapped when the floor sealed.`,[i.id],4));let t=e.agents.filter(i=>i.hp).map(i=>v[i.index].name),o=e.events.filter(i=>i.floor===e.floor&&i.weight>=2&&i.people.length).sort((i,s)=>s.weight-i.weight||s.id-i.id).slice(0,4).sort((i,s)=>i.id-s.id);if(e.recaps.push({floor:e.floor,survivors:t,highlights:o}),!t.length||e.floor===P.length-1){e.completed=!0,S(e,"floor",t.length?`${t.length} crawlers survived the Hollow.`:"The Hollow claimed every crawler. The season is over.",[],5);return}e.floor++,xe(e)}function te(e){if(e.completed)return;e.clock+=ee(e),e.turn++,st(e),e.turn===22&&S(e,"floor","The exit is open. Crawlers are making their last run for the stairs.",[],3);let t=e.agents.filter(i=>i.hp&&!i.escaped),o=Math.floor(G(e)*t.length);for(let i of[...t.slice(o),...t.slice(0,o)])rt(e,i);if(lt(e),e.monsters=e.monsters.filter(i=>i.hp),e.turn<21&&e.turn%7===0&&e.monsters.length<4){let i=g(D[Math.floor(G(e)*D.length)],e.floor);Z(e,e.turn%2,i),S(e,"combat",`A ${e.monsters.at(-1).name} entered the floor.`)}(e.turn>=36||e.agents.every(i=>!i.hp||i.escaped))&&ct(e),e.frame.actions.some(i=>i.type==="strike")&&(e.lastFight={...e.frame,actions:e.frame.actions.slice()})}function Pe(e,t){for(;!e.completed&&e.clock+ee(e)<=t;)te(e)}function dt(e,t,o,i){return e.completed||!t.hp||t.escaped?"Unavailable on this floor":t.sponsoredFloor===e.floor?"Gift already delivered this floor":o.id==="tonic"&&t.hp===t.maxHp?"Health is already full":i===null?"Sign in to sponsor":i<o.cost?"Insufficient credits":""}function Ee(e,t,o,i){if(dt(e,t,o,i))return!1;t.sponsoredFloor=e.floor;let s=v[t.index].name;if(o.id==="tonic"){let a=Math.min(30,t.maxHp-t.hp);t.hp+=a;let r=e.monsters.find(l=>l.windup?.crawler===t.id);r&&(r.windup.giftHp=a),S(e,"support",`A sponsor restored ${a} HP to ${s} with a vitality tonic.`,[t.id],4)}else S(e,"support",`A sponsor sent ${s} ${o.id==="relic"?"a runeforged charm":"field training"}.`,[t.id],3);return o.id==="training"&&J(e,t,45),o.id==="relic"&&(t.attack+=3,t.maxHp+=8,t.hp+=8,t.gear.push(o.title)),!0}var y=40,F=26*y,q=14*y,ge=["#312c40","#332d43","#373148","#2c273a","#352f43","#3b344c"],Fe=["#3e344d","#443953","#3a3249","#41374f"];function oe(e,t,o=0){return((Math.imul(e+13,76157)^Math.imul(t+19,41843)^Math.imul(o,2351))>>>0)%97}function B(e,t,o,i,s){let a=e.createRadialGradient(t,o,2,t,o,i);a.addColorStop(0,s),a.addColorStop(1,"transparent"),e.fillStyle=a,e.fillRect(t-i,o-i,i*2,i*2)}function qe(e,t,o,i,s,a){e.beginPath(),e.moveTo(t,o-i),e.lineTo(t+i,o),e.lineTo(t,o+i),e.lineTo(t-i,o),e.closePath(),e.fillStyle=s,e.fill(),e.strokeStyle=a,e.stroke()}function Be(e){let t=document.createElement("canvas");t.width=F,t.height=q;let o=t.getContext("2d"),i=N({floor:e}),s=P[e].color,a=(n,c)=>i[c]?.[n];o.fillStyle="#100e18",o.fillRect(0,0,F,q),B(o,F*.55,q*.39,555,s+"15");for(let n=0;n<14;n++)for(let c=0;c<26;c++){let d=c*y,h=n*y,m=oe(c,n,e);if(a(c,n)){o.fillStyle=ge[m%ge.length],o.fillRect(d+1,h+1,y-2,y-2),o.fillStyle="#e6d2ff0a",o.fillRect(d+2,h+2,y-4,2);for(let p=0;p<13;p++){let k=oe(c+p,n,31)%36,u=oe(c,n+p,47)%36;o.fillStyle=p%2?"#08050b32":"#e6d2ff10",o.fillRect(d+2+k,h+2+u,1+p%3,1)}m%4===0&&(o.strokeStyle="#110d195f",o.beginPath(),o.moveTo(d+5,h+14),o.lineTo(d+14,h+17),o.lineTo(d+18,h+23),o.lineTo(d+29,h+22),o.stroke()),a(c,n-1)||(o.fillStyle="#0d091678",o.fillRect(d,h,y,11)),a(c+1,n)||(o.fillStyle="#110c1865",o.fillRect(d+y-6,h,6,y));continue}if(![a(c-1,n),a(c+1,n),a(c,n-1),a(c,n+1)].some(Boolean)){m%3===0&&(o.fillStyle="#40334f36",o.fillRect(d+m%18,h+m%22,5+m%11,2));continue}o.fillStyle="#16101f",o.fillRect(d,h+4,y,y-4);for(let p=0;p<2;p++){let k=p===0?5+m%10:20+m%9;o.fillStyle=Fe[(m+p)%Fe.length],o.fillRect(d+1,h+p*13,k,11),o.fillRect(d+k+3,h+p*13,y-k-4,11)}o.fillStyle="#8c72a452",o.fillRect(d+1,h,y-2,2),o.fillStyle="#221928",o.fillRect(d+1,h+25,y-2,5)}for(let[n,c]of[[1,1],[6,1],[9,1],[15,1],[19,1],[24,1],[2,8],[8,8],[11,7],[16,7],[20,8],[24,8]]){let d=((e===2||e===3?26-n-1:n)+.5)*y,h=((e%2?14-c-1:c)+.18)*y,p=oe(n,c)%3===0?s:"#d69661";B(o,d,h+5,77,p+"33"),B(o,d,h+1,28,p+"40"),o.fillStyle="#1a121e",o.fillRect(d-3,h+3,6,11),qe(o,d,h,5,p,"#f4d4b0"),o.fillStyle="#ffead3",o.fillRect(d-1,h-1,2,3)}let[r,l]=P[e].exit.map(n=>(n+.5)*y);B(o,r,l,48,s+"51"),o.fillStyle="#191125",o.fillRect(r-14,l-15,28,30),o.strokeStyle=s+"a0",o.strokeRect(r-13.5,l-14.5,27,29);for(let n=0;n<5;n++)o.fillStyle=s+["44","55","68","80","a0"][n],o.fillRect(r-10,l-10+n*5,20,3);let f=o.createRadialGradient(F/2,q*.48,q/3,F/2,q*.48,F*.63);return f.addColorStop(0,"transparent"),f.addColorStop(1,"#09070d8c"),o.fillStyle=f,o.fillRect(0,0,F,q),t}function Ue(e,t,o){if(t.turn>=22&&!t.completed){let[i,s]=P[t.floor].exit.map(a=>(a+.5)*y);B(e,i,s,54,"#d3afff65"),e.strokeStyle="#d3afff",e.strokeRect(i-14,s-15,28,30)}if(t.threat){let i=t.units.get(t.threat.target),s=t.units.get(t.threat.actor),a=(i.x+.5)*y,r=(i.y+.5)*y,l=Math.sin(o/205);B(e,a,r,63,"#df5e7c50"),e.save(),e.strokeStyle="#ff9caa",e.lineWidth=1.6,e.globalAlpha=.7+l*.2,e.setLineDash([5,4]),e.beginPath(),e.moveTo((s.x+.5)*y,(s.y+.5)*y),e.lineTo(a,r),e.stroke(),e.setLineDash([]),e.beginPath(),e.ellipse(a,r+3,18+l*2,10+l,0,0,Math.PI*2),e.stroke(),e.restore()}for(let i of t.caches){let s=(i.x+.5)*y,a=(i.y+.5)*y;B(e,s,a,23,"#f8bd6344"),e.fillStyle="#39262a",e.fillRect(s-9,a-5,18,12),e.strokeStyle="#d3a15c",e.strokeRect(s-9,a-5,18,12),e.fillRect(s-9,a-3,18,4),e.strokeRect(s-9,a-3,18,4),qe(e,s,a+.5,3,"#ffe1a0","#9b7257")}}function M(e,t,o,i="#15101e",s=1){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let[a,r]of t.slice(1))e.lineTo(a,r);e.closePath(),e.fillStyle=o,e.fill(),i&&(e.strokeStyle=i,e.lineWidth=s,e.stroke())}function I(e,t,o,i,s,a){e.beginPath(),e.ellipse(t,o,i,s,0,0,Math.PI*2),e.fillStyle=a,e.fill()}function w(e,t,o,i,s,a,r){e.beginPath(),e.moveTo(t,o),e.lineTo(i,s),e.strokeStyle=a,e.lineWidth=r,e.lineCap="round",e.stroke()}var fe=["#a97152","#ca9e79","#c0a276","#b67c58","#caa294","#c59177","#dfb3a1","#81523e"],ht="#bbb8c8";function pt(e,t,o,i,s){let{role:a,color:r}=v[t.index],l=a==="Warrior",f=a==="Mystic",n=l?8:6,c=f?"#33254d":l?"#383340":"#282430",d=Math.sin(s/670+t.index)*1.4-o,h=i?Math.sin(i*Math.PI)*8:0;M(e,[[-n,-23],[2,-21],[n+d,-2],[-3+d,1],[-n-4,-5]],c),M(e,[[-n,-22],[-4,-8],[-n-3,-5],[-n-1,-12]],r+"86",null);for(let u of[-1,1]){let $=u*o;w(e,u*3,-11,u*4+$,-3,"#15101c",5.2),w(e,u*3,-10,u*4+$,-3,l?"#666170":"#55475c",3.1),w(e,u*4+$,-2.4,u*4+$+3,-1.3,"#1c1821",3.8)}let m=e.createLinearGradient(-8,-20,9,-8);m.addColorStop(0,r),m.addColorStop(1,c),M(e,[[-n,-23],[n,-23],[6,-13],[3,-9],[-5,-10]],m),w(e,-5,-11,5,-11,"#2a1a21",2.7),I(e,1,-11,1.45,1.15,"#e7bf78"),l?(M(e,[[-8,-25],[-4,-24],[-4,-20],[-10,-19],[-11,-22]],ht),M(e,[[5,-25],[10,-24],[11,-20],[6,-19]],"#d3c5b7"),w(e,-4,-16,4,-18,"#d8c3a7",1.2)):(w(e,-5,-21,4,-15,r,1.8),I(e,-3,-16.5,1.2,1.2,"#d8bd84"));let p=n+2+h,k=-14-(i?Math.sin(i*Math.PI*1.5)*6:o*.55);if(w(e,-n+1,-20,-n-2-o*.4,-12,"#1a1521",4.6),w(e,n-1,-21,p,k,"#19111f",5.3),w(e,n-1,-21,p,k,r+"ce",3.4),I(e,p,k,2.1,1.8,fe[t.index]),l&&(t.index===4||t.index===7)&&(M(e,[[-13,-17],[-7,-18],[-6,-11],[-9,-8],[-13,-11]],"#6c6777","#251e2b",1.5),w(e,-9.5,-16,-9.5,-11,r,1.6)),e.save(),e.translate(p+.5,k),e.rotate(i?-.95+i*2.75:f?.22:-.54),f)w(e,0,9,0,-13,"#613c37",2.1),w(e,0,5,0,-11,"#ad8265",.9),M(e,[[0,-19],[3,-15],[0,-10],[-3,-15]],r,"#e5caff"),I(e,0,-15,i?5:3.6,i?5:3.6,r+"39");else{let u=l?16:10;w(e,0,3,0,-3,"#75523e",2.4),w(e,-3,-3,3,-3,"#d1af7d",1.55),M(e,[[-1.35,-4],[0,-u],[1.55,-u+3],[1.45,-4]],"#f6e5d2","#5a4c5c",.85)}e.restore(),l?(I(e,0,-27,5.8,6.1,"#211a26"),I(e,1,-26,4.2,4.7,fe[t.index]),M(e,[[-5,-31],[-1,-34],[5,-31],[5,-28],[1,-28],[-4,-26]],t.index===0?"#4d3033":"#8e879a"),w(e,1,-27.6,4,-27,"#422f38",.95)):(M(e,[[-6,-25],[-6,-30],[-2,-34],[2,-34],[6,-30],[6,-25],[2,-22],[-2,-22]],c),w(e,-4.5,-30,-1,-32.5,r,1.45),I(e,1.8,-27,3.3,3.65,t.index===2?"#a38568":fe[t.index]),w(e,1,-28.2,4,-28.2,t.index===2?"#f4c4ff":"#34232b",1),M(e,[[-3,-25],[5,-25],[1,-22],[-3,-23]],r+"b3",null))}function mt(e,t,o,i){let s=Math.sin(o/270+t.x),a=e.createLinearGradient(0,-33,0,1);a.addColorStop(0,"#cba7fa"),a.addColorStop(.47,"#794bac"),a.addColorStop(1,"#35205a35"),M(e,[[-8,-26],[-1,-34],[7,-30],[10,-21],[15+i,-15],[8,-12],[12+s,3],[4,-2],[1,-9],[-3,1],[-10+s,-3],[-8,-13],[-15,-11],[-11,-21]],a,"#3a245c"),M(e,[[-4,-27],[3,-29],[7,-24],[4,-19],[-2,-20]],"#261637",null),w(e,-1,-24.5,2,-24.5,"#f2cbff",1.7),w(e,4,-24.3,6,-24.1,"#f2cbff",1.5),w(e,7,-18,17+i,-15+s,"#b985e9",3.7),w(e,14+i,-14+s,19+i,-14+s,"#ecd1ff",1.15),I(e,1,-20,13,13,"#a26cde10")}function yt(e,t,o,i){for(let s of[-1,1]){let a=s*t;M(e,[[-12,-17],[-4,-16],[-7+a,-5],[-14+a,-3],[-15+a,-8]],"#514652","#211723"),M(e,[[5,-17],[10,-16],[16+a+o,-7],[12+a+o,-2],[7+a,-5]],"#78616a","#271822"),w(e,10+a+o,-4,15+a+o,-2,"#d2b8af",1.7)}M(e,[[-15,-17],[-14,-25],[-6,-32],[5,-32],[15,-27],[17,-18],[8,-12],[-9,-11]],"#665365","#251b2c",1.6),M(e,[[-11,-24],[-6,-32],[0,-33],[3,-25],[-4,-21]],"#9b7984","#513c51"),M(e,[[-2,-20],[5,-26],[13,-25],[15,-19],[8,-15],[1,-15]],"#7d6175","#342538"),M(e,[[7,-25],[12,-27],[20,-20],[20,-16],[11,-15],[6,-19]],"#9a7582","#40283b",1.4),M(e,[[11,-19],[20,-18],[18,-14],[11,-15]],"#301921",null),w(e,14,-21.4,18,-20.9,i?"#fff4b6":"#ff9a7c",i?2.6:1.8),w(e,7,-25,4,-20,i?"#ff5874":"#ae6975",1.6)}function We(e,t,o,i,s,a){let r=t.pose,l=r?.progress??0,f=r?.type==="walk",n=r?.type==="dodge",c=r?.type==="fall",d=r?.type==="hit",h=r?.type==="strike"?l:0,m=Math.cos(t.direction??0)<-.15?-1:1,p=f||n?Math.sin(l*Math.PI*4)*(n?4.5:3.2):0,k=h?Math.sin(h*Math.PI)*(r.heavy?12:8):0,u=d?Math.sin(l*Math.PI)*5:0,$=d?r.direction:t.direction??0,se=t.kind==="wraith"?Math.sin(s/370+t.x)*2.7-4:f?-Math.abs(p)*.7:Math.sin(s/620+t.x)*.8;e.save(),e.globalAlpha*=(t.opacity??(t.escaped?.27:1))*(c?1-l*.69:1),I(e,o,i,t.kind==="maw"?18:12,4,"#090610a0"),e.translate(o+Math.cos($)*(k+u),i+se+Math.sin($)*(k+u)),e.scale(m,1),n?(e.rotate(.32*Math.sin(l*Math.PI)),e.scale(1.1,1-Math.sin(l*Math.PI)*.32)):c?e.rotate(l*1.26):a&&t.kind==="maw"&&e.scale(1.03,.92+Math.sin(s/170)*.02),t.kind==="wraith"?mt(e,t,s,k*.75):t.kind==="maw"?yt(e,p,k*.72,a):pt(e,t,p,h,s),d&&l<.4&&I(e,0,-18,18*(.6+l),18,"#ff8e9b38"),e.restore()}function Ne(e,t,o,i,s,a,r){let l=t.kind?t.kind==="maw"?"Stone Maw":"Rift Wraith":v[t.index].name.split(" ")[0],f=t.kind?"#ff94aa":v[t.index].color,n=t.hp*3<=t.maxHp;if(e.fillStyle="#140e1ce8",e.fillRect(o-11,i+4,22,3.4),e.fillStyle=n?"#ff8499":t.kind?"#ee8bab":"#82deb0",e.fillRect(o-10,i+5,20*Math.min(1,t.hp/t.maxHp),1.65),!a&&!r)return;let c=Math.max(7.5,11/s);e.font=`600 ${c}px system-ui`;let d=e.measureText(l).width+7,h=i-37-c;e.fillStyle="#1b1326ea",e.fillRect(o-d/2,h,d,c+4),e.strokeStyle=r?"#ef82a0":"#725d88",e.lineWidth=.7,e.strokeRect(o-d/2,h,d,c+4),e.textAlign="center",e.fillStyle=f,e.fillText(l,o,h+c)}function Ge(e,t,o,i){let s=f=>(f+.5)*o,a=s(t.x),r=s(t.y),l=t.progress;if(e.save(),e.globalAlpha=(1-l)*.98,t.type==="trail")w(e,a+2,r-10,s(t.toX),s(t.toY)-10,"#b5e7f0",2.5),w(e,a-4,r-5,s(t.toX)-2,s(t.toY)-5,"#bea4ff",1.4);else{let f=t.type==="heal"?"#9df6c7":t.type==="miss"?"#c2dbff":"#ffd1a2";if(t.type!=="heal"){e.translate(a,r-10),e.rotate(t.direction),e.beginPath(),e.ellipse(1,0,(t.heavy?20:13)*(.5+l*.7),11,0,-1.1,1.1),e.strokeStyle=f,e.lineWidth=t.heavy?4:2.7,e.stroke(),e.rotate(-t.direction);for(let d=0;d<(t.heavy?8:5);d++){let h=d*2.347+t.direction,m=7+l*(17+d),p=Math.cos(h)*m,k=Math.sin(h)*m;w(e,p*.7,k*.7,p,k,f,1.4)}e.translate(-a,10-r)}else I(e,a,r-17,15+l*7,17,"#86f6bd55");let n=t.type==="miss"?"MISS":t.type==="heal"?`+${t.amount}`:`\u2212${t.amount}`;e.font=`800 ${Math.max(12,16/i)}px system-ui`,e.textAlign="center",e.strokeStyle="#211321",e.lineWidth=2.5;let c=r-36-l*17;e.strokeText(n,a,c),e.fillStyle=f,e.fillText(n,a,c)}e.restore()}var ut={walk:590,dodge:440,strike:760,heal:650,charge:430,loot:340,exit:510,spawn:650,fall:680},X=.49;function De(e){let t=new Map,o=0,i=0,s=e.actions.map(a=>{let r=[a.actor??a.unit?.id,a.target].filter(Boolean),l=Math.max(o,...r.map(n=>t.get(n)??0)),f=a.heavy?960:ut[a.type];for(let n of r)t.set(n,l+f);return o=l+115,i=Math.max(i,l+f),{...a,start:l,span:f}});return{frame:e,actions:s,duration:i}}var he=e=>Math.min(1,Math.max(0,e)),pe=e=>e*e*(3-2*e);function _e(e,t){let{frame:o,actions:i}=e,s=new Map(o.units.map(n=>[n.id,{...n}])),a=o.caches,r=o.threat,l,f=[];for(let n of i){if(t<n.start)break;let c=he((t-n.start)/n.span),d=s.get(n.actor),h=s.get(n.target);if(n.type==="spawn"){s.set(n.unit.id,{...n.unit,opacity:pe(c)});continue}if(d)switch(n.type){case"walk":case"dodge":{let m=d.x,p=d.y,k=Math.atan2(n.y-p,n.x-m),u=n.type==="dodge"?1-(1-c)**3:pe(c);d.x+=(n.x-m)*u,d.y+=(n.y-p)*u,d.direction=k,d.pose=c<1?{type:n.type,progress:c}:null,n.type==="dodge"&&c<1&&f.push({type:"trail",x:m,y:p,toX:d.x,toY:d.y,progress:c});break}case"charge":r={actor:n.actor,target:n.target},h&&(d.direction=Math.atan2(h.y-d.y,h.x-d.x));break;case"strike":{let m=Math.atan2(n.y-d.y,n.x-d.x);d.direction=m,d.pose=c<1?{type:"strike",progress:c,heavy:n.heavy,against:{x:n.x,y:n.y}}:null,c<1&&(!l||n.heavy)&&(l={actor:n.actor,target:n.target}),c>=X&&(n.heavy&&(r=null),h&&!n.missed&&(h.hp=n.hp,h.pose={type:n.hp?"hit":"fall",direction:m,progress:he((c-X)/(1-X))}),c<1&&f.push({type:n.missed?"miss":"impact",x:n.x,y:n.y,amount:n.damage,direction:m,progress:he((c-X)/(1-X)),heavy:n.heavy}));break}case"heal":h&&c>=.35&&(h.hp=n.hp,c<1&&f.push({type:"heal",x:h.x,y:h.y,amount:n.amount,progress:c}));break;case"loot":c>=.55&&(a=a.filter(m=>m.x!==n.x||m.y!==n.y));break;case"exit":d.opacity=1-pe(c)*.82,c===1&&(d.escaped=!0);break;case"fall":d.hp=0,d.pose={type:"fall",direction:0,progress:c};break}}return r&&(!s.get(r.actor)?.hp||!s.get(r.target)?.hp||s.get(r.target)?.escaped)&&(r=null),{floor:o.floor,turn:o.turn,units:s,caches:a,threat:r,effects:f,focus:l}}var me=864e5,je={survive:"Keep Brakka alive through the strike.",train:"Reach level 2 and survive the strike.",stop:"Defeat the Stone Maw before it can strike."},Xe=Object.keys(je);function Ve({seed:e=1,hp:t=24,attack:o=16}={}){let i=Ae(0,1,e),[s,...a]=i.agents;Object.assign(s,{x:4,y:3,hp:t,tonic:0});for(let r of a)r.hp=0;return i.monsters=[{x:5,y:3,hp:200,maxHp:200,kind:"maw",name:"Stone Maw",attack:o}],te(i),i}function j(e,t){let o=_(e),i=structuredClone(e),s=i.agents[0],a=s.hp;t&&Ee(i,s,t,t.cost);let r=s.hp-a;te(i);let l=i.frame;Pe(i,o.at),i.frame!==l&&l.actions.push(...i.frame.actions),r&&(l.units.find(n=>n.id===s.id).hp=a,l.actions.unshift({type:"heal",actor:s.id,target:s.id,hp:a+r,amount:r}));let f=i.monsters.find(n=>n.id===o.monster.id);return{playback:De(l),hp:s.hp,restoredHp:r,level:s.level,mawHp:f?.hp??0}}function kt(){let e=Ve(),{crawler:t,damage:o}=_(e);return{incoming:o,initialHp:t.hp,withTonic:j(e,Q[0]),withoutTonic:j(e)}}function wt(e,t){let o=Math.floor(e/me),i=/^\d{4}-\d{2}-\d{2}$/.test(t??"")?Date.parse(`${t}T00:00:00Z`):NaN,a=Number.isFinite(i)&&new Date(i).toISOString().startsWith(`${t}T`)?Math.min(o,i/me):o,r=Xe.length,l=Xe[(a%r+r)%r],f=Math.imul(a,2654435769)>>>0,n=14+f%9,c=1+f%97,d=Ve({seed:c,attack:n,hp:l==="survive"?n-3:n+24+f%7}),h=_(d),m="";if(l==="stop"){let k=j(d),u=h.monster.hp-k.mawHp;h.monster.hp=h.monster.maxHp=u+5,m=`The Maw has ${h.monster.hp} HP. Brakka\u2019s two swings deal ${u} base damage before the strike.`}let p=Q.map(k=>{let u=j(d,k),$=l==="train"?u.level>=2:l==="stop"?!u.mawHp:!0;return{...u,success:u.hp>0&&$}});return{date:new Date(a*me).toISOString().slice(0,10),goal:l,objective:je[l],hint:m,incoming:h.damage,initialHp:h.crawler.hp,withoutTonic:j(d),outcomes:p}}function bt(e,t,o){let i=new URL(o),s=new URL(i.pathname,i.origin);return s.searchParams.set("try","daily"),s.searchParams.set("day",e),`Underwatch Daily Rescue \xB7 ${e}
Solved in ${t} ${t===1?"try":"tries"}.
${s.href}`}function Ye(e,t,o=location.href){let i=e.querySelector("canvas"),s=i.getContext("2d"),a=e.querySelector('[role="status"]'),r=e.querySelector("#rescue-choices"),l=e.querySelector("#rescue-daily-choices"),f=e.querySelector("#rescue-objective"),n=e.querySelector("#rescue-result"),c=[...r.querySelectorAll("button")],d=[...l.querySelectorAll("button")],h=e.querySelector("#rescue-title"),m=e.querySelector(".eyebrow"),p=e.querySelector("#rescue-again"),k=e.querySelector("#rescue-share"),u=e.querySelector("#rescue-share-status"),$=e.querySelector("#rescue-share-text"),se=matchMedia("(prefers-reduced-motion: reduce)"),L,H,ue,Y,E;function ke(T,C){let x=_e(T,C),R=4;s.setTransform(R,0,0,R,i.width/2-5*y*R,i.height*.71-3.5*y*R),s.drawImage(ue,0,0),Ue(s,x,C);for(let A of x.units.values()){if(!A.hp&&A.pose?.type!=="fall")continue;let K=(A.x+.5)*y,W=(A.y+.5)*y+5,U=x.threat?.actor===A.id;We(s,A,K,W,C,U),A.hp&&Ne(s,A,K,W,R,!0,U)}for(let A of x.effects)Ge(s,A,y,R)}function we(){cancelAnimationFrame(Y),ue??=Be(L.withoutTonic.playback.frame.floor),ke(L.withoutTonic.playback,0),a.textContent=`Brakka has ${L.initialHp} HP. The Stone Maw is charging a ${L.incoming}-damage strike.`,n.hidden=!0,k.hidden=!0,u.hidden=!0,$.hidden=!0,r.hidden=H,l.hidden=!H;let T=H?d:c;for(let C of T)C.disabled=!1;return T[0]}function ae(T,C){let{playback:x,hp:R,restoredHp:A}=T;H&&E.attempts++;for(let U of H?d:c)U.disabled=!0;a.textContent=H?`${C.title} sent. The turn is resolving.`:A?`Tonic delivered. Brakka recovers ${A} HP.`:"The Stone Maw swings.";let K=performance.now();function W(U){let be=se.matches?x.duration:Math.min(U-K,x.duration);if(ke(x,be),be<x.duration){Y=requestAnimationFrame(W);return}if(H){let Qe=R>0?`Brakka has ${R} HP at level ${T.level}.`:"Brakka fell.",et=T.mawHp>0?`The Maw still has ${T.mawHp} HP.`:"The Maw fell before the strike.";a.textContent=`${T.success?"Challenge solved.":"Try another gift."} ${Qe} ${et}`,T.success&&(E.solvedIn??=E.attempts),k.hidden=!T.success}else a.textContent=R>0?`Brakka survives with ${R} HP. The tonic restored ${A} HP before the strike.`:"Brakka falls. Try again and send the tonic before the strike.";r.hidden=!0,l.hidden=!0,n.hidden=!1,p.focus()}Y=requestAnimationFrame(W)}return c[0].addEventListener("click",()=>ae(L.withTonic)),c[1].addEventListener("click",()=>ae(L.withoutTonic)),d.forEach((T,C)=>{T.addEventListener("click",()=>ae(L.outcomes[C],Q[C]))}),p.addEventListener("click",()=>we().focus()),k.addEventListener("click",async()=>{let{date:T,solvedIn:C}=E,x=bt(T,C,o),R=!1;try{await navigator.clipboard.writeText(x),R=!0}catch{}!e.open||k.hidden||E.date!==T||(u.textContent=R?"Result copied.":"Select and copy the result below.",u.hidden=!1,$.hidden=R,R||($.value=x,$.focus(),$.select()))}),e.querySelector("#rescue-sponsor").addEventListener("click",()=>{e.close(),t()}),e.addEventListener("close",()=>cancelAnimationFrame(Y)),(T="practice",C)=>{if(e.open)return;H=T==="daily",L=H?wt(Date.now(),C):kt(),H&&E?.date!==L.date&&(E={date:L.date,attempts:0}),h.textContent=H?"Daily rescue":"Can Brakka survive?",m.textContent=H?`${L.date} \xB7 UTC`:"Practice scene",f.hidden=!H,f.textContent=H?[L.objective,L.hint].filter(Boolean).join(" "):"";let x=we();e.showModal(),x.focus()}}var Ke="https://underwatch-the-hollow.dchilds64.chatgpt.site/",ie=document.querySelector("#rescue"),St=document.querySelector("#play"),ye=document.querySelector("#launch-status"),V=document.querySelector("#launch-url");async function Ze(e,t){let o=`${Ke}${e}`;if(V.hidden=!0,ye.textContent="",window===window.top){window.location.assign(o);return}let i=window.napplet?.link;if(i){try{if((await i.open(o,{label:t})).status==="opened")return}catch{}ye.textContent="The app launcher could not open Underwatch.";return}ye.textContent="Copy this address to open Underwatch in your browser.",V.value=o,V.hidden=!1,V.focus(),V.select()}var ze=()=>Ze("?sponsor=1","View the $3 Underwatch sponsorship"),Je=Ye(ie,ze,Ke);ie.querySelector("#rescue-sponsor").hidden=!1;ie.querySelector(".dialog-close button").addEventListener("click",()=>ie.close());St.addEventListener("click",()=>Je("daily"));document.querySelector("#watch").addEventListener("click",()=>Ze("?watch=fight","Watch the live dungeon"));document.querySelector("#sponsor").addEventListener("click",ze);Je("daily");})();
</script>
</body>
</html>