@puzzmo/sdk 1.0.71 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +20 -6
  2. package/dist/{createSimulator-uk8H5md8.cjs → createSimulator-Bb1LTB5P.cjs} +44 -44
  3. package/dist/createSimulator-Bb1LTB5P.cjs.map +1 -0
  4. package/dist/{createSimulator-treFHkmV.js → createSimulator-CYo2KWWM.js} +480 -440
  5. package/dist/createSimulator-CYo2KWWM.js.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.global.js +1 -1
  11. package/dist/index.global.js.map +1 -1
  12. package/dist/index.js +154 -91
  13. package/dist/index.js.map +1 -1
  14. package/dist/sdk.d.ts +66 -4
  15. package/dist/sdk.d.ts.map +1 -1
  16. package/dist/sdk.gameReady.spec.d.ts +2 -0
  17. package/dist/sdk.gameReady.spec.d.ts.map +1 -0
  18. package/dist/simulator/createSimulator.d.ts.map +1 -1
  19. package/dist/simulator/index.cjs +1 -1
  20. package/dist/simulator/index.js +1 -1
  21. package/dist/simulator/standalone.cjs +1 -1
  22. package/dist/simulator/standalone.js +1 -1
  23. package/dist/simulator/state.d.ts.map +1 -1
  24. package/dist/simulator/types.d.ts +5 -0
  25. package/dist/simulator/types.d.ts.map +1 -1
  26. package/dist/simulator/views/ThumbView.d.ts.map +1 -1
  27. package/dist/thumbnailMotion.cjs +5 -0
  28. package/dist/thumbnailMotion.cjs.map +1 -0
  29. package/dist/thumbnailMotion.d.ts +119 -0
  30. package/dist/thumbnailMotion.d.ts.map +1 -0
  31. package/dist/thumbnailMotion.js +453 -0
  32. package/dist/thumbnailMotion.js.map +1 -0
  33. package/dist/thumbnailMotion.spec.d.ts +2 -0
  34. package/dist/thumbnailMotion.spec.d.ts.map +1 -0
  35. package/dist/types.d.ts +55 -0
  36. package/dist/types.d.ts.map +1 -1
  37. package/package.json +6 -1
  38. package/dist/createSimulator-treFHkmV.js.map +0 -1
  39. package/dist/createSimulator-uk8H5md8.cjs.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import { t as e } from "./objectSpread2-BJrS9rM5.js";
2
2
  import { t } from "./asyncToGenerator-DSd3oTwb.js";
3
- var n = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
4
- const r = [
3
+ import { createThumbnailMorpher as n } from "./thumbnailMotion.js";
4
+ var r = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
5
+ const i = [
5
6
  {
6
7
  name: "Puzzmo (light)",
7
8
  type: "light",
@@ -307,7 +308,7 @@ const r = [
307
308
  a_infoBG: "#001900"
308
309
  }
309
310
  ];
310
- var i = {
311
+ var a = {
311
312
  collapsed: "simulator-collapsed",
312
313
  tab: "simulator-tab",
313
314
  theme: "simulator-theme",
@@ -319,42 +320,42 @@ var i = {
319
320
  gameSettings: "simulator-game-settings",
320
321
  hostContext: "simulator-host-context",
321
322
  keyboardDocked: "simulator-keyboard-docked"
322
- }, a = "simulator-override:";
323
+ }, o = "simulator-override:";
323
324
  /**
324
325
  * Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
325
326
  * commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
326
327
  * string is only meaningful to the game it came from.
327
328
  */
328
- function o(e) {
329
- return `${a}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
329
+ function s(e) {
330
+ return `${o}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
330
331
  }
331
332
  /** The applied override for this page, or null when nothing has been applied. "" is a real value. */
332
- function s(e) {
333
+ function c(e) {
333
334
  try {
334
- return localStorage.getItem(o(e));
335
+ return localStorage.getItem(s(e));
335
336
  } catch (e) {
336
337
  return null;
337
338
  }
338
339
  }
339
340
  /** False when the write failed — private-mode storage, or a board state over the origin's quota. */
340
- function c(e, t) {
341
+ function l(e, t) {
341
342
  try {
342
- return localStorage.setItem(o(e), t), !0;
343
+ return localStorage.setItem(s(e), t), !0;
343
344
  } catch (e) {
344
345
  return !1;
345
346
  }
346
347
  }
347
- function l(e) {
348
+ function u(e) {
348
349
  try {
349
- localStorage.removeItem(o(e));
350
+ localStorage.removeItem(s(e));
350
351
  } catch (e) {}
351
352
  }
352
- function u() {
353
- l("puzzle"), l("input");
353
+ function d() {
354
+ u("puzzle"), u("input");
354
355
  }
355
356
  /** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
356
- function d() {
357
- let e = localStorage.getItem(i.hostContext);
357
+ function f() {
358
+ let e = localStorage.getItem(a.hostContext);
358
359
  if (!e) return null;
359
360
  try {
360
361
  let t = JSON.parse(e);
@@ -362,21 +363,21 @@ function d() {
362
363
  } catch (e) {}
363
364
  return null;
364
365
  }
365
- function f(e) {
366
- localStorage.setItem(i.hostContext, JSON.stringify(e));
366
+ function p(e) {
367
+ localStorage.setItem(a.hostContext, JSON.stringify(e));
367
368
  }
368
- function p() {
369
- localStorage.removeItem(i.hostContext);
369
+ function m() {
370
+ localStorage.removeItem(a.hostContext);
370
371
  }
371
372
  /** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
372
- function m() {
373
- return localStorage.getItem(i.keyboardDocked) === "true";
373
+ function h() {
374
+ return localStorage.getItem(a.keyboardDocked) === "true";
374
375
  }
375
- function h(e) {
376
- localStorage.setItem(i.keyboardDocked, String(e));
376
+ function g(e) {
377
+ localStorage.setItem(a.keyboardDocked, String(e));
377
378
  }
378
- function g() {
379
- let e = localStorage.getItem(i.gameSettings);
379
+ function _() {
380
+ let e = localStorage.getItem(a.gameSettings);
380
381
  if (!e) return {};
381
382
  try {
382
383
  let t = JSON.parse(e);
@@ -384,36 +385,36 @@ function g() {
384
385
  } catch (e) {}
385
386
  return {};
386
387
  }
387
- function _() {
388
- let e = localStorage.getItem(i.theme);
388
+ function v() {
389
+ let e = localStorage.getItem(a.theme);
389
390
  if (e) {
390
- let t = r.find((t) => t.name === e);
391
+ let t = i.find((t) => t.name === e);
391
392
  if (t) return t;
392
393
  }
393
- return r[0];
394
+ return i[0];
394
395
  }
395
- function v(e) {
396
+ function y(e) {
396
397
  var t;
397
- let n = localStorage.getItem(i.tab);
398
+ let n = localStorage.getItem(a.tab);
398
399
  return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
399
400
  }
400
- function y(e) {
401
- let t = localStorage.getItem(i.collapsed);
401
+ function b(e) {
402
+ let t = localStorage.getItem(a.collapsed);
402
403
  return t === null ? e : t === "true";
403
404
  }
404
- function b() {
405
- let e = localStorage.getItem(i.renderHost);
405
+ function x() {
406
+ let e = localStorage.getItem(a.renderHost);
406
407
  return e && [
407
408
  "game",
408
409
  "app",
409
410
  "opengraph"
410
411
  ].includes(e) ? e : "game";
411
412
  }
412
- function x() {
413
- return localStorage.getItem(i.previewKind) === "text" ? "text" : "image";
414
- }
415
413
  function S() {
416
- let e = localStorage.getItem(i.renderContext);
414
+ return localStorage.getItem(a.previewKind) === "text" ? "text" : "image";
415
+ }
416
+ function C() {
417
+ let e = localStorage.getItem(a.renderContext);
417
418
  if (e && [
418
419
  "preview",
419
420
  "share",
@@ -422,8 +423,8 @@ function S() {
422
423
  ].includes(e)) return e;
423
424
  }
424
425
  function ee(e, t, n) {
425
- var r, a, o;
426
- let c = localStorage.getItem(i.fixtureCategory), l = localStorage.getItem(i.fixturePuzzle), u = d(), f = s("puzzle"), p = s("input");
426
+ var r, i, o;
427
+ let s = localStorage.getItem(a.fixtureCategory), l = localStorage.getItem(a.fixturePuzzle), u = f(), d = c("puzzle"), p = c("input");
427
428
  return {
428
429
  hostContext: (r = u == null ? e.hostContext : u) == null ? [{
429
430
  type: "app",
@@ -431,61 +432,62 @@ function ee(e, t, n) {
431
432
  host: null
432
433
  }] : r,
433
434
  hostContextIsOverridden: u !== null,
434
- isCollapsed: y((a = e.collapsed) == null ? !0 : a),
435
+ isCollapsed: b((i = e.collapsed) == null ? !0 : i),
435
436
  isPaused: !1,
436
437
  hasStarted: !1,
437
- activeTab: v(n),
438
- puzzleData: f,
439
- originalPuzzle: f == null ? "" : f,
438
+ activeTab: y(n),
439
+ puzzleData: d,
440
+ originalPuzzle: d == null ? "" : d,
440
441
  currentInputStr: p == null ? "" : p,
441
- appliedPuzzleOverride: f,
442
+ userStorage: null,
443
+ appliedPuzzleOverride: d,
442
444
  appliedInputOverride: p,
443
445
  completionData: null,
444
- selectedTheme: _(),
445
- selectedCategory: c && t.includes(c) ? c : (o = t[0]) == null ? null : o,
446
+ selectedTheme: v(),
447
+ selectedCategory: s && t.includes(s) ? s : (o = t[0]) == null ? null : o,
446
448
  selectedPuzzle: l == null ? null : l,
447
- renderHost: b(),
448
- renderContext: S(),
449
- previewKind: x(),
450
- gameSettings: g(),
451
- keyboardDocked: m(),
449
+ renderHost: x(),
450
+ renderContext: C(),
451
+ previewKind: S(),
452
+ gameSettings: _(),
453
+ keyboardDocked: h(),
452
454
  settingsComponents: null
453
455
  };
454
456
  }
455
- function C(e) {
456
- localStorage.setItem(i.gameSettings, JSON.stringify(e));
457
+ function w(e) {
458
+ localStorage.setItem(a.gameSettings, JSON.stringify(e));
457
459
  }
458
- function w() {
459
- localStorage.removeItem(i.gameSettings);
460
+ function T() {
461
+ localStorage.removeItem(a.gameSettings);
460
462
  }
461
463
  function te(e) {
462
- localStorage.setItem(i.collapsed, String(e));
464
+ localStorage.setItem(a.collapsed, String(e));
463
465
  }
464
466
  function ne(e) {
465
- localStorage.setItem(i.tab, e);
466
- }
467
- function T(e) {
468
- localStorage.setItem(i.theme, e);
467
+ localStorage.setItem(a.tab, e);
469
468
  }
470
469
  function E(e) {
471
- localStorage.setItem(i.fixtureCategory, e);
470
+ localStorage.setItem(a.theme, e);
472
471
  }
473
472
  function D(e) {
474
- localStorage.setItem(i.fixturePuzzle, e);
473
+ localStorage.setItem(a.fixtureCategory, e);
475
474
  }
476
- function O() {
477
- localStorage.removeItem(i.fixturePuzzle);
475
+ function O(e) {
476
+ localStorage.setItem(a.fixturePuzzle, e);
478
477
  }
479
- function k(e) {
480
- e ? localStorage.setItem(i.renderHost, e) : localStorage.removeItem(i.renderHost);
478
+ function k() {
479
+ localStorage.removeItem(a.fixturePuzzle);
481
480
  }
482
481
  function A(e) {
483
- localStorage.setItem(i.previewKind, e);
482
+ e ? localStorage.setItem(a.renderHost, e) : localStorage.removeItem(a.renderHost);
484
483
  }
485
484
  function j(e) {
486
- e ? localStorage.setItem(i.renderContext, e) : localStorage.removeItem(i.renderContext);
485
+ localStorage.setItem(a.previewKind, e);
487
486
  }
488
- function re(e) {
487
+ function M(e) {
488
+ e ? localStorage.setItem(a.renderContext, e) : localStorage.removeItem(a.renderContext);
489
+ }
490
+ function N(e) {
489
491
  let t = [];
490
492
  return {
491
493
  log(n, r, i) {
@@ -510,13 +512,13 @@ function re(e) {
510
512
  }
511
513
  };
512
514
  }
513
- function M(e, t, n) {
515
+ function P(e, t, n) {
514
516
  console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
515
517
  type: e,
516
518
  data: t
517
519
  }, "*");
518
520
  }
519
- function N(e, t) {
521
+ function re(e, t) {
520
522
  let n = (n) => {
521
523
  var r, i, a;
522
524
  if (!(!(n == null || (r = n.data) == null) && r.type)) return;
@@ -545,7 +547,7 @@ function ie(e) {
545
547
  }), t;
546
548
  }
547
549
  /** Render fixture selector HTML */
548
- function P(e, t) {
550
+ function F(e, t) {
549
551
  return e.length === 0 ? "" : `
550
552
  <div class="simulator-fixtures">
551
553
  <div class="simulator-field">
@@ -562,7 +564,7 @@ function P(e, t) {
562
564
  `;
563
565
  }
564
566
  /** Update puzzle select options based on selected category */
565
- function F(e, t, n, r) {
567
+ function I(e, t, n, r) {
566
568
  let i = t.get(n);
567
569
  if (!i) return null;
568
570
  let a = Array.from(i.keys()), o = r;
@@ -573,7 +575,7 @@ function F(e, t, n, r) {
573
575
  return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
574
576
  }
575
577
  /** Get puzzle data from fixtures */
576
- function I(e, t, n) {
578
+ function L(e, t, n) {
577
579
  var r, i;
578
580
  return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
579
581
  }
@@ -601,19 +603,19 @@ function oe() {
601
603
  selectedCategory: e.state.selectedCategory,
602
604
  selectedPuzzle: e.state.selectedPuzzle
603
605
  }), e.fixtures && e.fixtureCategories.length > 0 && i) {
604
- i.innerHTML = P(e.fixtureCategories, e.state.selectedCategory);
606
+ i.innerHTML = F(e.fixtureCategories, e.state.selectedCategory);
605
607
  let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
606
608
  if (t && n && e.state.selectedCategory) {
607
- e.state.selectedPuzzle = F(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
608
- let r = I(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
609
+ e.state.selectedPuzzle = I(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
610
+ let r = L(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
609
611
  console.log("Simulator: Loading fixture puzzle", {
610
612
  category: e.state.selectedCategory,
611
613
  puzzle: e.state.selectedPuzzle,
612
614
  hasPuzzleData: !!r
613
- }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && E(e.state.selectedCategory), e.state.selectedPuzzle && D(e.state.selectedPuzzle)), t.addEventListener("change", () => {
614
- console.log("Simulator: Category changed, reloading...", t.value), u(), E(t.value), O(), window.location.reload();
615
+ }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && D(e.state.selectedCategory), e.state.selectedPuzzle && O(e.state.selectedPuzzle)), t.addEventListener("change", () => {
616
+ console.log("Simulator: Category changed, reloading...", t.value), d(), D(t.value), k(), window.location.reload();
615
617
  }), n.addEventListener("change", () => {
616
- console.log("Simulator: Puzzle changed, reloading...", n.value), u(), D(n.value), window.location.reload();
618
+ console.log("Simulator: Puzzle changed, reloading...", n.value), d(), O(n.value), window.location.reload();
617
619
  });
618
620
  }
619
621
  }
@@ -639,10 +641,10 @@ function oe() {
639
641
  * Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
640
642
  * must stay self-contained.
641
643
  */
642
- function L(e) {
644
+ function R(e) {
643
645
  var t;
644
646
  if (typeof e != "string") return e;
645
- let n = (t = R(e)) == null ? {
647
+ let n = (t = z(e)) == null ? {
646
648
  width: 800,
647
649
  height: 800
648
650
  } : t;
@@ -653,7 +655,7 @@ function L(e) {
653
655
  };
654
656
  }
655
657
  /** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
656
- function R(e) {
658
+ function z(e) {
657
659
  var t, n, r, i;
658
660
  let a = e.indexOf("<svg");
659
661
  if (a === -1) return;
@@ -671,9 +673,9 @@ function R(e) {
671
673
  height: u
672
674
  };
673
675
  }
674
- var z = "simulator-saved-states";
676
+ var B = "simulator-saved-states";
675
677
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
676
- function B() {
678
+ function se() {
677
679
  let e = globalThis;
678
680
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
679
681
  name: t,
@@ -683,7 +685,7 @@ function B() {
683
685
  }
684
686
  /** Generate a small thumbnail SVG for a given input string */
685
687
  function V(e, t) {
686
- let n = B();
688
+ let n = se();
687
689
  if (!n) return "";
688
690
  try {
689
691
  var r;
@@ -693,7 +695,7 @@ function V(e, t) {
693
695
  strict: !0,
694
696
  renderHost: "game"
695
697
  };
696
- return L(n.fn(i, t, a)).svg;
698
+ return R(n.fn(i, t, a)).svg;
697
699
  } catch (e) {
698
700
  return "";
699
701
  }
@@ -705,7 +707,7 @@ function U(e, t = 8) {
705
707
  let r = Math.min(Math.max(e.scrollHeight, 40), n);
706
708
  e.style.height = `${r}px`;
707
709
  }
708
- function se() {
710
+ function ce() {
709
711
  let e = "", t = "";
710
712
  return {
711
713
  id: "data",
@@ -723,12 +725,12 @@ function se() {
723
725
  let i = n.getElement(".data-view-container");
724
726
  i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
725
727
  e.classList.toggle("active", e.id === `data-subtab-${t}`);
726
- }), t === "edit" ? ue(n) : t === "history" ? W(n) : t === "saves" && G(n);
728
+ }), t === "edit" ? de(n) : t === "history" ? W(n) : t === "saves" && G(n);
727
729
  });
728
730
  });
729
- let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
731
+ let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), c = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
730
732
  setTimeout(() => {
731
- i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, U(a)), de(n);
733
+ i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, U(a)), fe(n);
732
734
  }, 0), i == null || i.addEventListener("input", () => {
733
735
  U(i);
734
736
  let t = i.value !== e;
@@ -739,27 +741,27 @@ function se() {
739
741
  d && (d.disabled = !e);
740
742
  }), o == null || o.addEventListener("click", () => {
741
743
  if (n.state.appliedPuzzleOverride !== null) {
742
- l("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
744
+ u("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
743
745
  return;
744
746
  }
745
747
  i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i), s && (s.disabled = !0));
746
748
  }), s == null || s.addEventListener("click", () => {
747
749
  if (i) {
748
- if (!c("puzzle", i.value)) {
750
+ if (!l("puzzle", i.value)) {
749
751
  n.updateStatus("Could not store puzzle — storage unavailable", "paused");
750
752
  return;
751
753
  }
752
- l("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
754
+ u("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
753
755
  }
754
- }), u == null || u.addEventListener("click", () => {
756
+ }), c == null || c.addEventListener("click", () => {
755
757
  if (n.state.appliedInputOverride !== null) {
756
- l("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
758
+ u("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
757
759
  return;
758
760
  }
759
761
  a && (a.value = t, U(a), d && (d.disabled = !0));
760
762
  }), d == null || d.addEventListener("click", () => {
761
763
  if (a) {
762
- if (!c("input", a.value)) {
764
+ if (!l("input", a.value)) {
763
765
  n.updateStatus("Could not store input — storage unavailable", "paused");
764
766
  return;
765
767
  }
@@ -773,17 +775,17 @@ function se() {
773
775
  let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
774
776
  m == null || m.addEventListener("click", () => {
775
777
  if (!p || !p.value.trim()) return;
776
- let e = ce(), t = {
778
+ let e = le(), t = {
777
779
  name: p.value.trim(),
778
780
  puzzleStr: n.state.originalPuzzle,
779
781
  inputStr: n.state.currentInputStr,
780
782
  timestamp: Date.now()
781
783
  };
782
- e.push(t), localStorage.setItem(z, JSON.stringify(e)), p.value = "", G(n);
784
+ e.push(t), localStorage.setItem(B, JSON.stringify(e)), p.value = "", G(n);
783
785
  }), G(n);
784
786
  },
785
787
  onActivate(n) {
786
- e = n.state.originalPuzzle, t = n.state.currentInputStr, ue(n), W(n);
788
+ e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), W(n);
787
789
  },
788
790
  onMessage(e, n, r) {
789
791
  var i, a;
@@ -802,9 +804,9 @@ function se() {
802
804
  }
803
805
  };
804
806
  }
805
- function ce() {
807
+ function le() {
806
808
  try {
807
- let e = localStorage.getItem(z);
809
+ let e = localStorage.getItem(B);
808
810
  return e ? JSON.parse(e) : [];
809
811
  } catch (e) {
810
812
  return [];
@@ -828,7 +830,7 @@ function W(e) {
828
830
  <span class="history-item-time">${i}</span>
829
831
  <button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
830
832
  </div>
831
- <div class="history-item-preview">${le(a)}</div>
833
+ <div class="history-item-preview">${ue(a)}</div>
832
834
  </div>
833
835
  </div>
834
836
  `;
@@ -848,7 +850,7 @@ function W(e) {
848
850
  function G(e) {
849
851
  let t = e.getElement("#simulator-saves-list");
850
852
  if (!t) return;
851
- let n = ce();
853
+ let n = le();
852
854
  if (n.length === 0) {
853
855
  t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
854
856
  return;
@@ -858,7 +860,7 @@ function G(e) {
858
860
  return `
859
861
  <div class="save-item">
860
862
  <div class="save-item-header">
861
- <span class="save-item-name">${le(e.name)}</span>
863
+ <span class="save-item-name">${ue(e.name)}</span>
862
864
  <span class="save-item-time">${i} ${a}</span>
863
865
  </div>
864
866
  <div class="save-item-actions">
@@ -871,8 +873,8 @@ function G(e) {
871
873
  t.addEventListener("click", (t) => {
872
874
  let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
873
875
  if (r) {
874
- if (!c("puzzle", r.puzzleStr) || !c("input", r.inputStr)) {
875
- u(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
876
+ if (!l("puzzle", r.puzzleStr) || !l("input", r.inputStr)) {
877
+ d(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
876
878
  return;
877
879
  }
878
880
  e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
@@ -881,25 +883,25 @@ function G(e) {
881
883
  }), t.querySelectorAll(".save-delete-btn").forEach((t) => {
882
884
  t.addEventListener("click", (t) => {
883
885
  let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
884
- localStorage.setItem(z, JSON.stringify(i)), G(e);
886
+ localStorage.setItem(B, JSON.stringify(i)), G(e);
885
887
  });
886
888
  });
887
889
  }
888
- function le(e) {
890
+ function ue(e) {
889
891
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
890
892
  }
891
- function ue(e) {
893
+ function de(e) {
892
894
  let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
893
- t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, U(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, U(n), i && (i.disabled = !0)), de(e);
895
+ t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, U(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, U(n), i && (i.disabled = !0)), fe(e);
894
896
  }
895
- function de(e) {
897
+ function fe(e) {
896
898
  let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
897
899
  t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
898
900
  }
899
- function fe(e) {
901
+ function pe(e) {
900
902
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
901
903
  }
902
- function pe() {
904
+ function me() {
903
905
  let e = 0;
904
906
  return {
905
907
  id: "msgs",
@@ -926,7 +928,7 @@ function pe() {
926
928
  <span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
927
929
  <span class="simulator-msg-time">${t.time}</span>
928
930
  </div>
929
- ${a ? `<div class="simulator-msg-data">${fe(a)}</div>` : ""}
931
+ ${a ? `<div class="simulator-msg-data">${pe(a)}</div>` : ""}
930
932
  `;
931
933
  let o = i.querySelector(".simulator-msg-data");
932
934
  for (o && o.addEventListener("click", () => {
@@ -937,7 +939,7 @@ function pe() {
937
939
  }
938
940
  };
939
941
  }
940
- function me() {
942
+ function he() {
941
943
  return {
942
944
  id: "done",
943
945
  label: "Done",
@@ -974,7 +976,7 @@ function me() {
974
976
  }
975
977
  };
976
978
  }
977
- function he() {
979
+ function ge() {
978
980
  let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
979
981
  let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
980
982
  return `
@@ -1024,7 +1026,7 @@ function he() {
1024
1026
  }
1025
1027
  };
1026
1028
  }
1027
- var ge = /* @__PURE__ */ n(((e) => {
1029
+ var _e = /* @__PURE__ */ r(((e) => {
1028
1030
  var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
1029
1031
  return v(e) ? e.toLowerCase() : e;
1030
1032
  }, i = Array.isArray;
@@ -1220,9 +1222,9 @@ var ge = /* @__PURE__ */ n(((e) => {
1220
1222
  function S(e) {
1221
1223
  return e && e.$evalAsync && e.$watch;
1222
1224
  }
1223
- var ee = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1224
- function C(e) {
1225
- return e && y(e.length) && ee.test(s.call(e));
1225
+ var C = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1226
+ function ee(e) {
1227
+ return e && y(e.length) && C.test(s.call(e));
1226
1228
  }
1227
1229
  function w(e) {
1228
1230
  return s.call(e) === "[object ArrayBuffer]";
@@ -1292,10 +1294,10 @@ var ge = /* @__PURE__ */ n(((e) => {
1292
1294
  </file>
1293
1295
  </example>
1294
1296
  */
1295
- function te(e, t) {
1297
+ function T(e, t) {
1296
1298
  var r = [], a = [];
1297
1299
  if (t) {
1298
- if (C(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1300
+ if (ee(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1299
1301
  if (e === t) throw l("cpi", "Can't copy! Source and destination are identical.");
1300
1302
  return i(t) ? t.length = 0 : d(t, function(e, n) {
1301
1303
  n !== "$$hashKey" && delete t[n];
@@ -1364,7 +1366,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1364
1366
  * @param {...*} args Optional arguments to be prebound to the `fn` function call.
1365
1367
  * @returns {function()} Function that wraps the `fn` with all the specified bindings.
1366
1368
  */
1367
- function ne(e, n) {
1369
+ function te(e, n) {
1368
1370
  var r = n;
1369
1371
  return typeof e == "string" && e.charAt(0) === "$" && e.charAt(1) === "$" ? r = void 0 : x(n) ? r = "$WINDOW" : n && t.document === n ? r = "$DOCUMENT" : S(n) && (r = "$SCOPE"), r;
1370
1372
  }
@@ -1379,13 +1381,13 @@ var ge = /* @__PURE__ */ n(((e) => {
1379
1381
  *
1380
1382
  * @returns {Object}
1381
1383
  */
1382
- function T() {
1384
+ function ne() {
1383
1385
  return Object.create(null);
1384
1386
  }
1385
1387
  function E(e) {
1386
1388
  var t = [];
1387
1389
  return JSON.stringify(e, function(e, n) {
1388
- if (n = ne(e, n), g(n)) {
1390
+ if (n = te(e, n), g(n)) {
1389
1391
  if (t.indexOf(n) >= 0) return "...";
1390
1392
  t.push(n);
1391
1393
  }
@@ -1438,11 +1440,11 @@ var ge = /* @__PURE__ */ n(((e) => {
1438
1440
  function A(e) {
1439
1441
  return e + "";
1440
1442
  }
1441
- var j = T();
1443
+ var j = ne();
1442
1444
  d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
1443
1445
  j[e] = !0;
1444
1446
  });
1445
- var re = {
1447
+ var M = {
1446
1448
  n: "\n",
1447
1449
  f: "\f",
1448
1450
  r: "\r",
@@ -1454,11 +1456,11 @@ var ge = /* @__PURE__ */ n(((e) => {
1454
1456
  /**
1455
1457
  * @constructor
1456
1458
  */
1457
- function M(e) {
1459
+ function N(e) {
1458
1460
  this.options = e || {};
1459
1461
  }
1460
- M.prototype = {
1461
- constructor: M,
1462
+ N.prototype = {
1463
+ constructor: N,
1462
1464
  lex: function(e) {
1463
1465
  for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
1464
1466
  var t = this.text.charAt(this.index);
@@ -1575,7 +1577,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1575
1577
  text: "+",
1576
1578
  operator: !0
1577
1579
  });
1578
- for (var l = new M(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1580
+ for (var l = new N(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1579
1581
  this.tokens.push({
1580
1582
  index: this.index,
1581
1583
  text: "+",
@@ -1588,7 +1590,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1588
1590
  var f = this.text.substring(this.index + 1, this.index + 5);
1589
1591
  f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
1590
1592
  } else {
1591
- var p = re[o];
1593
+ var p = M[o];
1592
1594
  n += p || o;
1593
1595
  }
1594
1596
  a = !1;
@@ -1607,10 +1609,10 @@ var ge = /* @__PURE__ */ n(((e) => {
1607
1609
  this.throwError("Unterminated quote", t);
1608
1610
  }
1609
1611
  };
1610
- function N(e, t) {
1612
+ function P(e, t) {
1611
1613
  this.lexer = e, this.options = t;
1612
1614
  }
1613
- N.Program = "Program", N.ExpressionStatement = "ExpressionStatement", N.AssignmentExpression = "AssignmentExpression", N.ConditionalExpression = "ConditionalExpression", N.LogicalExpression = "LogicalExpression", N.BinaryExpression = "BinaryExpression", N.UnaryExpression = "UnaryExpression", N.CallExpression = "CallExpression", N.MemberExpression = "MemberExpression", N.Identifier = "Identifier", N.Literal = "Literal", N.ArrayExpression = "ArrayExpression", N.Property = "Property", N.ObjectExpression = "ObjectExpression", N.ThisExpression = "ThisExpression", N.LocalsExpression = "LocalsExpression", N.NGValueParameter = "NGValueParameter", N.prototype = {
1615
+ P.Program = "Program", P.ExpressionStatement = "ExpressionStatement", P.AssignmentExpression = "AssignmentExpression", P.ConditionalExpression = "ConditionalExpression", P.LogicalExpression = "LogicalExpression", P.BinaryExpression = "BinaryExpression", P.UnaryExpression = "UnaryExpression", P.CallExpression = "CallExpression", P.MemberExpression = "MemberExpression", P.Identifier = "Identifier", P.Literal = "Literal", P.ArrayExpression = "ArrayExpression", P.Property = "Property", P.ObjectExpression = "ObjectExpression", P.ThisExpression = "ThisExpression", P.LocalsExpression = "LocalsExpression", P.NGValueParameter = "NGValueParameter", P.prototype = {
1614
1616
  ast: function(e) {
1615
1617
  this.text = e, this.tokens = this.lexer.lex(e);
1616
1618
  var t = this.program();
@@ -1618,13 +1620,13 @@ var ge = /* @__PURE__ */ n(((e) => {
1618
1620
  },
1619
1621
  program: function() {
1620
1622
  for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
1621
- type: N.Program,
1623
+ type: P.Program,
1622
1624
  body: e
1623
1625
  };
1624
1626
  },
1625
1627
  expressionStatement: function() {
1626
1628
  return {
1627
- type: N.ExpressionStatement,
1629
+ type: P.ExpressionStatement,
1628
1630
  expression: this.filterChain()
1629
1631
  };
1630
1632
  },
@@ -1638,9 +1640,9 @@ var ge = /* @__PURE__ */ n(((e) => {
1638
1640
  assignment: function() {
1639
1641
  var e = this.ternary();
1640
1642
  if (this.expect("=")) {
1641
- if (!oe(e)) throw k("lval", "Trying to assign a value to a non l-value");
1643
+ if (!ae(e)) throw k("lval", "Trying to assign a value to a non l-value");
1642
1644
  e = {
1643
- type: N.AssignmentExpression,
1645
+ type: P.AssignmentExpression,
1644
1646
  left: e,
1645
1647
  right: this.assignment(),
1646
1648
  operator: "="
@@ -1651,7 +1653,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1651
1653
  ternary: function() {
1652
1654
  var e = this.nullishCoalescing(), t, n;
1653
1655
  return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
1654
- type: N.ConditionalExpression,
1656
+ type: P.ConditionalExpression,
1655
1657
  test: e,
1656
1658
  alternate: t,
1657
1659
  consequent: n
@@ -1659,7 +1661,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1659
1661
  },
1660
1662
  nullishCoalescing: function() {
1661
1663
  for (var e = this.logicalOR(); this.expect("??");) e = {
1662
- type: N.LogicalExpression,
1664
+ type: P.LogicalExpression,
1663
1665
  operator: "??",
1664
1666
  left: e,
1665
1667
  right: this.logicalOR()
@@ -1668,7 +1670,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1668
1670
  },
1669
1671
  logicalOR: function() {
1670
1672
  for (var e = this.logicalAND(); this.expect("||");) e = {
1671
- type: N.LogicalExpression,
1673
+ type: P.LogicalExpression,
1672
1674
  operator: "||",
1673
1675
  left: e,
1674
1676
  right: this.logicalAND()
@@ -1677,7 +1679,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1677
1679
  },
1678
1680
  logicalAND: function() {
1679
1681
  for (var e = this.equality(); this.expect("&&");) e = {
1680
- type: N.LogicalExpression,
1682
+ type: P.LogicalExpression,
1681
1683
  operator: "&&",
1682
1684
  left: e,
1683
1685
  right: this.equality()
@@ -1686,7 +1688,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1686
1688
  },
1687
1689
  equality: function() {
1688
1690
  for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
1689
- type: N.BinaryExpression,
1691
+ type: P.BinaryExpression,
1690
1692
  operator: t.text,
1691
1693
  left: e,
1692
1694
  right: this.relational()
@@ -1695,7 +1697,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1695
1697
  },
1696
1698
  relational: function() {
1697
1699
  for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
1698
- type: N.BinaryExpression,
1700
+ type: P.BinaryExpression,
1699
1701
  operator: t.text,
1700
1702
  left: e,
1701
1703
  right: this.additive()
@@ -1704,7 +1706,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1704
1706
  },
1705
1707
  additive: function() {
1706
1708
  for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
1707
- type: N.BinaryExpression,
1709
+ type: P.BinaryExpression,
1708
1710
  operator: t.text,
1709
1711
  left: e,
1710
1712
  right: this.multiplicative()
@@ -1713,7 +1715,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1713
1715
  },
1714
1716
  multiplicative: function() {
1715
1717
  for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
1716
- type: N.BinaryExpression,
1718
+ type: P.BinaryExpression,
1717
1719
  operator: t.text,
1718
1720
  left: e,
1719
1721
  right: this.unary()
@@ -1723,7 +1725,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1723
1725
  unary: function() {
1724
1726
  var e;
1725
1727
  return (e = this.expect("+", "-", "!")) ? {
1726
- type: N.UnaryExpression,
1728
+ type: P.UnaryExpression,
1727
1729
  operator: e.text,
1728
1730
  prefix: !0,
1729
1731
  argument: this.unary()
@@ -1731,21 +1733,21 @@ var ge = /* @__PURE__ */ n(((e) => {
1731
1733
  },
1732
1734
  primary: function() {
1733
1735
  var e;
1734
- this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = te(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1735
- type: N.Literal,
1736
+ this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = T(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1737
+ type: P.Literal,
1736
1738
  value: this.options.literals[this.consume().text]
1737
1739
  } : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
1738
1740
  for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
1739
- type: N.CallExpression,
1741
+ type: P.CallExpression,
1740
1742
  callee: e,
1741
1743
  arguments: this.parseArguments()
1742
1744
  }, this.consume(")")) : t.text === "[" ? (e = {
1743
- type: N.MemberExpression,
1745
+ type: P.MemberExpression,
1744
1746
  object: e,
1745
1747
  property: this.expression(),
1746
1748
  computed: !0
1747
1749
  }, this.consume("]")) : t.text === "." ? e = {
1748
- type: N.MemberExpression,
1750
+ type: P.MemberExpression,
1749
1751
  object: e,
1750
1752
  property: this.identifier(),
1751
1753
  computed: !1
@@ -1754,7 +1756,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1754
1756
  },
1755
1757
  filter: function(e) {
1756
1758
  for (var t = [e], n = {
1757
- type: N.CallExpression,
1759
+ type: P.CallExpression,
1758
1760
  callee: this.identifier(),
1759
1761
  arguments: t,
1760
1762
  filter: !0
@@ -1771,13 +1773,13 @@ var ge = /* @__PURE__ */ n(((e) => {
1771
1773
  identifier: function() {
1772
1774
  var e = this.consume();
1773
1775
  return e.identifier || this.throwError("is not a valid identifier", e), {
1774
- type: N.Identifier,
1776
+ type: P.Identifier,
1775
1777
  name: e.text
1776
1778
  };
1777
1779
  },
1778
1780
  constant: function() {
1779
1781
  return {
1780
- type: N.Literal,
1782
+ type: P.Literal,
1781
1783
  value: this.consume().value
1782
1784
  };
1783
1785
  },
@@ -1788,7 +1790,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1788
1790
  e.push(this.expression());
1789
1791
  } while (this.expect(","));
1790
1792
  return this.consume("]"), {
1791
- type: N.ArrayExpression,
1793
+ type: P.ArrayExpression,
1792
1794
  elements: e
1793
1795
  };
1794
1796
  },
@@ -1797,12 +1799,12 @@ var ge = /* @__PURE__ */ n(((e) => {
1797
1799
  if (this.peekToken().text !== "}") do {
1798
1800
  if (this.peek("}")) break;
1799
1801
  t = {
1800
- type: N.Property,
1802
+ type: P.Property,
1801
1803
  kind: "init"
1802
1804
  }, this.peek().constant ? (t.key = this.constant(), t.computed = !1, this.consume(":"), t.value = this.expression()) : this.peek().identifier ? (t.key = this.identifier(), t.computed = !1, this.peek(":") ? (this.consume(":"), t.value = this.expression()) : t.value = t.key) : this.peek("[") ? (this.consume("["), t.key = this.expression(), this.consume("]"), t.computed = !0, this.consume(":"), t.value = this.expression()) : this.throwError("invalid key", this.peek()), e.push(t);
1803
1805
  } while (this.expect(","));
1804
1806
  return this.consume("}"), {
1805
- type: N.ObjectExpression,
1807
+ type: P.ObjectExpression,
1806
1808
  properties: e
1807
1809
  };
1808
1810
  },
@@ -1833,10 +1835,10 @@ var ge = /* @__PURE__ */ n(((e) => {
1833
1835
  return i ? (this.tokens.shift(), i) : !1;
1834
1836
  }
1835
1837
  };
1836
- function ie(e, t) {
1838
+ function re(e, t) {
1837
1839
  return e === void 0 ? t : e;
1838
1840
  }
1839
- function P(e, t) {
1841
+ function ie(e, t) {
1840
1842
  return e === void 0 ? t : t === void 0 ? e : e + t;
1841
1843
  }
1842
1844
  function F(e, t) {
@@ -1847,77 +1849,77 @@ var ge = /* @__PURE__ */ n(((e) => {
1847
1849
  function I(e, t) {
1848
1850
  var n, r, i;
1849
1851
  switch (e.type) {
1850
- case N.Program:
1852
+ case P.Program:
1851
1853
  n = !0, d(e.body, function(e) {
1852
1854
  I(e.expression, t), n = n && e.expression.constant;
1853
1855
  }), e.constant = n;
1854
1856
  break;
1855
- case N.Literal:
1857
+ case P.Literal:
1856
1858
  e.constant = !0, e.toWatch = [];
1857
1859
  break;
1858
- case N.UnaryExpression:
1860
+ case P.UnaryExpression:
1859
1861
  I(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
1860
1862
  break;
1861
- case N.BinaryExpression:
1863
+ case P.BinaryExpression:
1862
1864
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
1863
1865
  break;
1864
- case N.LogicalExpression:
1866
+ case P.LogicalExpression:
1865
1867
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
1866
1868
  break;
1867
- case N.ConditionalExpression:
1869
+ case P.ConditionalExpression:
1868
1870
  I(e.test, t), I(e.alternate, t), I(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
1869
1871
  break;
1870
- case N.Identifier:
1872
+ case P.Identifier:
1871
1873
  e.constant = !1, e.toWatch = [e];
1872
1874
  break;
1873
- case N.MemberExpression:
1875
+ case P.MemberExpression:
1874
1876
  I(e.object, t), e.computed && I(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
1875
1877
  break;
1876
- case N.CallExpression:
1878
+ case P.CallExpression:
1877
1879
  i = e.filter ? F(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
1878
1880
  I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1879
1881
  }), e.constant = n, e.toWatch = i ? r : [e];
1880
1882
  break;
1881
- case N.AssignmentExpression:
1883
+ case P.AssignmentExpression:
1882
1884
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
1883
1885
  break;
1884
- case N.ArrayExpression:
1886
+ case P.ArrayExpression:
1885
1887
  n = !0, r = [], d(e.elements, function(e) {
1886
1888
  I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1887
1889
  }), e.constant = n, e.toWatch = r;
1888
1890
  break;
1889
- case N.ObjectExpression:
1891
+ case P.ObjectExpression:
1890
1892
  n = !0, r = [], d(e.properties, function(e) {
1891
1893
  I(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
1892
1894
  }), e.constant = n, e.toWatch = r;
1893
1895
  break;
1894
- case N.ThisExpression:
1896
+ case P.ThisExpression:
1895
1897
  e.constant = !1, e.toWatch = [];
1896
1898
  break;
1897
- case N.LocalsExpression:
1899
+ case P.LocalsExpression:
1898
1900
  e.constant = !1, e.toWatch = [];
1899
1901
  break;
1900
1902
  }
1901
1903
  }
1902
- function ae(e) {
1904
+ function L(e) {
1903
1905
  if (e.length === 1) {
1904
1906
  var t = e[0].expression, n = t.toWatch;
1905
1907
  return n.length === 1 && n[0] === t ? void 0 : n;
1906
1908
  }
1907
1909
  }
1908
- function oe(e) {
1909
- return e.type === N.Identifier || e.type === N.MemberExpression;
1910
+ function ae(e) {
1911
+ return e.type === P.Identifier || e.type === P.MemberExpression;
1910
1912
  }
1911
- function L(e) {
1912
- if (e.body.length === 1 && oe(e.body[0].expression)) return {
1913
- type: N.AssignmentExpression,
1913
+ function oe(e) {
1914
+ if (e.body.length === 1 && ae(e.body[0].expression)) return {
1915
+ type: P.AssignmentExpression,
1914
1916
  left: e.body[0].expression,
1915
- right: { type: N.NGValueParameter },
1917
+ right: { type: P.NGValueParameter },
1916
1918
  operator: "="
1917
1919
  };
1918
1920
  }
1919
1921
  function R(e) {
1920
- return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === N.Literal || e.body[0].expression.type === N.ArrayExpression || e.body[0].expression.type === N.ObjectExpression);
1922
+ return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === P.Literal || e.body[0].expression.type === P.ArrayExpression || e.body[0].expression.type === P.ObjectExpression);
1921
1923
  }
1922
1924
  function z(e) {
1923
1925
  return e.constant;
@@ -1944,12 +1946,12 @@ var ge = /* @__PURE__ */ n(((e) => {
1944
1946
  inputs: []
1945
1947
  }, I(n, t.$filter);
1946
1948
  var r = "", i;
1947
- if (this.stage = "assign", i = L(n)) {
1949
+ if (this.stage = "assign", i = oe(n)) {
1948
1950
  this.state.computing = "assign";
1949
1951
  var o = this.nextId();
1950
1952
  this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
1951
1953
  }
1952
- var s = ae(n.body);
1954
+ var s = L(n.body);
1953
1955
  t.stage = "inputs", d(s, function(e, n) {
1954
1956
  var r = "fn" + n;
1955
1957
  t.state[r] = {
@@ -1960,7 +1962,7 @@ var ge = /* @__PURE__ */ n(((e) => {
1960
1962
  var i = t.nextId();
1961
1963
  t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
1962
1964
  }), this.state.computing = "fn", this.stage = "main", this.recurse(n);
1963
- var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, ie, P), u = function(e, t, n, r) {
1965
+ var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, re, ie), u = function(e, t, n, r) {
1964
1966
  return a(function() {
1965
1967
  return l(e, t, n, r);
1966
1968
  });
@@ -2001,35 +2003,35 @@ var ge = /* @__PURE__ */ n(((e) => {
2001
2003
  return;
2002
2004
  }
2003
2005
  switch (e.type) {
2004
- case N.Program:
2006
+ case P.Program:
2005
2007
  d(e.body, function(t, n) {
2006
2008
  c.recurse(t.expression, void 0, void 0, function(e) {
2007
2009
  s = e;
2008
2010
  }), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
2009
2011
  });
2010
2012
  break;
2011
- case N.Literal:
2013
+ case P.Literal:
2012
2014
  u = this.escape(e.value), this.assign(t, u), r(t || u);
2013
2015
  break;
2014
- case N.UnaryExpression:
2016
+ case P.UnaryExpression:
2015
2017
  this.recurse(e.argument, void 0, void 0, function(e) {
2016
2018
  s = e;
2017
2019
  }), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
2018
2020
  break;
2019
- case N.BinaryExpression:
2021
+ case P.BinaryExpression:
2020
2022
  this.recurse(e.left, void 0, void 0, function(e) {
2021
2023
  o = e;
2022
2024
  }), this.recurse(e.right, void 0, void 0, function(e) {
2023
2025
  s = e;
2024
2026
  }), u = e.operator === "+" ? this.plus(o, s) : e.operator === "-" ? this.ifDefined(o, 0) + e.operator + this.ifDefined(s, 0) : "(" + o + ")" + e.operator + "(" + s + ")", this.assign(t, u), r(u);
2025
2027
  break;
2026
- case N.LogicalExpression:
2028
+ case P.LogicalExpression:
2027
2029
  t = t || this.nextId(), c.recurse(e.left, t), e.operator === "??" ? c.if_(c.or_(c.isNull(t), "typeof " + t + " === 'undefined'"), c.lazyRecurse(e.right, t)) : c.if_(e.operator === "&&" ? t : c.not(t), c.lazyRecurse(e.right, t)), r(t);
2028
2030
  break;
2029
- case N.ConditionalExpression:
2031
+ case P.ConditionalExpression:
2030
2032
  t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
2031
2033
  break;
2032
- case N.Identifier:
2034
+ case P.Identifier:
2033
2035
  t = t || this.nextId();
2034
2036
  var m = c.current().inAssignment;
2035
2037
  n && (m ? n.context = this.assign(this.nextId(), "s") : n.context = c.stage === "inputs" ? "s" : this.assign(this.nextId(), this.getHasOwnProperty("l", e.name) + "?l:s"), n.computed = !1, n.name = e.name), c.if_(c.stage === "inputs" || c.not(c.getHasOwnProperty("l", e.name)), function() {
@@ -2043,17 +2045,17 @@ var ge = /* @__PURE__ */ n(((e) => {
2043
2045
  c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
2044
2046
  }), r(t);
2045
2047
  break;
2046
- case N.MemberExpression:
2048
+ case P.MemberExpression:
2047
2049
  o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
2048
2050
  var a = null, l = c.current().inAssignment;
2049
- e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === N.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
2050
- e.computed ? (e.property.type !== N.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
2051
+ e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === P.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
2052
+ e.computed ? (e.property.type !== P.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
2051
2053
  }, function() {
2052
2054
  c.assign(t, "undefined");
2053
2055
  }), r(t);
2054
2056
  }, !!i);
2055
2057
  break;
2056
- case N.CallExpression:
2058
+ case P.CallExpression:
2057
2059
  t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
2058
2060
  var t = c.nextId();
2059
2061
  c.recurse(e, t), l.push(t);
@@ -2069,38 +2071,38 @@ var ge = /* @__PURE__ */ n(((e) => {
2069
2071
  }), r(t);
2070
2072
  }));
2071
2073
  break;
2072
- case N.AssignmentExpression:
2074
+ case P.AssignmentExpression:
2073
2075
  s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
2074
2076
  c.if_(c.and_(c.notNull(o.context), c.or_(c.hasOwnProperty_(o.context, o.name), c.isNull(c.member(o.context, o.name, o.computed)))), function() {
2075
2077
  c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
2076
2078
  }), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
2077
2079
  }, 1), c.current().inAssignment = !1;
2078
2080
  break;
2079
- case N.ArrayExpression:
2081
+ case P.ArrayExpression:
2080
2082
  l = [], d(e.elements, function(t) {
2081
2083
  c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2082
2084
  l.push(e);
2083
2085
  });
2084
2086
  }), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
2085
2087
  break;
2086
- case N.ObjectExpression:
2088
+ case P.ObjectExpression:
2087
2089
  l = [], f = !1, d(e.properties, function(e) {
2088
2090
  e.computed && (f = !0);
2089
2091
  }), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
2090
- e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === N.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2092
+ e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === P.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2091
2093
  })) : (d(e.properties, function(t) {
2092
2094
  c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2093
- l.push(c.escape(t.key.type === N.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2095
+ l.push(c.escape(t.key.type === P.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2094
2096
  });
2095
2097
  }), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
2096
2098
  break;
2097
- case N.ThisExpression:
2099
+ case P.ThisExpression:
2098
2100
  this.assign(t, "s"), r(t || "s");
2099
2101
  break;
2100
- case N.LocalsExpression:
2102
+ case P.LocalsExpression:
2101
2103
  this.assign(t, "l"), r(t || "l");
2102
2104
  break;
2103
- case N.NGValueParameter:
2105
+ case P.NGValueParameter:
2104
2106
  this.assign(t, "v"), r(t || "v");
2105
2107
  break;
2106
2108
  }
@@ -2204,16 +2206,16 @@ var ge = /* @__PURE__ */ n(((e) => {
2204
2206
  return this.state[this.state.computing];
2205
2207
  }
2206
2208
  };
2207
- function V(e, t) {
2209
+ function se(e, t) {
2208
2210
  this.astBuilder = e, this.$filter = t;
2209
2211
  }
2210
- V.prototype = {
2212
+ se.prototype = {
2211
2213
  compile: function(e) {
2212
2214
  var t = this, n = this.astBuilder.ast(e);
2213
2215
  I(n, t.$filter);
2214
2216
  var r, i;
2215
- (r = L(n)) && (i = this.recurse(r));
2216
- var o = ae(n.body), s;
2217
+ (r = oe(n)) && (i = this.recurse(r));
2218
+ var o = L(n.body), s;
2217
2219
  o && (s = [], d(o, function(e, n) {
2218
2220
  var r = t.recurse(e);
2219
2221
  e.input = r, s.push(r), e.watchId = n;
@@ -2246,14 +2248,14 @@ var ge = /* @__PURE__ */ n(((e) => {
2246
2248
  var r, i, a = this, o;
2247
2249
  if (e.input) return this.inputs(e.input, e.watchId);
2248
2250
  switch (e.type) {
2249
- case N.Literal: return this.value(e.value, t);
2250
- case N.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2251
- case N.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2252
- case N.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2253
- case N.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2254
- case N.Identifier: return a.identifier(e.name, t, n);
2255
- case N.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
2256
- case N.CallExpression: return o = [], d(e.arguments, function(e) {
2251
+ case P.Literal: return this.value(e.value, t);
2252
+ case P.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2253
+ case P.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2254
+ case P.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2255
+ case P.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2256
+ case P.Identifier: return a.identifier(e.name, t, n);
2257
+ case P.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
2258
+ case P.CallExpression: return o = [], d(e.arguments, function(e) {
2257
2259
  o.push(a.recurse(e));
2258
2260
  }), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
2259
2261
  for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
@@ -2271,23 +2273,23 @@ var ge = /* @__PURE__ */ n(((e) => {
2271
2273
  }
2272
2274
  return t ? { value: c } : c;
2273
2275
  };
2274
- case N.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2276
+ case P.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2275
2277
  var s = r(e, !1, a, o), c = i(e, n, a, o);
2276
2278
  return s.context[s.name] = c, t ? { value: c } : c;
2277
2279
  };
2278
- case N.ArrayExpression: return o = [], d(e.elements, function(e) {
2280
+ case P.ArrayExpression: return o = [], d(e.elements, function(e) {
2279
2281
  o.push(a.recurse(e));
2280
2282
  }), function(e, n, r, i) {
2281
2283
  for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
2282
2284
  return t ? { value: a } : a;
2283
2285
  };
2284
- case N.ObjectExpression: return o = [], d(e.properties, function(e) {
2286
+ case P.ObjectExpression: return o = [], d(e.properties, function(e) {
2285
2287
  e.computed ? o.push({
2286
2288
  key: a.recurse(e.key),
2287
2289
  computed: !0,
2288
2290
  value: a.recurse(e.value)
2289
2291
  }) : o.push({
2290
- key: e.key.type === N.Identifier ? e.key.name : "" + e.key.value,
2292
+ key: e.key.type === P.Identifier ? e.key.name : "" + e.key.value,
2291
2293
  computed: !1,
2292
2294
  value: a.recurse(e.value)
2293
2295
  });
@@ -2295,13 +2297,13 @@ var ge = /* @__PURE__ */ n(((e) => {
2295
2297
  for (var a = {}, s = 0; s < o.length; ++s) o[s].computed ? a[o[s].key(e, n, r, i)] = o[s].value(e, n, r, i) : a[o[s].key] = o[s].value(e, n, r, i);
2296
2298
  return t ? { value: a } : a;
2297
2299
  };
2298
- case N.ThisExpression: return function(e) {
2300
+ case P.ThisExpression: return function(e) {
2299
2301
  return t ? { value: e } : e;
2300
2302
  };
2301
- case N.LocalsExpression: return function(e, n) {
2303
+ case P.LocalsExpression: return function(e, n) {
2302
2304
  return t ? { value: n } : n;
2303
2305
  };
2304
- case N.NGValueParameter: return function(e, n, r) {
2306
+ case P.NGValueParameter: return function(e, n, r) {
2305
2307
  return t ? { value: r } : r;
2306
2308
  };
2307
2309
  }
@@ -2326,7 +2328,7 @@ var ge = /* @__PURE__ */ n(((e) => {
2326
2328
  },
2327
2329
  "binary+": function(e, t, n) {
2328
2330
  return function(r, i, a, o) {
2329
- var s = P(e(r, i, a, o), t(r, i, a, o));
2331
+ var s = ie(e(r, i, a, o), t(r, i, a, o));
2330
2332
  return n ? { value: s } : s;
2331
2333
  };
2332
2334
  },
@@ -2478,17 +2480,17 @@ var ge = /* @__PURE__ */ n(((e) => {
2478
2480
  /**
2479
2481
  * @constructor
2480
2482
  */
2481
- var H = function(e, t, n) {
2482
- this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new N(e, n), this.ast.selfReferential = { $locals: { type: N.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: N.ThisExpression }), this.astCompiler = n.csp ? new V(this.ast, t) : new B(this.ast, t);
2483
+ var V = function(e, t, n) {
2484
+ this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new P(e, n), this.ast.selfReferential = { $locals: { type: P.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: P.ThisExpression }), this.astCompiler = n.csp ? new se(this.ast, t) : new B(this.ast, t);
2483
2485
  };
2484
- H.prototype = {
2485
- constructor: H,
2486
+ V.prototype = {
2487
+ constructor: V,
2486
2488
  parse: function(e) {
2487
2489
  return this.astCompiler.compile(e);
2488
2490
  }
2489
- }, e.Lexer = M, e.Parser = H;
2490
- })), _e = (/* @__PURE__ */ n(((e) => {
2491
- var t = ge(), n = {}, r = t.Lexer, i = t.Parser;
2491
+ }, e.Lexer = N, e.Parser = V;
2492
+ })), ve = (/* @__PURE__ */ r(((e) => {
2493
+ var t = _e(), n = {}, r = t.Lexer, i = t.Parser;
2492
2494
  function a(e) {
2493
2495
  return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
2494
2496
  }
@@ -2526,7 +2528,7 @@ var ge = /* @__PURE__ */ n(((e) => {
2526
2528
  s.cache = Object.create(null), e.compile = s;
2527
2529
  })))();
2528
2530
  /** Cleans deeds the way puzzmo.com's PlayGameIframe and the API's `getDeedsFromCompletion` do, collecting what was dropped. */
2529
- const ve = (e, t) => {
2531
+ const ye = (e, t) => {
2530
2532
  let n = [];
2531
2533
  e !== void 0 && !Array.isArray(e) && n.push("deeds is not an array, the host ignores it");
2532
2534
  let r = [];
@@ -2560,17 +2562,17 @@ const ve = (e, t) => {
2560
2562
  })),
2561
2563
  warnings: n
2562
2564
  };
2563
- }, ye = (e) => {
2565
+ }, be = (e) => {
2564
2566
  let t = {};
2565
- for (let n of e) n.value !== void 0 && (t[Se(n.id)] = n.value);
2567
+ for (let n of e) n.value !== void 0 && (t[Ce(n.id)] = n.value);
2566
2568
  return t;
2567
- }, be = (e, t) => {
2569
+ }, xe = (e, t) => {
2568
2570
  try {
2569
- if (e.filterExp && !(0, _e.compile)(e.filterExp)(t) || !e.incrementExp) return {
2571
+ if (e.filterExp && !(0, ve.compile)(e.filterExp)(t) || !e.incrementExp) return {
2570
2572
  complete: !1,
2571
2573
  value: 0
2572
2574
  };
2573
- let n = (0, _e.compile)(e.incrementExp)(t);
2575
+ let n = (0, ve.compile)(e.incrementExp)(t);
2574
2576
  if (typeof n == "boolean" && (n = n ? 1 : 0), n === void 0 && (n = 0), typeof n != "number" || isNaN(n)) throw Error(`incrementExp must return a number, undefined or boolean, got ${n}`);
2575
2577
  let r = Math.floor(n);
2576
2578
  return {
@@ -2584,17 +2586,17 @@ const ve = (e, t) => {
2584
2586
  error: e.message
2585
2587
  };
2586
2588
  }
2587
- }, xe = (e) => {
2589
+ }, Se = (e) => {
2588
2590
  let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
2589
- for (; i < t.length && (a = be(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
2591
+ for (; i < t.length && (a = xe(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
2590
2592
  return {
2591
2593
  index: i,
2592
2594
  head: i < t.length ? a : void 0
2593
2595
  };
2594
2596
  };
2595
- var Se = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
2597
+ var Ce = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
2596
2598
  /** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
2597
- function Ce(e) {
2599
+ function we(e) {
2598
2600
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = [], s = (e) => {
2599
2601
  var t;
2600
2602
  return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
@@ -2649,11 +2651,11 @@ function Ce(e) {
2649
2651
  let t = e.getElement("#simulator-checklist-list");
2650
2652
  t && (t.innerHTML = f());
2651
2653
  }, m = (n, r, s, c) => {
2652
- let u = 0, d = ve(r, s), f = ye(d.deeds);
2654
+ let u = 0, d = ye(r, s), f = be(d.deeds);
2653
2655
  a = c, o = d.warnings;
2654
2656
  for (let n of e) {
2655
2657
  var m, h;
2656
- let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = xe({
2658
+ let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = Se({
2657
2659
  items: n.items,
2658
2660
  index: e,
2659
2661
  scope: f,
@@ -2693,7 +2695,7 @@ function Ce(e) {
2693
2695
  }
2694
2696
  var K = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2695
2697
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
2696
- function we() {
2698
+ function Te() {
2697
2699
  let e = globalThis;
2698
2700
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
2699
2701
  name: t,
@@ -2702,23 +2704,26 @@ function we() {
2702
2704
  return null;
2703
2705
  }
2704
2706
  /** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
2705
- function Te() {
2707
+ function Ee() {
2706
2708
  let e = globalThis.getShareString;
2707
2709
  return typeof e == "function" ? e : null;
2708
2710
  }
2709
- function Ee(e) {
2711
+ function De(e) {
2710
2712
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2711
2713
  }
2712
- function De() {
2714
+ function Oe() {
2713
2715
  let e = /* @__PURE__ */ new Date();
2714
2716
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
2715
2717
  }
2716
- function Oe(e) {
2718
+ function ke(e) {
2717
2719
  return e.charAt(0).toUpperCase() + e.slice(1);
2718
2720
  }
2719
2721
  /** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
2720
- var ke = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) =&gt; ({ str: `${title}: ...` })</pre>\n </div>\n";
2721
- function Ae() {
2722
+ var Ae = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) =&gt; ({ str: `${title}: ...` })</pre>\n </div>\n";
2723
+ function je() {
2724
+ let e, t, r = () => {
2725
+ e == null || e.dispose(), e = void 0, t = void 0;
2726
+ };
2722
2727
  return {
2723
2728
  id: "thumb",
2724
2729
  label: "Thumb",
@@ -2740,63 +2745,64 @@ function Ae() {
2740
2745
  o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
2741
2746
  t.addEventListener("click", () => {
2742
2747
  let n = t.dataset.previewKind;
2743
- !n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
2748
+ !n || n === e.state.previewKind || (e.state.previewKind = n, j(n), c(), s(), e.updateThumbnail());
2744
2749
  });
2745
- }), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2746
- e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
2747
- })), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2748
- e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
2750
+ }), n && (e.state.renderHost || (e.state.renderHost = "game", A(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2751
+ e.state.renderHost = n.value, A(e.state.renderHost), s(), e.updateThumbnail();
2752
+ })), r && (e.state.renderContext || (e.state.renderContext = "preview", M(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2753
+ e.state.renderContext = r.value, M(e.state.renderContext), e.updateThumbnail();
2749
2754
  })), c(), s();
2750
2755
  },
2751
2756
  onActivate(e) {
2752
2757
  setTimeout(() => e.updateThumbnail(), 0);
2753
2758
  },
2754
- updatePreview: (e) => {
2755
- let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
2756
- if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
2757
- let s = Te();
2758
- if (!s) {
2759
- t && (t.innerHTML = ke), n && (n.textContent = "");
2759
+ updatePreview: (i) => {
2760
+ let a = i.getElement("#simulator-thumb-preview"), o = i.getElement("#simulator-thumb-fn");
2761
+ if (a == null || a.style.setProperty("--sim-thumb-bg", i.state.selectedTheme.g_bg), i.state.previewKind === "text") {
2762
+ r();
2763
+ let e = Ee();
2764
+ if (!e) {
2765
+ a && (a.innerHTML = Ae), o && (o.textContent = "");
2760
2766
  return;
2761
2767
  }
2762
- n && (n.textContent = "Using: getShareString()");
2768
+ o && (o.textContent = "Using: getShareString()");
2763
2769
  try {
2764
- var r, i, a, o;
2765
- let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Oe(n), {
2766
- puzzleString: (a = e.state.puzzleData) == null ? "" : a,
2767
- dateKey: De(),
2768
- gameplaySlug: `simulator:${n}`
2769
- }), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
2770
- t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ee(l)}</pre>`);
2770
+ var s, c, l, u;
2771
+ let t = (s = i.gameSlug) == null ? "game" : s, n = e((c = i.state.currentInputStr) == null ? "" : c, ke(t), {
2772
+ puzzleString: (l = i.state.puzzleData) == null ? "" : l,
2773
+ dateKey: Oe(),
2774
+ gameplaySlug: `simulator:${t}`
2775
+ }), r = (u = n == null ? void 0 : n.str) == null ? "" : u;
2776
+ a && (a.innerHTML = `<pre class="simulator-share-preview" style="color: ${i.state.selectedTheme.fg}">${De(r)}</pre>`);
2771
2777
  } catch (e) {
2772
- console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2778
+ console.error("Simulator: Share string error", e), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2773
2779
  }
2774
2780
  return;
2775
2781
  }
2776
- let s = we();
2777
- if (!s) {
2778
- t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
2782
+ let d = Te();
2783
+ if (!d) {
2784
+ r(), a && (a.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), o && (o.textContent = "");
2779
2785
  return;
2780
2786
  }
2781
- n && (n.textContent = `Using: ${s.name}()`);
2787
+ o && (o.textContent = `Using: ${d.name}()`);
2782
2788
  try {
2783
- var c;
2784
- let n = (c = e.state.puzzleData) == null ? "" : c, r = {
2789
+ var f;
2790
+ let o = (f = i.state.puzzleData) == null ? "" : f, s = {
2785
2791
  viewerIsOwner: !0,
2786
- theme: e.state.selectedTheme,
2792
+ theme: i.state.selectedTheme,
2787
2793
  strict: !0,
2788
- renderHost: e.state.renderHost,
2789
- renderContext: e.state.renderContext
2790
- }, { svg: i } = L(s.fn(n, e.state.currentInputStr, r));
2791
- t && (t.innerHTML = i);
2794
+ renderHost: i.state.renderHost,
2795
+ renderContext: i.state.renderContext
2796
+ }, { svg: c } = R(d.fn(o, i.state.currentInputStr, s));
2797
+ a && ((!e || t !== a) && (r(), a.innerHTML = "", e = n(a), t = a), e.show(c));
2792
2798
  } catch (e) {
2793
- console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2799
+ console.error("Simulator: Thumbnail error", e), r(), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2794
2800
  }
2795
2801
  }
2796
2802
  };
2797
2803
  }
2798
2804
  /** Generate theme preview HTML showing key colors */
2799
- function je(e) {
2805
+ function Me(e) {
2800
2806
  let t = [
2801
2807
  e.key,
2802
2808
  e.subBrand,
@@ -2807,7 +2813,7 @@ function je(e) {
2807
2813
  ].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
2808
2814
  return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
2809
2815
  }
2810
- function Me() {
2816
+ function Ne() {
2811
2817
  return {
2812
2818
  id: "theme",
2813
2819
  label: "Theme",
@@ -2816,20 +2822,20 @@ function Me() {
2816
2822
  },
2817
2823
  bind(e) {
2818
2824
  let t = e.getElement("#simulator-themes");
2819
- t && r.forEach((n) => {
2825
+ t && i.forEach((n) => {
2820
2826
  let r = document.createElement("div");
2821
2827
  r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
2822
- ${je(n)}
2828
+ ${Me(n)}
2823
2829
  <div class="simulator-theme-name">${n.name}</div>
2824
2830
  <div class="simulator-theme-type">${n.type}</div>
2825
2831
  `, r.addEventListener("click", () => {
2826
- console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
2832
+ console.log("Simulator: Theme changed, reloading...", n.name), E(n.name), window.location.reload();
2827
2833
  }), t.appendChild(r);
2828
2834
  });
2829
2835
  }
2830
2836
  };
2831
2837
  }
2832
- var Ne = [
2838
+ var Pe = [
2833
2839
  {
2834
2840
  name: "app (desktop)",
2835
2841
  context: [{
@@ -2876,8 +2882,8 @@ var Ne = [
2876
2882
  * The bootstrap is only read at game boot, so applying a change persists it to localStorage and
2877
2883
  * restarts (reloads) the page — the same flow as the Theme tab.
2878
2884
  */
2879
- function Pe(e = []) {
2880
- let t = [...Ne, ...e];
2885
+ function Fe(e = []) {
2886
+ let t = [...Pe, ...e];
2881
2887
  return {
2882
2888
  id: "host",
2883
2889
  label: "Host",
@@ -2894,7 +2900,7 @@ function Pe(e = []) {
2894
2900
  <div class="host-note" id="host-source"></div>
2895
2901
  <select class="simulator-select" id="host-presets">
2896
2902
  <option value="">Preset…</option>
2897
- ${t.map((e, t) => `<option value="${t}">${Fe(e.name)}</option>`).join("")}
2903
+ ${t.map((e, t) => `<option value="${t}">${Ie(e.name)}</option>`).join("")}
2898
2904
  </select>
2899
2905
  <textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
2900
2906
  <div class="host-actions">
@@ -2923,24 +2929,24 @@ function Pe(e = []) {
2923
2929
  o.textContent = "hostContext must be an array of { type: string, ... } objects";
2924
2930
  return;
2925
2931
  }
2926
- console.log("Simulator: hostContext changed, reloading...", e), f(e), window.location.reload();
2932
+ console.log("Simulator: hostContext changed, reloading...", e), p(e), window.location.reload();
2927
2933
  }), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
2928
- p(), window.location.reload();
2934
+ m(), window.location.reload();
2929
2935
  }));
2930
2936
  }
2931
2937
  };
2932
2938
  }
2933
2939
  /** Minimal HTML-escape so preset names can't break the simulator markup. */
2934
- function Fe(e) {
2940
+ function Ie(e) {
2935
2941
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2936
2942
  }
2937
- var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.puzzmo.com", q = () => localStorage.getItem(Ie) === "dev" ? "dev" : "prod", ze = (e) => {
2938
- localStorage.setItem(Ie, e);
2939
- }, J = null, Be = function() {
2943
+ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.puzzmo.com", q = () => localStorage.getItem(Le) === "dev" ? "dev" : "prod", Be = (e) => {
2944
+ localStorage.setItem(Le, e);
2945
+ }, J = null, Ve = function() {
2940
2946
  var e = t(function* () {
2941
2947
  if (J !== null) return J;
2942
2948
  try {
2943
- let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Le}/healthz`, { signal: e.signal });
2949
+ let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Re}/healthz`, { signal: e.signal });
2944
2950
  return clearTimeout(t), J = n.ok, J;
2945
2951
  } catch (e) {
2946
2952
  return J = !1, !1;
@@ -2949,24 +2955,24 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
2949
2955
  return function() {
2950
2956
  return e.apply(this, arguments);
2951
2957
  };
2952
- }(), Ve = () => ({
2953
- apiURL: q() === "dev" ? Le : Re,
2958
+ }(), He = () => ({
2959
+ apiURL: q() === "dev" ? Re : ze,
2954
2960
  clientID: "protosdk:oauthclient",
2955
2961
  redirectUri: `${window.location.origin}/oauth/callback`
2956
- }), He = () => {
2962
+ }), Ue = () => {
2957
2963
  let e = new Uint8Array(32);
2958
2964
  return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2959
- }, Ue = "puzzmo_sim_oauth_token", We = "puzzmo_sim_oauth_refresh_token", Ge = (e) => localStorage.setItem(Ue, e), Ke = (e) => localStorage.setItem(We, e), qe = () => {
2960
- let e = localStorage.getItem(Ue);
2965
+ }, We = "puzzmo_sim_oauth_token", Ge = "puzzmo_sim_oauth_refresh_token", Ke = (e) => localStorage.setItem(We, e), qe = (e) => localStorage.setItem(Ge, e), Je = () => {
2966
+ let e = localStorage.getItem(We);
2961
2967
  return e && `${e.substring(0, 20)}`, e;
2962
- }, Je = () => localStorage.getItem(We), Ye = () => {
2963
- localStorage.removeItem(Ue), localStorage.removeItem(We);
2964
- }, Xe = () => {
2965
- let e = Ve(), t = He();
2968
+ }, Ye = () => localStorage.getItem(Ge), Xe = () => {
2969
+ localStorage.removeItem(We), localStorage.removeItem(Ge);
2970
+ }, Ze = () => {
2971
+ let e = He(), t = Ue();
2966
2972
  sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
2967
2973
  let n = new URL(`${e.apiURL}/oauth/auth`);
2968
2974
  n.searchParams.set("client_id", e.clientID), n.searchParams.set("response_type", "code"), n.searchParams.set("redirect_uri", e.redirectUri), n.searchParams.set("state", t), window.location.href = n.toString();
2969
- }, Ze = (e) => {
2975
+ }, Qe = (e) => {
2970
2976
  try {
2971
2977
  let t = e.split(".");
2972
2978
  if (t.length !== 3) return !0;
@@ -2975,11 +2981,11 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
2975
2981
  } catch (e) {
2976
2982
  return !0;
2977
2983
  }
2978
- }, Qe = function() {
2984
+ }, $e = function() {
2979
2985
  var e = t(function* () {
2980
- let e = Je();
2986
+ let e = Ye();
2981
2987
  if (!e) return !1;
2982
- let t = Ve();
2988
+ let t = He();
2983
2989
  try {
2984
2990
  let n = new URLSearchParams({
2985
2991
  grant_type: "refresh_token",
@@ -2993,9 +2999,9 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
2993
2999
  if (!r.ok) return r.statusText, !1;
2994
3000
  let i = yield r.json(), a = i.access_token || i.accessToken;
2995
3001
  if (!a) return !1;
2996
- Ge(a);
3002
+ Ke(a);
2997
3003
  let o = i.refresh_token || i.refreshToken;
2998
- return o && Ke(o), !0;
3004
+ return o && qe(o), !0;
2999
3005
  } catch (e) {
3000
3006
  return !1;
3001
3007
  }
@@ -3003,9 +3009,9 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
3003
3009
  return function() {
3004
3010
  return e.apply(this, arguments);
3005
3011
  };
3006
- }(), $e = function() {
3012
+ }(), et = function() {
3007
3013
  var e = t(function* (e, t) {
3008
- let n = Ve(), r = sessionStorage.getItem("oauth_state");
3014
+ let n = He(), r = sessionStorage.getItem("oauth_state");
3009
3015
  if (!r || r !== t) return null;
3010
3016
  sessionStorage.removeItem("oauth_state");
3011
3017
  try {
@@ -3027,13 +3033,13 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
3027
3033
  return function(t, n) {
3028
3034
  return e.apply(this, arguments);
3029
3035
  };
3030
- }(), et = function() {
3036
+ }(), tt = function() {
3031
3037
  var e = t(function* (e, t = {}) {
3032
- let n = Ve(), r = qe();
3038
+ let n = He(), r = Je();
3033
3039
  if (!r) throw Error("Not authenticated");
3034
- if (Ze(r)) if (yield Qe()) {
3035
- if (r = qe(), !r) throw Error("Token refresh succeeded but no token available");
3036
- } else throw Ye(), Error("Session expired. Please log in again.");
3040
+ if (Qe(r)) if (yield $e()) {
3041
+ if (r = Je(), !r) throw Error("Token refresh succeeded but no token available");
3042
+ } else throw Xe(), Error("Session expired. Please log in again.");
3037
3043
  let i = yield fetch(`${n.apiURL}/graphql`, {
3038
3044
  method: "POST",
3039
3045
  headers: {
@@ -3052,7 +3058,7 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
3052
3058
  return function(t) {
3053
3059
  return e.apply(this, arguments);
3054
3060
  };
3055
- }(), tt = (e) => {
3061
+ }(), nt = (e) => {
3056
3062
  try {
3057
3063
  let t = e.split(".");
3058
3064
  return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
@@ -3060,15 +3066,15 @@ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.
3060
3066
  return null;
3061
3067
  }
3062
3068
  };
3063
- function nt() {
3069
+ function rt() {
3064
3070
  let e = !1;
3065
3071
  return {
3066
3072
  id: "auth",
3067
3073
  label: "Auth",
3068
3074
  render() {
3069
- let e = qe(), t = !!e, n = q(), r = n === "dev" ? Le : Re, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3075
+ let e = Je(), t = !!e, n = q(), r = n === "dev" ? Re : ze, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3070
3076
  if (t) {
3071
- let t = tt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Je(), o = a ? tt(Je()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3077
+ let t = nt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Ye(), o = a ? nt(Ye()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3072
3078
  return `
3073
3079
  <div class="simulator-section">
3074
3080
  <div class="simulator-section-title auth-title-row">
@@ -3109,7 +3115,7 @@ function nt() {
3109
3115
  </div>
3110
3116
  <p class="auth-description">
3111
3117
  Login with your Puzzmo account to make authenticated API requests.
3112
- ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Le}` : ""}
3118
+ ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Re}` : ""}
3113
3119
  </p>
3114
3120
  <div class="simulator-row">
3115
3121
  <button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
@@ -3120,21 +3126,21 @@ function nt() {
3120
3126
  },
3121
3127
  bind(n) {
3122
3128
  let r = n.getElement("#auth-login"), i = n.getElement("#auth-logout"), a = n.getElement("#auth-refresh"), o = n.getElement("#auth-test-api"), s = n.getElement("#auth-api-result"), c = n.getElement("#auth-dev-toggle");
3123
- e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Be().then((e) => {
3129
+ e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Ve().then((e) => {
3124
3130
  e && c && (c.style.display = "", q() === "dev" && c.classList.add("active"));
3125
3131
  })), c == null || c.addEventListener("click", () => {
3126
- ze(q() === "dev" ? "prod" : "dev"), Ye(), window.location.reload();
3132
+ Be(q() === "dev" ? "prod" : "dev"), Xe(), window.location.reload();
3127
3133
  }), r == null || r.addEventListener("click", () => {
3128
- Xe();
3134
+ Ze();
3129
3135
  }), i == null || i.addEventListener("click", () => {
3130
- Ye(), window.location.reload();
3136
+ Xe(), window.location.reload();
3131
3137
  }), a == null || a.addEventListener("click", t(function* () {
3132
- a.disabled = !0, a.textContent = "Refreshing...", (yield Qe()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3138
+ a.disabled = !0, a.textContent = "Refreshing...", (yield $e()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3133
3139
  })), o == null || o.addEventListener("click", t(function* () {
3134
3140
  if (s) {
3135
3141
  s.innerHTML = "<div class=\"loading\">Loading...</div>";
3136
3142
  try {
3137
- let t = yield et("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3143
+ let t = yield tt("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3138
3144
  if (t.errors) {
3139
3145
  var e;
3140
3146
  s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
@@ -3156,13 +3162,13 @@ function nt() {
3156
3162
  if (n && r) {
3157
3163
  let t = e.getElement("#auth-status");
3158
3164
  t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
3159
- let i = yield $e(n, r);
3165
+ let i = yield et(n, r);
3160
3166
  if (window.history.replaceState({}, "", window.location.pathname), i) {
3161
3167
  let e = i.access_token || i.accessToken;
3162
3168
  if (e) {
3163
- Ge(e);
3169
+ Ke(e);
3164
3170
  let t = i.refresh_token || i.refreshToken;
3165
- t && Ke(t);
3171
+ t && qe(t);
3166
3172
  }
3167
3173
  window.location.reload();
3168
3174
  } else {
@@ -3174,9 +3180,9 @@ function nt() {
3174
3180
  }
3175
3181
  };
3176
3182
  }
3177
- var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.puzzmo.com", ot = "puzzmo_sim_oauth_token", st = "puzzmo_sim_oauth_refresh_token", ct = () => localStorage.getItem(rt) === "dev" ? "dev" : "prod", lt = () => localStorage.getItem(ot), ut = () => localStorage.getItem(st), dt = (e) => localStorage.setItem(ot, e), ft = (e) => localStorage.setItem(st, e), pt = () => {
3178
- localStorage.removeItem(ot), localStorage.removeItem(st);
3179
- }, mt = (e) => {
3183
+ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.puzzmo.com", st = "puzzmo_sim_oauth_token", ct = "puzzmo_sim_oauth_refresh_token", lt = () => localStorage.getItem(it) === "dev" ? "dev" : "prod", ut = () => localStorage.getItem(st), dt = () => localStorage.getItem(ct), ft = (e) => localStorage.setItem(st, e), pt = (e) => localStorage.setItem(ct, e), mt = () => {
3184
+ localStorage.removeItem(st), localStorage.removeItem(ct);
3185
+ }, ht = (e) => {
3180
3186
  try {
3181
3187
  let t = e.split(".");
3182
3188
  if (t.length !== 3) return !0;
@@ -3185,11 +3191,11 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3185
3191
  } catch (e) {
3186
3192
  return !0;
3187
3193
  }
3188
- }, ht = function() {
3194
+ }, gt = function() {
3189
3195
  var e = t(function* () {
3190
- let e = ut();
3196
+ let e = dt();
3191
3197
  if (!e) return !1;
3192
- let t = ct() === "dev" ? it : at;
3198
+ let t = lt() === "dev" ? at : ot;
3193
3199
  try {
3194
3200
  let n = new URLSearchParams({
3195
3201
  grant_type: "refresh_token",
@@ -3203,9 +3209,9 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3203
3209
  if (!r.ok) return !1;
3204
3210
  let i = yield r.json(), a = i.access_token || i.accessToken;
3205
3211
  if (!a) return !1;
3206
- dt(a);
3212
+ ft(a);
3207
3213
  let o = i.refresh_token || i.refreshToken;
3208
- return o && ft(o), !0;
3214
+ return o && pt(o), !0;
3209
3215
  } catch (e) {
3210
3216
  return !1;
3211
3217
  }
@@ -3213,13 +3219,13 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3213
3219
  return function() {
3214
3220
  return e.apply(this, arguments);
3215
3221
  };
3216
- }(), gt = function() {
3222
+ }(), _t = function() {
3217
3223
  var e = t(function* (e, t = {}) {
3218
- let n = ct() === "dev" ? it : at, r = lt();
3224
+ let n = lt() === "dev" ? at : ot, r = ut();
3219
3225
  if (!r) throw Error("Not authenticated");
3220
- if (mt(r)) if (yield ht()) {
3221
- if (r = lt(), !r) throw Error("Token refresh succeeded but no token available");
3222
- } else throw pt(), Error("Session expired. Please log in again.");
3226
+ if (ht(r)) if (yield gt()) {
3227
+ if (r = ut(), !r) throw Error("Token refresh succeeded but no token available");
3228
+ } else throw mt(), Error("Session expired. Please log in again.");
3223
3229
  let i = yield fetch(`${n}/graphql`, {
3224
3230
  method: "POST",
3225
3231
  headers: {
@@ -3238,19 +3244,19 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3238
3244
  return function(t) {
3239
3245
  return e.apply(this, arguments);
3240
3246
  };
3241
- }(), _t = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", vt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = (e, t) => {
3247
+ }(), vt = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", bt = (e, t) => {
3242
3248
  let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
3243
3249
  for (; a.length <= r;) a.push(0);
3244
3250
  return a[r] = a[r] ^ 1 << i, a;
3245
3251
  };
3246
- const bt = () => !!lt();
3247
- function xt() {
3252
+ const xt = () => !!ut();
3253
+ function St() {
3248
3254
  let n = null, r = !1, i = null, a = function() {
3249
3255
  var e = t(function* (e) {
3250
3256
  r = !0, i = null;
3251
3257
  try {
3252
3258
  var t;
3253
- let r = yield gt(_t, { slug: e });
3259
+ let r = yield _t(vt, { slug: e });
3254
3260
  if (r.errors) {
3255
3261
  var a;
3256
3262
  i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
@@ -3267,10 +3273,10 @@ function xt() {
3267
3273
  }(), o = function() {
3268
3274
  var r = t(function* (t) {
3269
3275
  if (!n) return;
3270
- let r = yt(n.featuresArr, t);
3276
+ let r = bt(n.featuresArr, t);
3271
3277
  try {
3272
3278
  var i;
3273
- let t = yield gt(vt, {
3279
+ let t = yield _t(yt, {
3274
3280
  gameSlug: n.slug,
3275
3281
  input: { featuresArr: r }
3276
3282
  });
@@ -3318,7 +3324,7 @@ function xt() {
3318
3324
  id: "features",
3319
3325
  label: "Features",
3320
3326
  render() {
3321
- return bt() ? `
3327
+ return xt() ? `
3322
3328
  <div class="features-view-container">
3323
3329
  <div class="simulator-section">
3324
3330
  <div class="simulator-section-title">Game Features</div>
@@ -3359,7 +3365,7 @@ function xt() {
3359
3365
  e && (yield d(e));
3360
3366
  })), i == null || i.addEventListener("keypress", (e) => {
3361
3367
  e.key === "Enter" && (r == null || r.click());
3362
- }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, bt() && !n && d(e.gameSlug)), u();
3368
+ }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, xt() && !n && d(e.gameSlug)), u();
3363
3369
  },
3364
3370
  onActivate(e) {
3365
3371
  let t = e.getElement("#simulator-tab-features");
@@ -3383,15 +3389,15 @@ function xt() {
3383
3389
  * tuning it needs to see it.
3384
3390
  */
3385
3391
  /** Space the keys occupy. */
3386
- var St = 200, Ct = 24;
3392
+ var Ct = 200, wt = 24;
3387
3393
  /** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
3388
- const Y = St + Ct;
3394
+ const Y = Ct + wt;
3389
3395
  /** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
3390
- var wt = 6, Tt = 2.5, Et = 100, Dt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
3396
+ var Tt = 6, Et = 2.5, Dt = 100, Ot = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
3391
3397
  let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
3392
3398
  return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
3393
- }, Ot = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), kt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3394
- function At(e) {
3399
+ }, kt = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), At = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3400
+ function jt(e) {
3395
3401
  let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
3396
3402
  o.id = "sim-docked-kbd-page-style", o.textContent = `
3397
3403
  html.sim-kbd-docked #simulator {
@@ -3440,7 +3446,7 @@ function At(e) {
3440
3446
  }, f = (e, t) => {
3441
3447
  var n, r;
3442
3448
  let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), s = [
3443
- `width:${Dt(t.l.includes(e), t.xl.includes(e))}`,
3449
+ `width:${Ot(t.l.includes(e), t.xl.includes(e))}`,
3444
3450
  `flex:${o ? "1 0 auto" : "0 1 auto"}`,
3445
3451
  "height:100%",
3446
3452
  "display:flex",
@@ -3450,8 +3456,8 @@ function At(e) {
3450
3456
  "position:relative",
3451
3457
  a ? "pointer-events:none" : ""
3452
3458
  ].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
3453
- return `<div class="sim-docked-kbd-key" data-key="${Ot(e)}" style="${s}">
3454
- <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${kt(i)}</div></div>
3459
+ return `<div class="sim-docked-kbd-key" data-key="${kt(e)}" style="${s}">
3460
+ <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${At(i)}</div></div>
3455
3461
  </div>`;
3456
3462
  }, p = (e) => {
3457
3463
  let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
@@ -3467,17 +3473,17 @@ function At(e) {
3467
3473
  }, S = (e) => {
3468
3474
  var t, n;
3469
3475
  return (t = (n = document.elementFromPoint(e.clientX, e.clientY)) == null || (n = n.closest(".sim-docked-kbd-key")) == null ? void 0 : n.getAttribute("data-key")) == null ? null : t;
3470
- }, ee = (e) => {
3471
- y = S(e), a == null || a.setPointerCapture(e.pointerId);
3472
3476
  }, C = (e) => {
3473
- !(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= wt && Date.now() - v >= Et && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Tt, h[1] + (e.clientY - g.clientY) * Tt]), g = {
3477
+ y = S(e), a == null || a.setPointerCapture(e.pointerId);
3478
+ }, ee = (e) => {
3479
+ !(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= Tt && Date.now() - v >= Dt && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Et, h[1] + (e.clientY - g.clientY) * Et]), g = {
3474
3480
  clientX: e.clientX,
3475
3481
  clientY: e.clientY,
3476
3482
  pointerId: e.pointerId
3477
3483
  }, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
3478
3484
  }, w = (e) => {
3479
3485
  m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
3480
- }, te = () => {
3486
+ }, T = () => {
3481
3487
  a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
3482
3488
  "position:fixed",
3483
3489
  "left:0",
@@ -3486,7 +3492,7 @@ function At(e) {
3486
3492
  `height:${Y}px`,
3487
3493
  "box-sizing:border-box",
3488
3494
  "padding-top:8px",
3489
- `padding-bottom:${Ct}px`,
3495
+ `padding-bottom:${wt}px`,
3490
3496
  "display:flex",
3491
3497
  "flex-direction:column",
3492
3498
  "z-index:999998",
@@ -3495,18 +3501,18 @@ function At(e) {
3495
3501
  "-webkit-user-select:none",
3496
3502
  `background:${t.a_bg}`,
3497
3503
  `border-top:1px solid ${X(t.fg, .2)}`
3498
- ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", ee), a.addEventListener("pointermove", C), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
3499
- }, ne = () => {
3504
+ ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", ee), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
3505
+ }, te = () => {
3500
3506
  a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
3501
- }, T = () => {
3507
+ }, ne = () => {
3502
3508
  let e = i;
3503
3509
  !a || !e || a.querySelectorAll(".sim-docked-kbd-key").forEach((t) => {
3504
3510
  let n = t.getAttribute("data-key"), r = t.firstElementChild, i = r == null ? void 0 : r.firstElementChild;
3505
3511
  !n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
3506
3512
  });
3507
3513
  }, E = () => {
3508
- if (!r || !i) return ne();
3509
- if (!a) return te();
3514
+ if (!r || !i) return te();
3515
+ if (!a) return T();
3510
3516
  a.innerHTML = p(i), b(m);
3511
3517
  };
3512
3518
  return {
@@ -3514,13 +3520,13 @@ function At(e) {
3514
3520
  r = e, E();
3515
3521
  },
3516
3522
  setConfig(e) {
3517
- let t = a && e && i && jt(e) === jt(i);
3518
- i = e, t ? T() : E();
3523
+ let t = a && e && i && Mt(e) === Mt(i);
3524
+ i = e, t ? ne() : E();
3519
3525
  }
3520
3526
  };
3521
3527
  }
3522
3528
  /** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
3523
- var jt = (e) => JSON.stringify([
3529
+ var Mt = (e) => JSON.stringify([
3524
3530
  e.layout,
3525
3531
  e.symbols,
3526
3532
  e.highlight,
@@ -3532,9 +3538,9 @@ var jt = (e) => JSON.stringify([
3532
3538
  e.keyStyles
3533
3539
  ]);
3534
3540
  /** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
3535
- const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${Ot(String(t))}`).join(";");
3541
+ const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${kt(String(t))}`).join(";");
3536
3542
  /** Renders a single keyboard key as an HTML button string */
3537
- var Mt = (e, t) => {
3543
+ var Nt = (e, t) => {
3538
3544
  var n, r, i, a;
3539
3545
  let o = (n = t.symbols[e]) == null ? e : n, s = t.disabled.includes(e), c = t.highlight.includes(e), l = t.xl.includes(e), u = t.l.includes(e), d = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), f = [
3540
3546
  "sim-kb-key",
@@ -3545,9 +3551,9 @@ var Mt = (e, t) => {
3545
3551
  d ? "grow" : ""
3546
3552
  ].filter(Boolean).join(" "), p = Z((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = Z((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
3547
3553
  return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
3548
- }, Nt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Mt(t, e)).join("")}</div>`).join("")}</div>`;
3549
- function Pt() {
3550
- let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Nt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
3554
+ }, Pt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Nt(t, e)).join("")}</div>`).join("")}</div>`;
3555
+ function Ft() {
3556
+ let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Pt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
3551
3557
  return {
3552
3558
  id: "kbd",
3553
3559
  label: "Kbd",
@@ -3567,14 +3573,14 @@ function Pt() {
3567
3573
  `;
3568
3574
  },
3569
3575
  bind(e) {
3570
- t != null || (t = At({
3576
+ t != null || (t = jt({
3571
3577
  theme: e.state.selectedTheme,
3572
3578
  sendToGame: e.sendToGame
3573
3579
  })), t.setEnabled(e.state.keyboardDocked);
3574
3580
  let n = e.getElement("#sim-kb-dock");
3575
3581
  n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
3576
- e.state.keyboardDocked = n.checked, h(n.checked), t == null || t.setEnabled(n.checked), r(e);
3577
- })), Ft(e);
3582
+ e.state.keyboardDocked = n.checked, g(n.checked), t == null || t.setEnabled(n.checked), r(e);
3583
+ })), It(e);
3578
3584
  },
3579
3585
  onMessage(n, i, a) {
3580
3586
  var o;
@@ -3584,11 +3590,11 @@ function Pt() {
3584
3590
  /** Re-render the tab's own content (not the dock) and rebind its keys. */
3585
3591
  function r(e) {
3586
3592
  let t = e.getElement("#sim-kb-content");
3587
- t && (t.innerHTML = n(e.state.keyboardDocked), Ft(e));
3593
+ t && (t.innerHTML = n(e.state.keyboardDocked), It(e));
3588
3594
  }
3589
3595
  }
3590
3596
  /** Attach click handlers to all rendered keys */
3591
- function Ft(e) {
3597
+ function It(e) {
3592
3598
  var t;
3593
3599
  let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
3594
3600
  n == null || n.forEach((t) => {
@@ -3603,15 +3609,15 @@ function Ft(e) {
3603
3609
  * change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
3604
3610
  * production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
3605
3611
  */
3606
- function It() {
3612
+ function Lt() {
3607
3613
  let t = (e) => {
3608
3614
  let t = e.state.settingsComponents;
3609
- return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Lt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
3615
+ return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Rt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
3610
3616
  }, n = (e) => {
3611
3617
  let n = e.getElement("#sim-settings-content");
3612
3618
  n && (n.innerHTML = t(e), i(e));
3613
3619
  }, r = (e) => {
3614
- C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3620
+ w(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3615
3621
  }, i = (t) => {
3616
3622
  var i;
3617
3623
  let a = t.getElement("#sim-settings-content");
@@ -3627,7 +3633,7 @@ function It() {
3627
3633
  });
3628
3634
  }), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
3629
3635
  var e;
3630
- w(), t.state.gameSettings = zt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3636
+ T(), t.state.gameSettings = Bt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3631
3637
  }));
3632
3638
  };
3633
3639
  return {
@@ -3642,21 +3648,21 @@ function It() {
3642
3648
  onMessage(t, r, i) {
3643
3649
  if (t === "INITIALIZE_SETTINGS") {
3644
3650
  var a;
3645
- i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), C(i.state.gameSettings), n(i);
3651
+ i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), w(i.state.gameSettings), n(i);
3646
3652
  return;
3647
3653
  }
3648
- t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), C(i.state.gameSettings), n(i));
3654
+ t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), w(i.state.gameSettings), n(i));
3649
3655
  }
3650
3656
  };
3651
3657
  }
3652
3658
  /** Renders a single settings UI component as HTML, reading its current value from `settings` */
3653
- function Lt(e, t) {
3659
+ function Rt(e, t) {
3654
3660
  switch (e.type) {
3655
3661
  case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
3656
3662
  case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
3657
3663
  case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
3658
3664
  case "separator": return "<div class=\"simulator-divider\"></div>";
3659
- case "split": return `<div class="sim-settings-split">${e.content.map((e) => Lt(e, t)).join("")}</div>`;
3665
+ case "split": return `<div class="sim-settings-split">${e.content.map((e) => Rt(e, t)).join("")}</div>`;
3660
3666
  case "boolean": {
3661
3667
  var n;
3662
3668
  let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
@@ -3677,7 +3683,7 @@ function Lt(e, t) {
3677
3683
  }).join("");
3678
3684
  return `
3679
3685
  <div class="simulator-field">
3680
- ${Rt(e)}
3686
+ ${zt(e)}
3681
3687
  <select class="simulator-select" data-setting="${e.name}">${i}</select>
3682
3688
  </div>`;
3683
3689
  }
@@ -3693,7 +3699,7 @@ function Lt(e, t) {
3693
3699
  }).join("");
3694
3700
  return `
3695
3701
  <div class="simulator-field">
3696
- ${Rt(e)}
3702
+ ${zt(e)}
3697
3703
  ${a}
3698
3704
  </div>`;
3699
3705
  }
@@ -3702,7 +3708,7 @@ function Lt(e, t) {
3702
3708
  let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
3703
3709
  return `
3704
3710
  <div class="simulator-field">
3705
- ${Rt(e)}
3711
+ ${zt(e)}
3706
3712
  <select class="simulator-select" data-setting="${e.name}" data-setting-type="number">${r}</select>
3707
3713
  </div>`;
3708
3714
  }
@@ -3711,7 +3717,7 @@ function Lt(e, t) {
3711
3717
  let n = String((o = (s = t[e.name]) == null ? e.defaultValue : s) == null ? "" : o), r = e.textarea ? `<textarea class="simulator-textarea" data-setting="${e.name}">${Q(n)}</textarea>` : `<input class="simulator-input" type="text" data-setting="${e.name}" value="${Q(n)}" />`;
3712
3718
  return `
3713
3719
  <div class="simulator-field">
3714
- ${Rt(e)}
3720
+ ${zt(e)}
3715
3721
  ${r}
3716
3722
  </div>`;
3717
3723
  }
@@ -3719,14 +3725,14 @@ function Lt(e, t) {
3719
3725
  }
3720
3726
  }
3721
3727
  /** Title + optional subtitle markup for a value-producing component */
3722
- function Rt(e) {
3728
+ function zt(e) {
3723
3729
  let t = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
3724
3730
  return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
3725
3731
  }
3726
3732
  /** Collects name → defaultValue pairs from components, recursing into split groups */
3727
- function zt(e) {
3733
+ function Bt(e) {
3728
3734
  let t = {};
3729
- for (let n of e) n.type === "split" ? Object.assign(t, zt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3735
+ for (let n of e) n.type === "split" ? Object.assign(t, Bt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3730
3736
  return t;
3731
3737
  }
3732
3738
  function Q(e) {
@@ -3737,8 +3743,8 @@ function Q(e) {
3737
3743
  * parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
3738
3744
  * anything) and a log of the cues the game asked us for, with any haptic it wanted.
3739
3745
  */
3740
- function Bt() {
3741
- let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ht(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ht(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3746
+ function Vt() {
3747
+ let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ut(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ut(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3742
3748
  let r = t.getElement("#sound-events");
3743
3749
  r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
3744
3750
  };
@@ -3785,13 +3791,13 @@ function Bt() {
3785
3791
  n === "SENSORY_EVENT" && (e.unshift({
3786
3792
  id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
3787
3793
  haptic: i == null ? void 0 : i.haptic,
3788
- time: Vt()
3794
+ time: Ht()
3789
3795
  }), e.length > 100 && e.pop(), r(a));
3790
3796
  }
3791
3797
  };
3792
3798
  }
3793
3799
  /** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
3794
- function Vt() {
3800
+ function Ht() {
3795
3801
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
3796
3802
  hour12: !1,
3797
3803
  hour: "2-digit",
@@ -3800,16 +3806,16 @@ function Vt() {
3800
3806
  });
3801
3807
  }
3802
3808
  /** Minimal HTML-escape so event ids can't break the simulator markup. */
3803
- function Ht(e) {
3809
+ function Ut(e) {
3804
3810
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3805
3811
  }
3806
3812
  var $ = null;
3807
3813
  /** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
3808
- function Ut() {
3814
+ function Wt() {
3809
3815
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
3810
3816
  }
3811
3817
  /** Inert instance returned when the simulator declines to boot (the app is the host). */
3812
- var Wt = {
3818
+ var Gt = {
3813
3819
  updateFixtures: () => {},
3814
3820
  sendToGame: () => {},
3815
3821
  loadPuzzle: function() {
@@ -3858,28 +3864,28 @@ var Wt = {
3858
3864
  * Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
3859
3865
  * This will show dropdowns in the Ctrl tab to select category and puzzle.
3860
3866
  */
3861
- function Gt(n = {}) {
3867
+ function Kt(n = {}) {
3862
3868
  var r, i, a, o, s;
3863
- if (Ut()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Wt;
3869
+ if (Wt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Gt;
3864
3870
  if (console.log("[Simulator] createSimulator called with config:", {
3865
3871
  slug: n.slug,
3866
3872
  hasFixtures: !!n.fixtures
3867
3873
  }), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
3868
- let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? ie(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = pe(), f = Ae(), p = [
3874
+ let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? ie(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = me(), f = je(), p = [
3869
3875
  oe(),
3870
- se(),
3876
+ ce(),
3871
3877
  d,
3872
- me(),
3873
3878
  he(),
3874
- Ce((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
3879
+ ge(),
3880
+ we((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
3875
3881
  f,
3876
- Me(),
3877
- Pe(n.hostContextPresets),
3878
- nt(),
3879
- xt(),
3880
- Pt(),
3881
- It(),
3882
- Bt(),
3882
+ Ne(),
3883
+ Fe(n.hostContextPresets),
3884
+ rt(),
3885
+ St(),
3886
+ Ft(),
3887
+ Lt(),
3888
+ Vt(),
3883
3889
  ...(o = n.views) == null ? [] : o
3884
3890
  ], m = p.map((e) => e.id), h = ee(n, u, m), g = {
3885
3891
  pause: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"1\" width=\"3\" height=\"8\"/><rect x=\"6\" y=\"1\" width=\"3\" height=\"8\"/></svg>",
@@ -5363,7 +5369,7 @@ function Gt(n = {}) {
5363
5369
  }, j = (e, t) => {
5364
5370
  let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
5365
5371
  n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
5366
- }, P = (e, t) => {
5372
+ }, M = (e, t) => {
5367
5373
  t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
5368
5374
  }, F = (e) => {
5369
5375
  var t;
@@ -5398,10 +5404,32 @@ function Gt(n = {}) {
5398
5404
  return function() {
5399
5405
  return e.apply(this, arguments);
5400
5406
  };
5401
- }(), z = re((e) => {
5407
+ }(), z = N((e) => {
5402
5408
  d.addLogEntry(e, H);
5403
5409
  }), B = (e, t) => {
5404
- M(e, t, z);
5410
+ P(e, t, z);
5411
+ }, se = (e) => {
5412
+ var t;
5413
+ let n = (t = e.buckets) != null && t.length ? e.buckets : u, r = n.find((e) => {
5414
+ var t;
5415
+ return !(!(l == null || (t = l.get(e)) == null) && t.size);
5416
+ });
5417
+ if (r !== void 0 || !n.length) return {
5418
+ nonce: e.nonce,
5419
+ error: `No fixtures in "${r == null ? "" : r}" to stand in for a pool`,
5420
+ failed: !0
5421
+ };
5422
+ let i = n.flatMap((e) => [...l.get(e).keys()].map((t) => `fixtures/${e}/${t}`)), a = i.filter((t) => {
5423
+ var n;
5424
+ return !((n = e.exclude) != null && n.includes(t));
5425
+ }), o = a.length ? a : i, s = o[Math.floor(Math.random() * o.length)], [, c, ...d] = s.split("/");
5426
+ return {
5427
+ nonce: e.nonce,
5428
+ puzzle: {
5429
+ key: s,
5430
+ puzzle: l.get(c).get(d.join("/"))
5431
+ }
5432
+ };
5405
5433
  }, V = (e, t) => {
5406
5434
  let n = _.querySelector(`[data-badge="${e}"]`);
5407
5435
  n && (n.textContent = t && t > 0 ? String(t) : "");
@@ -5412,7 +5440,7 @@ function Gt(n = {}) {
5412
5440
  logMessage: z.log,
5413
5441
  loadPuzzle: R,
5414
5442
  updateStatus: j,
5415
- updateTimer: P,
5443
+ updateTimer: M,
5416
5444
  setCollapsed: I,
5417
5445
  switchTab: F,
5418
5446
  updateThumbnail: L,
@@ -5443,7 +5471,7 @@ function Gt(n = {}) {
5443
5471
  }), h.isCollapsed || F(h.activeTab);
5444
5472
  let U = new URLSearchParams(window.location.search);
5445
5473
  (U.has("code") || U.has("error")) && (I(!1), F("auth"));
5446
- let ce = (e) => {
5474
+ let le = (e) => {
5447
5475
  let t = {
5448
5476
  additionalTimeAddedSecs: 0,
5449
5477
  boardState: h.currentInputStr,
@@ -5479,8 +5507,9 @@ function Gt(n = {}) {
5479
5507
  type: "User",
5480
5508
  roles: ""
5481
5509
  },
5482
- game: Kt,
5510
+ game: qt,
5483
5511
  session: n,
5512
+ viewerStorage: h.userStorage,
5484
5513
  theme: h.selectedTheme,
5485
5514
  hostContext: h.hostContext,
5486
5515
  appRuntimeContract: "1.0"
@@ -5490,7 +5519,7 @@ function Gt(n = {}) {
5490
5519
  let r = n.session !== !1 || t === "1.0";
5491
5520
  r ? n.session === !1 && console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later") : console.log("Simulator: Sending READY_DATA without a session"), j(r ? "Loading puzzle..." : "Sending READY_DATA...", "waiting");
5492
5521
  try {
5493
- let n = e(e({}, ce(r ? yield R() : null)), {}, { appRuntimeContract: t });
5522
+ let n = e(e({}, le(r ? yield R() : null)), {}, { appRuntimeContract: t });
5494
5523
  j("Sending READY_DATA...", "waiting"), B("READY_DATA", n), j("Waiting for game to load...", "waiting");
5495
5524
  } catch (e) {
5496
5525
  j(`Error: ${e}`, "paused");
@@ -5499,7 +5528,7 @@ function Gt(n = {}) {
5499
5528
  return function(e) {
5500
5529
  return r.apply(this, arguments);
5501
5530
  };
5502
- }(), le = () => {
5531
+ }(), ue = () => {
5503
5532
  console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
5504
5533
  var t;
5505
5534
  return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, H);
@@ -5508,20 +5537,20 @@ function Gt(n = {}) {
5508
5537
  e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
5509
5538
  }, 100);
5510
5539
  };
5511
- return N((e, t) => {
5540
+ return re((e, t) => {
5512
5541
  var n, r;
5513
5542
  if (e === "READY") {
5514
5543
  console.log("Simulator: Received READY from game"), G(W.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
5515
5544
  return;
5516
5545
  }
5517
5546
  if (e === "READY_GAME_LOADED") {
5518
- le();
5547
+ ue();
5519
5548
  return;
5520
5549
  }
5521
5550
  if (e === "TIMER_TICK") {
5522
5551
  if (t != null && t.display) {
5523
5552
  let [e, n] = t.display;
5524
- P(e, n);
5553
+ M(e, n);
5525
5554
  }
5526
5555
  return;
5527
5556
  }
@@ -5535,7 +5564,18 @@ function Gt(n = {}) {
5535
5564
  return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, H);
5536
5565
  });
5537
5566
  let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
5538
- e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && L(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
5567
+ if (e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && L(), console.log("Simulator: Game state uploaded", t)), e === "COMPLETE_REPEATABLE_RUN" && console.log("Simulator: Repeatable run completed", t), e === "REQUEST_PUZZLE") {
5568
+ B("PUZZLE_DATA", se(t));
5569
+ return;
5570
+ }
5571
+ if (e === "UPDATE_GAME_USER_STATE" && typeof (t == null ? void 0 : t.state) == "string") {
5572
+ var a;
5573
+ h.userStorage = {
5574
+ state: t.state,
5575
+ stateVersion: (a = t.stateVersion) == null ? 1 : a
5576
+ }, console.log("Simulator: Game user storage updated", t);
5577
+ }
5578
+ e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
5539
5579
  }, z), console.log("Simulator initialized"), $ = {
5540
5580
  updateFixtures: (e) => {
5541
5581
  l = ie(e), u = Array.from(l.keys()).sort(), H.fixtures = l, H.fixtureCategories = u;
@@ -5555,7 +5595,7 @@ function Gt(n = {}) {
5555
5595
  }, $;
5556
5596
  }
5557
5597
  /** The game the simulator stands in for, with placeholder IDs since nothing is stored */
5558
- var Kt = {
5598
+ var qt = {
5559
5599
  id: "simulator-game",
5560
5600
  slug: "proto-game",
5561
5601
  stableSlug: "proto-game",
@@ -5571,6 +5611,6 @@ var Kt = {
5571
5611
  }
5572
5612
  }
5573
5613
  };
5574
- export { Bt as n, ae as r, Gt as t };
5614
+ export { Vt as n, ae as r, Kt as t };
5575
5615
 
5576
- //# sourceMappingURL=createSimulator-treFHkmV.js.map
5616
+ //# sourceMappingURL=createSimulator-CYo2KWWM.js.map