aboutsummaryrefslogtreecommitdiffstats
path: root/views/error.html
blob: 58edb1a5167de3a32cdcb365c4e6d8483d52ce85 (plain) (blame)
1
Error: {{error}}
#FDD } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #A00 } /* Generic.Error */ .highlight .gh { color: #333 } /* Generic.Heading */ .highlight .gi { color: #000; background-color: #DFD } /* Generic.Inserted */ .highlight .go { color: #888 } /* Generic.Output */ .highlight .gp { color: #555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666 } /* Generic.Subheading */ .highlight .gt { color: #A00 } /* Generic.Traceback */ .highlight .kc { color: #080; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #080; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #080; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #080 } /* Keyword.Pseudo */ .highlight .kr { color: #080; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #00D; font-weight: bold } /* Literal.Number */ .highlight .s { color: #D20; background-color: #FFF0F0 } /* Literal.String */ .highlight .na { color: #369 } /* Name.Attribute */ .highlight .nb { color: #038 } /* Name.Builtin */ .highlight .nc { color: #B06; font-weight: bold } /* Name.Class */ .highlight .no { color: #036; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555 } /* Name.Decorator */ .highlight .ne { color: #B06; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #06B; font-weight: bold } /* Name.Function */ .highlight .nl { color: #369; font-style: italic } /* Name.Label */ .highlight .nn { color: #B06; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #369; font-weight: bold } /* Name.Property */ .highlight .nt { color: #B06; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #369 } /* Name.Variable */ .highlight .ow { color: #080 } /* Operator.Word */ .highlight .w { color: #BBB } /* Text.Whitespace */ .highlight .mb { color: #00D; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #00D; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #00D; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #00D; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #00D; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #D20; background-color: #FFF0F0 } /* Literal.String.Affix */ .highlight .sb { color: #D20; background-color: #FFF0F0 } /* Literal.String.Backtick */ .highlight .sc { color: #D20; background-color: #FFF0F0 } /* Literal.String.Char */ .highlight .dl { color: #D20; background-color: #FFF0F0 } /* Literal.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
// Outside the app's morphed tree so relay updates cannot restart the effect.
// This is tap feedback only: payment settlement never plays it again.

// The clip is 62KB of base64 — messages.js can't be deferred (it's the boot
// shell), so the sound is its own chunk instead, fetched once a zappable
// post or chat message is on screen. By the first tap it's decoded; and if
// it isn't, the sound keeps the tap's own clock and stays silent when late.
let soundModule = null, sound = null;
export function warmZapSound() {
  if (!soundModule) {
    soundModule = import('./zap-sound.js')
      .then((m) => (sound = m))
      .catch(() => { soundModule = null; return null; });
  }
  return soundModule;
}

const trembles = new WeakMap();
function tremblePost(id) {
  if (!id || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
  for (const post of document.querySelectorAll(`[data-zap-post="${CSS.escape(id)}"]`)) {
    // Web Animations survive the app's DOM morphs without adding a class
    // that a balance update could remove or accidentally restart.
    trembles.get(post)?.cancel();
    const animation = post.animate([
      { transform: 'none' },
      { transform: 'translate(-3px, 1px) rotate(-.3deg)' },
      { transform: 'translate(3px, -1px) rotate(.3deg)' },
      { transform: 'translate(-2.5px, 0) rotate(-.2deg)' },
      { transform: 'translate(2px, 1px) rotate(.2deg)' },
      { transform: 'translate(-1.5px, -1px)' },
      { transform: 'translate(1px, 0)' },
      { transform: 'none' },
    ], { duration: 360, easing: 'ease-out' });
    trembles.set(post, animation);
    animation.onfinish = () => { if (trembles.get(post) === animation) trembles.delete(post); };
  }
}

export function animateZap(sats, origin, postId, withSound = true) {
  // Warm: play inside the tap itself (the audio context resumes on a
  // gesture). Cold: play when the chunk lands, if that's still soon enough.
  if (!withSound) {} // switched off from the held-⚡ screen: the strike stays
  else if (sound) sound.playZapSound();
  else { const tappedAt = performance.now(); warmZapSound().then((m) => { if (m) m.playZapSound(tappedAt); }); }
  try { tremblePost(postId); } catch {} // Optional motion must never block a zap.
  const layer = document.createElement('div');
  layer.className = 'zap-fx';
  layer.setAttribute('aria-hidden', 'true');
  const x = origin ? origin.left + origin.width / 2 : innerWidth / 2;
  const y = origin ? origin.top + origin.height / 2 : innerHeight / 2;
  layer.style.setProperty('--zap-x', `${x}px`);
  layer.style.setProperty('--zap-y', `${Math.max(110, y)}px`);
  layer.innerHTML = '<div class="zap-fx-impact">'
    + '<svg class="zap-fx-bolt" viewBox="0 0 100 180"><path d="M62 0 25 65 52 59 15 122 43 110 50 180 72 91 48 100 88 35 59 43Z"/></svg>'
    + '<i class="zap-fx-flash"></i><i class="zap-fx-ring"></i>'
    + '<div class="zap-fx-amount"><strong></strong><span>sats</span></div></div>';
  layer.querySelector('strong').textContent = '+' + sats.toLocaleString();
  const impact = layer.firstElementChild;
  for (let i = 0; i < 26; i++) {
    const spark = document.createElement('i');
    const angle = i * 2.39996;
    const distance = 38 + (i % 6) * 15;
    spark.className = 'zap-fx-spark' + (i >= 16 ? ' ember' : '');
    spark.style.setProperty('--dx', `${Math.cos(angle) * distance}px`);
    spark.style.setProperty('--dy', `${Math.sin(angle) * distance - 35}px`);
    spark.style.setProperty('--angle', `${angle}rad`);
    spark.style.setProperty('--delay', `${i >= 16 ? 600 + (i % 5) * 55 : 60 + (i % 4) * 20}ms`);
    impact.append(spark);
  }
  document.body.append(layer);
  // Leave room for the pop's 1.2x overshoot, even for long amounts at an edge.
  const label = layer.querySelector('.zap-fx-amount');
  if (label.offsetWidth > (innerWidth - 32) / 1.2) {
    const strong = label.querySelector('strong');
    strong.style.fontSize = `${parseFloat(getComputedStyle(strong).fontSize) * (innerWidth - 80) / (label.offsetWidth * 1.2)}px`;
  }
  const margin = label.offsetWidth * .6 + 12;
  const labelX = Math.max(margin, Math.min(innerWidth - margin, x));
  layer.style.setProperty('--zap-label-x', `${labelX - x}px`);
  const clean = () => { layer.remove(); window.removeEventListener('pagehide', clean); };
  window.addEventListener('pagehide', clean, { once: true });
  setTimeout(clean, 1700);
}