@puzzmo/sdk 1.0.60 → 1.0.61

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 (36) hide show
  1. package/dist/bootstrapPayload.d.ts +8 -0
  2. package/dist/bootstrapPayload.d.ts.map +1 -0
  3. package/dist/contracts.d.ts +1 -1
  4. package/dist/{createSimulator-Dory7qUL.js → createSimulator-CdInpCHG.js} +220 -202
  5. package/dist/{createSimulator-Dory7qUL.js.map → createSimulator-CdInpCHG.js.map} +1 -1
  6. package/dist/{createSimulator-kGIstLy9.cjs → createSimulator-PNeBoNux.cjs} +22 -22
  7. package/dist/{createSimulator-kGIstLy9.cjs.map → createSimulator-PNeBoNux.cjs.map} +1 -1
  8. package/dist/index.cjs +1 -1
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.global.js +1 -1
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.js +229 -179
  15. package/dist/index.js.map +1 -1
  16. package/dist/inputs/index.cjs +1 -1
  17. package/dist/inputs/index.js +1 -1
  18. package/dist/pico8/index.cjs +1 -1
  19. package/dist/pico8/index.js +2 -2
  20. package/dist/sdk.d.ts.map +1 -1
  21. package/dist/simulator/createSimulator.d.ts.map +1 -1
  22. package/dist/simulator/index.cjs +1 -1
  23. package/dist/simulator/index.js +1 -1
  24. package/dist/simulator/standalone.cjs +1 -1
  25. package/dist/simulator/standalone.js +1 -1
  26. package/dist/types.d.ts +99 -50
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/vite.cjs +3 -3
  29. package/dist/vite.js +26 -26
  30. package/package.json +1 -1
  31. /package/dist/{asyncToGenerator-Dn36a-ch.js → asyncToGenerator-BotOOyB7.js} +0 -0
  32. /package/dist/{asyncToGenerator-DANjdFmB.cjs → asyncToGenerator-DIL7svO7.cjs} +0 -0
  33. /package/dist/{objectSpread2-C8x7fbpH.js → objectSpread2-BQwrzeNG.js} +0 -0
  34. /package/dist/{objectSpread2-DLgRiGrq.cjs → objectSpread2-CCAs_T0X.cjs} +0 -0
  35. /package/dist/{objectWithoutProperties-BVU0RRck.js → objectWithoutProperties-Bjd1IAMi.js} +0 -0
  36. /package/dist/{objectWithoutProperties-ChRmjIUS.cjs → objectWithoutProperties-Ee8z5QMa.cjs} +0 -0
@@ -1,5 +1,5 @@
1
- import { t as e } from "./objectSpread2-C8x7fbpH.js";
2
- import { t } from "./asyncToGenerator-Dn36a-ch.js";
1
+ import { t as e } from "./objectSpread2-BQwrzeNG.js";
2
+ import { t } from "./asyncToGenerator-BotOOyB7.js";
3
3
  const n = [
4
4
  {
5
5
  name: "Puzzmo (light)",
@@ -420,7 +420,7 @@ function x() {
420
420
  "timeline"
421
421
  ].includes(e)) return e;
422
422
  }
423
- function S(e, t, n) {
423
+ function ee(e, t, n) {
424
424
  var i, a, s;
425
425
  let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"), m = o("input");
426
426
  return {
@@ -451,40 +451,40 @@ function S(e, t, n) {
451
451
  settingsComponents: null
452
452
  };
453
453
  }
454
- function C(e) {
454
+ function S(e) {
455
455
  localStorage.setItem(r.gameSettings, JSON.stringify(e));
456
456
  }
457
- function w() {
457
+ function C() {
458
458
  localStorage.removeItem(r.gameSettings);
459
459
  }
460
- function ee(e) {
460
+ function te(e) {
461
461
  localStorage.setItem(r.collapsed, String(e));
462
462
  }
463
- function te(e) {
463
+ function ne(e) {
464
464
  localStorage.setItem(r.tab, e);
465
465
  }
466
- function T(e) {
466
+ function w(e) {
467
467
  localStorage.setItem(r.theme, e);
468
468
  }
469
- function E(e) {
469
+ function T(e) {
470
470
  localStorage.setItem(r.fixtureCategory, e);
471
471
  }
472
- function D(e) {
472
+ function E(e) {
473
473
  localStorage.setItem(r.fixturePuzzle, e);
474
474
  }
475
- function O() {
475
+ function D() {
476
476
  localStorage.removeItem(r.fixturePuzzle);
477
477
  }
478
- function k(e) {
478
+ function O(e) {
479
479
  e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
480
480
  }
481
- function A(e) {
481
+ function k(e) {
482
482
  localStorage.setItem(r.previewKind, e);
483
483
  }
484
- function j(e) {
484
+ function A(e) {
485
485
  e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
486
486
  }
487
- function ne(e) {
487
+ function re(e) {
488
488
  let t = [];
489
489
  return {
490
490
  log(n, r, i) {
@@ -509,13 +509,13 @@ function ne(e) {
509
509
  }
510
510
  };
511
511
  }
512
- function re(e, t, n) {
512
+ function ie(e, t, n) {
513
513
  console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
514
514
  type: e,
515
515
  data: t
516
516
  }, "*");
517
517
  }
518
- function ie(e, t) {
518
+ function ae(e, t) {
519
519
  let n = (n) => {
520
520
  var r, i, a;
521
521
  if (!(!(n == null || (r = n.data) == null) && r.type)) return;
@@ -525,7 +525,7 @@ function ie(e, t) {
525
525
  return window.addEventListener("message", n), () => window.removeEventListener("message", n);
526
526
  }
527
527
  /** Parse fixture imports into a structured format: { category: { filename: data } } */
528
- function ae(e) {
528
+ function oe(e) {
529
529
  let t = /* @__PURE__ */ new Map();
530
530
  console.log("Simulator: Parsing fixtures", Object.keys(e));
531
531
  for (let [o, s] of Object.entries(e)) {
@@ -544,7 +544,7 @@ function ae(e) {
544
544
  }), t;
545
545
  }
546
546
  /** Render fixture selector HTML */
547
- function M(e, t) {
547
+ function j(e, t) {
548
548
  return e.length === 0 ? "" : `
549
549
  <div class="simulator-fixtures">
550
550
  <div class="simulator-field">
@@ -561,7 +561,7 @@ function M(e, t) {
561
561
  `;
562
562
  }
563
563
  /** Update puzzle select options based on selected category */
564
- function N(e, t, n, r) {
564
+ function M(e, t, n, r) {
565
565
  let i = t.get(n);
566
566
  if (!i) return null;
567
567
  let a = Array.from(i.keys()), o = r;
@@ -572,7 +572,7 @@ function N(e, t, n, r) {
572
572
  return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
573
573
  }
574
574
  /** Get puzzle data from fixtures */
575
- function P(e, t, n) {
575
+ function N(e, t, n) {
576
576
  var r, i;
577
577
  return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
578
578
  }
@@ -584,8 +584,8 @@ function P(e, t, n) {
584
584
  * `puzzmo games validate` greps build output for it — keep it in sync with the copy in
585
585
  * packages/cli/src/util/lintDist.ts.
586
586
  */
587
- const oe = "puzzmo-simulator-dev-only-do-not-ship";
588
- function se() {
587
+ const se = "puzzmo-simulator-dev-only-do-not-ship";
588
+ function ce() {
589
589
  return {
590
590
  id: "ctrl",
591
591
  label: "Ctrl",
@@ -600,19 +600,19 @@ function se() {
600
600
  selectedCategory: e.state.selectedCategory,
601
601
  selectedPuzzle: e.state.selectedPuzzle
602
602
  }), e.fixtures && e.fixtureCategories.length > 0 && i) {
603
- i.innerHTML = M(e.fixtureCategories, e.state.selectedCategory);
603
+ i.innerHTML = j(e.fixtureCategories, e.state.selectedCategory);
604
604
  let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
605
605
  if (t && n && e.state.selectedCategory) {
606
- e.state.selectedPuzzle = N(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
607
- let r = P(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
606
+ e.state.selectedPuzzle = M(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
607
+ let r = N(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
608
608
  console.log("Simulator: Loading fixture puzzle", {
609
609
  category: e.state.selectedCategory,
610
610
  puzzle: e.state.selectedPuzzle,
611
611
  hasPuzzleData: !!r
612
- }), 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", () => {
613
- console.log("Simulator: Category changed, reloading...", t.value), l(), E(t.value), O(), window.location.reload();
612
+ }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && T(e.state.selectedCategory), e.state.selectedPuzzle && E(e.state.selectedPuzzle)), t.addEventListener("change", () => {
613
+ console.log("Simulator: Category changed, reloading...", t.value), l(), T(t.value), D(), window.location.reload();
614
614
  }), n.addEventListener("change", () => {
615
- console.log("Simulator: Puzzle changed, reloading...", n.value), l(), D(n.value), window.location.reload();
615
+ console.log("Simulator: Puzzle changed, reloading...", n.value), l(), E(n.value), window.location.reload();
616
616
  });
617
617
  }
618
618
  }
@@ -638,10 +638,10 @@ function se() {
638
638
  * Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
639
639
  * must stay self-contained.
640
640
  */
641
- function F(e) {
641
+ function P(e) {
642
642
  var t;
643
643
  if (typeof e != "string") return e;
644
- let n = (t = I(e)) == null ? {
644
+ let n = (t = F(e)) == null ? {
645
645
  width: 800,
646
646
  height: 800
647
647
  } : t;
@@ -652,7 +652,7 @@ function F(e) {
652
652
  };
653
653
  }
654
654
  /** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
655
- function I(e) {
655
+ function F(e) {
656
656
  var t, n, r, i;
657
657
  let a = e.indexOf("<svg");
658
658
  if (a === -1) return;
@@ -670,9 +670,9 @@ function I(e) {
670
670
  height: u
671
671
  };
672
672
  }
673
- var L = "simulator-saved-states";
673
+ var I = "simulator-saved-states";
674
674
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
675
- function R() {
675
+ function L() {
676
676
  let e = globalThis;
677
677
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
678
678
  name: t,
@@ -681,8 +681,8 @@ function R() {
681
681
  return null;
682
682
  }
683
683
  /** Generate a small thumbnail SVG for a given input string */
684
- function z(e, t) {
685
- let n = R();
684
+ function R(e, t) {
685
+ let n = L();
686
686
  if (!n) return "";
687
687
  try {
688
688
  var r;
@@ -692,19 +692,19 @@ function z(e, t) {
692
692
  strict: !0,
693
693
  renderHost: "game"
694
694
  };
695
- return F(n.fn(i, t, a)).svg;
695
+ return P(n.fn(i, t, a)).svg;
696
696
  } catch (e) {
697
697
  return "";
698
698
  }
699
699
  }
700
- var B = [];
701
- function V(e, t = 8) {
700
+ var z = [];
701
+ function B(e, t = 8) {
702
702
  let n = 14 * t + 8 + 4;
703
703
  e.style.height = "auto";
704
704
  let r = Math.min(Math.max(e.scrollHeight, 40), n);
705
705
  e.style.height = `${r}px`;
706
706
  }
707
- function ce() {
707
+ function le() {
708
708
  let e = "", t = "";
709
709
  return {
710
710
  id: "data",
@@ -727,13 +727,13 @@ function ce() {
727
727
  });
728
728
  let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), l = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
729
729
  setTimeout(() => {
730
- i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, V(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, V(a)), fe(n);
730
+ i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, B(a)), fe(n);
731
731
  }, 0), i == null || i.addEventListener("input", () => {
732
- V(i);
732
+ B(i);
733
733
  let t = i.value !== e;
734
734
  l && (l.disabled = !t);
735
735
  }), a == null || a.addEventListener("input", () => {
736
- V(a);
736
+ B(a);
737
737
  let e = a.value !== t;
738
738
  d && (d.disabled = !e);
739
739
  }), o == null || o.addEventListener("click", () => {
@@ -741,7 +741,7 @@ function ce() {
741
741
  c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
742
742
  return;
743
743
  }
744
- i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, V(i), l && (l.disabled = !0));
744
+ i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i), l && (l.disabled = !0));
745
745
  }), l == null || l.addEventListener("click", () => {
746
746
  if (i) {
747
747
  if (!s("puzzle", i.value)) {
@@ -755,7 +755,7 @@ function ce() {
755
755
  c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
756
756
  return;
757
757
  }
758
- a && (a.value = t, V(a), d && (d.disabled = !0));
758
+ a && (a.value = t, B(a), d && (d.disabled = !0));
759
759
  }), d == null || d.addEventListener("click", () => {
760
760
  if (a) {
761
761
  if (!s("input", a.value)) {
@@ -767,18 +767,18 @@ function ce() {
767
767
  });
768
768
  let f = n.getElement("#simulator-history-clear");
769
769
  f == null || f.addEventListener("click", () => {
770
- B = [], H(n);
770
+ z = [], H(n);
771
771
  });
772
772
  let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
773
773
  m == null || m.addEventListener("click", () => {
774
774
  if (!p || !p.value.trim()) return;
775
- let e = le(), t = {
775
+ let e = V(), t = {
776
776
  name: p.value.trim(),
777
777
  puzzleStr: n.state.originalPuzzle,
778
778
  inputStr: n.state.currentInputStr,
779
779
  timestamp: Date.now()
780
780
  };
781
- e.push(t), localStorage.setItem(L, JSON.stringify(e)), p.value = "", U(n);
781
+ e.push(t), localStorage.setItem(I, JSON.stringify(e)), p.value = "", U(n);
782
782
  }), U(n);
783
783
  },
784
784
  onActivate(n) {
@@ -788,22 +788,22 @@ function ce() {
788
788
  var i, a;
789
789
  let o = r.getElement("#simulator-input"), s = r.getElement("#simulator-input-apply"), c = (i = n == null || (a = n.input) == null ? void 0 : a.boardState) == null ? n == null ? void 0 : n.boardState : i;
790
790
  if (e === "UPLOAD_NEW_GAME_STATE" && c) {
791
- if (r.state.currentInputStr = c, B.length === 0 || B[B.length - 1].value !== c) {
792
- B.push({
791
+ if (r.state.currentInputStr = c, z.length === 0 || z[z.length - 1].value !== c) {
792
+ z.push({
793
793
  value: c,
794
794
  timestamp: Date.now()
795
- }), B.length > 100 && (B = B.slice(-100));
795
+ }), z.length > 100 && (z = z.slice(-100));
796
796
  let e = r.getElement("#data-subtab-history");
797
797
  e != null && e.classList.contains("active") && H(r);
798
798
  }
799
- o && document.activeElement !== o && (o.value !== c && (o.value = c, V(o)), t = c, s && (s.disabled = !0));
799
+ o && document.activeElement !== o && (o.value !== c && (o.value = c, B(o)), t = c, s && (s.disabled = !0));
800
800
  }
801
801
  }
802
802
  };
803
803
  }
804
- function le() {
804
+ function V() {
805
805
  try {
806
- let e = localStorage.getItem(L);
806
+ let e = localStorage.getItem(I);
807
807
  return e ? JSON.parse(e) : [];
808
808
  } catch (e) {
809
809
  return [];
@@ -812,15 +812,15 @@ function le() {
812
812
  function H(e) {
813
813
  let t = e.getElement("#simulator-history-list");
814
814
  if (t) {
815
- if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), B.length === 0) {
815
+ if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), z.length === 0) {
816
816
  t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
817
817
  return;
818
818
  }
819
- t.innerHTML = [...B].reverse().map((t, n) => {
820
- let r = B.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
819
+ t.innerHTML = [...z].reverse().map((t, n) => {
820
+ let r = z.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
821
821
  return `
822
822
  <div class="history-item" data-history-idx="${r}">
823
- <div class="history-item-thumb">${z(e, t.value)}</div>
823
+ <div class="history-item-thumb">${R(e, t.value)}</div>
824
824
  <div class="history-item-content">
825
825
  <div class="history-item-header">
826
826
  <span class="history-item-num">#${r + 1}</span>
@@ -833,12 +833,12 @@ function H(e) {
833
833
  `;
834
834
  }).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
835
835
  t.addEventListener("click", (t) => {
836
- let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = B[n];
836
+ let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = z[n];
837
837
  if (r) {
838
838
  let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
839
839
  t == null || t.click();
840
840
  let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
841
- n && (n.value = r.value, V(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
841
+ n && (n.value = r.value, B(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
842
842
  }
843
843
  });
844
844
  });
@@ -847,7 +847,7 @@ function H(e) {
847
847
  function U(e) {
848
848
  let t = e.getElement("#simulator-saves-list");
849
849
  if (!t) return;
850
- let n = le();
850
+ let n = V();
851
851
  if (n.length === 0) {
852
852
  t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
853
853
  return;
@@ -880,7 +880,7 @@ function U(e) {
880
880
  }), t.querySelectorAll(".save-delete-btn").forEach((t) => {
881
881
  t.addEventListener("click", (t) => {
882
882
  let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
883
- localStorage.setItem(L, JSON.stringify(i)), U(e);
883
+ localStorage.setItem(I, JSON.stringify(i)), U(e);
884
884
  });
885
885
  });
886
886
  }
@@ -889,7 +889,7 @@ function ue(e) {
889
889
  }
890
890
  function de(e) {
891
891
  let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
892
- t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, V(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, V(n), i && (i.disabled = !0)), fe(e);
892
+ t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, B(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, B(n), i && (i.disabled = !0)), fe(e);
893
893
  }
894
894
  function fe(e) {
895
895
  let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
@@ -1071,12 +1071,12 @@ function Ce() {
1071
1071
  o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
1072
1072
  t.addEventListener("click", () => {
1073
1073
  let n = t.dataset.previewKind;
1074
- !n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
1074
+ !n || n === e.state.previewKind || (e.state.previewKind = n, k(n), c(), s(), e.updateThumbnail());
1075
1075
  });
1076
- }), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
1077
- e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
1078
- })), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
1079
- e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
1076
+ }), n && (e.state.renderHost || (e.state.renderHost = "game", O(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
1077
+ e.state.renderHost = n.value, O(e.state.renderHost), s(), e.updateThumbnail();
1078
+ })), r && (e.state.renderContext || (e.state.renderContext = "preview", A(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
1079
+ e.state.renderContext = r.value, A(e.state.renderContext), e.updateThumbnail();
1080
1080
  })), c(), s();
1081
1081
  },
1082
1082
  onActivate(e) {
@@ -1118,7 +1118,7 @@ function Ce() {
1118
1118
  strict: !0,
1119
1119
  renderHost: e.state.renderHost,
1120
1120
  renderContext: e.state.renderContext
1121
- }, { svg: i } = F(s.fn(n, e.state.currentInputStr, r));
1121
+ }, { svg: i } = P(s.fn(n, e.state.currentInputStr, r));
1122
1122
  t && (t.innerHTML = i);
1123
1123
  } catch (e) {
1124
1124
  console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
@@ -1154,7 +1154,7 @@ function Te() {
1154
1154
  <div class="simulator-theme-name">${n.name}</div>
1155
1155
  <div class="simulator-theme-type">${n.type}</div>
1156
1156
  `, r.addEventListener("click", () => {
1157
- console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
1157
+ console.log("Simulator: Theme changed, reloading...", n.name), w(n.name), window.location.reload();
1158
1158
  }), t.appendChild(r);
1159
1159
  });
1160
1160
  }
@@ -1795,20 +1795,20 @@ function xt(e) {
1795
1795
  t && (t.style.opacity = e ? "0.5" : "0");
1796
1796
  }, x = () => {
1797
1797
  m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b(!1);
1798
- }, S = (e) => {
1798
+ }, ee = (e) => {
1799
1799
  var t, n;
1800
1800
  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;
1801
+ }, S = (e) => {
1802
+ y = ee(e), a == null || a.setPointerCapture(e.pointerId);
1801
1803
  }, C = (e) => {
1802
- y = S(e), a == null || a.setPointerCapture(e.pointerId);
1803
- }, w = (e) => {
1804
1804
  !(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, _ >= ht && Date.now() - v >= _t && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * gt, h[1] + (e.clientY - g.clientY) * gt]), g = {
1805
1805
  clientX: e.clientX,
1806
1806
  clientY: e.clientY,
1807
1807
  pointerId: e.pointerId
1808
1808
  }, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
1809
- }, ee = (e) => {
1810
- m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
1811
- }, te = () => {
1809
+ }, te = (e) => {
1810
+ m ? n("KEYBOARD_CURSOR_END", {}) : y && ee(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
1811
+ }, ne = () => {
1812
1812
  a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
1813
1813
  "position:fixed",
1814
1814
  "left:0",
@@ -1826,27 +1826,27 @@ function xt(e) {
1826
1826
  "-webkit-user-select:none",
1827
1827
  `background:${t.a_bg}`,
1828
1828
  `border-top:1px solid ${Y(t.fg, .2)}`
1829
- ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", w), a.addEventListener("pointerup", ee), 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());
1830
- }, T = () => {
1829
+ ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", S), a.addEventListener("pointermove", C), a.addEventListener("pointerup", te), 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());
1830
+ }, w = () => {
1831
1831
  a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
1832
- }, E = () => {
1832
+ }, T = () => {
1833
1833
  let e = i;
1834
1834
  !a || !e || a.querySelectorAll(".sim-docked-kbd-key").forEach((t) => {
1835
1835
  let n = t.getAttribute("data-key"), r = t.firstElementChild, i = r == null ? void 0 : r.firstElementChild;
1836
1836
  !n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
1837
1837
  });
1838
- }, D = () => {
1839
- if (!r || !i) return T();
1840
- if (!a) return te();
1838
+ }, E = () => {
1839
+ if (!r || !i) return w();
1840
+ if (!a) return ne();
1841
1841
  a.innerHTML = p(i), b(m);
1842
1842
  };
1843
1843
  return {
1844
1844
  setEnabled(e) {
1845
- r = e, D();
1845
+ r = e, E();
1846
1846
  },
1847
1847
  setConfig(e) {
1848
1848
  let t = a && e && i && St(e) === St(i);
1849
- i = e, t ? E() : D();
1849
+ i = e, t ? T() : E();
1850
1850
  }
1851
1851
  };
1852
1852
  }
@@ -1942,7 +1942,7 @@ function Dt() {
1942
1942
  let n = e.getElement("#sim-settings-content");
1943
1943
  n && (n.innerHTML = t(e), i(e));
1944
1944
  }, r = (e) => {
1945
- C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
1945
+ S(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
1946
1946
  }, i = (t) => {
1947
1947
  var i;
1948
1948
  let a = t.getElement("#sim-settings-content");
@@ -1958,7 +1958,7 @@ function Dt() {
1958
1958
  });
1959
1959
  }), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
1960
1960
  var e;
1961
- w(), t.state.gameSettings = kt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
1961
+ C(), t.state.gameSettings = kt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
1962
1962
  }));
1963
1963
  };
1964
1964
  return {
@@ -1973,10 +1973,10 @@ function Dt() {
1973
1973
  onMessage(t, r, i) {
1974
1974
  if (t === "INITIALIZE_SETTINGS") {
1975
1975
  var a;
1976
- 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);
1976
+ 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), S(i.state.gameSettings), n(i);
1977
1977
  return;
1978
1978
  }
1979
- 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));
1979
+ t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), S(i.state.gameSettings), n(i));
1980
1980
  }
1981
1981
  };
1982
1982
  }
@@ -2189,37 +2189,37 @@ var Pt = {
2189
2189
  * Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
2190
2190
  * This will show dropdowns in the Ctrl tab to select category and puzzle.
2191
2191
  */
2192
- function Ft(e = {}) {
2193
- var n, r, i;
2192
+ function Ft(n = {}) {
2193
+ var r, i, a;
2194
2194
  if (Nt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Pt;
2195
2195
  if (console.log("[Simulator] createSimulator called with config:", {
2196
- slug: e.slug,
2197
- hasFixtures: !!e.fixtures
2198
- }), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
2199
- let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? ae(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = me(), l = Ce(), u = [
2200
- se(),
2196
+ slug: n.slug,
2197
+ hasFixtures: !!n.fixtures
2198
+ }), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
2199
+ let o = (r = n.autoStart) == null ? !0 : r, s = n.fixtures ? oe(n.fixtures) : null, c = s ? Array.from(s.keys()).sort() : [], l = me(), u = Ce(), d = [
2201
2200
  ce(),
2202
- c,
2201
+ le(),
2202
+ l,
2203
2203
  he(),
2204
2204
  ge(),
2205
- l,
2205
+ u,
2206
2206
  Te(),
2207
- De(e.hostContextPresets),
2207
+ De(n.hostContextPresets),
2208
2208
  qe(),
2209
2209
  ft(),
2210
2210
  Tt(),
2211
2211
  Dt(),
2212
2212
  At(),
2213
- ...(r = e.views) == null ? [] : r
2214
- ], d = u.map((e) => e.id), f = S(e, s, d), p = {
2213
+ ...(i = n.views) == null ? [] : i
2214
+ ], f = d.map((e) => e.id), p = ee(n, c, f), m = {
2215
2215
  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>",
2216
2216
  play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
2217
2217
  retry: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z\"/></svg>",
2218
2218
  cog: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z\"/></svg>",
2219
2219
  minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
2220
2220
  expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
2221
- }, m = document.createElement("div");
2222
- m.id = "simulator", m.dataset.puzzmoBuild = oe, m.innerHTML = `
2221
+ }, h = document.createElement("div");
2222
+ h.id = "simulator", h.dataset.puzzmoBuild = se, h.innerHTML = `
2223
2223
  <style>
2224
2224
  :root {
2225
2225
  --sim-bg: #1a1a2e;
@@ -3537,15 +3537,15 @@ function Ft(e = {}) {
3537
3537
  border-top: 2px solid var(--sim-border);
3538
3538
  }
3539
3539
  </style>
3540
- <div id="simulator-panel" class="${f.isCollapsed ? "collapsed" : ""}">
3540
+ <div id="simulator-panel" class="${p.isCollapsed ? "collapsed" : ""}">
3541
3541
  <div id="simulator-header">
3542
3542
  <span id="simulator-title">PUZZMO SIMULATOR</span>
3543
3543
  <span class="header-sep">|</span>
3544
3544
  <div id="simulator-timer">--:--</div>
3545
3545
  <span class="header-sep">|</span>
3546
3546
  <div id="simulator-header-controls">
3547
- <button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${p.pause}</button>
3548
- <button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${p.retry}</button>
3547
+ <button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${m.pause}</button>
3548
+ <button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${m.retry}</button>
3549
3549
  </div>
3550
3550
  <span class="header-sep">|</span>
3551
3551
  <div id="simulator-header-status">
@@ -3553,68 +3553,68 @@ function Ft(e = {}) {
3553
3553
  <span id="simulator-header-status-text">Waiting...</span>
3554
3554
  </div>
3555
3555
  <span class="header-spacer"></span>
3556
- <button id="simulator-header-settings" class="header-icon-btn" title="Settings">${p.cog}</button>
3557
- <button id="simulator-toggle" class="header-icon-btn" title="Minimize">${p.minimize}</button>
3556
+ <button id="simulator-header-settings" class="header-icon-btn" title="Settings">${m.cog}</button>
3557
+ <button id="simulator-toggle" class="header-icon-btn" title="Minimize">${m.minimize}</button>
3558
3558
  </div>
3559
3559
  <div id="simulator-body">
3560
3560
  <div id="simulator-tabs">
3561
- ${u.filter((e) => e.id !== "auth").map((e) => `<button class="simulator-tab" data-tab="${e.id}">${e.label}<span class="simulator-tab-badge" data-badge="${e.id}"></span></button>`).join("")}
3561
+ ${d.filter((e) => e.id !== "auth").map((e) => `<button class="simulator-tab" data-tab="${e.id}">${e.label}<span class="simulator-tab-badge" data-badge="${e.id}"></span></button>`).join("")}
3562
3562
  </div>
3563
3563
  <div id="simulator-content" class="hidden">
3564
- ${u.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
3564
+ ${d.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
3565
3565
  </div>
3566
3566
  </div>
3567
3567
  </div>
3568
- `, document.body.appendChild(m);
3569
- let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"), C = m.querySelector("#simulator-toggle"), w = m.querySelector("#simulator-timer"), T = m.querySelector("#simulator-tabs"), E = m.querySelector("#simulator-content"), D = (e) => m.querySelector(e), O = (e) => {
3570
- y.innerHTML = e ? p.play : p.pause, y.title = e ? "Resume" : "Pause";
3568
+ `, document.body.appendChild(h);
3569
+ let g = h.querySelector("#simulator-panel"), _ = h.querySelector("#simulator-header"), v = h.querySelector("#simulator-header-indicator"), y = h.querySelector("#simulator-header-status-text"), b = h.querySelector("#simulator-header-pause"), x = h.querySelector("#simulator-header-retry"), S = h.querySelector("#simulator-header-settings"), C = h.querySelector("#simulator-toggle"), w = h.querySelector("#simulator-timer"), T = h.querySelector("#simulator-tabs"), E = h.querySelector("#simulator-content"), D = (e) => h.querySelector(e), O = (e) => {
3570
+ b.innerHTML = e ? m.play : m.pause, b.title = e ? "Resume" : "Pause";
3571
3571
  }, k = (e, t) => {
3572
3572
  let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
3573
- n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
3573
+ n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), v.className = t, v.textContent = i, y.textContent = e;
3574
3574
  }, A = (e, t) => {
3575
3575
  t && t !== "0" ? w.innerHTML = `${e}<span class="penalty">+${t}</span>` : w.textContent = e;
3576
3576
  }, j = (e) => {
3577
3577
  var t;
3578
- f.activeTab = e, E.classList.remove("hidden"), te(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
3578
+ p.activeTab = e, E.classList.remove("hidden"), ne(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
3579
3579
  t.classList.toggle("active", t.getAttribute("data-tab") === e);
3580
- }), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
3580
+ }), h.querySelectorAll(".simulator-tab-content").forEach((t) => {
3581
3581
  t.classList.toggle("active", t.id === `simulator-tab-${e}`);
3582
- }), x.classList.toggle("active", e === "auth");
3583
- let n = u.find((t) => t.id === e);
3582
+ }), S.classList.toggle("active", e === "auth");
3583
+ let n = d.find((t) => t.id === e);
3584
3584
  n == null || (t = n.onActivate) == null || t.call(n, R);
3585
3585
  }, M = (e) => {
3586
- f.isCollapsed = e, h.classList.toggle("collapsed", e), ee(e), e ? (E.classList.add("hidden"), T.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : j(f.activeTab);
3586
+ p.isCollapsed = e, g.classList.toggle("collapsed", e), te(e), e ? (E.classList.add("hidden"), T.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : j(p.activeTab);
3587
3587
  }, N = () => {
3588
- l.updatePreview(R);
3588
+ u.updatePreview(R);
3589
3589
  }, P = function() {
3590
3590
  var e = t(function* () {
3591
3591
  var e, t;
3592
- if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
3593
- if (f.puzzleData) return f.puzzleData;
3594
- if (!o || o.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
3595
- let n = (e = f.selectedCategory) == null ? s[0] : e, r = n ? o.get(n) : void 0;
3592
+ if (p.appliedPuzzleOverride !== null) return p.appliedPuzzleOverride;
3593
+ if (p.puzzleData) return p.puzzleData;
3594
+ if (!s || s.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
3595
+ let n = (e = p.selectedCategory) == null ? c[0] : e, r = n ? s.get(n) : void 0;
3596
3596
  if (!r || r.size === 0) throw Error(`No puzzles found in fixture category "${n}"`);
3597
- let i = (t = f.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
3597
+ let i = (t = p.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
3598
3598
  if (!a) throw Error(`Puzzle "${i}" not found in category "${n}"`);
3599
- f.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
3599
+ p.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
3600
3600
  category: n,
3601
3601
  puzzle: i
3602
- }), f.originalPuzzle = a;
3603
- let c = D("#simulator-puzzle");
3604
- return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" && N(), f.puzzleData;
3602
+ }), p.originalPuzzle = a;
3603
+ let o = D("#simulator-puzzle");
3604
+ return o && (o.value = p.originalPuzzle), p.activeTab === "thumb" && N(), p.puzzleData;
3605
3605
  });
3606
3606
  return function() {
3607
3607
  return e.apply(this, arguments);
3608
3608
  };
3609
- }(), F = ne((e) => {
3610
- c.addLogEntry(e, R);
3609
+ }(), F = re((e) => {
3610
+ l.addLogEntry(e, R);
3611
3611
  }), I = (e, t) => {
3612
- re(e, t, F);
3612
+ ie(e, t, F);
3613
3613
  }, L = (e, t) => {
3614
- let n = m.querySelector(`[data-badge="${e}"]`);
3614
+ let n = h.querySelector(`[data-badge="${e}"]`);
3615
3615
  n && (n.textContent = t && t > 0 ? String(t) : "");
3616
3616
  }, R = {
3617
- state: f,
3617
+ state: p,
3618
3618
  getElement: D,
3619
3619
  sendToGame: I,
3620
3620
  logMessage: F.log,
@@ -3625,49 +3625,36 @@ function Ft(e = {}) {
3625
3625
  switchTab: j,
3626
3626
  updateThumbnail: N,
3627
3627
  updateBadge: L,
3628
- fixtures: o,
3629
- fixtureCategories: s,
3630
- gameSlug: (i = e.slug) == null ? null : i
3628
+ fixtures: s,
3629
+ fixtureCategories: c,
3630
+ gameSlug: (a = n.slug) == null ? null : a
3631
3631
  };
3632
- console.log("[Simulator] Context created with gameSlug:", R.gameSlug), u.forEach((e) => e.bind(R)), T.querySelectorAll(".simulator-tab").forEach((e) => {
3632
+ console.log("[Simulator] Context created with gameSlug:", R.gameSlug), d.forEach((e) => e.bind(R)), T.querySelectorAll(".simulator-tab").forEach((e) => {
3633
3633
  e.addEventListener("click", () => {
3634
3634
  let t = e.getAttribute("data-tab");
3635
3635
  j(t), L(t, 0);
3636
3636
  });
3637
3637
  }), C.addEventListener("click", (e) => {
3638
3638
  e.stopPropagation(), M(!0);
3639
- }), y.addEventListener("click", (e) => {
3640
- e.stopPropagation(), f.isPaused ? (I("RESUME_GAME", {}), f.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), f.isPaused = !0, O(!0), k("Paused", "paused"));
3641
- let t = D("#simulator-pause");
3642
- t && (t.textContent = f.isPaused ? "Resume" : "Pause");
3643
3639
  }), b.addEventListener("click", (e) => {
3644
- e.stopPropagation(), I("RETRY_PUZZLE", {}), f.hasStarted = !1, f.isPaused = !1, O(!1), y.disabled = !0, k("Ready to retry", "ready");
3640
+ e.stopPropagation(), p.isPaused ? (I("RESUME_GAME", {}), p.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), p.isPaused = !0, O(!0), k("Paused", "paused"));
3641
+ let t = D("#simulator-pause");
3642
+ t && (t.textContent = p.isPaused ? "Resume" : "Pause");
3643
+ }), x.addEventListener("click", (e) => {
3644
+ e.stopPropagation(), I("RETRY_PUZZLE", {}), p.hasStarted = !1, p.isPaused = !1, O(!1), b.disabled = !0, k("Ready to retry", "ready");
3645
3645
  let t = D("#simulator-pause"), n = D("#simulator-start");
3646
3646
  t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
3647
- }), x.addEventListener("click", (e) => {
3648
- e.stopPropagation(), f.isCollapsed && M(!1), j("auth");
3649
- }), g.addEventListener("click", (e) => {
3650
- f.isCollapsed && e.target !== C && M(!1);
3651
- }), f.isCollapsed || j(f.activeTab);
3647
+ }), S.addEventListener("click", (e) => {
3648
+ e.stopPropagation(), p.isCollapsed && M(!1), j("auth");
3649
+ }), _.addEventListener("click", (e) => {
3650
+ p.isCollapsed && e.target !== C && M(!1);
3651
+ }), p.isCollapsed || j(p.activeTab);
3652
3652
  let z = new URLSearchParams(window.location.search);
3653
3653
  (z.has("code") || z.has("error")) && (M(!1), j("auth"));
3654
- let B = (e) => ({
3655
- userState: {
3656
- gameSettings: { "proto-game": f.gameSettings },
3657
- id: "simulator-user",
3658
- ownerID: "simulator-owner"
3659
- },
3660
- currentUser: {
3661
- id: "simulator-user",
3662
- name: "Simulator",
3663
- username: "simulator",
3664
- usernameID: "0000",
3665
- type: "User",
3666
- roles: ""
3667
- },
3668
- startOrFindGameplay: { gamePlayed: {
3654
+ let B = (e) => {
3655
+ let t = {
3669
3656
  additionalTimeAddedSecs: 0,
3670
- boardState: f.currentInputStr,
3657
+ boardState: p.currentInputStr,
3671
3658
  combinedTimeSecs: 0,
3672
3659
  completed: !1,
3673
3660
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3676,52 +3663,66 @@ function Ft(e = {}) {
3676
3663
  ownerID: "simulator-owner",
3677
3664
  pointsAwarded: 0,
3678
3665
  slug: "simulator-game",
3679
- viewerOwnsPuzzle: !0,
3680
- puzzle: {
3681
- id: "simulator-puzzle",
3682
- name: "Proto Jig Puzzle",
3683
- puzzle: e,
3684
- game: {
3685
- displayName: "Proto Game",
3686
- jsPath: "",
3687
- slug: "proto-game"
3688
- },
3689
- mostRecentDaily: null
3690
- }
3691
- } },
3692
- theme: f.selectedTheme,
3693
- hostContext: f.hostContext,
3694
- appRuntimeContract: "1.0"
3695
- }), V = function() {
3696
- var e = t(function* () {
3666
+ viewerOwnsPuzzle: !0
3667
+ }, n = {
3668
+ id: "simulator-puzzle",
3669
+ name: "Proto Jig Puzzle",
3670
+ puzzle: e,
3671
+ mostRecentDaily: null
3672
+ };
3673
+ return {
3674
+ userState: {
3675
+ gameSettings: { "proto-game": p.gameSettings },
3676
+ id: "simulator-user",
3677
+ ownerID: "simulator-owner"
3678
+ },
3679
+ currentUser: {
3680
+ id: "simulator-user",
3681
+ name: "Simulator",
3682
+ username: "simulator",
3683
+ usernameID: "0000",
3684
+ type: "User",
3685
+ roles: ""
3686
+ },
3687
+ game: It,
3688
+ session: {
3689
+ gameplay: t,
3690
+ puzzle: n
3691
+ },
3692
+ theme: p.selectedTheme,
3693
+ hostContext: p.hostContext,
3694
+ appRuntimeContract: "1.0"
3695
+ };
3696
+ }, V = function() {
3697
+ var n = t(function* (t) {
3697
3698
  k("Loading puzzle...", "waiting");
3698
3699
  try {
3699
- let e = B(yield P());
3700
- k("Sending READY_DATA...", "waiting"), I("READY_DATA", e), k("Waiting for game to load...", "waiting");
3700
+ let n = e(e({}, B(yield P())), {}, { appRuntimeContract: t });
3701
+ k("Sending READY_DATA...", "waiting"), I("READY_DATA", n), k("Waiting for game to load...", "waiting");
3701
3702
  } catch (e) {
3702
3703
  k(`Error: ${e}`, "paused");
3703
3704
  }
3704
3705
  });
3705
- return function() {
3706
- return e.apply(this, arguments);
3706
+ return function(e) {
3707
+ return n.apply(this, arguments);
3707
3708
  };
3708
- }(), le = () => {
3709
- console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
3709
+ }(), H = () => {
3710
+ console.log("Simulator: Game loaded, ready to start"), x.disabled = !1, d.forEach((e) => {
3710
3711
  var t;
3711
3712
  return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, R);
3712
- }), a && !f.hasStarted && setTimeout(() => {
3713
+ }), o && !p.hasStarted && setTimeout(() => {
3713
3714
  let e = D("#simulator-start");
3714
- e == null || e.click(), y.disabled = !1, f.hasStarted = !0, k("Running", "ready");
3715
+ e == null || e.click(), b.disabled = !1, p.hasStarted = !0, k("Running", "ready");
3715
3716
  }, 100);
3716
3717
  };
3717
- return ie((e, t) => {
3718
+ return ae((e, t) => {
3718
3719
  var n, r;
3719
3720
  if (e === "READY") {
3720
- console.log("Simulator: Received READY from game"), V();
3721
+ console.log("Simulator: Received READY from game"), V((t == null ? void 0 : t.runtimeContract) === "1.1" ? "1.1" : "1.0");
3721
3722
  return;
3722
3723
  }
3723
3724
  if (e === "READY_GAME_LOADED") {
3724
- le();
3725
+ H();
3725
3726
  return;
3726
3727
  }
3727
3728
  if (e === "TIMER_TICK") {
@@ -3736,30 +3737,47 @@ function Ft(e = {}) {
3736
3737
  console.log("Simulator: Sidebar update", t);
3737
3738
  return;
3738
3739
  }
3739
- u.forEach((n) => {
3740
+ d.forEach((n) => {
3740
3741
  var r;
3741
3742
  return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, R);
3742
3743
  });
3743
3744
  let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
3744
- e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" && N(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), y.disabled = !0, f.hasStarted = !1, k("Completed!", "complete"));
3745
+ e === "UPLOAD_NEW_GAME_STATE" && i && (p.currentInputStr = i, p.activeTab === "thumb" && N(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), b.disabled = !0, p.hasStarted = !1, k("Completed!", "complete"));
3745
3746
  }, F), console.log("Simulator initialized"), $ = {
3746
3747
  updateFixtures: (e) => {
3747
- o = ae(e), s = Array.from(o.keys()).sort(), R.fixtures = o, R.fixtureCategories = s;
3748
+ s = oe(e), c = Array.from(s.keys()).sort(), R.fixtures = s, R.fixtureCategories = c;
3748
3749
  let t = localStorage.getItem("simulator-fixture-category");
3749
- if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
3750
+ if (!p.selectedCategory || !c.includes(p.selectedCategory)) {
3750
3751
  var n;
3751
- f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
3752
+ p.selectedCategory = t && c.includes(t) ? t : (n = c[0]) == null ? null : n;
3752
3753
  }
3753
- let r = u.find((e) => e.id === "ctrl");
3754
+ let r = d.find((e) => e.id === "ctrl");
3754
3755
  r == null || r.bind(R), console.log("Simulator: Fixtures updated", {
3755
- categories: s,
3756
- selectedCategory: f.selectedCategory
3756
+ categories: c,
3757
+ selectedCategory: p.selectedCategory
3757
3758
  });
3758
3759
  },
3759
3760
  sendToGame: I,
3760
3761
  loadPuzzle: P
3761
3762
  }, $;
3762
3763
  }
3763
- export { At as n, oe as r, Ft as t };
3764
+ /** The game the simulator stands in for, with placeholder IDs since nothing is stored */
3765
+ var It = {
3766
+ id: "simulator-game",
3767
+ slug: "proto-game",
3768
+ stableSlug: "proto-game",
3769
+ displayName: "Proto Game",
3770
+ version: {
3771
+ id: "simulator-version",
3772
+ label: null,
3773
+ featuresArr: [0],
3774
+ flagsArr: [0],
3775
+ runtime: {
3776
+ id: "simulator-runtime",
3777
+ version: null
3778
+ }
3779
+ }
3780
+ };
3781
+ export { At as n, se as r, Ft as t };
3764
3782
 
3765
- //# sourceMappingURL=createSimulator-Dory7qUL.js.map
3783
+ //# sourceMappingURL=createSimulator-CdInpCHG.js.map