@puzzmo/sdk 1.0.85 → 1.0.87

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.
package/README.md CHANGED
@@ -83,6 +83,15 @@ themselves.
83
83
  | `sdk.completeRepeatableRun(run, config?)` | Report a finished run; the timer keeps going for the next one. |
84
84
  | `sdk.requestPuzzle({ buckets, exclude })` | Another puzzle from the pool, or from `buckets`; `exclude` is the game's recent keys. |
85
85
 
86
+ Repeat play's host sits the game on a table with other players' boards around it, so it can ask the game's
87
+ questions over its whole page, dimming the table too. Check first, and use the game's own dialog where it can't
88
+ (the daily, embeds). Settings need nothing from the game: the host shows the ones from `sdk.settings.initialize`.
89
+
90
+ | Method | Description |
91
+ | ------------------------------ | ------------------------------------------------------------------------------- |
92
+ | `sdk.canConfirm()` | Whether the host draws `sdk.confirm()`'s question. |
93
+ | `sdk.confirm({ title, text })` | A yes/no question over the host's page; resolves true when the player confirms. |
94
+
86
95
  ### Game State
87
96
 
88
97
  | Method | Description |
@@ -1,4 +1,4 @@
1
- const e=require(`./chunk-350yNsax.cjs`),t=require(`./objectSpread2-BU9HzoRm.cjs`),n=require(`./asyncToGenerator-Tjg_Hpik.cjs`),r=require(`./tableBoard-CLDBwRYs.cjs`),i=require(`./fonts-CS5qdLf3.cjs`),a=[{name:`Puzzmo (light)`,type:`light`,key:`#FFAAAC`,keyFG:`#000000`,keyStrong:`#F7868B`,keyLight:`#FFD2D3`,g_key:`#FFAAAC`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#98B389`,alt2:`#FAC16C`,alt3:`#D298FF`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#FFFFFF`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#F2F2F2`,a_bgAlt:`#ECECEC`,a_puzmo:`#FFC000`,a_headerText:`#000000`,a_table:`#F9F9F9`,a_tableAlt:`#F6F4F4`,a_inlineTag:`#D9D9D9`,a_anchor:`#1F97EE`,a_infoBG:`#FFFFFF`},{name:`Puzzmo (dark)`,type:`dark`,key:`#FFAAAC`,keyFG:`#000000`,keyStrong:`#F7868B`,keyLight:`#FFD2D3`,g_key:`#FFAAAC`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,subBrand:`#FFC000`,subBrandFG:`#000000`,alt1:`#98B389`,alt2:`#FAC16C`,alt3:`#D298FF`,error:`#FF3C3C`,fg:`#ECECEC`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#374351`,g_bgAlt:`#333D49`,g_bgDark:`#2C2F33`,g_textDark:`#F2F2F2`,g_textLight:`#20180E`,g_blank:`#000000`,g_unsolved:`#747474`,g_outline:`#646464`,a_bg:`#141620`,a_bgAlt:`#202433`,a_puzmo:`#FFC000`,a_headerText:`#A1BAD4`,a_table:`#303246`,a_tableAlt:`#393b52`,a_inlineTag:`#ECECEC`,a_anchor:`#1F97EE`,a_infoBG:`#282C3A`},{name:`Foshay`,type:`light`,key:`#98B389`,keyFG:`#313540`,keyStrong:`#87BD69`,keyLight:`#809B77`,g_key:`#98B389`,player:`#3EC0E5`,subBrand:`#FFC000`,subBrandFG:`#000000`,playerFG:`#292B35`,playerLight:`#A8B5D6`,alt1:`#D87DA4`,alt2:`#E3A54F`,alt3:`#D298FF`,error:`#FF3C3C`,fg:`#292B35`,alwaysDark:`#292B35`,alwaysLight:`#D1DBF2`,g_bg:`#949EBA`,g_bgAlt:`#8891AB`,g_bgDark:`#7B839B`,g_textDark:`#292B35`,g_textLight:`#FFFFFF`,g_blank:`#292B35`,g_unsolved:`#B6B7BA`,g_outline:`#676F83`,a_bg:`#828CA3`,a_bgAlt:`#7F889F`,a_puzmo:`#FFC000`,a_headerText:`#292B35`,a_table:`#7A8399`,a_tableAlt:`#767E94`,a_inlineTag:`#ECECEC`,a_anchor:`#56C9E9`,a_infoBG:`#767F95`},{name:`Bright white`,type:`light`,key:`#67ced2`,keyFG:`#000000`,keyStrong:`#26a0a5`,keyLight:`#ade6e9`,g_key:`#67ced2`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#d26767`,alt2:`#fac16c`,alt3:`#7580bd`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#111111`,alwaysLight:`#FFFFFF`,g_bg:`#f6f6f6`,g_bgAlt:`#F4F4F4`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FFFFFF`,a_bgAlt:`#f8fbfc`,a_puzmo:`#FFC000`,a_headerText:`#000000`,a_table:`#EDEDED`,a_tableAlt:`#DBDBDB`,a_inlineTag:`#D9D9D9`,a_anchor:`#1F97EE`,a_infoBG:`#f6f6f6`},{name:`Submersible`,type:`dark`,key:`#CD6DC6`,keyFG:`#031698`,keyStrong:`#FF7ABC`,keyLight:`#B467CB`,g_key:`#CD6DC6`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#4AB1D1`,playerFG:`#071D47`,playerLight:`#3C99D7`,alt1:`#8BA964`,alt2:`#C69A58`,alt3:`#7644B5`,fg:`#FFEBFF`,error:`#FF3C3C`,alwaysDark:`#031698`,alwaysLight:`#FFEBFF`,g_bg:`#043BED`,g_bgAlt:`#0A31CC`,g_bgDark:`#0E2DA8`,g_textDark:`#031698`,g_textLight:`#FFEBFF`,g_blank:`#031698`,g_unsolved:`#3662F1`,g_outline:`#031698`,a_bg:`#043BED`,a_bgAlt:`#0A31CC`,a_puzmo:`#FFC000`,a_headerText:`#FFEBFF`,a_table:`#043BED`,a_tableAlt:`#0A31CC`,a_inlineTag:`#FF7ABC`,a_anchor:`#FF7ABC`,a_infoBG:`#0A31CC`},{name:`Hot Dog (beta)`,type:`light`,key:`#FFFF00`,keyFG:`#000000`,keyStrong:`#FFE600`,keyLight:`#FFEC44`,g_key:`#FFFF00`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#FF7A00`,playerFG:`#000000`,playerLight:`#FFA450`,alt1:`#3ABC5E`,alt2:`#5C3ABC`,alt3:`#BC3AAF`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#EBFF00`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FF0000`,a_bgAlt:`#E50000`,a_puzmo:`#FFC000`,a_headerText:`#FFFFFF`,a_table:`#E50000`,a_tableAlt:`#FF2525`,a_inlineTag:`#000000`,a_anchor:`#000000`,a_infoBG:`#C6C6C6`},{name:`Outlook Hayesy`,type:`light`,key:`#DAB98C`,keyFG:`#000000`,keyStrong:`#B99368`,keyLight:`#DAB98C`,subBrand:`#FFC000`,subBrandFG:`#000000`,g_key:`#DAB98C`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#5EC386`,alt2:`#5E93C3`,alt3:`#C35E5E`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#5E390F`,alwaysLight:`#FFF3E4`,g_bg:`#FFFFFF`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FEF5E8`,a_bgAlt:`#ffffff`,a_puzmo:`#FAC7CE`,a_headerText:`#000000`,a_table:`#FAE8D3`,a_tableAlt:`#EED7BC`,a_inlineTag:`#D9D9D9`,a_anchor:`#B99368`,a_infoBG:`#FFFFFF`},{name:`Console (beta)`,type:`dark`,key:`#957df9`,keyFG:`#000000`,keyStrong:`#590FF5`,keyLight:`#590FF5`,subBrand:`#FFC000`,subBrandFG:`#000000`,g_key:`#FFFF00`,player:`#ffffff`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#590ff5`,alt2:`#00e200`,alt3:`#ff8a02`,fg:`#00e200`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#00e200`,g_bg:`#101428`,g_bgAlt:`#101428`,g_bgDark:`#00e200`,g_textDark:`#00e200`,g_textLight:`#590ff5`,g_blank:`#00e200`,g_unsolved:`#0000ff`,g_outline:`#00e200`,a_bg:`#000000`,a_bgAlt:`#112211`,a_puzmo:`#ffffff`,a_headerText:`#00e200`,a_table:`#000000`,a_tableAlt:`#002200`,a_inlineTag:`#D9D9D9`,a_anchor:`#957df9`,a_infoBG:`#001900`}];var o={collapsed:`simulator-collapsed`,tab:`simulator-tab`,theme:`simulator-theme`,fixtureCategory:`simulator-fixture-category`,fixturePuzzle:`simulator-fixture-puzzle`,renderHost:`simulator-render-host`,renderContext:`simulator-render-context`,previewKind:`simulator-preview-kind`,gameSettings:`simulator-game-settings`,hostContext:`simulator-host-context`,keyboardDocked:`simulator-keyboard-docked`,pmmg:`simulator-pmmg`},s=`simulator-override:`;function c(e){return`${s}${e}:${(window.location.pathname||`/`).replace(/\/index\.html$/,``).replace(/\/+$/,``)||`/`}`}function l(e){try{return localStorage.getItem(c(e))}catch(e){return null}}function u(e,t){try{return localStorage.setItem(c(e),t),!0}catch(e){return!1}}function d(e){try{localStorage.removeItem(c(e))}catch(e){}}function f(){d(`puzzle`),d(`input`)}function p(){let e=localStorage.getItem(o.hostContext);if(!e)return null;try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return null}function m(e){localStorage.setItem(o.hostContext,JSON.stringify(e))}function h(){localStorage.removeItem(o.hostContext)}function g(){return localStorage.getItem(o.keyboardDocked)===`true`}function _(e){localStorage.setItem(o.keyboardDocked,String(e))}var v={subtab:`layout`,follow:!0,bounds:!0,grid:!1,boxes:!1,anchors:!1,keys:!1,backdrop:`checker`,fidelity:`high`,backgroundStyle:`theme`};function y(){let e=t.t({},v);try{var n;let t=JSON.parse((n=localStorage.getItem(o.pmmg))==null?`{}`:n);[`layout`,`sprites`,`scene`].includes(t.subtab)&&(e.subtab=t.subtab),[`checker`,`theme`,`black`,`white`].includes(t.backdrop)&&(e.backdrop=t.backdrop),[`high`,`low`].includes(t.fidelity)&&(e.fidelity=t.fidelity),[`theme`,`dark`,`light`].includes(t.backgroundStyle)&&(e.backgroundStyle=t.backgroundStyle);for(let n of[`follow`,`bounds`,`grid`,`boxes`,`anchors`,`keys`])typeof t[n]==`boolean`&&(e[n]=t[n])}catch(e){}return e}function b(e){localStorage.setItem(o.pmmg,JSON.stringify(e))}function x(){let e=localStorage.getItem(o.gameSettings);if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`)return t}catch(e){}return{}}function S(){let e=localStorage.getItem(o.theme);if(e){let t=a.find(t=>t.name===e);if(t)return t}return a[0]}function C(e){var t;let n=localStorage.getItem(o.tab);return n&&e.includes(n)?n:(t=e[0])==null?`ctrl`:t}function w(e){let t=localStorage.getItem(o.collapsed);return t===null?e:t===`true`}function T(){let e=localStorage.getItem(o.renderHost);return e&&[`game`,`app`,`opengraph`].includes(e)?e:`game`}function E(){return localStorage.getItem(o.previewKind)===`text`?`text`:`image`}function D(){let e=localStorage.getItem(o.renderContext);if(e&&[`preview`,`share`,`completed`,`timeline`].includes(e))return e}function O(e,t,n){var r,i,a;let s=localStorage.getItem(o.fixtureCategory),c=localStorage.getItem(o.fixturePuzzle),u=p(),d=l(`puzzle`),f=l(`input`);return{hostContext:(r=u==null?e.hostContext:u)==null?[{type:`app`,layout:`desktop`,host:null}]:r,hostContextIsOverridden:u!==null,isCollapsed:w((i=e.collapsed)==null?!0:i),isPaused:!1,hasStarted:!1,activeTab:C(n),puzzleData:d,originalPuzzle:d==null?``:d,currentInputStr:f==null?``:f,userStorage:null,appliedPuzzleOverride:d,appliedInputOverride:f,completionData:null,selectedTheme:S(),selectedCategory:s&&t.includes(s)?s:(a=t[0])==null?null:a,selectedPuzzle:c==null?null:c,renderHost:T(),renderContext:D(),previewKind:E(),gameSettings:x(),keyboardDocked:g(),settingsComponents:null}}function k(e){localStorage.setItem(o.gameSettings,JSON.stringify(e))}function A(){localStorage.removeItem(o.gameSettings)}function j(e){localStorage.setItem(o.collapsed,String(e))}function M(e){localStorage.setItem(o.tab,e)}function N(e){localStorage.setItem(o.theme,e)}function P(e){localStorage.setItem(o.fixtureCategory,e)}function ee(e){localStorage.setItem(o.fixturePuzzle,e)}function F(){localStorage.removeItem(o.fixturePuzzle)}function I(e){e?localStorage.setItem(o.renderHost,e):localStorage.removeItem(o.renderHost)}function L(e){localStorage.setItem(o.previewKind,e)}function R(e){e?localStorage.setItem(o.renderContext,e):localStorage.removeItem(o.renderContext)}function te(e){let t=[];return{log(n,r,i){let a={type:n,data:r,time:new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),direction:i};t.push(a),t.length>100&&t.shift(),e==null||e(a)},clear(){t.length=0},getLog(){return t}}}function z(e,t,n){console.log(`Simulator sending:`,e,t),n==null||n.log(e,t,`out`),window.postMessage({type:e,data:t},`*`)}function ne(e,t){let n=n=>{var r,i,a;if(!(!(n==null||(r=n.data)==null)&&r.type))return;let o=n.data.type,s=(i=(a=n.data.data)==null?n.data.json:a)==null?{}:i;[`TIMER_TICK`,`TIMER_SYNC`].includes(o)||t==null||t.log(o,s,`in`),e(o,s)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function B(e){let t=new Map;console.log(`Simulator: Parsing fixtures`,Object.keys(e));for(let[o,s]of Object.entries(e)){var n,r,i,a;let e=o.split(`/`),c=(n=(r=e.pop())==null?void 0:r.replace(/\.[^.]+$/,``))==null?``:n,l=(i=e.pop())==null?`default`:i;t.has(l)||t.set(l,new Map);let u=(a=s.default)==null?s:a;t.get(l).set(c,u)}return t.forEach((e,n)=>{let r=new Map(Array.from(e.entries()).sort((e,t)=>{var n,r,i,a;return parseInt((n=(r=e[0].match(/\d+/))==null?void 0:r[0])==null?`0`:n)-parseInt((i=(a=t[0].match(/\d+/))==null?void 0:a[0])==null?`0`:i)}));t.set(n,r)}),t}function V(e,t){return e.length===0?``:`
1
+ const e=require(`./chunk-350yNsax.cjs`),t=require(`./objectSpread2-BU9HzoRm.cjs`),n=require(`./asyncToGenerator-Tjg_Hpik.cjs`),r=require(`./tableBoard-CLDBwRYs.cjs`),i=require(`./fonts-CS5qdLf3.cjs`),a=[{name:`Puzzmo (light)`,type:`light`,key:`#FFAAAC`,keyFG:`#000000`,keyStrong:`#F7868B`,keyLight:`#FFD2D3`,g_key:`#FFAAAC`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#98B389`,alt2:`#FAC16C`,alt3:`#D298FF`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#FFFFFF`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#F2F2F2`,a_bgAlt:`#ECECEC`,a_puzmo:`#FFC000`,a_headerText:`#000000`,a_table:`#F9F9F9`,a_tableAlt:`#F6F4F4`,a_inlineTag:`#D9D9D9`,a_anchor:`#1F97EE`,a_infoBG:`#FFFFFF`},{name:`Puzzmo (dark)`,type:`dark`,key:`#FFAAAC`,keyFG:`#000000`,keyStrong:`#F7868B`,keyLight:`#FFD2D3`,g_key:`#FFAAAC`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,subBrand:`#FFC000`,subBrandFG:`#000000`,alt1:`#98B389`,alt2:`#FAC16C`,alt3:`#D298FF`,error:`#FF3C3C`,fg:`#ECECEC`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#374351`,g_bgAlt:`#333D49`,g_bgDark:`#2C2F33`,g_textDark:`#F2F2F2`,g_textLight:`#20180E`,g_blank:`#000000`,g_unsolved:`#747474`,g_outline:`#646464`,a_bg:`#141620`,a_bgAlt:`#202433`,a_puzmo:`#FFC000`,a_headerText:`#A1BAD4`,a_table:`#303246`,a_tableAlt:`#393b52`,a_inlineTag:`#ECECEC`,a_anchor:`#1F97EE`,a_infoBG:`#282C3A`},{name:`Foshay`,type:`light`,key:`#98B389`,keyFG:`#313540`,keyStrong:`#87BD69`,keyLight:`#809B77`,g_key:`#98B389`,player:`#3EC0E5`,subBrand:`#FFC000`,subBrandFG:`#000000`,playerFG:`#292B35`,playerLight:`#A8B5D6`,alt1:`#D87DA4`,alt2:`#E3A54F`,alt3:`#D298FF`,error:`#FF3C3C`,fg:`#292B35`,alwaysDark:`#292B35`,alwaysLight:`#D1DBF2`,g_bg:`#949EBA`,g_bgAlt:`#8891AB`,g_bgDark:`#7B839B`,g_textDark:`#292B35`,g_textLight:`#FFFFFF`,g_blank:`#292B35`,g_unsolved:`#B6B7BA`,g_outline:`#676F83`,a_bg:`#828CA3`,a_bgAlt:`#7F889F`,a_puzmo:`#FFC000`,a_headerText:`#292B35`,a_table:`#7A8399`,a_tableAlt:`#767E94`,a_inlineTag:`#ECECEC`,a_anchor:`#56C9E9`,a_infoBG:`#767F95`},{name:`Bright white`,type:`light`,key:`#67ced2`,keyFG:`#000000`,keyStrong:`#26a0a5`,keyLight:`#ade6e9`,g_key:`#67ced2`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#d26767`,alt2:`#fac16c`,alt3:`#7580bd`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#111111`,alwaysLight:`#FFFFFF`,g_bg:`#f6f6f6`,g_bgAlt:`#F4F4F4`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FFFFFF`,a_bgAlt:`#f8fbfc`,a_puzmo:`#FFC000`,a_headerText:`#000000`,a_table:`#EDEDED`,a_tableAlt:`#DBDBDB`,a_inlineTag:`#D9D9D9`,a_anchor:`#1F97EE`,a_infoBG:`#f6f6f6`},{name:`Submersible`,type:`dark`,key:`#CD6DC6`,keyFG:`#031698`,keyStrong:`#FF7ABC`,keyLight:`#B467CB`,g_key:`#CD6DC6`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#4AB1D1`,playerFG:`#071D47`,playerLight:`#3C99D7`,alt1:`#8BA964`,alt2:`#C69A58`,alt3:`#7644B5`,fg:`#FFEBFF`,error:`#FF3C3C`,alwaysDark:`#031698`,alwaysLight:`#FFEBFF`,g_bg:`#043BED`,g_bgAlt:`#0A31CC`,g_bgDark:`#0E2DA8`,g_textDark:`#031698`,g_textLight:`#FFEBFF`,g_blank:`#031698`,g_unsolved:`#3662F1`,g_outline:`#031698`,a_bg:`#043BED`,a_bgAlt:`#0A31CC`,a_puzmo:`#FFC000`,a_headerText:`#FFEBFF`,a_table:`#043BED`,a_tableAlt:`#0A31CC`,a_inlineTag:`#FF7ABC`,a_anchor:`#FF7ABC`,a_infoBG:`#0A31CC`},{name:`Hot Dog (beta)`,type:`light`,key:`#FFFF00`,keyFG:`#000000`,keyStrong:`#FFE600`,keyLight:`#FFEC44`,g_key:`#FFFF00`,subBrand:`#FFC000`,subBrandFG:`#000000`,player:`#FF7A00`,playerFG:`#000000`,playerLight:`#FFA450`,alt1:`#3ABC5E`,alt2:`#5C3ABC`,alt3:`#BC3AAF`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#FFFFFF`,g_bg:`#EBFF00`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FF0000`,a_bgAlt:`#E50000`,a_puzmo:`#FFC000`,a_headerText:`#FFFFFF`,a_table:`#E50000`,a_tableAlt:`#FF2525`,a_inlineTag:`#000000`,a_anchor:`#000000`,a_infoBG:`#C6C6C6`},{name:`Outlook Hayesy`,type:`light`,key:`#DAB98C`,keyFG:`#000000`,keyStrong:`#B99368`,keyLight:`#DAB98C`,subBrand:`#FFC000`,subBrandFG:`#000000`,g_key:`#DAB98C`,player:`#5DBAFC`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#5EC386`,alt2:`#5E93C3`,alt3:`#C35E5E`,fg:`#000000`,error:`#FF3C3C`,alwaysDark:`#5E390F`,alwaysLight:`#FFF3E4`,g_bg:`#FFFFFF`,g_bgAlt:`#EBEBEB`,g_bgDark:`#D6D6D6`,g_textDark:`#1B1B28`,g_textLight:`#FFFFFF`,g_blank:`#000000`,g_unsolved:`#C2C2C2`,g_outline:`#1B1D29`,a_bg:`#FEF5E8`,a_bgAlt:`#ffffff`,a_puzmo:`#FAC7CE`,a_headerText:`#000000`,a_table:`#FAE8D3`,a_tableAlt:`#EED7BC`,a_inlineTag:`#D9D9D9`,a_anchor:`#B99368`,a_infoBG:`#FFFFFF`},{name:`Console (beta)`,type:`dark`,key:`#957df9`,keyFG:`#000000`,keyStrong:`#590FF5`,keyLight:`#590FF5`,subBrand:`#FFC000`,subBrandFG:`#000000`,g_key:`#FFFF00`,player:`#ffffff`,playerFG:`#000000`,playerLight:`#9EDDFF`,alt1:`#590ff5`,alt2:`#00e200`,alt3:`#ff8a02`,fg:`#00e200`,error:`#FF3C3C`,alwaysDark:`#1B1D29`,alwaysLight:`#00e200`,g_bg:`#101428`,g_bgAlt:`#101428`,g_bgDark:`#00e200`,g_textDark:`#00e200`,g_textLight:`#590ff5`,g_blank:`#00e200`,g_unsolved:`#0000ff`,g_outline:`#00e200`,a_bg:`#000000`,a_bgAlt:`#112211`,a_puzmo:`#ffffff`,a_headerText:`#00e200`,a_table:`#000000`,a_tableAlt:`#002200`,a_inlineTag:`#D9D9D9`,a_anchor:`#957df9`,a_infoBG:`#001900`}];var o={collapsed:`simulator-collapsed`,tab:`simulator-tab`,theme:`simulator-theme`,fixtureCategory:`simulator-fixture-category`,fixturePuzzle:`simulator-fixture-puzzle`,renderHost:`simulator-render-host`,renderContext:`simulator-render-context`,previewKind:`simulator-preview-kind`,gameSettings:`simulator-game-settings`,hostContext:`simulator-host-context`,keyboardDocked:`simulator-keyboard-docked`,pmmg:`simulator-pmmg`},s=`simulator-override:`;function c(e){return`${s}${e}:${(window.location.pathname||`/`).replace(/\/index\.html$/,``).replace(/\/+$/,``)||`/`}`}function l(e){try{return localStorage.getItem(c(e))}catch(e){return null}}function u(e,t){try{return localStorage.setItem(c(e),t),!0}catch(e){return!1}}function d(e){try{localStorage.removeItem(c(e))}catch(e){}}function f(){d(`puzzle`),d(`input`)}function p(){let e=localStorage.getItem(o.hostContext);if(!e)return null;try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return null}function m(e){localStorage.setItem(o.hostContext,JSON.stringify(e))}function h(){localStorage.removeItem(o.hostContext)}function g(){return localStorage.getItem(o.keyboardDocked)===`true`}function _(e){localStorage.setItem(o.keyboardDocked,String(e))}var v={subtab:`layout`,follow:!0,bounds:!0,grid:!1,boxes:!1,anchors:!1,keys:!1,backdrop:`checker`,fidelity:`high`,backgroundStyle:`theme`};function y(){let e=t.t({},v);try{var n;let t=JSON.parse((n=localStorage.getItem(o.pmmg))==null?`{}`:n);[`layout`,`sprites`,`scene`].includes(t.subtab)&&(e.subtab=t.subtab),[`checker`,`theme`,`black`,`white`].includes(t.backdrop)&&(e.backdrop=t.backdrop),[`high`,`low`].includes(t.fidelity)&&(e.fidelity=t.fidelity),[`theme`,`dark`,`light`].includes(t.backgroundStyle)&&(e.backgroundStyle=t.backgroundStyle);for(let n of[`follow`,`bounds`,`grid`,`boxes`,`anchors`,`keys`])typeof t[n]==`boolean`&&(e[n]=t[n])}catch(e){}return e}function b(e){localStorage.setItem(o.pmmg,JSON.stringify(e))}function x(){let e=localStorage.getItem(o.gameSettings);if(!e)return{};try{let t=JSON.parse(e);if(t&&typeof t==`object`)return t}catch(e){}return{}}function S(){let e=localStorage.getItem(o.theme);if(e){let t=a.find(t=>t.name===e);if(t)return t}return a[0]}function C(e){var t;let n=localStorage.getItem(o.tab);return n&&e.includes(n)?n:(t=e[0])==null?`ctrl`:t}function w(e){let t=localStorage.getItem(o.collapsed);return t===null?e:t===`true`}function T(){let e=localStorage.getItem(o.renderHost);return e&&[`game`,`app`,`opengraph`].includes(e)?e:`game`}function E(){return localStorage.getItem(o.previewKind)===`text`?`text`:`image`}function D(){let e=localStorage.getItem(o.renderContext);if(e&&[`preview`,`share`,`completed`,`timeline`].includes(e))return e}function ee(e,t,n){var r,i,a;let s=localStorage.getItem(o.fixtureCategory),c=localStorage.getItem(o.fixturePuzzle),u=p(),d=l(`puzzle`),f=l(`input`);return{hostContext:(r=u==null?e.hostContext:u)==null?[{type:`app`,layout:`desktop`,host:null}]:r,hostContextIsOverridden:u!==null,isCollapsed:w((i=e.collapsed)==null?!0:i),isPaused:!1,hasStarted:!1,activeTab:C(n),puzzleData:d,originalPuzzle:d==null?``:d,currentInputStr:f==null?``:f,userStorage:null,appliedPuzzleOverride:d,appliedInputOverride:f,completionData:null,selectedTheme:S(),selectedCategory:s&&t.includes(s)?s:(a=t[0])==null?null:a,selectedPuzzle:c==null?null:c,renderHost:T(),renderContext:D(),previewKind:E(),gameSettings:x(),keyboardDocked:g(),settingsComponents:null}}function O(e){localStorage.setItem(o.gameSettings,JSON.stringify(e))}function k(){localStorage.removeItem(o.gameSettings)}function A(e){localStorage.setItem(o.collapsed,String(e))}function j(e){localStorage.setItem(o.tab,e)}function M(e){localStorage.setItem(o.theme,e)}function N(e){localStorage.setItem(o.fixtureCategory,e)}function P(e){localStorage.setItem(o.fixturePuzzle,e)}function F(){localStorage.removeItem(o.fixturePuzzle)}function I(e){e?localStorage.setItem(o.renderHost,e):localStorage.removeItem(o.renderHost)}function L(e){localStorage.setItem(o.previewKind,e)}function R(e){e?localStorage.setItem(o.renderContext,e):localStorage.removeItem(o.renderContext)}function te(e){let t=[];return{log(n,r,i){let a={type:n,data:r,time:new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),direction:i};t.push(a),t.length>100&&t.shift(),e==null||e(a)},clear(){t.length=0},getLog(){return t}}}function z(e,t,n){console.log(`Simulator sending:`,e,t),n==null||n.log(e,t,`out`),window.postMessage({type:e,data:t},`*`)}function ne(e,t){let n=n=>{var r,i,a;if(!(!(n==null||(r=n.data)==null)&&r.type))return;let o=n.data.type,s=(i=(a=n.data.data)==null?n.data.json:a)==null?{}:i;[`TIMER_TICK`,`TIMER_SYNC`].includes(o)||t==null||t.log(o,s,`in`),e(o,s)};return window.addEventListener(`message`,n),()=>window.removeEventListener(`message`,n)}function re(e){let t=new Map;console.log(`Simulator: Parsing fixtures`,Object.keys(e));for(let[o,s]of Object.entries(e)){var n,r,i,a;let e=o.split(`/`),c=(n=(r=e.pop())==null?void 0:r.replace(/\.[^.]+$/,``))==null?``:n,l=(i=e.pop())==null?`default`:i;t.has(l)||t.set(l,new Map);let u=(a=s.default)==null?s:a;t.get(l).set(c,u)}return t.forEach((e,n)=>{let r=new Map(Array.from(e.entries()).sort((e,t)=>{var n,r,i,a;return parseInt((n=(r=e[0].match(/\d+/))==null?void 0:r[0])==null?`0`:n)-parseInt((i=(a=t[0].match(/\d+/))==null?void 0:a[0])==null?`0`:i)}));t.set(n,r)}),t}function B(e,t){return e.length===0?``:`
2
2
  <div class="simulator-fixtures">
3
3
  <div class="simulator-field">
4
4
  <label class="simulator-label">Category</label>
@@ -11,7 +11,7 @@ const e=require(`./chunk-350yNsax.cjs`),t=require(`./objectSpread2-BU9HzoRm.cjs`
11
11
  <select class="simulator-select" id="simulator-fixture-puzzle"></select>
12
12
  </div>
13
13
  </div>
14
- `}function H(e,t,n,r){let i=t.get(n);if(!i)return null;let a=Array.from(i.keys()),o=r;if(!r||!i.has(r)){var s;o=(s=a[0])==null?null:s}return e.innerHTML=a.map(e=>`<option value="${e}" ${e===o?`selected`:``}>${e}</option>`).join(``),o}function re(e,t,n){var r,i;return!t||!n||(r=(i=e.get(t))==null?void 0:i.get(n))==null?null:r}const ie=`puzzmo-simulator-dev-only-do-not-ship`;function ae(){return{id:`ctrl`,label:`Ctrl`,render(){return`
14
+ `}function V(e,t,n,r){let i=t.get(n);if(!i)return null;let a=Array.from(i.keys()),o=r;if(!r||!i.has(r)){var s;o=(s=a[0])==null?null:s}return e.innerHTML=a.map(e=>`<option value="${e}" ${e===o?`selected`:``}>${e}</option>`).join(``),o}function H(e,t,n){var r,i;return!t||!n||(r=(i=e.get(t))==null?void 0:i.get(n))==null?null:r}const ie=`puzzmo-simulator-dev-only-do-not-ship`;function ae(){return{id:`ctrl`,label:`Ctrl`,render(){return`
15
15
  <div id="simulator-fixtures-container"></div>
16
16
  <div id="simulator-status">
17
17
  <span class="indicator waiting"></span>
@@ -24,7 +24,7 @@ const e=require(`./chunk-350yNsax.cjs`),t=require(`./objectSpread2-BU9HzoRm.cjs`
24
24
  <div class="simulator-row">
25
25
  <button class="simulator-btn danger" id="simulator-retry" disabled>Retry</button>
26
26
  </div>
27
- `},bind(e){let t=e.getElement(`#simulator-start`),n=e.getElement(`#simulator-pause`),r=e.getElement(`#simulator-retry`),i=e.getElement(`#simulator-fixtures-container`);if(console.log(`Simulator: CtrlView.bind called`,{hasFixtures:!!e.fixtures,categories:e.fixtureCategories,selectedCategory:e.state.selectedCategory,selectedPuzzle:e.state.selectedPuzzle}),e.fixtures&&e.fixtureCategories.length>0&&i){i.innerHTML=V(e.fixtureCategories,e.state.selectedCategory);let t=e.getElement(`#simulator-fixture-category`),n=e.getElement(`#simulator-fixture-puzzle`);if(t&&n&&e.state.selectedCategory){e.state.selectedPuzzle=H(n,e.fixtures,e.state.selectedCategory,e.state.selectedPuzzle);let r=re(e.fixtures,e.state.selectedCategory,e.state.selectedPuzzle);console.log(`Simulator: Loading fixture puzzle`,{category:e.state.selectedCategory,puzzle:e.state.selectedPuzzle,hasPuzzleData:!!r}),r&&(e.state.appliedPuzzleOverride===null&&(e.state.puzzleData=r,e.state.originalPuzzle=r),e.state.selectedCategory&&P(e.state.selectedCategory),e.state.selectedPuzzle&&ee(e.state.selectedPuzzle)),t.addEventListener(`change`,()=>{console.log(`Simulator: Category changed, reloading...`,t.value),f(),P(t.value),F(),window.location.reload()}),n.addEventListener(`change`,()=>{console.log(`Simulator: Puzzle changed, reloading...`,n.value),f(),ee(n.value),window.location.reload()})}}t==null||t.addEventListener(`click`,()=>{e.state.isPaused?(e.sendToGame(`RESUME_GAME`,{}),e.state.isPaused=!1,n&&(n.textContent=`Pause`),e.updateStatus(`Running`,`ready`)):(e.sendToGame(`START_GAME`,void 0),e.state.hasStarted=!0,n&&(n.disabled=!1),t&&(t.textContent=`Resume`),e.updateStatus(`Running`,`ready`))}),n==null||n.addEventListener(`click`,()=>{e.state.isPaused?(e.sendToGame(`RESUME_GAME`,{}),e.state.isPaused=!1,n.textContent=`Pause`,e.updateStatus(`Running`,`ready`)):(e.sendToGame(`PAUSE_GAME`,{}),e.state.isPaused=!0,n.textContent=`Resume`,e.updateStatus(`Paused`,`paused`))}),r==null||r.addEventListener(`click`,()=>{e.sendToGame(`RETRY_PUZZLE`,{}),e.state.hasStarted=!1,e.state.isPaused=!1,n&&(n.disabled=!0,n.textContent=`Pause`),t&&(t.textContent=`Start`),e.updateStatus(`Ready to retry`,`ready`)})},onMessage(e,t,n){let r=n.getElement(`#simulator-start`),i=n.getElement(`#simulator-pause`),a=n.getElement(`#simulator-retry`);e===`READY_GAME_LOADED`&&(r&&(r.disabled=!1),a&&(a.disabled=!1),n.updateStatus(`Ready`,`ready`)),e===`GAME_COMPLETED`&&(n.state.hasStarted=!1,i&&(i.disabled=!0),r&&(r.disabled=!0),n.updateStatus(`Completed!`,`complete`))}}}function U(e){var t;if(typeof e!=`string`)return e;let n=(t=W(e))==null?{width:800,height:800}:t;return{svg:e,width:n.width,height:n.height}}function W(e){var t,n,r,i;let a=e.indexOf(`<svg`);if(a===-1)return;let o=e.indexOf(`>`,a),s=o===-1?e.slice(a):e.slice(a,o+1),c=/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(s);if(c){let e=parseFloat(c[1]),t=parseFloat(c[2]);if(e>0&&t>0)return{width:e,height:t}}let l=parseFloat((t=(n=/\bwidth\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s))==null?void 0:n[1])==null?``:t),u=parseFloat((r=(i=/\bheight\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s))==null?void 0:i[1])==null?``:r);if(l>0&&u>0)return{width:l,height:u}}var oe=`simulator-saved-states`;function se(){let e=globalThis;for(let t of Object.keys(e))if(t.endsWith(`Thumbnail`)&&typeof e[t]==`function`)return{name:t,fn:e[t]};return null}function ce(e,t){let n=se();if(!n)return``;try{var r;let i=(r=e.state.puzzleData)==null?``:r,a={viewerIsOwner:!0,theme:e.state.selectedTheme,strict:!0,renderHost:`game`};return U(n.fn(i,t,a)).svg}catch(e){return``}}var G=[];function K(e,t=8){let n=14*t+8+4;e.style.height=`auto`;let r=Math.min(Math.max(e.scrollHeight,40),n);e.style.height=`${r}px`}function le(){let e=``,t=``;return{id:`data`,label:`Data`,render(){return`
27
+ `},bind(e){let t=e.getElement(`#simulator-start`),n=e.getElement(`#simulator-pause`),r=e.getElement(`#simulator-retry`),i=e.getElement(`#simulator-fixtures-container`);if(console.log(`Simulator: CtrlView.bind called`,{hasFixtures:!!e.fixtures,categories:e.fixtureCategories,selectedCategory:e.state.selectedCategory,selectedPuzzle:e.state.selectedPuzzle}),e.fixtures&&e.fixtureCategories.length>0&&i){i.innerHTML=B(e.fixtureCategories,e.state.selectedCategory);let t=e.getElement(`#simulator-fixture-category`),n=e.getElement(`#simulator-fixture-puzzle`);if(t&&n&&e.state.selectedCategory){e.state.selectedPuzzle=V(n,e.fixtures,e.state.selectedCategory,e.state.selectedPuzzle);let r=H(e.fixtures,e.state.selectedCategory,e.state.selectedPuzzle);console.log(`Simulator: Loading fixture puzzle`,{category:e.state.selectedCategory,puzzle:e.state.selectedPuzzle,hasPuzzleData:!!r}),r&&(e.state.appliedPuzzleOverride===null&&(e.state.puzzleData=r,e.state.originalPuzzle=r),e.state.selectedCategory&&N(e.state.selectedCategory),e.state.selectedPuzzle&&P(e.state.selectedPuzzle)),t.addEventListener(`change`,()=>{console.log(`Simulator: Category changed, reloading...`,t.value),f(),N(t.value),F(),window.location.reload()}),n.addEventListener(`change`,()=>{console.log(`Simulator: Puzzle changed, reloading...`,n.value),f(),P(n.value),window.location.reload()})}}t==null||t.addEventListener(`click`,()=>{e.state.isPaused?(e.sendToGame(`RESUME_GAME`,{}),e.state.isPaused=!1,n&&(n.textContent=`Pause`),e.updateStatus(`Running`,`ready`)):(e.sendToGame(`START_GAME`,void 0),e.state.hasStarted=!0,n&&(n.disabled=!1),t&&(t.textContent=`Resume`),e.updateStatus(`Running`,`ready`))}),n==null||n.addEventListener(`click`,()=>{e.state.isPaused?(e.sendToGame(`RESUME_GAME`,{}),e.state.isPaused=!1,n.textContent=`Pause`,e.updateStatus(`Running`,`ready`)):(e.sendToGame(`PAUSE_GAME`,{}),e.state.isPaused=!0,n.textContent=`Resume`,e.updateStatus(`Paused`,`paused`))}),r==null||r.addEventListener(`click`,()=>{e.sendToGame(`RETRY_PUZZLE`,{}),e.state.hasStarted=!1,e.state.isPaused=!1,n&&(n.disabled=!0,n.textContent=`Pause`),t&&(t.textContent=`Start`),e.updateStatus(`Ready to retry`,`ready`)})},onMessage(e,t,n){let r=n.getElement(`#simulator-start`),i=n.getElement(`#simulator-pause`),a=n.getElement(`#simulator-retry`);e===`READY_GAME_LOADED`&&(r&&(r.disabled=!1),a&&(a.disabled=!1),n.updateStatus(`Ready`,`ready`)),e===`GAME_COMPLETED`&&(n.state.hasStarted=!1,i&&(i.disabled=!0),r&&(r.disabled=!0),n.updateStatus(`Completed!`,`complete`))}}}function U(e){var t;if(typeof e!=`string`)return e;let n=(t=W(e))==null?{width:800,height:800}:t;return{svg:e,width:n.width,height:n.height}}function W(e){var t,n,r,i;let a=e.indexOf(`<svg`);if(a===-1)return;let o=e.indexOf(`>`,a),s=o===-1?e.slice(a):e.slice(a,o+1),c=/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(s);if(c){let e=parseFloat(c[1]),t=parseFloat(c[2]);if(e>0&&t>0)return{width:e,height:t}}let l=parseFloat((t=(n=/\bwidth\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s))==null?void 0:n[1])==null?``:t),u=parseFloat((r=(i=/\bheight\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s))==null?void 0:i[1])==null?``:r);if(l>0&&u>0)return{width:l,height:u}}var oe=`simulator-saved-states`;function se(){let e=globalThis;for(let t of Object.keys(e))if(t.endsWith(`Thumbnail`)&&typeof e[t]==`function`)return{name:t,fn:e[t]};return null}function ce(e,t){let n=se();if(!n)return``;try{var r;let i=(r=e.state.puzzleData)==null?``:r,a={viewerIsOwner:!0,theme:e.state.selectedTheme,strict:!0,renderHost:`game`};return U(n.fn(i,t,a)).svg}catch(e){return``}}var G=[];function K(e,t=8){let n=14*t+8+4;e.style.height=`auto`;let r=Math.min(Math.max(e.scrollHeight,40),n);e.style.height=`${r}px`}function le(){let e=``,t=``;return{id:`data`,label:`Data`,render(){return`
28
28
  <div class="data-view-container">
29
29
  <div class="data-subtabs">
30
30
  <button class="data-subtab active" data-subtab="edit">Edit</button>
@@ -160,11 +160,11 @@ const e=require(`./chunk-350yNsax.cjs`),t=require(`./objectSpread2-BU9HzoRm.cjs`
160
160
  ${r()}
161
161
  </div>
162
162
  </div>
163
- `},bind(t){let n=t.getElement(`#simulator-checkpoints-clear`),i=t.getElement(`#simulator-checkpoints-list`);n==null||n.addEventListener(`click`,()=>{e=[],i&&(i.innerHTML=r()),t.updateBadge(`checkpoints`,0)})},onMessage(n,i,a){if(n!==`HIT_CHECKPOINT`)return;let o={checkpointName:i.checkpointName,augConfig:i.augConfig,time:t()};e.push(o),a.updateBadge(`checkpoints`,e.length);let s=a.getElement(`#simulator-checkpoints-list`);s&&(s.innerHTML=r(),s.scrollTop=s.scrollHeight)}}}var be=e.t((e=>{var t={document:{}},n=Object.prototype.hasOwnProperty,r=function(e){return v(e)?e.toLowerCase():e},i=Array.isArray;function a(e){var t=Function.prototype.constructor;delete Function.prototype.constructor;var n=e();return Function.prototype.constructor=t,n}var o,s=Object.prototype.toString,c=Object.getPrototypeOf,l=j(`ng`);function u(e){if(e==null||x(e))return!1;if(i(e)||v(e)||o&&e instanceof o)return!0;var t=`length`in Object(e)&&e.length;return y(t)&&(t>=0&&(t-1 in e||e instanceof Array)||typeof e.item==`function`)}function d(e,t,r){var a,o;if(e)if(b(e))for(a in e)a!==`prototype`&&a!==`length`&&a!==`name`&&e.hasOwnProperty(a)&&t.call(r,e[a],a,e);else if(i(e)||u(e)){var s=typeof e!=`object`;for(a=0,o=e.length;a<o;a++)(s||a in e)&&t.call(r,e[a],a,e)}else if(e.forEach&&e.forEach!==d)e.forEach(t,r,e);else if(_(e))for(a in e)t.call(r,e[a],a,e);else if(typeof e.hasOwnProperty==`function`)for(a in e)e.hasOwnProperty(a)&&t.call(r,e[a],a,e);else for(a in e)n.call(e,a)&&t.call(r,e[a],a,e);return e}function f(e,t){t?e.$$hashKey=t:delete e.$$hashKey}function p(){}function m(e){return e===void 0}function h(e){return e!==void 0}function g(e){return typeof e==`object`&&!!e}function _(e){return typeof e==`object`&&!!e&&!c(e)}function v(e){return typeof e==`string`}function y(e){return typeof e==`number`}function b(e){return typeof e==`function`}function x(e){return e&&e.window===e}function S(e){return e&&e.$evalAsync&&e.$watch}var C=/^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;function w(e){return e&&y(e.length)&&C.test(s.call(e))}function T(e){return s.call(e)===`[object ArrayBuffer]`}function E(e,t){var r=[],a=[];if(t){if(w(t)||T(t))throw l(`cpta`,`Can't copy! TypedArray destination cannot be mutated.`);if(e===t)throw l(`cpi`,`Can't copy! Source and destination are identical.`);return i(t)?t.length=0:d(t,function(e,n){n!==`$$hashKey`&&delete t[n]}),r.push(e),a.push(t),o(e,t)}return u(e);function o(e,t){var r=t.$$hashKey,a;if(i(e))for(var o=0,s=e.length;o<s;o++)t.push(u(e[o]));else if(_(e))for(a in e)t[a]=u(e[a]);else if(e&&typeof e.hasOwnProperty==`function`)for(a in e)e.hasOwnProperty(a)&&(t[a]=u(e[a]));else for(a in e)n.call(e,a)&&(t[a]=u(e[a]));return f(t,r),t}function u(e){if(!g(e))return e;var t=r.indexOf(e);if(t!==-1)return a[t];if(x(e)||S(e))throw l(`cpws`,`Can't copy! Making copies of Window or Scope instances is not supported.`);var n=!1,s=p(e);return s===void 0&&(s=i(e)?[]:Object.create(c(e)),n=!0),r.push(e),a.push(s),n?o(e,s):s}function p(e){switch(s.call(e)){case`[object Int8Array]`:case`[object Int16Array]`:case`[object Int32Array]`:case`[object Float32Array]`:case`[object Float64Array]`:case`[object Uint8Array]`:case`[object Uint8ClampedArray]`:case`[object Uint16Array]`:case`[object Uint32Array]`:return new e.constructor(u(e.buffer),e.byteOffset,e.length);case`[object ArrayBuffer]`:if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case`[object Boolean]`:case`[object Number]`:case`[object String]`:case`[object Date]`:return new e.constructor(e.valueOf());case`[object RegExp]`:var n=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]);return n.lastIndex=e.lastIndex,n;case`[object Blob]`:return new e.constructor([e],{type:e.type})}if(b(e.cloneNode))return e.cloneNode(!0)}}function D(e,n){var r=n;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}function O(){return Object.create(null)}function k(e){var t=[];return JSON.stringify(e,function(e,n){if(n=D(e,n),g(n)){if(t.indexOf(n)>=0)return`...`;t.push(n)}return n})}function A(e){return typeof e==`function`?e.toString().replace(/ \{[\s\S]*$/,``):m(e)?`undefined`:typeof e==`string`?e:k(e)}function j(e,t){return t=t||Error,function(){var n=2,r=arguments,i=r[0],a=`[`+(e?e+`:`:``)+i+`] `,o=r[1],s,c;for(a+=o.replace(/\{\d+\}/g,function(e){var t=+e.slice(1,-1)+n;return t<r.length?A(r[t]):e}),a+=`
164
- http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.length;c++,s=`&`)a+=s+`p`+(c-n)+`=`+encodeURIComponent(A(r[c]));return new t(a)}}var M=j(`$parse`);function N(e){return e+``}var P=O();d(`+ - * / % === !== == != < > <= >= && || ?? ! = | ?`.split(` `),function(e){P[e]=!0});var ee={n:`
165
- `,f:`\f`,r:`\r`,t:` `,v:`\v`,"'":`'`,'"':`"`};function F(e){this.options=e||{}}F.prototype={constructor:F,lex:function(e){for(this.text=e,this.index=0,this.tokens=[];this.index<this.text.length;){var t=this.text.charAt(this.index);if(t===`"`||t===`'`||t==="`")this.readString(t);else if(this.isNumber(t)||t===`.`&&this.isNumber(this.peek()))this.readNumber();else if(this.isIdentifierStart(this.peekMultichar()))this.readIdent();else if(this.is(t,`(){}[].,;:`))this.tokens.push({index:this.index,text:t}),this.index++;else if(this.isWhitespace(t))this.index++;else{var n=t+this.peek(),r=n+this.peek(2),i=P[t],a=P[n],o=P[r];if(i||a||o){var s=o?r:a?n:t;this.tokens.push({index:this.index,text:s,operator:!0}),this.index+=s.length}else this.throwError(`Unexpected next character `,this.index,this.index+1)}}return this.tokens},is:function(e,t){return t.indexOf(e)!==-1},peek:function(e){var t=e||1;return this.index+t<this.text.length?this.text.charAt(this.index+t):!1},isNumber:function(e){return e>=`0`&&e<=`9`&&typeof e==`string`},isWhitespace:function(e){return e===` `||e===`\r`||e===` `||e===`
166
- `||e===`\v`||e===`\xA0`},isIdentifierStart:function(e){return this.options.isIdentifierStart?this.options.isIdentifierStart(e,this.codePointAt(e)):this.isValidIdentifierStart(e)},isValidIdentifierStart:function(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`||e===`$`},isIdentifierContinue:function(e){return this.options.isIdentifierContinue?this.options.isIdentifierContinue(e,this.codePointAt(e)):this.isValidIdentifierContinue(e)},isValidIdentifierContinue:function(e,t){return this.isValidIdentifierStart(e,t)||this.isNumber(e)},codePointAt:function(e){return e.length===1?e.charCodeAt(0):(e.charCodeAt(0)<<10)+e.charCodeAt(1)-56613888},peekMultichar:function(){var e=this.text.charAt(this.index),t=this.peek();if(!t)return e;var n=e.charCodeAt(0),r=t.charCodeAt(0);return n>=55296&&n<=56319&&r>=56320&&r<=57343?e+t:e},isExpOperator:function(e){return e===`-`||e===`+`||this.isNumber(e)},throwError:function(e,t,n){throw n=n||this.index,M(`lexerr`,`Lexer Error: {0} at column{1} in expression [{2}].`,e,h(t)?`s `+t+`-`+this.index+` [`+this.text.substring(t,n)+`]`:` `+n,this.text)},readNumber:function(){for(var e=``,t=this.index;this.index<this.text.length;){var n=r(this.text.charAt(this.index));if(n===`.`||this.isNumber(n))e+=n;else{var i=this.peek();if(n===`e`&&this.isExpOperator(i))e+=n;else if(this.isExpOperator(n)&&i&&this.isNumber(i)&&e.charAt(e.length-1)===`e`)e+=n;else if(this.isExpOperator(n)&&(!i||!this.isNumber(i))&&e.charAt(e.length-1)===`e`)this.throwError(`Invalid exponent`);else break}this.index++}this.tokens.push({index:t,text:e,constant:!0,value:Number(e)})},readIdent:function(){var e=this.index;for(this.index+=this.peekMultichar().length;this.index<this.text.length;){var t=this.peekMultichar();if(!this.isIdentifierContinue(t))break;this.index+=t.length}this.tokens.push({index:e,text:this.text.slice(e,this.index),identifier:!0})},readString:function(e){var t=this.index;this.index++;for(var n=``,r=e,i=e==="`",a=!1;this.index<this.text.length;){var o=this.text.charAt(this.index);if(i&&o===`$`&&this.text.charAt(this.index+1)===`{`){this.tokens.push({index:t,text:r,constant:!0,value:n});var s=this.text.indexOf(`}`,this.index),c=this.text.substr(this.index+2,s-this.index-2);this.tokens.push({index:this.index,text:`+`,operator:!0});for(var l=new F(this.options).lex(c),u=0,d=l.length;u<d;u++)this.tokens.push(l[u]);this.tokens.push({index:this.index,text:`+`,operator:!0}),this.index=s,this.readString("`");return}if(r+=o,a){if(o===`u`){var f=this.text.substring(this.index+1,this.index+5);f.match(/[\da-f]{4}/i)||this.throwError(`Invalid unicode escape [\\u`+f+`]`),this.index+=4,n+=String.fromCharCode(parseInt(f,16))}else{var p=ee[o];n+=p||o}a=!1}else if(o===`\\`)a=!0;else if(o===e){this.index++,this.tokens.push({index:t,text:r,constant:!0,value:n});return}else n+=o;this.index++}this.throwError(`Unterminated quote`,t)}};function I(e,t){this.lexer=e,this.options=t}I.Program=`Program`,I.ExpressionStatement=`ExpressionStatement`,I.AssignmentExpression=`AssignmentExpression`,I.ConditionalExpression=`ConditionalExpression`,I.LogicalExpression=`LogicalExpression`,I.BinaryExpression=`BinaryExpression`,I.UnaryExpression=`UnaryExpression`,I.CallExpression=`CallExpression`,I.MemberExpression=`MemberExpression`,I.Identifier=`Identifier`,I.Literal=`Literal`,I.ArrayExpression=`ArrayExpression`,I.Property=`Property`,I.ObjectExpression=`ObjectExpression`,I.ThisExpression=`ThisExpression`,I.LocalsExpression=`LocalsExpression`,I.NGValueParameter=`NGValueParameter`,I.prototype={ast:function(e){this.text=e,this.tokens=this.lexer.lex(e);var t=this.program();return this.tokens.length!==0&&this.throwError(`is an unexpected token`,this.tokens[0]),t},program:function(){for(var e=[];;)if(this.tokens.length>0&&!this.peek(`}`,`)`,`;`,`]`)&&e.push(this.expressionStatement()),!this.expect(`;`))return{type:I.Program,body:e}},expressionStatement:function(){return{type:I.ExpressionStatement,expression:this.filterChain()}},filterChain:function(){for(var e=this.expression();this.expect(`|`);)e=this.filter(e);return e},expression:function(){return this.assignment()},assignment:function(){var e=this.ternary();if(this.expect(`=`)){if(!B(e))throw M(`lval`,`Trying to assign a value to a non l-value`);e={type:I.AssignmentExpression,left:e,right:this.assignment(),operator:`=`}}return e},ternary:function(){var e=this.nullishCoalescing(),t,n;return this.expect(`?`)&&(t=this.expression(),this.consume(`:`))?(n=this.expression(),{type:I.ConditionalExpression,test:e,alternate:t,consequent:n}):e},nullishCoalescing:function(){for(var e=this.logicalOR();this.expect(`??`);)e={type:I.LogicalExpression,operator:`??`,left:e,right:this.logicalOR()};return e},logicalOR:function(){for(var e=this.logicalAND();this.expect(`||`);)e={type:I.LogicalExpression,operator:`||`,left:e,right:this.logicalAND()};return e},logicalAND:function(){for(var e=this.equality();this.expect(`&&`);)e={type:I.LogicalExpression,operator:`&&`,left:e,right:this.equality()};return e},equality:function(){for(var e=this.relational(),t;t=this.expect(`==`,`!=`,`===`,`!==`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.relational()};return e},relational:function(){for(var e=this.additive(),t;t=this.expect(`<`,`>`,`<=`,`>=`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.additive()};return e},additive:function(){for(var e=this.multiplicative(),t;t=this.expect(`+`,`-`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.multiplicative()};return e},multiplicative:function(){for(var e=this.unary(),t;t=this.expect(`*`,`/`,`%`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.unary()};return e},unary:function(){var e;return(e=this.expect(`+`,`-`,`!`))?{type:I.UnaryExpression,operator:e.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var e;this.expect(`(`)?(e=this.filterChain(),this.consume(`)`)):this.expect(`[`)?e=this.arrayDeclaration():this.expect(`{`)?e=this.object():this.selfReferential.hasOwnProperty(this.peek().text)?e=E(this.selfReferential[this.consume().text]):this.options.literals.hasOwnProperty(this.peek().text)?e={type:I.Literal,value:this.options.literals[this.consume().text]}:this.peek().identifier?e=this.identifier():this.peek().constant?e=this.constant():this.throwError(`not a primary expression`,this.peek());for(var t;t=this.expect(`(`,`[`,`.`);)t.text===`(`?(e={type:I.CallExpression,callee:e,arguments:this.parseArguments()},this.consume(`)`)):t.text===`[`?(e={type:I.MemberExpression,object:e,property:this.expression(),computed:!0},this.consume(`]`)):t.text===`.`?e={type:I.MemberExpression,object:e,property:this.identifier(),computed:!1}:this.throwError(`IMPOSSIBLE`);return e},filter:function(e){for(var t=[e],n={type:I.CallExpression,callee:this.identifier(),arguments:t,filter:!0};this.expect(`:`);)t.push(this.expression());return n},parseArguments:function(){var e=[];if(this.peekToken().text!==`)`)do e.push(this.filterChain());while(this.expect(`,`));return e},identifier:function(){var e=this.consume();return e.identifier||this.throwError(`is not a valid identifier`,e),{type:I.Identifier,name:e.text}},constant:function(){return{type:I.Literal,value:this.consume().value}},arrayDeclaration:function(){var e=[];if(this.peekToken().text!==`]`)do{if(this.peek(`]`))break;e.push(this.expression())}while(this.expect(`,`));return this.consume(`]`),{type:I.ArrayExpression,elements:e}},object:function(){var e=[],t;if(this.peekToken().text!==`}`)do{if(this.peek(`}`))break;t={type:I.Property,kind:`init`},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)}while(this.expect(`,`));return this.consume(`}`),{type:I.ObjectExpression,properties:e}},throwError:function(e,t){throw M(`syntax`,`Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].`,t.text,e,t.index+1,this.text,this.text.substring(t.index))},consume:function(e){if(this.tokens.length===0)throw M(`ueoe`,`Unexpected end of expression: {0}`,this.text);var t=this.expect(e);return t||this.throwError(`is unexpected, expecting [`+e+`]`,this.peek()),t},peekToken:function(){if(this.tokens.length===0)throw M(`ueoe`,`Unexpected end of expression: {0}`,this.text);return this.tokens[0]},peek:function(e,t,n,r){return this.peekAhead(0,e,t,n,r)},peekAhead:function(e,t,n,r,i){if(this.tokens.length>e){var a=this.tokens[e],o=a.text;if(o===t||o===n||o===r||o===i||!t&&!n&&!r&&!i)return a}return!1},expect:function(e,t,n,r){var i=this.peek(e,t,n,r);return i?(this.tokens.shift(),i):!1}};function L(e,t){return e===void 0?t:e}function R(e,t){return e===void 0?t:t===void 0?e:e+t}function te(e,t){var n=e(t);if(!n)throw Error(`Filter '`+t+`' is not defined`);return!n.$stateful}function z(e,t){var n,r,i;switch(e.type){case I.Program:n=!0,d(e.body,function(e){z(e.expression,t),n=n&&e.expression.constant}),e.constant=n;break;case I.Literal:e.constant=!0,e.toWatch=[];break;case I.UnaryExpression:z(e.argument,t),e.constant=e.argument.constant,e.toWatch=e.argument.toWatch;break;case I.BinaryExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=e.left.toWatch.concat(e.right.toWatch);break;case I.LogicalExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=e.constant?[]:[e];break;case I.ConditionalExpression:z(e.test,t),z(e.alternate,t),z(e.consequent,t),e.constant=e.test.constant&&e.alternate.constant&&e.consequent.constant,e.toWatch=e.constant?[]:[e];break;case I.Identifier:e.constant=!1,e.toWatch=[e];break;case I.MemberExpression:z(e.object,t),e.computed&&z(e.property,t),e.constant=e.object.constant&&(!e.computed||e.property.constant),e.toWatch=[e];break;case I.CallExpression:i=e.filter?te(t,e.callee.name):!1,n=i,r=[],d(e.arguments,function(e){z(e,t),n=n&&e.constant,e.constant||r.push.apply(r,e.toWatch)}),e.constant=n,e.toWatch=i?r:[e];break;case I.AssignmentExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=[e];break;case I.ArrayExpression:n=!0,r=[],d(e.elements,function(e){z(e,t),n=n&&e.constant,e.constant||r.push.apply(r,e.toWatch)}),e.constant=n,e.toWatch=r;break;case I.ObjectExpression:n=!0,r=[],d(e.properties,function(e){z(e.value,t),n=n&&e.value.constant&&!e.computed,e.value.constant||r.push.apply(r,e.value.toWatch)}),e.constant=n,e.toWatch=r;break;case I.ThisExpression:e.constant=!1,e.toWatch=[];break;case I.LocalsExpression:e.constant=!1,e.toWatch=[];break}}function ne(e){if(e.length===1){var t=e[0].expression,n=t.toWatch;return n.length===1&&n[0]===t?void 0:n}}function B(e){return e.type===I.Identifier||e.type===I.MemberExpression}function V(e){if(e.body.length===1&&B(e.body[0].expression))return{type:I.AssignmentExpression,left:e.body[0].expression,right:{type:I.NGValueParameter},operator:`=`}}function H(e){return e.body.length===0||e.body.length===1&&(e.body[0].expression.type===I.Literal||e.body[0].expression.type===I.ArrayExpression||e.body[0].expression.type===I.ObjectExpression)}function re(e){return e.constant}function ie(e,t){this.astBuilder=e,this.$filter=t}ie.prototype={compile:function(e){var t=this,n=this.astBuilder.ast(e);this.state={nextId:0,filters:{},fn:{vars:[],body:[],own:{}},assign:{vars:[],body:[],own:{}},inputs:[]},z(n,t.$filter);var r=``,i;if(this.stage=`assign`,i=V(n)){this.state.computing=`assign`;var o=this.nextId();this.recurse(i,o),this.return_(o),r=`fn.assign=`+this.generateFunction(`assign`,`s,v,l`)}var s=ne(n.body);t.stage=`inputs`,d(s,function(e,n){var r=`fn`+n;t.state[r]={vars:[],body:[],own:{}},t.state.computing=r;var i=t.nextId();t.recurse(e,i),t.return_(i),t.state.inputs.push(r),e.watchId=n}),this.state.computing=`fn`,this.stage=`main`,this.recurse(n);var c=`"`+this.USE+` `+this.STRICT+`";
167
- `+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,N,L,R),u=function(e,t,n,r){return a(function(){return l(e,t,n,r)})};return u.assign=function(e,t,n){return a(function(){return l.assign(e,t,n)})},u.inputs=l.inputs,this.state=this.stage=void 0,u.ast=n,u.literal=H(n),u.constant=re(n),u},USE:`use`,STRICT:`strict`,watchFns:function(){var e=[],t=this.state.inputs,n=this;return d(t,function(t){e.push(`var `+t+`=`+n.generateFunction(t,`s`))}),t.length&&e.push(`fn.inputs=[`+t.join(`,`)+`];`),e.join(``)},generateFunction:function(e,t){return`function(`+t+`){`+this.varsPrefix(e)+this.body(e)+`};`},filterPrefix:function(){var e=[],t=this;return d(this.state.filters,function(n,r){e.push(n+`=$filter(`+t.escape(r)+`)`)}),e.length?`var `+e.join(`,`)+`;`:``},varsPrefix:function(e){return this.state[e].vars.length?`var `+this.state[e].vars.join(`,`)+`;`:``},body:function(e){return this.state[e].body.join(``)},recurse:function(e,t,n,r,i,a){var o,s,c=this,l,u,f;if(r=r||p,!a&&h(e.watchId)){t=t||this.nextId(),this.if_(`i`,this.lazyAssign(t,this.unsafeComputedMember(`i`,e.watchId)),this.lazyRecurse(e,t,n,r,i,!0));return}switch(e.type){case I.Program:d(e.body,function(t,n){c.recurse(t.expression,void 0,void 0,function(e){s=e}),n===e.body.length-1?c.return_(s):c.current().body.push(s,`;`)});break;case I.Literal:u=this.escape(e.value),this.assign(t,u),r(t||u);break;case I.UnaryExpression:this.recurse(e.argument,void 0,void 0,function(e){s=e}),u=e.operator+`(`+this.ifDefined(s,0)+`)`,this.assign(t,u),r(u);break;case I.BinaryExpression:this.recurse(e.left,void 0,void 0,function(e){o=e}),this.recurse(e.right,void 0,void 0,function(e){s=e}),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);break;case I.LogicalExpression: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);break;case I.ConditionalExpression:t=t||this.nextId(),c.recurse(e.test,t),c.if_(t,c.lazyRecurse(e.alternate,t),c.lazyRecurse(e.consequent,t)),r(t);break;case I.Identifier:t=t||this.nextId();var m=c.current().inAssignment;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(){c.if_(c.stage===`inputs`||`s`,function(){var n=c.nextId();c.assign(n,c.nonComputedMember(`s`,e.name)),c.if_(c.or_(c.isNull(n),c.hasOwnProperty_(`s`,e.name)),function(){i&&i!==1?(c.if_(c.isNull(n),c.lazyAssign(c.nonComputedMember(`s`,e.name),`{}`)),c.assign(t,c.nonComputedMember(`s`,e.name))):c.assign(t,n)})})},t&&function(){c.if_(c.hasOwnProperty_(`l`,e.name),c.lazyAssign(t,c.nonComputedMember(`l`,e.name)))}),r(t);break;case I.MemberExpression:o=n&&(n.context=this.nextId())||this.nextId(),t=t||this.nextId(),c.recurse(e.object,o,void 0,function(){var a=null,l=c.current().inAssignment;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===I.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(){e.computed?(e.property.type!==I.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))},function(){c.assign(t,`undefined`)}),r(t)},!!i);break;case I.CallExpression:t=t||this.nextId(),e.filter?(s=c.filter(e.callee.name),l=[],d(e.arguments,function(e){var t=c.nextId();c.recurse(e,t),l.push(t)}),u=s+`.call(`+s+`,`+l.join(`,`)+`)`,c.assign(t,u),r(t)):(s=c.nextId(),o={},l=[],c.recurse(e.callee,s,o,function(){c.if_(c.notNull(s),function(){d(e.arguments,function(t){c.recurse(t,e.constant?void 0:c.nextId(),void 0,function(e){l.push(e)})}),u=o.name?`(`+c.member(o.context,o.name,o.computed)+` === null ? null : `+c.unsafeMember(o.context,o.name,o.computed)+`.call(`+[o.context].concat(l).join(`,`)+`))`:s+`(`+l.join(`,`)+`)`,c.assign(t,u)},function(){c.assign(t,`undefined`)}),r(t)}));break;case I.AssignmentExpression:s=this.nextId(),o={},c.current().inAssignment=!0,this.recurse(e.left,void 0,o,function(){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(){c.recurse(e.right,s),u=c.member(o.context,o.name,o.computed)+e.operator+s,c.assign(t,u),r(t||u)}),c.current().inAssignment=!1,c.recurse(e.right,s),c.current().inAssignment=!0},1),c.current().inAssignment=!1;break;case I.ArrayExpression:l=[],d(e.elements,function(t){c.recurse(t,e.constant?void 0:c.nextId(),void 0,function(e){l.push(e)})}),u=`[`+l.join(`,`)+`]`,this.assign(t,u),r(t||u);break;case I.ObjectExpression:l=[],f=!1,d(e.properties,function(e){e.computed&&(f=!0)}),f?(t=t||this.nextId(),this.assign(t,`{}`),d(e.properties,function(e){e.computed?(o=c.nextId(),c.recurse(e.key,o)):o=e.key.type===I.Identifier?e.key.name:``+e.key.value,s=c.nextId(),c.recurse(e.value,s),c.assign(c.unsafeMember(t,o,e.computed),s)})):(d(e.properties,function(t){c.recurse(t.value,e.constant?void 0:c.nextId(),void 0,function(e){l.push(c.escape(t.key.type===I.Identifier?t.key.name:``+t.key.value)+`:`+e)})}),u=`{`+l.join(`,`)+`}`,this.assign(t,u)),r(t||u);break;case I.ThisExpression:this.assign(t,`s`),r(t||`s`);break;case I.LocalsExpression:this.assign(t,`l`),r(t||`l`);break;case I.NGValueParameter:this.assign(t,`v`),r(t||`v`);break}},getHasOwnProperty:function(e,t){var n=e+`.`+t,r=this.current().own;return r.hasOwnProperty(n)||(r[n]=this.nextId(!1,e+`&&(`+this.escape(t)+` in `+e+`)`)),r[n]},assign:function(e,t){if(e)return this.current().body.push(e,`=`,t,`;`),e},filter:function(e){return n.call(this.state.filters,e)||(this.state.filters[e]=this.nextId(!0)),this.state.filters[e]},ifDefined:function(e,t){return`ifDefined(`+e+`,`+this.escape(t)+`)`},plus:function(e,t){return`plus(`+e+`,`+t+`)`},return_:function(e){this.current().body.push(`return `,e,`;`)},if_:function(e,t,n){if(e===!0)t();else{var r=this.current().body;r.push(`if(`,e,`){`),t(),r.push(`}`),n&&(r.push(`else{`),n(),r.push(`}`))}},or_:function(e,t){return`(`+e+`) || (`+t+`)`},hasOwnProperty_:function(e,t,n){return n?`(Object.prototype.hasOwnProperty.call(`+e+`,`+t+`))`:`(Object.prototype.hasOwnProperty.call(`+e+`,'`+t+`'))`},and_:function(e,t){return`(`+e+`) && (`+t+`)`},not:function(e){return`!(`+e+`)`},isNull:function(e){return e+`==null`},notNull:function(e){return e+`!=null`},nonComputedMember:function(e,t){var n=/^[$_a-zA-Z][$_a-zA-Z0-9]*$/,r=/[^$_a-zA-Z0-9]/g,i=``;return n.test(t)?i=e+`.`+t:(t=t.replace(r,this.stringEscapeFn),i=e+`["`+t+`"]`),i},unsafeComputedMember:function(e,t){return e+`[`+t+`]`},unsafeNonComputedMember:function(e,t){return this.nonComputedMember(e,t)},computedMember:function(e,t){return this.state.computing===`assign`?this.unsafeComputedMember(e,t):`(`+e+`.hasOwnProperty(`+t+`) ? `+e+`[`+t+`] : undefined)`},unsafeMember:function(e,t,n){return n?this.unsafeComputedMember(e,t):this.unsafeNonComputedMember(e,t)},member:function(e,t,n){return n?this.computedMember(e,t):this.nonComputedMember(e,t)},getStringValue:function(e){this.assign(e,`getStringValue(`+e+`)`)},lazyRecurse:function(e,t,n,r,i,a){var o=this;return function(){o.recurse(e,t,n,r,i,a)}},lazyAssign:function(e,t){var n=this;return function(){n.assign(e,t)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(e){return`\\u`+(`0000`+e.charCodeAt(0).toString(16)).slice(-4)},escape:function(e){if(v(e))return`'`+e.replace(this.stringEscapeRegex,this.stringEscapeFn)+`'`;if(y(e))return e.toString();if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e===void 0)return`undefined`;throw M(`esc`,`IMPOSSIBLE`)},nextId:function(e,t){var n=`v`+ this.state.nextId++;return e||this.current().vars.push(n+(t?`=`+t:``)),n},current:function(){return this.state[this.state.computing]}};function ae(e,t){this.astBuilder=e,this.$filter=t}ae.prototype={compile:function(e){var t=this,n=this.astBuilder.ast(e);z(n,t.$filter);var r,i;(r=V(n))&&(i=this.recurse(r));var o=ne(n.body),s;o&&(s=[],d(o,function(e,n){var r=t.recurse(e);e.input=r,s.push(r),e.watchId=n}));var c=[];d(n.body,function(e){c.push(t.recurse(e.expression))});var l=n.body.length===0?p:n.body.length===1?c[0]:function(e,t){var n;return d(c,function(r){n=r(e,t)}),n};i&&(l.assign=function(e,t,n){return i(e,n,t)});var u=function(e,t){return a(function(){return l(e,t)})};return u.assign=function(e,t,n){return a(function(){return l.assign(e,t,n)})},s&&(u.inputs=s),u.ast=n,u.literal=H(n),u.constant=re(n),u},recurse:function(e,t,n){var r,i,a=this,o;if(e.input)return this.inputs(e.input,e.watchId);switch(e.type){case I.Literal:return this.value(e.value,t);case I.UnaryExpression:return i=this.recurse(e.argument),this[`unary`+e.operator](i,t);case I.BinaryExpression:return r=this.recurse(e.left),i=this.recurse(e.right),this[`binary`+e.operator](r,i,t);case I.LogicalExpression:return r=this.recurse(e.left),i=this.recurse(e.right),this[`binary`+e.operator](r,i,t);case I.ConditionalExpression:return this[`ternary?:`](this.recurse(e.test),this.recurse(e.alternate),this.recurse(e.consequent),t);case I.Identifier:return a.identifier(e.name,t,n);case I.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);case I.CallExpression:return o=[],d(e.arguments,function(e){o.push(a.recurse(e))}),e.filter&&(i=this.$filter(e.callee.name)),e.filter||(i=this.recurse(e.callee,!0)),e.filter?function(e,n,r,a){for(var s=[],c=0;c<o.length;++c)s.push(o[c](e,n,r,a));var l=i.apply(void 0,s,a);return t?{context:void 0,name:void 0,value:l}:l}:function(e,n,r,a){var s=i(e,n,r,a),c;if(s.value!=null){for(var l=[],u=0;u<o.length;++u)l.push(o[u](e,n,r,a));c=s.value.apply(s.context,l)}return t?{value:c}:c};case I.AssignmentExpression:return r=this.recurse(e.left,!0,1),i=this.recurse(e.right),function(e,n,a,o){var s=r(e,!1,a,o),c=i(e,n,a,o);return s.context[s.name]=c,t?{value:c}:c};case I.ArrayExpression:return o=[],d(e.elements,function(e){o.push(a.recurse(e))}),function(e,n,r,i){for(var a=[],s=0;s<o.length;++s)a.push(o[s](e,n,r,i));return t?{value:a}:a};case I.ObjectExpression:return o=[],d(e.properties,function(e){e.computed?o.push({key:a.recurse(e.key),computed:!0,value:a.recurse(e.value)}):o.push({key:e.key.type===I.Identifier?e.key.name:``+e.key.value,computed:!1,value:a.recurse(e.value)})}),function(e,n,r,i){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);return t?{value:a}:a};case I.ThisExpression:return function(e){return t?{value:e}:e};case I.LocalsExpression:return function(e,n){return t?{value:n}:n};case I.NGValueParameter:return function(e,n,r){return t?{value:r}:r}}},"unary+":function(e,t){return function(n,r,i,a){var o=e(n,r,i,a);return o=h(o)?+o:0,t?{value:o}:o}},"unary-":function(e,t){return function(n,r,i,a){var o=e(n,r,i,a);return o=h(o)?-o:-0,t?{value:o}:o}},"unary!":function(e,t){return function(n,r,i,a){var o=!e(n,r,i,a);return t?{value:o}:o}},"binary+":function(e,t,n){return function(r,i,a,o){var s=R(e(r,i,a,o),t(r,i,a,o));return n?{value:s}:s}},"binary-":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o),c=t(r,i,a,o),l=(h(s)?s:0)-(h(c)?c:0);return n?{value:l}:l}},"binary*":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)*t(r,i,a,o);return n?{value:s}:s}},"binary/":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)/t(r,i,a,o);return n?{value:s}:s}},"binary%":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)%t(r,i,a,o);return n?{value:s}:s}},"binary===":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)===t(r,i,a,o);return n?{value:s}:s}},"binary!==":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)!==t(r,i,a,o);return n?{value:s}:s}},"binary==":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)==t(r,i,a,o);return n?{value:s}:s}},"binary!=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)!=t(r,i,a,o);return n?{value:s}:s}},"binary<":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)<t(r,i,a,o);return n?{value:s}:s}},"binary>":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)>t(r,i,a,o);return n?{value:s}:s}},"binary<=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)<=t(r,i,a,o);return n?{value:s}:s}},"binary>=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)>=t(r,i,a,o);return n?{value:s}:s}},"binary&&":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)&&t(r,i,a,o);return n?{value:s}:s}},"binary||":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)||t(r,i,a,o);return n?{value:s}:s}},"binary??":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o),c=s!=null&&s!==void 0?s:t(r,i,a,o);return n?{value:c}:c}},"ternary?:":function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s)?t(i,a,o,s):n(i,a,o,s);return r?{value:c}:c}},value:function(e,t){return function(){return t?{context:void 0,name:void 0,value:e}:e}},identifier:function(e,t,r){return function(i,a){var o=a&&e in a?a:i;r&&r!==1&&o&&o[e]==null&&(o[e]={});var s;return o&&n.call(o,e)&&(s=o?o[e]:void 0),t?{context:o,name:e,value:s}:s}},computedMember:function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s),l,u;return c!=null&&(l=t(i,a,o,s),l=N(l),r&&r!==1&&c&&!c[l]&&(c[l]={}),Object.prototype.hasOwnProperty.call(c,l)&&(u=c[l])),n?{context:c,name:l,value:u}:u}},nonComputedMember:function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s);r&&r!==1&&c&&c[t]==null&&(c[t]={});var l=void 0;return c!=null&&Object.prototype.hasOwnProperty.call(c,t)&&(l=c[t]),n?{context:c,name:t,value:l}:l}},inputs:function(e,t){return function(n,r,i,a){return a?a[t]:e(n,r,i)}}};var U=function(e,t,n){this.lexer=e,this.$filter=t,n=n||{},n.handleThis=n.handleThis==null?!0:n.handleThis,this.options=n,this.ast=new I(e,n),this.ast.selfReferential={$locals:{type:I.LocalsExpression}},n.handleThis&&(this.ast.selfReferential.this={type:I.ThisExpression}),this.astCompiler=n.csp?new ae(this.ast,t):new ie(this.ast,t)};U.prototype={constructor:U,parse:function(e){return this.astCompiler.compile(e)}},e.Lexer=F,e.Parser=U})),xe=e.t((e=>{var t=be(),n={},r=t.Lexer,i=t.Parser;function a(e){return e=e||{},e.filters&&(e.cache=e.cache||{}),e.cache=e.cache||s.cache,e.filters=e.filters||n,e}function o(e){return{handleThis:e.handleThis==null?!0:e.handleThis,csp:e.csp==null?!1:e.csp,literals:e.literals==null?{true:!0,false:!1,null:null,undefined:void 0}:e.literals}}function s(e,t){if(typeof e!=`string`)throw TypeError(`src must be a string, instead saw '`+typeof e+`'`);t=a(t);var n=t,s=o(t),c=new i(new r(n),function(e){return t.filters[e]},s);if(!t.cache)return c.parse(e);delete t.src;var l=JSON.stringify(Object.assign({src:e},t)),u=t.cache[l];return u||(u=t.cache[l]=c.parse(e)),u}s.cache=Object.create(null),e.compile=s}))();const Se=(e,t)=>{let n=[];e!==void 0&&!Array.isArray(e)&&n.push(`deeds is not an array, the host ignores it`);let r=[];for(let[i,a]of(Array.isArray(e)?e:[]).entries()){if(a==null||typeof a.id!=`string`){n.push(`deed ${i} has no string id, the host drops it`);continue}if(t===`checkpoint`){r.push({id:a.id,value:a.value});continue}a.value===void 0||a.value===null||r.push({id:a.id,value:typeof a.value==`number`?Math.floor(a.value):a.value,persist:a.persist===!0})}if(t===`checkpoint`)return{deeds:r,warnings:n};let i=r.filter(e=>e.persist),a=r.filter(e=>!e.persist),o=i.splice(3);return o.length&&n.push(`only 3 persisted deeds are kept, dropped: ${o.map(e=>e.id).join(`, `)}`),{deeds:[...i,...a].map(({id:e,value:t})=>({id:e,value:t})),warnings:n}},Ce=e=>{let t={};for(let n of e)n.value!==void 0&&(t[Ee(n.id)]=n.value);return t},we=(e,t)=>{try{if(e.filterExp&&!(0,xe.compile)(e.filterExp)(t)||!e.incrementExp)return{complete:!1,value:0};let n=(0,xe.compile)(e.incrementExp)(t);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}`);let r=Math.floor(n);return{complete:r>=(e.targetCount||1),value:r}}catch(e){return{complete:!1,value:0,error:e.message}}},Te=e=>{let{items:t,scope:n,mode:r}=e,i=Math.min(Math.max(e.index,0),t.length),a;for(;i<t.length&&(a=we(t[i],n),!(!a.complete||r===`checkpoint`&&!t[i].liveUpdate));i++);return{index:i,head:i<t.length?a:void 0}};var Ee=e=>e.replace(/-./g,e=>e[1].toUpperCase());function De(e){let t=new Map,n=new Set,r=null,i=0,a,o=[],s=e=>{var t;return`simulator-checklist:${(t=r)==null?`game`:t}:${e}`},c=e=>{try{let t=Number(localStorage.getItem(s(e.stableID)))||0;return Math.min(Math.max(t,0),e.items.length)}catch(e){return 0}},l=(e,t)=>{try{t===0?localStorage.removeItem(s(e)):localStorage.setItem(s(e),String(t))}catch(e){}},u=(e,t,r,i)=>{var a;let o=r<i.index?`done`:r===i.index?`active`:`upcoming`,s=`${e.stableID}:${r}`,c=n.has(s),l=!!t.expandMD&&o!==`done`,u=t.targetCount||1,d=o===`active`&&i.head?`${Math.min(i.head.value,u)}/${u}`:``,f=[t.incrementExp&&`increment: ${t.incrementExp}`,t.filterExp&&`filter: ${t.filterExp}`,`target: ${u}`,t.liveUpdate?`liveUpdate: checkpoints + completion`:`completion only`].filter(Boolean).join(`
163
+ `},bind(t){let n=t.getElement(`#simulator-checkpoints-clear`),i=t.getElement(`#simulator-checkpoints-list`);n==null||n.addEventListener(`click`,()=>{e=[],i&&(i.innerHTML=r()),t.updateBadge(`checkpoints`,0)})},onMessage(n,i,a){if(n!==`HIT_CHECKPOINT`)return;let o={checkpointName:i.checkpointName,augConfig:i.augConfig,time:t()};e.push(o),a.updateBadge(`checkpoints`,e.length);let s=a.getElement(`#simulator-checkpoints-list`);s&&(s.innerHTML=r(),s.scrollTop=s.scrollHeight)}}}var be=e.t((e=>{var t={document:{}},n=Object.prototype.hasOwnProperty,r=function(e){return v(e)?e.toLowerCase():e},i=Array.isArray;function a(e){var t=Function.prototype.constructor;delete Function.prototype.constructor;var n=e();return Function.prototype.constructor=t,n}var o,s=Object.prototype.toString,c=Object.getPrototypeOf,l=A(`ng`);function u(e){if(e==null||x(e))return!1;if(i(e)||v(e)||o&&e instanceof o)return!0;var t=`length`in Object(e)&&e.length;return y(t)&&(t>=0&&(t-1 in e||e instanceof Array)||typeof e.item==`function`)}function d(e,t,r){var a,o;if(e)if(b(e))for(a in e)a!==`prototype`&&a!==`length`&&a!==`name`&&e.hasOwnProperty(a)&&t.call(r,e[a],a,e);else if(i(e)||u(e)){var s=typeof e!=`object`;for(a=0,o=e.length;a<o;a++)(s||a in e)&&t.call(r,e[a],a,e)}else if(e.forEach&&e.forEach!==d)e.forEach(t,r,e);else if(_(e))for(a in e)t.call(r,e[a],a,e);else if(typeof e.hasOwnProperty==`function`)for(a in e)e.hasOwnProperty(a)&&t.call(r,e[a],a,e);else for(a in e)n.call(e,a)&&t.call(r,e[a],a,e);return e}function f(e,t){t?e.$$hashKey=t:delete e.$$hashKey}function p(){}function m(e){return e===void 0}function h(e){return e!==void 0}function g(e){return typeof e==`object`&&!!e}function _(e){return typeof e==`object`&&!!e&&!c(e)}function v(e){return typeof e==`string`}function y(e){return typeof e==`number`}function b(e){return typeof e==`function`}function x(e){return e&&e.window===e}function S(e){return e&&e.$evalAsync&&e.$watch}var C=/^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;function w(e){return e&&y(e.length)&&C.test(s.call(e))}function T(e){return s.call(e)===`[object ArrayBuffer]`}function E(e,t){var r=[],a=[];if(t){if(w(t)||T(t))throw l(`cpta`,`Can't copy! TypedArray destination cannot be mutated.`);if(e===t)throw l(`cpi`,`Can't copy! Source and destination are identical.`);return i(t)?t.length=0:d(t,function(e,n){n!==`$$hashKey`&&delete t[n]}),r.push(e),a.push(t),o(e,t)}return u(e);function o(e,t){var r=t.$$hashKey,a;if(i(e))for(var o=0,s=e.length;o<s;o++)t.push(u(e[o]));else if(_(e))for(a in e)t[a]=u(e[a]);else if(e&&typeof e.hasOwnProperty==`function`)for(a in e)e.hasOwnProperty(a)&&(t[a]=u(e[a]));else for(a in e)n.call(e,a)&&(t[a]=u(e[a]));return f(t,r),t}function u(e){if(!g(e))return e;var t=r.indexOf(e);if(t!==-1)return a[t];if(x(e)||S(e))throw l(`cpws`,`Can't copy! Making copies of Window or Scope instances is not supported.`);var n=!1,s=p(e);return s===void 0&&(s=i(e)?[]:Object.create(c(e)),n=!0),r.push(e),a.push(s),n?o(e,s):s}function p(e){switch(s.call(e)){case`[object Int8Array]`:case`[object Int16Array]`:case`[object Int32Array]`:case`[object Float32Array]`:case`[object Float64Array]`:case`[object Uint8Array]`:case`[object Uint8ClampedArray]`:case`[object Uint16Array]`:case`[object Uint32Array]`:return new e.constructor(u(e.buffer),e.byteOffset,e.length);case`[object ArrayBuffer]`:if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case`[object Boolean]`:case`[object Number]`:case`[object String]`:case`[object Date]`:return new e.constructor(e.valueOf());case`[object RegExp]`:var n=new RegExp(e.source,e.toString().match(/[^\/]*$/)[0]);return n.lastIndex=e.lastIndex,n;case`[object Blob]`:return new e.constructor([e],{type:e.type})}if(b(e.cloneNode))return e.cloneNode(!0)}}function D(e,n){var r=n;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}function ee(){return Object.create(null)}function O(e){var t=[];return JSON.stringify(e,function(e,n){if(n=D(e,n),g(n)){if(t.indexOf(n)>=0)return`...`;t.push(n)}return n})}function k(e){return typeof e==`function`?e.toString().replace(/ \{[\s\S]*$/,``):m(e)?`undefined`:typeof e==`string`?e:O(e)}function A(e,t){return t=t||Error,function(){var n=2,r=arguments,i=r[0],a=`[`+(e?e+`:`:``)+i+`] `,o=r[1],s,c;for(a+=o.replace(/\{\d+\}/g,function(e){var t=+e.slice(1,-1)+n;return t<r.length?k(r[t]):e}),a+=`
164
+ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.length;c++,s=`&`)a+=s+`p`+(c-n)+`=`+encodeURIComponent(k(r[c]));return new t(a)}}var j=A(`$parse`);function M(e){return e+``}var N=ee();d(`+ - * / % === !== == != < > <= >= && || ?? ! = | ?`.split(` `),function(e){N[e]=!0});var P={n:`
165
+ `,f:`\f`,r:`\r`,t:` `,v:`\v`,"'":`'`,'"':`"`};function F(e){this.options=e||{}}F.prototype={constructor:F,lex:function(e){for(this.text=e,this.index=0,this.tokens=[];this.index<this.text.length;){var t=this.text.charAt(this.index);if(t===`"`||t===`'`||t==="`")this.readString(t);else if(this.isNumber(t)||t===`.`&&this.isNumber(this.peek()))this.readNumber();else if(this.isIdentifierStart(this.peekMultichar()))this.readIdent();else if(this.is(t,`(){}[].,;:`))this.tokens.push({index:this.index,text:t}),this.index++;else if(this.isWhitespace(t))this.index++;else{var n=t+this.peek(),r=n+this.peek(2),i=N[t],a=N[n],o=N[r];if(i||a||o){var s=o?r:a?n:t;this.tokens.push({index:this.index,text:s,operator:!0}),this.index+=s.length}else this.throwError(`Unexpected next character `,this.index,this.index+1)}}return this.tokens},is:function(e,t){return t.indexOf(e)!==-1},peek:function(e){var t=e||1;return this.index+t<this.text.length?this.text.charAt(this.index+t):!1},isNumber:function(e){return e>=`0`&&e<=`9`&&typeof e==`string`},isWhitespace:function(e){return e===` `||e===`\r`||e===` `||e===`
166
+ `||e===`\v`||e===`\xA0`},isIdentifierStart:function(e){return this.options.isIdentifierStart?this.options.isIdentifierStart(e,this.codePointAt(e)):this.isValidIdentifierStart(e)},isValidIdentifierStart:function(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`||e===`$`},isIdentifierContinue:function(e){return this.options.isIdentifierContinue?this.options.isIdentifierContinue(e,this.codePointAt(e)):this.isValidIdentifierContinue(e)},isValidIdentifierContinue:function(e,t){return this.isValidIdentifierStart(e,t)||this.isNumber(e)},codePointAt:function(e){return e.length===1?e.charCodeAt(0):(e.charCodeAt(0)<<10)+e.charCodeAt(1)-56613888},peekMultichar:function(){var e=this.text.charAt(this.index),t=this.peek();if(!t)return e;var n=e.charCodeAt(0),r=t.charCodeAt(0);return n>=55296&&n<=56319&&r>=56320&&r<=57343?e+t:e},isExpOperator:function(e){return e===`-`||e===`+`||this.isNumber(e)},throwError:function(e,t,n){throw n=n||this.index,j(`lexerr`,`Lexer Error: {0} at column{1} in expression [{2}].`,e,h(t)?`s `+t+`-`+this.index+` [`+this.text.substring(t,n)+`]`:` `+n,this.text)},readNumber:function(){for(var e=``,t=this.index;this.index<this.text.length;){var n=r(this.text.charAt(this.index));if(n===`.`||this.isNumber(n))e+=n;else{var i=this.peek();if(n===`e`&&this.isExpOperator(i))e+=n;else if(this.isExpOperator(n)&&i&&this.isNumber(i)&&e.charAt(e.length-1)===`e`)e+=n;else if(this.isExpOperator(n)&&(!i||!this.isNumber(i))&&e.charAt(e.length-1)===`e`)this.throwError(`Invalid exponent`);else break}this.index++}this.tokens.push({index:t,text:e,constant:!0,value:Number(e)})},readIdent:function(){var e=this.index;for(this.index+=this.peekMultichar().length;this.index<this.text.length;){var t=this.peekMultichar();if(!this.isIdentifierContinue(t))break;this.index+=t.length}this.tokens.push({index:e,text:this.text.slice(e,this.index),identifier:!0})},readString:function(e){var t=this.index;this.index++;for(var n=``,r=e,i=e==="`",a=!1;this.index<this.text.length;){var o=this.text.charAt(this.index);if(i&&o===`$`&&this.text.charAt(this.index+1)===`{`){this.tokens.push({index:t,text:r,constant:!0,value:n});var s=this.text.indexOf(`}`,this.index),c=this.text.substr(this.index+2,s-this.index-2);this.tokens.push({index:this.index,text:`+`,operator:!0});for(var l=new F(this.options).lex(c),u=0,d=l.length;u<d;u++)this.tokens.push(l[u]);this.tokens.push({index:this.index,text:`+`,operator:!0}),this.index=s,this.readString("`");return}if(r+=o,a){if(o===`u`){var f=this.text.substring(this.index+1,this.index+5);f.match(/[\da-f]{4}/i)||this.throwError(`Invalid unicode escape [\\u`+f+`]`),this.index+=4,n+=String.fromCharCode(parseInt(f,16))}else{var p=P[o];n+=p||o}a=!1}else if(o===`\\`)a=!0;else if(o===e){this.index++,this.tokens.push({index:t,text:r,constant:!0,value:n});return}else n+=o;this.index++}this.throwError(`Unterminated quote`,t)}};function I(e,t){this.lexer=e,this.options=t}I.Program=`Program`,I.ExpressionStatement=`ExpressionStatement`,I.AssignmentExpression=`AssignmentExpression`,I.ConditionalExpression=`ConditionalExpression`,I.LogicalExpression=`LogicalExpression`,I.BinaryExpression=`BinaryExpression`,I.UnaryExpression=`UnaryExpression`,I.CallExpression=`CallExpression`,I.MemberExpression=`MemberExpression`,I.Identifier=`Identifier`,I.Literal=`Literal`,I.ArrayExpression=`ArrayExpression`,I.Property=`Property`,I.ObjectExpression=`ObjectExpression`,I.ThisExpression=`ThisExpression`,I.LocalsExpression=`LocalsExpression`,I.NGValueParameter=`NGValueParameter`,I.prototype={ast:function(e){this.text=e,this.tokens=this.lexer.lex(e);var t=this.program();return this.tokens.length!==0&&this.throwError(`is an unexpected token`,this.tokens[0]),t},program:function(){for(var e=[];;)if(this.tokens.length>0&&!this.peek(`}`,`)`,`;`,`]`)&&e.push(this.expressionStatement()),!this.expect(`;`))return{type:I.Program,body:e}},expressionStatement:function(){return{type:I.ExpressionStatement,expression:this.filterChain()}},filterChain:function(){for(var e=this.expression();this.expect(`|`);)e=this.filter(e);return e},expression:function(){return this.assignment()},assignment:function(){var e=this.ternary();if(this.expect(`=`)){if(!re(e))throw j(`lval`,`Trying to assign a value to a non l-value`);e={type:I.AssignmentExpression,left:e,right:this.assignment(),operator:`=`}}return e},ternary:function(){var e=this.nullishCoalescing(),t,n;return this.expect(`?`)&&(t=this.expression(),this.consume(`:`))?(n=this.expression(),{type:I.ConditionalExpression,test:e,alternate:t,consequent:n}):e},nullishCoalescing:function(){for(var e=this.logicalOR();this.expect(`??`);)e={type:I.LogicalExpression,operator:`??`,left:e,right:this.logicalOR()};return e},logicalOR:function(){for(var e=this.logicalAND();this.expect(`||`);)e={type:I.LogicalExpression,operator:`||`,left:e,right:this.logicalAND()};return e},logicalAND:function(){for(var e=this.equality();this.expect(`&&`);)e={type:I.LogicalExpression,operator:`&&`,left:e,right:this.equality()};return e},equality:function(){for(var e=this.relational(),t;t=this.expect(`==`,`!=`,`===`,`!==`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.relational()};return e},relational:function(){for(var e=this.additive(),t;t=this.expect(`<`,`>`,`<=`,`>=`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.additive()};return e},additive:function(){for(var e=this.multiplicative(),t;t=this.expect(`+`,`-`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.multiplicative()};return e},multiplicative:function(){for(var e=this.unary(),t;t=this.expect(`*`,`/`,`%`);)e={type:I.BinaryExpression,operator:t.text,left:e,right:this.unary()};return e},unary:function(){var e;return(e=this.expect(`+`,`-`,`!`))?{type:I.UnaryExpression,operator:e.text,prefix:!0,argument:this.unary()}:this.primary()},primary:function(){var e;this.expect(`(`)?(e=this.filterChain(),this.consume(`)`)):this.expect(`[`)?e=this.arrayDeclaration():this.expect(`{`)?e=this.object():this.selfReferential.hasOwnProperty(this.peek().text)?e=E(this.selfReferential[this.consume().text]):this.options.literals.hasOwnProperty(this.peek().text)?e={type:I.Literal,value:this.options.literals[this.consume().text]}:this.peek().identifier?e=this.identifier():this.peek().constant?e=this.constant():this.throwError(`not a primary expression`,this.peek());for(var t;t=this.expect(`(`,`[`,`.`);)t.text===`(`?(e={type:I.CallExpression,callee:e,arguments:this.parseArguments()},this.consume(`)`)):t.text===`[`?(e={type:I.MemberExpression,object:e,property:this.expression(),computed:!0},this.consume(`]`)):t.text===`.`?e={type:I.MemberExpression,object:e,property:this.identifier(),computed:!1}:this.throwError(`IMPOSSIBLE`);return e},filter:function(e){for(var t=[e],n={type:I.CallExpression,callee:this.identifier(),arguments:t,filter:!0};this.expect(`:`);)t.push(this.expression());return n},parseArguments:function(){var e=[];if(this.peekToken().text!==`)`)do e.push(this.filterChain());while(this.expect(`,`));return e},identifier:function(){var e=this.consume();return e.identifier||this.throwError(`is not a valid identifier`,e),{type:I.Identifier,name:e.text}},constant:function(){return{type:I.Literal,value:this.consume().value}},arrayDeclaration:function(){var e=[];if(this.peekToken().text!==`]`)do{if(this.peek(`]`))break;e.push(this.expression())}while(this.expect(`,`));return this.consume(`]`),{type:I.ArrayExpression,elements:e}},object:function(){var e=[],t;if(this.peekToken().text!==`}`)do{if(this.peek(`}`))break;t={type:I.Property,kind:`init`},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)}while(this.expect(`,`));return this.consume(`}`),{type:I.ObjectExpression,properties:e}},throwError:function(e,t){throw j(`syntax`,`Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].`,t.text,e,t.index+1,this.text,this.text.substring(t.index))},consume:function(e){if(this.tokens.length===0)throw j(`ueoe`,`Unexpected end of expression: {0}`,this.text);var t=this.expect(e);return t||this.throwError(`is unexpected, expecting [`+e+`]`,this.peek()),t},peekToken:function(){if(this.tokens.length===0)throw j(`ueoe`,`Unexpected end of expression: {0}`,this.text);return this.tokens[0]},peek:function(e,t,n,r){return this.peekAhead(0,e,t,n,r)},peekAhead:function(e,t,n,r,i){if(this.tokens.length>e){var a=this.tokens[e],o=a.text;if(o===t||o===n||o===r||o===i||!t&&!n&&!r&&!i)return a}return!1},expect:function(e,t,n,r){var i=this.peek(e,t,n,r);return i?(this.tokens.shift(),i):!1}};function L(e,t){return e===void 0?t:e}function R(e,t){return e===void 0?t:t===void 0?e:e+t}function te(e,t){var n=e(t);if(!n)throw Error(`Filter '`+t+`' is not defined`);return!n.$stateful}function z(e,t){var n,r,i;switch(e.type){case I.Program:n=!0,d(e.body,function(e){z(e.expression,t),n=n&&e.expression.constant}),e.constant=n;break;case I.Literal:e.constant=!0,e.toWatch=[];break;case I.UnaryExpression:z(e.argument,t),e.constant=e.argument.constant,e.toWatch=e.argument.toWatch;break;case I.BinaryExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=e.left.toWatch.concat(e.right.toWatch);break;case I.LogicalExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=e.constant?[]:[e];break;case I.ConditionalExpression:z(e.test,t),z(e.alternate,t),z(e.consequent,t),e.constant=e.test.constant&&e.alternate.constant&&e.consequent.constant,e.toWatch=e.constant?[]:[e];break;case I.Identifier:e.constant=!1,e.toWatch=[e];break;case I.MemberExpression:z(e.object,t),e.computed&&z(e.property,t),e.constant=e.object.constant&&(!e.computed||e.property.constant),e.toWatch=[e];break;case I.CallExpression:i=e.filter?te(t,e.callee.name):!1,n=i,r=[],d(e.arguments,function(e){z(e,t),n=n&&e.constant,e.constant||r.push.apply(r,e.toWatch)}),e.constant=n,e.toWatch=i?r:[e];break;case I.AssignmentExpression:z(e.left,t),z(e.right,t),e.constant=e.left.constant&&e.right.constant,e.toWatch=[e];break;case I.ArrayExpression:n=!0,r=[],d(e.elements,function(e){z(e,t),n=n&&e.constant,e.constant||r.push.apply(r,e.toWatch)}),e.constant=n,e.toWatch=r;break;case I.ObjectExpression:n=!0,r=[],d(e.properties,function(e){z(e.value,t),n=n&&e.value.constant&&!e.computed,e.value.constant||r.push.apply(r,e.value.toWatch)}),e.constant=n,e.toWatch=r;break;case I.ThisExpression:e.constant=!1,e.toWatch=[];break;case I.LocalsExpression:e.constant=!1,e.toWatch=[];break}}function ne(e){if(e.length===1){var t=e[0].expression,n=t.toWatch;return n.length===1&&n[0]===t?void 0:n}}function re(e){return e.type===I.Identifier||e.type===I.MemberExpression}function B(e){if(e.body.length===1&&re(e.body[0].expression))return{type:I.AssignmentExpression,left:e.body[0].expression,right:{type:I.NGValueParameter},operator:`=`}}function V(e){return e.body.length===0||e.body.length===1&&(e.body[0].expression.type===I.Literal||e.body[0].expression.type===I.ArrayExpression||e.body[0].expression.type===I.ObjectExpression)}function H(e){return e.constant}function ie(e,t){this.astBuilder=e,this.$filter=t}ie.prototype={compile:function(e){var t=this,n=this.astBuilder.ast(e);this.state={nextId:0,filters:{},fn:{vars:[],body:[],own:{}},assign:{vars:[],body:[],own:{}},inputs:[]},z(n,t.$filter);var r=``,i;if(this.stage=`assign`,i=B(n)){this.state.computing=`assign`;var o=this.nextId();this.recurse(i,o),this.return_(o),r=`fn.assign=`+this.generateFunction(`assign`,`s,v,l`)}var s=ne(n.body);t.stage=`inputs`,d(s,function(e,n){var r=`fn`+n;t.state[r]={vars:[],body:[],own:{}},t.state.computing=r;var i=t.nextId();t.recurse(e,i),t.return_(i),t.state.inputs.push(r),e.watchId=n}),this.state.computing=`fn`,this.stage=`main`,this.recurse(n);var c=`"`+this.USE+` `+this.STRICT+`";
167
+ `+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,M,L,R),u=function(e,t,n,r){return a(function(){return l(e,t,n,r)})};return u.assign=function(e,t,n){return a(function(){return l.assign(e,t,n)})},u.inputs=l.inputs,this.state=this.stage=void 0,u.ast=n,u.literal=V(n),u.constant=H(n),u},USE:`use`,STRICT:`strict`,watchFns:function(){var e=[],t=this.state.inputs,n=this;return d(t,function(t){e.push(`var `+t+`=`+n.generateFunction(t,`s`))}),t.length&&e.push(`fn.inputs=[`+t.join(`,`)+`];`),e.join(``)},generateFunction:function(e,t){return`function(`+t+`){`+this.varsPrefix(e)+this.body(e)+`};`},filterPrefix:function(){var e=[],t=this;return d(this.state.filters,function(n,r){e.push(n+`=$filter(`+t.escape(r)+`)`)}),e.length?`var `+e.join(`,`)+`;`:``},varsPrefix:function(e){return this.state[e].vars.length?`var `+this.state[e].vars.join(`,`)+`;`:``},body:function(e){return this.state[e].body.join(``)},recurse:function(e,t,n,r,i,a){var o,s,c=this,l,u,f;if(r=r||p,!a&&h(e.watchId)){t=t||this.nextId(),this.if_(`i`,this.lazyAssign(t,this.unsafeComputedMember(`i`,e.watchId)),this.lazyRecurse(e,t,n,r,i,!0));return}switch(e.type){case I.Program:d(e.body,function(t,n){c.recurse(t.expression,void 0,void 0,function(e){s=e}),n===e.body.length-1?c.return_(s):c.current().body.push(s,`;`)});break;case I.Literal:u=this.escape(e.value),this.assign(t,u),r(t||u);break;case I.UnaryExpression:this.recurse(e.argument,void 0,void 0,function(e){s=e}),u=e.operator+`(`+this.ifDefined(s,0)+`)`,this.assign(t,u),r(u);break;case I.BinaryExpression:this.recurse(e.left,void 0,void 0,function(e){o=e}),this.recurse(e.right,void 0,void 0,function(e){s=e}),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);break;case I.LogicalExpression: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);break;case I.ConditionalExpression:t=t||this.nextId(),c.recurse(e.test,t),c.if_(t,c.lazyRecurse(e.alternate,t),c.lazyRecurse(e.consequent,t)),r(t);break;case I.Identifier:t=t||this.nextId();var m=c.current().inAssignment;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(){c.if_(c.stage===`inputs`||`s`,function(){var n=c.nextId();c.assign(n,c.nonComputedMember(`s`,e.name)),c.if_(c.or_(c.isNull(n),c.hasOwnProperty_(`s`,e.name)),function(){i&&i!==1?(c.if_(c.isNull(n),c.lazyAssign(c.nonComputedMember(`s`,e.name),`{}`)),c.assign(t,c.nonComputedMember(`s`,e.name))):c.assign(t,n)})})},t&&function(){c.if_(c.hasOwnProperty_(`l`,e.name),c.lazyAssign(t,c.nonComputedMember(`l`,e.name)))}),r(t);break;case I.MemberExpression:o=n&&(n.context=this.nextId())||this.nextId(),t=t||this.nextId(),c.recurse(e.object,o,void 0,function(){var a=null,l=c.current().inAssignment;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===I.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(){e.computed?(e.property.type!==I.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))},function(){c.assign(t,`undefined`)}),r(t)},!!i);break;case I.CallExpression:t=t||this.nextId(),e.filter?(s=c.filter(e.callee.name),l=[],d(e.arguments,function(e){var t=c.nextId();c.recurse(e,t),l.push(t)}),u=s+`.call(`+s+`,`+l.join(`,`)+`)`,c.assign(t,u),r(t)):(s=c.nextId(),o={},l=[],c.recurse(e.callee,s,o,function(){c.if_(c.notNull(s),function(){d(e.arguments,function(t){c.recurse(t,e.constant?void 0:c.nextId(),void 0,function(e){l.push(e)})}),u=o.name?`(`+c.member(o.context,o.name,o.computed)+` === null ? null : `+c.unsafeMember(o.context,o.name,o.computed)+`.call(`+[o.context].concat(l).join(`,`)+`))`:s+`(`+l.join(`,`)+`)`,c.assign(t,u)},function(){c.assign(t,`undefined`)}),r(t)}));break;case I.AssignmentExpression:s=this.nextId(),o={},c.current().inAssignment=!0,this.recurse(e.left,void 0,o,function(){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(){c.recurse(e.right,s),u=c.member(o.context,o.name,o.computed)+e.operator+s,c.assign(t,u),r(t||u)}),c.current().inAssignment=!1,c.recurse(e.right,s),c.current().inAssignment=!0},1),c.current().inAssignment=!1;break;case I.ArrayExpression:l=[],d(e.elements,function(t){c.recurse(t,e.constant?void 0:c.nextId(),void 0,function(e){l.push(e)})}),u=`[`+l.join(`,`)+`]`,this.assign(t,u),r(t||u);break;case I.ObjectExpression:l=[],f=!1,d(e.properties,function(e){e.computed&&(f=!0)}),f?(t=t||this.nextId(),this.assign(t,`{}`),d(e.properties,function(e){e.computed?(o=c.nextId(),c.recurse(e.key,o)):o=e.key.type===I.Identifier?e.key.name:``+e.key.value,s=c.nextId(),c.recurse(e.value,s),c.assign(c.unsafeMember(t,o,e.computed),s)})):(d(e.properties,function(t){c.recurse(t.value,e.constant?void 0:c.nextId(),void 0,function(e){l.push(c.escape(t.key.type===I.Identifier?t.key.name:``+t.key.value)+`:`+e)})}),u=`{`+l.join(`,`)+`}`,this.assign(t,u)),r(t||u);break;case I.ThisExpression:this.assign(t,`s`),r(t||`s`);break;case I.LocalsExpression:this.assign(t,`l`),r(t||`l`);break;case I.NGValueParameter:this.assign(t,`v`),r(t||`v`);break}},getHasOwnProperty:function(e,t){var n=e+`.`+t,r=this.current().own;return r.hasOwnProperty(n)||(r[n]=this.nextId(!1,e+`&&(`+this.escape(t)+` in `+e+`)`)),r[n]},assign:function(e,t){if(e)return this.current().body.push(e,`=`,t,`;`),e},filter:function(e){return n.call(this.state.filters,e)||(this.state.filters[e]=this.nextId(!0)),this.state.filters[e]},ifDefined:function(e,t){return`ifDefined(`+e+`,`+this.escape(t)+`)`},plus:function(e,t){return`plus(`+e+`,`+t+`)`},return_:function(e){this.current().body.push(`return `,e,`;`)},if_:function(e,t,n){if(e===!0)t();else{var r=this.current().body;r.push(`if(`,e,`){`),t(),r.push(`}`),n&&(r.push(`else{`),n(),r.push(`}`))}},or_:function(e,t){return`(`+e+`) || (`+t+`)`},hasOwnProperty_:function(e,t,n){return n?`(Object.prototype.hasOwnProperty.call(`+e+`,`+t+`))`:`(Object.prototype.hasOwnProperty.call(`+e+`,'`+t+`'))`},and_:function(e,t){return`(`+e+`) && (`+t+`)`},not:function(e){return`!(`+e+`)`},isNull:function(e){return e+`==null`},notNull:function(e){return e+`!=null`},nonComputedMember:function(e,t){var n=/^[$_a-zA-Z][$_a-zA-Z0-9]*$/,r=/[^$_a-zA-Z0-9]/g,i=``;return n.test(t)?i=e+`.`+t:(t=t.replace(r,this.stringEscapeFn),i=e+`["`+t+`"]`),i},unsafeComputedMember:function(e,t){return e+`[`+t+`]`},unsafeNonComputedMember:function(e,t){return this.nonComputedMember(e,t)},computedMember:function(e,t){return this.state.computing===`assign`?this.unsafeComputedMember(e,t):`(`+e+`.hasOwnProperty(`+t+`) ? `+e+`[`+t+`] : undefined)`},unsafeMember:function(e,t,n){return n?this.unsafeComputedMember(e,t):this.unsafeNonComputedMember(e,t)},member:function(e,t,n){return n?this.computedMember(e,t):this.nonComputedMember(e,t)},getStringValue:function(e){this.assign(e,`getStringValue(`+e+`)`)},lazyRecurse:function(e,t,n,r,i,a){var o=this;return function(){o.recurse(e,t,n,r,i,a)}},lazyAssign:function(e,t){var n=this;return function(){n.assign(e,t)}},stringEscapeRegex:/[^ a-zA-Z0-9]/g,stringEscapeFn:function(e){return`\\u`+(`0000`+e.charCodeAt(0).toString(16)).slice(-4)},escape:function(e){if(v(e))return`'`+e.replace(this.stringEscapeRegex,this.stringEscapeFn)+`'`;if(y(e))return e.toString();if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e===void 0)return`undefined`;throw j(`esc`,`IMPOSSIBLE`)},nextId:function(e,t){var n=`v`+ this.state.nextId++;return e||this.current().vars.push(n+(t?`=`+t:``)),n},current:function(){return this.state[this.state.computing]}};function ae(e,t){this.astBuilder=e,this.$filter=t}ae.prototype={compile:function(e){var t=this,n=this.astBuilder.ast(e);z(n,t.$filter);var r,i;(r=B(n))&&(i=this.recurse(r));var o=ne(n.body),s;o&&(s=[],d(o,function(e,n){var r=t.recurse(e);e.input=r,s.push(r),e.watchId=n}));var c=[];d(n.body,function(e){c.push(t.recurse(e.expression))});var l=n.body.length===0?p:n.body.length===1?c[0]:function(e,t){var n;return d(c,function(r){n=r(e,t)}),n};i&&(l.assign=function(e,t,n){return i(e,n,t)});var u=function(e,t){return a(function(){return l(e,t)})};return u.assign=function(e,t,n){return a(function(){return l.assign(e,t,n)})},s&&(u.inputs=s),u.ast=n,u.literal=V(n),u.constant=H(n),u},recurse:function(e,t,n){var r,i,a=this,o;if(e.input)return this.inputs(e.input,e.watchId);switch(e.type){case I.Literal:return this.value(e.value,t);case I.UnaryExpression:return i=this.recurse(e.argument),this[`unary`+e.operator](i,t);case I.BinaryExpression:return r=this.recurse(e.left),i=this.recurse(e.right),this[`binary`+e.operator](r,i,t);case I.LogicalExpression:return r=this.recurse(e.left),i=this.recurse(e.right),this[`binary`+e.operator](r,i,t);case I.ConditionalExpression:return this[`ternary?:`](this.recurse(e.test),this.recurse(e.alternate),this.recurse(e.consequent),t);case I.Identifier:return a.identifier(e.name,t,n);case I.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);case I.CallExpression:return o=[],d(e.arguments,function(e){o.push(a.recurse(e))}),e.filter&&(i=this.$filter(e.callee.name)),e.filter||(i=this.recurse(e.callee,!0)),e.filter?function(e,n,r,a){for(var s=[],c=0;c<o.length;++c)s.push(o[c](e,n,r,a));var l=i.apply(void 0,s,a);return t?{context:void 0,name:void 0,value:l}:l}:function(e,n,r,a){var s=i(e,n,r,a),c;if(s.value!=null){for(var l=[],u=0;u<o.length;++u)l.push(o[u](e,n,r,a));c=s.value.apply(s.context,l)}return t?{value:c}:c};case I.AssignmentExpression:return r=this.recurse(e.left,!0,1),i=this.recurse(e.right),function(e,n,a,o){var s=r(e,!1,a,o),c=i(e,n,a,o);return s.context[s.name]=c,t?{value:c}:c};case I.ArrayExpression:return o=[],d(e.elements,function(e){o.push(a.recurse(e))}),function(e,n,r,i){for(var a=[],s=0;s<o.length;++s)a.push(o[s](e,n,r,i));return t?{value:a}:a};case I.ObjectExpression:return o=[],d(e.properties,function(e){e.computed?o.push({key:a.recurse(e.key),computed:!0,value:a.recurse(e.value)}):o.push({key:e.key.type===I.Identifier?e.key.name:``+e.key.value,computed:!1,value:a.recurse(e.value)})}),function(e,n,r,i){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);return t?{value:a}:a};case I.ThisExpression:return function(e){return t?{value:e}:e};case I.LocalsExpression:return function(e,n){return t?{value:n}:n};case I.NGValueParameter:return function(e,n,r){return t?{value:r}:r}}},"unary+":function(e,t){return function(n,r,i,a){var o=e(n,r,i,a);return o=h(o)?+o:0,t?{value:o}:o}},"unary-":function(e,t){return function(n,r,i,a){var o=e(n,r,i,a);return o=h(o)?-o:-0,t?{value:o}:o}},"unary!":function(e,t){return function(n,r,i,a){var o=!e(n,r,i,a);return t?{value:o}:o}},"binary+":function(e,t,n){return function(r,i,a,o){var s=R(e(r,i,a,o),t(r,i,a,o));return n?{value:s}:s}},"binary-":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o),c=t(r,i,a,o),l=(h(s)?s:0)-(h(c)?c:0);return n?{value:l}:l}},"binary*":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)*t(r,i,a,o);return n?{value:s}:s}},"binary/":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)/t(r,i,a,o);return n?{value:s}:s}},"binary%":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)%t(r,i,a,o);return n?{value:s}:s}},"binary===":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)===t(r,i,a,o);return n?{value:s}:s}},"binary!==":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)!==t(r,i,a,o);return n?{value:s}:s}},"binary==":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)==t(r,i,a,o);return n?{value:s}:s}},"binary!=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)!=t(r,i,a,o);return n?{value:s}:s}},"binary<":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)<t(r,i,a,o);return n?{value:s}:s}},"binary>":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)>t(r,i,a,o);return n?{value:s}:s}},"binary<=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)<=t(r,i,a,o);return n?{value:s}:s}},"binary>=":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)>=t(r,i,a,o);return n?{value:s}:s}},"binary&&":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)&&t(r,i,a,o);return n?{value:s}:s}},"binary||":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o)||t(r,i,a,o);return n?{value:s}:s}},"binary??":function(e,t,n){return function(r,i,a,o){var s=e(r,i,a,o),c=s!=null&&s!==void 0?s:t(r,i,a,o);return n?{value:c}:c}},"ternary?:":function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s)?t(i,a,o,s):n(i,a,o,s);return r?{value:c}:c}},value:function(e,t){return function(){return t?{context:void 0,name:void 0,value:e}:e}},identifier:function(e,t,r){return function(i,a){var o=a&&e in a?a:i;r&&r!==1&&o&&o[e]==null&&(o[e]={});var s;return o&&n.call(o,e)&&(s=o?o[e]:void 0),t?{context:o,name:e,value:s}:s}},computedMember:function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s),l,u;return c!=null&&(l=t(i,a,o,s),l=M(l),r&&r!==1&&c&&!c[l]&&(c[l]={}),Object.prototype.hasOwnProperty.call(c,l)&&(u=c[l])),n?{context:c,name:l,value:u}:u}},nonComputedMember:function(e,t,n,r){return function(i,a,o,s){var c=e(i,a,o,s);r&&r!==1&&c&&c[t]==null&&(c[t]={});var l=void 0;return c!=null&&Object.prototype.hasOwnProperty.call(c,t)&&(l=c[t]),n?{context:c,name:t,value:l}:l}},inputs:function(e,t){return function(n,r,i,a){return a?a[t]:e(n,r,i)}}};var U=function(e,t,n){this.lexer=e,this.$filter=t,n=n||{},n.handleThis=n.handleThis==null?!0:n.handleThis,this.options=n,this.ast=new I(e,n),this.ast.selfReferential={$locals:{type:I.LocalsExpression}},n.handleThis&&(this.ast.selfReferential.this={type:I.ThisExpression}),this.astCompiler=n.csp?new ae(this.ast,t):new ie(this.ast,t)};U.prototype={constructor:U,parse:function(e){return this.astCompiler.compile(e)}},e.Lexer=F,e.Parser=U})),xe=e.t((e=>{var t=be(),n={},r=t.Lexer,i=t.Parser;function a(e){return e=e||{},e.filters&&(e.cache=e.cache||{}),e.cache=e.cache||s.cache,e.filters=e.filters||n,e}function o(e){return{handleThis:e.handleThis==null?!0:e.handleThis,csp:e.csp==null?!1:e.csp,literals:e.literals==null?{true:!0,false:!1,null:null,undefined:void 0}:e.literals}}function s(e,t){if(typeof e!=`string`)throw TypeError(`src must be a string, instead saw '`+typeof e+`'`);t=a(t);var n=t,s=o(t),c=new i(new r(n),function(e){return t.filters[e]},s);if(!t.cache)return c.parse(e);delete t.src;var l=JSON.stringify(Object.assign({src:e},t)),u=t.cache[l];return u||(u=t.cache[l]=c.parse(e)),u}s.cache=Object.create(null),e.compile=s}))();const Se=(e,t)=>{let n=[];e!==void 0&&!Array.isArray(e)&&n.push(`deeds is not an array, the host ignores it`);let r=[];for(let[i,a]of(Array.isArray(e)?e:[]).entries()){if(a==null||typeof a.id!=`string`){n.push(`deed ${i} has no string id, the host drops it`);continue}if(t===`checkpoint`){r.push({id:a.id,value:a.value});continue}a.value===void 0||a.value===null||r.push({id:a.id,value:typeof a.value==`number`?Math.floor(a.value):a.value,persist:a.persist===!0})}if(t===`checkpoint`)return{deeds:r,warnings:n};let i=r.filter(e=>e.persist),a=r.filter(e=>!e.persist),o=i.splice(3);return o.length&&n.push(`only 3 persisted deeds are kept, dropped: ${o.map(e=>e.id).join(`, `)}`),{deeds:[...i,...a].map(({id:e,value:t})=>({id:e,value:t})),warnings:n}},Ce=e=>{let t={};for(let n of e)n.value!==void 0&&(t[Ee(n.id)]=n.value);return t},we=(e,t)=>{try{if(e.filterExp&&!(0,xe.compile)(e.filterExp)(t)||!e.incrementExp)return{complete:!1,value:0};let n=(0,xe.compile)(e.incrementExp)(t);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}`);let r=Math.floor(n);return{complete:r>=(e.targetCount||1),value:r}}catch(e){return{complete:!1,value:0,error:e.message}}},Te=e=>{let{items:t,scope:n,mode:r}=e,i=Math.min(Math.max(e.index,0),t.length),a;for(;i<t.length&&(a=we(t[i],n),!(!a.complete||r===`checkpoint`&&!t[i].liveUpdate));i++);return{index:i,head:i<t.length?a:void 0}};var Ee=e=>e.replace(/-./g,e=>e[1].toUpperCase());function De(e){let t=new Map,n=new Set,r=null,i=0,a,o=[],s=e=>{var t;return`simulator-checklist:${(t=r)==null?`game`:t}:${e}`},c=e=>{try{let t=Number(localStorage.getItem(s(e.stableID)))||0;return Math.min(Math.max(t,0),e.items.length)}catch(e){return 0}},l=(e,t)=>{try{t===0?localStorage.removeItem(s(e)):localStorage.setItem(s(e),String(t))}catch(e){}},u=(e,t,r,i)=>{var a;let o=r<i.index?`done`:r===i.index?`active`:`upcoming`,s=`${e.stableID}:${r}`,c=n.has(s),l=!!t.expandMD&&o!==`done`,u=t.targetCount||1,d=o===`active`&&i.head?`${Math.min(i.head.value,u)}/${u}`:``,f=[t.incrementExp&&`increment: ${t.incrementExp}`,t.filterExp&&`filter: ${t.filterExp}`,`target: ${u}`,t.liveUpdate?`liveUpdate: checkpoints + completion`:`completion only`].filter(Boolean).join(`
168
168
  `);return`${e.instructionsVisibleFromItemIndex===r&&r>0?`<div class="checklist-divider"><span>full instructions unlock</span></div>`:``}
169
169
  <div class="checklist-item ${o}" title="${q(f)}">
170
170
  <div class="checklist-row">
@@ -234,10 +234,10 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
234
234
  </select>
235
235
  </div>
236
236
  </div>
237
- `},bind(e){let t=e.getElement(`#simulator-thumb-refresh`);t==null||t.addEventListener(`click`,()=>e.updateThumbnail());let n=e.getElement(`#simulator-render-host-select`),r=e.getElement(`#simulator-render-context-select`),i=e.getElement(`#simulator-render-host-field`),a=e.getElement(`#simulator-render-context-field`),o=e.getElement(`#simulator-preview-kind`),s=()=>{let t=e.state.previewKind!==`text`;i&&(i.style.display=t?`block`:`none`),a&&(a.style.display=t&&e.state.renderHost===`opengraph`?`block`:`none`)},c=()=>{o==null||o.querySelectorAll(`.simulator-segmented-btn`).forEach(t=>{let n=t.dataset.previewKind;t.classList.toggle(`active`,n===e.state.previewKind),t.setAttribute(`aria-selected`,n===e.state.previewKind?`true`:`false`)})};o==null||o.querySelectorAll(`.simulator-segmented-btn`).forEach(t=>{t.addEventListener(`click`,()=>{let n=t.dataset.previewKind;!n||n===e.state.previewKind||(e.state.previewKind=n,L(n),c(),s(),e.updateThumbnail())})}),n&&(e.state.renderHost||(e.state.renderHost=`game`,I(e.state.renderHost)),n.value=e.state.renderHost||`game`,n.addEventListener(`change`,()=>{e.state.renderHost=n.value,I(e.state.renderHost),s(),e.updateThumbnail()})),r&&(e.state.renderContext||(e.state.renderContext=`preview`,R(e.state.renderContext)),r.value=e.state.renderContext||`preview`,r.addEventListener(`change`,()=>{e.state.renderContext=r.value,R(e.state.renderContext),e.updateThumbnail()})),c(),s()},onActivate(e){setTimeout(()=>e.updateThumbnail(),0)},updatePreview:e=>{let t=e.getElement(`#simulator-thumb-preview`),n=e.getElement(`#simulator-thumb-fn`);if(t==null||t.style.setProperty(`--sim-thumb-bg`,e.state.selectedTheme.g_bg),e.state.previewKind===`text`){let s=ke();if(!s){t&&(t.innerHTML=Ne),n&&(n.textContent=``);return}n&&(n.textContent=`Using: getShareString()`);try{var r,i,a,o;let n=(r=e.gameSlug)==null?`game`:r,c=s((i=e.state.currentInputStr)==null?``:i,Me(n),{puzzleString:(a=e.state.puzzleData)==null?``:a,dateKey:je(),gameplaySlug:`simulator:${n}`}),l=(o=c==null?void 0:c.str)==null?``:o;t&&(t.innerHTML=`<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ae(l)}</pre>`)}catch(e){console.error(`Simulator: Share string error`,e),t&&(t.innerHTML=`<span class="simulator-empty">Error: ${e}</span>`)}return}let s=Oe();if(!s){t&&(t.innerHTML=`<span class="simulator-empty">No thumbnail function found</span>`),n&&(n.textContent=``);return}n&&(n.textContent=`Using: ${s.name}()`);try{var c;let n=(c=e.state.puzzleData)==null?``:c,r={viewerIsOwner:!0,theme:e.state.selectedTheme,strict:!0,renderHost:e.state.renderHost,renderContext:e.state.renderContext},{svg:i}=U(s.fn(n,e.state.currentInputStr,r));t&&(t.innerHTML=i)}catch(e){console.error(`Simulator: Thumbnail error`,e),t&&(t.innerHTML=`<span class="simulator-empty">Error: ${e}</span>`)}}}}var J={bounds:`#ffd700`,grid:`rgba(96, 165, 250, 0.35)`,box:`rgba(34, 211, 238, 0.85)`,exiting:`#f87171`,hovered:`#ffd700`,highlighted:`#f472b6`,anchor:`#f472b6`,group:`#a78bfa`,label:`#e8e8e8`,labelBackground:`rgba(15, 15, 26, 0.8)`};const Fe=(e,t)=>{let{ctx:n,scale:r,scene:i,nodes:a}=e,o=t.devicePixelRatio,s=([e,t])=>[e*r,t*r];if(n.save(),n.lineWidth=o,t.grid&&i.grid&&i.width/i.grid+i.height/i.grid<=400){n.strokeStyle=J.grid,n.beginPath();for(let e=i.grid;e<i.width;e+=i.grid){let t=Math.round(e*r)+o/2;n.moveTo(t,0),n.lineTo(t,i.height*r)}for(let e=i.grid;e<i.height;e+=i.grid){let t=Math.round(e*r)+o/2;n.moveTo(0,t),n.lineTo(i.width*r,t)}n.stroke()}t.bounds&&(n.strokeStyle=J.bounds,n.setLineDash([4*o,3*o]),n.strokeRect(o/2,o/2,i.width*r-o,i.height*r-o),n.setLineDash([]));for(let e of a){let r=e.sprite?t.boxOf(e.sprite):void 0,i=e.key===t.hovered,a=!!e.sprite&&e.sprite===t.highlighted;if(r&&(t.boxes||i||a)){let t=Ie(e.matrix,r).map(s);n.strokeStyle=i?J.hovered:a?J.highlighted:e.exiting?J.exiting:J.box,n.lineWidth=(i||a?2:1)*o,n.setLineDash(e.alpha<=0?[3*o,3*o]:[]),n.beginPath(),t.forEach(([e,t],r)=>r?n.lineTo(e,t):n.moveTo(e,t)),n.closePath(),n.stroke(),n.setLineDash([]),n.lineWidth=o}if(t.anchors){let[t,i]=s(Re(e.matrix,[0,0]));r?(n.fillStyle=J.anchor,n.fillRect(t-1.5*o,i-1.5*o,3*o,3*o)):(n.strokeStyle=J.group,n.beginPath(),n.moveTo(t,i-4*o),n.lineTo(t+4*o,i),n.lineTo(t,i+4*o),n.lineTo(t-4*o,i),n.closePath(),n.stroke())}}if(t.keys){n.font=`${9*o}px Menlo, Monaco, monospace`,n.textBaseline=`top`;for(let e of a){let r=e.sprite?t.boxOf(e.sprite):void 0,[i,a]=r?Be(Ie(e.matrix,r).map(s)):s(Re(e.matrix,[0,0])),c=n.measureText(e.key).width;n.fillStyle=J.labelBackground,n.fillRect(i,a,c+4*o,11*o),n.fillStyle=J.label,n.fillText(e.key,i+2*o,a+o)}}n.restore()},Ie=(e,t)=>{let[n,r]=t.anchor;return[[-n,-r],[t.width-n,-r],[t.width-n,t.height-r],[-n,t.height-r]].map(t=>Re(e,t))},Le=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(!i.sprite||i.alpha<=0)continue;let a=n(i.sprite),o=a&&ze(i.matrix,t);if(!a||!o)continue;let s=o[0]+a.anchor[0],c=o[1]+a.anchor[1];if(s>=0&&c>=0&&s<=a.width&&c<=a.height)return i}return null};var Re=(e,[t,n])=>[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]],ze=(e,[t,n])=>{let r=e[0]*e[3]-e[1]*e[2];if(Math.abs(r)<1e-12)return null;let i=t-e[4],a=n-e[5];return[(e[3]*i-e[2]*a)/r,(-e[1]*i+e[0]*a)/r]},Be=e=>[Math.min(...e.map(e=>e[0])),Math.min(...e.map(e=>e[1]))];const Ve=(e,i={})=>{var a,o;let s=(a=i.rasterise)==null?Ge:a,c=(o=i.fontFaces)==null?``:o,l=new Map,u=new Map,d=new Set,f=0,p=!1,m=null,h=e=>{g.warnings.includes(e)||g.warnings.push(e)},g={render:function(){var i=n.t(function*(n){let i=n.pixelsPerUnit,a={render:++f,update:n,renderMs:0,spritesMs:0,made:[]};g.latest=a;let o=`render`;try{var _,v;p&&u.clear(),p=!1;let f=(_=u.get(i))==null?u.set(i,new Set).get(i):_,g=(v=l.get(i))==null?l.set(i,new Map).get(i):v,b=new Map,x=[],S=[],C=[],w=(e,t,n)=>{var r;let a=`${i}|${e}`,o=g.get(e),s=(r=b.get(e))==null?o&&{box:o,svg:o.svg}:r;if(!s||d.has(a))return;d.add(a);let c;try{c=qe(t)}catch(e){return}c.width===s.box.width&&c.height===s.box.height&&c.anchor[0]===s.box.anchor[0]&&c.anchor[1]===s.box.anchor[1]?n!==void 0&&s.svg!==void 0&&n!==s.svg&&h(`"${e}" was made again with different SVG. Puzzmo keeps the first, so put what differs into the ID`):h(`"${e}" was made again with a different box. Puzzmo keeps the first, so put what differs into the ID`)},T={has:e=>f.has(e)||b.has(e),draw(e,n,r){if(T.has(e))return w(e,n);let o=qe(n);m!=null||(m=new OffscreenCanvas(1,1)),m.width=Math.max(1,Math.ceil(o.width*i)),m.height=Math.max(1,Math.ceil(o.height*i));let s=m.getContext(`2d`);s.setTransform(i,0,0,i,0,0),r(s),b.set(e,{box:o}),x.push(t.t(t.t({id:e,kind:`draw`,bitmap:m.transferToImageBitmap()},o),{},{pixelsPerUnit:i,render:a.render}))},svg(e,t,n,r){if(T.has(e))return w(e,t,String(n));let i=qe(t),a=r?String(r):``,o=C.indexOf(a);o<0&&(o=C.push(a)-1),b.set(e,{box:i,svg:String(n)}),S.push({id:e,box:i,svg:String(n),defs:o})}},E=performance.now(),D=e.render(n,T);if(a.renderMs=performance.now()-E,D&&typeof D.then==`function`)throw Error(`render returned a Promise. Puzzmo's sandbox doesn't wait for one, so build the scene and return it`);for(let e of b.keys())f.add(e);try{D=structuredClone(D)}catch(e){throw Error(`The scene can't leave the sandbox: ${Ye(e)}`)}a.raw=D,o=`sprites`;let O=performance.now(),k=S.length?yield s(S,C,i,c):[];a.spritesMs=performance.now()-O;for(let{id:e,bitmap:n}of k){let r=S.find(t=>t.id===e);x.push(t.t(t.t({id:e,kind:`svg`,bitmap:n},r.box),{},{svg:r.svg,pixelsPerUnit:i,render:a.render}))}for(let e of x){var y;(y=g.get(e.id))==null||y.bitmap.close(),g.set(e.id,e)}a.made=x.map(e=>e.id),o=`scene`;let A=r.a(D),j=[...r.i(A)].filter(e=>!g.has(e));if(j.length)throw Error(`The scene names sprites it never made: ${j.slice(0,5).join(`, `)}`);return a.scene=A,A}catch(e){throw p=!0,a.error={phase:o,message:Ye(e),stack:e instanceof Error?e.stack:void 0},e}finally{var b;(b=g.onRender)==null||b.call(g,a)}});return function(e){return i.apply(this,arguments)}}(),sprite:(e,t)=>{var n;return(n=l.get(t))==null?void 0:n.get(e)},spritesAt:e=>{var t,n;return[...(t=(n=l.get(e))==null?void 0:n.values())==null?[]:t]},anySprite:e=>{let t;for(let n of l.values()){let r=n.get(e);r&&(!t||r.render>t.render)&&(t=r)}return t},resolutions:()=>[...l.keys()],warnings:[],latest:null,clear(){for(let e of l.values())for(let t of e.values())t.bitmap.close();l.clear(),u.clear(),d.clear(),g.warnings.length=0}};return g},He=function(){var e=n.t(function*(e){let t=[],n=[],r=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];for(let e of r){if(!i.r.includes(e)){t.push(`fonts names "${e}", which isn't a Puzzmo font, so the table won't load it`);continue}try{let t=yield fetch(i.i(e));if(!t.ok)throw Error(`the CDN answered ${t.status}`);let r=yield t.arrayBuffer();document.fonts.add(yield new FontFace(e,r.slice(0)).load()),n.push(`@font-face{font-family:"${e.replace(/["\\]/g,``)}";src:url(data:font/woff2;base64,${Je(r)})}`)}catch(n){t.push(`The font ${e} didn't load: ${Ye(n)}`)}}return{fontFaces:n.join(``),warnings:t}});return function(t){return e.apply(this,arguments)}}();var Ue=64,We=4096;const Ge=function(){var e=n.t(function*(e,t,n,r){var i;let a=[],o=new Map;for(let t of e)o.set(t.defs,[...(i=o.get(t.defs))==null?[]:i,t]);for(let[e,i]of o)for(let o=0;o<i.length;o+=Ue){let s=i.slice(o,o+Ue);try{a.push(...yield Ke(s,t[e],n,r))}catch(i){let a=[];for(let i of s)yield Ke([i],t[e],n,r).catch(()=>a.push(i.id));let o=a.length?`${a.slice(0,5).join(`, `)} won't decode`:Ye(i);throw Error(`An SVG sprite couldn't be drawn: ${o}`)}}return a});return function(t,n,r,i){return e.apply(this,arguments)}}();var Ke=function(){var e=n.t(function*(e,t,n,r){let i=0,a=0,o=0,s=1,c=e.map(e=>{let t=Math.max(1,Math.ceil(e.box.width*n)),r=Math.max(1,Math.ceil(e.box.height*n));i>0&&i+t>We&&(i=0,a+=o+1,o=0);let c={sprite:e,x:i,y:a,w:t,h:r};return i+=t+1,s=Math.max(s,i),o=Math.max(o,r),c}),l=a+o,u=c.map(({sprite:e,x:t,y:n,w:r,h:i})=>`<svg x="${t}" y="${n}" width="${r}" height="${i}" viewBox="0 0 ${e.box.width} ${e.box.height}" preserveAspectRatio="none" overflow="hidden">${e.svg}</svg>`).join(``),d=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${s}" height="${l}" viewBox="0 0 ${s} ${l}"><style>${r}</style>${t}${u}</svg>`,f=URL.createObjectURL(new Blob([d],{type:`image/svg+xml`}));try{let e=new Image;e.src=f,yield e.decode();let t=[];for(let n of c)t.push({id:n.sprite.id,bitmap:yield createImageBitmap(e,n.x,n.y,n.w,n.h)});return t}finally{URL.revokeObjectURL(f)}});return function(t,n,r,i){return e.apply(this,arguments)}}(),qe=e=>{let t=e,n=Number(t==null?void 0:t.width),r=Number(t==null?void 0:t.height);if(!(n>0&&r>0&&n<1e4&&r<1e4))throw Error(`A sprite's box must have a positive width and height, got ${JSON.stringify(e)}`);return{width:n,height:r,anchor:Array.isArray(t.anchor)?[Number(t.anchor[0]),Number(t.anchor[1])]:[n/2,r/2]}},Je=e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)},Ye=e=>e instanceof Error?e.message:String(e),Xe=[[`bounds`,`Bounds`,`The scene's width and height`],[`grid`,`Grid`,`Lines every grid step, for a scene that sets grid`],[`boxes`,`Boxes`,`Each sprite's box, as it's turned and scaled`],[`anchors`,`Anchors`,`Each node's anchor; hollow for a node with no sprite`],[`keys`,`Keys`,`Each node's key`]],Ze={render:`render threw`,sprites:`A sprite couldn't be made`,scene:`Puzzmo would refuse this scene`};function Qe(e){let t=y(),i,a=null,o=!1,s=null,c=null,l,u=[],d=[],f=null,p=!1,m=null,h=null,g=null,_=`session`,v=null,x=[],S=!1,C=e=>i.getElement(`#sim-pmmg-${e}`),w=()=>({bounds:t.bounds,grid:t.grid,boxes:t.boxes,anchors:t.anchors,keys:t.keys,boxOf:e=>c==null?void 0:c.anySprite(e),hovered:h,highlighted:g,devicePixelRatio:window.devicePixelRatio||1}),T=()=>({fidelity:t.fidelity,backgroundStyle:t.backgroundStyle===`theme`?void 0:t.backgroundStyle}),E=()=>{if(x.length)return x[x.length-1];let e=i.state.puzzleData;return e===null?null:{puzzle:e,input:i.state.currentInputStr}},D=function(){var t=n.t(function*(){s=null,o=!0,N();try{var t;let n=yield e(),r=(t=n==null?void 0:n.default)==null?n:t,i=r==null?void 0:r.table;if(!i||typeof i.render!=`function`){s=`The pmmg bundle has no table capability: export default createPmmgBundle({ table: { contract: 1, render } })`;return}l=i.contract,u=Array.isArray(i.fonts)?i.fonts.filter(e=>typeof e==`string`):[];let a=yield He(i.fonts);d=a.warnings,l!==1&&d.push(`contract is ${JSON.stringify(l)}, and Puzzmo knows contract 1`),c=Ve(i,{fontFaces:a.fontFaces}),c.onRender=()=>N()}catch(e){s=`The pmmg bundle didn't load: ${tt(e)}`,a=null}finally{o=!1}});return function(){return t.apply(this,arguments)}}(),O=function(){var e=n.t(function*(){var e;yield(e=a)==null?a=D():e,c&&!f?k(!1):S&&t.follow&&A(),N()});return function(){return e.apply(this,arguments)}}(),k=e=>{let t=E(),n=C(`canvas`),a=C(`stage`);if(!c||!t||!n||!a)return N();f==null||f.dispose(),p=!1,m=null,h=null;let o=new r.t(n,c,`simulator`,()=>{f===o&&(p=!0,N())});f=o,o.onDrawn=e=>{f===o&&(m=e,Fe(e,w()))},o.resize(a.clientWidth,a.clientHeight),o.setLook(T()),o.setTheme(i.state.selectedTheme);let s=e?x[x.length-2]:void 0;s&&o.update(s),o.update(t),S=!1,N()},A=()=>{let e=E();f&&e&&f.update(e),S=!1},j=e=>{let n=x[x.length-1];if(n&&n.puzzle===e.puzzle&&n.input===e.input)return;x.push(e),x.length>2&&x.shift();let r=i.state.activeTab===`pmmg`;r&&c&&!f?k(!1):t.follow&&r&&f?f.update(e):t.follow&&(S=!0),M()},M=()=>{let e=C(`replay`);e&&(e.disabled=!c||x.length<2)},N=()=>{if(!i)return;P(),M(),ee(),F();let e=C(`sprite-count`),n=c==null?void 0:c.latest;e&&(e.textContent=n?` ${c.spritesAt(n.update.pixelsPerUnit).length}`:``),t.subtab===`sprites`&&I(),t.subtab===`scene`&&ne()},P=()=>{let e=C(`status`);if(!e)return;if(s)return void(e.innerHTML=`<span class="pmmg-error">${X(s)}</span>`);if(!c)return void(e.textContent=o?`Loading the pmmg bundle…`:`Open this tab to load the pmmg bundle`);let t=_===`table`?`Drawing what neighbours see: the game's UPDATE_TABLE_GAME_STATE`:`Drawing the session's puzzle and saves, as the game hasn't sent UPDATE_TABLE_GAME_STATE (sdk.table.updateGameState)`,n=E()?``:`<div class="pmmg-dim">Waiting for the game's first state</div>`;e.innerHTML=`
237
+ `},bind(e){let t=e.getElement(`#simulator-thumb-refresh`);t==null||t.addEventListener(`click`,()=>e.updateThumbnail());let n=e.getElement(`#simulator-render-host-select`),r=e.getElement(`#simulator-render-context-select`),i=e.getElement(`#simulator-render-host-field`),a=e.getElement(`#simulator-render-context-field`),o=e.getElement(`#simulator-preview-kind`),s=()=>{let t=e.state.previewKind!==`text`;i&&(i.style.display=t?`block`:`none`),a&&(a.style.display=t&&e.state.renderHost===`opengraph`?`block`:`none`)},c=()=>{o==null||o.querySelectorAll(`.simulator-segmented-btn`).forEach(t=>{let n=t.dataset.previewKind;t.classList.toggle(`active`,n===e.state.previewKind),t.setAttribute(`aria-selected`,n===e.state.previewKind?`true`:`false`)})};o==null||o.querySelectorAll(`.simulator-segmented-btn`).forEach(t=>{t.addEventListener(`click`,()=>{let n=t.dataset.previewKind;!n||n===e.state.previewKind||(e.state.previewKind=n,L(n),c(),s(),e.updateThumbnail())})}),n&&(e.state.renderHost||(e.state.renderHost=`game`,I(e.state.renderHost)),n.value=e.state.renderHost||`game`,n.addEventListener(`change`,()=>{e.state.renderHost=n.value,I(e.state.renderHost),s(),e.updateThumbnail()})),r&&(e.state.renderContext||(e.state.renderContext=`preview`,R(e.state.renderContext)),r.value=e.state.renderContext||`preview`,r.addEventListener(`change`,()=>{e.state.renderContext=r.value,R(e.state.renderContext),e.updateThumbnail()})),c(),s()},onActivate(e){setTimeout(()=>e.updateThumbnail(),0)},updatePreview:e=>{let t=e.getElement(`#simulator-thumb-preview`),n=e.getElement(`#simulator-thumb-fn`);if(t==null||t.style.setProperty(`--sim-thumb-bg`,e.state.selectedTheme.g_bg),e.state.previewKind===`text`){let s=ke();if(!s){t&&(t.innerHTML=Ne),n&&(n.textContent=``);return}n&&(n.textContent=`Using: getShareString()`);try{var r,i,a,o;let n=(r=e.gameSlug)==null?`game`:r,c=s((i=e.state.currentInputStr)==null?``:i,Me(n),{puzzleString:(a=e.state.puzzleData)==null?``:a,dateKey:je(),gameplaySlug:`simulator:${n}`}),l=(o=c==null?void 0:c.str)==null?``:o;t&&(t.innerHTML=`<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ae(l)}</pre>`)}catch(e){console.error(`Simulator: Share string error`,e),t&&(t.innerHTML=`<span class="simulator-empty">Error: ${e}</span>`)}return}let s=Oe();if(!s){t&&(t.innerHTML=`<span class="simulator-empty">No thumbnail function found</span>`),n&&(n.textContent=``);return}n&&(n.textContent=`Using: ${s.name}()`);try{var c;let n=(c=e.state.puzzleData)==null?``:c,r={viewerIsOwner:!0,theme:e.state.selectedTheme,strict:!0,renderHost:e.state.renderHost,renderContext:e.state.renderContext},{svg:i}=U(s.fn(n,e.state.currentInputStr,r));t&&(t.innerHTML=i)}catch(e){console.error(`Simulator: Thumbnail error`,e),t&&(t.innerHTML=`<span class="simulator-empty">Error: ${e}</span>`)}}}}var J={bounds:`#ffd700`,grid:`rgba(96, 165, 250, 0.35)`,box:`rgba(34, 211, 238, 0.85)`,exiting:`#f87171`,hovered:`#ffd700`,highlighted:`#f472b6`,anchor:`#f472b6`,group:`#a78bfa`,label:`#e8e8e8`,labelBackground:`rgba(15, 15, 26, 0.8)`};const Fe=(e,t)=>{let{ctx:n,scale:r,scene:i,nodes:a}=e,o=t.devicePixelRatio,s=([e,t])=>[e*r,t*r];if(n.save(),n.lineWidth=o,t.grid&&i.grid&&i.width/i.grid+i.height/i.grid<=400){n.strokeStyle=J.grid,n.beginPath();for(let e=i.grid;e<i.width;e+=i.grid){let t=Math.round(e*r)+o/2;n.moveTo(t,0),n.lineTo(t,i.height*r)}for(let e=i.grid;e<i.height;e+=i.grid){let t=Math.round(e*r)+o/2;n.moveTo(0,t),n.lineTo(i.width*r,t)}n.stroke()}t.bounds&&(n.strokeStyle=J.bounds,n.setLineDash([4*o,3*o]),n.strokeRect(o/2,o/2,i.width*r-o,i.height*r-o),n.setLineDash([]));for(let e of a){let r=e.sprite?t.boxOf(e.sprite):void 0,i=e.key===t.hovered,a=!!e.sprite&&e.sprite===t.highlighted;if(r&&(t.boxes||i||a)){let t=Ie(e.matrix,r).map(s);n.strokeStyle=i?J.hovered:a?J.highlighted:e.exiting?J.exiting:J.box,n.lineWidth=(i||a?2:1)*o,n.setLineDash(e.alpha<=0?[3*o,3*o]:[]),n.beginPath(),t.forEach(([e,t],r)=>r?n.lineTo(e,t):n.moveTo(e,t)),n.closePath(),n.stroke(),n.setLineDash([]),n.lineWidth=o}if(t.anchors){let[t,i]=s(Re(e.matrix,[0,0]));r?(n.fillStyle=J.anchor,n.fillRect(t-1.5*o,i-1.5*o,3*o,3*o)):(n.strokeStyle=J.group,n.beginPath(),n.moveTo(t,i-4*o),n.lineTo(t+4*o,i),n.lineTo(t,i+4*o),n.lineTo(t-4*o,i),n.closePath(),n.stroke())}}if(t.keys){n.font=`${9*o}px Menlo, Monaco, monospace`,n.textBaseline=`top`;for(let e of a){let r=e.sprite?t.boxOf(e.sprite):void 0,[i,a]=r?Be(Ie(e.matrix,r).map(s)):s(Re(e.matrix,[0,0])),c=n.measureText(e.key).width;n.fillStyle=J.labelBackground,n.fillRect(i,a,c+4*o,11*o),n.fillStyle=J.label,n.fillText(e.key,i+2*o,a+o)}}n.restore()},Ie=(e,t)=>{let[n,r]=t.anchor;return[[-n,-r],[t.width-n,-r],[t.width-n,t.height-r],[-n,t.height-r]].map(t=>Re(e,t))},Le=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(!i.sprite||i.alpha<=0)continue;let a=n(i.sprite),o=a&&ze(i.matrix,t);if(!a||!o)continue;let s=o[0]+a.anchor[0],c=o[1]+a.anchor[1];if(s>=0&&c>=0&&s<=a.width&&c<=a.height)return i}return null};var Re=(e,[t,n])=>[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]],ze=(e,[t,n])=>{let r=e[0]*e[3]-e[1]*e[2];if(Math.abs(r)<1e-12)return null;let i=t-e[4],a=n-e[5];return[(e[3]*i-e[2]*a)/r,(-e[1]*i+e[0]*a)/r]},Be=e=>[Math.min(...e.map(e=>e[0])),Math.min(...e.map(e=>e[1]))];const Ve=(e,i={})=>{var a,o;let s=(a=i.rasterise)==null?Ge:a,c=(o=i.fontFaces)==null?``:o,l=new Map,u=new Map,d=new Set,f=0,p=!1,m=null,h=e=>{g.warnings.includes(e)||g.warnings.push(e)},g={render:function(){var i=n.t(function*(n){let i=n.pixelsPerUnit,a={render:++f,update:n,renderMs:0,spritesMs:0,made:[]};g.latest=a;let o=`render`;try{var _,v;p&&u.clear(),p=!1;let f=(_=u.get(i))==null?u.set(i,new Set).get(i):_,g=(v=l.get(i))==null?l.set(i,new Map).get(i):v,b=new Map,x=[],S=[],C=[],w=(e,t,n)=>{var r;let a=`${i}|${e}`,o=g.get(e),s=(r=b.get(e))==null?o&&{box:o,svg:o.svg}:r;if(!s||d.has(a))return;d.add(a);let c;try{c=qe(t)}catch(e){return}c.width===s.box.width&&c.height===s.box.height&&c.anchor[0]===s.box.anchor[0]&&c.anchor[1]===s.box.anchor[1]?n!==void 0&&s.svg!==void 0&&n!==s.svg&&h(`"${e}" was made again with different SVG. Puzzmo keeps the first, so put what differs into the ID`):h(`"${e}" was made again with a different box. Puzzmo keeps the first, so put what differs into the ID`)},T={has:e=>f.has(e)||b.has(e),draw(e,n,r){if(T.has(e))return w(e,n);let o=qe(n);m!=null||(m=new OffscreenCanvas(1,1)),m.width=Math.max(1,Math.ceil(o.width*i)),m.height=Math.max(1,Math.ceil(o.height*i));let s=m.getContext(`2d`);s.setTransform(i,0,0,i,0,0),r(s),b.set(e,{box:o}),x.push(t.t(t.t({id:e,kind:`draw`,bitmap:m.transferToImageBitmap()},o),{},{pixelsPerUnit:i,render:a.render}))},svg(e,t,n,r){if(T.has(e))return w(e,t,String(n));let i=qe(t),a=r?String(r):``,o=C.indexOf(a);o<0&&(o=C.push(a)-1),b.set(e,{box:i,svg:String(n)}),S.push({id:e,box:i,svg:String(n),defs:o})}},E=performance.now(),D=e.render(n,T);if(a.renderMs=performance.now()-E,D&&typeof D.then==`function`)throw Error(`render returned a Promise. Puzzmo's sandbox doesn't wait for one, so build the scene and return it`);for(let e of b.keys())f.add(e);try{D=structuredClone(D)}catch(e){throw Error(`The scene can't leave the sandbox: ${Ye(e)}`)}a.raw=D,o=`sprites`;let ee=performance.now(),O=S.length?yield s(S,C,i,c):[];a.spritesMs=performance.now()-ee;for(let{id:e,bitmap:n}of O){let r=S.find(t=>t.id===e);x.push(t.t(t.t({id:e,kind:`svg`,bitmap:n},r.box),{},{svg:r.svg,pixelsPerUnit:i,render:a.render}))}for(let e of x){var y;(y=g.get(e.id))==null||y.bitmap.close(),g.set(e.id,e)}a.made=x.map(e=>e.id),o=`scene`;let k=r.a(D),A=[...r.i(k)].filter(e=>!g.has(e));if(A.length)throw Error(`The scene names sprites it never made: ${A.slice(0,5).join(`, `)}`);return a.scene=k,k}catch(e){throw p=!0,a.error={phase:o,message:Ye(e),stack:e instanceof Error?e.stack:void 0},e}finally{var b;(b=g.onRender)==null||b.call(g,a)}});return function(e){return i.apply(this,arguments)}}(),sprite:(e,t)=>{var n;return(n=l.get(t))==null?void 0:n.get(e)},spritesAt:e=>{var t,n;return[...(t=(n=l.get(e))==null?void 0:n.values())==null?[]:t]},anySprite:e=>{let t;for(let n of l.values()){let r=n.get(e);r&&(!t||r.render>t.render)&&(t=r)}return t},resolutions:()=>[...l.keys()],warnings:[],latest:null,clear(){for(let e of l.values())for(let t of e.values())t.bitmap.close();l.clear(),u.clear(),d.clear(),g.warnings.length=0}};return g},He=function(){var e=n.t(function*(e){let t=[],n=[],r=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];for(let e of r){if(!i.r.includes(e)){t.push(`fonts names "${e}", which isn't a Puzzmo font, so the table won't load it`);continue}try{let t=yield fetch(i.i(e));if(!t.ok)throw Error(`the CDN answered ${t.status}`);let r=yield t.arrayBuffer();document.fonts.add(yield new FontFace(e,r.slice(0)).load()),n.push(`@font-face{font-family:"${e.replace(/["\\]/g,``)}";src:url(data:font/woff2;base64,${Je(r)})}`)}catch(n){t.push(`The font ${e} didn't load: ${Ye(n)}`)}}return{fontFaces:n.join(``),warnings:t}});return function(t){return e.apply(this,arguments)}}();var Ue=64,We=4096;const Ge=function(){var e=n.t(function*(e,t,n,r){var i;let a=[],o=new Map;for(let t of e)o.set(t.defs,[...(i=o.get(t.defs))==null?[]:i,t]);for(let[e,i]of o)for(let o=0;o<i.length;o+=Ue){let s=i.slice(o,o+Ue);try{a.push(...yield Ke(s,t[e],n,r))}catch(i){let a=[];for(let i of s)yield Ke([i],t[e],n,r).catch(()=>a.push(i.id));let o=a.length?`${a.slice(0,5).join(`, `)} won't decode`:Ye(i);throw Error(`An SVG sprite couldn't be drawn: ${o}`)}}return a});return function(t,n,r,i){return e.apply(this,arguments)}}();var Ke=function(){var e=n.t(function*(e,t,n,r){let i=0,a=0,o=0,s=1,c=e.map(e=>{let t=Math.max(1,Math.ceil(e.box.width*n)),r=Math.max(1,Math.ceil(e.box.height*n));i>0&&i+t>We&&(i=0,a+=o+1,o=0);let c={sprite:e,x:i,y:a,w:t,h:r};return i+=t+1,s=Math.max(s,i),o=Math.max(o,r),c}),l=a+o,u=c.map(({sprite:e,x:t,y:n,w:r,h:i})=>`<svg x="${t}" y="${n}" width="${r}" height="${i}" viewBox="0 0 ${e.box.width} ${e.box.height}" preserveAspectRatio="none" overflow="hidden">${e.svg}</svg>`).join(``),d=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${s}" height="${l}" viewBox="0 0 ${s} ${l}"><style>${r}</style>${t}${u}</svg>`,f=URL.createObjectURL(new Blob([d],{type:`image/svg+xml`}));try{let e=new Image;e.src=f,yield e.decode();let t=[];for(let n of c)t.push({id:n.sprite.id,bitmap:yield createImageBitmap(e,n.x,n.y,n.w,n.h)});return t}finally{URL.revokeObjectURL(f)}});return function(t,n,r,i){return e.apply(this,arguments)}}(),qe=e=>{let t=e,n=Number(t==null?void 0:t.width),r=Number(t==null?void 0:t.height);if(!(n>0&&r>0&&n<1e4&&r<1e4))throw Error(`A sprite's box must have a positive width and height, got ${JSON.stringify(e)}`);return{width:n,height:r,anchor:Array.isArray(t.anchor)?[Number(t.anchor[0]),Number(t.anchor[1])]:[n/2,r/2]}},Je=e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)},Ye=e=>e instanceof Error?e.message:String(e),Xe=[[`bounds`,`Bounds`,`The scene's width and height`],[`grid`,`Grid`,`Lines every grid step, for a scene that sets grid`],[`boxes`,`Boxes`,`Each sprite's box, as it's turned and scaled`],[`anchors`,`Anchors`,`Each node's anchor; hollow for a node with no sprite`],[`keys`,`Keys`,`Each node's key`]],Ze={render:`render threw`,sprites:`A sprite couldn't be made`,scene:`Puzzmo would refuse this scene`};function Qe(e){let t=y(),i,a=null,o=!1,s=null,c=null,l,u=[],d=[],f=null,p=!1,m=null,h=null,g=null,_=`session`,v=null,x=!1,S=[],C=!1,w=e=>i.getElement(`#sim-pmmg-${e}`),T=()=>({bounds:t.bounds,grid:t.grid,boxes:t.boxes,anchors:t.anchors,keys:t.keys,boxOf:e=>c==null?void 0:c.anySprite(e),hovered:h,highlighted:g,devicePixelRatio:window.devicePixelRatio||1}),E=()=>({fidelity:t.fidelity,backgroundStyle:t.backgroundStyle===`theme`?void 0:t.backgroundStyle}),D=()=>{if(S.length)return S[S.length-1];let e=i.state.puzzleData;return e===null?null:{puzzle:e,input:i.state.currentInputStr}},ee=function(){var t=n.t(function*(){s=null,o=!0,N();try{var t;let n=yield e(),r=(t=n==null?void 0:n.default)==null?n:t,i=r==null?void 0:r.table;if(!i||typeof i.render!=`function`){s=`The pmmg bundle has no table capability: export default createPmmgBundle({ table: { contract: 1, render } })`;return}l=i.contract,u=Array.isArray(i.fonts)?i.fonts.filter(e=>typeof e==`string`):[];let a=yield He(i.fonts);d=a.warnings,l!==1&&d.push(`contract is ${JSON.stringify(l)}, and Puzzmo knows contract 1`),c=Ve(i,{fontFaces:a.fontFaces}),c.onRender=()=>N()}catch(e){s=`The pmmg bundle didn't load: ${tt(e)}`,a=null}finally{o=!1}});return function(){return t.apply(this,arguments)}}(),O=function(){var e=n.t(function*(){var e;yield(e=a)==null?a=ee():e,c&&!f?k(!1):C&&t.follow&&A(),N()});return function(){return e.apply(this,arguments)}}(),k=e=>{let t=D(),n=w(`canvas`),a=w(`stage`);if(!c||!t||!n||!a)return N();f==null||f.dispose(),p=!1,m=null,h=null;let o=new r.t(n,c,`simulator`,()=>{f===o&&(p=!0,N())});f=o,o.onDrawn=e=>{f===o&&(m=e,Fe(e,T()))},o.resize(a.clientWidth,a.clientHeight),o.setLook(E()),o.setTheme(i.state.selectedTheme);let s=e?S[S.length-2]:void 0;s&&o.update(s),o.update(t),C=!1,N()},A=()=>{let e=D();f&&e&&f.update(e),C=!1},j=e=>{let n=S[S.length-1];if(n&&n.puzzle===e.puzzle&&n.input===e.input)return;S.push(e),S.length>2&&S.shift();let r=i.state.activeTab===`pmmg`;r&&c&&!f?k(!1):t.follow&&r&&f?f.update(e):t.follow&&(C=!0),M()},M=()=>{let e=w(`replay`);e&&(e.disabled=!c||S.length<2)},N=()=>{if(!i)return;P(),M(),F(),I();let e=w(`sprite-count`),n=c==null?void 0:c.latest;e&&(e.textContent=n?` ${c.spritesAt(n.update.pixelsPerUnit).length}`:``),t.subtab===`sprites`&&L(),t.subtab===`scene`&&re()},P=()=>{let e=w(`status`);if(!e)return;if(s)return void(e.innerHTML=`<span class="pmmg-error">${X(s)}</span>`);if(!c)return void(e.textContent=o?`Loading the pmmg bundle…`:`Open this tab to load the pmmg bundle`);let t=_===`table`?`Drawing what neighbours see: the game's UPDATE_TABLE_GAME_STATE`:`Drawing the session's puzzle and saves, as the game hasn't sent UPDATE_TABLE_GAME_STATE (sdk.table.updateGameState)`,n=D()?``:`<div class="pmmg-dim">Waiting for the game's first state</div>`;e.innerHTML=`
238
238
  <div>table · contract ${X(String(l))} · fonts: ${X(u.join(`, `)||`none`)}</div>
239
- <div class="pmmg-dim">${X(t)}</div>${n}`},ee=()=>{var e,t;let n=C(`stats`),r=c==null?void 0:c.latest;if(!n)return;if(!r)return void(n.textContent=``);let i=r.scene,a=[i&&[`${Y(i.width)}×${Y(i.height)} units`,`${i.nodes.length} nodes`,`${(e=(t=i.effects)==null?void 0:t.length)==null?0:e} effects`,i.grid&&`grid ${Y(i.grid)}`],[`render #${r.render}: ${Y(r.renderMs)} ms`,r.spritesMs&&`${Y(r.spritesMs)} ms of SVG`,`made ${r.made.length}`,`${Y(r.update.pixelsPerUnit)} px/unit`,r.update.skipped&&`${r.update.skipped} skipped`]].filter(e=>!!e).map(e=>e.filter(Boolean).join(` · `)).map(e=>`<div>${X(e)}</div>`);matchMedia(`(prefers-reduced-motion: reduce)`).matches&&a.push(`<div class="pmmg-dim">Reduced motion is on, so changes show at once, as they do at the table</div>`),n.innerHTML=a.join(``)},F=()=>{var e;let t=C(`problems`);if(!t)return;let n=c==null?void 0:c.latest,r=[];if(n!=null&&n.error){let e=n.error.stack&&n.error.stack!==n.error.message?n.error.stack:``;r.push(`<div class="pmmg-problem error"><b>${Ze[n.error.phase]}</b> ${X(n.error.message)}
240
- ${e?`<details><summary>Stack</summary><pre class="pmmg-json">${X(e)}</pre></details>`:``}</div>`)}p&&r.push(`<div class="pmmg-problem error">The board stopped, as a neighbour's does after its renders fail. Redraw to start again.</div>`);for(let t of[...d,...(e=c==null?void 0:c.warnings)==null?[]:e])r.push(`<div class="pmmg-problem warn">${X(t)}</div>`);c&&r.push(`<div class="pmmg-problem note">The bundle runs in this page here. At the table it runs in a worker with no DOM and no network, so anything that reaches for window, document or fetch only works here.</div>`),t.innerHTML=r.join(``)},I=()=>{var e,t;let n=C(`sprites`),i=C(`sprite-summary`);if(!n||!i)return;let a=c==null?void 0:c.latest;if(!c||!a){n.replaceChildren(),i.textContent=c?`Nothing rendered yet`:``,R([]);return}let o=a.update.pixelsPerUnit,s=c.spritesAt(o).sort((e,t)=>e.id.localeCompare(t.id)),l=a.scene?r.i(a.scene):null,u=((e=(t=C(`filter`))==null?void 0:t.value)==null?``:e).trim().toLowerCase(),d=u?s.filter(e=>e.id.toLowerCase().includes(u)):s,f=l?s.filter(e=>!l.has(e.id)).length:0,p=c.resolutions().filter(e=>e!==o);i.textContent=[`${s.length} at ${Y(o)} px/unit`,f&&`${f} not in this scene`,p.length&&`also made at ${p.map(Y).join(`, `)}`,u&&`${d.length} match`].filter(Boolean).join(` · `),n.replaceChildren(...d.map(e=>L(e,l))),R(s)},L=(e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`pmmg-sprite${t&&!t.has(e.id)?` unused`:``}${e.id===g?` selected`:``}`,n.title=`${e.id}\n${Y(e.width)}×${Y(e.height)} units, ${e.kind}${t&&!t.has(e.id)?`, not in this scene`:``}`;let r=document.createElement(`span`);r.className=`pmmg-sprite-picture`,r.append($e(e,72,64));let i=document.createElement(`span`);i.className=`pmmg-sprite-id`,i.textContent=e.id;let a=document.createElement(`span`);return a.className=`pmmg-sprite-meta`,a.textContent=`${Y(e.width)}×${Y(e.height)} ${e.kind}`,n.append(r,i,a),n.addEventListener(`click`,()=>z(g===e.id?null:e.id)),n},R=e=>{var t,n;let r=C(`detail`);if(!r)return;let i=g?e.find(e=>e.id===g):void 0;if(!i)return void(r.innerHTML=``);let a=te(i.id);r.innerHTML=`
239
+ <div class="pmmg-dim">${X(t)}</div>${n}`},F=()=>{var e,t;let n=w(`stats`),r=c==null?void 0:c.latest;if(!n)return;if(!r)return void(n.textContent=``);let i=r.scene,a=[i&&[`${Y(i.width)}×${Y(i.height)} units`,`${i.nodes.length} nodes`,`${(e=(t=i.effects)==null?void 0:t.length)==null?0:e} effects`,i.grid&&`grid ${Y(i.grid)}`],[`render #${r.render}: ${Y(r.renderMs)} ms`,r.spritesMs&&`${Y(r.spritesMs)} ms of SVG`,`made ${r.made.length}`,`${Y(r.update.pixelsPerUnit)} px/unit`,r.update.skipped&&`${r.update.skipped} skipped`]].filter(e=>!!e).map(e=>e.filter(Boolean).join(` · `)).map(e=>`<div>${X(e)}</div>`);matchMedia(`(prefers-reduced-motion: reduce)`).matches&&a.push(`<div class="pmmg-dim">Reduced motion is on, so changes show at once, as they do at the table</div>`),n.innerHTML=a.join(``)},I=()=>{var e;let t=w(`problems`);if(!t)return;let n=c==null?void 0:c.latest,r=[];if(n!=null&&n.error){let e=n.error.stack&&n.error.stack!==n.error.message?n.error.stack:``;r.push(`<div class="pmmg-problem error"><b>${Ze[n.error.phase]}</b> ${X(n.error.message)}
240
+ ${e?`<details><summary>Stack</summary><pre class="pmmg-json">${X(e)}</pre></details>`:``}</div>`)}p&&r.push(`<div class="pmmg-problem error">The board stopped, as a neighbour's does after its renders fail. Redraw to start again.</div>`),x&&_===`session`&&r.push(`<div class="pmmg-problem warn">The game has loaded but hasn't sent its table state, so at the table nobody sees this player until it does. Call <code>sdk.table.updateGameState(input, { puzzleString })</code> once the board is built, before <code>gameLoaded()</code>, not only after a move.</div>`);for(let t of[...d,...(e=c==null?void 0:c.warnings)==null?[]:e])r.push(`<div class="pmmg-problem warn">${X(t)}</div>`);c&&r.push(`<div class="pmmg-problem note">The bundle runs in this page here. At the table it runs in a worker with no DOM and no network, so anything that reaches for window, document or fetch only works here.</div>`),t.innerHTML=r.join(``)},L=()=>{var e,t;let n=w(`sprites`),i=w(`sprite-summary`);if(!n||!i)return;let a=c==null?void 0:c.latest;if(!c||!a){n.replaceChildren(),i.textContent=c?`Nothing rendered yet`:``,te([]);return}let o=a.update.pixelsPerUnit,s=c.spritesAt(o).sort((e,t)=>e.id.localeCompare(t.id)),l=a.scene?r.i(a.scene):null,u=((e=(t=w(`filter`))==null?void 0:t.value)==null?``:e).trim().toLowerCase(),d=u?s.filter(e=>e.id.toLowerCase().includes(u)):s,f=l?s.filter(e=>!l.has(e.id)).length:0,p=c.resolutions().filter(e=>e!==o);i.textContent=[`${s.length} at ${Y(o)} px/unit`,f&&`${f} not in this scene`,p.length&&`also made at ${p.map(Y).join(`, `)}`,u&&`${d.length} match`].filter(Boolean).join(` · `),n.replaceChildren(...d.map(e=>R(e,l))),te(s)},R=(e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`pmmg-sprite${t&&!t.has(e.id)?` unused`:``}${e.id===g?` selected`:``}`,n.title=`${e.id}\n${Y(e.width)}×${Y(e.height)} units, ${e.kind}${t&&!t.has(e.id)?`, not in this scene`:``}`;let r=document.createElement(`span`);r.className=`pmmg-sprite-picture`,r.append($e(e,72,64));let i=document.createElement(`span`);i.className=`pmmg-sprite-id`,i.textContent=e.id;let a=document.createElement(`span`);return a.className=`pmmg-sprite-meta`,a.textContent=`${Y(e.width)}×${Y(e.height)} ${e.kind}`,n.append(r,i,a),n.addEventListener(`click`,()=>ne(g===e.id?null:e.id)),n},te=e=>{var t,n;let r=w(`detail`);if(!r)return;let i=g?e.find(e=>e.id===g):void 0;if(!i)return void(r.innerHTML=``);let a=z(i.id);r.innerHTML=`
241
241
  <div class="pmmg-detail">
242
242
  <div class="pmmg-detail-head">
243
243
  <span class="pmmg-detail-id">${X(i.id)}</span>
@@ -252,7 +252,7 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
252
252
  <dt>Used by</dt><dd>${a.length?X(a.slice(0,24).join(`, `)+(a.length>24?`, and ${a.length-24} more`:``)):`nothing in this scene`}</dd>
253
253
  </dl>
254
254
  ${i.svg?`<details><summary>SVG, ${i.svg.length.toLocaleString()} characters</summary><pre class="pmmg-json">${X(i.svg)}</pre></details>`:``}
255
- </div>`,(t=r.querySelector(`.pmmg-detail-picture`))==null||t.append($e(i,300,160)),(n=r.querySelector(`[data-pmmg-deselect]`))==null||n.addEventListener(`click`,()=>z(null))},te=e=>{var t,n;let r=c==null||(t=c.latest)==null?void 0:t.scene;if(!r)return[];let i=t=>[t.enter,t.exit].some(t=>t==null?void 0:t.keyframes.some(t=>t.sprite===e)),a=r.nodes.filter(t=>t.sprite===e||i(t)).map(e=>e.key),o=((n=r.effects)==null?[]:n).filter(t=>t.keyframes.some(t=>t.sprite===e)).map(e=>`${e.key} (effect)`);return[...a,...o]},z=e=>{g=e,t.subtab===`sprites`&&I(),f==null||f.redraw()},ne=()=>{var e;let t=C(`update`),n=C(`scene`),r=c==null?void 0:c.latest;if(!(!t||!n)){if(!r){t.textContent=``,n.textContent=c?`Nothing rendered yet`:``;return}t.textContent=[`render #${r.render}`,`puzzle ${r.update.puzzle.length.toLocaleString()} chars`,`input ${r.update.input.length.toLocaleString()} chars`,r.update.previous?`animating from the board before`:`first draw`,`${r.update.skipped} skipped`,`${r.update.fidelity} fidelity on ${r.update.backgroundStyle}`,r.scene?`as Puzzmo keeps it`:`as returned, since Puzzmo refused it`].join(` · `),n.textContent=et((e=r.scene)==null?r.raw:e)}},B=()=>{let e=C(`root`);e==null||e.querySelectorAll(`[data-pmmg-subtab]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.pmmgSubtab===t.subtab)}),e==null||e.querySelectorAll(`[data-pmmg-pane]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.pmmgPane===t.subtab)}),N()},V=e=>{let t=C(`canvas`);if(!t||!m)return null;let n=t.getBoundingClientRect();if(!n.width)return null;let r=t.width/n.width;return[(e.clientX-n.left)*r/m.scale,(e.clientY-n.top)*r/m.scale]},H=e=>{var t;let n=C(`hover`);if(!n)return;let r=e&&m?Le(m.nodes,e,e=>c==null?void 0:c.anySprite(e)):null,i=r?m.scene.nodes.find(e=>e.key===r.key):void 0,a=(t=r==null?void 0:r.key)==null?null:t;if(a!==h&&(h=a,f==null||f.redraw()),!e)return void(n.textContent=`Hover the board to see a node, click one to pick its sprite`);if(!r)return void(n.textContent=`${Y(e[0])}, ${Y(e[1])}`);n.textContent=[r.key,r.sprite,i&&`at ${Y(i.x)}, ${Y(i.y)}`,(i==null?void 0:i.rotation)&&`${Y(i.rotation)}°`,(i==null?void 0:i.scale)&&`scale ${i.scale.map(Y).join(`, `)}`,(i==null?void 0:i.opacity)!==void 0&&`opacity ${Y(i.opacity)}`,(i==null?void 0:i.tint)&&`tint ${i.tint}`,(i==null?void 0:i.brightness)!==void 0&&`brightness ${Y(i.brightness)}`,(i==null?void 0:i.blend)&&i.blend!==`normal`&&i.blend,(i==null?void 0:i.parent)&&`in ${i.parent}`,r.exiting&&`exiting`].filter(Boolean).join(` · `)};return{id:`pmmg`,label:`Pmmg`,render(){return`
255
+ </div>`,(t=r.querySelector(`.pmmg-detail-picture`))==null||t.append($e(i,300,160)),(n=r.querySelector(`[data-pmmg-deselect]`))==null||n.addEventListener(`click`,()=>ne(null))},z=e=>{var t,n;let r=c==null||(t=c.latest)==null?void 0:t.scene;if(!r)return[];let i=t=>[t.enter,t.exit].some(t=>t==null?void 0:t.keyframes.some(t=>t.sprite===e)),a=r.nodes.filter(t=>t.sprite===e||i(t)).map(e=>e.key),o=((n=r.effects)==null?[]:n).filter(t=>t.keyframes.some(t=>t.sprite===e)).map(e=>`${e.key} (effect)`);return[...a,...o]},ne=e=>{g=e,t.subtab===`sprites`&&L(),f==null||f.redraw()},re=()=>{var e;let t=w(`update`),n=w(`scene`),r=c==null?void 0:c.latest;if(!(!t||!n)){if(!r){t.textContent=``,n.textContent=c?`Nothing rendered yet`:``;return}t.textContent=[`render #${r.render}`,`puzzle ${r.update.puzzle.length.toLocaleString()} chars`,`input ${r.update.input.length.toLocaleString()} chars`,r.update.previous?`animating from the board before`:`first draw`,`${r.update.skipped} skipped`,`${r.update.fidelity} fidelity on ${r.update.backgroundStyle}`,r.scene?`as Puzzmo keeps it`:`as returned, since Puzzmo refused it`].join(` · `),n.textContent=et((e=r.scene)==null?r.raw:e)}},B=()=>{let e=w(`root`);e==null||e.querySelectorAll(`[data-pmmg-subtab]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.pmmgSubtab===t.subtab)}),e==null||e.querySelectorAll(`[data-pmmg-pane]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.pmmgPane===t.subtab)}),N()},V=e=>{let t=w(`canvas`);if(!t||!m)return null;let n=t.getBoundingClientRect();if(!n.width)return null;let r=t.width/n.width;return[(e.clientX-n.left)*r/m.scale,(e.clientY-n.top)*r/m.scale]},H=e=>{var t;let n=w(`hover`);if(!n)return;let r=e&&m?Le(m.nodes,e,e=>c==null?void 0:c.anySprite(e)):null,i=r?m.scene.nodes.find(e=>e.key===r.key):void 0,a=(t=r==null?void 0:r.key)==null?null:t;if(a!==h&&(h=a,f==null||f.redraw()),!e)return void(n.textContent=`Hover the board to see a node, click one to pick its sprite`);if(!r)return void(n.textContent=`${Y(e[0])}, ${Y(e[1])}`);n.textContent=[r.key,r.sprite,i&&`at ${Y(i.x)}, ${Y(i.y)}`,(i==null?void 0:i.rotation)&&`${Y(i.rotation)}°`,(i==null?void 0:i.scale)&&`scale ${i.scale.map(Y).join(`, `)}`,(i==null?void 0:i.opacity)!==void 0&&`opacity ${Y(i.opacity)}`,(i==null?void 0:i.tint)&&`tint ${i.tint}`,(i==null?void 0:i.brightness)!==void 0&&`brightness ${Y(i.brightness)}`,(i==null?void 0:i.blend)&&i.blend!==`normal`&&i.blend,(i==null?void 0:i.parent)&&`in ${i.parent}`,r.exiting&&`exiting`].filter(Boolean).join(` · `)};return{id:`pmmg`,label:`Pmmg`,render(){return`
256
256
  <div class="pmmg-view pmmg-backdrop-${t.backdrop}" id="sim-pmmg-root">
257
257
  <div class="pmmg-status" id="sim-pmmg-status">Open this tab to load the pmmg bundle</div>
258
258
  <div class="data-subtabs">
@@ -311,7 +311,7 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
311
311
  <pre class="pmmg-json" id="sim-pmmg-scene"></pre>
312
312
  </div>
313
313
  </div>
314
- `},bind(e){var n,r,a,o;i=e;let s=C(`root`);if(!s)return;s.style.setProperty(`--pmmg-theme-bg`,i.state.selectedTheme.g_bg),s.querySelectorAll(`[data-pmmg-subtab]`).forEach(e=>{e.addEventListener(`click`,()=>{t.subtab=e.dataset.pmmgSubtab,b(t),B()})}),s.querySelectorAll(`[data-pmmg-pref]`).forEach(e=>{let n=e.dataset.pmmgPref;e.checked=t[n],e.addEventListener(`change`,()=>{t[n]=e.checked,b(t),n===`follow`&&e.checked&&A(),f==null||f.redraw()})});let l=C(`backdrop`);l&&(l.value=t.backdrop,l.addEventListener(`change`,()=>{t.backdrop=l.value,b(t),s.className=`pmmg-view pmmg-backdrop-${t.backdrop}`}));let u=C(`fidelity`);u&&(u.value=t.fidelity,u.addEventListener(`change`,()=>{t.fidelity=u.value,b(t),f==null||f.setLook(T())}));let d=C(`background-style`);d&&(d.options[0].textContent=`Theme's (${i.state.selectedTheme.type})`,d.value=t.backgroundStyle,d.addEventListener(`change`,()=>{t.backgroundStyle=d.value,b(t),f==null||f.setLook(T())})),(n=C(`replay`))==null||n.addEventListener(`click`,()=>k(!0)),(r=C(`redraw`))==null||r.addEventListener(`click`,()=>k(!1)),(a=C(`clear`))==null||a.addEventListener(`click`,()=>{c==null||c.clear(),k(!1)}),(o=C(`filter`))==null||o.addEventListener(`input`,()=>I());let p=C(`canvas`);p==null||p.addEventListener(`mousemove`,e=>H(V(e))),p==null||p.addEventListener(`mouseleave`,()=>H(null)),p==null||p.addEventListener(`click`,e=>{let t=V(e),n=t&&m?Le(m.nodes,t,e=>c==null?void 0:c.anySprite(e)):null;n!=null&&n.sprite&&z(g===n.sprite?null:n.sprite)});let h=C(`stage`);h&&new ResizeObserver(([e])=>f==null?void 0:f.resize(e.contentRect.width,e.contentRect.height)).observe(h),B()},onActivate(){O()},onMessage(e,t,n){if(e===`UPDATE_TABLE_GAME_STATE`&&typeof(t==null?void 0:t.inputString)==`string`){var r;typeof t.puzzleString==`string`&&(v=t.puzzleString);let e=(r=v)==null?n.state.puzzleData:r;if(e===null)return;_!==`table`&&(_=`table`,x.length=0),j({puzzle:e,input:t.inputString})}else if(e===`UPLOAD_NEW_GAME_STATE`&&_===`session`){var i,a;let e=(i=t==null||(a=t.input)==null?void 0:a.boardState)==null?t==null?void 0:t.boardState:i,r=n.state.puzzleData;typeof e==`string`&&r!==null&&j({puzzle:r,input:e})}else e===`READY_GAME_LOADED`&&n.state.activeTab===`pmmg`&&O()}}}var $e=(e,t,n)=>{let r=window.devicePixelRatio||1,{bitmap:i}=e,a=Math.min(t/(i.width/r),n/(i.height/r),8),o=Math.max(1,i.width/r*a),s=Math.max(1,i.height/r*a),c=document.createElement(`canvas`);c.className=`pmmg-backdrop`,c.width=Math.max(1,Math.round(o*r)),c.height=Math.max(1,Math.round(s*r)),c.style.width=`${o}px`,c.style.height=`${s}px`;let l=c.getContext(`2d`);if(!l)return c;l.imageSmoothingEnabled=a<1;try{l.drawImage(i,0,0,c.width,c.height)}catch(e){}let u=e.anchor[0]/e.width*c.width,d=e.anchor[1]/e.height*c.height,f=4*r;return l.strokeStyle=`#f472b6`,l.lineWidth=r,l.beginPath(),l.moveTo(u-f,d),l.lineTo(u+f,d),l.moveTo(u,d-f),l.lineTo(u,d+f),l.stroke(),c},Y=e=>Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,``),et=e=>{try{var t;return(t=JSON.stringify(e,null,2))==null?String(e):t}catch(t){return String(e)}},X=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),tt=e=>e instanceof Error?e.message:String(e);function nt(e){let t=[e.key,e.subBrand,e.player,e.alt1,e.alt2,e.alt3].map(e=>`<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join(``);return`<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`}function rt(){return{id:`theme`,label:`Theme`,render(){return`
314
+ `},bind(e){var n,r,a,o;i=e;let s=w(`root`);if(!s)return;s.style.setProperty(`--pmmg-theme-bg`,i.state.selectedTheme.g_bg),s.querySelectorAll(`[data-pmmg-subtab]`).forEach(e=>{e.addEventListener(`click`,()=>{t.subtab=e.dataset.pmmgSubtab,b(t),B()})}),s.querySelectorAll(`[data-pmmg-pref]`).forEach(e=>{let n=e.dataset.pmmgPref;e.checked=t[n],e.addEventListener(`change`,()=>{t[n]=e.checked,b(t),n===`follow`&&e.checked&&A(),f==null||f.redraw()})});let l=w(`backdrop`);l&&(l.value=t.backdrop,l.addEventListener(`change`,()=>{t.backdrop=l.value,b(t),s.className=`pmmg-view pmmg-backdrop-${t.backdrop}`}));let u=w(`fidelity`);u&&(u.value=t.fidelity,u.addEventListener(`change`,()=>{t.fidelity=u.value,b(t),f==null||f.setLook(E())}));let d=w(`background-style`);d&&(d.options[0].textContent=`Theme's (${i.state.selectedTheme.type})`,d.value=t.backgroundStyle,d.addEventListener(`change`,()=>{t.backgroundStyle=d.value,b(t),f==null||f.setLook(E())})),(n=w(`replay`))==null||n.addEventListener(`click`,()=>k(!0)),(r=w(`redraw`))==null||r.addEventListener(`click`,()=>k(!1)),(a=w(`clear`))==null||a.addEventListener(`click`,()=>{c==null||c.clear(),k(!1)}),(o=w(`filter`))==null||o.addEventListener(`input`,()=>L());let p=w(`canvas`);p==null||p.addEventListener(`mousemove`,e=>H(V(e))),p==null||p.addEventListener(`mouseleave`,()=>H(null)),p==null||p.addEventListener(`click`,e=>{let t=V(e),n=t&&m?Le(m.nodes,t,e=>c==null?void 0:c.anySprite(e)):null;n!=null&&n.sprite&&ne(g===n.sprite?null:n.sprite)});let h=w(`stage`);h&&new ResizeObserver(([e])=>f==null?void 0:f.resize(e.contentRect.width,e.contentRect.height)).observe(h),B()},onActivate(){O()},onMessage(e,t,n){if(e===`UPDATE_TABLE_GAME_STATE`&&typeof(t==null?void 0:t.inputString)==`string`){var r;typeof t.puzzleString==`string`&&(v=t.puzzleString);let e=(r=v)==null?n.state.puzzleData:r;if(e===null)return;_!==`table`&&(_=`table`,S.length=0),j({puzzle:e,input:t.inputString}),N()}else if(e===`UPLOAD_NEW_GAME_STATE`&&_===`session`){var i,a;let e=(i=t==null||(a=t.input)==null?void 0:a.boardState)==null?t==null?void 0:t.boardState:i,r=n.state.puzzleData;typeof e==`string`&&r!==null&&j({puzzle:r,input:e})}else e===`READY_GAME_LOADED`&&(x=!0,n.state.activeTab===`pmmg`?O():N())}}}var $e=(e,t,n)=>{let r=window.devicePixelRatio||1,{bitmap:i}=e,a=Math.min(t/(i.width/r),n/(i.height/r),8),o=Math.max(1,i.width/r*a),s=Math.max(1,i.height/r*a),c=document.createElement(`canvas`);c.className=`pmmg-backdrop`,c.width=Math.max(1,Math.round(o*r)),c.height=Math.max(1,Math.round(s*r)),c.style.width=`${o}px`,c.style.height=`${s}px`;let l=c.getContext(`2d`);if(!l)return c;l.imageSmoothingEnabled=a<1;try{l.drawImage(i,0,0,c.width,c.height)}catch(e){}let u=e.anchor[0]/e.width*c.width,d=e.anchor[1]/e.height*c.height,f=4*r;return l.strokeStyle=`#f472b6`,l.lineWidth=r,l.beginPath(),l.moveTo(u-f,d),l.lineTo(u+f,d),l.moveTo(u,d-f),l.lineTo(u,d+f),l.stroke(),c},Y=e=>Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,``),et=e=>{try{var t;return(t=JSON.stringify(e,null,2))==null?String(e):t}catch(t){return String(e)}},X=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),tt=e=>e instanceof Error?e.message:String(e);function nt(e){let t=[e.key,e.subBrand,e.player,e.alt1,e.alt2,e.alt3].map(e=>`<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join(``);return`<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`}function rt(){return{id:`theme`,label:`Theme`,render(){return`
315
315
  <div class="theme-view-container">
316
316
  <div class="theme-header">
317
317
  <span class="simulator-label">Select Theme</span>
@@ -322,7 +322,7 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
322
322
  ${nt(n)}
323
323
  <div class="simulator-theme-name">${n.name}</div>
324
324
  <div class="simulator-theme-type">${n.type}</div>
325
- `,r.addEventListener(`click`,()=>{console.log(`Simulator: Theme changed, reloading...`,n.name),N(n.name),window.location.reload()}),t.appendChild(r)})}}}var it=[{name:`app (desktop)`,context:[{type:`app`,layout:`desktop`,host:null}]},{name:`app (mobile)`,context:[{type:`app`,layout:`mobile`,host:null}]},{name:`app (ios)`,context:[{type:`app`,layout:`mobile`,host:`ios-app`}]},{name:`embed`,context:[{type:`embed`}]},{name:`embed (no UI)`,context:[{type:`embed`,noUI:!0}]},{name:`sandbox`,context:[{type:`sandbox`}]}];function at(e=[]){let t=[...it,...e];return{id:`host`,label:`Host`,render(){return`
325
+ `,r.addEventListener(`click`,()=>{console.log(`Simulator: Theme changed, reloading...`,n.name),M(n.name),window.location.reload()}),t.appendChild(r)})}}}var it=[{name:`app (desktop)`,context:[{type:`app`,layout:`desktop`,host:null}]},{name:`app (mobile)`,context:[{type:`app`,layout:`mobile`,host:null}]},{name:`app (ios)`,context:[{type:`app`,layout:`mobile`,host:`ios-app`}]},{name:`embed`,context:[{type:`embed`}]},{name:`embed (no UI)`,context:[{type:`embed`,noUI:!0}]},{name:`sandbox`,context:[{type:`sandbox`}]}];function at(e=[]){let t=[...it,...e];return{id:`host`,label:`Host`,render(){return`
326
326
  <style>
327
327
  #simulator-tab-host .host-note { opacity: 0.5; font-size: 10px; margin: 4px 0 8px; }
328
328
  #simulator-tab-host .host-error { color: #f66; font-size: 11px; margin-top: 6px; white-space: pre-wrap; }
@@ -474,7 +474,7 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
474
474
  }
475
475
  `;let s=()=>{var e;return(e=document.getElementById(`root`))==null?document.body.firstElementChild:e},c=null,l=()=>{let e=s();if(!e||c)return;let{height:t,maxHeight:n,position:r}=e.style;c=()=>{e.style.height=t,e.style.maxHeight=n,e.style.position=r,c=null},e.style.height=`calc(100% - ${Xt}px)`,e.style.maxHeight=`calc(100% - ${Xt}px)`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`)},u=(e,n)=>{var r;let i=n.disabled.includes(e),a=n.highlight.includes(e);return[`display:flex`,`align-items:center`,`justify-content:center`,`width:100%`,`height:100%`,`box-sizing:border-box`,`border-radius:3px`,`overflow:hidden`,`background:transparent`,`pointer-events:none`,`border:${i?`1px dashed ${Q(t.fg,.25)}`:a?`2px solid ${Q(t.fg,.75)}`:`1px solid ${Q(t.fg,.4)}`}`,on((r=n.individualKeyStyles)==null||(r=r[e])==null?void 0:r.background)].filter(Boolean).join(`;`)},d=(e,n)=>{var r;return[`font:11px/1 Menlo, Monaco, Consolas, monospace`,`letter-spacing:0.5px`,`text-transform:uppercase`,`white-space:nowrap`,`color:${Q(t.fg,n.disabled.includes(e)?.3:.65)}`,n.highlight.includes(e)?``:on(n.keyStyles),on((r=n.individualKeyStyles)==null||(r=r[e])==null?void 0:r.text)].filter(Boolean).join(`;`)},f=(e,t)=>{var n,r;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=[`width:${en(t.l.includes(e),t.xl.includes(e))}`,`flex:${o?`1 0 auto`:`0 1 auto`}`,`height:100%`,`display:flex`,`align-items:center`,`justify-content:center`,`padding:0 3px 12px`,`position:relative`,a?`pointer-events:none`:``].filter(Boolean).join(`;`),c=u(e,t),l=d(e,t);return`<div class="sim-docked-kbd-key" data-key="${tn(e)}" style="${s}">
476
476
  <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${nn(i)}</div></div>
477
- </div>`},p=e=>{let n=e.layout.filter(e=>!!e),r=`calc(100% / ${n.length})`;return`${n.map((t,n)=>{var i,a;return`<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i=(a=e.rowPositioning)==null?void 0:a[n])==null?`center`:i}`}">${[...t].map(t=>f(t,e)).join(``)}</div>`}).join(``)}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${Q(t.fg,.12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`},m=!1,h=[0,0],g=null,_=0,v=null,y=null,b=e=>{let t=a==null?void 0:a.querySelector(`#sim-docked-kbd-cursor`);t&&(t.style.opacity=e?`0.5`:`0`)},x=()=>{m=!1,h=[0,0],g=null,_=0,v=null,y=null,b(!1)},S=e=>{var t,n;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},C=e=>{y=S(e),a==null||a.setPointerCapture(e.pointerId)},w=e=>{!(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,_>=Zt&&Date.now()-v>=$t&&(m=!0,b(!0))),m&&g&&(h=[h[0]+(e.clientX-g.clientX)*Qt,h[1]+(e.clientY-g.clientY)*Qt]),g={clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId},m&&n(`KEYBOARD_CURSOR_CHANGE`,{position:h}))},T=e=>{m?n(`KEYBOARD_CURSOR_END`,{}):y&&S(e)===y&&n(`KEYBOARD_KEY_PRESS`,{key:y}),x()},E=()=>{a||!i||(a=document.createElement(`div`),a.id=`sim-docked-kbd`,a.style.cssText=[`position:fixed`,`left:0`,`right:0`,`bottom:0`,`height:${Xt}px`,`box-sizing:border-box`,`padding-top:8px`,`padding-bottom:${Yt}px`,`display:flex`,`flex-direction:column`,`z-index:999998`,`touch-action:none`,`user-select:none`,`-webkit-user-select:none`,`background:${t.a_bg}`,`border-top:1px solid ${Q(t.fg,.2)}`].join(`;`),a.innerHTML=p(i),a.addEventListener(`pointerdown`,C),a.addEventListener(`pointermove`,w),a.addEventListener(`pointerup`,T),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())},D=()=>{a&&(a.remove(),a=null,document.documentElement.classList.remove(`sim-kbd-docked`),c==null||c(),x())},O=()=>{let e=i;!a||!e||a.querySelectorAll(`.sim-docked-kbd-key`).forEach(t=>{let n=t.getAttribute(`data-key`),r=t.firstElementChild,i=r==null?void 0:r.firstElementChild;!n||!r||!i||(r.style.cssText=u(n,e),i.style.cssText=d(n,e))})},k=()=>{if(!r||!i)return D();if(!a)return E();a.innerHTML=p(i),b(m)};return{setEnabled(e){r=e,k()},setConfig(e){let t=a&&e&&i&&an(e)===an(i);i=e,t?O():k()}}}var an=e=>JSON.stringify([e.layout,e.symbols,e.highlight,e.disabled,e.xl,e.l,e.flexGrowSymbols,e.rowPositioning,e.keyStyles]);const on=e=>Object.entries(e==null?{}:e).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${tn(String(t))}`).join(`;`);var sn=(e,t)=>{var n,r,i,a;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=[`sim-kb-key`,s?`disabled`:``,c?`highlight`:``,l?`xl`:``,u?`l`:``,d?`grow`:``].filter(Boolean).join(` `),p=on((i=t.individualKeyStyles)==null||(i=i[e])==null?void 0:i.background),m=on((a=t.individualKeyStyles)==null||(a=a[e])==null?void 0:a.text);return`<button class="${f}" data-key="${e}" style="${p}" ${s?`disabled`:``}><span style="${m}">${o}</span></button>`},cn=e=>`<div class="sim-kb">${e.layout.filter(e=>e!=null).map(t=>`<div class="sim-kb-row">${[...t].map(t=>sn(t,e)).join(``)}</div>`).join(``)}</div>`;function ln(){let e=null,t=null,n=t=>e?t?`<div class="sim-kb-empty">Shown under the game at production size, taking ${Xt}px off the bottom.<br>Uncheck to preview the layout here instead.</div>`:cn(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>`;return{id:`kbd`,label:`Kbd`,render(){return`
477
+ </div>`},p=e=>{let n=e.layout.filter(e=>!!e),r=`calc(100% / ${n.length})`;return`${n.map((t,n)=>{var i,a;return`<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i=(a=e.rowPositioning)==null?void 0:a[n])==null?`center`:i}`}">${[...t].map(t=>f(t,e)).join(``)}</div>`}).join(``)}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${Q(t.fg,.12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`},m=!1,h=[0,0],g=null,_=0,v=null,y=null,b=e=>{let t=a==null?void 0:a.querySelector(`#sim-docked-kbd-cursor`);t&&(t.style.opacity=e?`0.5`:`0`)},x=()=>{m=!1,h=[0,0],g=null,_=0,v=null,y=null,b(!1)},S=e=>{var t,n;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},C=e=>{y=S(e),a==null||a.setPointerCapture(e.pointerId)},w=e=>{!(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,_>=Zt&&Date.now()-v>=$t&&(m=!0,b(!0))),m&&g&&(h=[h[0]+(e.clientX-g.clientX)*Qt,h[1]+(e.clientY-g.clientY)*Qt]),g={clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId},m&&n(`KEYBOARD_CURSOR_CHANGE`,{position:h}))},T=e=>{m?n(`KEYBOARD_CURSOR_END`,{}):y&&S(e)===y&&n(`KEYBOARD_KEY_PRESS`,{key:y}),x()},E=()=>{a||!i||(a=document.createElement(`div`),a.id=`sim-docked-kbd`,a.style.cssText=[`position:fixed`,`left:0`,`right:0`,`bottom:0`,`height:${Xt}px`,`box-sizing:border-box`,`padding-top:8px`,`padding-bottom:${Yt}px`,`display:flex`,`flex-direction:column`,`z-index:999998`,`touch-action:none`,`user-select:none`,`-webkit-user-select:none`,`background:${t.a_bg}`,`border-top:1px solid ${Q(t.fg,.2)}`].join(`;`),a.innerHTML=p(i),a.addEventListener(`pointerdown`,C),a.addEventListener(`pointermove`,w),a.addEventListener(`pointerup`,T),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())},D=()=>{a&&(a.remove(),a=null,document.documentElement.classList.remove(`sim-kbd-docked`),c==null||c(),x())},ee=()=>{let e=i;!a||!e||a.querySelectorAll(`.sim-docked-kbd-key`).forEach(t=>{let n=t.getAttribute(`data-key`),r=t.firstElementChild,i=r==null?void 0:r.firstElementChild;!n||!r||!i||(r.style.cssText=u(n,e),i.style.cssText=d(n,e))})},O=()=>{if(!r||!i)return D();if(!a)return E();a.innerHTML=p(i),b(m)};return{setEnabled(e){r=e,O()},setConfig(e){let t=a&&e&&i&&an(e)===an(i);i=e,t?ee():O()}}}var an=e=>JSON.stringify([e.layout,e.symbols,e.highlight,e.disabled,e.xl,e.l,e.flexGrowSymbols,e.rowPositioning,e.keyStyles]);const on=e=>Object.entries(e==null?{}:e).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${tn(String(t))}`).join(`;`);var sn=(e,t)=>{var n,r,i,a;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=[`sim-kb-key`,s?`disabled`:``,c?`highlight`:``,l?`xl`:``,u?`l`:``,d?`grow`:``].filter(Boolean).join(` `),p=on((i=t.individualKeyStyles)==null||(i=i[e])==null?void 0:i.background),m=on((a=t.individualKeyStyles)==null||(a=a[e])==null?void 0:a.text);return`<button class="${f}" data-key="${e}" style="${p}" ${s?`disabled`:``}><span style="${m}">${o}</span></button>`},cn=e=>`<div class="sim-kb">${e.layout.filter(e=>e!=null).map(t=>`<div class="sim-kb-row">${[...t].map(t=>sn(t,e)).join(``)}</div>`).join(``)}</div>`;function ln(){let e=null,t=null,n=t=>e?t?`<div class="sim-kb-empty">Shown under the game at production size, taking ${Xt}px off the bottom.<br>Uncheck to preview the layout here instead.</div>`:cn(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>`;return{id:`kbd`,label:`Kbd`,render(){return`
478
478
  <div class="keyboard-view-container">
479
479
  <div class="simulator-field">
480
480
  <label class="sim-settings-row">
@@ -486,11 +486,11 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
486
486
  ${n(!1)}
487
487
  </div>
488
488
  </div>
489
- `},bind(e){t!=null||(t=rn({theme:e.state.selectedTheme,sendToGame:e.sendToGame})),t.setEnabled(e.state.keyboardDocked);let n=e.getElement(`#sim-kb-dock`);n&&(n.checked=e.state.keyboardDocked,n.addEventListener(`change`,()=>{e.state.keyboardDocked=n.checked,_(n.checked),t==null||t.setEnabled(n.checked),r(e)})),un(e)},onMessage(n,i,a){var o;n===`KEYBOARD_UPDATE_CONFIG`&&(e=!(!(i==null||(o=i.layout)==null)&&o.length)||i.layout.every(e=>!e)?null:i,t==null||t.setConfig(e),r(a))}};function r(e){let t=e.getElement(`#sim-kb-content`);t&&(t.innerHTML=n(e.state.keyboardDocked),un(e))}}function un(e){var t;let n=(t=e.getElement(`#sim-kb-content`))==null?void 0:t.querySelectorAll(`.sim-kb-key`);n==null||n.forEach(t=>{t.addEventListener(`click`,()=>{let n=t.getAttribute(`data-key`);n&&e.sendToGame(`KEYBOARD_KEY_PRESS`,{key:n})})})}function dn(){let e=e=>{let t=e.state.settingsComponents;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=>fn(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>`},n=t=>{let n=t.getElement(`#sim-settings-content`);n&&(n.innerHTML=e(t),i(t))},r=e=>{k(e.state.gameSettings),e.sendToGame(`SETTINGS_UPDATE`,e.state.gameSettings)},i=e=>{var i;let a=e.getElement(`#sim-settings-content`);a&&(a.querySelectorAll(`[data-setting]`).forEach(n=>{let i=n.getAttribute(`data-setting`),o=n.getAttribute(`data-setting-type`);n.addEventListener(`change`,()=>{let s;if(o===`multiselect`){let e=a.querySelectorAll(`input[data-multiselect="${i}"]`);s=Array.from(e).filter(e=>e.checked).map(e=>e.value)}else s=n instanceof HTMLInputElement&&n.type===`checkbox`?n.checked:o===`number`?Number(n.value):n.value;e.state.gameSettings=t.t(t.t({},e.state.gameSettings),{},{[i]:s}),r(e)})}),(i=a.querySelector(`#sim-settings-reset`))==null||i.addEventListener(`click`,()=>{var t;A(),e.state.gameSettings=mn((t=e.state.settingsComponents)==null?[]:t),r(e),n(e)}))};return{id:`settings`,label:`Set`,render(){return`
489
+ `},bind(e){t!=null||(t=rn({theme:e.state.selectedTheme,sendToGame:e.sendToGame})),t.setEnabled(e.state.keyboardDocked);let n=e.getElement(`#sim-kb-dock`);n&&(n.checked=e.state.keyboardDocked,n.addEventListener(`change`,()=>{e.state.keyboardDocked=n.checked,_(n.checked),t==null||t.setEnabled(n.checked),r(e)})),un(e)},onMessage(n,i,a){var o;n===`KEYBOARD_UPDATE_CONFIG`&&(e=!(!(i==null||(o=i.layout)==null)&&o.length)||i.layout.every(e=>!e)?null:i,t==null||t.setConfig(e),r(a))}};function r(e){let t=e.getElement(`#sim-kb-content`);t&&(t.innerHTML=n(e.state.keyboardDocked),un(e))}}function un(e){var t;let n=(t=e.getElement(`#sim-kb-content`))==null?void 0:t.querySelectorAll(`.sim-kb-key`);n==null||n.forEach(t=>{t.addEventListener(`click`,()=>{let n=t.getAttribute(`data-key`);n&&e.sendToGame(`KEYBOARD_KEY_PRESS`,{key:n})})})}function dn(){let e=e=>{let t=e.state.settingsComponents;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=>fn(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>`},n=t=>{let n=t.getElement(`#sim-settings-content`);n&&(n.innerHTML=e(t),i(t))},r=e=>{O(e.state.gameSettings),e.sendToGame(`SETTINGS_UPDATE`,e.state.gameSettings)},i=e=>{var i;let a=e.getElement(`#sim-settings-content`);a&&(a.querySelectorAll(`[data-setting]`).forEach(n=>{let i=n.getAttribute(`data-setting`),o=n.getAttribute(`data-setting-type`);n.addEventListener(`change`,()=>{let s;if(o===`multiselect`){let e=a.querySelectorAll(`input[data-multiselect="${i}"]`);s=Array.from(e).filter(e=>e.checked).map(e=>e.value)}else s=n instanceof HTMLInputElement&&n.type===`checkbox`?n.checked:o===`number`?Number(n.value):n.value;e.state.gameSettings=t.t(t.t({},e.state.gameSettings),{},{[i]:s}),r(e)})}),(i=a.querySelector(`#sim-settings-reset`))==null||i.addEventListener(`click`,()=>{var t;k(),e.state.gameSettings=mn((t=e.state.settingsComponents)==null?[]:t),r(e),n(e)}))};return{id:`settings`,label:`Set`,render(){return`
490
490
  <div class="settings-view-container">
491
491
  <div id="sim-settings-content"></div>
492
492
  </div>
493
- `},bind(e){n(e)},onMessage(e,r,i){if(e===`INITIALIZE_SETTINGS`){var a;i.state.settingsComponents=(a=r==null?void 0:r.components)==null?[]:a,i.state.gameSettings=t.t(t.t({},r==null?void 0:r.settings),i.state.gameSettings),k(i.state.gameSettings),n(i);return}e===`UPDATE_SETTINGS_FROM_EMBED`&&(i.state.gameSettings=t.t(t.t({},i.state.gameSettings),r==null?void 0:r.settings),k(i.state.gameSettings),n(i))}}}function fn(e,t){if(e.hidden)return``;switch(e.type){case`title`:return`<div class="sim-settings-heading">${$(e.value)}</div>`;case`subtitle`:return`<div class="sim-settings-subheading">${$(e.value)}</div>`;case`paragraph`:return`<p class="sim-settings-paragraph">${$(e.value)}</p>`;case`separator`:return`<div class="simulator-divider"></div>`;case`split`:return`<div class="sim-settings-split">${e.content.map(e=>fn(e,t)).join(``)}</div>`;case`boolean`:{var n;let r=((n=t[e.name])==null?e.defaultValue:n)?`checked`:``,i=e.subtitle?`<div class="sim-settings-subtitle">${$(e.subtitle)}</div>`:``;return`
493
+ `},bind(e){n(e)},onMessage(e,r,i){if(e===`INITIALIZE_SETTINGS`){var a;i.state.settingsComponents=(a=r==null?void 0:r.components)==null?[]:a,i.state.gameSettings=t.t(t.t({},r==null?void 0:r.settings),i.state.gameSettings),O(i.state.gameSettings),n(i);return}e===`UPDATE_SETTINGS_FROM_EMBED`&&(i.state.gameSettings=t.t(t.t({},i.state.gameSettings),r==null?void 0:r.settings),O(i.state.gameSettings),n(i))}}}function fn(e,t){if(e.hidden)return``;switch(e.type){case`title`:return`<div class="sim-settings-heading">${$(e.value)}</div>`;case`subtitle`:return`<div class="sim-settings-subheading">${$(e.value)}</div>`;case`paragraph`:return`<p class="sim-settings-paragraph">${$(e.value)}</p>`;case`separator`:return`<div class="simulator-divider"></div>`;case`split`:return`<div class="sim-settings-split">${e.content.map(e=>fn(e,t)).join(``)}</div>`;case`boolean`:{var n;let r=((n=t[e.name])==null?e.defaultValue:n)?`checked`:``,i=e.subtitle?`<div class="sim-settings-subtitle">${$(e.subtitle)}</div>`:``;return`
494
494
  <div class="simulator-field">
495
495
  <label class="sim-settings-row">
496
496
  <input type="checkbox" data-setting="${e.name}" ${r} />
@@ -535,7 +535,7 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
535
535
  </div>
536
536
  <div id="sound-events">${n()}</div>
537
537
  </div>
538
- `},bind(n){let i=n.getElement(`#sound-clear`);i==null||i.addEventListener(`click`,()=>{e.length=0,r(n)});let a=n.getElement(`#sound-enabled`);a==null||a.addEventListener(`change`,()=>{t=!!a.checked,n.sendToGame(`SOUND_ENABLED`,{enabled:t})}),n.sendToGame(`SOUND_ENABLED`,{enabled:t})},onMessage(n,i,a){var o;if(n===`READY_GAME_LOADED`){a.sendToGame(`SOUND_ENABLED`,{enabled:t});return}n===`SENSORY_EVENT`&&(e.unshift({id:(o=i==null?void 0:i.id)==null?JSON.stringify(i):o,haptic:i==null?void 0:i.haptic,time:gn()}),e.length>100&&e.pop(),r(a))}}}function gn(){return new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function _n(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var vn=null;function yn(){return typeof window>`u`?!1:new URLSearchParams(window.location.search).has(`developer`)}var bn={updateFixtures:()=>{},sendToGame:()=>{},loadPuzzle:function(){var e=n.t(function*(){return null});return function(){return e.apply(this,arguments)}}()};function xn(e={}){var r,i,a,o,s;if(yn())return console.log(`[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot`),bn;if(console.log(`[Simulator] createSimulator called with config:`,{slug:e.slug,hasFixtures:!!e.fixtures}),vn)return e.fixtures&&(console.log(`[Simulator] Instance already exists, updating fixtures`),vn.updateFixtures(e.fixtures)),vn;let c=(r=e.autoStart)==null?!0:r,l=e.fixtures?B(e.fixtures):null,u=l?Array.from(l.keys()).sort():[],d=_e(),f=Pe(),p=[ae(),le(),d,ve(),ye(),De((i=(a=e.integrations)==null?void 0:a.checklists)==null?[]:i),f,...e.pmmgBundle?[Qe(e.pmmgBundle)]:[],rt(),at(e.hostContextPresets),Ot(),qt(),ln(),dn(),hn(),...(o=e.views)==null?[]:o],m=p.map(e=>e.id),h=O(e,u,m),g={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>`,play:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><polygon points="2,1 9,5 2,9"/></svg>`,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>`,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>`,minimize:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="4" width="8" height="2"/></svg>`,expand:`<svg width="8" height="8" viewBox="0 0 8 8" fill="currentColor"><polygon points="1,1 7,4 1,7"/></svg>`},_=document.createElement(`div`);_.id=`simulator`,_.dataset.puzzmoBuild=ie,_.innerHTML=`
538
+ `},bind(n){let i=n.getElement(`#sound-clear`);i==null||i.addEventListener(`click`,()=>{e.length=0,r(n)});let a=n.getElement(`#sound-enabled`);a==null||a.addEventListener(`change`,()=>{t=!!a.checked,n.sendToGame(`SOUND_ENABLED`,{enabled:t})}),n.sendToGame(`SOUND_ENABLED`,{enabled:t})},onMessage(n,i,a){var o;if(n===`READY_GAME_LOADED`){a.sendToGame(`SOUND_ENABLED`,{enabled:t});return}n===`SENSORY_EVENT`&&(e.unshift({id:(o=i==null?void 0:i.id)==null?JSON.stringify(i):o,haptic:i==null?void 0:i.haptic,time:gn()}),e.length>100&&e.pop(),r(a))}}}function gn(){return new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function _n(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var vn=null;function yn(){return typeof window>`u`?!1:new URLSearchParams(window.location.search).has(`developer`)}var bn={updateFixtures:()=>{},sendToGame:()=>{},loadPuzzle:function(){var e=n.t(function*(){return null});return function(){return e.apply(this,arguments)}}()};function xn(e={}){var r,i,a,o,s;if(yn())return console.log(`[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot`),bn;if(console.log(`[Simulator] createSimulator called with config:`,{slug:e.slug,hasFixtures:!!e.fixtures}),vn)return e.fixtures&&(console.log(`[Simulator] Instance already exists, updating fixtures`),vn.updateFixtures(e.fixtures)),vn;let c=(r=e.autoStart)==null?!0:r,l=e.fixtures?re(e.fixtures):null,u=l?Array.from(l.keys()).sort():[],d=_e(),f=Pe(),p=[ae(),le(),d,ve(),ye(),De((i=(a=e.integrations)==null?void 0:a.checklists)==null?[]:i),f,...e.pmmgBundle?[Qe(e.pmmgBundle)]:[],rt(),at(e.hostContextPresets),Ot(),qt(),ln(),dn(),hn(),...(o=e.views)==null?[]:o],m=p.map(e=>e.id),h=ee(e,u,m),g={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>`,play:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><polygon points="2,1 9,5 2,9"/></svg>`,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>`,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>`,minimize:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="4" width="8" height="2"/></svg>`,expand:`<svg width="8" height="8" viewBox="0 0 8 8" fill="currentColor"><polygon points="1,1 7,4 1,7"/></svg>`},_=document.createElement(`div`);_.id=`simulator`,_.dataset.puzzmoBuild=ie,_.innerHTML=`
539
539
  <style>
540
540
  :root {
541
541
  --sim-bg: #1a1a2e;
@@ -2229,5 +2229,5 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
2229
2229
  </div>
2230
2230
  </div>
2231
2231
  </div>
2232
- `,document.body.appendChild(_);let v=_.querySelector(`#simulator-panel`),y=_.querySelector(`#simulator-header`),b=_.querySelector(`#simulator-header-indicator`),x=_.querySelector(`#simulator-header-status-text`),S=_.querySelector(`#simulator-header-pause`),C=_.querySelector(`#simulator-header-retry`),w=_.querySelector(`#simulator-header-settings`),T=_.querySelector(`#simulator-toggle`),E=_.querySelector(`#simulator-timer`),D=_.querySelector(`#simulator-tabs`),k=_.querySelector(`#simulator-content`),A=e=>_.querySelector(e),N=e=>{S.innerHTML=e?g.play:g.pause,S.title=e?`Resume`:`Pause`},P=(e,t)=>{let n=A(`#simulator-status .text`),r=A(`#simulator-status .indicator`),i=t===`complete`?`✓`:``;n&&(n.textContent=e),r&&(r.className=`indicator ${t}`,r.textContent=i),b.className=t,b.textContent=i,x.textContent=e},ee=(e,t)=>{t&&t!==`0`?E.innerHTML=`${e}<span class="penalty">+${t}</span>`:E.textContent=e},F=e=>{var t;h.activeTab=e,k.classList.remove(`hidden`),M(e),D.querySelectorAll(`.simulator-tab`).forEach(t=>{t.classList.toggle(`active`,t.getAttribute(`data-tab`)===e)}),_.querySelectorAll(`.simulator-tab-content`).forEach(t=>{t.classList.toggle(`active`,t.id===`simulator-tab-${e}`)}),w.classList.toggle(`active`,e===`auth`);let n=p.find(t=>t.id===e);n==null||(t=n.onActivate)==null||t.call(n,W)},I=e=>{h.isCollapsed=e,v.classList.toggle(`collapsed`,e),j(e),e?(k.classList.add(`hidden`),D.querySelectorAll(`.simulator-tab`).forEach(e=>e.classList.remove(`active`))):F(h.activeTab)},L=()=>{f.updatePreview(W)},R=function(){var e=n.t(function*(){var e,t;if(h.appliedPuzzleOverride!==null)return h.appliedPuzzleOverride;if(h.puzzleData)return h.puzzleData;if(!l||l.size===0)throw Error(`No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.`);let n=(e=h.selectedCategory)==null?u[0]:e,r=n?l.get(n):void 0;if(!r||r.size===0)throw Error(`No puzzles found in fixture category "${n}"`);let i=(t=h.selectedPuzzle)==null?r.keys().next().value:t,a=i?r.get(i):void 0;if(!a)throw Error(`Puzzle "${i}" not found in category "${n}"`);h.puzzleData=a,console.log(`Simulator: Puzzle loaded from fixtures`,{category:n,puzzle:i}),h.originalPuzzle=a;let o=A(`#simulator-puzzle`);return o&&(o.value=h.originalPuzzle),h.activeTab===`thumb`&&L(),h.puzzleData});return function(){return e.apply(this,arguments)}}(),V=te(e=>{d.addLogEntry(e,W)}),H=(e,t)=>{z(e,t,V)},re=e=>{var t;let n=(t=e.buckets)!=null&&t.length?e.buckets:u,r=n.find(e=>{var t;return!(!(l==null||(t=l.get(e))==null)&&t.size)});if(r!==void 0||!n.length)return{nonce:e.nonce,error:`No fixtures in "${r==null?``:r}" to stand in for a pool`,failed:!0};let i=n.flatMap(e=>[...l.get(e).keys()].map(t=>`fixtures/${e}/${t}`)),a=i.filter(t=>{var n;return!((n=e.exclude)!=null&&n.includes(t))}),o=a.length?a:i,s=o[Math.floor(Math.random()*o.length)],[,c,...d]=s.split(`/`);return{nonce:e.nonce,puzzle:{key:s,puzzle:l.get(c).get(d.join(`/`))}}},U=(e,t)=>{let n=_.querySelector(`[data-badge="${e}"]`);n&&(n.textContent=t&&t>0?String(t):``)},W={state:h,getElement:A,sendToGame:H,logMessage:V.log,loadPuzzle:R,updateStatus:P,updateTimer:ee,setCollapsed:I,switchTab:F,updateThumbnail:L,updateBadge:U,fixtures:l,fixtureCategories:u,gameSlug:(s=e.slug)==null?null:s};console.log(`[Simulator] Context created with gameSlug:`,W.gameSlug),p.forEach(e=>e.bind(W)),D.querySelectorAll(`.simulator-tab`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-tab`);F(t),U(t,0)})}),T.addEventListener(`click`,e=>{e.stopPropagation(),I(!0)}),S.addEventListener(`click`,e=>{e.stopPropagation(),h.isPaused?(H(`RESUME_GAME`,{}),h.isPaused=!1,N(!1),P(`Running`,`ready`)):(H(`PAUSE_GAME`,{}),h.isPaused=!0,N(!0),P(`Paused`,`paused`));let t=A(`#simulator-pause`);t&&(t.textContent=h.isPaused?`Resume`:`Pause`)}),C.addEventListener(`click`,e=>{e.stopPropagation(),H(`RETRY_PUZZLE`,{}),h.hasStarted=!1,h.isPaused=!1,N(!1),S.disabled=!0,P(`Ready to retry`,`ready`);let t=A(`#simulator-pause`),n=A(`#simulator-start`);t&&(t.disabled=!0,t.textContent=`Pause`),n&&(n.textContent=`Start`)}),w.addEventListener(`click`,e=>{e.stopPropagation(),h.isCollapsed&&I(!1),F(`auth`)}),y.addEventListener(`click`,e=>{h.isCollapsed&&e.target!==T&&I(!1)}),h.isCollapsed||F(h.activeTab);let oe=new URLSearchParams(window.location.search);(oe.has(`code`)||oe.has(`error`))&&(I(!1),F(`auth`));let se=n=>{let r=e.slug?t.t(t.t({},Sn),{},{slug:e.slug,stableSlug:e.slug}):Sn,i={additionalTimeAddedSecs:0,boardState:h.currentInputStr,combinedTimeSecs:0,completed:!1,createdAt:new Date().toISOString(),elapsedTimeSecs:0,id:`simulator-gameplay-${Date.now()}`,ownerID:`simulator-owner`,pointsAwarded:0,slug:`simulator-game`,viewerOwnsPuzzle:!0},a=n===null?void 0:{gameplay:i,puzzle:{id:`simulator-puzzle`,name:`Proto Jig Puzzle`,puzzle:n,mostRecentDaily:null}};return{userState:{gameSettings:{[r.slug]:h.gameSettings},id:`simulator-user`,ownerID:`simulator-owner`},currentUser:{id:`simulator-user`,name:`Simulator`,username:`simulator`,usernameID:`0000`,type:`User`,roles:``},game:r,session:a,viewerStorage:h.userStorage,theme:h.selectedTheme,hostContext:h.hostContext,appRuntimeContract:`1.0`}},ce=[`1.0`,`1.1`],G=function(){var r=n.t(function*(n){let r=e.session!==!1||n===`1.0`;r?e.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`),P(r?`Loading puzzle...`:`Sending READY_DATA...`,`waiting`);try{let e=t.t(t.t({},se(r?yield R():null)),{},{appRuntimeContract:n});P(`Sending READY_DATA...`,`waiting`),H(`READY_DATA`,e),P(`Waiting for game to load...`,`waiting`)}catch(e){P(`Error: ${e}`,`paused`)}});return function(e){return r.apply(this,arguments)}}(),K=()=>{console.log(`Simulator: Game loaded, ready to start`),C.disabled=!1,p.forEach(e=>{var t;return(t=e.onMessage)==null?void 0:t.call(e,`READY_GAME_LOADED`,void 0,W)}),c&&!h.hasStarted&&setTimeout(()=>{let e=A(`#simulator-start`);e==null||e.click(),S.disabled=!1,h.hasStarted=!0,P(`Running`,`ready`)},100)};return ne((e,t)=>{var n,r;if(e===`READY`){console.log(`Simulator: Received READY from game`),G(ce.includes(t==null?void 0:t.runtimeContract)?t.runtimeContract:`1.0`);return}if(e===`READY_GAME_LOADED`){K();return}if(e===`TIMER_TICK`){if(t!=null&&t.display){let[e,n]=t.display;ee(e,n)}return}if(e===`TIMER_SYNC`)return;if(e===`SIDEBAR_UPDATE`){console.log(`Simulator: Sidebar update`,t);return}p.forEach(n=>{var r;return(r=n.onMessage)==null?void 0:r.call(n,e,t,W)});let i=(n=t==null||(r=t.input)==null?void 0:r.boardState)==null?t==null?void 0:t.boardState:n;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===`START_REPEATABLE_ROUND`&&console.log(`Simulator: Repeatable round started`,t),e===`RESUME_REPEATABLE_ROUND`&&console.log(`Simulator: Repeatable round resumed`,t),e===`UPDATE_TABLE_GAME_STATE`&&console.log(`Simulator: Table game state`,t),e===`REQUEST_PUZZLE`){H(`PUZZLE_DATA`,re(t));return}if(e===`UPDATE_GAME_USER_STATE`&&typeof(t==null?void 0:t.state)==`string`){var a;h.userStorage={state:t.state,stateVersion:(a=t.stateVersion)==null?1:a},console.log(`Simulator: Game user storage updated`,t)}e===`GAME_COMPLETED`&&(console.log(`Simulator: Game completed!`,t),S.disabled=!0,h.hasStarted=!1,P(`Completed!`,`complete`))},V),console.log(`Simulator initialized`),vn={updateFixtures:e=>{l=B(e),u=Array.from(l.keys()).sort(),W.fixtures=l,W.fixtureCategories=u;let t=localStorage.getItem(`simulator-fixture-category`);if(!h.selectedCategory||!u.includes(h.selectedCategory)){var n;h.selectedCategory=t&&u.includes(t)?t:(n=u[0])==null?null:n}let r=p.find(e=>e.id===`ctrl`);r==null||r.bind(W),console.log(`Simulator: Fixtures updated`,{categories:u,selectedCategory:h.selectedCategory})},sendToGame:H,loadPuzzle:R},vn}var Sn={id:`simulator-game`,slug:`proto-game`,stableSlug:`proto-game`,displayName:`Proto Game`,version:{id:`simulator-version`,label:null,featuresArr:[0],flagsArr:[0],runtime:{id:`simulator-runtime`,version:null}}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return hn}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return xn}});
2233
- //# sourceMappingURL=createSimulator-CIE72Xs2.cjs.map
2232
+ `,document.body.appendChild(_);let v=_.querySelector(`#simulator-panel`),y=_.querySelector(`#simulator-header`),b=_.querySelector(`#simulator-header-indicator`),x=_.querySelector(`#simulator-header-status-text`),S=_.querySelector(`#simulator-header-pause`),C=_.querySelector(`#simulator-header-retry`),w=_.querySelector(`#simulator-header-settings`),T=_.querySelector(`#simulator-toggle`),E=_.querySelector(`#simulator-timer`),D=_.querySelector(`#simulator-tabs`),O=_.querySelector(`#simulator-content`),k=e=>_.querySelector(e),M=e=>{S.innerHTML=e?g.play:g.pause,S.title=e?`Resume`:`Pause`},N=(e,t)=>{let n=k(`#simulator-status .text`),r=k(`#simulator-status .indicator`),i=t===`complete`?`✓`:``;n&&(n.textContent=e),r&&(r.className=`indicator ${t}`,r.textContent=i),b.className=t,b.textContent=i,x.textContent=e},P=(e,t)=>{t&&t!==`0`?E.innerHTML=`${e}<span class="penalty">+${t}</span>`:E.textContent=e},F=e=>{var t;h.activeTab=e,O.classList.remove(`hidden`),j(e),D.querySelectorAll(`.simulator-tab`).forEach(t=>{t.classList.toggle(`active`,t.getAttribute(`data-tab`)===e)}),_.querySelectorAll(`.simulator-tab-content`).forEach(t=>{t.classList.toggle(`active`,t.id===`simulator-tab-${e}`)}),w.classList.toggle(`active`,e===`auth`);let n=p.find(t=>t.id===e);n==null||(t=n.onActivate)==null||t.call(n,W)},I=e=>{h.isCollapsed=e,v.classList.toggle(`collapsed`,e),A(e),e?(O.classList.add(`hidden`),D.querySelectorAll(`.simulator-tab`).forEach(e=>e.classList.remove(`active`))):F(h.activeTab)},L=()=>{f.updatePreview(W)},R=function(){var e=n.t(function*(){var e,t;if(h.appliedPuzzleOverride!==null)return h.appliedPuzzleOverride;if(h.puzzleData)return h.puzzleData;if(!l||l.size===0)throw Error(`No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.`);let n=(e=h.selectedCategory)==null?u[0]:e,r=n?l.get(n):void 0;if(!r||r.size===0)throw Error(`No puzzles found in fixture category "${n}"`);let i=(t=h.selectedPuzzle)==null?r.keys().next().value:t,a=i?r.get(i):void 0;if(!a)throw Error(`Puzzle "${i}" not found in category "${n}"`);h.puzzleData=a,console.log(`Simulator: Puzzle loaded from fixtures`,{category:n,puzzle:i}),h.originalPuzzle=a;let o=k(`#simulator-puzzle`);return o&&(o.value=h.originalPuzzle),h.activeTab===`thumb`&&L(),h.puzzleData});return function(){return e.apply(this,arguments)}}(),B=te(e=>{d.addLogEntry(e,W)}),V=(e,t)=>{z(e,t,B)},H=e=>{var t;let n=(t=e.buckets)!=null&&t.length?e.buckets:u,r=n.find(e=>{var t;return!(!(l==null||(t=l.get(e))==null)&&t.size)});if(r!==void 0||!n.length)return{nonce:e.nonce,error:`No fixtures in "${r==null?``:r}" to stand in for a pool`,failed:!0};let i=n.flatMap(e=>[...l.get(e).keys()].map(t=>`fixtures/${e}/${t}`)),a=i.filter(t=>{var n;return!((n=e.exclude)!=null&&n.includes(t))}),o=a.length?a:i,s=o[Math.floor(Math.random()*o.length)],[,c,...d]=s.split(`/`);return{nonce:e.nonce,puzzle:{key:s,puzzle:l.get(c).get(d.join(`/`))}}},U=(e,t)=>{let n=_.querySelector(`[data-badge="${e}"]`);n&&(n.textContent=t&&t>0?String(t):``)},W={state:h,getElement:k,sendToGame:V,logMessage:B.log,loadPuzzle:R,updateStatus:N,updateTimer:P,setCollapsed:I,switchTab:F,updateThumbnail:L,updateBadge:U,fixtures:l,fixtureCategories:u,gameSlug:(s=e.slug)==null?null:s};console.log(`[Simulator] Context created with gameSlug:`,W.gameSlug),p.forEach(e=>e.bind(W)),D.querySelectorAll(`.simulator-tab`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-tab`);F(t),U(t,0)})}),T.addEventListener(`click`,e=>{e.stopPropagation(),I(!0)}),S.addEventListener(`click`,e=>{e.stopPropagation(),h.isPaused?(V(`RESUME_GAME`,{}),h.isPaused=!1,M(!1),N(`Running`,`ready`)):(V(`PAUSE_GAME`,{}),h.isPaused=!0,M(!0),N(`Paused`,`paused`));let t=k(`#simulator-pause`);t&&(t.textContent=h.isPaused?`Resume`:`Pause`)}),C.addEventListener(`click`,e=>{e.stopPropagation(),V(`RETRY_PUZZLE`,{}),h.hasStarted=!1,h.isPaused=!1,M(!1),S.disabled=!0,N(`Ready to retry`,`ready`);let t=k(`#simulator-pause`),n=k(`#simulator-start`);t&&(t.disabled=!0,t.textContent=`Pause`),n&&(n.textContent=`Start`)}),w.addEventListener(`click`,e=>{e.stopPropagation(),h.isCollapsed&&I(!1),F(`auth`)}),y.addEventListener(`click`,e=>{h.isCollapsed&&e.target!==T&&I(!1)}),h.isCollapsed||F(h.activeTab);let oe=new URLSearchParams(window.location.search);(oe.has(`code`)||oe.has(`error`))&&(I(!1),F(`auth`));let se=n=>{let r=e.slug?t.t(t.t({},Sn),{},{slug:e.slug,stableSlug:e.slug}):Sn,i={additionalTimeAddedSecs:0,boardState:h.currentInputStr,combinedTimeSecs:0,completed:!1,createdAt:new Date().toISOString(),elapsedTimeSecs:0,id:`simulator-gameplay-${Date.now()}`,ownerID:`simulator-owner`,pointsAwarded:0,slug:`simulator-game`,viewerOwnsPuzzle:!0},a=n===null?void 0:{gameplay:i,puzzle:{id:`simulator-puzzle`,name:`Proto Jig Puzzle`,puzzle:n,mostRecentDaily:null}};return{userState:{gameSettings:{[r.slug]:h.gameSettings},id:`simulator-user`,ownerID:`simulator-owner`},currentUser:{id:`simulator-user`,name:`Simulator`,username:`simulator`,usernameID:`0000`,type:`User`,roles:``},game:r,session:a,viewerStorage:h.userStorage,theme:h.selectedTheme,hostContext:h.hostContext,appRuntimeContract:`1.0`}},ce=[`1.0`,`1.1`],G=function(){var r=n.t(function*(n){let r=e.session!==!1||n===`1.0`;r?e.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`),N(r?`Loading puzzle...`:`Sending READY_DATA...`,`waiting`);try{let e=t.t(t.t({},se(r?yield R():null)),{},{appRuntimeContract:n});N(`Sending READY_DATA...`,`waiting`),V(`READY_DATA`,e),N(`Waiting for game to load...`,`waiting`)}catch(e){N(`Error: ${e}`,`paused`)}});return function(e){return r.apply(this,arguments)}}(),K=()=>{console.log(`Simulator: Game loaded, ready to start`),C.disabled=!1,p.forEach(e=>{var t;return(t=e.onMessage)==null?void 0:t.call(e,`READY_GAME_LOADED`,void 0,W)}),c&&!h.hasStarted&&setTimeout(()=>{let e=k(`#simulator-start`);e==null||e.click(),S.disabled=!1,h.hasStarted=!0,N(`Running`,`ready`)},100)};return ne((e,t)=>{var n,r;if(e===`READY`){console.log(`Simulator: Received READY from game`),G(ce.includes(t==null?void 0:t.runtimeContract)?t.runtimeContract:`1.0`);return}if(e===`READY_GAME_LOADED`){K();return}if(e===`TIMER_TICK`){if(t!=null&&t.display){let[e,n]=t.display;P(e,n)}return}if(e===`TIMER_SYNC`)return;if(e===`SIDEBAR_UPDATE`){console.log(`Simulator: Sidebar update`,t);return}p.forEach(n=>{var r;return(r=n.onMessage)==null?void 0:r.call(n,e,t,W)});let i=(n=t==null||(r=t.input)==null?void 0:r.boardState)==null?t==null?void 0:t.boardState:n;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===`START_REPEATABLE_ROUND`&&console.log(`Simulator: Repeatable round started`,t),e===`RESUME_REPEATABLE_ROUND`&&console.log(`Simulator: Repeatable round resumed`,t),e===`UPDATE_TABLE_GAME_STATE`&&console.log(`Simulator: Table game state`,t),e===`REQUEST_PUZZLE`){V(`PUZZLE_DATA`,H(t));return}if(e===`UPDATE_GAME_USER_STATE`&&typeof(t==null?void 0:t.state)==`string`){var a;h.userStorage={state:t.state,stateVersion:(a=t.stateVersion)==null?1:a},console.log(`Simulator: Game user storage updated`,t)}e===`GAME_COMPLETED`&&(console.log(`Simulator: Game completed!`,t),S.disabled=!0,h.hasStarted=!1,N(`Completed!`,`complete`))},B),console.log(`Simulator initialized`),vn={updateFixtures:e=>{l=re(e),u=Array.from(l.keys()).sort(),W.fixtures=l,W.fixtureCategories=u;let t=localStorage.getItem(`simulator-fixture-category`);if(!h.selectedCategory||!u.includes(h.selectedCategory)){var n;h.selectedCategory=t&&u.includes(t)?t:(n=u[0])==null?null:n}let r=p.find(e=>e.id===`ctrl`);r==null||r.bind(W),console.log(`Simulator: Fixtures updated`,{categories:u,selectedCategory:h.selectedCategory})},sendToGame:V,loadPuzzle:R},vn}var Sn={id:`simulator-game`,slug:`proto-game`,stableSlug:`proto-game`,displayName:`Proto Game`,version:{id:`simulator-version`,label:null,featuresArr:[0],flagsArr:[0],runtime:{id:`simulator-runtime`,version:null}}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return hn}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return xn}});
2233
+ //# sourceMappingURL=createSimulator-BfoUQbBk.cjs.map