gamestage 0.79.0 → 0.80.0
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/cli.mjs +2 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -307,7 +307,7 @@ You scored {points} points.`},Wne=Object.keys(Gz),qz=l.object({notify_template_s
|
|
|
307
307
|
`);for(let n of t??[])process.stderr.write(` ${Tf(n)}
|
|
308
308
|
`)}process.exit(1)}async function To(e,t,n={}){if(pu)Z({ok:!1,error:{code:e,message:t,...n.extra},detail:n.detail??[]});else{process.stderr.write(`${M.red("Error")} ${Tf(t)}
|
|
309
309
|
`);for(let r of n.detail??[])process.stderr.write(` ${Tf(r)}
|
|
310
|
-
`)}return pa(n.exitCode??1)}var pu,Vue,bm,M,Hue,Kue,$R,ct=L(()=>{"use strict";pu=!1;Vue=()=>!pu&&process.stdout.isTTY===!0&&!process.env.NO_COLOR,bm=(e,t)=>Vue()?`\x1B[${e}m${t}\x1B[0m`:t,M={bold:e=>bm("1",e),dim:e=>bm("2",e),red:e=>bm("31",e),green:e=>bm("32",e),yellow:e=>bm("33",e),cyan:e=>bm("36",e)};Hue=["admin","adopt","ads","archive","cdn","client","create","deploy","dev","doctor","docs","domain","endpoint","fixtures","formats","graphic","help","inspect","issue","leaderboard","link","list","live","login","logout","logs","look","manifest","open","org","plan","promote","prune","reference","rename","results","review","round","sources","start","status","suggest","suspend","theme","usage","verify","wake","whoami","workspace"],Kue=/`gamestage ([a-z][a-z-]*)((?: [^`]*)?)`/g});function Yue(e=__){let[t,n]=e.replace(/^[^\d]*/,"").split(".").map(Number);return[t,n||0]}function a3(e,t=__){let[n,r]=Yue(t),[o,a]=e.split(".").map(Number);return o>n||o===n&&a>=r}var Jn,Ys,__,Gl=L(()=>{"use strict";Jn="0.
|
|
310
|
+
`)}return pa(n.exitCode??1)}var pu,Vue,bm,M,Hue,Kue,$R,ct=L(()=>{"use strict";pu=!1;Vue=()=>!pu&&process.stdout.isTTY===!0&&!process.env.NO_COLOR,bm=(e,t)=>Vue()?`\x1B[${e}m${t}\x1B[0m`:t,M={bold:e=>bm("1",e),dim:e=>bm("2",e),red:e=>bm("31",e),green:e=>bm("32",e),yellow:e=>bm("33",e),cyan:e=>bm("36",e)};Hue=["admin","adopt","ads","archive","cdn","client","create","deploy","dev","doctor","docs","domain","endpoint","fixtures","formats","graphic","help","inspect","issue","leaderboard","link","list","live","login","logout","logs","look","manifest","open","org","plan","promote","prune","reference","rename","results","review","round","sources","start","status","suggest","suspend","theme","usage","verify","wake","whoami","workspace"],Kue=/`gamestage ([a-z][a-z-]*)((?: [^`]*)?)`/g});function Yue(e=__){let[t,n]=e.replace(/^[^\d]*/,"").split(".").map(Number);return[t,n||0]}function a3(e,t=__){let[n,r]=Yue(t),[o,a]=e.split(".").map(Number);return o>n||o===n&&a>=r}var Jn,Ys,__,Gl=L(()=>{"use strict";Jn="0.80.0",Ys="2026-11-15-4",__=">=22.13.0"});function Do(){return{[vG]:Jn}}function Xue(e){let t=e;return t?.code===u_||t?.status===426}function Zue(e){let t=e?.trim()||`Update required: this is gamestage ${Jn}, and a newer version is needed. Run ${mu}.`;G()?process.stderr.write(JSON.stringify({ok:!1,code:u_,error:t,update:{current:Jn,command:mu},detail:[]},null,2)+`
|
|
311
311
|
`):process.stderr.write(`${t}
|
|
312
312
|
`),process.exit(1)}function Kr(e){if(!Xue(e))return;let t=e.code===u_,n=e.message;Zue(t&&typeof n=="string"?n:void 0)}var li=L(()=>{"use strict";Ye();ct();Gl()});function Jue(e){try{let t=new URL(e).hostname.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.startsWith("127.")}catch{return!1}}function i3(e){return e.GAMESTAGE_TEST_RUN==="1"||e.NODE_TEST_CONTEXT!==void 0}function hs(e=process.env){return i3(e)?1:void 0}function k_(e=Qt,t=process.env){if(i3(t)&&!Jue(e)&&t.GAMESTAGE_ALLOW_REMOTE_TESTS!=="1")return`Refusing to register a test game against non-local control plane ${e}. Use the throwaway local control plane, or set GAMESTAGE_ALLOW_REMOTE_TESTS=1 for a deliberate real-plane run.`}function wm(e=Qt){let t=k_(e);t&&B(t)}async function Ri(){let e=await jn();return e||B("You are not signed in.",["Run `gamestage login`. It creates the account too if you do not have one.","Inspecting, scaffolding and validating a manifest still need no account."]),e}async function Le(e={}){let t=await Ri();return{client:ms({baseUrl:Qt,headers:Do(),maxAttempts:hs(),workspace:e.ignoreChoice?void 0:ii(),org:e.org,token:async()=>(await jn())?.accessToken??t.accessToken}),email:t.email??t.userId??"unknown"}}async function Ua(e={}){let t=await jn().catch(()=>null);if(t)return ms({baseUrl:Qt,headers:Do(),maxAttempts:hs(),workspace:ii(),org:e.org,token:async()=>(await jn())?.accessToken??t.accessToken})}async function ql(){await Ri();let e=await Ua();if(!e)throw new Error("Signed in, but the session could not be read. Run `gamestage login` again.");return e}async function nn(){let e=await jn();return e||B("You are not signed in.",["Run `gamestage login`. An operator's command needs an operator's own session."]),{admin:hG({baseUrl:Qt,headers:Do(),maxAttempts:hs(),token:async()=>(await jn())?.accessToken??e.accessToken}),email:e.email??e.userId??"unknown"}}async function Af(e){try{let t=await e.getWorkspace(),n=t?.access;return n==="approved"||n==="pending"||n==="refused"?{access:n,workspace:t}:{access:"unreported",workspace:t}}catch(t){Kr(t);let n=t.status,r=t.code;return r===IR?{access:"pending"}:r===c_?{access:"unknown",problem:"not_a_control_plane",reason:t.message??`${Qt} is not a Gamestage control plane.`,detail:["You are signed in, and your token was never checked: the address is wrong, not the token.","The main Space's API is https://api.gamestage.ai, which is the default when GAMESTAGE_CONTROL_URL is unset."]}:n===404||r==="not_found"?{access:"unknown",problem:"no_control_plane",reason:`Nothing is serving a control plane at ${Qt}.`,detail:["You are signed in, and deploying will fail until this is pointed somewhere real.","Set GAMESTAGE_CONTROL_URL to your control plane and run this again."]}:n===401||n===403?{access:"unknown",problem:"token_refused",reason:"The control plane refused this account's token.",detail:[`It is at ${Qt}.`,"A token from one environment is refused by another, so check which one you signed into."]}:{access:"unknown",problem:"unreachable",reason:`Could not reach the control plane at ${Qt}.`,detail:[String(t.message??t),"You are signed in. Deploying will fail until this answers."]}}}function Cf(e){switch(e.access){case"approved":return{ok:!0,status:"approved",access:"approved",heading:"Approved",message:"Your account is approved, so every command works, including deploy.",next:["`gamestage status` shows the workspace, its games and what they are using."]};case"pending":return{ok:!0,status:"pending_approval",access:"pending",code:IR,heading:"On the waitlist",message:"You are registered and your account is on the waitlist. That is the normal path for an account created without an invitation, and a person decides it.",next:["Finish your application at https://gamestage.ai/stage: three questions and the terms. Nobody can approve the account until both are in.","We email you when the account is approved, usually within one to two weeks.","Inspecting a prototype, scaffolding a game and writing a round all work now and need no approval.","`gamestage status` re-checks approval. It never opens the browser again."]};case"refused":return{ok:!0,status:"access_refused",access:"refused",heading:"Access refused",message:"This account has been refused access. Signing in worked, so this is a decision about the account rather than a broken token.",next:["Nothing in the CLI changes this, and running `gamestage login` again will not.","Inspecting, scaffolding and writing a round still work and need no account.",`If you think this is wrong, say so where you registered: ${fn}.`]};case"unreported":return{ok:!0,status:"access_not_reported",access:null,heading:"Signed in",message:"This control plane answered and does not report an access state, so whether this account is approved is not known here.",next:["It predates the access state rather than being broken, so carry on.","A deploy that is refused for approval will say so in its own words."]};default:return{ok:!1,status:e.problem==="no_control_plane"||e.problem==="not_a_control_plane"?e.problem:e.problem==="token_refused"?"token_refused":"control_plane_unreachable",access:null,heading:"Signed in, and the control plane is not usable",message:e.reason,next:e.detail}}}function s3(e){return!e.changed&&e.refused?{ok:!0,status:"refused_by_store",access:e.access,code:e.code,heading:"Not approved",message:e.refused,next:[e.code==="profile_incomplete"?"Nothing was written. When they have finished their application in Stage, run this again.":e.code==="personal_email"?"Nothing was written. Ask them to sign in with their work email, or approve the exception in Stage > Approvals.":"Nothing was written. When they have accepted the terms, run this again."]}:e.changed?e.access==="approved"?{ok:!0,status:"approved",access:"approved",heading:"Approved",message:`${e.workspaceId} was ${e.previous} and is now approved.`,next:["Their next `gamestage status` says approved, and deploy works from then on."]}:{ok:!0,status:"refused",access:"refused",heading:"Refused",message:`${e.workspaceId} was ${e.previous} and is now refused.`,next:["Their next `gamestage status` says refused, and says how to argue with it."]}:{ok:!0,status:"unchanged",access:e.access,heading:"No change",message:`${e.workspaceId} was already ${e.previous}. Nothing was written.`,next:["No audit record either: the trail records transitions, and this was not one."]}}function _m(e){if(q(e.heading),v(` ${e.message}`),e.next.length){v();for(let t of e.next)I(t)}v()}function l3(e,t,n){let r=i=>{let s=i.trim().toLowerCase();return _i.options.find(c=>c===s||Ca[c].toLowerCase()===s)},o=_i.options.map(i=>`${i} (${Ca[i]})`).join(", "),a=r(t);return a?n===void 0?{request:{workspaceId:e,tier:a}}:!/^\d+$/.test(n)||Number(n)>1e4?{problem:`"${n}" is not a live-game allowance.`,detail:["Give a whole number from 0 to 10000, where 0 means no ceiling.","Nothing has been changed."]}:{request:{workspaceId:e,tier:a,allowance:Number(n)}}:r(e)?{problem:"The workspace comes first and the plan second.",detail:[`Try: ${xe(`admin plan ${t} ${e}`)}`,"Nothing has been changed."]}:{problem:`"${t}" is not a plan.`,detail:[`Use one of: ${o}.`,"Nothing has been changed."]}}function vm(e){let t=Ca[e.tier];if(e.liveGameAllowance===void 0)return t;let n=e.liveGameAllowance===0?"no live-game ceiling":`${e.liveGameAllowance} live game${e.liveGameAllowance===1?"":"s"}`;return`${t}, ${n}`}function c3(e){let{request:t,previous:n,result:r,stored:o}=e,a=vm({tier:t.tier,liveGameAllowance:t.allowance}),i={previous:n,stored:o};return r.refused?{...i,status:"refused_by_store",exitCode:1,heading:"Not changed",message:r.refused,next:["Nothing was written."]}:o?o.tier===t.tier&&(t.allowance===void 0||o.liveGameAllowance===t.allowance)?n!==null&&n.tier===o.tier&&n.liveGameAllowance===o.liveGameAllowance?{...i,status:"unchanged",exitCode:0,heading:"No change",message:`${t.workspaceId} was already on ${vm(o)}, and still is.`,next:[RR]}:{...i,status:"set",exitCode:0,heading:"Plan set",message:`${t.workspaceId} is on ${vm(o)}, read back from the control plane after the write.`,next:[RR]}:{...i,status:"not_what_was_asked",exitCode:1,heading:"Not what was asked",message:`${t.workspaceId} was sent ${a} and holds ${vm(o)}. The write reported success, and the stored workspace disagrees with it.`,next:["Run it again to see whether the second read agrees. If it still disagrees, that is a control-plane defect to raise, not an operator mistake."]}:{...i,status:"unconfirmed",exitCode:2,heading:"Sent, and not confirmed",message:`The control plane accepted ${t.workspaceId} moving to ${a}, and could not then be asked what it kept: ${e.unreadable??"no reason given"}.`,next:["Treat the plan as unknown rather than set. Run this again once the control plane answers reads; repeating the same plan is safe.",RR]}}function u3(e){if(q(e.heading),v(` ${e.message}`),v(),z("Before",e.previous?vm(e.previous):"could not be read"),z("Stored now",e.stored?vm(e.stored):"could not be read"),e.next.length){v();for(let t of e.next)I(t)}v()}function Que(e){let t=e.status,n=e instanceof Error?e.message:"";if(!(t!==404||!/^No game with id\b/.test(n)))return"This workspace has no game by that id: it was never registered, or `create` could not register it. Run `gamestage manifest register gamestage.yaml` in the game's folder, then run this again."}async function Te(e){let t=[],n=e.status,r=e.code;if(Kr(e),r===IR){let{client:a}=await Le(),i=Cf(await Af(a));i.access==="approved"&&i.next.push("The original command was not completed. Run it again."),G()?Z({ok:!1,status:i.status,access:i.access,code:i.code,message:i.message,next:i.next}):_m(i),process.exit(1)}r===c_&&B(e instanceof Error?e.message:`${Qt} is not a Gamestage control plane.`,["Your session was never checked: the address is wrong, not the token.","Unset GAMESTAGE_CONTROL_URL to use https://api.gamestage.ai, or set it to a Space's API address.",`Code: ${r}`]);let o=Que(e);o&&t.push(o),n===401?t.push("Your session has expired. Run `gamestage login` again."):n===403&&r===eu?G()&&await To(eu,e instanceof Error?e.message:"Not an organisation admin."):n===403?t.push("Either your session expired or that is not something this workspace is allowed to do. `gamestage login` rules out the first."):n===429?t.push("You are being rate limited. Wait a moment and try again."):e.retryable&&t.push("This one is worth retrying: the failure was at our end."),r&&t.push(`Code: ${r}`),t.push(`Control plane: ${Qt}`),B(e instanceof Error?e.message:"The control plane call failed.",t)}var Qt,IR,RR,Wt=L(()=>{"use strict";v_();Ye();Oi();ct();si();li();Qt=process.env.GAMESTAGE_CONTROL_URL??"https://api.gamestage.ai";IR="access_pending";RR="This does not re-provision. A live round keeps the caps it was provisioned with, including its day cap, until the game is deployed again, so a creator refused before this is refused the same way until they redeploy with `gamestage deploy`. That is not this change failing."});var Sm,fu,Vo,Zs,fs,Tn,gs,mde,pde,hde,fde,gde,yde,bde,vde,wde,_de,kde,xm,FR,ci=L(()=>{"use strict";Sm=`/**
|
|
313
313
|
* @monterosa/gamestage-player, bundled for a browser.
|
|
@@ -896,7 +896,7 @@ export {
|
|
|
896
896
|
shootOperation,
|
|
897
897
|
shootProgressOf
|
|
898
898
|
};
|
|
899
|
-
`,fu="48fd8242624ce764",Vo="gamestage-player.js",Zs='/**\n * @monterosa/gamestage, bundled for a browser.\n * Gamestage client 0.116.0.\n *\n * Generated by the Gamestage CLI. Do not edit: it is replaced whenever the CLI\n * writes it again, and it carries no game logic of yours. Minified; its source\n * map is beside it on gamestage.ai.\n */\nvar es=Object.defineProperty;var qa=Object.getOwnPropertyDescriptor;var Ba=Object.getOwnPropertyNames;var za=Object.prototype.hasOwnProperty;var ee=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(s){throw n=[s],s}};var Wo=(e,t)=>{for(var n in t)es(e,n,{get:t[n],enumerable:!0})},Ha=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ba(t))!za.call(e,o)&&o!==n&&es(e,o,{get:()=>t[o],enumerable:!(s=qa(t,o))||s.enumerable});return e};var Va=e=>Ha(es({},"__esModule",{value:!0}),e);function nr(e,t){let n=a=>{let d=e[a],f=d&&typeof d=="object"?d:void 0,c=f?[t,"all","en",...Object.keys(f)].filter(u=>!!u).map(u=>f[u]).find(u=>typeof u=="boolean"||typeof u=="string"&&u.trim()):d;return typeof c=="boolean"?String(c):typeof c=="string"?c.trim():""},s=Object.fromEntries(Object.entries(rc).map(([a,d])=>[a,n(`label_notify_${a}`)||d])),o=n("consent_brand_name"),r=n("privacy_policy_url"),i=(n("notify_channels")||"email").split(",").map(a=>a.trim()).filter(a=>["email","sms","rcs"].includes(a));return{enabled:["true","yes","1"].includes(n("notify_enabled")),channels:i,ownerName:o,privacyUrl:r,labels:s,termsVersion:n("notify_terms_version")||"2",wording:`${s.consent.replaceAll("{brand}",o)} ${s.privacy}`}}function wn(e,t){return t==="email"?e.length<=254&&/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(e):/^\\+[1-9]\\d{6,14}$/.test(e)}var rc,ds=ee(()=>{"use strict";rc={title:"Tell me my result",via:"Send my result by",email:"Email",sms:"Text message",email_address:"Email address",mobile_number:"Mobile number",country:"Country",consent:"{brand} will use these details to tell you your result. You can unsubscribe at any time.",privacy:"Privacy policy",button:"Notify Me",pending:"Saving\\u2026",success:"Done. We\'ll tell you after full time.",error:"That did not work. Please try again.",invalid_email:"Enter an email address, such as name@example.com.",invalid_mobile:"Enter a complete mobile number for the country you picked.",code:"6-digit code",code_incomplete:"Enter all 6 digits.",confirm:"Confirm",resend_code:"Send a new code",resend_email:"Send the email again",resend_wait:"Send again in {seconds}s",resent:"Sent. Check again.",change_address:"Use a different number or email"}});function En(e,t){if(!e||typeof e!="object"||Array.isArray(e))return e;let n=e;for(let s of[t,"all","en",...Object.keys(n)])if(s&&n[s]!==void 0&&n[s]!==null&&n[s]!=="")return n[s]}function or(e,t){if(!e)return{};let n={},s=En(e.gate_age_required,t),o=typeof s=="boolean"?s:typeof s=="string"?s.trim().toLowerCase():void 0;o===!0||o==="true"||o==="yes"||o==="1"?n.ageRequired=!0:(o===!1||o==="false"||o==="no"||o==="0")&&(n.ageRequired=!1);let r=En(e.gate_minimum_age,t),i=typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r.trim()):NaN;Number.isInteger(i)&&i>0&&i<=120&&(n.minimumAge=i);let a=En(e.gate_territories,t);if(typeof a=="string"&&a.trim()){let f=a.split(/[\\s,;]+/).map(c=>c.trim().toUpperCase()).filter(c=>/^[A-Z]{2}$/.test(c));n.territories=[...new Set(f)]}let d=En(e.gate_note,t);return typeof d=="string"&&d.trim()&&(n.note=d.trim().slice(0,200)),n}function rr(e,t){let n=e??{},s=n.ageRequired!==void 0;if(!(s||n.minimumAge!==void 0||n.territories!==void 0||n.note!==void 0))return t?{...t}:void 0;let i=n.ageRequired??!!t?.minimumAge?n.minimumAge??t?.minimumAge??ic:void 0,a=n.territories?.length?n.territories:n.territories!==void 0||!s?t?.territories:void 0,d=n.note??(s?void 0:t?.note);if(!(!i&&!a?.length))return{...i?{minimumAge:i}:{},...a?.length?{territories:[...a]}:{},...d?{note:d}:{}}}function ir(e,t){if(!e||t!==!0||!e.minimumAge)return e;if(e.territories?.length)return{territories:[...e.territories],...e.note?{note:e.note}:{}}}var sr,ic,ls=ee(()=>{"use strict";sr=["gate_age_required","gate_minimum_age","gate_territories","gate_note"];ic=18});function Cn(e){let t=Array.isArray(e)?e.filter(s=>typeof s=="string"):typeof e=="string"?e.split(/[\\s,]+/):[],n=new Set;for(let s of t){let o=s.trim();if(!/^[a-z][a-z0-9+.-]*:\\/\\/[^/?#@*\\s]+\\/?$/i.test(o))continue;let r;try{r=new URL(o)}catch{continue}let i=r.hostname==="localhost"||r.hostname==="127.0.0.1";r.protocol!=="https:"&&!(r.protocol==="http:"&&i)||n.add(r.origin)}return[...n]}function cc(){return{necessary:!0,analytics:!1,marketing:!1,functional:!1}}function qt(e,t,n={}){let s=cc();for(let o of ar)o!=="necessary"&&(s[o]=e[o]===!0);return{version:1,categories:s,source:t,decidedAt:(n.at??new Date).toISOString(),policyVersion:n.policyVersion??us,jurisdiction:n.jurisdiction??ac}}function lr(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||t.source!=="host"&&t.source!=="fan"&&t.source!=="default"||typeof t.decidedAt!="string"||typeof t.policyVersion!="string"||typeof t.jurisdiction!="string"||!t.categories||typeof t.categories!="object")return null;let n=t.categories;for(let s of ar)if(typeof n[s]!="boolean")return null;return qt(n,t.source,{policyVersion:t.policyVersion,jurisdiction:t.jurisdiction,at:new Date(t.decidedAt)})}function gr(e,t){let n=t.trim();if(e.includes("{brand}")){let s=!n||n.toLowerCase()==="monterosa";return e.includes("{brand} and Monterosa, who run")?s?e.replace("{brand} and Monterosa, who run","Monterosa, who runs").replaceAll("{brand}","Monterosa"):e.replaceAll("{brand}",n):e.replaceAll("{brand}",n||"Monterosa")}return e}var ar,cr,dr,ac,us,ur,fr,Tn=ee(()=>{"use strict";ar=["necessary","analytics","marketing","functional"],cr="gamestage:consent:v1",dr="gamestage:consent";ac="GB",us="1";ur="https://gamestage.ai/copyright",fr={brand:"",title:"Your privacy",detail:"{brand} would like to record analytics on how you play, so we can improve the game. We only do this if you agree. Data needed to run the game, such as your scores, is processed on the basis of legitimate interests.",accept:"Accept",reject:"Reject",dismiss:"Close",choose:"Manage preferences",save:"Save my choices",necessary:"Needed for the game to work. Always on.",analytics:"Measure how the game is played",marketing:"Offers and news from the game\'s owner",functional:"Remember my preferences",settings:"Privacy settings",policy:"Privacy policy",copyright:"Report copyright infringement"}});function Ce(e,t){if(typeof e=="string")return e.trim()||void 0;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"]){if(!s)continue;let o=n[s];if(typeof o=="string"&&o.trim())return o.trim()}}function uc(e,t){if(typeof e=="boolean")return e;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"])if(s&&typeof n[s]=="boolean")return n[s]}function fc(e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e,o=("data"in n?n:[t,"all","en"].map(i=>i?n[i]:void 0).find(i=>i&&typeof i=="object"))?.data,r=Array.isArray(o)?o[0]?.id:void 0;if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}function gc(e){let t=e?.submissions;if(!Array.isArray(t))return;let n=t.find(o=>o?.name==="webservice"),s=typeof n?.data=="string"?n.data.trim().replace(/\\/+$/,""):"";return/^https?:\\/\\/[^\\s/]+$/.test(s)?s:void 0}function hs(e,t,n){let s=gc(t);if(!e||!s)return;let o={};for(let r of Object.keys(e)){if(!r.startsWith(gs)||r===gs)continue;let i=fc(e[r],n);i&&(o[r.slice(gs.length)]={id:i,host:s})}return Object.keys(o).length>0?o:void 0}function Or(e){let t=e?.forms;if(!t||typeof t!="object"||Array.isArray(t))return;let n={};for(let[s,o]of Object.entries(t)){let{id:r,host:i}=o??{};typeof r=="string"&&r!==""&&typeof i=="string"&&i.startsWith("https://")&&(n[s]={id:r,host:i})}return Object.keys(n).length>0?n:void 0}function pc(e,t=ys){return`${t}/fonts/${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.css`}function bs(e){return e.replace(/[^\\p{L}\\p{N} \\-]/gu,"").trim()}function Ar(e,t){if(!e)return;let n=Object.keys(ps).find(i=>i.toLowerCase()===e.trim().toLowerCase());if(!n)return;let s=ps[n],o=Number(t);if(!Number.isFinite(o))return{family:n,weight:s[s.length-1]};let r=[...s].sort((i,a)=>Math.abs(i-o)-Math.abs(a-o)||a-i)[0];return{family:n,weight:r}}function Ir(e){if(e===void 0)return;let t=/^\\s*(-?(?:\\d+\\.?\\d*|\\.\\d+))(?:em)?\\s*$/i.exec(e);if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return`${Math.min(.4,Math.max(-.1,n))}em`}function Nr(e){let t=e?.trim().toLowerCase();if(t)return["upper","uppercase","capitals","caps"].includes(t)?"uppercase":["none","uppercase","lowercase","capitalize"].includes(t)?t:"none"}function mc(e,t){let n=Ce(e.sponsor_name,t);if(!n)return;let s=Ce(e.sponsor_logo,t),o=Ce(e.sponsor_link,t);return{name:n,label:Ce(e.sponsor_intro,t)||"In association with",...s&&ms.test(s)?{logoUrl:s}:{},...o&&ms.test(o)?{link:o}:{}}}function Bt(e,t){let n=e?.trim();if(!n)return null;let s=t.find(r=>r.name.trim().toLowerCase()===n.toLowerCase());if(s){let r=bs(s.name);if(r)return{family:r}}let o=Object.keys(ps).find(r=>r.toLowerCase()===n.toLowerCase());return o?{family:o,stylesheetHref:pc(o)}:null}function at(e,t){let n={};if(!e)return n;if("notify_enabled"in e&&(n.notify=nr(e,t)),sr.some(b=>b in e)){let b=or(e,t);Object.keys(b).length>0&&(n.gate=b)}for(let[b,x]of Object.entries(dc)){let g=Ce(e[b],t);g&&(n[x]=g)}for(let[b,x]of Object.entries(lc)){if(n[x])continue;let g=Ce(e[b],t);g&&(n[x]=g)}let s=Ce(e.analytics_oneTrustId,t);s&&(n.oneTrustId=s);let o=Cn(Ce(e.embed_origins,t));o.length&&(n.embedOrigins=o);let r=Ce(e.logo_url,t)?.replace(/^\\/\\//,"https://");r&&ms.test(r)&&(n.logoUrl=r);let i=mc(e,t);i&&(n.sponsor=i);let a=Ce(e.default_font_family,t);a&&(n.defaultFontFamily=a);let d=e.uploaded_fonts;if(Array.isArray(d)){let b=g=>typeof g=="string"?g.trim():g==null?"":String(g),x=d.map(g=>g&&typeof g=="object"?g:{}).map(g=>({name:b(g.name),url:b(g.file),weight:b(g.weight)})).filter(g=>g.name&&g.url);x.length&&(n.uploadedFonts=x)}let f="css_variables_",c={};for(let b of Object.keys(e)){if(!b.startsWith(f))continue;let x=Ce(e[b],t);x&&(c[b.slice(f.length)]=x)}Object.keys(c).length>0&&(n.cssVariables=c);let u={};for(let b of Object.keys(e)){if(!b.startsWith(pr))continue;let x=Ce(e[b],t);x&&(u[b.slice(pr.length)]=x)}Object.keys(u).length>0&&(n.labels=u);let y={};for(let b of Object.keys(e)){if(!b.startsWith(fs)||b===fs)continue;let x=uc(e[b],t);x!==void 0&&(y[b.slice(fs.length)]=x)}return Object.keys(y).length>0&&(n.options=y),n}var mr,hr,yr,br,_r,vr,Sr,wr,Er,Cr,Tr,xr,kr,dc,lc,pr,fs,gs,ps,ys,ms,St=ee(()=>{"use strict";ds();ls();Tn();mr="Provisional result. Final at {finalAt}.",hr=["a","b","c","d","e","f"],yr=e=>`quiz_option_${e}`,br="quiz_question",_r="quiz_image",vr="quiz_image_alt",Sr="quiz_media",wr=e=>`quiz_option_${e}_image`,Er="quiz_outcome_name",Cr="quiz_outcome_verdict",Tr="quiz_outcome_why",xr="quiz_outcome_image",kr="quiz_outcome_image_alt",dc={display_name:"displayName",title_font:"titleFont",title_font_weight:"titleFontWeight",title_letter_spacing:"titleLetterSpacing",title_colour:"titleColour",title_case:"titleCase",logo_text:"logoText",logo_accent_colour:"logoAccentColour",splash_gradient_start:"splashGradientStart",splash_gradient_end:"splashGradientEnd",splash_play_label:"splashPlayLabel",splash_continue_label:"splashContinueLabel",splash_error_text:"splashErrorText",splash_retry_label:"splashRetryLabel",consent_brand_name:"consentBrandName",consent_title:"consentTitle",consent_detail:"consentDetail",consent_accept_label:"consentAcceptLabel",consent_reject_label:"consentRejectLabel",consent_choose_label:"consentChooseLabel",consent_save_label:"consentSaveLabel",consent_analytics_label:"consentAnalyticsLabel",consent_marketing_label:"consentMarketingLabel",consent_functional_label:"consentFunctionalLabel",consent_settings_label:"consentSettingsLabel",consent_policy_version:"consentPolicyVersion",privacy_policy_url:"privacyPolicyUrl",signin_play_as_label:"signInPlayAsLabel",signin_detail:"signInDetail",signin_dismiss_label:"signInDismissLabel",recovery_open_label:"recoveryOpenLabel",recovery_show_title:"recoveryShowTitle",recovery_show_detail:"recoveryShowDetail",recovery_private_note:"recoveryPrivateNote",recovery_replace_note:"recoveryReplaceNote",recovery_enter_title:"recoveryEnterTitle",recovery_enter_detail:"recoveryEnterDetail",recovery_submit_label:"recoverySubmitLabel",recovery_not_recognised:"recoveryNotRecognised",recovery_restored:"recoveryRestored",recovery_get_label:"recoveryGetLabel",recovery_issue_failed:"recoveryIssueFailed",recovery_copy_label:"recoveryCopyLabel",recovery_copied_label:"recoveryCopiedLabel",recovery_share_label:"recoveryShareLabel",recovery_close_label:"recoveryCloseLabel",analytics_url:"analyticsUrl",strapline:"strapline",how_to_play:"howToPlay",primary_colour:"primaryColour",play_button_label:"playButtonLabel",play_again_label:"playAgainLabel",result_button_label:"resultButtonLabel",share_button_label:"shareButtonLabel",edition_name:"editionName",edition_strapline:"editionStrapline",edition_live_contest:"liveContest",margin_over:"marginOver",margin_exact:"marginExact",margin_under:"marginUnder",result_over:"resultOver",result_exact:"resultExact",result_under:"resultUnder",share_over:"shareOver",share_exact:"shareExact",share_under:"shareUnder",result_bust_note:"resultBustNote",share_bust_note:"shareBustNote",capped_today_note:"cappedTodayNote",share_dare:"shareDare",result_dare:"resultDare"},lc={primary_color:"primaryColour"},pr="label_",fs="option_",gs="form_";ps={"Abril Fatface":[400],Anton:[400],"Archivo Black":[400],"Bebas Neue":[400],Bungee:[400],"Chakra Petch":[300,400,500,600,700],"DM Serif Display":[400],Fraunces:[400,600,700,900],Oswald:[400,500,600,700],"Playfair Display":[400,700,900],"Russo One":[400],"Space Grotesk":[400,500,700],Teko:[400,500,600,700],Unbounded:[400,700,900]},ys="https://gamestage.ai";ms=/^https:\\/\\//i});function Te(e,t){if(typeof e=="string")return e.trim()||void 0;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"]){if(!s)continue;let o=n[s];if(typeof o=="string"&&o.trim())return o.trim()}}function _c(e){return typeof e=="boolean"?e:Te(e)?.toLowerCase()==="true"}function zt(e,t){if(!e)return{enabled:!1};let n={web:Te(e.userAccessSignInUrlWeb,t),iOS:Te(e.userAccessSignInUrlNativeIOS,t),android:Te(e.userAccessSignInUrlNativeAndroid,t)},s={web:Te(e.userAccessSignUpUrlWeb,t),iOS:Te(e.userAccessSignUpUrlNativeIOS,t),android:Te(e.userAccessSignUpUrlNativeAndroid,t)},o=r=>Object.values(r).some(Boolean);return{enabled:_c(e.mIdEnabled),frontendUrl:Te(e.mIdFrontendUrl,t),apiUrl:Te(e.mIdApiUrl,t),clientId:Te(e.xClientId,t),title:Te(e.userAccessTitle,t),subtitle:Te(e.userAccessSubtitle,t),...o(n)?{signInUrl:n}:{},...o(s)?{signUpUrl:s}:{}}}var ws=ee(()=>{"use strict"});function Et(e,t){return e.declared?e.categories[t]===!0:!1}function ct(e,t){return e.analyticsRequiresConsent?Et(t,$r):!0}function dt(e,t){return ct(e,t)}var $r,Ht=ee(()=>{"use strict";$r="analytics"});function Gr(e){let t=0,n=0;return{track(s){if(!ct(e.policy,e.consent()))return t+=1,!1;for(let o of e.destinations)try{o.send(s)}catch{}return e.destinations.length>0&&(n+=1),e.destinations.length>0},get withheld(){return t},get sent(){return n}}}function On(e){let t={};for(let[n,s]of Object.entries(e))if(s===null)t[n]=null;else if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")t[n]=s;else{if(s===void 0)continue;try{t[n]=JSON.stringify(s)??null}catch{t[n]=null}}return t}var Vt=ee(()=>{"use strict";Ht()});function Kt(){let e=0,t=!1;return{now:()=>Date.now()+e,sample(n){Number.isFinite(n)&&(e=n-Date.now(),t=!0)},get synchronised(){return t}}}function Ct(e,t){if(!t)return;let n=Date.parse(t);Number.isNaN(n)||e.sample(n)}var Wt=ee(()=>{"use strict"});function ti(e){return`gamestage:settings:v${Ds}:${e}`}function si(e){return Et(e,ni)}function oi(e){let t=e.now??(()=>Date.now()),n=e.readTimeoutMs??300;return{async read(s){let o;try{o=await Promise.race([e.store.read(ti(s)),new Promise(r=>setTimeout(()=>r(null),n))])}catch{return null}if(!o)return null;try{let r=JSON.parse(o);if(r.format!==Ds||typeof r.savedAt!="number"||t()-r.savedAt>Lc)return null;let i=r.presentation;return!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0?null:i}catch{return null}},async write(s,o){if(si(e.consent())&&Object.keys(o).length!==0)try{await e.store.write(ti(s),JSON.stringify({format:Ds,savedAt:t(),presentation:o}))}catch{}}}}var Ds,ni,Lc,$s=ee(()=>{"use strict";Ht();Ds=1,ni="functional",Lc=720*60*60*1e3});function Gs(e){return e.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i,"").replace(/\\/+$/,"")}var Us=ee(()=>{"use strict"});var Ai={};Wo(Ai,{TextDecoder:()=>Oi,TextEncoder:()=>ki,default:()=>pd});var ki,Oi,pd,Ii=ee(()=>{"use strict";ki=globalThis.TextEncoder,Oi=globalThis.TextDecoder,pd={TextEncoder:ki,TextDecoder:Oi}});function Ve(){if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}function ut(e){return Rn.localStorage.getItem(Ws(e))}function tn(e,t){return Rn.localStorage.setItem(Ws(e),t)}function Ys(e){return Rn.localStorage.removeItem(Ws(e))}function Qs(){return Rn.localStorage.clear()}function nn(){try{return tn(Pn,Pn),ut(Pn),Ys(Pn),!0}catch{return!1}}function Ge(e,t,...n){let s=t[e](...n);return new Ze(e,s)}function Ne(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return"Unknown error"}}function Js(){return Date.now()/1e3}function Ri(e){return Math.floor(e)+.5}function _d(){return(Ri(Tt)+1-Tt)*1e3}function Mi(){clearTimeout(en);let e=Js(),t=e-Hs;Tt+=t,Hs=e,en=setTimeout(Mi,_d()),typeof en=="object"&&"unref"in en&&en.unref(),Pi.emit("tick",Tt)}function Xs(e){Hs=Js(),Tt=Ri(e)}function Ke(){return Math.floor(Tt)}function Mn(e){return He(Pi,"tick",e)}function Di(e){let s=2166136261,o=new Vs().encode(e);for(let r=0;r<o.length;r++)s^=o[r],s=Math.imul(s,16777619)>>>0;return s.toString(16).padStart(8,"0")}function Ln(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ue(e){return e.trim()}function et(e){let t=Ni.get(e);if(t!==void 0)return t;let n=new Ks(e);return n.logLevel=wd,n.logHandler=Ed,Ni.set(e,n),n}var z,He,be,md,Pn,Rn,Ws,Ze,hd,yd,cf,bd,df,Pi,Tt,Hs,en,Li,zs,vd,Vs,B,Sd,$i,Ks,Ni,wd,Ed,We=ee(()=>{z=class{constructor(){this.listeners=new Map}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){var s;if(n===void 0){this.listeners.delete(t);return}(s=this.listeners.get(t))===null||s===void 0||s.delete(n)}emit(t,...n){var s;(s=this.listeners.get(t))===null||s===void 0||s.forEach(o=>o(...n))}once(t,n){let s=(...o)=>{n(...o),this.off(t,s)};return this.on(t,s)}},He=(e,t,n)=>(e.on(t,n),()=>e.off(t,n));be=(e,t,n={})=>{var s,o;let r=(s=n.clearOnResolve)!==null&&s!==void 0?s:!1,i=(o=n.clearOnReject)!==null&&o!==void 0?o:!0,a=new Map,d=(...f)=>{let c=t(...f);if(a.has(c))return a.get(c);let u=e(...f);return a.set(c,u),u.then(()=>r&&a.delete(c)).catch(()=>i&&a.delete(c)),u};return d.cache=a,d};md="monterosa_sdk_",Pn="bait",Rn=Ve(),Ws=e=>`${md}${e}`;Ze=class e extends Error{constructor(t,n){super(n),this.name="MonterosaError",this.code=t,Object.setPrototypeOf(this,e.prototype)}};hd=typeof global=="object"&&global&&global.Object===Object&&global,yd=typeof self=="object"&&self&&self.Object===Object&&self,cf=hd||yd||Function("return this")(),bd=Object.prototype,df=bd.toString;Pi=new z,Tt=0,Hs=0;Xs(Js());Mi();Li=e=>{let t=e.reduce((r,i)=>r+i,0),n=e.map((r,i)=>{let a=100*r/t||0;return{idx:i,votes:r,percentage:Math.floor(a),remainder:a%1}}),s=n.reduce((r,{percentage:i})=>r+i,0);s=s||100;let o=100-s;n.sort((r,i)=>r.remainder!==i.remainder?i.remainder-r.remainder:r.idx-i.idx);for(let r=0;r<o;r++)n[r].percentage+=1;return n.sort((r,i)=>r.idx-i.idx),n.map(r=>r.percentage)};vd=typeof process<"u"&&((zs=process.versions)===null||zs===void 0?void 0:zs.node)!=null;vd?Vs=(Ii(),Va(Ai)).TextEncoder:Vs=TextEncoder;(function(e){e[e.Verbose=0]="Verbose",e[e.Debug=1]="Debug",e[e.Info=2]="Info",e[e.Warn=3]="Warn",e[e.Error=4]="Error",e[e.Silent=5]="Silent"})(B||(B={}));Sd={[B.Verbose]:"log",[B.Debug]:"log",[B.Info]:"info",[B.Warn]:"warn",[B.Error]:"error"},$i=(e,t,...n)=>{let s=Sd[t],o=e.name.replace("@monterosa/sdk-","monterosa/");console[s](`[${o}]`,...n)},Ks=class{constructor(t){this.name=t,this._logLevel=B.Warn,this._logHandler=$i}get logLevel(){return this._logLevel}set logLevel(t){this._logLevel=t}get logHandler(){return this._logHandler}set logHandler(t){this._logHandler=t}emit(t,...n){this._logLevel>t||this._logHandler(this,t,...n)}log(...t){this.emit(B.Verbose,...t)}debug(...t){this.emit(B.Debug,...t)}info(...t){this.emit(B.Info,...t)}warn(...t){this.emit(B.Warn,...t)}error(...t){this.emit(B.Error,...t)}},Ni=new Map,wd=B.Warn,Ed=$i});function sn(e=Gi){let t=to.get(e);if(!t)throw new Error(`No Monterosa Sdk "${e}" has been configured.\n You need to call configure() first`);return t}function Ui(e,t=Gi){let n=to.get(t);if(n)return n;let s=new eo(e,t);return to.set(t,s),s}var Cd,Gi,Td,Zs,eo,to,Dn=ee(()=>{We();Cd="2.0.0-rc.9";Gi="[DEFAULT]",Td=Cd;if(typeof document<"u"){let e=document.title||((Zs=document.location)===null||Zs===void 0?void 0:Zs.hostname)||"",t=e?` \\u2014 "${e}"`:"";console.debug(`Monterosa SDK v${Td}${t}`)}eo=class{constructor(t,n){this._isDestroyed=!1,this._options=Object.assign(Object.assign({},t),{host:Ue(t.host),projectId:Ue(t.projectId)}),this._name=n,this._kits=new Map}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get isDestroyed(){return this._isDestroyed}get kits(){return this._kits}set isDestroyed(t){this._isDestroyed=t}deleteKits(){this.kits.forEach((t,n)=>{this.kits.delete(n),t.delete()})}checkDestroyed(){if(this.isDestroyed)throw new Error(`SDK named ${this.name} destroyed`)}};to=new Map});function zi(e){if(e<=0)throw Ge(tt.InvalidRequestTimeoutError,Bi);fo.requestTimeout=e}function Pd(e){return e instanceof Object&&Object.prototype.hasOwnProperty.call(e,"bridgeId")}function Rd({data:e}){try{if(typeof e!="string")return;let t=JSON.parse(e);go(t)}catch(t){Gn.error(Ne(t))}}function Ld(e){if(rn.has(e))return rn.get(e);let t=new Fn(e);return rn.set(e,t),t}function Dd(){if(typeof window>"u")return null;if(on!==void 0)return on;let t=new URL(window.location.href).searchParams.get(kd);return t===null?null:(on=new Fn(t),on.send(gt.OnBridgeInitialised,{},xe.Sdk),on)}function Hi(e,t={}){rn.forEach(n=>{n.isConnected&&n.send(e,t,xe.Sdk)})}function xt(e){return He(Md.monterosaSdk.emitter,"message",t=>{t.sourceName===xe.Sdk&&t.action!==gt.OnBridgeInitialised&&rn.has(t.bridgeId)&&e(t)})}function po(e,t,n={}){return e.bridge.send(t,n,xe.Sdk)}function jn(e,t,n={},s=fo.requestTimeout){return e.bridge.request(t,n,s,xe.Sdk)}function an(e,t={}){$d(xe.Sdk,e,t)}function $d(e,t,n){Ld(t.bridgeId).send(t.action,n,e,t.id)}function Gd(e,t,n){return He(e.bridge,"message",s=>{s.sourceName===t&&n(s)})}function Vi(e,t){return Gd(e,xe.Sdk,t)}function Se(){if($n!==void 0)return $n;let e=Dd();return e===null?null:($n=new uo(e),$n)}var gt,xe,no,so,oo,ro,Un,xd,kd,Od,Ad,Id,Nd,tt,Bi,fo,Gn,io,ao,co,lo,Fi,ji,qi,Fe,go,ft,Fn,Md,on,rn,uo,$n,kt=ee(()=>{We();(function(e){e.OnBridgeInitialised="onBridgeInitialised",e.OnExperienceInitialised="onExperienceInitialised",e.OnReady="onReady",e.OnResize="onIntrinsicSizeChanged",e.OnMoreDataRequested="onMoreDataRequested",e.OnShare="onShare"})(gt||(gt={}));(function(e){e.Sdk="sdk",e.User="user"})(xe||(xe={}));Un=Ve(),xd="micBridge",kd="micBridgeId",Od=!!(!((oo=(so=(no=Un.webkit)===null||no===void 0?void 0:no.messageHandlers)===null||so===void 0?void 0:so.monterosaSdk)===null||oo===void 0)&&oo.postMessage),Ad=!!(!((ro=Un.monterosaSdk)===null||ro===void 0)&&ro.postMessage),Id=Un.self!==Un.parent,Nd="1.0.0";(function(e){e.InvalidRequestTimeoutError="invalid_request_timeout_error",e.RequestTimeoutError="request_timeout_error"})(tt||(tt={}));Bi={[tt.InvalidRequestTimeoutError]:()=>"Request timeout must be greater than 0",[tt.RequestTimeoutError]:(e,t)=>`Request timeout: action "${e}" did not receive a response within ${t}ms`};fo={requestTimeout:2e4};Gn=et("@monterosa/sdk-bridge-kit");Fe=Ve(),go=e=>{Pd(e)&&Fe.monterosaSdk.emitter.emit("message",e)};(io=Fe.monterosaSdk)!==null&&io!==void 0||(Fe.monterosaSdk={initialised:!1,emitter:new z,receiveMessage:go});(ao=(Fi=Fe.monterosaSdk).initialised)!==null&&ao!==void 0||(Fi.initialised=!1);(co=(ji=Fe.monterosaSdk).emitter)!==null&&co!==void 0||(ji.emitter=new z);(lo=(qi=Fe.monterosaSdk).receiveMessage)!==null&&lo!==void 0||(qi.receiveMessage=go);Fe.monterosaSdk.initialised||(typeof Fe.addEventListener<"u"&&Fe.addEventListener("message",Rd),Fe.monterosaSdk.initialised=!0);ft=Ve(),Fn=class extends z{constructor(t=Ln()){super(),this.id=t,this.recipientInitialised=!1,this.messagesQueue=[],ft.monterosaSdk.emitter.on("message",this.handleMessage.bind(this))}static isMessage(t){return t instanceof Object&&Object.prototype.hasOwnProperty.call(t,"bridgeId")&&Object.prototype.hasOwnProperty.call(t,"action")}get iFrameId(){return`${xd}-${this.id}`}get iFrameSelector(){return`iframe#${this.iFrameId}`}get childIFrame(){return document.querySelector(this.iFrameSelector)}handleMessage(t){let{id:n,bridgeId:s,action:o,respondingTo:r}=t;if(s===this.id){if(Gn.log(`Received a ${r===null?"message":"response"}`,t),o===gt.OnBridgeInitialised){r===null&&this.send(gt.OnBridgeInitialised,{},xe.Sdk,n),this.connect();return}this.emit("message",t)}}createMessage(t,n,s,o=null){return{id:Ln(),respondingTo:o,action:t,sourceName:s,bridgeId:this.id,payload:n,version:Nd,timestamp:Date.now()}}get isConnected(){return this.recipientInitialised}connect(){for(this.recipientInitialised=!0;this.messagesQueue.length>0;)this.postMessage(this.messagesQueue.shift())}disconnect(){this.recipientInitialised=!1}postMessage(t){var n,s,o,r;if(!this.recipientInitialised&&t.action!==gt.OnBridgeInitialised){this.messagesQueue.push(t);return}let i=JSON.stringify(t);Od&&((s=(n=ft.webkit)===null||n===void 0?void 0:n.messageHandlers)===null||s===void 0||s.monterosaSdk.postMessage(i)),Ad&&!((o=ft.monterosaSdk)===null||o===void 0)&&o.postMessage&&ft.monterosaSdk.postMessage(i),Id&&ft.parent.postMessage(i,"*"),this.childIFrame&&((r=this.childIFrame.contentWindow)===null||r===void 0||r.postMessage(i,"*"))}send(t,n={},s=xe.Sdk,o){let r=this.createMessage(t,n,s,o);return Gn.log(`Sending a ${r.respondingTo===null?"message":"response"}`,r),this.postMessage(r),r}async request(t,n={},s=fo.requestTimeout,o=xe.Sdk){let r,i,a=this.createMessage(t,n,o);Gn.log("Sending a request",a);let d=new Promise((c,u)=>{r=setTimeout(()=>{u(Ge(tt.RequestTimeoutError,Bi,t,s))},s)}),f=new Promise(c=>{i=u=>{u.respondingTo===a.id&&c(u)},ft.monterosaSdk.emitter.on("message",i),this.postMessage(a)});return Promise.race([d,f]).finally(()=>{clearTimeout(r),ft.monterosaSdk.emitter.off("message",i)})}};Md=Ve(),rn=new Map;uo=class{constructor(t){this.bridge=t}};});function Ud(e){var t;if(Object.values(je).includes(e.action))try{let n={};switch(e.action){case je.Read:n={key:e.payload.key,value:Pe.getItem(e.payload.key)};break;case je.Write:n={key:e.payload.key},Pe.setItem(e.payload.key,e.payload.value);break;case je.Remove:n={key:e.payload.key},Pe.removeItem(e.payload.key);break;case je.Clear:Pe.clear();break}an(e,n)}catch(n){let s=Ne(n),o=(t=e.payload)===null||t===void 0?void 0:t.key,r=o?` for key "${o}"`:"";qn.error(`Unable to handle storage action ${e.action}${r} with error: ${s}`),an(e,{error:s})}}async function ho(e,t,n){try{let s=await jn(e,t,n),{value:o,error:r}=s.payload;if(r!==void 0)throw Ge(we.ParentAppError,cn,r);return o}catch(s){if(s instanceof Ze&&s.code===tt.RequestTimeoutError){let o=Ne(s);throw Ge(we.ParentTimeoutError,cn,o)}throw s}}async function Ot(e){let t=Se(),n=null;try{t!==null?n=await ho(t,je.Read,{key:e}):n=Pe.getItem(e)}catch(s){let o=Ne(s);throw qn.error(`Unable to read storage item "${e}" with error: ${o}`),Ge(we.ReadError,cn,o)}return n}async function At(e,t){let n=Se();try{n!==null?await ho(n,je.Write,{key:e,value:t}):Pe.setItem(e,t)}catch(s){let o=Ne(s);throw qn.error(`Unable to write storage item "${e}" with error: ${o}`),Ge(we.WriteError,cn,o)}}async function Bn(e){let t=Se();try{t!==null?await ho(t,je.Remove,{key:e}):Pe.removeItem(e)}catch(n){let s=Ne(n);throw qn.error(`Unable to remove storage item "${e}" with error: ${s}`),Ge(we.RemoveError,cn,s)}}var je,we,cn,mo,qn,Pe,zn=ee(()=>{We();kt();(function(e){e.Read="storageRead",e.Write="storageWrite",e.Remove="storageRemove",e.Clear="storageClear"})(je||(je={}));(function(e){e.ParentAppError="parent_app_error",e.ParentTimeoutError="parent_timeout_error",e.ReadError="read_error",e.WriteError="write_error",e.RemoveError="remove_error",e.ClearError="clear_error"})(we||(we={}));cn={[we.ParentAppError]:e=>`Parent application error: ${e}`,[we.ParentTimeoutError]:e=>`Parent application timeout: ${e}. Please check if the storage-kit is imported on the parent page.`,[we.ReadError]:e=>`Storage read error: ${e}`,[we.WriteError]:e=>`Storage write error: ${e}`,[we.RemoveError]:e=>`Storage remove error: ${e}`,[we.ClearError]:e=>`Storage clear error: ${e}`};mo=class{constructor(){this.memoryStore={},this.accessible=nn(),this._persistent=!0}set persistent(t){if(this._persistent===t)return;let s=t===!0&&this.accessible,o=t===!1&&this.accessible;if(s)for(let[r,i]of Object.entries(this.memoryStore))tn(r,i);o&&Qs(),this._persistent=t}get persistent(){return this._persistent}getItem(t){return this.persistent&&this.accessible?ut(t):Object.prototype.hasOwnProperty.call(this.memoryStore,t)?this.memoryStore[t]:null}setItem(t,n){this.persistent&&this.accessible&&tn(t,n),this.memoryStore[t]=n}removeItem(t){this.persistent&&this.accessible&&Ys(t),delete this.memoryStore[t]}clear(){this.persistent&&this.accessible&&Qs(),this.memoryStore={}}};qn=et("@monterosa/sdk-storage-kit");Pe=new mo;xt(Ud)});function E(e,...t){var n;switch((n=Kd[e])!==null&&n!==void 0?n:B.Verbose){case B.Info:ln.info(...t);break;case B.Debug:ln.debug(...t);break;default:ln.log(...t);break}}function dn(e,t){ln.error(`EnMasse: ${e}: ${Ne(t)}`)}function Wd(e){ln.warn(`EnMasse: ${e}`)}var Fd,jd,Yi,Eo,Qi,Ji,Vn,Co,Xi,To,qd,Bd,xo,zd,Zi,Hd,Ki,Wi,Vd,Re,Q,le,ue,pt,ea,Me,It,ta,ln,Kd,yo,Kn,na,sa,Yd,bo,J,Hn,fe,he,Qd,_o,Jd,vo,Xd,Zd,el,So,wo,tl,nl,Pt,Rt,Nt,M,oa=ee(()=>{We();zn();kt();Fd="enmasse_override_methods",jd="enmasse_config",Yi="auth",Eo="authr",Qi="authok",Ji="ping",Vn="sub",Co="unsub",Xi="eoc",To="login",qd="login_ok",Bd="login_fail",xo="logout",zd="counter",Zi=e=>{if(nn()){let n=ut(e);if(n!==null)return n}if(typeof window>"u")return null;let{searchParams:t}=new URL(window.location.href);return t.has(e)?t.get(e):!1},Hd=()=>{let e=Zi(Fd);if(typeof e=="string")return e.split(",")},Ki=Hd(),Wi=Zi(jd),Vd="2.0.0-rc.9";Re=1,Q=2,le=4,ue=8,pt=16,ea=32,Me=64,It=128,ta=256,ln=et("@monterosa/sdk-enmasse-kit"),Kd={[Re]:B.Info,[Q]:B.Debug,[le]:B.Debug,[ue]:B.Debug,[Me]:B.Verbose,[It]:B.Verbose,[pt]:B.Verbose,[ea]:B.Verbose,[ta]:B.Verbose};yo=class{constructor(t={}){this.queue=[],this.stashed=[],this.running=!1,this.runner=typeof t.runner=="function"?t.runner:null,this._subscriptions=[]}push(t,n=!1){E(pt,"Queue::push",t,n);let{klass:s,channel:o}=t;if(!n)switch(s){case To:case xo:case Eo:break;case Vn:if(this._subscriptions.indexOf(o)===-1)this._subscriptions.push(o);else return;break;case Co:{let r=this._subscriptions.indexOf(o);if(r!==-1)this._subscriptions.splice(r,1);else return;break}default:if(this._subscriptions.indexOf(o)===-1)return;break}this.queue.push(t)}get subscriptions(){return this._subscriptions}run(){E(pt,"Queue::run",`running=${this.running}, head=${this.queue[0]}`),!(this.runner===null||this.running||!this.queue[0])&&(this.running=!0,this.runner(this.queue.shift()))}success(){E(pt,"Queue::success"),this.running=!1,this.run()}failure(){E(pt,"Queue::failure"),this.running=!1}stash(){E(pt,"Queue::stash");let t;for(;(t=this.queue.shift())!==void 0;)this.stashed.push(t)}unstash(){E(pt,"Queue::unstash");let t;for(;(t=this.stashed.shift())!==void 0;)this.queue.push(t)}},Kn=()=>Date.now()/1e3,na=Kn(),sa=Kn(),Yd=e=>{E(ea,"Time::setTime",e),na=e,sa=Kn()},bo=()=>{let e=Kn()-sa;return Math.round(na+e)},J=class e extends z{constructor(){super(...arguments),this.state=e.STATE_DISCONNECTED,this.trigger=this.emit,this.bind=this.on,this.unbind=this.off}connect(){}disconnect(){}init(){}send(t,n,s){}};J.ON_READY="ready";J.ON_MESSAGE="message";J.ON_CONNECTED="connected";J.ON_CONNECT_FAILED="connect_failed";J.ON_CONNECT_LOST="connect_lost";J.ON_DISCONNECTED="disconnected";J.STATE_CONNECTED="connected";J.STATE_CONNECTING="connecting";J.STATE_DISCONNECTED="disconnected";J.STATE_DISCONNECTING="disconnecting";Hn=[0,3,5,10,20,30,45,60],fe=class e extends z{constructor(t){super(),this._handleTransportMessage=s=>{E(Q,"ConnectionManager::handleTransportMessage",s);let o=s.split("\\0");for(let r=0;r<o.length;r+=1)o[r].length>0&&(this._inactivityTimeout.reset(),E(Q,"ConnectionManager::handleTransportMessage","send upstream m:",o[r]),this.emit(e.ON_MESSAGE,o[r]))},this._handleTransportConnected=()=>{E(Q,"ConnectionManager::handleTransportConnected"),this._setStateToConnected()},this._handleTransportConnectFailed=()=>{E(Q,"ConnectionManager::handleTransportConnectFailed"),this._disconnectingOnConnectFailed()},this._handleTransportConnectLost=()=>{E(Q,"ConnectionManager::handleTransportConnectLost"),this._disconnectingOnConnectLost()},this._handleTransportDisconnected=()=>{switch(E(Q,"ConnectionManager::handleTransportDisconnected"),this._state){case e.STATE_CONNECTED:this._disconnectedOnConnectLost();break;case e.STATE_CONNECTING:this._disconnectedOnConnectFailed();break;case e.STATE_DISCONNECTING:this._setStateToDisconnected();break}},this._handleVisibilityChange=()=>{switch(E(Q,"ConnectionManager::handleVisibilityChange()",document.visibilityState),document.visibilityState){case"visible":if(this._backgroundedAt===null||this._state!==e.STATE_CONNECTED)return;Date.now()-this._backgroundedAt>this._config.background_timeout*1e3&&(E(Q,"ConnectionManager::handleVisibilityChange()","disconnecting due to background timeout"),this._disconnect()),this._backgroundedAt=null;break;case"hidden":this._backgroundedAt=Date.now();break}},this._handleNetworkStatus=()=>{!navigator.onLine&&this._state===e.STATE_CONNECTED&&(E(Q,"ConnectionManager::handleNetworkStatus()","disconnecting due to network loss"),this._disconnect())},this._transportManager=t,this._state=e.STATE_DISCONNECTED,this._transport=null,this._attempt=1,this._backgroundedAt=null;let n=this;this._inactivityTimeout={start(){E(Me,"ConnectionManager::inactivityTimeout::start");let s=bo();this.interval=setInterval(()=>{bo()-s>=n._config.inactivity_timeout&&this.resolve()},1e3)},stop(){E(Me,"ConnectionManager::inactivityTimeout::stop"),clearInterval(this.interval)},reset(){E(Me,"ConnectionManager::inactivityTimeout::reset"),this.stop(),this.start()},resolve(){E(Me,"ConnectionManager::inactivityTimeout::resolve"),n._disconnectingOnConnectLost()}},this._connectTimeout={start(){E(Me,"ConnectionManager::connectTimeout::start"),this.timeout=setTimeout(()=>{this.resolve()},n._config.connect_timeout*1e3)},stop(){E(Me,"ConnectionManager::connectTimeout::stop"),clearTimeout(this.timeout)},resolve(){E(Me,"ConnectionManager::connectTimeout::resolve"),n._disconnectingOnConnectFailed()}},this._connectDelay={active:!1,start(s){E(Me,"ConnectionManager::connectDelay::start"),this.active=!0,this.timeout=setTimeout(()=>{this.resolve()},s*1e3)},stop(){E(Me,"ConnectionManager::connectDelay::stop"),this.active=!1,clearTimeout(this.timeout)},resolve(){E(Me,"ConnectionManager::connectDelay::resolve"),this.stop(),n._connect()}}}_initTransport(t){E(Q,"ConnectionManager::initTransport"),this._transport=t,t.bind(J.ON_MESSAGE,this._handleTransportMessage),t.bind(J.ON_CONNECTED,this._handleTransportConnected),t.bind(J.ON_CONNECT_FAILED,this._handleTransportConnectFailed),t.bind(J.ON_CONNECT_LOST,this._handleTransportConnectLost),t.bind(J.ON_DISCONNECTED,this._handleTransportDisconnected)}_teardownTransport(){E(Q,"ConnectionManager::teardownTransport"),this._transport!==null&&(this._transport.unbind(J.ON_MESSAGE,this._handleTransportMessage),this._transport.unbind(J.ON_CONNECTED,this._handleTransportConnected),this._transport.unbind(J.ON_CONNECT_FAILED,this._handleTransportConnectFailed),this._transport.unbind(J.ON_CONNECT_LOST,this._handleTransportConnectLost),this._transport.unbind(J.ON_DISCONNECTED,this._handleTransportDisconnected),this._transport=null)}_disconnectingOnConnectFailed(){E(Q,"ConnectionManager::disconnectingOnConnectFailed()"),this._disconnect()}_disconnectingOnConnectLost(){E(Q,"ConnectionManager::disconnectingOnConnectLost()"),this._disconnect()}_disconnectedOnConnectLost(){E(Q,"ConnectionManager::disconnectedOnConnectLost()"),this._teardownTransport(),this._setStateToConnecting()}_disconnectedOnConnectFailed(){E(Q,"ConnectionManager::disconnectedOnConnectFailed()"),this._transportManager.addUnsuccessful(this._transport),this._teardownTransport(),this._transportManager.next()===!1?this._setStateToConnecting():this._connect()}_setStateToConnecting(){E(Q,"ConnectionManager::setStateToConnecting()");let t;this._attempt>=Hn.length?t=Hn[Hn.length-1]:t=Hn[this._attempt-1],this._state=e.STATE_CONNECTING,this.emit(e.ON_STATE,this._state,this._attempt,t),this._transportManager.reset(),this._attempt+=1,this._connectDelay.start(t)}_setStateToConnected(){E(Q,"ConnectionManager::setStateToConnected()"),this._attempt=1,this._transportManager.reset(),this._inactivityTimeout.reset(),this._connectTimeout.stop(),this._connectDelay.stop(),this._state=e.STATE_CONNECTED,this.emit(e.ON_STATE,this._state)}_setStateToDisconnecting(){E(Q,"ConnectionManager::setStateToDisconnecting()"),this._state=e.STATE_DISCONNECTING,this.emit(e.ON_STATE,this._state),this._disconnect()}_setStateToDisconnected(){E(Q,"ConnectionManager::setStateToDisconnected()"),this._attempt=1,this._teardownTransport(),this._transportManager.reset(),this._state=e.STATE_DISCONNECTED,this.emit(e.ON_STATE,this._state)}_connect(){var t;this._state===e.STATE_CONNECTING&&(this._connectTimeout.start(),this._initTransport(this._transportManager.current),(t=this._transport)===null||t===void 0||t.connect())}_disconnect(){this._inactivityTimeout.stop(),this._connectTimeout.stop(),this._connectDelay.stop(),this._transport?this._transport.disconnect():this._setStateToDisconnected()}connect(){E(Q,"ConnectionManager::connect()"),this._connectDelay.active?this._connectDelay.resolve():this._state===e.STATE_DISCONNECTED&&this._setStateToConnecting(),window.addEventListener("online",this._handleNetworkStatus),window.addEventListener("offline",this._handleNetworkStatus),window.addEventListener("visibilitychange",this._handleVisibilityChange)}disconnect(){E(Q,"ConnectionManager::disconnect()"),this._setStateToDisconnecting(),window.removeEventListener("online",this._handleNetworkStatus),window.removeEventListener("offline",this._handleNetworkStatus),window.removeEventListener("visibilitychange",this._handleVisibilityChange)}send(t,n=()=>{},s=()=>{}){var o;E(Q,"ConnectionManager::send",t),(o=this._transport)===null||o===void 0||o.send(t,n,s)}get connectAttempt(){return this._attempt}init(t){E(Q,"ConnectionManager::init()",t),this._config=t}};fe.STATE_DISCONNECTED="state_disconnected";fe.STATE_DISCONNECTING="state_disconnecting";fe.STATE_CONNECTING="state_connecting";fe.STATE_CONNECTED="state_connected";fe.ON_MESSAGE="message";fe.ON_STATE="state";he=class e extends z{constructor(){super(...arguments),this.connected=!1,this.trigger=this.emit,this.bind=this.on,this.unbind=this.off}connect(t,n,s){}disconnect(){}send(...t){}init(){this.trigger(e.ON_READY)}};he.ON_READY="ready";he.ON_MESSAGE="message";he.ON_CONNECTED="connected";he.ON_DISCONNECTED="disconnected";Qd=Ve(),_o=class e extends he{constructor(t={}){super(),this.config=t,this.requests={},this.requestIdx=0}_request(t,n=()=>{},s=()=>{},o=()=>{}){this.requestIdx+=1,E(It,`XHRDriver::request url=${t}, idx=${this.requestIdx}`);let r=new XMLHttpRequest,i="POST";if(typeof XDomainRequest<"u")r=new XDomainRequest,r.open(i,t);else if("withCredentials"in r)r.open(i,t,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded");else return null;return r._idx=this.requestIdx,r.onload=()=>{E(It,`XHRDriver::request::onload idx=${r._idx}, response=${r.responseText}`),r.responseText.length>0?n(this._parseResponse(r.responseText)):s(r.responseText)},r.onerror=()=>{E(It,`XHRDriver::request::onerror idx=${r._idx}, response=${r.responseText}`),s(r.responseText)},r._onabort=()=>{E(It,`XHRDriver::request::onabort idx=${r._idx}`),o()},r}_parseResponse(t){let n={},s=t.split("&");for(let o=0,r=s.length;o<r;o++){let[i,a]=s[o].split("="),d=decodeURIComponent((a??"").replace("\\0",""));i in n?(n[i].constructor!==Array&&(n[i]=[n[i]]),n[i].push(d)):n[i]=d}return n}_removeRequest(t){E(It,"XHRDriver::removeRequest",t),Object.prototype.hasOwnProperty.call(this.requests,t)&&delete this.requests[t]}connect(){if(E(ue,"XHRDriver::connect"),this.connected){E(ue,"XHRDriver::connect already been connected!");return}this.connected=!0,this.trigger(e.ON_CONNECTED)}disconnect(){if(E(ue,"XHRDriver::disconnect"),this.connected){for(let t in this.requests)Object.prototype.hasOwnProperty.call(this.requests,t)&&typeof this.requests[t].abort=="function"&&(this.requests[t].abort(),typeof this.requests[t]._onabort=="function"&&this.requests[t]._onabort(),this._removeRequest(t));this.connected=!1}this.trigger(e.ON_DISCONNECTED)}send(t,n,s=()=>{},o=()=>{}){E(ue,"XHRDriver::send",n);let r,i=1,a=()=>{r=this._request(t,d,f,c),this.requests[r._idx]=r,setTimeout(()=>{r.send(n)},0)},d=u=>{E(ue,"XHRDriver::success",n),this._removeRequest(r._idx),s(u)},f=u=>{var y,b;E(ue,"XHRDriver::failure, retry: ",i),this._removeRequest(r._idx),i<=((y=this.config.request_retries)!==null&&y!==void 0?y:0)?setTimeout(()=>{a(),i++},((b=this.config.request_retry_delay)!==null&&b!==void 0?b:0)*1e3):o(u)},c=()=>{E(ue,"XHRDriver::abort",n),this._removeRequest(r._idx),o()};a()}static hasSupport(){return"XDomainRequest"in Qd||"withCredentials"in new XMLHttpRequest}},Jd=Ve(),vo=class e extends he{constructor(){super(...arguments),this.websocket=null,this.closeTimeout=void 0}_onMessage(t){E(ue,"WebSocketDriver::onMessage",t.data),this.trigger(e.ON_MESSAGE,t.data)}_onOpen(){E(ue,"WebSocketDriver::onOpen"),this.connected=!0,this.trigger(e.ON_CONNECTED)}_onClose(){E(ue,"WebSocketDriver::onClose"),this._disconnect()}_onError(){E(ue,"WebSocketDriver::onError")}_disconnect(){E(ue,"WebSocketDriver::disconnect"),this.connected=!1,this.websocket!==null&&(this.websocket.onmessage=()=>{},this.websocket.onopen=()=>{},this.websocket.onclose=()=>{},this.websocket.onerror=()=>{},this.websocket=null),clearTimeout(this.closeTimeout),this.trigger(e.ON_DISCONNECTED)}connect(t,n,s){if(this.connected)return;E(ue,"WebSocketDriver::connect",t,n);let o=`${s?"wss":"ws"}://${t}:${n}/ws`;this.websocket=new WebSocket(o),this.websocket.onmessage=this._onMessage.bind(this),this.websocket.onopen=this._onOpen.bind(this),this.websocket.onclose=this._onClose.bind(this),this.websocket.onerror=this._onError.bind(this)}disconnect(){var t;E(ue,"WebSocketDriver::disconnect"),this.connected?((t=this.websocket)===null||t===void 0||t.close(),this.closeTimeout=setTimeout(this._disconnect.bind(this),750)):this._disconnect()}send(t,n=()=>{}){var s;E(ue,"WebSocketDriver::send",t),(s=this.websocket)===null||s===void 0||s.send(t),n()}static hasSupport(){return"WebSocket"in Jd}},Xd="connect",Zd="pass",el="poll",So=class e extends J{constructor(t={}){E(le,"ProxyTransport::constructor",t),super(),this.driver=t.driver,this.host=t.host,this.port=t.port,this.secure=t.secure||!1,this.proxyIp=null,this.childId=null,this.clientId=null,this.sessionId=null,this.driver.bind(he.ON_READY,this._handleDriverReady.bind(this)),this.driver.bind(he.ON_CONNECTED,this._handleDriverConnected.bind(this)),this.driver.bind(he.ON_DISCONNECTED,this._handleDriverDisconnected.bind(this))}_url(){let t=this.childId===null?"":`${this.childId}/`;return`${this.secure?"https":"http"}://${this.proxyIp?this.proxyIp:this.host}:${this.port}/${t}?_r=${new Date().getTime()}`}_request(t="",n=()=>{},s=()=>{}){let o=i=>{i.sscp.constructor===String&&(i.sscp=[i.sscp]);for(let a=0,d=i.sscp.length;a<d;a++)i.sscp[a]!==""&&this.trigger(e.ON_MESSAGE,i.sscp[a]);n(i)},r=()=>{switch(this.state){case e.STATE_CONNECTED:case e.STATE_CONNECTING:this.state=e.STATE_DISCONNECTING,this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.state=e.STATE_DISCONNECTED,this.trigger(e.ON_DISCONNECTED);break}s()};this.driver.send(this._url(),t,o,r)}_poll(){let t=`command=${el}&clientid=${this.clientId}&sid=${this.sessionId}`;this._request(t,this._poll.bind(this))}_connect(){let t=o=>{o&&(this.proxyIp=o.proxy,this.clientId=Number.parseInt(o.clientid,10),this.childId=Number.parseInt(o.childid,10),this.sessionId=o.sid,this.state=e.STATE_CONNECTED,this.trigger(e.ON_CONNECTED),this._poll())},n=()=>{this.state=e.STATE_DISCONNECTED,this.trigger(e.ON_CONNECT_FAILED)},s=`command=${Xd}`;this._request(s,t,n)}_handleDriverReady(){this.trigger(e.ON_READY)}_handleDriverConnected(){this._connect()}_handleDriverDisconnected(){E(le,"ProxyTransport::handleDriverDisconnected");let{state:t}=this;switch(this.state=e.STATE_DISCONNECTED,t){case e.STATE_CONNECTED:this.trigger(e.ON_CONNECT_LOST);break;case e.STATE_CONNECTING:this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.trigger(e.ON_DISCONNECTED);break}}send(t,n=()=>{},s=()=>{}){E(le,"ProxyTransport::send",t);let o=`command=${Zd}&clientid=${this.clientId}&sscp=${t}&sid=${this.sessionId}`;this._request(o,n,s)}connect(){E(le,"ProxyTransport::connect",this.host,this.port),this.state=e.STATE_CONNECTING,this.driver.connect()}disconnect(){E(le,"ProxyTransport::disconnect"),this.proxyIp=null,this.childId=null,this.sessionId=null,this.state=e.STATE_DISCONNECTING,this.driver.disconnect()}init(){E(le,"ProxyTransport::init"),this.driver.init()}},wo=class e extends J{constructor(t={}){E(le,"SocketTransport::constructor",t),super(),this.driver=t.driver,this.host=t.host,this.port=t.port,this.secure=t.secure||!1,this.driver.bind(he.ON_READY,this._handleDriverReady.bind(this)),this.driver.bind(he.ON_MESSAGE,this._handleDriverMessage.bind(this)),this.driver.bind(he.ON_CONNECTED,this._handleDriverConnected.bind(this)),this.driver.bind(he.ON_DISCONNECTED,this._handleDriverDisconnected.bind(this))}_handleDriverReady(){E(le,"SocketTransport::_handleDriverReady"),this.trigger(e.ON_READY)}_handleDriverMessage(t){E(le,"SocketTransport::handleDriverMessage"),this.trigger(e.ON_MESSAGE,t)}_handleDriverConnected(){E(le,"SocketTransport::handleDriverConnected"),this.state=e.STATE_CONNECTED,this.trigger(e.ON_CONNECTED)}_handleDriverDisconnected(){E(le,"SocketTransport::handleDriverDisconnected");let{state:t}=this;switch(this.state=e.STATE_DISCONNECTED,t){case e.STATE_CONNECTED:this.trigger(e.ON_CONNECT_LOST);break;case e.STATE_CONNECTING:this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.trigger(e.ON_DISCONNECTED);break}}send(t,n=()=>{},s=()=>{}){E(le,"SocketTransport::send",t),this.driver.send(t,n,s)}connect(){E(le,"SocketTransport::connect",this.host,this.port),this.state=e.STATE_CONNECTING,this.driver.connect(this.host,this.port,this.secure)}disconnect(){E(le,"SocketTransport::disconnect"),this.state=e.STATE_DISCONNECTING,this.driver.disconnect()}init(){E(le,"SocketTransport::init"),this.driver.init()}},tl="proxy",nl="websocket",Pt=class e extends z{constructor(){super(),this.idx=0,this.methods={},this.transports={},this.loaded=0,this.sequence=[],this.allowed=[],this.secure=!0,this.unsuccessful=[],typeof window<"u"&&(this.secure=window.location.protocol.startsWith("https"))}_instantiate(){E(Q,"TransportManager::instantiate"),this.allowed.forEach(t=>{let n=this._getMethodConfig(t),s=n.hosts[Math.floor(Math.random()*n.hosts.length)],o=this.methods[t].transport,r=this.methods[t].driver,i=new o({driver:new r(n.driver||{}),host:s,port:this.secure?n.secure_port:n.port,secure:this.secure});this.transports[t]=i,i.bind(J.ON_READY,this._handleTransportReady.bind(this))});for(let t in this.transports)Object.prototype.hasOwnProperty.call(this.transports,t)&&this.transports[t].init()}_getMethodConfig(t){return this.config.methods.find(n=>n.type===t)}_handleTransportReady(){this.loaded+=1,this.loaded===this.allowed.length&&this.emit(e.ON_READY)}get current(){return this.transports[this.allowed[this.idx]]}next(){return this.idx+=1,this.idx>=this.allowed.length?!1:this.current}reset(){this.allowed=[],this.unsuccessful=[];for(let t=0,n=this.sequence.length;t<n;t+=1){let s=this.sequence[(t+this.idx)%n];this.methods[s].driver.hasSupport()&&this.allowed.push(s)}this.idx=0}addUnsuccessful(t){for(let n in this.transports)Object.prototype.hasOwnProperty.call(this.transports,n)&&this.transports[n]===t&&this.unsuccessful.push(n)}init(t={}){this.config=t,this.idx=0,this.loaded=0,this.sequence=[],this.secure=t.forceSecure===!0?!0:this.secure,this.methods[tl]={driver:_o,transport:So},this.methods[nl]={driver:vo,transport:wo},Ki?this.sequence=Ki:this.config.methods.forEach(s=>this.sequence.push(s.type));let n=s=>Object.prototype.hasOwnProperty.call(this.methods,s);this.sequence=this.sequence.filter(n),this.reset(),this._instantiate()}};Pt.ON_READY="ready";Rt=class e extends z{addCounter(t,n,s,o,r=null,i=null,a=null){if(E(ta,"Demographics::addCounter",t,n,s,o,r,i,a),!t||!n||!Array.isArray(s)||!s.length||s.length%2!==0||o!==Number.parseInt(String(o),10))return;let d=s.filter((c,u)=>(u+1)%2).join(":"),f=s.filter((c,u)=>u%2).join(":");this.emit(e.ON_ADD_COUNTER,t,[n,i,a,r,d,f,o])}};Rt.ON_ADD_COUNTER="add-counter";Nt="enmasse_session_id",M=class e extends z{constructor({transportManager:t=new Pt,demographics:n=new Rt,connectionManager:s}={}){super(),this._runner=o=>{let r=()=>{this._queue.success()},i=()=>{this._queue.failure()};this._connectionManager.send(this._stringifySSCP(o),r,i)},this._handleTransportManagerReady=()=>{E(Re,"Enmasse::handleTransportManagerReady"),this.emit(e.ON_READY)},this._handleConnectionManagerState=(o,r,i)=>{switch(E(Re,"Enmasse::handleConnectionManagerState",o,r,i),o){case fe.STATE_DISCONNECTED:this._setStateToDisconnected();break;case fe.STATE_CONNECTING:this._setStateToConnecting(r,i);break;case fe.STATE_CONNECTED:break}},this._handleConnectionManagerMessage=async o=>{E(Re,"Enmasse::handleConnectionManagerMessage",o);let r=this._parseSSCP(o);switch(r.klass){case Yi:{let i=r.sent_at,a=[`enmassejs-${e.VERSION}`,navigator.userAgent].concat(this._info);this._sysChannel=r.channel,a.forEach((d,f)=>{a[f]=encodeURIComponent(d)}),this._sessionId===null&&([this._sessionId]=r.body,await this._storeSession(this._sessionId)),Yd(i),this._queue.stash(),this._queue.push({channel:this._sysChannel,klass:Eo,body:[this._sessionId,e.PROTOCOL_VERSION,a.join(",")]},!0),this._queue.run();break}case Qi:{let{subscriptions:i}=this._queue;i.forEach(a=>{this._queue.push({channel:a,klass:Vn,body:[]},!0)}),this._queue.unstash(),this._queue.run(),this._setStateToConnected();break}case qd:this._resolveLogin();break;case Bd:this._rejectLogin();break;case Ji:break;case Xi:this.emit(e.ON_EOC,r.channel);break;default:this.emit(e.ON_MESSAGE,r);break}},this._handleDemographicsCounter=(o,r)=>{this.send(o,"avgcounter",r)},this._transportManager=t,this._demographics=n,this._connectionManager=s||new fe(t),this.Demographics=this._demographics,this._configFile=null,this._info=[],this._sessionId=null,this._state=e.STATE_DISCONNECTED,this._sysChannel=null,this._forceSecure=!1,this._loginContext={inProgress:!1,success:()=>{},failure:()=>{}},this._initPromise=null}async _storeSession(t){try{await At(Nt,t)}catch(n){dn("Failed to persist session to shared storage",n)}}async _restoreSession(){let t=null;try{t=await Ot(Nt)}catch(n){dn("Failed to read session from shared storage",n)}if(t!==null)return t;if(Se()===null)return null;try{t=ut(Nt)}catch(n){dn("Failed to read local session during migration",n)}if(t===null)return null;try{await At(Nt,t)}catch(n){dn("Failed to persist session to shared storage during migration",n)}return t}async resetSession(){this._sessionId=null;try{await Bn(Nt)}catch(t){dn("Failed to remove session from shared storage",t)}}_validateSession(t){return/^[a-f\\d]{8}\\-[a-f\\d]{4}\\-[a-f\\d]{4}-[a-f\\d]{4}\\-[a-f\\d]{12}$/i.test(t)}_finaliseLogin(t){this._loginContext.inProgress!==!1&&(this._loginContext={inProgress:!1,success:()=>{},failure:()=>{}},typeof t=="function"&&t())}_resolveLogin(){this._finaliseLogin(this._loginContext.success)}_rejectLogin(){this._finaliseLogin(this._loginContext.failure)}_setStateToDisconnected(){E(Re,"Enmasse::setStateToDisconnected()"),this._state=e.STATE_DISCONNECTED,this._sysChannel=null,this._rejectLogin(),this.emit(e.ON_STATE,this._state)}_setStateToConnected(){E(Re,"Enmasse::setStateToConnected()");let t=bo();this._state=e.STATE_CONNECTED,this.emit(e.ON_STATE,this._state,t)}_setStateToConnecting(t,n){E(Re,"Enmasse::setStateToConnecting()"),this._state=e.STATE_CONNECTING,this._rejectLogin(),this.emit(e.ON_STATE,this._state,t,n)}_parseSSCP(t){let n={channel:"",klass:"",sent_at:0,body:[]},s=t.indexOf("/");if(s!==-1){let o=t.indexOf("/",s+1);if(o!==-1){n.channel=t.substr(0,s),n.klass=t.substr(s+1,o-s-1);let r=t.indexOf("/",o+1);if(r!==-1){n.sent_at=Number.parseInt(t.substr(o+1,r-o-1),10);let i=t.substr(r+1);if(i!==""){let a=i.split("|");for(let d=0,f=a.length;d<f;d+=1)n.body[d]=decodeURIComponent(a[d])}}}}return n}_stringifySSCP(t){var n;return[t.channel,t.klass,Math.floor(Date.now()/1e3),((n=t.body)!==null&&n!==void 0?n:[]).join("|")].join("/")}connect(){E(Re,"Enmasse::connect"),this._connectionManager.connect()}disconnect(){E(Re,"Enmasse:disconnect"),this._connectionManager.disconnect()}teardown(){E(Re,"Enmasse::teardown"),this.disconnect(),this._transportManager.off(Pt.ON_READY,this._handleTransportManagerReady),this._connectionManager.off(fe.ON_STATE,this._handleConnectionManagerState),this._connectionManager.off(fe.ON_MESSAGE,this._handleConnectionManagerMessage),this._demographics.off(Rt.ON_ADD_COUNTER,this._handleDemographicsCounter)}send(t,n,s=[]){E(Re,"Enmasse::send",t,n,s),this._queue.push({channel:t,klass:n,body:s}),this._state===e.STATE_CONNECTED&&this._queue.run()}get sessionId(){return this._sessionId}get state(){return this._state}subscribe(t){this.send(t,Vn)}unsubscribe(t){this.send(t,Co)}login(t,n,s,o,r){let i=this._sysChannel;if(i!==null){if(this._loginContext.inProgress){Wd("Login is already in progress");return}this._loginContext={inProgress:!0,success:o,failure:r},this.send(i,To,[t,n,s])}}logout(){let t=this._sysChannel;t!==null&&(this._loginContext.inProgress&&this._rejectLogin(),this.send(t,xo))}init(t={}){return this._initPromise||(this._initPromise=this._init(t)),this._initPromise}async _init(t={}){if(this._configFile=Wi||t.config||null,this._info=t.info||[],this._sessionId=await this._restoreSession(),typeof t.forceSecure=="boolean"&&(this._forceSecure=t.forceSecure),this._configFile===null)throw new Error("EnMasse config file is not set");let n=this._configFile;this._sessionId!==null&&!this._validateSession(this._sessionId)&&await this.resetSession(),this._queue=new yo({runner:this._runner}),this._transportManager.on(Pt.ON_READY,this._handleTransportManagerReady),this._connectionManager.on(fe.ON_STATE,this._handleConnectionManagerState),this._connectionManager.on(fe.ON_MESSAGE,this._handleConnectionManagerMessage),this._demographics.on(Rt.ON_ADD_COUNTER,this._handleDemographicsCounter);try{let s=await fetch(n),{status:o,statusText:r}=s,i;try{i=await s.json()}catch{this.emit(e.ON_ERROR,`Invalid JSON from config ${n}`);return}let a=o>=200&&o<=300||o===0&&!!r||o==="";i.forceSecure=this._forceSecure,i.background_timeout===void 0&&(i.background_timeout=0),a?(this._connectionManager.init(i),this._transportManager.init(i)):this.emit(e.ON_ERROR,`Failed to load config ${n}`)}catch(s){this.emit(e.ON_ERROR,`Error loading config: ${s.message}`)}}};M.VERSION=Vd;M.PROTOCOL_VERSION="8";M.SSCP_KLASS_AUTH=Yi;M.SSCP_KLASS_AUTHR=Eo;M.SSCP_KLASS_AUTHOK=Qi;M.SSCP_KLASS_PING=Ji;M.SSCP_KLASS_SUB=Vn;M.SSCP_KLASS_UNSUB=Co;M.SSCP_KLASS_EOC=Xi;M.SSCP_KLASS_LOGIN=To;M.SSCP_KLASS_LOGOUT=xo;M.SSCP_KLASS_COUNTER=zd;M.ON_STATE="on_state";M.ON_MESSAGE="on_message";M.ON_EOC="on_eoc";M.ON_READY="on_ready";M.ON_ERROR="on_error";M.STATE_DISCONNECTED="disconnected";M.STATE_CONNECTED="connected";M.STATE_CONNECTING="connecting";M.PARAM_SESSION_ID=Nt});function Oo(e,t,n){let s=(o,...r)=>{o===t&&n(...r)};return e.on("state",s),()=>e.off("state",s)}function Wn(e){return e===void 0&&(e=sn().options.host),sl(Ue(e))}function un(e,t){return Oo(e,ae.Connected,t)}function ia(e,t){return Oo(e,ae.Connecting,t)}function aa(e,t){return Oo(e,ae.Disconnected,t)}function ca(e,t){let n=s=>{t(s)};return e.on("message",n),()=>e.off("message",n)}function Yn(e){return e.connect()}function Qn(e){e.disconnect()}function Mt(e,t){return ol(e,Ue(t))}function Lt(e,t){e.unsubscribe(Ue(t))}function da(e,t,n,s){e.send(Ue(t),n,s)}var Ye,ae,ra,ko,sl,ol,Ao=ee(()=>{Dn();We();oa();(function(e){e.NotInitialised="not_initialised",e.Initialised="initialised",e.Initialising="initialising"})(Ye||(Ye={}));(function(e){e.Disconnected="disconnected",e.Connecting="connecting",e.Connected="connected"})(ae||(ae={}));(function(e){e.Authenticate="auth",e.AuthenticateResponse="authr",e.AuthenticateSuccess="authok",e.Ping="ping",e.Subscribe="sub",e.Unsububscribe="unsub",e.EndOfCache="eoc",e.Login="login",e.LoginSuccess="login_ok",e.LoginFail="login_fail",e.Counter="counter",e.Vote="v"})(ra||(ra={}));ko=class extends z{constructor(t=new M){super(),this.enmasse=t,this.initState=Ye.NotInitialised,this.initPromise=Promise.resolve(),this.connectPromise=null,this.enmasse.on(M.ON_STATE,(n,...s)=>{if(n===M.STATE_CONNECTED){let[o]=s;Xs(o)}this.emit("state",this.toConnState(n),...s)}),this.enmasse.on(M.ON_MESSAGE,n=>{this.emit("message",n)})}get state(){return this.toConnState(this.enmasse.state)}get sessionId(){return this.enmasse.sessionId}toConnState(t){switch(t){case M.STATE_CONNECTING:return ae.Connecting;case M.STATE_CONNECTED:return ae.Connected;case M.STATE_DISCONNECTED:default:return ae.Disconnected}}async init(t){return this.initState===Ye.Initialising||this.initState===Ye.Initialised?this.initPromise:(this.initPromise=new Promise((n,s)=>{this.initState=Ye.Initialising,this.enmasse.on(M.ON_READY,()=>{this.initState=Ye.Initialised,this.enmasse.off(M.ON_READY),this.enmasse.off(M.ON_ERROR),n()}),this.enmasse.on(M.ON_ERROR,o=>{this.initState=Ye.NotInitialised,this.enmasse.off(M.ON_READY),this.enmasse.off(M.ON_ERROR),s(new Error(`Unable to initialise connect kit: ${o}`))}),this.enmasse.init({config:`https://${t}/config/enmasse.json`})}),this.initPromise)}connect(){return this.initState!==Ye.Initialised?Promise.reject(new Error("must be initialised before connecting")):this.state===ae.Connected?Promise.resolve():this.state===ae.Connecting?this.connectPromise?this.connectPromise:Promise.reject(new Error("BUG: Connection state is Connecting but connectPromise is null - this indicates an internal inconsistency")):(this.connectPromise=new Promise((t,n)=>{let s=o=>{switch(o){case ae.Connected:this.enmasse.off(M.ON_STATE,s),this.connectPromise=null,t();break;case ae.Disconnected:this.enmasse.off(M.ON_STATE,s),this.connectPromise=null,n(new Error("disconnected"));break;case ae.Connecting:break}};this.enmasse.on(M.ON_STATE,s),this.enmasse.connect()}),this.connectPromise)}disconnect(){this.enmasse.disconnect()}subscribe(t){return new Promise(n=>{let s=o=>{o===t&&(this.enmasse.off(M.ON_EOC,s),n())};this.enmasse.on(M.ON_EOC,s),this.enmasse.subscribe(t)})}unsubscribe(t){this.enmasse.unsubscribe(t)}send(t,n,s){this.enmasse.send(t,n,s)}async login(t,n,s){return new Promise((o,r)=>{this.enmasse.login(t,n,s,o,()=>{r(new Error("Login failure"))})})}async logout(){this.enmasse.logout()}delete(){this.enmasse.teardown()}};sl=be(async e=>{let t=new ko;return await t.init(e),t},e=>e);ol=be(async(e,t)=>e.subscribe(t),(e,t)=>t)});function fn(){let e=Io.getInstance();if(!ua){for(let t of fa)t(e);ua=!0}return e}function rl(e){fa.push(e)}function ga(e){if(Se()!==null)throw new Ze(nt.CannotSetFromChild,la[nt.CannotSetFromChild]());if("necessary"in e&&e.necessary===!1)throw new Ze(nt.NecessaryCategoryRequired,la[nt.NecessaryCategoryRequired]());let n=fn();n.state=e}function pa(){var e;return(e=fn().state)!==null&&e!==void 0?e:{}}function No(e){return fn().on(Jn.ConsentChanged,e)}function ma(e){let t=fn();t.state=e}function il(){No(e=>{Hi(Dt.OnConsentUpdated,{state:e})}),xt(e=>{if(e.action!==Dt.RequestConsent)return;let t=fn();an(e,{state:t.isActive?t.state:null})})}async function al(){let e=Se();if(e!==null)try{let t=await jn(e,Dt.RequestConsent),{state:n}=t.payload;n!=null&&ma(n)}catch{}}function cl(e){let t=Se();if(t===null)return()=>{};let n=Vi(t,s=>{if(s.action===Dt.OnConsentUpdated){let{state:o}=s.payload;ma(o)}});return al(),n}var Dt,Jn,nt,la,Io,fa,ua,ha=ee(()=>{kt();We();(function(e){e.OnConsentUpdated="consentOnConsentUpdated",e.SetConsent="consentSetConsent",e.RequestConsent="consentRequestConsent"})(Dt||(Dt={}));(function(e){e.ConsentChanged="consent_changed"})(Jn||(Jn={}));(function(e){e.NecessaryCategoryRequired="necessary_category_required",e.CannotSetFromChild="cannot_set_from_child"})(nt||(nt={}));la={[nt.NecessaryCategoryRequired]:()=>"Cannot set \'necessary\' category to false. Strictly necessary functionality cannot be disabled.",[nt.CannotSetFromChild]:()=>"Cannot set consent state from embedded experience. Consent is managed by the parent application."};Io=class e extends z{get state(){return this._state}set state(t){let n=this._state;this._state=t,t!==null&&!e.isConsentStateEqual(n,t)&&this.emit(Jn.ConsentChanged,t)}get isActive(){return this._state!==null}constructor(){super(),this._state=null}static isConsentStateEqual(t,n){if(t===null&&n===null)return!0;if(t===null||n===null)return!1;let s=Object.keys(t),o=Object.keys(n);if(s.length!==o.length)return!1;let r=t,i=n;return s.every(a=>r[a]===i[a])}static getInstance(){return e.instance||(e.instance=new e),e.instance}};fa=[],ua=!1;rl(cl);il()});function ya(e){if(Po.has(e))return Po.get(e);let t=new Ro(e);return Po.set(e,t),t}function dl(e){return ya(e===void 0?"__SELF__":e.bridge.id)}function ba(e,t){dl().emit(st.OnEvent,e,t);let s=Se();s!==null&&po(s,st.OnEvent,{eventName:e,properties:t})}var st,Ro,Po,_a=ee(()=>{kt();We();(function(e){e.OnEvent="onAnalyticsEvent"})(st||(st={}));Ro=class extends z{constructor(t){super(),this.id=t}};Po=new Map;xt(e=>{if(!Object.values(st).includes(e.action))return;let t=ya(e.bridgeId);if(e.action===st.OnEvent){let{eventName:n,properties:s}=e.payload;t.emit(st.OnEvent,n,s);let o=Se();o!==null&&po(o,st.OnEvent,{eventName:n,properties:s})}})});async function Mo(e,t){return await(await fetch(`https://${e}/projects/${t.substring(0,2)}/${t}/settings.json`)).json()}var va=ee(()=>{});function ht(e){return ll(e)}function Sa(e){return e.split(/[-_]/)[0]}function fl(e){let t=[navigator.language,...navigator.languages];for(let n of t)if(e.includes(n))return n;for(let n of t){let s=Sa(n);for(let o of e)if(Sa(o)===s)return o}return e[0]}function pn(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e.all}async function gl(e,t){let{id:n,host:s}=e;if($t.has(n))return $t.get(n);let o=new Go(e,t);$t.set(n,o);try{if(await(await pl(s)).subscribeProject(n),!o.listings)throw new Error(`Unable to fetch project ${n} listings. Possibly wrong project id.`);return o.fields=await Mo(o.host,o.id),o}catch(r){throw Xn.has(n)&&Xn.get(n).unsubscribeProject(n),$t.delete(n),r}}async function pl(e){if(Xn.has(e))return Xn.get(e);let t=await ht(e);return t.on("message",ml),t}async function ml(e){let{id:t,klass:n,data:s}=e,o=$t.get(t);o&&n===Xe.Listings&&await hl(o,s[0])}async function hl(e,t){var n;let s=JSON.parse(t),o=s.project.app_settings_digest,r=(n=e.listings)===null||n===void 0?void 0:n.project.app_settings_digest;e.listings=s;try{r!==void 0&&o!==r&&(e.fields=await Mo(e.host,e.id))}catch{Ca.warn(`Unable to fetch project ${e.id} settings`)}}function Ut(e=sn()){return yl(e)}function Ta(e,t){return He(e,"updated",t)}async function Zn(e,t){let n=await fetch(`https://${e}/events/${t.substring(0,2)}/${t}/history.json`);if(!n.ok)throw new Error(`Failed to fetch event ${t} history`);return await n.json()}function Fo(e,t){if(Gt.has(e.id))return Gt.get(e.id);let n=new Uo(e,t);return n.on("internal_state",wl.bind(n)),Gt.set(e.id,n),n}async function bl(e){if(e.initState===it.Initialising)throw new Error("can\'t initialise event, event is already being initialised");if(e.initState===it.Initialised)throw new Error("can\'t initialise event, event is already initialised");if(e.initState=it.Initialising,e.canLoadHistory&&e.history===null){let t=await Zn(e.context.project.host,e.id);e.history=t}e.canSubscribe&&await _l(e),await Sl(e),e.initState=it.Initialised}async function _l(e){if(!e.canSubscribe)throw new Error("Event can\'t be subscribed");await(await ht(e.context.project.host)).subscribeEvent(e.id)}async function vl(e){(await ht(e.context.project.host)).unsubscribeEvent(e.id)}async function Sl(e){let{project:t}=e.context;if(wa.has(t.id))return;let n=await ht(t.host);if(n.enmasse!==null){let s=un(n.enmasse,El);wa.set(t.id,s)}}async function wl(e){e===ye.Finished&&await vl(this)}async function El(){for(let e of Array.from(Gt.values()))if(e.initState===it.Initialised){let t=await Zn(e.context.project.host,e.id);e.history=t}}function xa(e){return Cl(e)}function mn(e,t){return Tl(Ue(e),t)}function ka(e,t){return He(e,"updated",t)}async function Oa(e,t){if(ke.has(e.id))return ke.get(e.id);let n=new Bo(e,t);return await Ml(n),ke.set(n.id,n),n}function Aa(e){return Array.from(ke.values()).find(t=>t.pollId===e)}async function Ho(e){return xl(e)}async function Ol(e){return kl(e)}async function Al(e){let{klass:t}=e;switch(t){case Xe.Create:await Il(e);break;case Xe.Revoke:Nl(e);break;case Xe.Feedback:await Pl(e);break;case Xe.Reveal:Rl(e);break}}async function Il(e){let{id:t,data:n}=e,s=JSON.parse(n[0]),o=await mn(t);if(o!==null)if(ke.has(s.id)){let r=ke.get(s.id);(s.updated_at>r.updatedAt||s.duration!==r.duration)&&(r.update(s),o.emit("update",r))}else{let r=Object.assign(Object.assign({},o.context),{event:o}),i=await Oa(s,r);o.emit("publish",i)}}function Nl(e){let{data:t}=e,{id:n}=JSON.parse(t[0]);if(!ke.has(n))return;let s=ke.get(n);ke.delete(n),s.destroy(),s.context.event.emit("revoke",s)}async function Pl(e){let{data:t}=e,n=+t[0],s=t[3],o=Aa(n);if(!o)return;let r=s.split(":").map(d=>+d),i=Li(r),a=r.map((d,f)=>({percentage:i[f],votes:d}));o.results=a}function Rl(e){let{data:t}=e,n=+t[0],s=+t[1]-1,o=Aa(n);o&&o.correctOption!==s&&(o.correctOption=s,o.context.event.emit("update",o))}async function Ea(e){if(e.timeline.length===0)return;let t=await mn(e.config.id);if(t===null)return;let n=Object.assign(Object.assign({},t.context),{event:t});for(let s of e.timeline)ke.has(s.id)||await Oa(s,n)}async function Ml(e){let t=await Ot(`element_${e.id}_vote`);t!==null&&(e.userAnswer=jo.fromJSON(t))}function Ia(e){return Ll(e)}function Na(e,t){return Ho(e),He(e,"update",t)}var rt,Xe,Qe,Do,ll,gn,$o,Gf,ul,Go,Ca,$t,Xn,yl,ye,it,Uo,Gt,wa,Cl,Tl,qe,Uf,mt,jo,qo,ot,Bo,ke,xl,kl,Ff,Ll,Je,zo,Lo,jf,Pa=ee(()=>{We();Ao();Dn();va();zn();(function(e){e.Ok="ok",e.Error="error"})(rt||(rt={}));(function(e){e.Listings="listings",e.History="history",e.Create="create",e.Revoke="revoke",e.Stop="stop",e.Reveal="reveal",e.Poll="p",e.Feedback="fb",e.Eoc="eoc",e.Vote="v",e.SubsCounter="subscounter"})(Xe||(Xe={}));(function(e){e.Poll="p",e.Live="l"})(Qe||(Qe={}));Do=class extends z{constructor(t){super(),this.host=t,this._state=rt.Ok,this._enmasse=null}get state(){return this._state}set state(t){t!==this._state&&(this._state=t,this.emit("state",this._state))}get enmasse(){if(this._enmasse===null)throw new Error("Connect is not initialised, init() method should be called first.");return this._enmasse}set enmasse(t){this._enmasse=t}async init(){this.enmasse=await Wn(this.host),this.enmasse.on("message",this.handleMessage.bind(this)),this.enmasse.on("state",this.handleState.bind(this))}async connect(){await Yn(this.enmasse)}disconnect(){Qn(this.enmasse)}async subscribeProject(t){await Mt(this.enmasse,`${Qe.Live}-${t}`)}unsubscribeProject(t){Lt(this.enmasse,`${Qe.Live}-${t}`)}async subscribeEvent(t){await Promise.all([Mt(this.enmasse,`${Qe.Live}-${t}`),Mt(this.enmasse,`${Qe.Poll}-${t}`)])}unsubscribeEvent(t){Lt(this.enmasse,`${Qe.Live}-${t}`),Lt(this.enmasse,`${Qe.Poll}-${t}`)}sendVote(t,n,s){da(this.enmasse,`${Qe.Poll}-${t}`,Xe.Vote,[n,s,""])}handleMessage(t){let{klass:n,body:s,channel:o}=t,r=o.substring(o.indexOf("-")+1);this.emit("message",{id:r,klass:n,data:s})}handleState(t,...n){switch(t){case ae.Disconnected:this.state=rt.Error;break;case ae.Connecting:{let[s]=n;s>1&&(this.state=rt.Error);break}case ae.Connected:this.state=rt.Ok;break}}};ll=be(async e=>{let t=new Do(e);return await t.init(),await t.connect(),t},e=>e);(function(e){e.Ok="ok",e.Error="error"})(gn||(gn={}));$o=class extends z{constructor(t){super(),this.connect=t,this._state=gn.Ok,this.connect.on("state",this.handleState.bind(this))}get state(){return this._state}set state(t){this._state=t,this.emit("state",t)}handleState(){switch(this.connect.state){case rt.Error:this.state=gn.Error;break;case rt.Ok:default:this.state=gn.Ok;break}}};Gf=be(async e=>{let t=await ht(e.options.host);return new $o(t)},e=>e.options.host);ul=30;Go=class extends z{constructor(t,n){super(),this.eventsChecksum=null,this.id=t.id,this.host=t.host,this._context=n}get context(){return this._context}get embedUrl(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.embed}get uuid(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.uuid}get events(){var t;return((t=this._listings)===null||t===void 0?void 0:t.events)||[]}get listings(){return this._listings}set listings(t){let n=this._calculateCreatedEvents(t),s=this._calculateUpdatedEvents(t),o=this._calculateDeletedEvents(t);this._listings=Object.assign({},t),this._updateLocales(t),this._updateEventsChecksum(t),this._emitListingsEvents(n,s,o)}_calculateCreatedEvents(t){return this._listings?t.events.filter(({id:n})=>!this._listings.events.some(s=>n===s.id)):[]}_calculateUpdatedEvents(t){return this._listings?t.events.filter(n=>{let s=this._listings.events.find(({id:o})=>n.id===o);return s&&n.digest!==s.digest}):[]}_calculateDeletedEvents(t){return this._listings?this._listings.events.filter(({id:n})=>!t.events.some(s=>n===s.id)):[]}_updateLocales(t){this._locales=t.project.locales.map(n=>Object.assign({},n)).sort(n=>n.default?-1:0).map(n=>n.key),this._locale=fl(this._locales)}_updateEventsChecksum(t){this.eventsChecksum=Di(t.events.map(n=>n.digest).join(""))}_emitListingsEvents(t,n,s){let o=t.length>0,r=s.length>0,i=n.length>0,a=o||r||i;o&&this.emit("listings_events_created",t),r&&this.emit("listings_events_deleted",s),i&&this.emit("listings_events_updated",n),a&&this.emit("listings")}get isLocalisationSupported(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.is_localisation_supported}get locale(){return this._locale}set locale(t){if(!this.locales.includes(t))throw new Error(`Unknown locale name "${t}"`);this._locale=t}get locales(){return this._locales}get fields(){return this._fields!==void 0?pn(this._fields,this.locale):{}}set fields(t){let n=typeof this._fields<"u";this._fields=Object.assign({},t),n&&this.emit("updated")}get extensions(){var t;return(t=this._listings)===null||t===void 0?void 0:t.assets}get historyIgnore(){var t;let n=(t=this._listings)===null||t===void 0?void 0:t.project.history_ignore;return n&&n>0?n:ul}delete(){}};Ca=et("@monterosa/sdk-interact-kit");$t=new Map,Xn=new Map;yl=be(async e=>await gl({id:e.options.projectId,host:e.options.host},{sdk:e}),e=>e.options.projectId);(function(e){e.Upcoming="upcoming",e.Active="active",e.Prolonged="prolonged",e.Finished="finished"})(ye||(ye={}));(function(e){e.Uninitialised="uninitialised",e.Initialising="initialising",e.Initialised="initialised"})(it||(it={}));Uo=class extends z{constructor(t,n){super(),this._initState=it.Uninitialised,this._history=null,this._data=t,this._context=n,this._state=this.calculateState(),this._internalState=this.calculateInternalState(),this.boundHandleState=this.handleState.bind(this),this.boundHandleInternalState=this.handleInternalState.bind(this),this.boundHandleEventsUpdated=this.handleEventsUpdated.bind(this),this.unsubscribeStateHandler=Mn(this.boundHandleState),this.unsubscribeInternalStateHandler=Mn(this.boundHandleInternalState),this.unsubscribeListingsHandler=He(this.context.project,"listings_events_updated",this.boundHandleEventsUpdated)}calculateState(){return!this._data.started||Ke()<this.startAt?ye.Upcoming:Ke()<this.endAt?ye.Active:ye.Finished}calculateInternalState(){return!this._data.started||Ke()<this.startAt?ye.Upcoming:Ke()<this.endAt?ye.Active:Ke()<this.endAt+this._data.extra_time?ye.Prolonged:ye.Finished}handleState(){let t=this.calculateState();t===ye.Finished&&this.unsubscribeStateHandler(),t!==this._state&&(this._state=t,this.emit("state",t))}handleInternalState(){let t=this.calculateInternalState();t===ye.Finished&&this.unsubscribeInternalStateHandler(),t!==this._internalState&&(this._internalState=t,this.emit("internal_state",t))}handleEventsUpdated(t){let n=t.find(({id:s})=>s===this.id);n&&this._data.digest!==n.digest&&(this._data=n,this.handleState(),this.handleInternalState(),this.emit("updated"))}destroy(){this.unsubscribeStateHandler(),this.unsubscribeInternalStateHandler(),this.unsubscribeListingsHandler()}get context(){return this._context}get id(){return this._data.id}get name(){return this._data.name}get startAt(){return this._data.start_at}get startAtIso(){return this._data.start_at_iso}get endAt(){return this._data.end_at}get endAtIso(){return this._data.end_at_iso}get duration(){return this._data.duration}get fields(){let{locale:t}=this.context.project;return pn(this._data.custom_fields,t)}get state(){return this._state}get internalState(){return this._internalState}get initState(){return this._initState}set initState(t){this._initState=t}get history(){return this._history}set history(t){this._history=t,this.emit("history",t)}get canSubscribe(){return this._internalState===ye.Active||this._internalState===ye.Prolonged}get canLoadHistory(){return Ke()>=this.startAt+this.context.project.historyIgnore}};Gt=new Map,wa=new Map;Cl=be(async e=>{e===void 0&&(e=await Ut());let t=Object.assign(Object.assign({},e.context),{project:e});return e.events.map(n=>Fo(n,t)).sort((n,s)=>n.startAt-s.startAt)},e=>{var t,n;if(e!==void 0)return(t=e.eventsChecksum)!==null&&t!==void 0?t:e.id;let s=sn(),o=$t.get(s.options.projectId);return o?(n=o.eventsChecksum)!==null&&n!==void 0?n:o.id:s.options.projectId});Tl=be(async(e,t)=>{if(Gt.has(e))return Gt.get(e);t===void 0&&(t=await Ut());let n=Object.assign(Object.assign({},t.context),{project:t}),s=t.events.find(o=>o.id===e);if(s!==void 0){let o=Fo(s,n);if(o.canLoadHistory){let r=await Zn(t.host,e);o.history=r}return o}try{let o=await Zn(t.host,e),r=Fo(o.config,n);return r.history=o,r}catch{return null}},e=>e);(function(e){e.OptionIndexOutOfRange="out_of_range",e.BelowMinVoteOptions="below_min_vote_options",e.AboveMaxVoteOptions="above_max_vote_options",e.AboveMaxVotesPerUser="above_max_per_user",e.AboveMaxVotesPerOption="above_max_per_option",e.VotedOnNonInteractiveElement="non_interactive_element",e.VotedOnClosedElement="closed_element",e.EmptyVote="empty_vote"})(qe||(qe={}));Uf={[qe.OptionIndexOutOfRange]:(e,t)=>`Options index ${t} is out of range [0..${e}]`,[qe.BelowMinVoteOptions]:(e,t)=>`Below min (${e}) vote options: ${t}`,[qe.AboveMaxVoteOptions]:(e,t)=>`Above max (${e}) vote options: ${t}`,[qe.AboveMaxVotesPerUser]:(e,t)=>`Above max (${e}) votes per user: ${t}`,[qe.AboveMaxVotesPerOption]:(e,t)=>`Above max (${e}) votes per option: ${t}`,[qe.VotedOnNonInteractiveElement]:e=>`Non interact element ${e}`,[qe.VotedOnClosedElement]:e=>`Element ${e} is closed`,[qe.EmptyVote]:e=>`Empty value for options indices: ${e}`};(function(e){e.Opened="opened",e.Closed="closed"})(mt||(mt={}));jo=class e{constructor(t=[]){this._answers=new Map;for(let{option:n,value:s}of t)this._answers.set(n,s)}get answers(){return Array.from(this._answers.entries()).map(([t,n])=>({option:t,value:n}))}static fromIndices(t){return new e(t.map(n=>({option:n,value:1})))}set(t,n){return this._answers.set(t,n),this}remove(t){return this._answers.delete(t),this}toJSON(){return this.answers}static fromJSON(t){return new e(JSON.parse(t))}};(function(e){e.Data="data",e.Poll="poll",e.RegularPoll="rpoll",e.DiametricPoll="dpoll",e.EmotingPoll="emo",e.Powerbar="powerbar",e.Prediction="prediction",e.Trivia="trivia"})(qo||(qo={}));(function(e){e.OnVote="vote",e.OnClose="close",e.OnEventEnd="event_end",e.Manual="manual",e.Never="never",e.Always="always"})(ot||(ot={}));Bo=class extends z{constructor(t,n){var s,o;super(),this._results=null,this._userAnswer=null,this._correctOption=null,this._data=t,this._context=n,this._results=((s=t.data)===null||s===void 0?void 0:s.results)||null,this._correctOption=!((o=t.data)===null||o===void 0)&&o.correct_option?t.data.correct_option-1:null,this._state=this.calculateState(),this.unsubscribeStateHandler=Mn(()=>this.handleState())}calculateState(){return Ke()<this.publishedAt+this.duration?mt.Opened:mt.Closed}handleState(){let t=this.calculateState();t===mt.Closed&&this.unsubscribeStateHandler(),t!==this._state&&(this._state=t,this.emit("state",t))}update(t){this._data=t,this.handleState()}destroy(){this.unsubscribeStateHandler()}get context(){return this._context}get id(){return this._data.id}get eventId(){return this.context.event.id}get state(){return this._state}get type(){return this._data.type}get contentType(){return this._data.content_type}get publishedAt(){return this._data.published_at}get publishedAtIso(){return this._data.published_at_iso}get updatedAt(){return this._data.updated_at}get updatedAtIso(){return this._data.updated_at_iso}get duration(){return this._data.duration}get fields(){let{locale:t}=this.context.project;return pn(this._data.custom_fields,t)}get interactive(){return this.type!==qo.Data}get pollId(){return this._data.data.id||null}get question(){let{locale:t}=this.context.project;return this._data.data.question===void 0?null:pn(this._data.data.question,t)}get answerOptions(){let{locale:t}=this.context.project;return this._data.data.options===void 0?null:pn(this._data.data.options,t)}get minOptionsPerVote(){return this._data.data.min_options_per_vote||1}get maxOptionsPerVote(){return this._data.data.max_options_per_vote||1}get maxVotesPerOption(){return this._data.data.max_votes_per_option||1}get maxVotesPerUser(){return this._data.data.max_votes_per_user||null}get userAnswer(){return this._userAnswer}set userAnswer(t){this._userAnswer=t}get hasBeenAnswered(){return this._userAnswer!==null}get showResultsMode(){return this._data.data.reveal_results_mode||null}get canShowResults(){switch(this.showResultsMode){case ot.OnVote:return this.hasBeenAnswered||this.state===mt.Closed;case ot.OnClose:return this.state===mt.Closed;case ot.Manual:return this._results!==null;case ot.OnEventEnd:return this.context.event.state===ye.Finished;case ot.Never:return!1;case ot.Always:default:return!0}}get results(){return this.canShowResults?this._results:null}set results(t){JSON.stringify(t)!==JSON.stringify(this.results)&&(this._results=t,this.canShowResults&&this.emit("results"))}get correctOption(){return this._correctOption}set correctOption(t){this._correctOption=t}get isCorrectOptionRevealed(){return this._correctOption!==null}};ke=new Map;xl=be(async e=>{e.on("history",Ea),e.history!==null&&Ea(e.history),await Ol(e.context.sdk.options.host),await bl(e)},e=>e.id);kl=be(async e=>{(await ht(e)).on("message",Al)},e=>e);Ff=be(async(e,t)=>(await Ho(e),Array.from(ke.values()).find(s=>s.id===t)||null),(e,t)=>t),Ll=be(async e=>(await Ho(e),Array.from(ke.values()).filter(t=>t.eventId===e.id).sort((t,n)=>t.publishedAt-n.publishedAt)),e=>e.id,{clearOnResolve:!0});(function(e){e.Opened="opened",e.Closed="closed"})(Je||(Je={}));zo=class extends z{constructor(t,n){super(),this.host=t,this.id=n,this.state=Je.Closed,this.lastCount=0,this.connect=null,this.boundHandleMessage=this.handleMessage.bind(this),this.boundHandleTimeout=this.handleTimeout.bind(this)}async init(){this.connect=await ht(this.host),this.connect.on("message",this.boundHandleMessage)}get isOpened(){return this.state===Je.Opened}handleMessage(t){let{id:n,klass:s,data:o}=t;if(!(n!==this.id||s!==Xe.SubsCounter))try{let r=JSON.parse(o[0]);this.handleCounterUpdate(r.counter),this.resetTimeout(r.next_update_at)}catch{Ca.warn("Couldn\'t parse subscounter message.")}}handleCounterUpdate(t){if(t<0)return;let n=!1,s=!1;this.lastCount!==t&&(n=!0,this.lastCount=t),this.state===Je.Closed&&(s=!0,this.state=Je.Opened),n&&this.emit("updated",this.lastCount),s&&this.emit("state",Je.Opened)}handleTimeout(){this.state=Je.Closed,this.emit("state",Je.Closed)}resetTimeout(t){clearTimeout(this.closeTimeout),this.closeTimeout=setTimeout(this.boundHandleTimeout,(t-Ke()+3)*1e3)}destroy(){this.connect!==null&&this.connect.off("message",this.boundHandleMessage)}};Lo=new Map,jf=be(async(e,t)=>{if(Lo.has(t))return Lo.get(t);let n=new zo(e,t);return await n.init(),Lo.set(t,n),n},(e,t)=>t)});function Ra(e=15e3){let t=new Map,n,s=!1;return{announce:()=>{for(let r of[...t.keys()])r()},subscribe(r,i){return t.set(r,i),()=>{t.delete(r)}},start(r){s||n!==void 0||(n=setInterval(()=>{for(let[i,a]of[...t])(!r||a?.())&&i()},e))},stop(){s=!0,clearInterval(n),t.clear()}}}var Ma=ee(()=>{"use strict"});function Dl(e){let t;try{t=new URL(e??"").searchParams}catch{return"none"}return t.get("micBridgeId")===null?"none":parseInt(t.get("micBridgeVersion")??"",10)>=2?"v2":"legacy"}function Gl(e){let{kit:t,local:n,timeout:s=()=>{}}=e;if(e.bridge==="none")return t;let o=e.answerMs??1500,r,i=()=>{r=!1,s(1)};e.bridge==="legacy"?i():s(o+500);let a=d=>{if(r===!1)return d(n);if(r)return d(t);let f=d(t).finally(()=>{r===void 0&&(r=!0,s($l))});return new Promise((c,u)=>{let y=setTimeout(()=>{i(),f.catch(()=>{}),d(n).then(c,u)},o);f.then(c,u).finally(()=>clearTimeout(y))})};return{read:d=>a(f=>f.read(d)),write:(d,f)=>a(c=>c.write(d,f)),remove:d=>a(f=>f.remove(d))}}var $l,Ul,La,Da=ee(()=>{"use strict";kt();zn();$l=2e4;La=()=>Ul??=Gl({bridge:Dl(globalThis.location?.href),kit:{read:Ot,write:At,remove:Bn},local:{read:async e=>Pe.getItem(e),write:async(e,t)=>Pe.setItem(e,t),remove:async e=>Pe.removeItem(e)},timeout:zi})});var Ga={};Wo(Ga,{createMonterosaPlatform:()=>jl});function Vo(){let t={...pa()};return{declared:Object.keys(t).length>0,categories:t}}async function $a(e,t){return t?await mn(t,e):(await xa(e)).find(s=>s.state==="active")}function Fl(e,t){return Ui({host:e,projectId:t},`gamestage:${e}:${t}`)}async function jl(e){let t=Kt(),n={},s=[],o=Ra(e.pollMilliseconds),r=o.announce;s.push(o.stop);let i=new Set,a,d={enabled:!1},f=Gs(e.host),c=Fl(f,e.projectId),u=La(),y=async()=>{try{let v=await Ut(c);b(v);let h=at(v?.fields),N=hs(v?.fields,v?.extensions);N&&(h.forms=N),d=zt(v?.fields);let L=await $a(v,e.eventId);if(a=L?.id??a,L){let C=at(L.fields),H={...h.labels,...C.labels},te={...h.options,...C.options};Object.assign(h,C),Object.keys(H).length>0&&(h.labels=H),Object.keys(te).length>0&&(h.options=te)}for(let C of Object.keys(n))delete n[C];Object.assign(n,h);for(let C of[...i])C(n);g="studio",l=h,S?.write(e.projectId,h)}catch{}},b=v=>{if(!(!e.locale||!v||typeof v!="object"))try{v.locale=e.locale}catch{}},x=v=>{for(let h of Object.keys(n))delete n[h];Object.assign(n,v);for(let h of[...i])h(n)},g="none",l,S=e.rememberSettings===!1?void 0:oi({store:u,consent:e.settingsConsent??Vo}),p=S?await S.read(e.projectId):null;p&&(Object.assign(n,p),g="device");let T,w=new Promise(v=>T=v),_=(async()=>{let v=!1;try{let h=await Wn(f);T(h),s.push(un(h,N=>t.sample(N*1e3))),s.push(()=>Qn(h)),await Promise.race([Yn(h),new Promise((N,L)=>setTimeout(()=>L(new Error("mesh connect timed out")),e.connectTimeoutMs??8e3))]),v=!0}catch{T(null)}try{let h=await Promise.race([Ut(c),new Promise((H,te)=>setTimeout(()=>te(new Error("studio settings read timed out")),e.connectTimeoutMs??8e3))]);b(h);let N=at(h?.fields),L=hs(h?.fields,h?.extensions);L&&(N.forms=L),d=zt(h?.fields);let C=await $a(h,e.eventId);if(a=C?.id,C){let H=at(C.fields),te={...N.labels,...H.labels},ce={...N.options,...H.options};Object.assign(N,H),Object.keys(te).length>0&&(N.labels=te),Object.keys(ce).length>0&&(N.options=ce)}return x(N),g="studio",l=N,S?.write(e.projectId,N),C&&v&&(s.push(Na(C,r)),s.push(ka(C,()=>{y()}))),h&&v&&s.push(Ta(h,()=>{y()})),v&&!!C}catch{return!1}})();p?_.then(o.start):o.start(await _);let k=new Set;return s.push(No(()=>{let v=Vo();for(let h of[...k])h(v)})),{kind:"monterosa",projectId:c.options.projectId,get eventId(){return a},async elementFields(v){let h=await Ut(c),N=await mn(v,h);return N?(await Ia(N)).map(C=>({id:C.id,contentType:String(C.contentType),fields:C.fields??{}})):[]},clock:t,presentation:n,get signInSettings(){return d},settingsSource:()=>g,rememberSettings(){l&&S?.write(e.projectId,l)},consent:Vo,onConsentChanged(v){return k.add(v),()=>k.delete(v)},onPresentationChanged(v){return i.add(v),()=>i.delete(v)},declareConsent(v){try{return ga(v),!0}catch{return!1}},onRoundAnnounced:o.subscribe,subscribeLive(v,h){let N=!1,L=!1,C=null,H=!1,te=[];h.status({state:"connecting"});let ce=async $=>{L=!1;try{await Mt($,v)}catch{return}N||(L=!0,h.synced(),h.status({state:"live"}))};return w.then($=>{if(!N){if(!$)return h.status({state:"unavailable"});C=$,te.push(ca($,ge=>{if(ge.channel!==v)return;let _e;try{_e=JSON.parse(ge.body[0]??"")}catch{return}h.message(String(ge.klass),_e,!L)}),ia($,(ge,_e)=>h.status({state:typeof navigator<"u"&&navigator.onLine===!1?"offline":ge>1?"reconnecting":"connecting",attempt:ge,retryAt:Date.now()+_e*1e3})),aa($,()=>{L=!1,H=!0,h.status({state:"reconnecting"})}),un($,()=>{H&&(H=!1,ce($))})),ce($)}}),()=>{if(N=!0,te.forEach($=>$()),C)try{Lt(C,v)}catch{}}},emit(v){ba(v.name,{...On(v.properties),at:v.at})},storage:u,stop(){for(let v of s.splice(0))v();k.clear()}}}var Ua=ee(()=>{"use strict";Dn();Ao();ha();_a();Pa();Vt();Us();St();ws();Wt();$s();Ma();Da()});var Yo="gs-gate-style",Ka=`\n.gs-gate{position:fixed;inset:0;z-index:2147483100;display:grid;place-items:center;padding:16px;background:rgba(10,10,14,.72);box-sizing:border-box}\n.gs-gate__card{width:100%;max-width:24rem;box-sizing:border-box;display:grid;gap:14px;padding:22px 20px;border-radius:20px;background:var(--gs-gate-surface,#fff);color:var(--gs-gate-ink,#1b1c1f);font-family:inherit;font-size:17px;line-height:1.45;box-shadow:0 10px 30px rgba(0,0,0,.25)}\n.gs-gate__title{margin:0;font-size:22px;line-height:1.25}\n.gs-gate__note{margin:0;font-weight:600}\n.gs-gate__choice{display:flex;gap:12px;align-items:flex-start;cursor:pointer}\n.gs-gate__choice input{width:22px;height:22px;margin:2px 0 0;flex:none;accent-color:var(--gs-gate-accent,#1b1c1f)}\n.gs-gate__continue{min-height:48px;padding:12px 20px;border:0;border-radius:12px;background:var(--gs-gate-accent,#1b1c1f);color:var(--gs-gate-on-accent,#fff);font:inherit;font-weight:650;cursor:pointer}\n.gs-gate__continue:disabled{opacity:.45;cursor:default}\n.gs-gate [hidden]{display:none!important}\n.gs-gate__not-me{justify-self:center;min-height:44px;padding:8px 12px;border:0;background:none;color:inherit;font:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer}\n.gs-gate__sorry{margin:0;font-size:19px;font-weight:600}\n.gs-gate :is(input,button):focus-visible{outline:3px solid var(--gs-gate-accent,#1b1c1f);outline-offset:3px}\n`;function ts(e){let t=e.GAMESTAGE_GATE;if(!t||typeof t!="object")return;let n=t,s=typeof n.minimumAge=="number"&&n.minimumAge>0?n.minimumAge:void 0,o=Array.isArray(n.territories)?n.territories.filter(r=>typeof r=="string"&&/^[A-Z]{2}$/.test(r)):[];if(!(!s&&!o.length))return{...s?{minimumAge:s}:{},...o.length?{territories:o}:{},...typeof n.note=="string"&&n.note.trim()?{note:n.note.trim()}:{}}}function ns(e,t="en-GB"){let n;try{n=new Intl.DisplayNames([t],{type:"region"})}catch{}let s=new Set(["GB","US","AE","NL","PH","CZ","DO","BS","GM","MV"]),o=e.map(r=>`${s.has(r)?"the ":""}${n?.of(r)??r}`);return o.length<=1?o.join(""):`${o.slice(0,-1).join(", ")} or ${o[o.length-1]}`}var ss=e=>`gamestage:gate:${e}`,jt=e=>JSON.stringify([e.minimumAge??null,e.territories??[]]);function Qo(e,t,n){try{let s=n?.getItem(ss(e));if(!s)return;let o=JSON.parse(s);return o.gate!==jt(t)?void 0:o.qualified===!1?"not_qualified":"qualified"}catch{return}}function Jo(e,t,n){return Qo(e,t,n)==="qualified"}function os(e,t=Wa()){try{t?.removeItem(ss(e))}catch{}}function Wa(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Ya(e,t){let n=e.minimumAge?` aged ${e.minimumAge} and over`:"",s=e.territories?.length?` in ${ns(e.territories,t)}`:"";return`Sorry, this game is for people${n}${s}.`}function bn(e,t,n={}){let s=n.document??(typeof document>"u"?void 0:document),o=n.storage??(typeof localStorage>"u"?void 0:localStorage);if(!e||!s||Jo(t,e,o))return Promise.resolve();let r=k=>{try{o?.setItem(ss(t),JSON.stringify({gate:jt(e),qualified:k,at:i().toISOString()}))}catch{}},i=n.now??(()=>new Date);if(!s.getElementById?.(Yo)){let k=s.createElement("style");k.id=Yo,k.textContent=Ka,s.head?.append(k)}let a=(k,v)=>{let h=s.createElement(k);return v&&(h.textContent=v),h},d=a("div");d.className="gs-gate",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby","gs-gate-title");let f=a("form");f.className="gs-gate__card";let c=a("h2","Before you play");if(c.id="gs-gate-title",c.className="gs-gate__title",f.append(c),e.note){let k=a("p",e.note);k.className="gs-gate__note",f.append(k)}let u=[],y=(k,v)=>{let h=a("label");h.className="gs-gate__choice";let N=a("input");N.type="checkbox",N.setAttribute("data-gs-declare",k),h.append(N,a("span",v)),u.push(N),f.append(h)};e.territories?.length&&y("territory",`I\'m in ${ns(e.territories,n.locale)}.`),e.minimumAge&&y("age",`I\'m ${e.minimumAge} or over.`);let b=a("button","Continue");b.type="submit",b.className="gs-gate__continue",b.setAttribute("data-gs-gate-continue",""),b.disabled=!0,f.append(b);let x=a("button","I don\'t meet these");x.type="button",x.className="gs-gate__not-me",x.setAttribute("data-gs-gate-not-me",""),f.append(x);let g=a("div");g.className="gs-gate__card gs-gate__exit";let l=a("p",Ya(e,n.locale));l.className="gs-gate__sorry";let S=a("button","Go back");S.type="button",S.className="gs-gate__not-me",S.setAttribute("data-gs-gate-back",""),g.append(l,S);let p=k=>{f.hidden=k,g.hidden=!k};x.onclick=()=>{r(!1),p(!0)},S.onclick=()=>{p(!1),u[0]?.focus?.()},p(Qo(t,e,o)==="not_qualified"),d.append(f,g);let T=()=>Array.from(d.querySelectorAll?.("input, button")??[]).filter(k=>!k.disabled&&!k.closest?.("[hidden]"));d.onkeydown=k=>{if(k.key!=="Tab")return;let v=T();if(!v.length)return;let h=v[0],N=v[v.length-1],L=s.activeElement;k.shiftKey&&(L===h||!d.contains?.(L))?(k.preventDefault(),N.focus()):!k.shiftKey&&(L===N||!d.contains?.(L))&&(k.preventDefault(),h.focus())};let w=k=>{d.isConnected&&!d.contains?.(k.target)&&T()[0]?.focus()};s.addEventListener?.("focusin",w);let _=()=>s.removeEventListener?.("focusin",w);for(let k of u)k.onchange=()=>{b.disabled=!u.every(v=>v.checked)};return new Promise(k=>{f.onsubmit=v=>{v.preventDefault?.(),u.every(h=>h.checked)&&(r(!0),_(),d.remove?.(),k())},(s.body??s.documentElement)?.append(d),u[0]?.focus?.()})}var W={notify:"/play/v1/games/{game}/notify",notifyConfirm:"/play/v1/games/{game}/notify/confirm",notifyResend:"/play/v1/games/{game}/notify/resend",runtime:"/play/v1/games/{game}/runtime",currentRound:"/play/v1/games/{game}/rounds/current",rounds:"/play/v1/games/{game}/rounds",roundsMine:"/play/v1/games/{game}/rounds/mine",nextRound:"/play/v1/games/{game}/rounds/next",round:"/play/v1/games/{game}/rounds/{round}",plays:"/play/v1/games/{game}/rounds/{round}/plays",session:"/play/v1/games/{game}/session",restoreSession:"/play/v1/games/{game}/session/restore",guestToken:"/play/v1/games/{game}/guest-token",gameToken:"/play/v1/games/{game}/game-token",commentsToken:"/play/v1/games/{game}/comments-token",commentsKeys:"/play/v1/comments-keys",roundState:"/play/v1/games/{game}/rounds/{round}/players/me",profile:"/play/v1/games/{game}/players/me/profile",identityOptions:"/play/v1/games/{game}/identity",identity:"/play/v1/games/{game}/players/me/identity",nameTicket:"/play/v1/games/{game}/name-ticket",recoveryCode:"/play/v1/games/{game}/players/me/recovery-code",declaration:"/play/v1/games/{game}/players/me/declaration",roundStats:"/play/v1/games/{game}/rounds/{round}/stats",leaderboard:"/play/v1/games/{game}/leaderboard",editionLeaderboard:"/play/v1/games/{game}/leaderboard/edition"};var Be={rooms:"/play/v1/games/{game}/rooms",roomJoin:"/play/v1/games/{game}/rooms/join",room:"/play/v1/games/{game}/rooms/{room}",roomStart:"/play/v1/games/{game}/rooms/{room}/start",roomLeave:"/play/v1/games/{game}/rooms/{room}/leave",roomPresence:"/play/v1/games/{game}/rooms/{room}/presence",roomPlay:"/play/v1/games/{game}/rooms/{room}/play",roomBoard:"/play/v1/games/{game}/rooms/{room}/board"};var Xo="penalty_v1";var Qa="balanced_v1",Zo={aimX:{min:-1200,max:1200},aimY:{min:-200,max:1200},power:{min:0,max:1e3}},er={postX:1e3,barY:1e3,postWidth:60,barHeight:60,ballRadius:40,keeperStart:{x:0,y:420}},Ja="shoot";function bt(e){return{op:Ja,model:Xo,shotIndex:e.shotIndex,aimX:e.aimX,aimY:e.aimY,power:e.power}}function _n(e){let t=e?.progress;if(!t||t.kind!=="shoot")return;let n=Array.isArray(t.shots)?t.shots:[];return{kind:"shoot",model:t.model??Xo,profile:t.profile??Qa,goals:typeof t.goals=="number"?t.goals:0,shots:n}}function vn(e){return e?.shots.at(-1)}function Xa(e){return{...e.picks?{picks:e.picks}:{},...e.answers?{answers:e.answers}:{},...e.op?{op:e.op}:{},...e.centre!==void 0?{centre:e.centre}:{},...e.board!==void 0?{board:e.board}:{},...e.operation??{}}}var Sn=e=>`gamestage-session:${e}`;function rs(e,t=typeof localStorage>"u"?void 0:localStorage){return t?.getItem(Sn(e))??void 0}var F=(e,t,n,s)=>e.replace("{game}",encodeURIComponent(t)).replace("{round}",encodeURIComponent(n??"")).replace("{room}",encodeURIComponent(s??""));function is(){let e=new Uint8Array(12);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}var _t=class extends Error{status;code;retryable;detail;constructor(t,n,s,o,r={}){super(s),this.status=t,this.code=n,this.retryable=o,this.detail=r,this.name="PlayerApiError"}},Za=6e4;function ec(e){let t=e.split(".")[1];if(t)try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),s=n+"=".repeat((4-n.length%4)%4),o=JSON.parse(atob(s));return typeof o.exp=="number"&&Number.isFinite(o.exp)?o.exp*1e3:void 0}catch{return}}function tr(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=e.baseUrl.replace(/\\/+$/,""),s=e.storage??(typeof localStorage>"u"?void 0:localStorage),o=e.session??s?.getItem(Sn(e.game))??void 0,r;async function i(){return o||(r??=(async()=>{let p=await t(`${n}${F(W.session,e.game)}`,{method:"POST"});if(!p.ok)return;let T=await p.json();if(T.token)return o=T.token,s?.setItem(Sn(e.game),o),o})().finally(()=>{r=void 0}),r)}let a=e.now??Date.now,d,f;async function c(p=!1){return p&&(d=void 0),d&&a()<d.renewAt?d.token:(d=void 0,f??=(async()=>{let T=await l(F(W.guestToken,e.game),{method:"POST"});if(!T.token)throw new _t(200,"unknown","The Engine did not issue a guest token.",!1);let w=ec(T.token);return d=w===void 0?void 0:{token:T.token,renewAt:w-Za},T.token})().finally(()=>{f=void 0}),f)}async function u(){let p=await l(F(W.commentsToken,e.game),{method:"POST"});if(!p.token)throw new _t(200,"unknown","The Engine did not issue a comments token.",!1);return p.token}let y,b;async function x(){return y&&a()<y.renewAt?y.token:(b??=(async()=>{let p=await c(),T=await t(e.spaceAuthUrl??`${n}/api/auth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"jwt_bearer",assertion:p}).toString()}),w=await T.json().catch(()=>({}));if(!T.ok||!w.access_token)throw T.status<500&&(d=void 0),new _t(T.status,"space_sign_in_refused",w.message??"The Space did not accept the guest token.",T.status>=500);let _=(w.expires_in??3600)*1e3;return y={token:w.access_token,renewAt:a()+Math.max(_-6e4,0)},w.access_token})().finally(()=>{b=void 0}),b)}let g=()=>typeof e.identity=="function"?e.identity():e.identity;async function l(p,T,w=!0){let _=await i(),k=await g(),v=await t(`${n}${p}`,{...T,headers:{"content-type":"application/json",..._?{"x-gamestage-player":_}:{},...k?{authorization:`Bearer ${k}`}:{},...T?.headers??{}}}),h=await v.json().catch(()=>({}));if(!v.ok){let N=h.error;if(w&&v.status===401&&N?.code==="session_required")return o===_&&(o=void 0),l(p,T,!1);throw new _t(v.status,N?.code??"unknown",N?.message??v.statusText,N?.retryable??!1,N??{})}return h}return{guestToken:c,commentsToken:u,spaceToken:x,subscribeNotify:p=>l(F(W.notify,e.game),{method:"POST",body:JSON.stringify(p)}),confirmNotify:p=>l(F(W.notifyConfirm,e.game),{method:"POST",body:JSON.stringify(p)}),resendNotify:p=>l(F(W.notifyResend,e.game),{method:"POST",body:JSON.stringify(p)}),getRuntime:()=>l(F(W.runtime,e.game)),getCurrentRound:()=>l(F(W.currentRound,e.game)),getRound:p=>l(F(W.round,e.game,p)),getNextRound:()=>l(F(W.nextRound,e.game)),getRounds:()=>l(F(W.rounds,e.game)),getPlayedRounds:()=>l(F(W.roundsMine,e.game)),getRoundState:p=>l(F(W.roundState,e.game,p)),getRoundStats:p=>l(F(W.roundStats,e.game,p)),getProfile:()=>l(F(W.profile,e.game)),getIdentityOptions:()=>l(F(W.identityOptions,e.game)),createRoom:p=>l(F(Be.rooms,e.game),{method:"POST",body:JSON.stringify({name:p})}),joinRoom:(p,T)=>l(F(Be.roomJoin,e.game),{method:"POST",body:JSON.stringify({code:p,name:T})}),getRoom:p=>l(F(Be.room,e.game,void 0,p)),startRoom:p=>l(F(Be.roomStart,e.game,void 0,p),{method:"POST"}),leaveRoom:p=>l(F(Be.roomLeave,e.game,void 0,p),{method:"POST"}),roomPresence:p=>l(F(Be.roomPresence,e.game,void 0,p),{method:"POST"}),getRoomPlay:p=>l(F(Be.roomPlay,e.game,void 0,p)),getRoomBoard:p=>l(F(Be.roomBoard,e.game,void 0,p)),setIdentity:p=>l(F(W.identity,e.game),{method:"POST",body:JSON.stringify(p)}),getNameTicket:()=>l(F(W.nameTicket,e.game),{method:"POST"}),declare:p=>l(F(W.declaration,e.game),{method:"POST",body:JSON.stringify({gate:p,qualified:!0})}),getLeaderboard:()=>l(F(W.leaderboard,e.game)),getEditionLeaderboard:()=>l(F(W.editionLeaderboard,e.game)),getRecoveryStatus:()=>l(F(W.recoveryCode,e.game)),issueRecoveryCode:()=>l(F(W.recoveryCode,e.game),{method:"POST"}),restoreFromRecoveryCode:async p=>{let T=await l(F(W.restoreSession,e.game),{method:"POST",body:JSON.stringify({code:p})});return o=T.token,r=void 0,s?.setItem(Sn(e.game),o),T},play:S,shoot:(p,T,w)=>S(p,{operation:bt(T),roundVersion:T.roundVersion,challengeInstanceId:T.challengeInstanceId},w)};function S(p,T,w){return l(F(W.plays,e.game,p),{method:"POST",body:JSON.stringify({idempotency_key:w,round_version:T.roundVersion,challenge_instance_id:T.challengeInstanceId??null,payload:Xa(T),...T.room?{room:T.room}:{}})})}}var vt=class extends Error{constructor(n,s,o){super(s);this.status=n;this.code=s;this.retryAfterSeconds=o;this.name="ArcadeError"}status;code;retryAfterSeconds;get retryable(){return this.code==="rate_limited"||this.code==="engine_busy"||this.status===0}get needsSignIn(){return this.code==="sign_in_required"}get runDidNotCount(){return/^(score_|duration_|run_)/.test(this.code)}},tc="/game-token";function as(e){let t=e.api.replace(/\\/$/,"")+(e.basePath??"/api/arcade"),n=e.fetch??fetch,s=e.newKey??(()=>crypto.randomUUID()),o=encodeURIComponent(e.game);async function r(){let a=await e.gameToken?.().catch(()=>{});return a?{token:a,prefix:tc}:{token:await e.token(),prefix:""}}async function i(a,d,f,c={}){let u=async()=>{let y;try{let{token:x,prefix:g}=await r();y=await n(t+g+d,{method:a,headers:{authorization:`Bearer ${x}`,...f===void 0?{}:{"content-type":"application/json"},...c},...f===void 0?{}:{body:JSON.stringify(f)}})}catch{throw new vt(0,"network_error")}let b=await y.json().catch(()=>({}));if(!y.ok)throw new vt(y.status,b.message??"unknown",b.retryAfterSeconds);return b.data};try{return await u()}catch(y){if(y instanceof vt&&y.status===0)return u();throw y}}return{start:a=>i("POST",`/games/${o}/runs`,{build:a.build},{"idempotency-key":s()}),finish:(a,d)=>i("POST",`/runs/${encodeURIComponent(a)}/result`,{score:d.score,playedMs:d.playedMs,metrics:d.metrics??{}}),board:(a="all-time",d={})=>{let f=new URLSearchParams;d.limit!==void 0&&f.set("limit",String(d.limit)),d.offset!==void 0&&f.set("offset",String(d.offset));let c=f.toString();return i("GET",`/boards/${o}/${encodeURIComponent(a)}${c?`?${c}`:""}`)},me:()=>i("GET",`/games/${o}/me`),setName:a=>i("PUT",`/games/${o}/me/name`,{ticket:a})}}var nc=e=>`edition-${e}`;function sc(e){if(!(typeof e!="string"||e.length===0||e.length>2048))try{let t=new URL(e.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.href.length<=2048?t.href:void 0}catch{return}}function oc(e){let n=(e??"").trim().toLowerCase().replace(/[^a-z0-9_.]/g,"").replace(/\\.{2,}/g,"."),s=/[a-z]/.test(n),r=(s?n:`fan${n?`_${n}`:""}`).slice(0,30);return(r.length>=3?r:s?r.padEnd(3,"0"):r.padEnd(3,"a"))||"fan"}function cs(e){let t=e.fetch??((...a)=>fetch(...a)),n,s,o=async(a=!1)=>{try{let d=await e.fanToken(a),f=await t(`${e.api}/api/auth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"jwt_bearer",assertion:d}).toString()}),c=await f.json().catch(()=>({}));return!f.ok||!c.access_token?!a&&f.status<500?o(!0):null:(n=c.access_token,c.access_token)}catch{return null}},r=async()=>n||(s??=o().finally(()=>{s=void 0}),s);async function i(a,d,f=!1,c=!0){let u=c?await r():void 0;if(c&&!u)return null;try{let y=await t(`${e.api}${a}`,{...d,headers:{...d?.body!==void 0?{"content-type":"application/json"}:{},...u?{authorization:`Bearer ${u}`}:{},...d?.headers??{}}});return c&&y.status===401&&!f?(n=void 0,s=void 0,i(a,d,!0)):y.ok?await y.json().catch(()=>null):null}catch{return null}}return{suggestName:oc,async list(){return((await i(`/api/v1/comments/topics/${encodeURIComponent(e.topicId)}/messages?sort=oldest&top_level=true`,void 0,!1,!1))?.data??[]).sort((f,c)=>f.received_at-c.received_at)},async canPost(){return await r()!==null},async post(a,d){let f=sc(d?.avatarUrl),u=(await i(`/api/v1/comments/topics/${encodeURIComponent(e.topicId)}`,{method:"POST",body:JSON.stringify(f?{text:a,user_avatar_url:f}:{text:a})}))?.data?.message_id;return u?{message_id:u}:null},async me(){let d=(await i(`/api/v1/comments/me?topic_id=${encodeURIComponent(e.topicId)}`,void 0))?.data;return d&&typeof d.user_id=="string"?d:null},async setName(a){let f=(await i("/api/v1/comments/me/display-name",{method:"PUT",body:JSON.stringify({display_name:a})}))?.data;return f?.allowed!==!1&&f?.display_name?{display_name:f.display_name}:null}}}St();var wt=class extends Error{constructor(n,s,o){super(s);this.status=n;this.code=s;this.retryAfterSeconds=o;this.name="QuizError"}status;code;retryAfterSeconds;get retryable(){return hc.has(this.code)||this.status===0}get needsSignIn(){return this.code==="sign_in_required"}get questionClosed(){return this.code==="question_closed"}get needsNickname(){return this.code==="nickname_required"||this.code==="nickname_refused"||this.code==="nickname_taken"}},hc=new Set(["rate_limited","engine_busy","nickname_check_unavailable","question_not_open"]),Pr=5,yc="/game-token",bc=30;function _s(e){let t=e.api.replace(/\\/$/,"")+(e.basePath??"/api/quiz"),n=e.fetch??fetch,s=e.sleep??(c=>new Promise(u=>setTimeout(u,c))),o=e.retries??3,r=encodeURIComponent(e.game),i=c=>encodeURIComponent(c);async function a(){let c=await e.gameToken?.().catch(()=>{});return c?{token:c,prefix:yc}:{token:await e.token(),prefix:""}}async function d(c,u,y){let b=async()=>{let g;try{let{token:S,prefix:p}=await a();g=await n(t+p+u,{method:c,headers:{authorization:`Bearer ${S}`,...y===void 0?{}:{"content-type":"application/json"}},...y===void 0?{}:{body:JSON.stringify(y)}})}catch{throw new wt(0,"network_error")}let l=await g.json().catch(()=>({}));if(!g.ok){let S=l.message&&/^[a-z_]+$/.test(l.message)?l.message:g.status===429?"rate_limited":"unknown";throw new wt(g.status,S,l.retryAfterSeconds)}return l.data},x=0;for(let g=0;;g++)try{return await b()}catch(l){if(!(l instanceof wt)||!l.retryable||g>=o)throw l;let S=l.status===0?0:Math.min(l.retryAfterSeconds??1,bc);if(l.code==="question_not_open"){if(x>=Pr)throw l;S=Math.min(S,Pr-x),x+=S}await s(S*1e3)}}let f=(c={})=>{let u=new URLSearchParams;c.limit!==void 0&&u.set("limit",String(c.limit)),c.cursor!==void 0&&u.set("cursor",c.cursor);let y=u.toString();return y?`?${y}`:""};return{nickname:c=>d("POST",`/games/${r}/nickname`,{nickname:c}),me:()=>d("GET",`/games/${r}/me`),get:c=>d("GET",`/quizzes/${i(c)}`),questions:async c=>e.words?e.words(c):[],outcomes:async c=>e.outcomeWords?e.outcomeWords(c):[],outcomeShares:async c=>{try{let u=await d("GET",`/quizzes/${i(c)}/outcomes`),y=Array.isArray(u?.outcomes)?u.outcomes:[],b=typeof u?.total=="number"?u.total:0;return b<=0?[]:y.flatMap(x=>typeof x?.outcomeId=="string"&&typeof x?.count=="number"?[{outcomeId:x.outcomeId,share:Math.min(1,Math.max(0,x.count/b))}]:[])}catch{return[]}},start:c=>d("POST",`/quizzes/${i(c)}/plays`,{}),answer:(c,u)=>d("POST",`/quizzes/${i(c)}/answers`,{answers:u.map(y=>({question:y.question,option:y.option}))}),result:c=>d("GET",`/quizzes/${i(c)}/result`),board:(c,u)=>d("GET",`/quizzes/${i(c)}/board${f(u)}`),gameBoard:c=>d("GET",`/games/${r}/board${f(c)}`)}}function vs(e,t){let n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,s=n(t[br]);if(!s)return;let o=hr.flatMap(a=>{let d=n(t[yr(a)]),f=xn(t[wr(a)]);return d?[{id:a,text:d,...f?{image:f}:{}}]:[]}),r=xn(t[_r]),i=xn(t[Sr]);return{id:e,question:s,options:o,...r?{image:{url:r,alt:n(t[vr])??""}}:{},...i?{media:{url:i}}:{}}}function Ss(e,t){let n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,s=n(t[Er]);if(!s)return;let o=n(t[Cr]),r=n(t[Tr]),i=xn(t[xr]);return{id:e,name:s,...o?{verdict:o}:{},...r?{why:r}:{},...i?{image:{url:i,alt:n(t[kr])??""}}:{}}}function xn(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&typeof e.url=="string"?e.url:void 0;if(!(!t||!t.trim()))try{let n=new URL(t.trim());return n.protocol==="https:"?n.href:void 0}catch{return}}var Rr=["moment"];function Mr(e,t){let n=t?.id;return e==="side"&&(typeof n=="string"||typeof n=="number")?`side:${n}`:e}async function Lr(e,t){let n=globalThis.crypto?.subtle;if(!n)throw new Error("liveChannel needs WebCrypto (a browser, or Node 18+)");let s=new Uint8Array(await n.digest("SHA-1",new TextEncoder().encode(`gamestage/live/${e}/${t}`)));s[6]=s[6]&15|80,s[8]=s[8]&63|128;let o=[...s.subarray(0,16)].map(r=>r.toString(16).padStart(2,"0")).join("");return`l-${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function Dr(e){return e.rows.map(t=>{let n={elapsed:0,sides:[]};return e.columns.forEach((s,o)=>{if(s==="elapsed")return void(n.elapsed=t[o]);let r=s.indexOf("."),i=Number(s.slice(0,r));(n.sides[i]??={})[s.slice(r+1)]=t[o]}),n})}function kn(e,t={}){let n=t.provider??"sportmonks",s=t.contest!==void 0?String(t.contest):null,o=new Map,r=new Map,i=new Set,a={state:"idle",contest:null,last:null},d=null,f=null,c=0,u=p=>{a={...a,...p};for(let T of[...i])T(a)},y=()=>o.get("state")?.sides.map(p=>p.id)??[],b=(p,T)=>p==="timeline"&&T&&typeof T=="object"&&"columns"in T?Dr(T):T;function x(p,T,w){let _=b(p,T);o.set(Mr(p,_),_),a={...a,last:Date.now()};for(let k of r.get(p)??[])if(!(k.news&&w))try{k.fn(_)}catch(v){console.error(v)}}async function g(p){if(p===d)return;let T=++c;if(f?.(),f=null,o.clear(),d=p,!p)return u({state:"idle",contest:null,attempt:void 0,retryAt:void 0});if(!e.subscribeLive)return u({state:"unavailable",contest:p});u({state:"connecting",contest:p,attempt:void 0,retryAt:void 0});let w=await Lr(n,p);T===c&&(f=e.subscribeLive(w,{message:(_,k,v)=>x(_,k,v),synced:()=>u({last:a.last}),status:_=>u({..._,contest:p})}))}let l=()=>s??e.presentation.liveContest?.trim()??null;g(l()||null);let S=s?()=>{}:e.onPresentationChanged(()=>{g(l()||null)});return{get contest(){return d},get status(){return a},state:()=>o.get("state"),clock:()=>o.get("clock"),sides:()=>y().map(p=>o.get(`side:${p}`)).filter(p=>!!p),moments:()=>o.get("moments")??[],timeline:()=>o.get("timeline")??[],health:()=>o.get("health"),on(p,T,w={}){let _=w.news??Rr.includes(p),k={fn:T,news:_};if(r.set(p,[...r.get(p)??[],k]),!_)for(let[v,h]of o)(v===p||v.startsWith(`${p}:`))&&k.fn(h);return()=>r.set(p,(r.get(p)??[]).filter(v=>v!==k))},onStatus(p){return i.add(p),p(a),()=>i.delete(p)},stop(){c++,S(),f?.(),f=null,u({state:"idle"})}}}St();ls();ws();Vt();Vt();var Ur=new Map,Fr=e=>{let t=Ur.get(e);if(t)return t;let n=new Promise((s,o)=>{if(typeof document>"u"){o(new Error("no document"));return}let r=document.createElement("script");r.src=e,r.async=!0,r.crossOrigin="anonymous",r.addEventListener("load",()=>s()),r.addEventListener("error",()=>o(new Error(`could not load ${e}`))),document.head.appendChild(r)});return Ur.set(e,n),n};var vc="https://fantenna.com/signal/v1.js";async function jr(e){if(!e.serviceUrl||!e.projectId)return null;await(e.load??Fr)(vc);let n=globalThis.FantennaSignal;if(!n)throw new Error("the Signal tag loaded without defining itself");let s=n.init({applicationId:e.game,endpoint:"",writeKey:"",fantenna:!1,consent:!0,monterosa:{enabled:!0,serviceUrl:e.serviceUrl,projectId:e.projectId},onObservation:e.onObservation?o=>{e.onObservation?.({name:`signal_${o.type}`,at:(e.now??(()=>Date.now()))(),properties:{...o.properties,signal_event_id:o.id,observed_at:o.occurredAt}})}:void 0});return s.start?.(),{track(o,r){s.track(o,{gamestage_game:e.game,...r??{}})},stop(){s.setConsent(!1),s.stop()}}}var Es={atCapacity:{title:"Kitchen\'s at capacity",body:"This game is taking more players than it can serve right now. Nothing you did. Try again in a few minutes."},rateLimited:{title:"Too many requests from here",body:"This device is sending more requests than the game will take. Wait a moment and carry on."},cappedToday:{title:"That\'s all the plays for today",body:"This game has taken all the plays it can today. Nothing you did. Come back tomorrow."}};function Cs(e){return e==="capped_today"?"cappedToday":"atCapacity"}var lt="gamestage-busy";function Ts(e,t=Es){let n=s=>{let o=e?.[s];return typeof o=="string"&&o.trim()?o:void 0};return{atCapacity:{title:n("busyTitle")??t.atCapacity.title,body:n("busyMessage")??t.atCapacity.body},rateLimited:{title:n("rateLimitedTitle")??t.rateLimited.title,body:n("rateLimitedMessage")??t.rateLimited.body},cappedToday:{title:t.cappedToday.title,body:n("cappedTodayNote")??t.cappedToday.body}}}function xs(e,t={}){let n=t.document??globalThis.document??void 0,s=t.container??n?.body??null;if(!n||!s)return{close:()=>{}};let o=(t.copy??Es)[e];n.getElementById(lt)?.remove();let r=n.createElement("div");r.id=lt,r.setAttribute("role","alertdialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",`${lt}-title`),r.setAttribute("aria-describedby",`${lt}-body`),r.setAttribute("data-kind",e),t.retryAfterSeconds!==void 0&&r.setAttribute("data-retry-after",String(t.retryAfterSeconds)),r.style.cssText=["position:fixed","inset:0","z-index:2147483000","display:flex","align-items:flex-end","justify-content:center","padding:0","background:rgba(0,0,0,0.6)","font-family:inherit"].join(";");let i=n.createElement("div");i.style.cssText=["max-width:480px","width:100%","box-sizing:border-box","padding:20px 24px calc(24px + env(safe-area-inset-bottom, 0px))","border-radius:16px 16px 0 0","background:#fff","color:#111","text-align:center","box-shadow:0 -18px 40px -20px rgba(0,0,0,0.45)"].join(";");let a=n.createElement("div");a.setAttribute("aria-hidden","true"),a.style.cssText=["width:36px","height:4px","margin:0 auto 16px","border-radius:999px","background:rgba(17,17,17,0.18)"].join(";");let d=n.createElement("h2");d.id=`${lt}-title`,d.textContent=o.title,d.style.cssText="margin:0 0 8px;font-size:1.25rem;line-height:1.2";let f=n.createElement("p");f.id=`${lt}-body`,f.textContent=o.body,f.style.cssText="margin:0 0 20px;font-size:1rem;line-height:1.45";let c=n.createElement("button");c.type="button",c.textContent="Close",c.style.cssText=["appearance:none","border:0","cursor:pointer","padding:10px 20px","border-radius:999px","font:inherit","color:#fff","background:var(--gamestage-primary, #111)"].join(";");let u=()=>{n.removeEventListener("keydown",y),r.remove()},y=b=>{b.key==="Escape"&&u()};return c.addEventListener("click",u),r.addEventListener("click",b=>{b.target===r&&u()}),n.addEventListener("keydown",y),i.append(a,d,f,c),r.append(i),s.append(r),c.focus?.(),{close:u}}Wt();Ht();function ks(e){return`gamestage:sign-in:v1:${e}`}function qr(e,t){let n=t.toLowerCase(),s=`${e.toLowerCase()}.apps.`;if(!n.startsWith(s))return;let o=n.slice(s.length);return/^[a-z0-9.-]+\\.[a-z]{2,}$/.test(o)?`https://${o}`:void 0}function Sc(e){try{let t=e.split(".")[1],n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),s=JSON.parse(n).exp;return typeof s=="number"?s:void 0}catch{return}}var wc="anon:test.";function Ec(e){try{let t=e?.();return t?.startsWith(wc)?t:void 0}catch{return}}function Br(e){let t=e.site??qr(e.game,e.hostname),n=e.fetch??(typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0),s=()=>e.messages??e.document?.defaultView??void 0,o=e.now??(()=>Date.now()),r=new Set,i=t&&n?"checking":"off",a,d,f,c=g=>{if(g!==i){i=g;for(let l of r)try{l(g)}catch{}}},u=g=>{try{if(!e.store||!e.mayRemember?.())return;e.store.setItem(ks(e.game),g)}catch{}},y=()=>{try{return e.store?.getItem(ks(e.game))??null}catch{return null}},b=()=>!t||!n?Promise.resolve(i):(d??=(async()=>{try{let g=Ec(e.session),l=await n(`${t}/hub/game-token`,{credentials:"include",cache:"no-store",...g?{headers:{"x-gamestage-player":g}}:{}}),S=l.ok?await l.json().catch(()=>({})):{};S.state==="granted"&&S.token?(a=S.token,c("granted"),u("granted")):S.state==="signed_out"?(a=void 0,c("signed-out")):S.state==="not_granted"?(a=void 0,c(y()==="dismissed"?"dismissed":"not-granted")):(a=void 0,c("not-available"))}catch{a=void 0,c("not-available")}return i})().finally(()=>{d=void 0}),d),x=()=>{f&&(s()?.removeEventListener("message",f.listener),f.host.remove(),f=void 0)};return{get state(){return i},begin:b,rememberedGranted:()=>y()==="granted",async token(){if(i!=="granted")return;let g=a?Sc(a):void 0;return a&&g!==void 0&&g-60>o()/1e3?a:(await b(),i==="granted"?a:void 0)},offer(g,l={}){let S=e.document,p=g.playAs?.trim();if(i!=="not-granted"||!S||!t||!p||f)return;let T=new URL(`${t}/hub/play-as`);T.searchParams.set("game",e.game),T.searchParams.set("label",p),g.detail?.trim()&&T.searchParams.set("detail",g.detail.trim()),g.dismiss?.trim()&&T.searchParams.set("dismiss",g.dismiss.trim()),l.accent&&T.searchParams.set("accent",l.accent),l.onAccent&&T.searchParams.set("on",l.onAccent),l.text&&T.searchParams.set("text",l.text);let w=S.createElement("div");w.setAttribute("data-gamestage-sign-in",""),w.style.cssText=["position:fixed","left:16px","right:16px","bottom:16px","z-index:2147483000","max-width:480px","margin:0 auto","padding:12px 16px","border-radius:16px","box-shadow:0 8px 28px rgba(0,0,0,.18)",`background:${l.surface??"Canvas"}`,"visibility:hidden"].join(";");let _=S.createElement("iframe");_.src=T.toString(),_.title=p.replaceAll("{name}","").trim(),_.style.cssText="display:block;width:100%;height:56px;border:0;background:transparent;color-scheme:normal",_.setAttribute("allowtransparency","true"),w.appendChild(_);let k=v=>{if(v.origin!==t||v.source!==_.contentWindow)return;let h=v.data;if(!(!h||h.type!=="gamestage-sign-in"))switch(h.state){case"ready":typeof h.height=="number"&&h.height>0&&h.height<400&&(_.style.height=`${Math.ceil(h.height)}px`),w.style.visibility="visible",c("offered");return;case"granted":x(),c("checking"),b();return;case"dismissed":x(),u("dismissed"),c("dismissed");return;default:x(),c("not-available")}};s()?.addEventListener("message",k),f={host:w,iframe:_,listener:k},S.body.appendChild(w)},async streak(){if(!(i!=="granted"||!t||!n))try{let g=await n(`${t}/hub/game-streak`,{credentials:"include",cache:"no-store"}),l=g.ok?await g.json().catch(()=>({})):{};return l.state==="granted"?l.streak:void 0}catch{return}},async request(g,l={},S){if(i==="granted"||i==="off"||i==="not-available")return i;if(i==="dismissed"&&c("not-granted"),i==="not-granted")return this.offer(g,l),i;if(i==="signed-out"&&t){let p=e.document,T=`${t}/hub/signin?return_to=${encodeURIComponent("/hub")}`,w=()=>{p?.visibilityState!=="hidden"&&(p?.removeEventListener("visibilitychange",w),b().then(()=>this.offer(g,l)))};p?.addEventListener("visibilitychange",w),(S??(_=>p?.defaultView?.open?.(_,"_blank")))(T)}return i},onChange(g){return r.add(g),()=>r.delete(g)},stop(){x(),r.clear()}}}Tn();function zr(e){return`${cr}:${e}`}function Hr(e){return Object.entries(e).filter(t=>typeof t[1]=="boolean").sort(([t],[n])=>t.localeCompare(n))}function Os(e,t,n){return n===!0?!0:!t||!e?!1:e.querySelector(\'script[src*="user-consent"], script[src*="onetrust"], script[src*="cookielaw"]\')!=null}function Cc(e){return{declared:!0,categories:{...e.categories}}}function As(e){let t=e.window??globalThis,n=e.policyVersion?.trim()||us,s=e.now??(()=>new Date),o=new Set,r=e.hostManagesConsent===!0||e.hostOwnsConsent===!0,i=null,a=new Set(Cn([...e.embedOrigins??[]])),d=()=>{try{return t?.localStorage}catch{return}},c=(()=>{try{let w=d()?.getItem(zr(e.scope?.trim()||e.game));if(!w)return null;let _=lr(JSON.parse(w));return!_||_.source!=="fan"||_.policyVersion!==n?null:_}catch{return null}})(),u=null,y=w=>u!==null&&JSON.stringify(Hr(w))===u,b=()=>{let w=e.platform.consent();return!w.declared||y(w.categories)?null:w},x=(()=>{try{return!!(t&&t.parent&&t.parent!==t)}catch{return!0}})(),g=()=>{let w=b();return w?qt(w.categories,"host",{policyVersion:n,at:s()}):e.hostOwnsConsent?i:c??i},l=()=>{let w=T.reading();for(let _ of[...o])_(w)},S=w=>{if(!x||w.source!==t?.parent||typeof w.origin!="string"||!a.has(w.origin))return;let _=w.data;!_||_.type!==dr||!_.categories||typeof _.categories!="object"||typeof _.policyVersion!="string"||_.policyVersion.trim()!==n||(i=qt(_.categories,"host",{policyVersion:n,at:s()}),l())};t?.addEventListener?.("message",S);let p=e.platform.onConsentChanged(()=>l()),T={reading(){let w=g();return w?Cc(w):e.hostOwnsConsent?{declared:!0,categories:{necessary:!0,functional:!0}}:{declared:!1,categories:{necessary:!0}}},record:()=>g(),needed:()=>!r&&e.policy.analyticsRequiresConsent&&g()===null,hostDecides:()=>r||b()!==null,decide(w){if(T.hostDecides())return!1;let _=qt(w,"fan",{policyVersion:n,at:s()});c=_;try{d()?.setItem(zr(e.scope?.trim()||e.game),JSON.stringify(_))}catch{}try{u=JSON.stringify(Hr(_.categories)),e.platform.declareConsent({..._.categories})}catch{}return l(),!0},onChange(w){return o.add(w),()=>o.delete(w)},stop(){t?.removeEventListener?.("message",S),p(),o.clear()}};return T}Tn();var Vr="gs-consent-style",Tc=`\n.gs-consent{position:fixed;left:0;right:0;bottom:var(--gs-consent-clear,0px);z-index:2147483000;display:flex;justify-content:center;padding:12px 12px calc(12px + env(safe-area-inset-bottom));pointer-events:none;box-sizing:border-box}\n.gs-consent[hidden]{display:none}\n.gs-consent--top{bottom:auto;top:0;padding:calc(12px + env(safe-area-inset-top)) 12px 12px}\n.gs-consent__card{pointer-events:auto;position:relative;width:100%;max-width:26rem;box-sizing:border-box;display:grid;gap:12px;padding:16px 44px 16px 18px;border-radius:20px;border:1px solid rgba(0,0,0,.08);background:var(--gs-consent-surface,#fff);color:var(--gs-consent-ink,#1b1c1f);box-shadow:0 10px 30px rgba(0,0,0,.18);font-family:inherit;font-size:15px;line-height:1.45}\n.gs-consent__title{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.gs-consent p{margin:0}\n.gs-consent a{color:var(--gs-consent-accent-ink,inherit);text-decoration:underline;text-decoration-color:var(--gs-consent-accent,currentColor);text-decoration-thickness:2px;text-underline-offset:4px}\n.gs-consent__row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}\n.gs-consent button{font:inherit;cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation}\n.gs-consent__pill{font-weight:600!important;font-size:15px;min-height:44px;min-width:6.5rem;padding:0 20px;border-radius:999px;box-sizing:border-box}\n.gs-consent__pill:active{transform:translateY(1px)}\n.gs-consent__accept{border:2px solid var(--gs-consent-accent,#1b1c1f);background:var(--gs-consent-accent,#1b1c1f);color:var(--gs-consent-on-accent,#fff)}\n.gs-consent__reject{border:2px solid currentColor;background:transparent;color:inherit}\n.gs-consent__close{position:absolute;top:6px;right:6px;width:40px;height:40px;border:0;border-radius:999px;background:transparent;color:inherit;font-size:22px!important;line-height:1;opacity:.7;display:grid;place-items:center;padding:0}\n.gs-consent__choose{border:0;background:none;color:inherit;text-decoration:underline;text-underline-offset:3px;font-size:14px;padding:4px 2px;min-height:44px}\n.gs-consent button:focus{outline:none}\n.gs-consent button:focus-visible,.gs-consent input:focus-visible,.gs-consent a:focus-visible,.gs-consent__card:focus-visible{outline:3px solid currentColor;outline-offset:2px}\n.gs-consent fieldset{border:0;margin:0;padding:0;display:grid;gap:8px}\n.gs-consent label{display:flex;gap:10px;align-items:flex-start;cursor:pointer}\n.gs-consent input[type=checkbox]{width:22px;height:22px;margin:1px 0 0;flex:none;accent-color:var(--gs-consent-accent,currentColor)}\n.gs-consent__note{font-size:14px}\n@media (min-width:720px){.gs-consent:not(.gs-consent--top) .gs-consent__card--bar{max-width:60rem;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:20px;padding:12px 52px 12px 20px}.gs-consent__card--bar .gs-consent__row{flex-wrap:nowrap}}\n.gs-consent-settings{font:inherit;font-size:inherit;background:none;border:0;color:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:0 .25em;margin:0 0 0 .75em;min-height:0;line-height:inherit;display:inline;vertical-align:baseline}\n.gs-consent-footer{display:block;text-align:center;padding:12px 16px calc(12px + env(safe-area-inset-bottom));font-size:14px}\n.gs-consent-footer .gs-consent-settings{margin:0}\n.gs-copyright-link{display:inline-block;white-space:nowrap;text-decoration:underline}\n.gs-consent-settings:focus{outline:none}\n.gs-consent-settings:focus-visible{outline:3px solid currentColor;outline-offset:2px}\n.gs-consent-room [data-gs-page]::after{content:"";display:block;block-size:var(--gs-consent-room,0px);pointer-events:none}\n`;function xc(e){return e.footCoversMain&&!e.topCoversKept?"top":"foot"}function Is(e,t){let n=e.presentation??{},s={brand:n.consentBrandName,title:n.consentTitle,detail:n.consentDetail,accept:n.consentAcceptLabel,reject:n.consentRejectLabel,choose:n.consentChooseLabel,save:n.consentSaveLabel,analytics:n.consentAnalyticsLabel,marketing:n.consentMarketingLabel,functional:n.consentFunctionalLabel,settings:n.consentSettingsLabel},o={...fr,...t};for(let[r,i]of Object.entries(s))i&&i.trim()&&(o[r]=i);return o}var Kr=["analytics","marketing","functional"],kc=Object.freeze({analytics:!0,marketing:!1,functional:!1});function Ps(e,t={}){let n=globalThis.document;if(!n.getElementById(Vr)){let P=n.createElement("style");P.id=Vr,P.textContent=Tc,n.head.append(P)}let s=n.createElement("div");s.className="gs-consent",Ns(s),s.hidden=!0,s.dataset.gsComponent="consent",s.setAttribute("aria-live","polite"),n.body.append(s);let o=null,r=null,i=P=>{e.consent.decide(P),s.hidden=!0,x(),t.onDecided?.(P)},a=(P,I,G,j="")=>{let D=n.createElement("button");return D.type="button",D.textContent=P,D.dataset.gsPart=I,j&&(D.className=j),D.addEventListener("click",G),D};function d(P){let I=Is(e,t.words),G=e.consent.record()?.categories??{},j=n.createElement("div");j.className=P?"gs-consent__card":"gs-consent__card gs-consent__card--bar",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","false"),j.setAttribute("aria-labelledby","gs-consent-title"),j.tabIndex=-1;let D=n.createElement("h2");D.id="gs-consent-title",D.className="gs-consent__title",D.textContent=I.title;let V=n.createElement("p");V.textContent=gr(I.detail,I.brand);let R=e.presentation?.privacyPolicyUrl;if(R&&/^https?:\\/\\//.test(R)){let K=n.createElement("a");K.href=R,K.target="_blank",K.rel="noopener",K.textContent=I.policy,V.append(" ",K,".")}let re=a("\\xD7","dismiss",()=>{s.hidden=!0,x()},"gs-consent__close");re.setAttribute("aria-label",I.dismiss),j.append(D,re,V);let q=(K,Oe,ie,Le)=>a(K,Oe,Le,`gs-consent__pill gs-consent__${ie}`);if(P){let K=n.createElement("fieldset"),Oe=n.createElement("legend");Oe.className="gs-consent__note",Oe.textContent=I.necessary,K.append(Oe);let ie={};for(let Ee of Kr){let De=n.createElement("label"),ve=n.createElement("input");ve.type="checkbox",ve.checked=G[Ee]===!0,ve.dataset.gsPart=Ee,ie[Ee]=ve,De.append(ve,n.createTextNode(I[Ee])),K.append(De)}let Le=n.createElement("div");Le.className="gs-consent__row",Le.append(q(I.save,"save","accept",()=>i(Object.fromEntries(Kr.map(Ee=>[Ee,ie[Ee].checked])))),q(I.reject,"reject","reject",()=>i({analytics:!1,marketing:!1,functional:!1}))),j.append(K,Le)}else{let K=n.createElement("div");K.className="gs-consent__row",K.append(q(I.accept,"accept","accept",()=>i({...kc})),q(I.reject,"reject","reject",()=>i({analytics:!1,marketing:!1,functional:!1})),a(I.choose,"choose",()=>N(!0,!0),"gs-consent__choose")),j.append(K)}return s.replaceChildren(j),j}let f=n.body,c=n.documentElement,u=f.style.paddingBottom,y=c.style.scrollPaddingBottom,b=()=>n.defaultView,x=()=>{s.hidden&&w();let P=s.querySelector(".gs-consent__card"),I=s.hidden||!P||s.classList.contains("gs-consent--top"),G=I?0:Math.ceil(b().innerHeight-P.getBoundingClientRect().top);f.style.paddingBottom=I?u:`calc(${u||"0px"} + ${G}px)`;let j=I?y:`${G}px`;c.style.scrollPaddingBottom!==j&&(c.style.scrollPaddingBottom=j);let D=I?"":`${G}px`;c.style.getPropertyValue("--gs-consent-room")!==D&&(D?c.style.setProperty("--gs-consent-room",D):c.style.removeProperty("--gs-consent-room")),c.classList.contains("gs-consent-room")===I&&c.classList.toggle("gs-consent-room",!I)},g=32,l=(P,I)=>{let G=Math.min(Math.max(I.left+I.width/2,0),n.documentElement.clientWidth-1),j=Math.min(Math.max(I.top+I.height/2,0),(n.defaultView?.innerHeight??1)-1),V=(typeof n.elementsFromPoint=="function"?n.elementsFromPoint(G,j):[]).find(R=>!s.contains(R));return!V||V===P||P.contains(V)||V.contains(P)},S=()=>{let P=n.defaultView;if(!P)return 0;let I=P.innerHeight,G=[];for(let D of Array.from(n.body.querySelectorAll("body *"))){if(s.contains(D))continue;let V=P.getComputedStyle(D).position;if(V!=="fixed"&&V!=="sticky")continue;let R=D.getBoundingClientRect();R.width===0||R.height===0||R.height>=I*.4||R.bottom<=0||l(D,R)&&G.push(R)}G.sort((D,V)=>V.bottom-D.bottom);let j=0;for(let D of G)I-D.bottom<=j+g&&(j=Math.max(j,I-D.top));return j},p=null,T="",w=()=>{p&&(p.style.paddingBottom=T),p=null},_=P=>{let I=n.querySelector(".gs-boot:not([data-done])");if(!I||!P||s.hidden||s.classList.contains("gs-consent--top"))return w();p!==I&&(w(),p=I,T=I.style.paddingBottom);let G=Math.ceil(b().innerHeight-P.getBoundingClientRect().top);I.style.paddingBottom=`calc(env(safe-area-inset-bottom, 0px) + ${G}px)`},k=()=>{if(!n.defaultView)return;s.style.setProperty("--gs-consent-clear",`${Math.ceil(S())}px`),s.classList.remove("gs-consent--top");let P=s.querySelector(".gs-consent__card");if(_(P),P&&!s.hidden){let I=P.getBoundingClientRect(),G=Array.from(n.querySelectorAll(\'.gs-boot__play, [data-gamestage-start], [data-gs-main], [data-gs-part="commit"]\')),j=(D,V)=>D.some(R=>{let re=R.getBoundingClientRect();return re.width===0||re.height===0||V.right<=re.left||re.right<=V.left||V.bottom<=re.top||re.bottom<=V.top?!1:l(R,re)});if(j(G,I)){s.classList.add("gs-consent--top"),w();let D=Array.from(n.querySelectorAll("[data-gs-keep-clear]")),V=D.length>0&&j(D,P.getBoundingClientRect());xc({footCoversMain:!0,topCoversKept:V})==="foot"&&(s.classList.remove("gs-consent--top"),_(P))}}x()},v=typeof ResizeObserver=="function"?new ResizeObserver(()=>{x()}):null;b()?.addEventListener("resize",k),v?.observe(s);let h=!1;function N(P=!1,I=!1){Ns(s);let G=d(P);h=I||!s.hidden&&h,s.hidden=!1,x(),I&&G.focus({preventScroll:!0}),k()}let L=null,C=()=>{if(t.settingsIn!==void 0)return t.settingsIn;let P=n.querySelector(\'[data-gs-slot="privacy-settings"]\');if(P)return P;let I=n.querySelector(\'[data-gs-part="recovery"]\');if(I?.parentElement&&I.parentElement!==n.body)return I.parentElement;let G=n.querySelectorAll("footer");return G.length?G[G.length-1]:(L||(L=n.createElement("div"),L.className="gs-consent-footer",L.dataset.gsPart="settings-footer",n.body.append(L)),L)},H=()=>{let P=e.consent.hostDecides()?null:C();if(!P){o?.remove(),o=null,r?.remove(),r=null;return}o||(o=a(Is(e,t.words).settings,"settings",()=>N(!0,!0),"gs-consent-settings")),o.parentElement!==P&&P.append(o),r||(r=n.createElement("a"),r.className="gs-consent-settings gs-copyright-link",r.dataset.gsPart="copyright",r.href=ur,r.target="_blank",r.rel="noopener",r.textContent=Is(e,t.words).copyright),r.previousElementSibling!==o&&o.after(r),L&&P!==L&&(L.remove(),L=null)},te=!1,ce=typeof MutationObserver=="function"&&t.settingsIn===void 0?new MutationObserver(P=>{te||P.every(I=>s.contains(I.target)||(o?.contains(I.target)??!1))||(te=!0,queueMicrotask(()=>{te=!1,H()}))}):null;ce?.observe(n.body,{childList:!0,subtree:!0});let $=e.consent.onChange(()=>{H(),(e.consent.hostDecides()||!h&&!e.consent.needed())&&(s.hidden=!0,x())});H();let ge=!1,_e=typeof MutationObserver=="function"?new MutationObserver(P=>{s.hidden||ge||P.every(I=>I.target===n.body||s.contains(I.target)||I.target===p&&I.attributeName==="style")||(ge=!0,(b()?.requestAnimationFrame??setTimeout)(()=>{ge=!1,Ns(s),k()}))}):null;return _e?.observe(n.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-done","data-state"]}),e.consent.needed()&&!e.consent.hostDecides()&&N(!1),{open:()=>{e.consent.hostDecides()||N(!0,!0)},close:()=>{s.hidden=!0,x()},stop:()=>{$(),ce?.disconnect(),_e?.disconnect(),b()?.removeEventListener("resize",k),v?.disconnect(),w(),s.remove(),o?.remove(),L?.remove(),f.style.paddingBottom=u,c.style.scrollPaddingBottom=y,c.style.removeProperty("--gs-consent-room"),c.classList.remove("gs-consent-room")}}}function Wr(e){let t=e.match(/rgba?\\(\\s*(\\d+)[ ,]+(\\d+)[ ,]+(\\d+)/);if(!t)return null;let[n,s,o]=[t[1],t[2],t[3]].map(r=>{let i=Number(r)/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*n+.7152*s+.0722*o}function Yr(e,t){let n=Wr(e),s=Wr(t);return n===null||s===null?null:(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}function Ns(e){let t=e.ownerDocument.defaultView;if(!t)return;let n=t.getComputedStyle(e.ownerDocument.documentElement),s=e.ownerDocument.createElement("span");e.append(s);let o=a=>(s.style.color="",s.style.color=a,t.getComputedStyle(s).color),r=[["--gs-backgroundContainerColour","--gs-onBackgroundContainerColour"],["--gs-backgroundMainColour","--gs-onBackgroundColour"]];for(let[a,d]of r){let f=n.getPropertyValue(a).trim(),c=n.getPropertyValue(d).trim();if(!f||!c)continue;let u=Yr(o(f),o(c));if(u!==null&&u>=4.5){e.style.setProperty("--gs-consent-surface",f),e.style.setProperty("--gs-consent-ink",c);break}}let i=[["--gs-highlightMainColour","--gs-onHighlightColour"],["--gamestage-primary",""],["--gs-primaryMainColour","--gs-onPrimaryColour"]];for(let[a,d]of i){let f=n.getPropertyValue(a).trim();if(!f)continue;let c=o(f),u=n.getPropertyValue(d||"--none").trim(),b=(u?[u,"#ffffff","#111111"]:["#ffffff","#111111"]).find(x=>(Yr(c,o(x))??0)>=4.5);if(b){e.style.setProperty("--gs-consent-accent",f),e.style.setProperty("--gs-consent-on-accent",b);break}}s.remove()}var An={heading:"Can\'t load the game right now",body:"Check your connection, then try again.",retry:"Try again"},Yt=class extends Error{code="unavailable";handled=!0;constructor(){super("Interaction Cloud did not answer and this device has no remembered settings, so the game has no words to show. The library has drawn its retry screen."),this.name="GamestageUnavailableError"}},Qr="gamestage-unavailable";function Jr(e){let t=e.document;if(!t?.body||typeof t.createElement!="function"||t.getElementById?.(Qr))return;let n=t.createElement("div");n.setAttribute("id",Qr),n.setAttribute("role","alert"),Object.assign(n.style,{position:"fixed",inset:"0",zIndex:"2147483647",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"16px",padding:"24px",background:"#111",color:"#fff",fontFamily:"system-ui, -apple-system, sans-serif",textAlign:"center"});let s=t.createElement("h1");s.textContent=An.heading,Object.assign(s.style,{fontSize:"22px",margin:"0",fontWeight:"700"});let o=t.createElement("p");o.textContent=An.body,Object.assign(o.style,{fontSize:"17px",margin:"0",opacity:"0.8"});let r=t.createElement("button");r.setAttribute("type","button"),r.textContent=An.retry,Object.assign(r.style,{fontSize:"17px",fontWeight:"700",minHeight:"48px",padding:"0 28px",borderRadius:"999px",border:"0",background:"#fff",color:"#111",cursor:"pointer",touchAction:"manipulation",userSelect:"none"}),r.addEventListener("click",()=>e.location?.reload()),n.appendChild(s),n.appendChild(o),n.appendChild(r),t.body.appendChild(n)}async function de(e){if(e===void 0)return{kind:"anonymous"};try{let t=typeof e=="function"?await e():e;return typeof t=="string"&&t.length>0?{kind:"identified",token:t}:{kind:"anonymous"}}catch{return{kind:"anonymous"}}}function me(e){return e.kind==="identified"?e.token:void 0}var Xr=e=>e.replace(/\\/+$/,"");async function Oc(e){let t=me(await de(e.identity));if(!t)return{kind:"anonymous"};let n=e.fetchImpl??globalThis.fetch,s=`${Xr(e.baseUrl)}/api/loyalty/v1/me`,o={Authorization:`Bearer ${t}`},r=await n(`${s}/points`,{headers:o});if(r.status===401||r.status===403)return{kind:"anonymous"};if(!r.ok)throw new Error(`Loyalty points read failed: ${r.status}`);let a=((await r.json()).items??[]).find(x=>x.programmeId===e.programmeId),{unlocked:d,stillToUnlock:f,catalogue:c}=await Ac(n,s,o);if(!a)return{kind:"standing",standing:{programmeId:e.programmeId,balance:0,enrolled:!1,statement:[],catalogue:c,unlocked:d,stillToUnlock:f}};let u=e.statementLimit??20,y=await n(`${s}/points/${encodeURIComponent(e.programmeId)}/statement?limit=${u}`,{headers:o}),b=y.ok?(await y.json()).lines??[]:[];return{kind:"standing",standing:{programmeId:a.programmeId,balance:a.balance,tier:a.tier,tiers:a.tiers,enrolled:!0,statement:b,catalogue:c,unlocked:d,stillToUnlock:f}}}async function Rs(e){if(!e.baseUrl)return null;let t=me(await de(e.identity));if(!t)return null;let n=e.fetchImpl??globalThis.fetch;try{let s=await n(`${Xr(e.baseUrl)}/api/loyalty/v1/me/streak`,{headers:{Authorization:`Bearer ${t}`}});return s.ok?Ms(await s.json()):null}catch{return null}}function Ms(e){let t=e??{};return typeof t.current!="number"||typeof t.best!="number"?null:{current:t.current,best:t.best,lastDay:t.lastDay??"",proved:t.proved===!0,nextMilestone:t.nextMilestone}}async function Ac(e,t,n){let[s,o]=await Promise.all([e(`${t}/rewards`,{headers:n}).catch(()=>{}),e(`${t}/products`,{headers:n}).catch(()=>{})]),r=s?.ok?((await s.json()).items??[]).map(c=>({instanceId:c.instance.instanceId,product:{productId:c.instance.product.productId,name:c.instance.product.name,description:c.instance.product.description,type:c.instance.product.type},campaignName:c.campaign?.name,awardedAt:c.awardedAt})):[],i=o?.ok?(await o.json()).items??[]:[],a=new Set(r.map(c=>c.product.productId)),d=i.map(c=>({productId:c.productId,name:c.name,description:c.description,type:c.type})),f=d.filter(c=>!a.has(c.productId));return{unlocked:r,stillToUnlock:f,catalogue:d}}function Ic(e){let t=e.round;if(!t)return"No round has been read yet.";let n=t.origin;return n?n.source==="studio"?`This round came from Studio: element ${n.element_id??"unknown"}`+(n.edition_id?` on edition ${n.edition_id}`:"")+`, as round ${t.id} version ${t.version}.`:`This round came from the game\'s manifest, as ${t.id} version ${t.version}.`:`This round is ${t.id}, and this Engine does not say where it came from. That is older than the field, not a manifest round.`}function Nc(e){return(e.performance?.getEntriesByType?.("resource")??[]).slice(-40).map(n=>{let s=n;return{name:s.name,status:s.responseStatus?String(s.responseStatus):"unknown",ms:Math.round(s.duration)}})}function Pc(e,t){let n=[Ic(e),"",`game ${e.game}`,`platform ${e.platform}`];e.offPlatformReason&&n.push(`not on ic ${e.offPlatformReason}`),e.ids?.project&&n.push(`project ${e.ids.project}`),e.ids?.event&&n.push(`edition ${e.ids.event}`),e.ids?.element&&n.push(`element ${e.ids.element}`),e.ids?.host&&n.push(`studio host ${e.ids.host}`),e.endpoints.playerApi&&n.push(`player api ${e.endpoints.playerApi}`),e.endpoints.mesh&&n.push(`mesh ${e.endpoints.mesh}`),n.push(`identity ${e.identity.signedIn?`${e.identity.kind}, signed in`:e.identity.kind}`),n.push(`consent ${e.consent.allowed?"granted":"not granted"}`);let s=Object.entries(e.presentation).filter(([,o])=>o);n.push(`producer ${s.length?s.map(([o])=>o).join(", "):"nothing set"}`),n.push("","requests");for(let o of Nc(t))n.push(` ${o.status.padEnd(7)} ${o.ms.toString().padStart(5)}ms ${o.name}`);return n.push("",`page ${t.location?.href??"unknown"}`),n.push(`when ${new Date().toISOString()}`),n.join(`\n`)}var Zr="gsdebug",Rc="gamestage-debug";function Mc(e,t){let n=e.document,s=n.createElement("div");s.id="gamestage-debug",s.setAttribute("role","dialog"),s.setAttribute("aria-label","Gamestage diagnostics"),s.style.cssText=["position:fixed","inset:auto 0 0 0","max-height:70vh","overflow:auto","z-index:2147483647","background:#0b0f1c","color:#e8eaf2","font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace","padding:12px 14px","border-top:2px solid #e5484d","white-space:pre-wrap"].join(";");let o=n.createElement("div");o.style.cssText="display:flex;gap:8px;margin-bottom:10px";let r=n.createElement("button");r.textContent="Copy",r.style.cssText="font:inherit;padding:4px 10px;cursor:pointer",r.onclick=()=>{e.navigator.clipboard?.writeText(t).then(()=>r.textContent="Copied",()=>r.textContent="Select and copy")};let i=n.createElement("button");i.textContent="Close",i.style.cssText=r.style.cssText,i.onclick=()=>s.remove(),o.append(r,i);let a=n.createElement("div");return a.textContent=t,s.append(o,a),s}function ei(e,t){let n=t.document;if(!n)return()=>{};let s=()=>{n.getElementById("gamestage-debug")?.remove(),n.body?.append(Mc(t,Pc(e(),t)))},o="",r=i=>{let a=i.target;a?.isContentEditable||a?.tagName==="INPUT"||a?.tagName==="TEXTAREA"||i.key.length!==1||(o=(o+i.key.toLowerCase()).slice(-Zr.length),o===Zr&&s())};return n.addEventListener("keydown",r),t.location&&new URLSearchParams(t.location.search).has(Rc)&&t.setTimeout(s,0),()=>n.removeEventListener("keydown",r)}Wt();function Ls(e={}){let t=Kt(),n=new Map,s=[],o=new Set,r=new Set,i=new Set,a={...e.presentation??{}},d={declared:!1,categories:{}},f,c=!1,u=()=>{for(let g of[...o])g()},y=e.setInterval??((g,l)=>setInterval(g,l)),b=e.clearInterval??(g=>clearInterval(g)),x=e.pollMilliseconds??0;return x>0&&(f=y(u,x)),{kind:"local",offPlatformReason:e.offPlatformReason,clock:t,emitted:s,presentation:a,signInSettings:e.signInSettings??{enabled:!1},consent:()=>d,onConsentChanged(g){return r.add(g),()=>r.delete(g)},onPresentationChanged(g){return i.add(g),()=>i.delete(g)},setPresentation(g){for(let l of Object.keys(a))delete a[l];Object.assign(a,g);for(let l of[...i])l(a)},declareConsent(g){d={declared:!0,categories:{...g}};for(let l of[...r])l(d);return!0},onRoundAnnounced(g){return o.add(g),()=>o.delete(g)},subscribeLive(g,l){let S=e.liveSource;if(!S||typeof EventSource>"u")return l.status({state:"unavailable"}),()=>{};let p=!1;l.status({state:"connecting"});let T=`${S}${S.includes("?")?"&":"?"}channel=${encodeURIComponent(g)}`,w=new EventSource(T);return w.onmessage=_=>{try{let k=JSON.parse(_.data);l.message(k.class,k.body,!p)}catch{}},w.addEventListener("synced",()=>{p=!0,l.synced(),l.status({state:"live"})}),w.onerror=()=>{p=!1,l.status({state:typeof navigator<"u"&&navigator.onLine===!1?"offline":"reconnecting"})},()=>w.close()},announce:u,emit(g){s.push(g)},storage:{read:async g=>n.get(g)??null,write:async(g,l)=>{n.set(g,l)},remove:async g=>{n.delete(g)}},stop(){c||(c=!0,f!==void 0&&b(f),o.clear(),r.clear())}}}Ht();$s();function ri(e,t){let n=new Date(e);if(!Number.isNaN(n.getTime()))try{return n.toLocaleDateString("en-CA",{timeZone:t})}catch{return}}function ii(e){let t=new Date(`${e}T12:00:00Z`);return t.setUTCDate(t.getUTCDate()-1),t.toISOString().slice(0,10)}function Dc(e,t={}){let n=t.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",s=t.now??new Date,o=new Set;for(let u of e){if(u.amount<=0)continue;let y=ri(u.occurredAt,n);y&&o.add(y)}if(o.size===0)return{days:0,capped:!1,today:!1};let r=ri(s.toISOString(),n)??"",i=o.has(r),a=i?r:ii(r);if(!o.has(a))return{days:0,capped:!1,today:i};let d=0;for(;o.has(a);)d+=1,a=ii(a);let f=[...o].sort()[0],c=a<f;return{days:d,capped:c,today:i}}Vt();Us();Wt();St();function ai(e,t,n=Date.now(),s){if(!e?.can.results_available||!e.finalAt||n>=Date.parse(e.finalAt))return"";let o=new Date(e.finalAt).toLocaleString(s,{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"});return t.replaceAll("{finalAt}",o)}function $c(e,t,n="label_provisional_result"){let s,o=()=>{clearTimeout(s),t.textContent=ai(e.round,e.presentation?.labels?.[n.replace(/^label_/,"")]??mr,e.now()),t.hidden=!t.textContent;let a=Date.parse(e.round?.finalAt??"")-e.now();a>0&&(s=setTimeout(o,Math.min(a,2147483647)))},r=e.onRoundChanged(o),i=e.onPresentationChanged(o);return o(),()=>{clearTimeout(s),r(),i()}}var ci={open:"Your progress",showTitle:"Keep your progress",showDetail:"Save this code. It brings your name, scores and achievements back on another phone or browser. You only see it once.",private:"Keep it private. Anyone with this code can play as you.",replace:"Getting a new code stops the old one working.",get:"Get a recovery code",issueFailed:"That didn\'t work. Check your connection and try again.",copy:"Copy",copied:"Copied",share:"Share",enterTitle:"I\'ve played before",enterDetail:"Type the recovery code you saved to get your progress back.",submit:"Get my progress back",notRecognised:"That code isn\'t one we know. Check it against the one you saved.",restored:"Welcome back. Your progress is on this device now.",close:"Close"};var di="gs-recovery-style",Gc=`\n.gs-recovery-open{font:inherit;background:none;border:0;color:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:.5rem 0;min-height:44px}\n.gs-recovery{border:0;border-radius:16px;padding:0;max-width:min(26rem,calc(100vw - 32px));width:100%;color:#1b1c1f;background:#fff;box-shadow:0 18px 48px rgba(0,0,0,.35)}\n.gs-recovery::backdrop{background:rgba(0,0,0,.55)}\n.gs-recovery__body{display:grid;gap:12px;padding:20px;font:17px/1.45 system-ui,sans-serif}\n.gs-recovery h2{margin:0;font-size:1.2rem}\n.gs-recovery p{margin:0}\n.gs-recovery__code{font:700 1.25rem/1.3 ui-monospace,Menlo,monospace;letter-spacing:.02em;text-align:center;padding:12px;border:1.5px solid #c9ccd3;border-radius:10px;background:#f4f5f7;user-select:all;overflow-wrap:anywhere}\n.gs-recovery__row{display:flex;gap:8px;flex-wrap:wrap}\n.gs-recovery button{font:inherit;font-weight:600;min-height:44px;padding:0 16px;border-radius:10px;border:1.5px solid #1b1c1f;background:#fff;color:#1b1c1f;cursor:pointer}\n.gs-recovery button.gs-recovery__primary{background:#1b1c1f;color:#fff}\n.gs-recovery button:disabled{opacity:.5;cursor:default}\n.gs-recovery input{font:16px/1.3 system-ui,sans-serif;min-height:44px;padding:0 12px;border:1.5px solid #c9ccd3;border-radius:10px}\n.gs-recovery input[aria-invalid=true]{border-color:#c62828;border-style:dashed}\n.gs-recovery__note{color:#50535c;font-size:.95rem}\n.gs-recovery__error{color:#c62828}\n.gs-recovery hr{border:0;border-top:1px solid #e3e5e9;margin:4px 0}\n`;function Uc(e,t){let n=e.presentation??{},s={open:n.recoveryOpenLabel,showTitle:n.recoveryShowTitle,showDetail:n.recoveryShowDetail,private:n.recoveryPrivateNote,replace:n.recoveryReplaceNote,enterTitle:n.recoveryEnterTitle,enterDetail:n.recoveryEnterDetail,submit:n.recoverySubmitLabel,notRecognised:n.recoveryNotRecognised,restored:n.recoveryRestored,get:n.recoveryGetLabel,issueFailed:n.recoveryIssueFailed,copy:n.recoveryCopyLabel,copied:n.recoveryCopiedLabel,share:n.recoveryShareLabel,close:n.recoveryCloseLabel},o={...ci,...t};for(let[r,i]of Object.entries(s))i&&i.trim()&&(o[r]=i);return o}function Y(e,t,n={},...s){let o=e.createElement(t),{dataset:r,...i}=n;return Object.assign(o,i),r&&Object.assign(o.dataset,r),o.append(...s),o}function Fc(e,t,n={}){let s=t.ownerDocument;s.getElementById(di)||s.head.append(Y(s,"style",{id:di,textContent:Gc}));let o=()=>Uc(e,n.words),r=Y(s,"button",{type:"button",className:"gs-recovery-open",textContent:o().open});r.dataset.gsPart="recovery";let i=Y(s,"dialog",{className:"gs-recovery"});i.setAttribute("aria-labelledby","gs-recovery-title"),t.append(r),s.body.append(i);function a(){let c=o(),u=Y(s,"div",{className:"gs-recovery__body"}),y=Y(s,"h2",{id:"gs-recovery-title",textContent:c.showTitle}),b=Y(s,"p",{className:"gs-recovery__code",hidden:!0});b.setAttribute("aria-label",c.showTitle);let x=Y(s,"button",{type:"button",textContent:c.copy,hidden:!0}),g=Y(s,"button",{type:"button",textContent:c.share,hidden:!0}),l=Y(s,"span",{className:"gs-recovery__note"});l.setAttribute("aria-live","polite");let S=Y(s,"button",{type:"button",className:"gs-recovery__primary",textContent:c.get}),p=Y(s,"p",{className:"gs-recovery__error",hidden:!0});p.setAttribute("role","alert"),S.addEventListener("click",async()=>{S.disabled=!0,p.hidden=!0;try{let L=await e.client.issueRecoveryCode();b.textContent=L.code,b.hidden=!1,x.hidden=!1,g.hidden=typeof navigator.share!="function",S.hidden=!0}catch{p.textContent=c.issueFailed,p.hidden=!1,S.disabled=!1}}),x.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(b.textContent??""),l.textContent=c.copied}catch{l.textContent=""}}),g.addEventListener("click",async()=>{try{await navigator.share({text:b.textContent??""})}catch{}});let T=Y(s,"h2",{textContent:c.enterTitle}),w=Y(s,"form");w.noValidate=!0;let _=Y(s,"label",{htmlFor:"gs-recovery-input",textContent:c.enterTitle});_.hidden=!0;let k=Y(s,"input",{id:"gs-recovery-input",type:"text",placeholder:"four words and two numbers"});k.setAttribute("inputmode","text"),k.setAttribute("autocomplete","off"),k.setAttribute("autocorrect","off"),k.setAttribute("autocapitalize","none"),k.setAttribute("spellcheck","false"),k.setAttribute("enterkeyhint","go");let v=Y(s,"p",{className:"gs-recovery__error",id:"gs-recovery-error",hidden:!0});v.setAttribute("role","alert");let h=Y(s,"button",{type:"submit",className:"gs-recovery__primary",textContent:c.submit});w.addEventListener("submit",async L=>{L.preventDefault();let C=k.value.trim();if(!C)return;let H=C;h.disabled=!0,v.hidden=!0,k.removeAttribute("aria-invalid");try{await e.client.restoreFromRecoveryCode(H),l.textContent=c.restored,v.hidden=!0,w.replaceChildren(Y(s,"p",{textContent:c.restored})),await n.onRestored?.()}catch{v.textContent=c.notRecognised,v.hidden=!1,k.setAttribute("aria-invalid","true"),k.setAttribute("aria-describedby","gs-recovery-error"),h.disabled=!1}}),w.append(_,k,v,h);let N=Y(s,"button",{type:"button",textContent:c.close});N.addEventListener("click",()=>i.close()),u.append(y,Y(s,"p",{textContent:c.showDetail}),S,b,Y(s,"div",{className:"gs-recovery__row"},x,g),l,Y(s,"p",{className:"gs-recovery__note",textContent:`${c.private} ${c.replace}`}),p,Y(s,"hr"),T,Y(s,"p",{textContent:c.enterDetail}),w,Y(s,"div",{className:"gs-recovery__row"},N)),i.replaceChildren(u)}let d=()=>{a(),i.showModal()};r.addEventListener("click",d);let f=e.onPresentationChanged?.(()=>{r.textContent=o().open});return()=>{r.removeEventListener("click",d),f?.(),r.remove(),i.remove()}}St();function In(e){let t=[],n=/\\[([^\\]]*)\\]/g,s=0;for(let o of e.matchAll(n))o.index>s&&t.push({text:e.slice(s,o.index),accent:!1}),o[1]&&t.push({text:o[1],accent:!0}),s=o.index+o[0].length;return s<e.length&&t.push({text:e.slice(s),accent:!1}),t.filter(o=>o.text.length>0)}function Fs(e){return In(e).map(t=>t.text).join("")}var jc=["displayName","strapline","howToPlay","playButtonLabel","playAgainLabel","resultButtonLabel","shareButtonLabel","editionName","editionStrapline"];function qc(e,t={},n={}){let s=t.document??globalThis.document??void 0,o=e.displayName||n.displayName||void 0;for(let c of jc){let u=c==="displayName"?o:e[c],y=t[c];if(y){if(!u){Bc(y);continue}Jt.has(y)?Jt.get(y).wrote=u:Jt.set(y,{text:y.textContent??"",hidden:y.hasAttribute?.("hidden")??!1,wrote:u}),y.textContent=u,y.removeAttribute("hidden")}}if(s)if(o)Qt.has(s)?Qt.get(s).wrote=o:Qt.set(s,{before:s.title,wrote:o}),s.title=o;else{let c=Qt.get(s);c&&s.title===c.wrote&&(s.title=c.before),Qt.delete(s)}let r=t.root??s?.documentElement??null;if(!r)return;let i={};if(e.primaryColour&&(i["--gamestage-primary"]=e.primaryColour,Object.assign(i,ui(e.primaryColour))),e.cssVariables){for(let[u,y]of Object.entries(e.cssVariables))y&&(i[`--gs-${u}`]=y);let c=e.cssVariables.highlightMainColour;c&&Object.assign(i,ui(c)),Object.assign(i,vi(e.cssVariables));for(let u of Kc){let y=Bt(e.cssVariables[u],e.uploadedFonts??[]);y&&(i[`--gs-${u}`]=y.family)}}let a=wi(e);Object.assign(i,a.vars),Vc(s,a);let d=Bt(e.defaultFontFamily,e.uploadedFonts??[]);d&&(i["--gs-font-default"]=`"${d.family}", system-ui, sans-serif`),s&&td(s,e.uploadedFonts),s&&Yc(s,e),e.logoAccentColour&&(i["--gs-title-accent"]=e.logoAccentColour),s&&rd(s,e.logoText,o),s&&id(s,e,o),s&&qs(s,e.logoText,o);let f=li.get(r)??new Set;for(let c of f)c in i||r.style.removeProperty(c);for(let[c,u]of Object.entries(i))r.style.setProperty(c,u);li.set(r,new Set(Object.keys(i)))}var li=new WeakMap,Jt=new WeakMap,Qt=new WeakMap;function Bc(e){let t=Jt.get(e);t&&(Jt.delete(e),e.textContent===t.wrote&&(e.textContent=t.text,t.hidden&&e.setAttribute?.("hidden","")))}var zc={backgroundMainColour:["background"],onBackgroundColour:["ink"],backgroundContainerColour:["surface"],highlightMainColour:["interactive"],highlightVariantColour:["interactive-base"],onHighlightColour:["on-accent"],positiveMainColour:["positive"],positiveVariantColour:["positive-base"],negativeMainColour:["negative"],negativeVariantColour:["negative-base"],secondaryMainColour:["selected"],tertiaryMainColour:["reward"]};function vi(e){let t={};for(let[n,s]of Object.entries(zc)){let o=e[n];if(o)for(let r of s)t[`--gs-color-${r}`]=o,t[`--gs-color-${r}-solid`]=o}return t}function ui(e){let t={},n=(o,r)=>{t[`--gs-color-${o}`]=r,t[`--gs-color-${o}-solid`]=r};n("interactive",e),n("interactive-hover",`color-mix(in oklab, ${e} 82%, white)`),n("interactive-base",`color-mix(in oklab, ${e} 68%, black)`);let s=Hc(e);return s!==void 0&&n("on-accent",s>.4?"#111111":"#ffffff"),t}function Hc(e){let t=e.trim(),n,s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(s){let a=s[1].length===3?s[1].split("").map(d=>d+d).join(""):s[1];n=[0,2,4].map(d=>parseInt(a.slice(d,d+2),16))}else{let a=/^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i.exec(t);a&&(n=a.slice(1,4).map(Number))}if(!n)return;let[o,r,i]=n.map(a=>{let d=a/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)});return .2126*o+.7152*r+.0722*i}var Si="[data-gamestage-title], :root:not(:has([data-gamestage-title])) h1";function wi(e){let t={},n=[],s,o=e.cssVariables??{},r=o.fontTitleFamily??e.titleFont,i=o.fontTitleWeight??e.titleFontWeight,a=o.fontTitleTracking??e.titleLetterSpacing,d=o.fontTitleCase??e.titleCase,f=Bt(r,e.uploadedFonts??[]);if(f){t["--gs-title-font"]=`"${f.family}", var(--gs-font-display, system-ui), sans-serif`,n.push("font-family: var(--gs-title-font)");let b=f.stylesheetHref?Ar(r,i)?.weight:i;b!==void 0&&b!==""&&(t["--gs-title-weight"]=String(b),n.push("font-weight: var(--gs-title-weight)")),s=f.stylesheetHref}let c=Ir(a);c&&(t["--gs-title-tracking"]=c,n.push("letter-spacing: var(--gs-title-tracking)"));let u=Nr(d);u&&(t["--gs-title-case"]=u,n.push("text-transform: var(--gs-title-case)")),e.titleColour&&(t["--gs-title-colour"]=e.titleColour,n.push("color: var(--gs-title-colour)"));let y=n.length?`${Si} { ${n.join("; ")}; }`:"";return e.logoText&&(y+=`${y?" ":""}.gamestage-title-accent { color: var(--gs-title-accent, inherit); }`),{vars:t,css:y,fontHref:s}}var fi="gamestage-title-style",gi="gamestage-title-font";function Vc(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=e.getElementById(fi);if(t.css?(n||(n=e.createElement("style"),n.id=fi,e.head.appendChild(n)),n.textContent!==t.css&&(n.textContent=t.css)):n?.remove(),!t.fontHref){e.getElementById(gi)?.remove();return}Ci(e,gi,t.fontHref)}var pi="gamestage-font-preconnect",mi="gamestage-role-font-",Ei=["fontBodyFamily","fontNumberFamily","fontCTAFamily","fontLabelFamily","fontHighlightFamily"],Kc=["fontTitleFamily",...Ei];function Wc(e){if(e.getElementById(pi))return;let t=e.createElement("link");t.id=pi,t.rel="preconnect",t.href=ys,t.crossOrigin="anonymous",e.head.appendChild(t)}function Ci(e,t,n){Wc(e);let s=e.getElementById(t);s&&s.href===n||(s||(s=e.createElement("link"),s.id=t,s.rel="stylesheet",e.head.appendChild(s)),s.media="print",s.onload=()=>{s&&(s.media="all")},s.href=n)}function Yc(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=t.cssVariables??{},s=t.uploadedFonts??[],o=new Map,r=[t.defaultFontFamily,...Ei.map(i=>n[i])];for(let i of r){let a=Bt(i,s);if(!a?.stylesheetHref)continue;let d=a.family.toLowerCase().replace(/[^a-z0-9]+/g,"-");o.set(`${mi}${d}`,a.stylesheetHref)}for(let i of Array.from(e.head.children)){let a=i.id;i.tagName==="LINK"&&a.startsWith(mi)&&!o.has(a)&&i.remove()}for(let[i,a]of o)Ci(e,i,a)}var hi="gamestage-font-faces",yi="gamestage-font-preload-",Qc={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype"};function Jc(e){let t=e.trim();return!/^(https:)?\\/\\//i.test(t)||/["\'()\\\\\\s<>{}]/.test(t)?null:t}function Xc(e){let t=e.split(/[?#]/)[0]?.split(".").pop()?.toLowerCase();return t?Qc[t]:void 0}function Zc(e){let t=[],n=new Set;for(let s of e??[]){let o=bs(s.name??""),r=Jc(s.url??"");if(!o||!r)continue;let i=o.toLowerCase().replace(/[^a-z0-9]+/g,"-");if(n.has(i))continue;n.add(i);let a=String(s.weight??"").trim();t.push({family:o,url:r,weight:/^\\d{2,4}$/.test(a)?a:"400",slug:i})}return t}function ed(e){let t=Xc(e.url),n=t?`url("${e.url}") format("${t}")`:`url("${e.url}")`;return`@font-face { font-family: "${e.family}"; src: ${n}; font-weight: ${e.weight}; font-display: swap; }`}function td(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=Zc(t),s=e.getElementById(hi);if(!n.length)s?.remove();else{let r=n.map(ed).join(" ");s||(s=e.createElement("style"),s.id=hi,e.head.appendChild(s)),s.textContent!==r&&(s.textContent=r)}let o=new Map(n.map(r=>[`${yi}${r.slug}`,r]));for(let r of Array.from(e.head.children)){let i=r.id;r.tagName==="LINK"&&i.startsWith(yi)&&!o.has(i)&&r.remove()}for(let[r,i]of o){if(e.getElementById(r))continue;let a=e.createElement("link");a.id=r,a.rel="preload",a.as="font",a.href=i.url,a.crossOrigin="anonymous",e.head.appendChild(a)}}var Xt=new WeakMap,ze="data-gamestage-logo",nd="gamestage-title-accent";function Ti(e,t,n){let s=Array.from(e.querySelectorAll("[data-gamestage-title]"));if(s.length)return s;let o=new Set([t,Fs(n)].filter(Boolean).map(r=>r.trim().toLowerCase()));return Array.from(e.querySelectorAll("h1")).filter(r=>r.hasAttribute(ze)||o.has((r.textContent??"").trim().toLowerCase()))}function bi(e){let t=Xt.get(e);if(t?.text){for(let n of Ti(e,t.name,t.text)){if(n.getAttribute(ze)===t.text&&n.textContent===Fs(t.text))continue;let s=In(t.text).map(o=>{if(!o.accent)return e.createTextNode(o.text);let r=e.createElement("span");return r.className=nd,r.textContent=o.text,r});n.replaceChildren(...s),n.setAttribute(ze,t.text),t.name&&n.setAttribute("aria-label",t.name)}qs(e,t.text,t.name)}}var sd=20,js="data-gamestage-fit",_i=new WeakSet;function qs(e,t,n){if(typeof e.querySelectorAll!="function")return;let s=e.defaultView;if(!s||typeof s.getComputedStyle!="function")return;let o=t?.trim()||n;if(o){for(let r of Ti(e,n,o))od(r,s);if(!_i.has(e)){_i.add(e);let r=()=>{let i=Xt.get(e);qs(e,i?.text,i?.name??n)};s.addEventListener?.("resize",r),e.fonts?.addEventListener?.("loadingdone",r),e.fonts?.ready?.then(r)}}}function od(e,t){if(!e.style)return;e.hasAttribute(js)&&(e.style.removeProperty("font-size"),e.style.removeProperty("white-space"),e.style.removeProperty("overflow-wrap"),e.removeAttribute(js));let n=e.clientWidth;if(!n)return;let s=e.style.whiteSpace;e.style.whiteSpace="nowrap";let o=e.scrollWidth;if(o<=n){e.style.whiteSpace=s;return}let r=parseFloat(t.getComputedStyle(e).fontSize);e.style.fontSize=`${Math.max(sd,Math.floor(r*n/o*.97))}px`,e.setAttribute(js,""),e.scrollWidth>n?(e.style.whiteSpace="normal",e.style.overflowWrap="anywhere"):e.style.whiteSpace=s}function rd(e,t,n){if(typeof e.querySelectorAll!="function")return;let s=Xt.get(e)??{},o=t?.trim()||void 0;if(!o){if(s.text)for(let i of Array.from(e.querySelectorAll(`[${ze}]`)))i.removeAttribute(ze),i.removeAttribute("aria-label"),n&&(i.textContent=n);s.observer?.disconnect(),Xt.set(e,{name:n});return}if(s.text!==o)for(let i of Array.from(e.querySelectorAll(`[${ze}]`)))i.removeAttribute(ze);s.text=o,s.name=n,Xt.set(e,s),bi(e);let r=e.defaultView;if(!s.observer&&r?.MutationObserver&&e.body){let i=!1;s.observer=new r.MutationObserver(()=>{i||(i=!0,queueMicrotask(()=>{i=!1,bi(e)}))}),s.observer.observe(e.body,{childList:!0,subtree:!0,characterData:!0})}}function id(e,t,n){let s=e.defaultView,o=s?.gamestageSplash;if(!o?.update)return;let r=t.cssVariables??{};o.update({start:t.splashGradientStart||r.backgroundMainColour,end:t.splashGradientEnd||r.backgroundContainerColour,ink:t.titleColour,accent:t.logoAccentColour,play:t.splashPlayLabel,resume:t.splashContinueLabel,error:t.splashErrorText,retry:t.splashRetryLabel});let i=e.querySelector(".gs-boot__logo"),a=()=>s?.gamestageSplash?.fit?.(),d=t.logoText?.trim()||n;i&&d&&i.getAttribute(ze)!==d&&(i.replaceChildren(...In(d).map(f=>{if(!f.accent)return e.createTextNode(f.text);let c=e.createElement("span");return c.className="gs-boot__accent",c.textContent=f.text,c})),i.setAttribute(ze,d),n&&i.setAttribute("aria-label",n),a())}ds();var ad="US1 1 10;AG1 1 10;AI1 1 10;AS1 1 10;BB1 1 10;BM1 1 10;BS1 1 10;CA1 1 10;DM1 1 10;DO1 1 10;GD1 1 10;GU1 1 10;JM1 1 10;KN1 1 10;KY1 1 10;LC1 1 10;MP1 1 10;MS1 1 10;PR1 1 10;SX1 1 10;TC1 1 10;TT1 1 10;VC1 1 10;VG1 1 10;VI1 1 10;RU7 8 10;KZ7 8 10;EG20 0 10;ZA27 0 5.6.7.8.9;GR30 0 10;NL31 0 9.11;BE32 0 9;FR33 0 9;ES34 0 9;HU36 06 9;IT39 0 9.10;VA39 0 9.10;RO40 0 9;CH41 0 9;AT43 0 7.8.9.10.11.12.13;GB44 0 10;GG44 0 10;IM44 0 10;JE44 0 10;DK45 0 8;SE46 0 9;NO47 0 8;SJ47 0 8;PL48 0 9;DE49 0 10.11;PE51 0 9;MX52 0 10;CU53 0 8;AR54 0 10.11;BR55 0 10.11;CL56 0 9;CO57 0 10;VE58 0 10;MY60 0 9.10;AU61 0 9;CC61 0 9;CX61 0 9;ID62 0 9.10.11.12;PH63 0 10;NZ64 0 8.9.10;SG65 0 8;TH66 0 9;JP81 0 10;KR82 0 9.10;VN84 0 9;CN86 0 11;TR90 0 10;IN91 0 10;PK92 0 10;AF93 0 9;LK94 0 9;MM95 0 7.8.9.10;IR98 0 10;SS211 0 9;MA212 0 9;EH212 0 9;DZ213 0 9;TN216 0 8;LY218 0 9;GM220 0 7.9;SN221 0 9;MR222 0 8;ML223 0 8;GN224 0 9;CI225 10;BF226 0 8;NE227 0 8;TG228 0 8;BJ229 10;MU230 0 8;LR231 0 7.9;SL232 0 8;GH233 0 9;NG234 0 10;TD235 0 8;CF236 0 8;CM237 0 9;CV238 0 7;ST239 0 7;GQ240 0 9;GA241 7.8;CG242 9;CD243 0 7.9;AO244 0 9;GW245 0 9;IO246 0 7;AC247 0 5;SC248 0 7;SD249 0 9;RW250 0 9;ET251 0 9;SO252 0 7.8.9;DJ253 0 8;KE254 0 9;TZ255 0 9;UG256 0 9;BI257 0 8;MZ258 0 9;ZM260 0 9;MG261 0 9;RE262 0 9;YT262 0 9;ZW263 0 9;NA264 0 9;MW265 0 9;LS266 0 8;BW267 0 8;SZ268 0 8;KM269 0 7;SH290 0 5;TA290 0 4;ER291 0 7;AW297 0 7;FO298 0 6;GL299 0 6;GI350 0 8;PT351 0 9;LU352 0 9;IE353 0 9;IS354 0 7.9;AL355 0 9;MT356 0 8;CY357 0 8;FI358 0 6.7.8.9.10;AX358 0 6.7.8.9.10;BG359 0 8.9;LT370 0 8;LV371 0 8;EE372 0 7.8;MD373 0 8;AM374 0 8;BY375 8 9;AD376 0 6.9;MC377 0 8.9;SM378 0 8;UA380 0 9;RS381 0 8.9.10;ME382 0 8;XK383 0 8;HR385 0 8.9;SI386 0 8;BA387 0 8.9;MK389 0 8;CZ420 0 9;SK421 0 9;LI423 0 7.9;FK500 0 5;BZ501 0 7;GT502 0 8;SV503 0 8;HN504 0 8;NI505 0 8;CR506 0 8;PA507 0 7.8;PM508 0 6.9;HT509 0 8;GP590 0 9;BL590 0 9;MF590 0 9;BO591 0 8;GY592 0 7;EC593 0 9;GF594 0 9;PY595 0 9;MQ596 0 9;SR597 0 7;UY598 0 8;CW599 0 7.8;BQ599 0 7;TL670 0 8;NF672 0 6;BN673 0 7;NR674 0 7;PG675 0 8;TO676 0 7;SB677 0 5.7;VU678 0 7;FJ679 0 7;PW680 0 7;WF681 0 6;CK682 0 5;NU683 0 4.7;WS685 0 7.10;KI686 0 8;NC687 0 6;TV688 0 6.7;PF689 0 8;TK690 0 4.5.6.7;FM691 0 7;MH692 1 7;KP850 0 10;HK852 0 8;MO853 0 8;KH855 0 8.9;LA856 0 9.10;BD880 0 10;TW886 0 9;MV960 0 7;LB961 0 7.8;JO962 0 9;SY963 0 9;IQ964 0 10;KW965 0 8;SA966 0 9;YE967 0 9;OM968 0 8;PS970 0 9;AE971 0 9;IL972 0 9;BH973 0 8;QA974 0 8;BT975 0 8;MN976 0 8;NP977 0 10;TJ992 0 9;TM993 8 8;AZ994 0 9;GE995 0 9;KG996 0 9;UZ998 0 9",Nn=ad.split(";").map(e=>{let[t,n,s]=e.split(" ");return[t.slice(0,2),t.slice(2),n,s.split(".").map(Number)]});var Zt=new Map(Nn.map(e=>[e[0],e])),cd="GB",dd=`\n.gs-notify-form [hidden]{display:none!important}\n:where(.gs-notify-field){display:grid;gap:12px}\n:where(.gs-notify-via){display:flex;gap:4px;margin:0;padding:4px;border:0;border-radius:10px;background:var(--bg,#fff)}\n:where(.gs-notify-via legend){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}\n:where(.gs-notify-via label){flex:1;display:block;position:relative;cursor:pointer}\n:where(.gs-notify-via input){position:absolute;inset:0;margin:0;opacity:0;cursor:pointer}\n:where(.gs-notify-via span){display:block;padding:10px 12px;border-radius:8px;text-align:center;font-weight:600}\n:where(.gs-notify-via input:checked+span){background:var(--text,#222);color:var(--bg,#fff)}\n:where(.gs-notify-via input:focus-visible+span){outline:3px solid var(--text,#222);outline-offset:2px}\n:where(.gs-notify-phone){display:flex;gap:8px}\n:where(.gs-notify-country){position:relative;flex:none;display:flex;align-items:center;gap:6px;min-height:48px;padding:0 12px;border-radius:10px;background:var(--bg,#fff);white-space:nowrap}\n:where(.gs-notify-country)::after{content:"";width:7px;height:7px;margin:-4px 0 0 2px;border:solid currentColor;border-width:0 2px 2px 0;transform:rotate(45deg)}\n:where(.gs-notify-country select){position:absolute;inset:0;width:100%;opacity:0;cursor:pointer;font:inherit}\n:where(.gs-notify-country:focus-within){outline:3px solid var(--text,#222);outline-offset:3px}\n:where(.gs-notify-phone input){flex:1}\n.gs-notify-form .gs-notify-secondary{min-height:48px;padding:12px 20px;border:1.5px solid currentColor;border-radius:10px;background:transparent;color:inherit;font:inherit;font-weight:600;cursor:pointer}\n.gs-notify-form .gs-notify-secondary:disabled{opacity:.55;cursor:default}\n.gs-notify-form .gs-notify-link{min-height:0;padding:4px 0;border:0;background:none;color:inherit;font:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;justify-self:start}\n:where(.gs-notify-confirm){margin-top:16px}\n:where(.gs-notify-confirm input[name=code]){letter-spacing:.3em;font-variant-numeric:tabular-nums;max-width:12ch}\n:where(.gs-notify-error){margin:0;color:var(--gs-errorColour,#b3261e);font-weight:600}\n`;function ld(e){let t;try{t=new Intl.DisplayNames([e],{type:"region"})}catch{}return Nn.map(([n,s])=>({code:n,name:t?.of(n)??n,dial:`+${s}`})).sort((n,s)=>n.name.localeCompare(s.name,e))}function ud(e){return String.fromCodePoint(...[...e].map(t=>127397+t.charCodeAt(0)))}function fd(){let e=typeof navigator>"u"?[]:[...navigator.languages??[],navigator.language];for(let t of e){let n=t?.split("-").slice(1).find(s=>/^[A-Za-z]{2}$/.test(s))?.toUpperCase();if(n&&Zt.has(n))return n}return cd}function xi(e,t){let n=Zt.get(t);return n&&e.startsWith(n[1])?t:Nn.find(([,s])=>e.startsWith(s))?.[0]}function Bs(e,t){let n=e.trim().replace(/^00/,"+"),s=n.replace(/\\D/g,""),o=Zt.get(t);if(n.startsWith("+")){let c=xi(s,t);if(o=c?Zt.get(c):void 0,!o)return;s=s.slice(o[1].length)}else if(!o)return;let[,r,i,a]=o,d=c=>a.includes(c.length);i&&s.startsWith(i)?s=s.slice(i.length):!n.startsWith("+")&&s.startsWith(r)&&!d(s)&&d(s.slice(r.length))&&(s=s.slice(r.length));let f=`+${r}${s}`;return d(s)&&wn(f,"sms")?f:void 0}function gd(e,t){let n=!1,s=!1,o="",r=typeof navigator>"u"?"en-GB":navigator.language||"en-GB",i,a=new Map,d,f=()=>{d!==void 0&&clearInterval(d),d=void 0},c=(g,l)=>{let S=g?.status??0,p=g?.message;return S>=400&&S<500&&p?p:l};if(typeof document<"u"&&document.head&&!document.head.querySelector?.("style[data-gs-notify]")){let g=document.createElement("style");g.setAttribute("data-gs-notify",""),g.textContent=dd,document.head.append(g)}let u=()=>{if(s)return;let g=e.round?.id??"",l=a.get(g)??{email:"",phone:"",country:fd(),message:"",pending:!1,saved:!1};a.set(g,l);let S=e.presentation.notify,p=JSON.stringify([g,n,S,l.message,l.pending,l.saved,l.awaiting]);if(p===o)return;o=p;let T=t.contains?.(document.activeElement),w=T?document.activeElement?.name:void 0;if(t.hidden=!n||!S?.enabled||!S.ownerName||!/^https:\\/\\//.test(S.privacyUrl)||!S.channels.length,t.replaceChildren(),t.hidden||!S)return;let _=S.labels,k=S.channels.includes("sms")?"sms":S.channels.includes("rcs")?"rcs":void 0,v=S.channels.includes("email");(!l.channel||(l.channel==="email"?!v:!k))&&(l.channel=k?"phone":"email");let h=(A,U)=>{let X=document.createElement(A);return U&&(X.textContent=U),X},N=t.id||"gs-notify",L=h("h2",_.title);L.id=`${N}-title`,t.setAttribute("aria-labelledby",L.id);let C=h("p");if(C.setAttribute("role","status"),C.hidden=!0,t.append(L,C),f(),l.saved){C.textContent=_.success,C.hidden=!1,T&&(C.tabIndex=-1,C.focus());return}if(l.awaiting){let A=l.awaiting,U=A.channel!=="email";C.textContent=A.note||A.sent,C.hidden=!1;let X=h("form");X.className="gs-notify-form gs-notify-confirm",X.noValidate=!0;let Z=h("input"),ne=h("p");if(U){Z.name="code",Z.id=`${N}-code`,Z.autocomplete="one-time-code",Z.inputMode="numeric",Z.maxLength=6,Z.value=A.code,ne.id=`${N}-code-error`,ne.className="gs-notify-error",ne.textContent=A.error,ne.hidden=!A.error,Z.setAttribute("aria-describedby",ne.id),A.error&&Z.setAttribute("aria-invalid","true");let oe=h("label",_.code);oe.append(Z);let m=h("div");m.className="gs-notify-field",m.append(oe,ne);let O=h("button",A.busy?_.pending:_.confirm);O.type="submit",O.disabled=A.busy,X.append(m,O),Z.oninput=()=>{A.code=Z.value.replace(/\\D/g,"").slice(0,6),Z.value!==A.code&&(Z.value=A.code),A.code.length===6&&!A.busy&&yn()}}let se=h("button");se.type="button",se.className="gs-notify-secondary";let Ft=()=>{let oe=Math.ceil((A.resendAt-Date.now())/1e3);se.disabled=oe>0||A.busy,se.textContent=oe>0?_.resend_wait.replaceAll("{seconds}",String(oe)):U?_.resend_code:_.resend_email,oe<=0&&f()};Ft(),A.resendAt>Date.now()&&(d=setInterval(Ft,1e3),d.unref?.());let yt=h("button",_.change_address);yt.type="button",yt.className="gs-notify-link",yt.onclick=()=>{l.awaiting=void 0,l.message="",u()},X.append(se,yt),t.append(X),U&&T&&Z.focus();let yn=async()=>{if(A.busy||A.code.length!==6){A.code.length!==6&&(A.error=_.code_incomplete,u());return}A.busy=!0,A.error="",u();try{if(await e.client.confirmNotify({roundId:g,channel:A.channel,address:A.address,code:A.code}),s)return;l.awaiting=void 0,l.saved=!0}catch(oe){A.error=c(oe,_.error),A.code=""}finally{A.busy=!1,!s&&e.round?.id===g&&u()}};X.onsubmit=oe=>{oe.preventDefault(),yn()},se.onclick=async()=>{A.busy=!0,u();try{let oe=await e.client.resendNotify({roundId:g,channel:A.channel,address:A.address});if(oe.status==="confirmed"){l.awaiting=void 0,l.saved=!0;return}A.resendAt=Date.now()+(oe.resendAfterSeconds??60)*1e3,A.note=_.resent,A.error=""}catch(oe){let m=Number(oe.detail?.retryAfterSeconds);Number.isFinite(m)&&m>0&&(A.resendAt=Date.now()+m*1e3),A.note=c(oe,_.error)}finally{A.busy=!1,!s&&e.round?.id===g&&u()}};return}let H=h("form");H.className="gs-notify-form",H.noValidate=!0;let te=new Map,ce=A=>{let U=te.get(A);U&&(U.hidden=!0,U.textContent=""),A.removeAttribute("aria-invalid")},$=h("input");$.type="email",$.name="email",$.autocomplete="email",$.inputMode="email",$.maxLength=254,$.value=l.email,$.oninput=()=>{l.email=$.value,wn($.value.trim(),"email")&&ce($)};let ge=(A,U)=>{let X=h("p");return X.id=`${N}-${U}-error`,X.className="gs-notify-error",X.hidden=!0,A.setAttribute("aria-describedby",X.id),te.set(A,X),X},_e=ge($,"email"),P=h("label",_.email_address);P.append($);let I=h("div");I.className="gs-notify-field",I.append(P,_e),i??=ld(r);let G=h("select");G.name="country",G.setAttribute("aria-label",_.country);for(let A of i){let U=h("option",`${A.name} (${A.dial})`);U.value=A.code,U.selected=A.code===l.country,G.append(U)}G.value=l.country;let j=h("span");j.setAttribute("aria-hidden","true");let D=()=>{j.textContent=`${ud(l.country)} +${Zt.get(l.country)?.[1]??""}`};D();let V=h("span");V.className="gs-notify-country",V.append(j,G);let R=h("input");R.type="tel",R.name="phone",R.id=`${N}-phone`,R.autocomplete="tel",R.inputMode="tel",R.maxLength=24,R.value=l.phone,R.oninput=()=>{let A=R.value.trim().replace(/^00/,"+"),U=A.startsWith("+")?xi(A.replace(/\\D/g,""),l.country):void 0;U&&U!==l.country&&(l.country=U,G.value=U,D()),l.phone=R.value,Bs(R.value,l.country)&&ce(R)},G.onchange=()=>{l.country=G.value,D(),Bs(R.value,l.country)&&ce(R),R.focus?.()};let re=h("label",_.mobile_number);re.htmlFor=R.id;let q=h("div");q.className="gs-notify-phone",q.append(V,R);let K=h("div");K.className="gs-notify-field";let Oe=ge(R,"phone");K.append(re,q,Oe);let ie=()=>{ce($),ce(R)},Le=()=>{I.hidden=l.channel!=="email",K.hidden=l.channel!=="phone"};if(v&&k){let A=h("fieldset");A.className="gs-notify-via",A.append(h("legend",_.via));for(let[U,X]of[["phone",_.sms],["email",_.email]]){let Z=h("label"),ne=h("input");ne.type="radio",ne.name=`${N}-via`,ne.value=U,ne.checked=l.channel===U,ne.onchange=()=>{l.channel=U,l.message="",C.hidden=!0,ie(),Le()},Z.append(ne,h("span",X)),A.append(Z)}H.append(A)}Le();let Ee=h("p",_.consent.replaceAll("{brand}",S.ownerName)+" "),De=h("a",_.privacy);De.href=S.privacyUrl,De.target="_blank",De.rel="noopener noreferrer",Ee.append(De);let ve=h("button",l.pending?_.pending:_.button);ve.disabled=l.pending,ve.type="submit",H.append(I,K,Ee,ve),t.append(H),C.textContent=l.message,C.hidden=!l.message,(w==="email"||w==="phone")&&(w==="email"?$:R).focus(),H.onsubmit=async A=>{if(A.preventDefault(),l.pending||!e.round||e.round.id!==g)return;l.email=$.value,l.phone=R.value;let U=l.channel==="email",X=U?$:R,Z=U?$.value.trim():Bs(R.value,l.country),ne=U?"email":k;if(ie(),!ne||!Z||!wn(Z,ne)){let se=U?_e:Oe;se.textContent=U?_.invalid_email:_.invalid_mobile,se.hidden=!1,X.setAttribute("aria-invalid","true"),X.focus?.();return}C.hidden=!1,l.pending=!0,o="",ve.disabled=!0,ve.textContent=_.pending,C.textContent="",l.message="";try{let se=await e.client.subscribeNotify({roundId:g,channel:ne,address:Z,consent:{wording:S.wording,termsVersion:S.termsVersion}});if(s)return;["subscribed","already_subscribed"].includes(se.status)?l.saved=!0:se.status==="pending_confirmation"?l.awaiting={channel:ne,address:Z,sent:se.fanMessage,code:"",error:"",note:"",busy:!1,resendAt:Date.now()+(se.resendAfterSeconds??60)*1e3}:l.message=se.fanMessage}catch(se){l.message=c(se,_.error)}finally{l.pending=!1,!s&&e.round?.id===g&&u()}}},y=async()=>{if(s||typeof document>"u"||document.visibilityState!=="visible")return;let g=e.round?.id??"",l=a.get(g),S=l?.awaiting,p=e.presentation.notify;if(!(!l||!S||S.channel!=="email"||S.busy||!p))try{let T=await e.client.subscribeNotify({roundId:g,channel:S.channel,address:S.address,consent:{wording:p.wording,termsVersion:p.termsVersion}});!s&&["subscribed","already_subscribed"].includes(T.status)&&l.awaiting===S&&(l.awaiting=void 0,l.saved=!0,u())}catch{}};typeof document<"u"&&document.addEventListener?.("visibilitychange",y);let b=e.onRoundChanged(()=>{n=!1,u()}),x=e.onPresentationChanged(u);return u(),{update(g){n=g?.finished===!0&&g.outcome==="pending",u()},destroy(){s=!0,f(),b(),x(),typeof document<"u"&&document.removeEventListener?.("visibilitychange",y),t.replaceChildren(),t.hidden=!0}}}var Bl=new Set(["comment"]);function Fa(e){let n=e.outcome==="accepted"||e.outcome==="duplicate"?e.round_state?.progress?.guesses?.at(-1):void 0;return n?{...e,guessed:n}:e}function Ng(e,t){if(!t?.finished||t.outcome!=="won"||!e||e.plays<2)return null;let n=t.progress?.guesses;if(!Array.isArray(n)||n.length===0)return null;let s=n.length,o=0;for(let[r,i]of Object.entries(e.pick_shares??{}))typeof i!="number"||!(i>0)||(r==="X"||/^\\d+$/.test(r)&&Number(r)>s)&&(o+=i);return Math.max(0,Math.min(100,Math.round(o*100)))}function zl(e){let t=e.GAMESTAGE_API,n=e.GAMESTAGE_GAME;if(!t||!n)throw new Error("This game has no Gamestage configuration. `window.GAMESTAGE_API` and `window.GAMESTAGE_GAME` are written by `gamestage deploy` and printed by `gamestage dev`.");return{api:t,game:n}}function hn(e,t){let n=new URLSearchParams(t??""),s=o=>{let r=n.get(o);return r&&r.trim()?r.trim():void 0};return{host:s("h")??e.GAMESTAGE_IC_HOST,projectId:s("p")??e.GAMESTAGE_IC_PROJECT,eventId:s("e")??e.GAMESTAGE_IC_EVENT,locale:s("locale")??e.GAMESTAGE_LOCALE,theme:s("theme")??e.GAMESTAGE_THEME}}function Ko(e,t=globalThis.navigator){let n=e.locale??t?.languages?.[0]??t?.language;return n&&n.trim().split(/[-_]/)[0].toLowerCase()||void 0}var ja=3e4;async function Hl(e,t,n){let s=`${e.replace(/\\/+$/,"")}/public/v1/platform/${encodeURIComponent(t)}`;try{let o=AbortSignal.timeout?AbortSignal.timeout(ja):void 0,r=await n(s,o?{signal:o}:void 0);if(!r.ok)return{because:r.status===404?`${t} is not on Interaction Cloud: the control plane answered 404.`:`asking for this game\'s platform ids answered ${r.status}.`};let i=await r.json(),a=typeof i.project=="string"?i.project:void 0,d=typeof i.host=="string"?i.host:void 0,f=typeof i.name=="string"&&i.name.trim()?i.name:void 0;if(!a||!d)return{because:"the control plane answered without both a project and a host, so there is nothing connectable to use."};let c=typeof i.analytics_url=="string"&&/^https:\\/\\//.test(i.analytics_url)?i.analytics_url:void 0,u=i.services?.comments,y=typeof u?.topic_id=="string"&&typeof u.api=="string"&&/^https:\\/\\//.test(u.api)?{topicId:u.topic_id,api:u.api}:void 0;return{host:d,projectId:a,name:f,analyticsUrl:c,comments:y}}catch(o){return{because:o instanceof Error&&(o.name==="TimeoutError"||o.name==="AbortError")?`the control plane did not answer within ${ja/1e3}s, so this page is playing the round without a Studio connection. A producer\'s words and live updates will reach the next load.`:`asking for this game\'s platform ids failed: ${o instanceof Error?o.message:String(o)}`}}}function Vl(e,t){return t?{...e,forms:t}:e}async function Kl(e,t,n){let s=hn(e,t),o=s.host,r=s.projectId,i=s.eventId,a,d,f,c;if((!o||!r)&&e.GAMESTAGE_IC_LOOKUP&&n?.api&&n?.game){n?.step?.("looking-up");let u=await Hl(n.api,n.game,n.fetch??fetch);o??=u.host,r??=u.projectId,d=u.name,f=u.analyticsUrl,c=u.comments,a=u.because}else(!o||!r)&&e.GAMESTAGE_IC_LOOKUP&&(a="this page carries no Interaction Cloud ids and no API to ask for them.");if((!o||!r)&&e.GAMESTAGE_IC_LOOKUP)throw new Error(a??"this game could not reach Interaction Cloud and there is no reason recorded.");return!o||!r?{deployedName:d,projectId:r,platform:Ls({pollMilliseconds:5e3,offPlatformReason:a,...typeof e.GAMESTAGE_LIVE_SOURCE=="string"?{liveSource:e.GAMESTAGE_LIVE_SOURCE}:{},presentation:Vl(at(e.GAMESTAGE_PRESENTATION,Ko(s)),Or(e.GAMESTAGE_PRESENTATION)),signInSettings:zt(e.GAMESTAGE_PRESENTATION,Ko(s))})}:{deployedName:d,projectId:r,analyticsUrl:f,comments:c,platform:await Wl({host:o,projectId:r,eventId:i,locale:Ko(s),settingsConsent:n?.settingsConsent},n?.step)}}async function Wl(e,t){t?.("loading-kits");let n=await Promise.resolve().then(()=>(Ua(),Ga));return t?.("opening"),n.createMonterosaPlatform(e)}async function Pg(e={}){let t=e.globals??globalThis.window??globalThis,{api:n,game:s}=zl(t),o=e.search??globalThis.location?.search,r=m=>{try{e.onStep?.(m)}catch{}},i=()=>({declared:!1,categories:{}}),a=e.platform!==void 0?Promise.resolve({platform:e.platform,deployedName:void 0}):Kl(t,o,{api:n,game:s,fetch:e.fetch,step:r,settingsConsent:()=>i()});a.catch(()=>{});let d=t.location??globalThis.location,f=e.signIn!==!0||typeof document>"u"||!d?.hostname?void 0:Br({game:s,hostname:d.hostname,fetch:e.fetch,document,store:globalThis.localStorage,mayRemember:()=>Et(i(),"functional"),session:()=>rs(s)});f?.state==="off"&&f.stop();let c=f&&f.state!=="off"?f:void 0,y=!me(await de(e.identity))&&c?c.begin():void 0;y&&c?.rememberedGranted()&&await Promise.race([y,new Promise(m=>setTimeout(m,1500))]);let b=async()=>me(await de(e.identity))??await c?.token()??void 0,x=await de(b),g=t.GAMESTAGE_HOST_OWNS_CONSENT===!0,l={analyticsRequiresConsent:g||(e.consent?.analyticsRequiresConsent??!0)},S,p=()=>S?.reading()??{declared:!1,categories:{necessary:!0}},T=Gr({policy:l,destinations:e.destinations??[],consent:p}),w=null,_=!1,k=()=>{if(w||_)return;let m=Jl(C.presentation?.analyticsUrl,ce);!m||!te||ct(l,p())&&(_=!0,jr({game:s,projectId:te,serviceUrl:m,now:()=>C.clock.now(),onObservation:O=>{T.track(O)}}).then(O=>{w=O}).catch(()=>{}).finally(()=>{_=!1}))},v=()=>{w?.stop(),w=null},h=tr({baseUrl:n,game:s,fetch:e.fetch,identity:async()=>(x=await de(b),me(x))}),N=t.GAMESTAGE_FORMAT==="arcade"||t.GAMESTAGE_FORMAT==="mystery"||t.GAMESTAGE_FORMAT==="quiz";N||r("fetching-round");let L=N?Promise.resolve({ok:"none"}):h.getCurrentRound().then(m=>({ok:!0,value:m}),m=>({ok:!1,cause:m})),{platform:C,deployedName:H,projectId:te,analyticsUrl:ce,comments:$}=await a;if(C.settingsSource?.()==="none"){let m=t,O=globalThis;throw Jr({document:m.document??O.document,location:m.location??O.location}),new Yt}let ge=ts(t),_e=()=>ir(rr(C.presentation?.gate,ge),g),P=_e(),I=bn(P,s),G=async(m=P)=>{if(!m)return!1;try{return await h.declare(jt(m)),!0}catch{return!1}},j=I.then(()=>G()),D,V=()=>{if(D)return D;let m=_e()??P;return m?(P=m,D=(async()=>(os(s),await bn(m,s),G(m)))().finally(()=>{D=void 0}),D):Promise.resolve(!1)};S=As({platform:C,policy:l,game:s,scope:e.consentScope,policyVersion:C.presentation?.consentPolicyVersion,embedOrigins:C.presentation?.embedOrigins,hostManagesConsent:Os(typeof document>"u"?void 0:document,C.presentation?.oneTrustId,g),hostOwnsConsent:g}),i=p,S.onChange(m=>{ct(l,m)?k():v(),C.rememberSettings?.()}),C.rememberSettings?.(),k();let R,re={reading:p,allowed:()=>dt(l,p()),record:()=>S?.record()??null,needed:()=>S?.needed()??l.analyticsRequiresConsent,hostDecides:()=>S?.hostDecides()??!1,decide:m=>S?.decide(m)??!1,declare:m=>S?.decide(m)??!1,onChange:m=>S?.onChange(m)??(()=>{}),openSettings:()=>R?.open()};if(await I,typeof document<"u"&&e.consentBanner!==!1&&!g&&(R=Ps({presentation:C.presentation,consent:re},e.consentBanner??{})),c&&y){let m=()=>{if(re.needed())return;let O=C.presentation??{},pe=O.cssVariables??{};c.offer({playAs:O.signInPlayAsLabel,detail:O.signInDetail,dismiss:O.signInDismissLabel},{accent:pe.highlightMainColour??O.primaryColour,onAccent:pe.onHighlightMainColour,surface:pe.backgroundMainColour,text:pe.onBackgroundMainColour})};y.then(m),re.onChange(()=>m()),c.onChange(O=>{O==="granted"&&de(b).then(pe=>{x=pe})})}let q,K=new Set,Oe=async(m=!1)=>{if(!N)try{let O=await h.getCurrentRound();return Ct(C.clock,O.server_time),q=O,O}catch(O){if(m)throw O;return}},ie=await L,Le=ie.ok==="none"||ie.ok===!1&&ie.cause instanceof Error&&ie.cause.status===404&&["not_found","no_round"].includes(ie.cause.code??"");if(ie.ok===!1&&!Le)throw ie.cause;ie.ok===!0&&(Ct(C.clock,ie.value.server_time),q=ie.value);let Ee=(m,O)=>m!==void 0&&m.id===O.id&&m.version===O.version&&(m.settled_revision??0)===(O.settled_revision??0)&&m.provisional===O.provisional&&m.challenge_instance_id===O.challenge_instance_id,De,ve=C.onRoundAnnounced(()=>{(async()=>{let m=q,O=await Oe();if(O&&!Ee(m,O))for(let pe of[...K])pe(O)})()},()=>!!(q&&(q.provisional===!0||q.awaits_settlement===!0&&!q.can.results_available&&(q.can.closed||(q.locks_at?C.clock.now()>=Date.parse(q.locks_at):De===q.id))))),A=!1,U=(()=>{let m=Ts(C.presentation),O=e.busy?.copy;return{atCapacity:{...m.atCapacity,...O?.atCapacity??{}},rateLimited:{...m.rateLimited,...O?.rateLimited??{}},cappedToday:{...m.cappedToday,...O?.cappedToday??{}}}})();function X(m,O){if(e.busy?.enabled!==!1)try{xs(m,{copy:U,...e.busy?.container===void 0?{}:{container:e.busy.container},...e.busy?.document?{document:e.busy.document}:{},...O===void 0?{}:{retryAfterSeconds:O}})}catch{}}let Z=typeof globalThis.document>"u"?()=>{}:ei(()=>({game:s,platform:C.kind,offPlatformReason:C.offPlatformReason,ids:{project:C.projectId??hn(t,o).projectId,event:hn(t,o).eventId,host:hn(t,o).host},round:q?{id:q.id,version:q.version,number:q.number,origin:q.origin}:void 0,endpoints:{playerApi:n,mesh:hn(t,o).host},identity:{kind:x.kind,signedIn:x.kind!=="anonymous"},consent:{allowed:dt(l,p())},presentation:C.presentation}),globalThis),ne=!!e?.optimistic&&q?.can.optimistic_play===!0,se,Ft=as({api:n,game:s,fetch:e.fetch,token:async()=>me(await de(e.identity))??h.spaceToken(),gameToken:async()=>me(await de(e.identity))?void 0:await c?.token()}),yt=_s({api:n,game:s,fetch:e.fetch,token:async()=>me(await de(e.identity))??h.spaceToken(),gameToken:async()=>me(await de(e.identity))?void 0:await c?.token(),words:async m=>(await C.elementFields?.(m)??[]).flatMap(O=>vs(O.id,O.fields)??[]),outcomeWords:async m=>(await C.elementFields?.(m)??[]).flatMap(O=>Ss(O.id,O.fields)??[])}),yn=t.GAMESTAGE_FORMAT==="arcade"?Ql(h,Ft,{returning:rs(s)!==void 0||!!me(x)}):h,oe=$?cs({api:$.api,topicId:$.topicId,fanToken:()=>h.commentsToken(),fetch:e.fetch}):null;return await j,{platform:C.kind,optimistic:ne,id:s,get eventId(){return C.eventId},client:yn,arcade:Ft,quiz:yt,comments:oe,streak:async()=>!me(await de(e.identity))&&c?.state==="granted"?Ms(await c.streak()):Rs({baseUrl:e.loyalty?.baseUrl,identity:b,fetchImpl:e.fetch}),presentation:C.presentation,get signInSettings(){return C.signInSettings},get needsSignIn(){return!!C.signInSettings?.enabled&&!me(x)},settingsSource:()=>C.settingsSource?.()??"studio",analytics:T,now:()=>C.clock.now(),deployedName:H,projectId:te,offPlatformReason:C.offPlatformReason,get identity(){return x},async refreshIdentity(){return x=await de(b),x},signIn:{get state(){return c?.state??"off"},onChange(m){return c?.onChange(m)??(()=>{})},requiredFor(m){return Bl.has(m)},async request(){if(!c)return"off";let m=C.presentation??{},O=m.cssVariables??{};return c.request({playAs:m.signInPlayAsLabel,detail:m.signInDetail,dismiss:m.signInDismissLabel},{accent:O.highlightMainColour??m.primaryColour,onAccent:O.onHighlightMainColour,surface:O.backgroundMainColour,text:O.onBackgroundMainColour})}},get round(){return q},onRoundChanged(m){return K.add(m),()=>K.delete(m)},async playNext(){let m=await h.getNextRound();if(m.status!=="ready"||!m.round)return"exhausted";Ct(C.clock,m.server_time),q=m.round;for(let O of K)O(m.round);return"ready"},onPresentationChanged(m){return C.onPresentationChanged(m)},live(m){return m?kn(C,m):se??=kn(C)},async play(m){let O=q??await Oe();if(!O)throw new Error("There is no round to play. The Engine did not return one.");let pe=m.idempotencyKey??is(),Ae=async()=>{try{return await h.play(O.id,{...m.picks?{picks:m.picks}:{},...m.answers?{answers:m.answers}:{},...m.op?{op:m.op}:{},...m.centre!==void 0?{centre:m.centre}:{},...m.board!==void 0?{board:m.board}:{},...m.operation?{operation:m.operation}:{},...m.room?{room:m.room}:{},roundVersion:O.version},pe)}catch(Ie){throw Ie?.status===429&&X("rateLimited"),Ie&&typeof Ie=="object"&&(Ie.idempotency_key=pe),Ie}},$e=await Ae();if($e.outcome==="rejected"&&$e.reason==="declaration_required"&&await V()&&($e=await Ae()),$e.outcome==="busy"){let Ie=$e;X(Cs(Ie.reason),Ie.retry_after_seconds)}return Ct(C.clock,$e.server_time),($e.outcome==="accepted"||$e.outcome==="duplicate")&&(De=O.id),{...$e,idempotency_key:pe}},async shoot(m){let{idempotencyKey:O,...pe}=m,Ae=await this.play({operation:bt(pe),idempotencyKey:O}),Ie=Ae.outcome==="accepted"||Ae.outcome==="duplicate"?vn(_n(Ae.round_state)):void 0;return Ie?{...Ae,shot:Ie}:Ae},async draw(m={}){let O=await this.play({operation:{op:"draw"},idempotencyKey:m.idempotencyKey}),Ae=O.outcome==="accepted"||O.outcome==="duplicate"?O.round_state?.progress?.drawn?.at(-1):void 0;return Ae?{...O,drawn:Ae}:O},async solve(m,O={}){return this.play({operation:{op:"solve",text:m},idempotencyKey:O.idempotencyKey})},async guess(m,O={}){return Fa(await this.play({operation:{op:"guess",value:m},idempotencyKey:O.idempotencyKey}))},async skip(m={}){return Fa(await this.play({operation:{op:"skip"},idempotencyKey:m.idempotencyKey}))},track(m,O={}){return w?.track(m,O),T.track({name:m,properties:O,at:C.clock.now()})},consent:re,storage:{read:m=>dt(l,p())?C.storage.read(m):Promise.resolve(null),write:async(m,O)=>dt(l,p())?(await C.storage.write(m,O),!0):!1,remove:async m=>dt(l,p())?(await C.storage.remove(m),!0):!1},stop(){Z(),!A&&(A=!0,ve(),K.clear(),v(),R?.stop(),S?.stop(),c?.stop(),C.stop())}}}var Yl=5e3;function Ql(e,t,{returning:n}){let s=async()=>{try{let{ticket:r}=await e.getNameTicket();await t.setName(r)}catch(r){let i=r?.code??"unknown";console.warn(`gamestage: the chosen name did not reach the board (${i}). Play carries on.`)}},o=async()=>{let r;try{await Promise.race([s(),new Promise(i=>r=setTimeout(i,Yl))])}finally{clearTimeout(r)}};return n&&e.getProfile().then(r=>r.name_chosen?s():void 0).catch(()=>{}),{...e,async setIdentity(r){let i=await e.setIdentity(r);return r.name&&await o(),i}}}function Jl(e,t){if(t)return e?.trim()||t}export{$r as ANALYTICS_CATEGORY,vt as ArcadeError,lt as BUSY_MODAL_ID,Es as DEFAULT_BUSY_COPY,er as GOAL_GEOMETRY,Yt as GamestageUnavailableError,wt as QuizError,ni as SETTINGS_CACHE_CATEGORY,Zo as SHOOT_INPUT,Si as TITLE_SELECTOR,An as UNAVAILABLE_COPY,ct as analyticsAllowed,qc as applyPresentation,Cs as busyKindFor,as as createArcadeClient,Kt as createClock,cs as createCommentsClient,As as createConsentState,kn as createLiveContest,Ls as createLocalPlatform,Wl as createMonterosaPlatform,_s as createQuizClient,nc as editionBoard,On as flatten,os as forgetGate,vi as gamestageUiTokens,ts as gateFrom,jt as gateKey,Et as granted,Ng as guessBetterThan,Jo as hasDeclared,Os as hostRunsConsentManager,Gs as hostname,vn as latestShot,Ko as localeFor,Ps as mountConsent,gd as mountNotify,$c as mountProvisionalResult,Fc as mountRecovery,is as newIdempotencyKey,bn as passGate,ns as placeNames,hn as platformIds,ai as provisionalResultText,Ss as quizOutcomeFromFields,vs as quizWordsFromFields,Oc as readLoyalty,Rs as readStreak,Ts as resolveBusyCopy,de as resolveIdentity,Ct as sampleIso,si as settingsCacheAllowed,bt as shootOperation,_n as shootProgressOf,xs as showBusyModal,ks as signInMemoryKey,Jl as signalAddress,qr as siteForGame,Pg as start,dt as storageAllowed,Dc as streakFrom,wi as titleTreatment,me as tokenOf};\n/*! Bundled license information:\n\n@monterosa/sdk-util/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @preserve\n * Global object polyfill.\n * Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\n *\n * @internal\n *\n * @returns typeof globalThis\n *)\n (**\n * @license\n * fromentries.ts\n * util\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * checksum.ts\n * util\n *\n * Copyright \xA9 2025 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2022-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-core/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2023-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2021-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-bridge-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2022-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-storage-kit/dist/index.js:\n (**\n * @license\n * types.ts\n * storage-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * storage_impl.ts\n * storage-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-storage-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * api.ts\n * storage-kit\n *\n * Copyright \xA9 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-enmasse-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-enmasse-kit\n *\n * Copyright \xA9 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-connect-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-connect-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-connect-kit\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-consent-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-analytics-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-analytics-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-analytics-kit\n *\n * Copyright \xA9 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-interact-interop/dist/index.js:\n (**\n * @license\n * api.ts\n * interact-interop\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-interact-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n*/\n//# sourceMappingURL=https://gamestage.ai/client/0.116.0/gamestage.js.map\n',fs="52e4687063a6fe3a",Tn="gamestage.js",gs="0.116.0",mde=`<!doctype html>
|
|
899
|
+
`,fu="48fd8242624ce764",Vo="gamestage-player.js",Zs='/**\n * @monterosa/gamestage, bundled for a browser.\n * Gamestage client 0.117.0.\n *\n * Generated by the Gamestage CLI. Do not edit: it is replaced whenever the CLI\n * writes it again, and it carries no game logic of yours. Minified; its source\n * map is beside it on gamestage.ai.\n */\nvar es=Object.defineProperty;var Ba=Object.getOwnPropertyDescriptor;var za=Object.getOwnPropertyNames;var Ha=Object.prototype.hasOwnProperty;var ee=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(s){throw n=[s],s}};var Wo=(e,t)=>{for(var n in t)es(e,n,{get:t[n],enumerable:!0})},Va=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of za(t))!Ha.call(e,o)&&o!==n&&es(e,o,{get:()=>t[o],enumerable:!(s=Ba(t,o))||s.enumerable});return e};var Ka=e=>Va(es({},"__esModule",{value:!0}),e);function sr(e,t){let n=a=>{let l=e[a],p=l&&typeof l=="object"?l:void 0,c=p?[t,"all","en",...Object.keys(p)].filter(u=>!!u).map(u=>p[u]).find(u=>typeof u=="boolean"||typeof u=="string"&&u.trim()):l;return typeof c=="boolean"?String(c):typeof c=="string"?c.trim():""},s=Object.fromEntries(Object.entries(ac).map(([a,l])=>[a,n(`label_notify_${a}`)||l])),o=n("consent_brand_name"),r=n("privacy_policy_url"),i=(n("notify_channels")||"email").split(",").map(a=>a.trim()).filter(a=>["email","sms","rcs"].includes(a));return{enabled:["true","yes","1"].includes(n("notify_enabled")),channels:i,ownerName:o,privacyUrl:r,labels:s,termsVersion:n("notify_terms_version")||"2",wording:`${s.consent.replaceAll("{brand}",o)} ${s.privacy}`}}function wn(e,t){return t==="email"?e.length<=254&&/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(e):/^\\+[1-9]\\d{6,14}$/.test(e)}var ac,ds=ee(()=>{"use strict";ac={title:"Tell me my result",via:"Send my result by",email:"Email",sms:"Text message",email_address:"Email address",mobile_number:"Mobile number",country:"Country",consent:"{brand} will use these details to tell you your result. You can unsubscribe at any time.",privacy:"Privacy policy",button:"Notify Me",pending:"Saving\\u2026",success:"Done. We\'ll tell you after full time.",error:"That did not work. Please try again.",invalid_email:"Enter an email address, such as name@example.com.",invalid_mobile:"Enter a complete mobile number for the country you picked.",code:"6-digit code",code_incomplete:"Enter all 6 digits.",confirm:"Confirm",resend_code:"Send a new code",resend_email:"Send the email again",resend_wait:"Send again in {seconds}s",resent:"Sent. Check again.",change_address:"Use a different number or email"}});function En(e,t){if(!e||typeof e!="object"||Array.isArray(e))return e;let n=e;for(let s of[t,"all","en",...Object.keys(n)])if(s&&n[s]!==void 0&&n[s]!==null&&n[s]!=="")return n[s]}function rr(e,t){if(!e)return{};let n={},s=En(e.gate_age_required,t),o=typeof s=="boolean"?s:typeof s=="string"?s.trim().toLowerCase():void 0;o===!0||o==="true"||o==="yes"||o==="1"?n.ageRequired=!0:(o===!1||o==="false"||o==="no"||o==="0")&&(n.ageRequired=!1);let r=En(e.gate_minimum_age,t),i=typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r.trim()):NaN;Number.isInteger(i)&&i>0&&i<=120&&(n.minimumAge=i);let a=En(e.gate_territories,t);if(typeof a=="string"&&a.trim()){let p=a.split(/[\\s,;]+/).map(c=>c.trim().toUpperCase()).filter(c=>/^[A-Z]{2}$/.test(c));n.territories=[...new Set(p)]}let l=En(e.gate_note,t);return typeof l=="string"&&l.trim()&&(n.note=l.trim().slice(0,200)),n}function ir(e,t){let n=e??{},s=n.ageRequired!==void 0;if(!(s||n.minimumAge!==void 0||n.territories!==void 0||n.note!==void 0))return t?{...t}:void 0;let i=n.ageRequired??!!t?.minimumAge?n.minimumAge??t?.minimumAge??cc:void 0,a=n.territories?.length?n.territories:n.territories!==void 0||!s?t?.territories:void 0,l=n.note??(s?void 0:t?.note);if(!(!i&&!a?.length))return{...i?{minimumAge:i}:{},...a?.length?{territories:[...a]}:{},...l?{note:l}:{}}}function ar(e,t){if(!e||t!==!0||!e.minimumAge)return e;if(e.territories?.length)return{territories:[...e.territories],...e.note?{note:e.note}:{}}}var or,cc,ls=ee(()=>{"use strict";or=["gate_age_required","gate_minimum_age","gate_territories","gate_note"];cc=18});function Cn(e){let t=Array.isArray(e)?e.filter(s=>typeof s=="string"):typeof e=="string"?e.split(/[\\s,]+/):[],n=new Set;for(let s of t){let o=s.trim();if(!/^[a-z][a-z0-9+.-]*:\\/\\/[^/?#@*\\s]+\\/?$/i.test(o))continue;let r;try{r=new URL(o)}catch{continue}let i=r.hostname==="localhost"||r.hostname==="127.0.0.1";r.protocol!=="https:"&&!(r.protocol==="http:"&&i)||n.add(r.origin)}return[...n]}function lc(){return{necessary:!0,analytics:!1,marketing:!1,functional:!1}}function qt(e,t,n={}){let s=lc();for(let o of cr)o!=="necessary"&&(s[o]=e[o]===!0);return{version:1,categories:s,source:t,decidedAt:(n.at??new Date).toISOString(),policyVersion:n.policyVersion??us,jurisdiction:n.jurisdiction??dc}}function ur(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||t.source!=="host"&&t.source!=="fan"&&t.source!=="default"||typeof t.decidedAt!="string"||typeof t.policyVersion!="string"||typeof t.jurisdiction!="string"||!t.categories||typeof t.categories!="object")return null;let n=t.categories;for(let s of cr)if(typeof n[s]!="boolean")return null;return qt(n,t.source,{policyVersion:t.policyVersion,jurisdiction:t.jurisdiction,at:new Date(t.decidedAt)})}function pr(e,t){let n=t.trim();if(e.includes("{brand}")){let s=!n||n.toLowerCase()==="monterosa";return e.includes("{brand} and Monterosa, who run")?s?e.replace("{brand} and Monterosa, who run","Monterosa, who runs").replaceAll("{brand}","Monterosa"):e.replaceAll("{brand}",n):e.replaceAll("{brand}",n||"Monterosa")}return e}var cr,dr,lr,dc,us,gr,fr,Tn=ee(()=>{"use strict";cr=["necessary","analytics","marketing","functional"],dr="gamestage:consent:v1",lr="gamestage:consent";dc="GB",us="1";gr="https://gamestage.ai/copyright",fr={brand:"",title:"Your privacy",detail:"{brand} would like to record analytics on how you play, so we can improve the game. We only do this if you agree. Data needed to run the game, such as your scores, is processed on the basis of legitimate interests.",accept:"Accept",reject:"Reject",dismiss:"Close",choose:"Manage preferences",save:"Save my choices",necessary:"Needed for the game to work. Always on.",analytics:"Measure how the game is played",marketing:"Offers and news from the game\'s owner",functional:"Remember my preferences",settings:"Privacy settings",policy:"Privacy policy",copyright:"Report copyright infringement"}});function Ce(e,t){if(typeof e=="string")return e.trim()||void 0;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"]){if(!s)continue;let o=n[s];if(typeof o=="string"&&o.trim())return o.trim()}}function fc(e,t){if(typeof e=="boolean")return e;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"])if(s&&typeof n[s]=="boolean")return n[s]}function pc(e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e,o=("data"in n?n:[t,"all","en"].map(i=>i?n[i]:void 0).find(i=>i&&typeof i=="object"))?.data,r=Array.isArray(o)?o[0]?.id:void 0;if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}function mc(e){let t=e?.submissions;if(!Array.isArray(t))return;let n=t.find(o=>o?.name==="webservice"),s=typeof n?.data=="string"?n.data.trim().replace(/\\/+$/,""):"";return/^https?:\\/\\/[^\\s/]+$/.test(s)?s:void 0}function hs(e,t,n){let s=mc(t);if(!e||!s)return;let o={};for(let r of Object.keys(e)){if(!r.startsWith(fs)||r===fs)continue;let i=pc(e[r],n);i&&(o[r.slice(fs.length)]={id:i,host:s})}return Object.keys(o).length>0?o:void 0}function Ar(e){let t=e?.forms;if(!t||typeof t!="object"||Array.isArray(t))return;let n={};for(let[s,o]of Object.entries(t)){let{id:r,host:i}=o??{};typeof r=="string"&&r!==""&&typeof i=="string"&&i.startsWith("https://")&&(n[s]={id:r,host:i})}return Object.keys(n).length>0?n:void 0}function hc(e,t=ys){return`${t}/fonts/${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.css`}function bs(e){return e.replace(/[^\\p{L}\\p{N} \\-]/gu,"").trim()}function Ir(e,t){if(!e)return;let n=Object.keys(ps).find(i=>i.toLowerCase()===e.trim().toLowerCase());if(!n)return;let s=ps[n],o=Number(t);if(!Number.isFinite(o))return{family:n,weight:s[s.length-1]};let r=[...s].sort((i,a)=>Math.abs(i-o)-Math.abs(a-o)||a-i)[0];return{family:n,weight:r}}function Nr(e){if(e===void 0)return;let t=/^\\s*(-?(?:\\d+\\.?\\d*|\\.\\d+))(?:em)?\\s*$/i.exec(e);if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return`${Math.min(.4,Math.max(-.1,n))}em`}function Pr(e){let t=e?.trim().toLowerCase();if(t)return["upper","uppercase","capitals","caps"].includes(t)?"uppercase":["none","uppercase","lowercase","capitalize"].includes(t)?t:"none"}function yc(e,t){let n=Ce(e.sponsor_name,t);if(!n)return;let s=Ce(e.sponsor_logo,t),o=Ce(e.sponsor_link,t);return{name:n,label:Ce(e.sponsor_intro,t)||"In association with",...s&&ms.test(s)?{logoUrl:s}:{},...o&&ms.test(o)?{link:o}:{}}}function Bt(e,t){let n=e?.trim();if(!n)return null;let s=t.find(r=>r.name.trim().toLowerCase()===n.toLowerCase());if(s){let r=bs(s.name);if(r)return{family:r}}let o=Object.keys(ps).find(r=>r.toLowerCase()===n.toLowerCase());return o?{family:o,stylesheetHref:hc(o)}:null}function at(e,t){let n={};if(!e)return n;if("notify_enabled"in e&&(n.notify=sr(e,t)),or.some(m=>m in e)){let m=rr(e,t);Object.keys(m).length>0&&(n.gate=m)}for(let[m,_]of Object.entries(uc)){let g=Ce(e[m],t);g&&(n[_]=g)}for(let[m,_]of Object.entries(gc)){if(n[_])continue;let g=Ce(e[m],t);g&&(n[_]=g)}let s=Ce(e.analytics_oneTrustId,t);s&&(n.oneTrustId=s);let o=Cn(Ce(e.embed_origins,t));o.length&&(n.embedOrigins=o);let r=Ce(e.logo_url,t)?.replace(/^\\/\\//,"https://");r&&ms.test(r)&&(n.logoUrl=r);let i=yc(e,t);i&&(n.sponsor=i);let a=Ce(e.default_font_family,t);a&&(n.defaultFontFamily=a);let l=e.uploaded_fonts;if(Array.isArray(l)){let m=g=>typeof g=="string"?g.trim():g==null?"":String(g),_=l.map(g=>g&&typeof g=="object"?g:{}).map(g=>({name:m(g.name),url:m(g.file),weight:m(g.weight)})).filter(g=>g.name&&g.url);_.length&&(n.uploadedFonts=_)}let p="css_variables_",c={};for(let m of Object.keys(e)){if(!m.startsWith(p))continue;let _=Ce(e[m],t);_&&(c[m.slice(p.length)]=_)}Object.keys(c).length>0&&(n.cssVariables=c);let u={};for(let m of Object.keys(e)){if(!m.startsWith(mr))continue;let _=Ce(e[m],t);_&&(u[m.slice(mr.length)]=_)}Object.keys(u).length>0&&(n.labels=u);let h={};for(let m of Object.keys(e)){if(!m.startsWith(gs)||m===gs)continue;let _=fc(e[m],t);_!==void 0&&(h[m.slice(gs.length)]=_)}return Object.keys(h).length>0&&(n.options=h),n}var hr,yr,br,_r,vr,Sr,wr,Er,Cr,Tr,xr,kr,Or,uc,gc,mr,gs,fs,ps,ys,ms,St=ee(()=>{"use strict";ds();ls();Tn();hr="Provisional result. Final at {finalAt}.",yr=["a","b","c","d","e","f"],br=e=>`quiz_option_${e}`,_r="quiz_question",vr="quiz_image",Sr="quiz_image_alt",wr="quiz_media",Er=e=>`quiz_option_${e}_image`,Cr="quiz_outcome_name",Tr="quiz_outcome_verdict",xr="quiz_outcome_why",kr="quiz_outcome_image",Or="quiz_outcome_image_alt",uc={display_name:"displayName",title_font:"titleFont",title_font_weight:"titleFontWeight",title_letter_spacing:"titleLetterSpacing",title_colour:"titleColour",title_case:"titleCase",logo_text:"logoText",logo_accent_colour:"logoAccentColour",splash_gradient_start:"splashGradientStart",splash_gradient_end:"splashGradientEnd",splash_play_label:"splashPlayLabel",splash_continue_label:"splashContinueLabel",splash_error_text:"splashErrorText",splash_retry_label:"splashRetryLabel",consent_brand_name:"consentBrandName",consent_title:"consentTitle",consent_detail:"consentDetail",consent_accept_label:"consentAcceptLabel",consent_reject_label:"consentRejectLabel",consent_choose_label:"consentChooseLabel",consent_save_label:"consentSaveLabel",consent_analytics_label:"consentAnalyticsLabel",consent_marketing_label:"consentMarketingLabel",consent_functional_label:"consentFunctionalLabel",consent_settings_label:"consentSettingsLabel",consent_policy_version:"consentPolicyVersion",privacy_policy_url:"privacyPolicyUrl",signin_play_as_label:"signInPlayAsLabel",signin_detail:"signInDetail",signin_dismiss_label:"signInDismissLabel",recovery_open_label:"recoveryOpenLabel",recovery_show_title:"recoveryShowTitle",recovery_show_detail:"recoveryShowDetail",recovery_private_note:"recoveryPrivateNote",recovery_replace_note:"recoveryReplaceNote",recovery_enter_title:"recoveryEnterTitle",recovery_enter_detail:"recoveryEnterDetail",recovery_submit_label:"recoverySubmitLabel",recovery_not_recognised:"recoveryNotRecognised",recovery_restored:"recoveryRestored",recovery_get_label:"recoveryGetLabel",recovery_issue_failed:"recoveryIssueFailed",recovery_copy_label:"recoveryCopyLabel",recovery_copied_label:"recoveryCopiedLabel",recovery_share_label:"recoveryShareLabel",recovery_close_label:"recoveryCloseLabel",analytics_url:"analyticsUrl",strapline:"strapline",how_to_play:"howToPlay",primary_colour:"primaryColour",play_button_label:"playButtonLabel",play_again_label:"playAgainLabel",result_button_label:"resultButtonLabel",share_button_label:"shareButtonLabel",edition_name:"editionName",edition_strapline:"editionStrapline",edition_live_contest:"liveContest",margin_over:"marginOver",margin_exact:"marginExact",margin_under:"marginUnder",result_over:"resultOver",result_exact:"resultExact",result_under:"resultUnder",share_over:"shareOver",share_exact:"shareExact",share_under:"shareUnder",result_bust_note:"resultBustNote",share_bust_note:"shareBustNote",capped_today_note:"cappedTodayNote",share_dare:"shareDare",result_dare:"resultDare"},gc={primary_color:"primaryColour"},mr="label_",gs="option_",fs="form_";ps={"Abril Fatface":[400],Anton:[400],"Archivo Black":[400],"Bebas Neue":[400],Bungee:[400],"Chakra Petch":[300,400,500,600,700],"DM Serif Display":[400],Fraunces:[400,600,700,900],Oswald:[400,500,600,700],"Playfair Display":[400,700,900],"Russo One":[400],"Space Grotesk":[400,500,700],Teko:[400,500,600,700],Unbounded:[400,700,900]},ys="https://gamestage.ai";ms=/^https:\\/\\//i});function Te(e,t){if(typeof e=="string")return e.trim()||void 0;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;for(let s of[t,"all","en"]){if(!s)continue;let o=n[s];if(typeof o=="string"&&o.trim())return o.trim()}}function Sc(e){return typeof e=="boolean"?e:Te(e)?.toLowerCase()==="true"}function zt(e,t){if(!e)return{enabled:!1};let n={web:Te(e.userAccessSignInUrlWeb,t),iOS:Te(e.userAccessSignInUrlNativeIOS,t),android:Te(e.userAccessSignInUrlNativeAndroid,t)},s={web:Te(e.userAccessSignUpUrlWeb,t),iOS:Te(e.userAccessSignUpUrlNativeIOS,t),android:Te(e.userAccessSignUpUrlNativeAndroid,t)},o=r=>Object.values(r).some(Boolean);return{enabled:Sc(e.mIdEnabled),frontendUrl:Te(e.mIdFrontendUrl,t),apiUrl:Te(e.mIdApiUrl,t),clientId:Te(e.xClientId,t),title:Te(e.userAccessTitle,t),subtitle:Te(e.userAccessSubtitle,t),...o(n)?{signInUrl:n}:{},...o(s)?{signUpUrl:s}:{}}}var ws=ee(()=>{"use strict"});function Et(e,t){return e.declared?e.categories[t]===!0:!1}function ct(e,t){return e.analyticsRequiresConsent?Et(t,Gr):!0}function dt(e,t){return ct(e,t)}var Gr,Ht=ee(()=>{"use strict";Gr="analytics"});function Ur(e){let t=0,n=0;return{track(s){if(!ct(e.policy,e.consent()))return t+=1,!1;for(let o of e.destinations)try{o.send(s)}catch{}return e.destinations.length>0&&(n+=1),e.destinations.length>0},get withheld(){return t},get sent(){return n}}}function On(e){let t={};for(let[n,s]of Object.entries(e))if(s===null)t[n]=null;else if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")t[n]=s;else{if(s===void 0)continue;try{t[n]=JSON.stringify(s)??null}catch{t[n]=null}}return t}var Vt=ee(()=>{"use strict";Ht()});function Kt(){let e=0,t=!1;return{now:()=>Date.now()+e,sample(n){Number.isFinite(n)&&(e=n-Date.now(),t=!0)},get synchronised(){return t}}}function Ct(e,t){if(!t)return;let n=Date.parse(t);Number.isNaN(n)||e.sample(n)}var Wt=ee(()=>{"use strict"});function ni(e){return`gamestage:settings:v${Ds}:${e}`}function oi(e){return Et(e,si)}function ri(e){let t=e.now??(()=>Date.now()),n=e.readTimeoutMs??300;return{async read(s){let o;try{o=await Promise.race([e.store.read(ni(s)),new Promise(r=>setTimeout(()=>r(null),n))])}catch{return null}if(!o)return null;try{let r=JSON.parse(o);if(r.format!==Ds||typeof r.savedAt!="number"||t()-r.savedAt>$c)return null;let i=r.presentation;return!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0?null:i}catch{return null}},async write(s,o){if(oi(e.consent())&&Object.keys(o).length!==0)try{await e.store.write(ni(s),JSON.stringify({format:Ds,savedAt:t(),presentation:o}))}catch{}}}}var Ds,si,$c,$s=ee(()=>{"use strict";Ht();Ds=1,si="functional",$c=720*60*60*1e3});function Gs(e){return e.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i,"").replace(/\\/+$/,"")}var Us=ee(()=>{"use strict"});var Ii={};Wo(Ii,{TextDecoder:()=>Ai,TextEncoder:()=>Oi,default:()=>hd});var Oi,Ai,hd,Ni=ee(()=>{"use strict";Oi=globalThis.TextEncoder,Ai=globalThis.TextDecoder,hd={TextEncoder:Oi,TextDecoder:Ai}});function Ve(){if(typeof self<"u")return self;if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}function ut(e){return Rn.localStorage.getItem(Ws(e))}function tn(e,t){return Rn.localStorage.setItem(Ws(e),t)}function Ys(e){return Rn.localStorage.removeItem(Ws(e))}function Qs(){return Rn.localStorage.clear()}function nn(){try{return tn(Pn,Pn),ut(Pn),Ys(Pn),!0}catch{return!1}}function Ge(e,t,...n){let s=t[e](...n);return new Ze(e,s)}function Ne(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return"Unknown error"}}function Js(){return Date.now()/1e3}function Mi(e){return Math.floor(e)+.5}function Sd(){return(Mi(Tt)+1-Tt)*1e3}function Li(){clearTimeout(en);let e=Js(),t=e-Hs;Tt+=t,Hs=e,en=setTimeout(Li,Sd()),typeof en=="object"&&"unref"in en&&en.unref(),Ri.emit("tick",Tt)}function Xs(e){Hs=Js(),Tt=Mi(e)}function Ke(){return Math.floor(Tt)}function Mn(e){return He(Ri,"tick",e)}function $i(e){let s=2166136261,o=new Vs().encode(e);for(let r=0;r<o.length;r++)s^=o[r],s=Math.imul(s,16777619)>>>0;return s.toString(16).padStart(8,"0")}function Ln(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ue(e){return e.trim()}function et(e){let t=Pi.get(e);if(t!==void 0)return t;let n=new Ks(e);return n.logLevel=Cd,n.logHandler=Td,Pi.set(e,n),n}var z,He,be,yd,Pn,Rn,Ws,Ze,bd,_d,dg,vd,lg,Ri,Tt,Hs,en,Di,zs,wd,Vs,B,Ed,Gi,Ks,Pi,Cd,Td,We=ee(()=>{z=class{constructor(){this.listeners=new Map}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){var s;if(n===void 0){this.listeners.delete(t);return}(s=this.listeners.get(t))===null||s===void 0||s.delete(n)}emit(t,...n){var s;(s=this.listeners.get(t))===null||s===void 0||s.forEach(o=>o(...n))}once(t,n){let s=(...o)=>{n(...o),this.off(t,s)};return this.on(t,s)}},He=(e,t,n)=>(e.on(t,n),()=>e.off(t,n));be=(e,t,n={})=>{var s,o;let r=(s=n.clearOnResolve)!==null&&s!==void 0?s:!1,i=(o=n.clearOnReject)!==null&&o!==void 0?o:!0,a=new Map,l=(...p)=>{let c=t(...p);if(a.has(c))return a.get(c);let u=e(...p);return a.set(c,u),u.then(()=>r&&a.delete(c)).catch(()=>i&&a.delete(c)),u};return l.cache=a,l};yd="monterosa_sdk_",Pn="bait",Rn=Ve(),Ws=e=>`${yd}${e}`;Ze=class e extends Error{constructor(t,n){super(n),this.name="MonterosaError",this.code=t,Object.setPrototypeOf(this,e.prototype)}};bd=typeof global=="object"&&global&&global.Object===Object&&global,_d=typeof self=="object"&&self&&self.Object===Object&&self,dg=bd||_d||Function("return this")(),vd=Object.prototype,lg=vd.toString;Ri=new z,Tt=0,Hs=0;Xs(Js());Li();Di=e=>{let t=e.reduce((r,i)=>r+i,0),n=e.map((r,i)=>{let a=100*r/t||0;return{idx:i,votes:r,percentage:Math.floor(a),remainder:a%1}}),s=n.reduce((r,{percentage:i})=>r+i,0);s=s||100;let o=100-s;n.sort((r,i)=>r.remainder!==i.remainder?i.remainder-r.remainder:r.idx-i.idx);for(let r=0;r<o;r++)n[r].percentage+=1;return n.sort((r,i)=>r.idx-i.idx),n.map(r=>r.percentage)};wd=typeof process<"u"&&((zs=process.versions)===null||zs===void 0?void 0:zs.node)!=null;wd?Vs=(Ni(),Ka(Ii)).TextEncoder:Vs=TextEncoder;(function(e){e[e.Verbose=0]="Verbose",e[e.Debug=1]="Debug",e[e.Info=2]="Info",e[e.Warn=3]="Warn",e[e.Error=4]="Error",e[e.Silent=5]="Silent"})(B||(B={}));Ed={[B.Verbose]:"log",[B.Debug]:"log",[B.Info]:"info",[B.Warn]:"warn",[B.Error]:"error"},Gi=(e,t,...n)=>{let s=Ed[t],o=e.name.replace("@monterosa/sdk-","monterosa/");console[s](`[${o}]`,...n)},Ks=class{constructor(t){this.name=t,this._logLevel=B.Warn,this._logHandler=Gi}get logLevel(){return this._logLevel}set logLevel(t){this._logLevel=t}get logHandler(){return this._logHandler}set logHandler(t){this._logHandler=t}emit(t,...n){this._logLevel>t||this._logHandler(this,t,...n)}log(...t){this.emit(B.Verbose,...t)}debug(...t){this.emit(B.Debug,...t)}info(...t){this.emit(B.Info,...t)}warn(...t){this.emit(B.Warn,...t)}error(...t){this.emit(B.Error,...t)}},Pi=new Map,Cd=B.Warn,Td=Gi});function sn(e=Ui){let t=to.get(e);if(!t)throw new Error(`No Monterosa Sdk "${e}" has been configured.\n You need to call configure() first`);return t}function Fi(e,t=Ui){let n=to.get(t);if(n)return n;let s=new eo(e,t);return to.set(t,s),s}var xd,Ui,kd,Zs,eo,to,Dn=ee(()=>{We();xd="2.0.0-rc.9";Ui="[DEFAULT]",kd=xd;if(typeof document<"u"){let e=document.title||((Zs=document.location)===null||Zs===void 0?void 0:Zs.hostname)||"",t=e?` \\u2014 "${e}"`:"";console.debug(`Monterosa SDK v${kd}${t}`)}eo=class{constructor(t,n){this._isDestroyed=!1,this._options=Object.assign(Object.assign({},t),{host:Ue(t.host),projectId:Ue(t.projectId)}),this._name=n,this._kits=new Map}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get isDestroyed(){return this._isDestroyed}get kits(){return this._kits}set isDestroyed(t){this._isDestroyed=t}deleteKits(){this.kits.forEach((t,n)=>{this.kits.delete(n),t.delete()})}checkDestroyed(){if(this.isDestroyed)throw new Error(`SDK named ${this.name} destroyed`)}};to=new Map});function Hi(e){if(e<=0)throw Ge(tt.InvalidRequestTimeoutError,zi);go.requestTimeout=e}function Md(e){return e instanceof Object&&Object.prototype.hasOwnProperty.call(e,"bridgeId")}function Ld({data:e}){try{if(typeof e!="string")return;let t=JSON.parse(e);fo(t)}catch(t){Gn.error(Ne(t))}}function $d(e){if(rn.has(e))return rn.get(e);let t=new Fn(e);return rn.set(e,t),t}function Gd(){if(typeof window>"u")return null;if(on!==void 0)return on;let t=new URL(window.location.href).searchParams.get(Ad);return t===null?null:(on=new Fn(t),on.send(ft.OnBridgeInitialised,{},xe.Sdk),on)}function Vi(e,t={}){rn.forEach(n=>{n.isConnected&&n.send(e,t,xe.Sdk)})}function xt(e){return He(Dd.monterosaSdk.emitter,"message",t=>{t.sourceName===xe.Sdk&&t.action!==ft.OnBridgeInitialised&&rn.has(t.bridgeId)&&e(t)})}function po(e,t,n={}){return e.bridge.send(t,n,xe.Sdk)}function jn(e,t,n={},s=go.requestTimeout){return e.bridge.request(t,n,s,xe.Sdk)}function an(e,t={}){Ud(xe.Sdk,e,t)}function Ud(e,t,n){$d(t.bridgeId).send(t.action,n,e,t.id)}function Fd(e,t,n){return He(e.bridge,"message",s=>{s.sourceName===t&&n(s)})}function Ki(e,t){return Fd(e,xe.Sdk,t)}function Se(){if($n!==void 0)return $n;let e=Gd();return e===null?null:($n=new uo(e),$n)}var ft,xe,no,so,oo,ro,Un,Od,Ad,Id,Nd,Pd,Rd,tt,zi,go,Gn,io,ao,co,lo,ji,qi,Bi,Fe,fo,gt,Fn,Dd,on,rn,uo,$n,kt=ee(()=>{We();(function(e){e.OnBridgeInitialised="onBridgeInitialised",e.OnExperienceInitialised="onExperienceInitialised",e.OnReady="onReady",e.OnResize="onIntrinsicSizeChanged",e.OnMoreDataRequested="onMoreDataRequested",e.OnShare="onShare"})(ft||(ft={}));(function(e){e.Sdk="sdk",e.User="user"})(xe||(xe={}));Un=Ve(),Od="micBridge",Ad="micBridgeId",Id=!!(!((oo=(so=(no=Un.webkit)===null||no===void 0?void 0:no.messageHandlers)===null||so===void 0?void 0:so.monterosaSdk)===null||oo===void 0)&&oo.postMessage),Nd=!!(!((ro=Un.monterosaSdk)===null||ro===void 0)&&ro.postMessage),Pd=Un.self!==Un.parent,Rd="1.0.0";(function(e){e.InvalidRequestTimeoutError="invalid_request_timeout_error",e.RequestTimeoutError="request_timeout_error"})(tt||(tt={}));zi={[tt.InvalidRequestTimeoutError]:()=>"Request timeout must be greater than 0",[tt.RequestTimeoutError]:(e,t)=>`Request timeout: action "${e}" did not receive a response within ${t}ms`};go={requestTimeout:2e4};Gn=et("@monterosa/sdk-bridge-kit");Fe=Ve(),fo=e=>{Md(e)&&Fe.monterosaSdk.emitter.emit("message",e)};(io=Fe.monterosaSdk)!==null&&io!==void 0||(Fe.monterosaSdk={initialised:!1,emitter:new z,receiveMessage:fo});(ao=(ji=Fe.monterosaSdk).initialised)!==null&&ao!==void 0||(ji.initialised=!1);(co=(qi=Fe.monterosaSdk).emitter)!==null&&co!==void 0||(qi.emitter=new z);(lo=(Bi=Fe.monterosaSdk).receiveMessage)!==null&&lo!==void 0||(Bi.receiveMessage=fo);Fe.monterosaSdk.initialised||(typeof Fe.addEventListener<"u"&&Fe.addEventListener("message",Ld),Fe.monterosaSdk.initialised=!0);gt=Ve(),Fn=class extends z{constructor(t=Ln()){super(),this.id=t,this.recipientInitialised=!1,this.messagesQueue=[],gt.monterosaSdk.emitter.on("message",this.handleMessage.bind(this))}static isMessage(t){return t instanceof Object&&Object.prototype.hasOwnProperty.call(t,"bridgeId")&&Object.prototype.hasOwnProperty.call(t,"action")}get iFrameId(){return`${Od}-${this.id}`}get iFrameSelector(){return`iframe#${this.iFrameId}`}get childIFrame(){return document.querySelector(this.iFrameSelector)}handleMessage(t){let{id:n,bridgeId:s,action:o,respondingTo:r}=t;if(s===this.id){if(Gn.log(`Received a ${r===null?"message":"response"}`,t),o===ft.OnBridgeInitialised){r===null&&this.send(ft.OnBridgeInitialised,{},xe.Sdk,n),this.connect();return}this.emit("message",t)}}createMessage(t,n,s,o=null){return{id:Ln(),respondingTo:o,action:t,sourceName:s,bridgeId:this.id,payload:n,version:Rd,timestamp:Date.now()}}get isConnected(){return this.recipientInitialised}connect(){for(this.recipientInitialised=!0;this.messagesQueue.length>0;)this.postMessage(this.messagesQueue.shift())}disconnect(){this.recipientInitialised=!1}postMessage(t){var n,s,o,r;if(!this.recipientInitialised&&t.action!==ft.OnBridgeInitialised){this.messagesQueue.push(t);return}let i=JSON.stringify(t);Id&&((s=(n=gt.webkit)===null||n===void 0?void 0:n.messageHandlers)===null||s===void 0||s.monterosaSdk.postMessage(i)),Nd&&!((o=gt.monterosaSdk)===null||o===void 0)&&o.postMessage&>.monterosaSdk.postMessage(i),Pd&>.parent.postMessage(i,"*"),this.childIFrame&&((r=this.childIFrame.contentWindow)===null||r===void 0||r.postMessage(i,"*"))}send(t,n={},s=xe.Sdk,o){let r=this.createMessage(t,n,s,o);return Gn.log(`Sending a ${r.respondingTo===null?"message":"response"}`,r),this.postMessage(r),r}async request(t,n={},s=go.requestTimeout,o=xe.Sdk){let r,i,a=this.createMessage(t,n,o);Gn.log("Sending a request",a);let l=new Promise((c,u)=>{r=setTimeout(()=>{u(Ge(tt.RequestTimeoutError,zi,t,s))},s)}),p=new Promise(c=>{i=u=>{u.respondingTo===a.id&&c(u)},gt.monterosaSdk.emitter.on("message",i),this.postMessage(a)});return Promise.race([l,p]).finally(()=>{clearTimeout(r),gt.monterosaSdk.emitter.off("message",i)})}};Dd=Ve(),rn=new Map;uo=class{constructor(t){this.bridge=t}};});function jd(e){var t;if(Object.values(je).includes(e.action))try{let n={};switch(e.action){case je.Read:n={key:e.payload.key,value:Pe.getItem(e.payload.key)};break;case je.Write:n={key:e.payload.key},Pe.setItem(e.payload.key,e.payload.value);break;case je.Remove:n={key:e.payload.key},Pe.removeItem(e.payload.key);break;case je.Clear:Pe.clear();break}an(e,n)}catch(n){let s=Ne(n),o=(t=e.payload)===null||t===void 0?void 0:t.key,r=o?` for key "${o}"`:"";qn.error(`Unable to handle storage action ${e.action}${r} with error: ${s}`),an(e,{error:s})}}async function ho(e,t,n){try{let s=await jn(e,t,n),{value:o,error:r}=s.payload;if(r!==void 0)throw Ge(we.ParentAppError,cn,r);return o}catch(s){if(s instanceof Ze&&s.code===tt.RequestTimeoutError){let o=Ne(s);throw Ge(we.ParentTimeoutError,cn,o)}throw s}}async function Ot(e){let t=Se(),n=null;try{t!==null?n=await ho(t,je.Read,{key:e}):n=Pe.getItem(e)}catch(s){let o=Ne(s);throw qn.error(`Unable to read storage item "${e}" with error: ${o}`),Ge(we.ReadError,cn,o)}return n}async function At(e,t){let n=Se();try{n!==null?await ho(n,je.Write,{key:e,value:t}):Pe.setItem(e,t)}catch(s){let o=Ne(s);throw qn.error(`Unable to write storage item "${e}" with error: ${o}`),Ge(we.WriteError,cn,o)}}async function Bn(e){let t=Se();try{t!==null?await ho(t,je.Remove,{key:e}):Pe.removeItem(e)}catch(n){let s=Ne(n);throw qn.error(`Unable to remove storage item "${e}" with error: ${s}`),Ge(we.RemoveError,cn,s)}}var je,we,cn,mo,qn,Pe,zn=ee(()=>{We();kt();(function(e){e.Read="storageRead",e.Write="storageWrite",e.Remove="storageRemove",e.Clear="storageClear"})(je||(je={}));(function(e){e.ParentAppError="parent_app_error",e.ParentTimeoutError="parent_timeout_error",e.ReadError="read_error",e.WriteError="write_error",e.RemoveError="remove_error",e.ClearError="clear_error"})(we||(we={}));cn={[we.ParentAppError]:e=>`Parent application error: ${e}`,[we.ParentTimeoutError]:e=>`Parent application timeout: ${e}. Please check if the storage-kit is imported on the parent page.`,[we.ReadError]:e=>`Storage read error: ${e}`,[we.WriteError]:e=>`Storage write error: ${e}`,[we.RemoveError]:e=>`Storage remove error: ${e}`,[we.ClearError]:e=>`Storage clear error: ${e}`};mo=class{constructor(){this.memoryStore={},this.accessible=nn(),this._persistent=!0}set persistent(t){if(this._persistent===t)return;let s=t===!0&&this.accessible,o=t===!1&&this.accessible;if(s)for(let[r,i]of Object.entries(this.memoryStore))tn(r,i);o&&Qs(),this._persistent=t}get persistent(){return this._persistent}getItem(t){return this.persistent&&this.accessible?ut(t):Object.prototype.hasOwnProperty.call(this.memoryStore,t)?this.memoryStore[t]:null}setItem(t,n){this.persistent&&this.accessible&&tn(t,n),this.memoryStore[t]=n}removeItem(t){this.persistent&&this.accessible&&Ys(t),delete this.memoryStore[t]}clear(){this.persistent&&this.accessible&&Qs(),this.memoryStore={}}};qn=et("@monterosa/sdk-storage-kit");Pe=new mo;xt(jd)});function C(e,...t){var n;switch((n=Yd[e])!==null&&n!==void 0?n:B.Verbose){case B.Info:ln.info(...t);break;case B.Debug:ln.debug(...t);break;default:ln.log(...t);break}}function dn(e,t){ln.error(`EnMasse: ${e}: ${Ne(t)}`)}function Qd(e){ln.warn(`EnMasse: ${e}`)}var qd,Bd,Qi,Eo,Ji,Xi,Vn,Co,Zi,To,zd,Hd,xo,Vd,ea,Kd,Wi,Yi,Wd,Re,Q,le,ue,pt,ta,Me,It,na,ln,Yd,yo,Kn,sa,oa,Jd,bo,J,Hn,ge,he,Xd,_o,Zd,vo,el,tl,nl,So,wo,sl,ol,Pt,Rt,Nt,M,ra=ee(()=>{We();zn();kt();qd="enmasse_override_methods",Bd="enmasse_config",Qi="auth",Eo="authr",Ji="authok",Xi="ping",Vn="sub",Co="unsub",Zi="eoc",To="login",zd="login_ok",Hd="login_fail",xo="logout",Vd="counter",ea=e=>{if(nn()){let n=ut(e);if(n!==null)return n}if(typeof window>"u")return null;let{searchParams:t}=new URL(window.location.href);return t.has(e)?t.get(e):!1},Kd=()=>{let e=ea(qd);if(typeof e=="string")return e.split(",")},Wi=Kd(),Yi=ea(Bd),Wd="2.0.0-rc.9";Re=1,Q=2,le=4,ue=8,pt=16,ta=32,Me=64,It=128,na=256,ln=et("@monterosa/sdk-enmasse-kit"),Yd={[Re]:B.Info,[Q]:B.Debug,[le]:B.Debug,[ue]:B.Debug,[Me]:B.Verbose,[It]:B.Verbose,[pt]:B.Verbose,[ta]:B.Verbose,[na]:B.Verbose};yo=class{constructor(t={}){this.queue=[],this.stashed=[],this.running=!1,this.runner=typeof t.runner=="function"?t.runner:null,this._subscriptions=[]}push(t,n=!1){C(pt,"Queue::push",t,n);let{klass:s,channel:o}=t;if(!n)switch(s){case To:case xo:case Eo:break;case Vn:if(this._subscriptions.indexOf(o)===-1)this._subscriptions.push(o);else return;break;case Co:{let r=this._subscriptions.indexOf(o);if(r!==-1)this._subscriptions.splice(r,1);else return;break}default:if(this._subscriptions.indexOf(o)===-1)return;break}this.queue.push(t)}get subscriptions(){return this._subscriptions}run(){C(pt,"Queue::run",`running=${this.running}, head=${this.queue[0]}`),!(this.runner===null||this.running||!this.queue[0])&&(this.running=!0,this.runner(this.queue.shift()))}success(){C(pt,"Queue::success"),this.running=!1,this.run()}failure(){C(pt,"Queue::failure"),this.running=!1}stash(){C(pt,"Queue::stash");let t;for(;(t=this.queue.shift())!==void 0;)this.stashed.push(t)}unstash(){C(pt,"Queue::unstash");let t;for(;(t=this.stashed.shift())!==void 0;)this.queue.push(t)}},Kn=()=>Date.now()/1e3,sa=Kn(),oa=Kn(),Jd=e=>{C(ta,"Time::setTime",e),sa=e,oa=Kn()},bo=()=>{let e=Kn()-oa;return Math.round(sa+e)},J=class e extends z{constructor(){super(...arguments),this.state=e.STATE_DISCONNECTED,this.trigger=this.emit,this.bind=this.on,this.unbind=this.off}connect(){}disconnect(){}init(){}send(t,n,s){}};J.ON_READY="ready";J.ON_MESSAGE="message";J.ON_CONNECTED="connected";J.ON_CONNECT_FAILED="connect_failed";J.ON_CONNECT_LOST="connect_lost";J.ON_DISCONNECTED="disconnected";J.STATE_CONNECTED="connected";J.STATE_CONNECTING="connecting";J.STATE_DISCONNECTED="disconnected";J.STATE_DISCONNECTING="disconnecting";Hn=[0,3,5,10,20,30,45,60],ge=class e extends z{constructor(t){super(),this._handleTransportMessage=s=>{C(Q,"ConnectionManager::handleTransportMessage",s);let o=s.split("\\0");for(let r=0;r<o.length;r+=1)o[r].length>0&&(this._inactivityTimeout.reset(),C(Q,"ConnectionManager::handleTransportMessage","send upstream m:",o[r]),this.emit(e.ON_MESSAGE,o[r]))},this._handleTransportConnected=()=>{C(Q,"ConnectionManager::handleTransportConnected"),this._setStateToConnected()},this._handleTransportConnectFailed=()=>{C(Q,"ConnectionManager::handleTransportConnectFailed"),this._disconnectingOnConnectFailed()},this._handleTransportConnectLost=()=>{C(Q,"ConnectionManager::handleTransportConnectLost"),this._disconnectingOnConnectLost()},this._handleTransportDisconnected=()=>{switch(C(Q,"ConnectionManager::handleTransportDisconnected"),this._state){case e.STATE_CONNECTED:this._disconnectedOnConnectLost();break;case e.STATE_CONNECTING:this._disconnectedOnConnectFailed();break;case e.STATE_DISCONNECTING:this._setStateToDisconnected();break}},this._handleVisibilityChange=()=>{switch(C(Q,"ConnectionManager::handleVisibilityChange()",document.visibilityState),document.visibilityState){case"visible":if(this._backgroundedAt===null||this._state!==e.STATE_CONNECTED)return;Date.now()-this._backgroundedAt>this._config.background_timeout*1e3&&(C(Q,"ConnectionManager::handleVisibilityChange()","disconnecting due to background timeout"),this._disconnect()),this._backgroundedAt=null;break;case"hidden":this._backgroundedAt=Date.now();break}},this._handleNetworkStatus=()=>{!navigator.onLine&&this._state===e.STATE_CONNECTED&&(C(Q,"ConnectionManager::handleNetworkStatus()","disconnecting due to network loss"),this._disconnect())},this._transportManager=t,this._state=e.STATE_DISCONNECTED,this._transport=null,this._attempt=1,this._backgroundedAt=null;let n=this;this._inactivityTimeout={start(){C(Me,"ConnectionManager::inactivityTimeout::start");let s=bo();this.interval=setInterval(()=>{bo()-s>=n._config.inactivity_timeout&&this.resolve()},1e3)},stop(){C(Me,"ConnectionManager::inactivityTimeout::stop"),clearInterval(this.interval)},reset(){C(Me,"ConnectionManager::inactivityTimeout::reset"),this.stop(),this.start()},resolve(){C(Me,"ConnectionManager::inactivityTimeout::resolve"),n._disconnectingOnConnectLost()}},this._connectTimeout={start(){C(Me,"ConnectionManager::connectTimeout::start"),this.timeout=setTimeout(()=>{this.resolve()},n._config.connect_timeout*1e3)},stop(){C(Me,"ConnectionManager::connectTimeout::stop"),clearTimeout(this.timeout)},resolve(){C(Me,"ConnectionManager::connectTimeout::resolve"),n._disconnectingOnConnectFailed()}},this._connectDelay={active:!1,start(s){C(Me,"ConnectionManager::connectDelay::start"),this.active=!0,this.timeout=setTimeout(()=>{this.resolve()},s*1e3)},stop(){C(Me,"ConnectionManager::connectDelay::stop"),this.active=!1,clearTimeout(this.timeout)},resolve(){C(Me,"ConnectionManager::connectDelay::resolve"),this.stop(),n._connect()}}}_initTransport(t){C(Q,"ConnectionManager::initTransport"),this._transport=t,t.bind(J.ON_MESSAGE,this._handleTransportMessage),t.bind(J.ON_CONNECTED,this._handleTransportConnected),t.bind(J.ON_CONNECT_FAILED,this._handleTransportConnectFailed),t.bind(J.ON_CONNECT_LOST,this._handleTransportConnectLost),t.bind(J.ON_DISCONNECTED,this._handleTransportDisconnected)}_teardownTransport(){C(Q,"ConnectionManager::teardownTransport"),this._transport!==null&&(this._transport.unbind(J.ON_MESSAGE,this._handleTransportMessage),this._transport.unbind(J.ON_CONNECTED,this._handleTransportConnected),this._transport.unbind(J.ON_CONNECT_FAILED,this._handleTransportConnectFailed),this._transport.unbind(J.ON_CONNECT_LOST,this._handleTransportConnectLost),this._transport.unbind(J.ON_DISCONNECTED,this._handleTransportDisconnected),this._transport=null)}_disconnectingOnConnectFailed(){C(Q,"ConnectionManager::disconnectingOnConnectFailed()"),this._disconnect()}_disconnectingOnConnectLost(){C(Q,"ConnectionManager::disconnectingOnConnectLost()"),this._disconnect()}_disconnectedOnConnectLost(){C(Q,"ConnectionManager::disconnectedOnConnectLost()"),this._teardownTransport(),this._setStateToConnecting()}_disconnectedOnConnectFailed(){C(Q,"ConnectionManager::disconnectedOnConnectFailed()"),this._transportManager.addUnsuccessful(this._transport),this._teardownTransport(),this._transportManager.next()===!1?this._setStateToConnecting():this._connect()}_setStateToConnecting(){C(Q,"ConnectionManager::setStateToConnecting()");let t;this._attempt>=Hn.length?t=Hn[Hn.length-1]:t=Hn[this._attempt-1],this._state=e.STATE_CONNECTING,this.emit(e.ON_STATE,this._state,this._attempt,t),this._transportManager.reset(),this._attempt+=1,this._connectDelay.start(t)}_setStateToConnected(){C(Q,"ConnectionManager::setStateToConnected()"),this._attempt=1,this._transportManager.reset(),this._inactivityTimeout.reset(),this._connectTimeout.stop(),this._connectDelay.stop(),this._state=e.STATE_CONNECTED,this.emit(e.ON_STATE,this._state)}_setStateToDisconnecting(){C(Q,"ConnectionManager::setStateToDisconnecting()"),this._state=e.STATE_DISCONNECTING,this.emit(e.ON_STATE,this._state),this._disconnect()}_setStateToDisconnected(){C(Q,"ConnectionManager::setStateToDisconnected()"),this._attempt=1,this._teardownTransport(),this._transportManager.reset(),this._state=e.STATE_DISCONNECTED,this.emit(e.ON_STATE,this._state)}_connect(){var t;this._state===e.STATE_CONNECTING&&(this._connectTimeout.start(),this._initTransport(this._transportManager.current),(t=this._transport)===null||t===void 0||t.connect())}_disconnect(){this._inactivityTimeout.stop(),this._connectTimeout.stop(),this._connectDelay.stop(),this._transport?this._transport.disconnect():this._setStateToDisconnected()}connect(){C(Q,"ConnectionManager::connect()"),this._connectDelay.active?this._connectDelay.resolve():this._state===e.STATE_DISCONNECTED&&this._setStateToConnecting(),window.addEventListener("online",this._handleNetworkStatus),window.addEventListener("offline",this._handleNetworkStatus),window.addEventListener("visibilitychange",this._handleVisibilityChange)}disconnect(){C(Q,"ConnectionManager::disconnect()"),this._setStateToDisconnecting(),window.removeEventListener("online",this._handleNetworkStatus),window.removeEventListener("offline",this._handleNetworkStatus),window.removeEventListener("visibilitychange",this._handleVisibilityChange)}send(t,n=()=>{},s=()=>{}){var o;C(Q,"ConnectionManager::send",t),(o=this._transport)===null||o===void 0||o.send(t,n,s)}get connectAttempt(){return this._attempt}init(t){C(Q,"ConnectionManager::init()",t),this._config=t}};ge.STATE_DISCONNECTED="state_disconnected";ge.STATE_DISCONNECTING="state_disconnecting";ge.STATE_CONNECTING="state_connecting";ge.STATE_CONNECTED="state_connected";ge.ON_MESSAGE="message";ge.ON_STATE="state";he=class e extends z{constructor(){super(...arguments),this.connected=!1,this.trigger=this.emit,this.bind=this.on,this.unbind=this.off}connect(t,n,s){}disconnect(){}send(...t){}init(){this.trigger(e.ON_READY)}};he.ON_READY="ready";he.ON_MESSAGE="message";he.ON_CONNECTED="connected";he.ON_DISCONNECTED="disconnected";Xd=Ve(),_o=class e extends he{constructor(t={}){super(),this.config=t,this.requests={},this.requestIdx=0}_request(t,n=()=>{},s=()=>{},o=()=>{}){this.requestIdx+=1,C(It,`XHRDriver::request url=${t}, idx=${this.requestIdx}`);let r=new XMLHttpRequest,i="POST";if(typeof XDomainRequest<"u")r=new XDomainRequest,r.open(i,t);else if("withCredentials"in r)r.open(i,t,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded");else return null;return r._idx=this.requestIdx,r.onload=()=>{C(It,`XHRDriver::request::onload idx=${r._idx}, response=${r.responseText}`),r.responseText.length>0?n(this._parseResponse(r.responseText)):s(r.responseText)},r.onerror=()=>{C(It,`XHRDriver::request::onerror idx=${r._idx}, response=${r.responseText}`),s(r.responseText)},r._onabort=()=>{C(It,`XHRDriver::request::onabort idx=${r._idx}`),o()},r}_parseResponse(t){let n={},s=t.split("&");for(let o=0,r=s.length;o<r;o++){let[i,a]=s[o].split("="),l=decodeURIComponent((a??"").replace("\\0",""));i in n?(n[i].constructor!==Array&&(n[i]=[n[i]]),n[i].push(l)):n[i]=l}return n}_removeRequest(t){C(It,"XHRDriver::removeRequest",t),Object.prototype.hasOwnProperty.call(this.requests,t)&&delete this.requests[t]}connect(){if(C(ue,"XHRDriver::connect"),this.connected){C(ue,"XHRDriver::connect already been connected!");return}this.connected=!0,this.trigger(e.ON_CONNECTED)}disconnect(){if(C(ue,"XHRDriver::disconnect"),this.connected){for(let t in this.requests)Object.prototype.hasOwnProperty.call(this.requests,t)&&typeof this.requests[t].abort=="function"&&(this.requests[t].abort(),typeof this.requests[t]._onabort=="function"&&this.requests[t]._onabort(),this._removeRequest(t));this.connected=!1}this.trigger(e.ON_DISCONNECTED)}send(t,n,s=()=>{},o=()=>{}){C(ue,"XHRDriver::send",n);let r,i=1,a=()=>{r=this._request(t,l,p,c),this.requests[r._idx]=r,setTimeout(()=>{r.send(n)},0)},l=u=>{C(ue,"XHRDriver::success",n),this._removeRequest(r._idx),s(u)},p=u=>{var h,m;C(ue,"XHRDriver::failure, retry: ",i),this._removeRequest(r._idx),i<=((h=this.config.request_retries)!==null&&h!==void 0?h:0)?setTimeout(()=>{a(),i++},((m=this.config.request_retry_delay)!==null&&m!==void 0?m:0)*1e3):o(u)},c=()=>{C(ue,"XHRDriver::abort",n),this._removeRequest(r._idx),o()};a()}static hasSupport(){return"XDomainRequest"in Xd||"withCredentials"in new XMLHttpRequest}},Zd=Ve(),vo=class e extends he{constructor(){super(...arguments),this.websocket=null,this.closeTimeout=void 0}_onMessage(t){C(ue,"WebSocketDriver::onMessage",t.data),this.trigger(e.ON_MESSAGE,t.data)}_onOpen(){C(ue,"WebSocketDriver::onOpen"),this.connected=!0,this.trigger(e.ON_CONNECTED)}_onClose(){C(ue,"WebSocketDriver::onClose"),this._disconnect()}_onError(){C(ue,"WebSocketDriver::onError")}_disconnect(){C(ue,"WebSocketDriver::disconnect"),this.connected=!1,this.websocket!==null&&(this.websocket.onmessage=()=>{},this.websocket.onopen=()=>{},this.websocket.onclose=()=>{},this.websocket.onerror=()=>{},this.websocket=null),clearTimeout(this.closeTimeout),this.trigger(e.ON_DISCONNECTED)}connect(t,n,s){if(this.connected)return;C(ue,"WebSocketDriver::connect",t,n);let o=`${s?"wss":"ws"}://${t}:${n}/ws`;this.websocket=new WebSocket(o),this.websocket.onmessage=this._onMessage.bind(this),this.websocket.onopen=this._onOpen.bind(this),this.websocket.onclose=this._onClose.bind(this),this.websocket.onerror=this._onError.bind(this)}disconnect(){var t;C(ue,"WebSocketDriver::disconnect"),this.connected?((t=this.websocket)===null||t===void 0||t.close(),this.closeTimeout=setTimeout(this._disconnect.bind(this),750)):this._disconnect()}send(t,n=()=>{}){var s;C(ue,"WebSocketDriver::send",t),(s=this.websocket)===null||s===void 0||s.send(t),n()}static hasSupport(){return"WebSocket"in Zd}},el="connect",tl="pass",nl="poll",So=class e extends J{constructor(t={}){C(le,"ProxyTransport::constructor",t),super(),this.driver=t.driver,this.host=t.host,this.port=t.port,this.secure=t.secure||!1,this.proxyIp=null,this.childId=null,this.clientId=null,this.sessionId=null,this.driver.bind(he.ON_READY,this._handleDriverReady.bind(this)),this.driver.bind(he.ON_CONNECTED,this._handleDriverConnected.bind(this)),this.driver.bind(he.ON_DISCONNECTED,this._handleDriverDisconnected.bind(this))}_url(){let t=this.childId===null?"":`${this.childId}/`;return`${this.secure?"https":"http"}://${this.proxyIp?this.proxyIp:this.host}:${this.port}/${t}?_r=${new Date().getTime()}`}_request(t="",n=()=>{},s=()=>{}){let o=i=>{i.sscp.constructor===String&&(i.sscp=[i.sscp]);for(let a=0,l=i.sscp.length;a<l;a++)i.sscp[a]!==""&&this.trigger(e.ON_MESSAGE,i.sscp[a]);n(i)},r=()=>{switch(this.state){case e.STATE_CONNECTED:case e.STATE_CONNECTING:this.state=e.STATE_DISCONNECTING,this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.state=e.STATE_DISCONNECTED,this.trigger(e.ON_DISCONNECTED);break}s()};this.driver.send(this._url(),t,o,r)}_poll(){let t=`command=${nl}&clientid=${this.clientId}&sid=${this.sessionId}`;this._request(t,this._poll.bind(this))}_connect(){let t=o=>{o&&(this.proxyIp=o.proxy,this.clientId=Number.parseInt(o.clientid,10),this.childId=Number.parseInt(o.childid,10),this.sessionId=o.sid,this.state=e.STATE_CONNECTED,this.trigger(e.ON_CONNECTED),this._poll())},n=()=>{this.state=e.STATE_DISCONNECTED,this.trigger(e.ON_CONNECT_FAILED)},s=`command=${el}`;this._request(s,t,n)}_handleDriverReady(){this.trigger(e.ON_READY)}_handleDriverConnected(){this._connect()}_handleDriverDisconnected(){C(le,"ProxyTransport::handleDriverDisconnected");let{state:t}=this;switch(this.state=e.STATE_DISCONNECTED,t){case e.STATE_CONNECTED:this.trigger(e.ON_CONNECT_LOST);break;case e.STATE_CONNECTING:this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.trigger(e.ON_DISCONNECTED);break}}send(t,n=()=>{},s=()=>{}){C(le,"ProxyTransport::send",t);let o=`command=${tl}&clientid=${this.clientId}&sscp=${t}&sid=${this.sessionId}`;this._request(o,n,s)}connect(){C(le,"ProxyTransport::connect",this.host,this.port),this.state=e.STATE_CONNECTING,this.driver.connect()}disconnect(){C(le,"ProxyTransport::disconnect"),this.proxyIp=null,this.childId=null,this.sessionId=null,this.state=e.STATE_DISCONNECTING,this.driver.disconnect()}init(){C(le,"ProxyTransport::init"),this.driver.init()}},wo=class e extends J{constructor(t={}){C(le,"SocketTransport::constructor",t),super(),this.driver=t.driver,this.host=t.host,this.port=t.port,this.secure=t.secure||!1,this.driver.bind(he.ON_READY,this._handleDriverReady.bind(this)),this.driver.bind(he.ON_MESSAGE,this._handleDriverMessage.bind(this)),this.driver.bind(he.ON_CONNECTED,this._handleDriverConnected.bind(this)),this.driver.bind(he.ON_DISCONNECTED,this._handleDriverDisconnected.bind(this))}_handleDriverReady(){C(le,"SocketTransport::_handleDriverReady"),this.trigger(e.ON_READY)}_handleDriverMessage(t){C(le,"SocketTransport::handleDriverMessage"),this.trigger(e.ON_MESSAGE,t)}_handleDriverConnected(){C(le,"SocketTransport::handleDriverConnected"),this.state=e.STATE_CONNECTED,this.trigger(e.ON_CONNECTED)}_handleDriverDisconnected(){C(le,"SocketTransport::handleDriverDisconnected");let{state:t}=this;switch(this.state=e.STATE_DISCONNECTED,t){case e.STATE_CONNECTED:this.trigger(e.ON_CONNECT_LOST);break;case e.STATE_CONNECTING:this.trigger(e.ON_CONNECT_FAILED);break;case e.STATE_DISCONNECTING:this.trigger(e.ON_DISCONNECTED);break}}send(t,n=()=>{},s=()=>{}){C(le,"SocketTransport::send",t),this.driver.send(t,n,s)}connect(){C(le,"SocketTransport::connect",this.host,this.port),this.state=e.STATE_CONNECTING,this.driver.connect(this.host,this.port,this.secure)}disconnect(){C(le,"SocketTransport::disconnect"),this.state=e.STATE_DISCONNECTING,this.driver.disconnect()}init(){C(le,"SocketTransport::init"),this.driver.init()}},sl="proxy",ol="websocket",Pt=class e extends z{constructor(){super(),this.idx=0,this.methods={},this.transports={},this.loaded=0,this.sequence=[],this.allowed=[],this.secure=!0,this.unsuccessful=[],typeof window<"u"&&(this.secure=window.location.protocol.startsWith("https"))}_instantiate(){C(Q,"TransportManager::instantiate"),this.allowed.forEach(t=>{let n=this._getMethodConfig(t),s=n.hosts[Math.floor(Math.random()*n.hosts.length)],o=this.methods[t].transport,r=this.methods[t].driver,i=new o({driver:new r(n.driver||{}),host:s,port:this.secure?n.secure_port:n.port,secure:this.secure});this.transports[t]=i,i.bind(J.ON_READY,this._handleTransportReady.bind(this))});for(let t in this.transports)Object.prototype.hasOwnProperty.call(this.transports,t)&&this.transports[t].init()}_getMethodConfig(t){return this.config.methods.find(n=>n.type===t)}_handleTransportReady(){this.loaded+=1,this.loaded===this.allowed.length&&this.emit(e.ON_READY)}get current(){return this.transports[this.allowed[this.idx]]}next(){return this.idx+=1,this.idx>=this.allowed.length?!1:this.current}reset(){this.allowed=[],this.unsuccessful=[];for(let t=0,n=this.sequence.length;t<n;t+=1){let s=this.sequence[(t+this.idx)%n];this.methods[s].driver.hasSupport()&&this.allowed.push(s)}this.idx=0}addUnsuccessful(t){for(let n in this.transports)Object.prototype.hasOwnProperty.call(this.transports,n)&&this.transports[n]===t&&this.unsuccessful.push(n)}init(t={}){this.config=t,this.idx=0,this.loaded=0,this.sequence=[],this.secure=t.forceSecure===!0?!0:this.secure,this.methods[sl]={driver:_o,transport:So},this.methods[ol]={driver:vo,transport:wo},Wi?this.sequence=Wi:this.config.methods.forEach(s=>this.sequence.push(s.type));let n=s=>Object.prototype.hasOwnProperty.call(this.methods,s);this.sequence=this.sequence.filter(n),this.reset(),this._instantiate()}};Pt.ON_READY="ready";Rt=class e extends z{addCounter(t,n,s,o,r=null,i=null,a=null){if(C(na,"Demographics::addCounter",t,n,s,o,r,i,a),!t||!n||!Array.isArray(s)||!s.length||s.length%2!==0||o!==Number.parseInt(String(o),10))return;let l=s.filter((c,u)=>(u+1)%2).join(":"),p=s.filter((c,u)=>u%2).join(":");this.emit(e.ON_ADD_COUNTER,t,[n,i,a,r,l,p,o])}};Rt.ON_ADD_COUNTER="add-counter";Nt="enmasse_session_id",M=class e extends z{constructor({transportManager:t=new Pt,demographics:n=new Rt,connectionManager:s}={}){super(),this._runner=o=>{let r=()=>{this._queue.success()},i=()=>{this._queue.failure()};this._connectionManager.send(this._stringifySSCP(o),r,i)},this._handleTransportManagerReady=()=>{C(Re,"Enmasse::handleTransportManagerReady"),this.emit(e.ON_READY)},this._handleConnectionManagerState=(o,r,i)=>{switch(C(Re,"Enmasse::handleConnectionManagerState",o,r,i),o){case ge.STATE_DISCONNECTED:this._setStateToDisconnected();break;case ge.STATE_CONNECTING:this._setStateToConnecting(r,i);break;case ge.STATE_CONNECTED:break}},this._handleConnectionManagerMessage=async o=>{C(Re,"Enmasse::handleConnectionManagerMessage",o);let r=this._parseSSCP(o);switch(r.klass){case Qi:{let i=r.sent_at,a=[`enmassejs-${e.VERSION}`,navigator.userAgent].concat(this._info);this._sysChannel=r.channel,a.forEach((l,p)=>{a[p]=encodeURIComponent(l)}),this._sessionId===null&&([this._sessionId]=r.body,await this._storeSession(this._sessionId)),Jd(i),this._queue.stash(),this._queue.push({channel:this._sysChannel,klass:Eo,body:[this._sessionId,e.PROTOCOL_VERSION,a.join(",")]},!0),this._queue.run();break}case Ji:{let{subscriptions:i}=this._queue;i.forEach(a=>{this._queue.push({channel:a,klass:Vn,body:[]},!0)}),this._queue.unstash(),this._queue.run(),this._setStateToConnected();break}case zd:this._resolveLogin();break;case Hd:this._rejectLogin();break;case Xi:break;case Zi:this.emit(e.ON_EOC,r.channel);break;default:this.emit(e.ON_MESSAGE,r);break}},this._handleDemographicsCounter=(o,r)=>{this.send(o,"avgcounter",r)},this._transportManager=t,this._demographics=n,this._connectionManager=s||new ge(t),this.Demographics=this._demographics,this._configFile=null,this._info=[],this._sessionId=null,this._state=e.STATE_DISCONNECTED,this._sysChannel=null,this._forceSecure=!1,this._loginContext={inProgress:!1,success:()=>{},failure:()=>{}},this._initPromise=null}async _storeSession(t){try{await At(Nt,t)}catch(n){dn("Failed to persist session to shared storage",n)}}async _restoreSession(){let t=null;try{t=await Ot(Nt)}catch(n){dn("Failed to read session from shared storage",n)}if(t!==null)return t;if(Se()===null)return null;try{t=ut(Nt)}catch(n){dn("Failed to read local session during migration",n)}if(t===null)return null;try{await At(Nt,t)}catch(n){dn("Failed to persist session to shared storage during migration",n)}return t}async resetSession(){this._sessionId=null;try{await Bn(Nt)}catch(t){dn("Failed to remove session from shared storage",t)}}_validateSession(t){return/^[a-f\\d]{8}\\-[a-f\\d]{4}\\-[a-f\\d]{4}-[a-f\\d]{4}\\-[a-f\\d]{12}$/i.test(t)}_finaliseLogin(t){this._loginContext.inProgress!==!1&&(this._loginContext={inProgress:!1,success:()=>{},failure:()=>{}},typeof t=="function"&&t())}_resolveLogin(){this._finaliseLogin(this._loginContext.success)}_rejectLogin(){this._finaliseLogin(this._loginContext.failure)}_setStateToDisconnected(){C(Re,"Enmasse::setStateToDisconnected()"),this._state=e.STATE_DISCONNECTED,this._sysChannel=null,this._rejectLogin(),this.emit(e.ON_STATE,this._state)}_setStateToConnected(){C(Re,"Enmasse::setStateToConnected()");let t=bo();this._state=e.STATE_CONNECTED,this.emit(e.ON_STATE,this._state,t)}_setStateToConnecting(t,n){C(Re,"Enmasse::setStateToConnecting()"),this._state=e.STATE_CONNECTING,this._rejectLogin(),this.emit(e.ON_STATE,this._state,t,n)}_parseSSCP(t){let n={channel:"",klass:"",sent_at:0,body:[]},s=t.indexOf("/");if(s!==-1){let o=t.indexOf("/",s+1);if(o!==-1){n.channel=t.substr(0,s),n.klass=t.substr(s+1,o-s-1);let r=t.indexOf("/",o+1);if(r!==-1){n.sent_at=Number.parseInt(t.substr(o+1,r-o-1),10);let i=t.substr(r+1);if(i!==""){let a=i.split("|");for(let l=0,p=a.length;l<p;l+=1)n.body[l]=decodeURIComponent(a[l])}}}}return n}_stringifySSCP(t){var n;return[t.channel,t.klass,Math.floor(Date.now()/1e3),((n=t.body)!==null&&n!==void 0?n:[]).join("|")].join("/")}connect(){C(Re,"Enmasse::connect"),this._connectionManager.connect()}disconnect(){C(Re,"Enmasse:disconnect"),this._connectionManager.disconnect()}teardown(){C(Re,"Enmasse::teardown"),this.disconnect(),this._transportManager.off(Pt.ON_READY,this._handleTransportManagerReady),this._connectionManager.off(ge.ON_STATE,this._handleConnectionManagerState),this._connectionManager.off(ge.ON_MESSAGE,this._handleConnectionManagerMessage),this._demographics.off(Rt.ON_ADD_COUNTER,this._handleDemographicsCounter)}send(t,n,s=[]){C(Re,"Enmasse::send",t,n,s),this._queue.push({channel:t,klass:n,body:s}),this._state===e.STATE_CONNECTED&&this._queue.run()}get sessionId(){return this._sessionId}get state(){return this._state}subscribe(t){this.send(t,Vn)}unsubscribe(t){this.send(t,Co)}login(t,n,s,o,r){let i=this._sysChannel;if(i!==null){if(this._loginContext.inProgress){Qd("Login is already in progress");return}this._loginContext={inProgress:!0,success:o,failure:r},this.send(i,To,[t,n,s])}}logout(){let t=this._sysChannel;t!==null&&(this._loginContext.inProgress&&this._rejectLogin(),this.send(t,xo))}init(t={}){return this._initPromise||(this._initPromise=this._init(t)),this._initPromise}async _init(t={}){if(this._configFile=Yi||t.config||null,this._info=t.info||[],this._sessionId=await this._restoreSession(),typeof t.forceSecure=="boolean"&&(this._forceSecure=t.forceSecure),this._configFile===null)throw new Error("EnMasse config file is not set");let n=this._configFile;this._sessionId!==null&&!this._validateSession(this._sessionId)&&await this.resetSession(),this._queue=new yo({runner:this._runner}),this._transportManager.on(Pt.ON_READY,this._handleTransportManagerReady),this._connectionManager.on(ge.ON_STATE,this._handleConnectionManagerState),this._connectionManager.on(ge.ON_MESSAGE,this._handleConnectionManagerMessage),this._demographics.on(Rt.ON_ADD_COUNTER,this._handleDemographicsCounter);try{let s=await fetch(n),{status:o,statusText:r}=s,i;try{i=await s.json()}catch{this.emit(e.ON_ERROR,`Invalid JSON from config ${n}`);return}let a=o>=200&&o<=300||o===0&&!!r||o==="";i.forceSecure=this._forceSecure,i.background_timeout===void 0&&(i.background_timeout=0),a?(this._connectionManager.init(i),this._transportManager.init(i)):this.emit(e.ON_ERROR,`Failed to load config ${n}`)}catch(s){this.emit(e.ON_ERROR,`Error loading config: ${s.message}`)}}};M.VERSION=Wd;M.PROTOCOL_VERSION="8";M.SSCP_KLASS_AUTH=Qi;M.SSCP_KLASS_AUTHR=Eo;M.SSCP_KLASS_AUTHOK=Ji;M.SSCP_KLASS_PING=Xi;M.SSCP_KLASS_SUB=Vn;M.SSCP_KLASS_UNSUB=Co;M.SSCP_KLASS_EOC=Zi;M.SSCP_KLASS_LOGIN=To;M.SSCP_KLASS_LOGOUT=xo;M.SSCP_KLASS_COUNTER=Vd;M.ON_STATE="on_state";M.ON_MESSAGE="on_message";M.ON_EOC="on_eoc";M.ON_READY="on_ready";M.ON_ERROR="on_error";M.STATE_DISCONNECTED="disconnected";M.STATE_CONNECTED="connected";M.STATE_CONNECTING="connecting";M.PARAM_SESSION_ID=Nt});function Oo(e,t,n){let s=(o,...r)=>{o===t&&n(...r)};return e.on("state",s),()=>e.off("state",s)}function Wn(e){return e===void 0&&(e=sn().options.host),rl(Ue(e))}function un(e,t){return Oo(e,ae.Connected,t)}function aa(e,t){return Oo(e,ae.Connecting,t)}function ca(e,t){return Oo(e,ae.Disconnected,t)}function da(e,t){let n=s=>{t(s)};return e.on("message",n),()=>e.off("message",n)}function Yn(e){return e.connect()}function Qn(e){e.disconnect()}function Mt(e,t){return il(e,Ue(t))}function Lt(e,t){e.unsubscribe(Ue(t))}function la(e,t,n,s){e.send(Ue(t),n,s)}var Ye,ae,ia,ko,rl,il,Ao=ee(()=>{Dn();We();ra();(function(e){e.NotInitialised="not_initialised",e.Initialised="initialised",e.Initialising="initialising"})(Ye||(Ye={}));(function(e){e.Disconnected="disconnected",e.Connecting="connecting",e.Connected="connected"})(ae||(ae={}));(function(e){e.Authenticate="auth",e.AuthenticateResponse="authr",e.AuthenticateSuccess="authok",e.Ping="ping",e.Subscribe="sub",e.Unsububscribe="unsub",e.EndOfCache="eoc",e.Login="login",e.LoginSuccess="login_ok",e.LoginFail="login_fail",e.Counter="counter",e.Vote="v"})(ia||(ia={}));ko=class extends z{constructor(t=new M){super(),this.enmasse=t,this.initState=Ye.NotInitialised,this.initPromise=Promise.resolve(),this.connectPromise=null,this.enmasse.on(M.ON_STATE,(n,...s)=>{if(n===M.STATE_CONNECTED){let[o]=s;Xs(o)}this.emit("state",this.toConnState(n),...s)}),this.enmasse.on(M.ON_MESSAGE,n=>{this.emit("message",n)})}get state(){return this.toConnState(this.enmasse.state)}get sessionId(){return this.enmasse.sessionId}toConnState(t){switch(t){case M.STATE_CONNECTING:return ae.Connecting;case M.STATE_CONNECTED:return ae.Connected;case M.STATE_DISCONNECTED:default:return ae.Disconnected}}async init(t){return this.initState===Ye.Initialising||this.initState===Ye.Initialised?this.initPromise:(this.initPromise=new Promise((n,s)=>{this.initState=Ye.Initialising,this.enmasse.on(M.ON_READY,()=>{this.initState=Ye.Initialised,this.enmasse.off(M.ON_READY),this.enmasse.off(M.ON_ERROR),n()}),this.enmasse.on(M.ON_ERROR,o=>{this.initState=Ye.NotInitialised,this.enmasse.off(M.ON_READY),this.enmasse.off(M.ON_ERROR),s(new Error(`Unable to initialise connect kit: ${o}`))}),this.enmasse.init({config:`https://${t}/config/enmasse.json`})}),this.initPromise)}connect(){return this.initState!==Ye.Initialised?Promise.reject(new Error("must be initialised before connecting")):this.state===ae.Connected?Promise.resolve():this.state===ae.Connecting?this.connectPromise?this.connectPromise:Promise.reject(new Error("BUG: Connection state is Connecting but connectPromise is null - this indicates an internal inconsistency")):(this.connectPromise=new Promise((t,n)=>{let s=o=>{switch(o){case ae.Connected:this.enmasse.off(M.ON_STATE,s),this.connectPromise=null,t();break;case ae.Disconnected:this.enmasse.off(M.ON_STATE,s),this.connectPromise=null,n(new Error("disconnected"));break;case ae.Connecting:break}};this.enmasse.on(M.ON_STATE,s),this.enmasse.connect()}),this.connectPromise)}disconnect(){this.enmasse.disconnect()}subscribe(t){return new Promise(n=>{let s=o=>{o===t&&(this.enmasse.off(M.ON_EOC,s),n())};this.enmasse.on(M.ON_EOC,s),this.enmasse.subscribe(t)})}unsubscribe(t){this.enmasse.unsubscribe(t)}send(t,n,s){this.enmasse.send(t,n,s)}async login(t,n,s){return new Promise((o,r)=>{this.enmasse.login(t,n,s,o,()=>{r(new Error("Login failure"))})})}async logout(){this.enmasse.logout()}delete(){this.enmasse.teardown()}};rl=be(async e=>{let t=new ko;return await t.init(e),t},e=>e);il=be(async(e,t)=>e.subscribe(t),(e,t)=>t)});function gn(){let e=Io.getInstance();if(!ga){for(let t of fa)t(e);ga=!0}return e}function al(e){fa.push(e)}function pa(e){if(Se()!==null)throw new Ze(nt.CannotSetFromChild,ua[nt.CannotSetFromChild]());if("necessary"in e&&e.necessary===!1)throw new Ze(nt.NecessaryCategoryRequired,ua[nt.NecessaryCategoryRequired]());let n=gn();n.state=e}function ma(){var e;return(e=gn().state)!==null&&e!==void 0?e:{}}function No(e){return gn().on(Jn.ConsentChanged,e)}function ha(e){let t=gn();t.state=e}function cl(){No(e=>{Vi(Dt.OnConsentUpdated,{state:e})}),xt(e=>{if(e.action!==Dt.RequestConsent)return;let t=gn();an(e,{state:t.isActive?t.state:null})})}async function dl(){let e=Se();if(e!==null)try{let t=await jn(e,Dt.RequestConsent),{state:n}=t.payload;n!=null&&ha(n)}catch{}}function ll(e){let t=Se();if(t===null)return()=>{};let n=Ki(t,s=>{if(s.action===Dt.OnConsentUpdated){let{state:o}=s.payload;ha(o)}});return dl(),n}var Dt,Jn,nt,ua,Io,fa,ga,ya=ee(()=>{kt();We();(function(e){e.OnConsentUpdated="consentOnConsentUpdated",e.SetConsent="consentSetConsent",e.RequestConsent="consentRequestConsent"})(Dt||(Dt={}));(function(e){e.ConsentChanged="consent_changed"})(Jn||(Jn={}));(function(e){e.NecessaryCategoryRequired="necessary_category_required",e.CannotSetFromChild="cannot_set_from_child"})(nt||(nt={}));ua={[nt.NecessaryCategoryRequired]:()=>"Cannot set \'necessary\' category to false. Strictly necessary functionality cannot be disabled.",[nt.CannotSetFromChild]:()=>"Cannot set consent state from embedded experience. Consent is managed by the parent application."};Io=class e extends z{get state(){return this._state}set state(t){let n=this._state;this._state=t,t!==null&&!e.isConsentStateEqual(n,t)&&this.emit(Jn.ConsentChanged,t)}get isActive(){return this._state!==null}constructor(){super(),this._state=null}static isConsentStateEqual(t,n){if(t===null&&n===null)return!0;if(t===null||n===null)return!1;let s=Object.keys(t),o=Object.keys(n);if(s.length!==o.length)return!1;let r=t,i=n;return s.every(a=>r[a]===i[a])}static getInstance(){return e.instance||(e.instance=new e),e.instance}};fa=[],ga=!1;al(ll);cl()});function ba(e){if(Po.has(e))return Po.get(e);let t=new Ro(e);return Po.set(e,t),t}function ul(e){return ba(e===void 0?"__SELF__":e.bridge.id)}function _a(e,t){ul().emit(st.OnEvent,e,t);let s=Se();s!==null&&po(s,st.OnEvent,{eventName:e,properties:t})}var st,Ro,Po,va=ee(()=>{kt();We();(function(e){e.OnEvent="onAnalyticsEvent"})(st||(st={}));Ro=class extends z{constructor(t){super(),this.id=t}};Po=new Map;xt(e=>{if(!Object.values(st).includes(e.action))return;let t=ba(e.bridgeId);if(e.action===st.OnEvent){let{eventName:n,properties:s}=e.payload;t.emit(st.OnEvent,n,s);let o=Se();o!==null&&po(o,st.OnEvent,{eventName:n,properties:s})}})});async function Mo(e,t){return await(await fetch(`https://${e}/projects/${t.substring(0,2)}/${t}/settings.json`)).json()}var Sa=ee(()=>{});function ht(e){return gl(e)}function wa(e){return e.split(/[-_]/)[0]}function pl(e){let t=[navigator.language,...navigator.languages];for(let n of t)if(e.includes(n))return n;for(let n of t){let s=wa(n);for(let o of e)if(wa(o)===s)return o}return e[0]}function pn(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e.all}async function ml(e,t){let{id:n,host:s}=e;if($t.has(n))return $t.get(n);let o=new Go(e,t);$t.set(n,o);try{if(await(await hl(s)).subscribeProject(n),!o.listings)throw new Error(`Unable to fetch project ${n} listings. Possibly wrong project id.`);return o.fields=await Mo(o.host,o.id),o}catch(r){throw Xn.has(n)&&Xn.get(n).unsubscribeProject(n),$t.delete(n),r}}async function hl(e){if(Xn.has(e))return Xn.get(e);let t=await ht(e);return t.on("message",yl),t}async function yl(e){let{id:t,klass:n,data:s}=e,o=$t.get(t);o&&n===Xe.Listings&&await bl(o,s[0])}async function bl(e,t){var n;let s=JSON.parse(t),o=s.project.app_settings_digest,r=(n=e.listings)===null||n===void 0?void 0:n.project.app_settings_digest;e.listings=s;try{r!==void 0&&o!==r&&(e.fields=await Mo(e.host,e.id))}catch{Ta.warn(`Unable to fetch project ${e.id} settings`)}}function Ut(e=sn()){return _l(e)}function xa(e,t){return He(e,"updated",t)}async function Zn(e,t){let n=await fetch(`https://${e}/events/${t.substring(0,2)}/${t}/history.json`);if(!n.ok)throw new Error(`Failed to fetch event ${t} history`);return await n.json()}function Fo(e,t){if(Gt.has(e.id))return Gt.get(e.id);let n=new Uo(e,t);return n.on("internal_state",Cl.bind(n)),Gt.set(e.id,n),n}async function vl(e){if(e.initState===it.Initialising)throw new Error("can\'t initialise event, event is already being initialised");if(e.initState===it.Initialised)throw new Error("can\'t initialise event, event is already initialised");if(e.initState=it.Initialising,e.canLoadHistory&&e.history===null){let t=await Zn(e.context.project.host,e.id);e.history=t}e.canSubscribe&&await Sl(e),await El(e),e.initState=it.Initialised}async function Sl(e){if(!e.canSubscribe)throw new Error("Event can\'t be subscribed");await(await ht(e.context.project.host)).subscribeEvent(e.id)}async function wl(e){(await ht(e.context.project.host)).unsubscribeEvent(e.id)}async function El(e){let{project:t}=e.context;if(Ea.has(t.id))return;let n=await ht(t.host);if(n.enmasse!==null){let s=un(n.enmasse,Tl);Ea.set(t.id,s)}}async function Cl(e){e===ye.Finished&&await wl(this)}async function Tl(){for(let e of Array.from(Gt.values()))if(e.initState===it.Initialised){let t=await Zn(e.context.project.host,e.id);e.history=t}}function ka(e){return xl(e)}function mn(e,t){return kl(Ue(e),t)}function Oa(e,t){return He(e,"updated",t)}async function Aa(e,t){if(ke.has(e.id))return ke.get(e.id);let n=new Bo(e,t);return await Dl(n),ke.set(n.id,n),n}function Ia(e){return Array.from(ke.values()).find(t=>t.pollId===e)}async function Ho(e){return Ol(e)}async function Il(e){return Al(e)}async function Nl(e){let{klass:t}=e;switch(t){case Xe.Create:await Pl(e);break;case Xe.Revoke:Rl(e);break;case Xe.Feedback:await Ml(e);break;case Xe.Reveal:Ll(e);break}}async function Pl(e){let{id:t,data:n}=e,s=JSON.parse(n[0]),o=await mn(t);if(o!==null)if(ke.has(s.id)){let r=ke.get(s.id);(s.updated_at>r.updatedAt||s.duration!==r.duration)&&(r.update(s),o.emit("update",r))}else{let r=Object.assign(Object.assign({},o.context),{event:o}),i=await Aa(s,r);o.emit("publish",i)}}function Rl(e){let{data:t}=e,{id:n}=JSON.parse(t[0]);if(!ke.has(n))return;let s=ke.get(n);ke.delete(n),s.destroy(),s.context.event.emit("revoke",s)}async function Ml(e){let{data:t}=e,n=+t[0],s=t[3],o=Ia(n);if(!o)return;let r=s.split(":").map(l=>+l),i=Di(r),a=r.map((l,p)=>({percentage:i[p],votes:l}));o.results=a}function Ll(e){let{data:t}=e,n=+t[0],s=+t[1]-1,o=Ia(n);o&&o.correctOption!==s&&(o.correctOption=s,o.context.event.emit("update",o))}async function Ca(e){if(e.timeline.length===0)return;let t=await mn(e.config.id);if(t===null)return;let n=Object.assign(Object.assign({},t.context),{event:t});for(let s of e.timeline)ke.has(s.id)||await Aa(s,n)}async function Dl(e){let t=await Ot(`element_${e.id}_vote`);t!==null&&(e.userAnswer=jo.fromJSON(t))}function Na(e){return $l(e)}function Pa(e,t){return Ho(e),He(e,"update",t)}var rt,Xe,Qe,Do,gl,fn,$o,Ug,fl,Go,Ta,$t,Xn,_l,ye,it,Uo,Gt,Ea,xl,kl,qe,Fg,mt,jo,qo,ot,Bo,ke,Ol,Al,jg,$l,Je,zo,Lo,qg,Ra=ee(()=>{We();Ao();Dn();Sa();zn();(function(e){e.Ok="ok",e.Error="error"})(rt||(rt={}));(function(e){e.Listings="listings",e.History="history",e.Create="create",e.Revoke="revoke",e.Stop="stop",e.Reveal="reveal",e.Poll="p",e.Feedback="fb",e.Eoc="eoc",e.Vote="v",e.SubsCounter="subscounter"})(Xe||(Xe={}));(function(e){e.Poll="p",e.Live="l"})(Qe||(Qe={}));Do=class extends z{constructor(t){super(),this.host=t,this._state=rt.Ok,this._enmasse=null}get state(){return this._state}set state(t){t!==this._state&&(this._state=t,this.emit("state",this._state))}get enmasse(){if(this._enmasse===null)throw new Error("Connect is not initialised, init() method should be called first.");return this._enmasse}set enmasse(t){this._enmasse=t}async init(){this.enmasse=await Wn(this.host),this.enmasse.on("message",this.handleMessage.bind(this)),this.enmasse.on("state",this.handleState.bind(this))}async connect(){await Yn(this.enmasse)}disconnect(){Qn(this.enmasse)}async subscribeProject(t){await Mt(this.enmasse,`${Qe.Live}-${t}`)}unsubscribeProject(t){Lt(this.enmasse,`${Qe.Live}-${t}`)}async subscribeEvent(t){await Promise.all([Mt(this.enmasse,`${Qe.Live}-${t}`),Mt(this.enmasse,`${Qe.Poll}-${t}`)])}unsubscribeEvent(t){Lt(this.enmasse,`${Qe.Live}-${t}`),Lt(this.enmasse,`${Qe.Poll}-${t}`)}sendVote(t,n,s){la(this.enmasse,`${Qe.Poll}-${t}`,Xe.Vote,[n,s,""])}handleMessage(t){let{klass:n,body:s,channel:o}=t,r=o.substring(o.indexOf("-")+1);this.emit("message",{id:r,klass:n,data:s})}handleState(t,...n){switch(t){case ae.Disconnected:this.state=rt.Error;break;case ae.Connecting:{let[s]=n;s>1&&(this.state=rt.Error);break}case ae.Connected:this.state=rt.Ok;break}}};gl=be(async e=>{let t=new Do(e);return await t.init(),await t.connect(),t},e=>e);(function(e){e.Ok="ok",e.Error="error"})(fn||(fn={}));$o=class extends z{constructor(t){super(),this.connect=t,this._state=fn.Ok,this.connect.on("state",this.handleState.bind(this))}get state(){return this._state}set state(t){this._state=t,this.emit("state",t)}handleState(){switch(this.connect.state){case rt.Error:this.state=fn.Error;break;case rt.Ok:default:this.state=fn.Ok;break}}};Ug=be(async e=>{let t=await ht(e.options.host);return new $o(t)},e=>e.options.host);fl=30;Go=class extends z{constructor(t,n){super(),this.eventsChecksum=null,this.id=t.id,this.host=t.host,this._context=n}get context(){return this._context}get embedUrl(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.embed}get uuid(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.uuid}get events(){var t;return((t=this._listings)===null||t===void 0?void 0:t.events)||[]}get listings(){return this._listings}set listings(t){let n=this._calculateCreatedEvents(t),s=this._calculateUpdatedEvents(t),o=this._calculateDeletedEvents(t);this._listings=Object.assign({},t),this._updateLocales(t),this._updateEventsChecksum(t),this._emitListingsEvents(n,s,o)}_calculateCreatedEvents(t){return this._listings?t.events.filter(({id:n})=>!this._listings.events.some(s=>n===s.id)):[]}_calculateUpdatedEvents(t){return this._listings?t.events.filter(n=>{let s=this._listings.events.find(({id:o})=>n.id===o);return s&&n.digest!==s.digest}):[]}_calculateDeletedEvents(t){return this._listings?this._listings.events.filter(({id:n})=>!t.events.some(s=>n===s.id)):[]}_updateLocales(t){this._locales=t.project.locales.map(n=>Object.assign({},n)).sort(n=>n.default?-1:0).map(n=>n.key),this._locale=pl(this._locales)}_updateEventsChecksum(t){this.eventsChecksum=$i(t.events.map(n=>n.digest).join(""))}_emitListingsEvents(t,n,s){let o=t.length>0,r=s.length>0,i=n.length>0,a=o||r||i;o&&this.emit("listings_events_created",t),r&&this.emit("listings_events_deleted",s),i&&this.emit("listings_events_updated",n),a&&this.emit("listings")}get isLocalisationSupported(){var t;return(t=this._listings)===null||t===void 0?void 0:t.project.is_localisation_supported}get locale(){return this._locale}set locale(t){if(!this.locales.includes(t))throw new Error(`Unknown locale name "${t}"`);this._locale=t}get locales(){return this._locales}get fields(){return this._fields!==void 0?pn(this._fields,this.locale):{}}set fields(t){let n=typeof this._fields<"u";this._fields=Object.assign({},t),n&&this.emit("updated")}get extensions(){var t;return(t=this._listings)===null||t===void 0?void 0:t.assets}get historyIgnore(){var t;let n=(t=this._listings)===null||t===void 0?void 0:t.project.history_ignore;return n&&n>0?n:fl}delete(){}};Ta=et("@monterosa/sdk-interact-kit");$t=new Map,Xn=new Map;_l=be(async e=>await ml({id:e.options.projectId,host:e.options.host},{sdk:e}),e=>e.options.projectId);(function(e){e.Upcoming="upcoming",e.Active="active",e.Prolonged="prolonged",e.Finished="finished"})(ye||(ye={}));(function(e){e.Uninitialised="uninitialised",e.Initialising="initialising",e.Initialised="initialised"})(it||(it={}));Uo=class extends z{constructor(t,n){super(),this._initState=it.Uninitialised,this._history=null,this._data=t,this._context=n,this._state=this.calculateState(),this._internalState=this.calculateInternalState(),this.boundHandleState=this.handleState.bind(this),this.boundHandleInternalState=this.handleInternalState.bind(this),this.boundHandleEventsUpdated=this.handleEventsUpdated.bind(this),this.unsubscribeStateHandler=Mn(this.boundHandleState),this.unsubscribeInternalStateHandler=Mn(this.boundHandleInternalState),this.unsubscribeListingsHandler=He(this.context.project,"listings_events_updated",this.boundHandleEventsUpdated)}calculateState(){return!this._data.started||Ke()<this.startAt?ye.Upcoming:Ke()<this.endAt?ye.Active:ye.Finished}calculateInternalState(){return!this._data.started||Ke()<this.startAt?ye.Upcoming:Ke()<this.endAt?ye.Active:Ke()<this.endAt+this._data.extra_time?ye.Prolonged:ye.Finished}handleState(){let t=this.calculateState();t===ye.Finished&&this.unsubscribeStateHandler(),t!==this._state&&(this._state=t,this.emit("state",t))}handleInternalState(){let t=this.calculateInternalState();t===ye.Finished&&this.unsubscribeInternalStateHandler(),t!==this._internalState&&(this._internalState=t,this.emit("internal_state",t))}handleEventsUpdated(t){let n=t.find(({id:s})=>s===this.id);n&&this._data.digest!==n.digest&&(this._data=n,this.handleState(),this.handleInternalState(),this.emit("updated"))}destroy(){this.unsubscribeStateHandler(),this.unsubscribeInternalStateHandler(),this.unsubscribeListingsHandler()}get context(){return this._context}get id(){return this._data.id}get name(){return this._data.name}get startAt(){return this._data.start_at}get startAtIso(){return this._data.start_at_iso}get endAt(){return this._data.end_at}get endAtIso(){return this._data.end_at_iso}get duration(){return this._data.duration}get fields(){let{locale:t}=this.context.project;return pn(this._data.custom_fields,t)}get state(){return this._state}get internalState(){return this._internalState}get initState(){return this._initState}set initState(t){this._initState=t}get history(){return this._history}set history(t){this._history=t,this.emit("history",t)}get canSubscribe(){return this._internalState===ye.Active||this._internalState===ye.Prolonged}get canLoadHistory(){return Ke()>=this.startAt+this.context.project.historyIgnore}};Gt=new Map,Ea=new Map;xl=be(async e=>{e===void 0&&(e=await Ut());let t=Object.assign(Object.assign({},e.context),{project:e});return e.events.map(n=>Fo(n,t)).sort((n,s)=>n.startAt-s.startAt)},e=>{var t,n;if(e!==void 0)return(t=e.eventsChecksum)!==null&&t!==void 0?t:e.id;let s=sn(),o=$t.get(s.options.projectId);return o?(n=o.eventsChecksum)!==null&&n!==void 0?n:o.id:s.options.projectId});kl=be(async(e,t)=>{if(Gt.has(e))return Gt.get(e);t===void 0&&(t=await Ut());let n=Object.assign(Object.assign({},t.context),{project:t}),s=t.events.find(o=>o.id===e);if(s!==void 0){let o=Fo(s,n);if(o.canLoadHistory){let r=await Zn(t.host,e);o.history=r}return o}try{let o=await Zn(t.host,e),r=Fo(o.config,n);return r.history=o,r}catch{return null}},e=>e);(function(e){e.OptionIndexOutOfRange="out_of_range",e.BelowMinVoteOptions="below_min_vote_options",e.AboveMaxVoteOptions="above_max_vote_options",e.AboveMaxVotesPerUser="above_max_per_user",e.AboveMaxVotesPerOption="above_max_per_option",e.VotedOnNonInteractiveElement="non_interactive_element",e.VotedOnClosedElement="closed_element",e.EmptyVote="empty_vote"})(qe||(qe={}));Fg={[qe.OptionIndexOutOfRange]:(e,t)=>`Options index ${t} is out of range [0..${e}]`,[qe.BelowMinVoteOptions]:(e,t)=>`Below min (${e}) vote options: ${t}`,[qe.AboveMaxVoteOptions]:(e,t)=>`Above max (${e}) vote options: ${t}`,[qe.AboveMaxVotesPerUser]:(e,t)=>`Above max (${e}) votes per user: ${t}`,[qe.AboveMaxVotesPerOption]:(e,t)=>`Above max (${e}) votes per option: ${t}`,[qe.VotedOnNonInteractiveElement]:e=>`Non interact element ${e}`,[qe.VotedOnClosedElement]:e=>`Element ${e} is closed`,[qe.EmptyVote]:e=>`Empty value for options indices: ${e}`};(function(e){e.Opened="opened",e.Closed="closed"})(mt||(mt={}));jo=class e{constructor(t=[]){this._answers=new Map;for(let{option:n,value:s}of t)this._answers.set(n,s)}get answers(){return Array.from(this._answers.entries()).map(([t,n])=>({option:t,value:n}))}static fromIndices(t){return new e(t.map(n=>({option:n,value:1})))}set(t,n){return this._answers.set(t,n),this}remove(t){return this._answers.delete(t),this}toJSON(){return this.answers}static fromJSON(t){return new e(JSON.parse(t))}};(function(e){e.Data="data",e.Poll="poll",e.RegularPoll="rpoll",e.DiametricPoll="dpoll",e.EmotingPoll="emo",e.Powerbar="powerbar",e.Prediction="prediction",e.Trivia="trivia"})(qo||(qo={}));(function(e){e.OnVote="vote",e.OnClose="close",e.OnEventEnd="event_end",e.Manual="manual",e.Never="never",e.Always="always"})(ot||(ot={}));Bo=class extends z{constructor(t,n){var s,o;super(),this._results=null,this._userAnswer=null,this._correctOption=null,this._data=t,this._context=n,this._results=((s=t.data)===null||s===void 0?void 0:s.results)||null,this._correctOption=!((o=t.data)===null||o===void 0)&&o.correct_option?t.data.correct_option-1:null,this._state=this.calculateState(),this.unsubscribeStateHandler=Mn(()=>this.handleState())}calculateState(){return Ke()<this.publishedAt+this.duration?mt.Opened:mt.Closed}handleState(){let t=this.calculateState();t===mt.Closed&&this.unsubscribeStateHandler(),t!==this._state&&(this._state=t,this.emit("state",t))}update(t){this._data=t,this.handleState()}destroy(){this.unsubscribeStateHandler()}get context(){return this._context}get id(){return this._data.id}get eventId(){return this.context.event.id}get state(){return this._state}get type(){return this._data.type}get contentType(){return this._data.content_type}get publishedAt(){return this._data.published_at}get publishedAtIso(){return this._data.published_at_iso}get updatedAt(){return this._data.updated_at}get updatedAtIso(){return this._data.updated_at_iso}get duration(){return this._data.duration}get fields(){let{locale:t}=this.context.project;return pn(this._data.custom_fields,t)}get interactive(){return this.type!==qo.Data}get pollId(){return this._data.data.id||null}get question(){let{locale:t}=this.context.project;return this._data.data.question===void 0?null:pn(this._data.data.question,t)}get answerOptions(){let{locale:t}=this.context.project;return this._data.data.options===void 0?null:pn(this._data.data.options,t)}get minOptionsPerVote(){return this._data.data.min_options_per_vote||1}get maxOptionsPerVote(){return this._data.data.max_options_per_vote||1}get maxVotesPerOption(){return this._data.data.max_votes_per_option||1}get maxVotesPerUser(){return this._data.data.max_votes_per_user||null}get userAnswer(){return this._userAnswer}set userAnswer(t){this._userAnswer=t}get hasBeenAnswered(){return this._userAnswer!==null}get showResultsMode(){return this._data.data.reveal_results_mode||null}get canShowResults(){switch(this.showResultsMode){case ot.OnVote:return this.hasBeenAnswered||this.state===mt.Closed;case ot.OnClose:return this.state===mt.Closed;case ot.Manual:return this._results!==null;case ot.OnEventEnd:return this.context.event.state===ye.Finished;case ot.Never:return!1;case ot.Always:default:return!0}}get results(){return this.canShowResults?this._results:null}set results(t){JSON.stringify(t)!==JSON.stringify(this.results)&&(this._results=t,this.canShowResults&&this.emit("results"))}get correctOption(){return this._correctOption}set correctOption(t){this._correctOption=t}get isCorrectOptionRevealed(){return this._correctOption!==null}};ke=new Map;Ol=be(async e=>{e.on("history",Ca),e.history!==null&&Ca(e.history),await Il(e.context.sdk.options.host),await vl(e)},e=>e.id);Al=be(async e=>{(await ht(e)).on("message",Nl)},e=>e);jg=be(async(e,t)=>(await Ho(e),Array.from(ke.values()).find(s=>s.id===t)||null),(e,t)=>t),$l=be(async e=>(await Ho(e),Array.from(ke.values()).filter(t=>t.eventId===e.id).sort((t,n)=>t.publishedAt-n.publishedAt)),e=>e.id,{clearOnResolve:!0});(function(e){e.Opened="opened",e.Closed="closed"})(Je||(Je={}));zo=class extends z{constructor(t,n){super(),this.host=t,this.id=n,this.state=Je.Closed,this.lastCount=0,this.connect=null,this.boundHandleMessage=this.handleMessage.bind(this),this.boundHandleTimeout=this.handleTimeout.bind(this)}async init(){this.connect=await ht(this.host),this.connect.on("message",this.boundHandleMessage)}get isOpened(){return this.state===Je.Opened}handleMessage(t){let{id:n,klass:s,data:o}=t;if(!(n!==this.id||s!==Xe.SubsCounter))try{let r=JSON.parse(o[0]);this.handleCounterUpdate(r.counter),this.resetTimeout(r.next_update_at)}catch{Ta.warn("Couldn\'t parse subscounter message.")}}handleCounterUpdate(t){if(t<0)return;let n=!1,s=!1;this.lastCount!==t&&(n=!0,this.lastCount=t),this.state===Je.Closed&&(s=!0,this.state=Je.Opened),n&&this.emit("updated",this.lastCount),s&&this.emit("state",Je.Opened)}handleTimeout(){this.state=Je.Closed,this.emit("state",Je.Closed)}resetTimeout(t){clearTimeout(this.closeTimeout),this.closeTimeout=setTimeout(this.boundHandleTimeout,(t-Ke()+3)*1e3)}destroy(){this.connect!==null&&this.connect.off("message",this.boundHandleMessage)}};Lo=new Map,qg=be(async(e,t)=>{if(Lo.has(t))return Lo.get(t);let n=new zo(e,t);return await n.init(),Lo.set(t,n),n},(e,t)=>t)});function Ma(e=15e3){let t=new Map,n,s=!1;return{announce:()=>{for(let r of[...t.keys()])r()},subscribe(r,i){return t.set(r,i),()=>{t.delete(r)}},start(r){s||n!==void 0||(n=setInterval(()=>{for(let[i,a]of[...t])(!r||a?.())&&i()},e))},stop(){s=!0,clearInterval(n),t.clear()}}}var La=ee(()=>{"use strict"});function Gl(e){let t;try{t=new URL(e??"").searchParams}catch{return"none"}return t.get("micBridgeId")===null?"none":parseInt(t.get("micBridgeVersion")??"",10)>=2?"v2":"legacy"}function Fl(e){let{kit:t,local:n,timeout:s=()=>{}}=e;if(e.bridge==="none")return t;let o=e.answerMs??1500,r,i=()=>{r=!1,s(1)};e.bridge==="legacy"?i():s(o+500);let a=l=>{if(r===!1)return l(n);if(r)return l(t);let p=l(t).finally(()=>{r===void 0&&(r=!0,s(Ul))});return new Promise((c,u)=>{let h=setTimeout(()=>{i(),p.catch(()=>{}),l(n).then(c,u)},o);p.then(c,u).finally(()=>clearTimeout(h))})};return{read:l=>a(p=>p.read(l)),write:(l,p)=>a(c=>c.write(l,p)),remove:l=>a(p=>p.remove(l))}}var Ul,jl,Da,$a=ee(()=>{"use strict";kt();zn();Ul=2e4;Da=()=>jl??=Fl({bridge:Gl(globalThis.location?.href),kit:{read:Ot,write:At,remove:Bn},local:{read:async e=>Pe.getItem(e),write:async(e,t)=>Pe.setItem(e,t),remove:async e=>Pe.removeItem(e)},timeout:Hi})});var Ua={};Wo(Ua,{createMonterosaPlatform:()=>Bl});function Vo(){let t={...ma()};return{declared:Object.keys(t).length>0,categories:t}}async function Ga(e,t){return t?await mn(t,e):(await ka(e)).find(s=>s.state==="active")}function ql(e,t){return Fi({host:e,projectId:t},`gamestage:${e}:${t}`)}async function Bl(e){let t=Kt(),n={},s=[],o=Ma(e.pollMilliseconds),r=o.announce;s.push(o.stop);let i=new Set,a,l={enabled:!1},p=Gs(e.host),c=ql(p,e.projectId),u=Da(),h=async()=>{try{let w=await Ut(c);m(w);let b=at(w?.fields),N=hs(w?.fields,w?.extensions);N&&(b.forms=N),l=zt(w?.fields);let L=await Ga(w,e.eventId);if(a=L?.id??a,L){let T=at(L.fields),H={...b.labels,...T.labels},te={...b.options,...T.options};Object.assign(b,T),Object.keys(H).length>0&&(b.labels=H),Object.keys(te).length>0&&(b.options=te)}for(let T of Object.keys(n))delete n[T];Object.assign(n,b);for(let T of[...i])T(n);g="studio",d=b,v?.write(e.projectId,b)}catch{}},m=w=>{if(!(!e.locale||!w||typeof w!="object"))try{w.locale=e.locale}catch{}},_=w=>{for(let b of Object.keys(n))delete n[b];Object.assign(n,w);for(let b of[...i])b(n)},g="none",d,v=e.rememberSettings===!1?void 0:ri({store:u,consent:e.settingsConsent??Vo}),f=v?await v.read(e.projectId):null;f&&(Object.assign(n,f),g="device");let x,E=new Promise(w=>x=w),S=(async()=>{let w=!1;try{let b=await Wn(p);x(b),s.push(un(b,N=>t.sample(N*1e3))),s.push(()=>Qn(b)),await Promise.race([Yn(b),new Promise((N,L)=>setTimeout(()=>L(new Error("mesh connect timed out")),e.connectTimeoutMs??8e3))]),w=!0}catch{x(null)}try{let b=await Promise.race([Ut(c),new Promise((H,te)=>setTimeout(()=>te(new Error("studio settings read timed out")),e.connectTimeoutMs??8e3))]);m(b);let N=at(b?.fields),L=hs(b?.fields,b?.extensions);L&&(N.forms=L),l=zt(b?.fields);let T=await Ga(b,e.eventId);if(a=T?.id,T){let H=at(T.fields),te={...N.labels,...H.labels},ce={...N.options,...H.options};Object.assign(N,H),Object.keys(te).length>0&&(N.labels=te),Object.keys(ce).length>0&&(N.options=ce)}return _(N),g="studio",d=N,v?.write(e.projectId,N),T&&w&&(s.push(Pa(T,r)),s.push(Oa(T,()=>{h()}))),b&&w&&s.push(xa(b,()=>{h()})),w&&!!T}catch{return!1}})();f?S.then(o.start):o.start(await S);let k=new Set;return s.push(No(()=>{let w=Vo();for(let b of[...k])b(w)})),{kind:"monterosa",projectId:c.options.projectId,get eventId(){return a},async elementFields(w){let b=await Ut(c),N=await mn(w,b);return N?(await Na(N)).map(T=>({id:T.id,contentType:String(T.contentType),fields:T.fields??{}})):[]},clock:t,presentation:n,get signInSettings(){return l},settingsSource:()=>g,rememberSettings(){d&&v?.write(e.projectId,d)},consent:Vo,onConsentChanged(w){return k.add(w),()=>k.delete(w)},onPresentationChanged(w){return i.add(w),()=>i.delete(w)},declareConsent(w){try{return pa(w),!0}catch{return!1}},onRoundAnnounced:o.subscribe,subscribeLive(w,b){let N=!1,L=!1,T=null,H=!1,te=[];b.status({state:"connecting"});let ce=async $=>{L=!1;try{await Mt($,w)}catch{return}N||(L=!0,b.synced(),b.status({state:"live"}))};return E.then($=>{if(!N){if(!$)return b.status({state:"unavailable"});T=$,te.push(da($,fe=>{if(fe.channel!==w)return;let _e;try{_e=JSON.parse(fe.body[0]??"")}catch{return}b.message(String(fe.klass),_e,!L)}),aa($,(fe,_e)=>b.status({state:typeof navigator<"u"&&navigator.onLine===!1?"offline":fe>1?"reconnecting":"connecting",attempt:fe,retryAt:Date.now()+_e*1e3})),ca($,()=>{L=!1,H=!0,b.status({state:"reconnecting"})}),un($,()=>{H&&(H=!1,ce($))})),ce($)}}),()=>{if(N=!0,te.forEach($=>$()),T)try{Lt(T,w)}catch{}}},emit(w){_a(w.name,{...On(w.properties),at:w.at})},storage:u,stop(){for(let w of s.splice(0))w();k.clear()}}}var Fa=ee(()=>{"use strict";Dn();Ao();ya();va();Ra();Vt();Us();St();ws();Wt();$s();La();$a()});var Yo="gs-gate-style",Wa=`\n.gs-gate{position:fixed;inset:0;z-index:2147483100;display:grid;place-items:center;padding:16px;background:rgba(10,10,14,.72);box-sizing:border-box}\n.gs-gate__card{width:100%;max-width:24rem;box-sizing:border-box;display:grid;gap:14px;padding:22px 20px;border-radius:20px;background:var(--gs-gate-surface,#fff);color:var(--gs-gate-ink,#1b1c1f);font-family:inherit;font-size:17px;line-height:1.45;box-shadow:0 10px 30px rgba(0,0,0,.25)}\n.gs-gate__title{margin:0;font-size:22px;line-height:1.25}\n.gs-gate__note{margin:0;font-weight:600}\n.gs-gate__choice{display:flex;gap:12px;align-items:flex-start;cursor:pointer}\n.gs-gate__choice input{width:22px;height:22px;margin:2px 0 0;flex:none;accent-color:var(--gs-gate-accent,#1b1c1f)}\n.gs-gate__continue{min-height:48px;padding:12px 20px;border:0;border-radius:12px;background:var(--gs-gate-accent,#1b1c1f);color:var(--gs-gate-on-accent,#fff);font:inherit;font-weight:650;cursor:pointer}\n.gs-gate__continue:disabled{opacity:.45;cursor:default}\n.gs-gate [hidden]{display:none!important}\n.gs-gate__not-me{justify-self:center;min-height:44px;padding:8px 12px;border:0;background:none;color:inherit;font:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer}\n.gs-gate__sorry{margin:0;font-size:19px;font-weight:600}\n.gs-gate :is(input,button):focus-visible{outline:3px solid var(--gs-gate-accent,#1b1c1f);outline-offset:3px}\n`;function ts(e){let t=e.GAMESTAGE_GATE;if(!t||typeof t!="object")return;let n=t,s=typeof n.minimumAge=="number"&&n.minimumAge>0?n.minimumAge:void 0,o=Array.isArray(n.territories)?n.territories.filter(r=>typeof r=="string"&&/^[A-Z]{2}$/.test(r)):[];if(!(!s&&!o.length))return{...s?{minimumAge:s}:{},...o.length?{territories:o}:{},...typeof n.note=="string"&&n.note.trim()?{note:n.note.trim()}:{}}}function ns(e,t="en-GB"){let n;try{n=new Intl.DisplayNames([t],{type:"region"})}catch{}let s=new Set(["GB","US","AE","NL","PH","CZ","DO","BS","GM","MV"]),o=e.map(r=>`${s.has(r)?"the ":""}${n?.of(r)??r}`);return o.length<=1?o.join(""):`${o.slice(0,-1).join(", ")} or ${o[o.length-1]}`}var ss=e=>`gamestage:gate:${e}`,jt=e=>JSON.stringify([e.minimumAge??null,e.territories??[]]);function Qo(e,t,n){try{let s=n?.getItem(ss(e));if(!s)return;let o=JSON.parse(s);return o.gate!==jt(t)?void 0:o.qualified===!1?"not_qualified":"qualified"}catch{return}}function Jo(e,t,n){return Qo(e,t,n)==="qualified"}function os(e,t=Ya()){try{t?.removeItem(ss(e))}catch{}}function Ya(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Qa(e,t){let n=e.minimumAge?` aged ${e.minimumAge} and over`:"",s=e.territories?.length?` in ${ns(e.territories,t)}`:"";return`Sorry, this game is for people${n}${s}.`}function bn(e,t,n={}){let s=n.document??(typeof document>"u"?void 0:document),o=n.storage??(typeof localStorage>"u"?void 0:localStorage);if(!e||!s||Jo(t,e,o))return Promise.resolve();let r=k=>{try{o?.setItem(ss(t),JSON.stringify({gate:jt(e),qualified:k,at:i().toISOString()}))}catch{}},i=n.now??(()=>new Date);if(!s.getElementById?.(Yo)){let k=s.createElement("style");k.id=Yo,k.textContent=Wa,s.head?.append(k)}let a=(k,w)=>{let b=s.createElement(k);return w&&(b.textContent=w),b},l=a("div");l.className="gs-gate",l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","gs-gate-title");let p=a("form");p.className="gs-gate__card";let c=a("h2","Before you play");if(c.id="gs-gate-title",c.className="gs-gate__title",p.append(c),e.note){let k=a("p",e.note);k.className="gs-gate__note",p.append(k)}let u=[],h=(k,w)=>{let b=a("label");b.className="gs-gate__choice";let N=a("input");N.type="checkbox",N.setAttribute("data-gs-declare",k),b.append(N,a("span",w)),u.push(N),p.append(b)};e.territories?.length&&h("territory",`I\'m in ${ns(e.territories,n.locale)}.`),e.minimumAge&&h("age",`I\'m ${e.minimumAge} or over.`);let m=a("button","Continue");m.type="submit",m.className="gs-gate__continue",m.setAttribute("data-gs-gate-continue",""),m.disabled=!0,p.append(m);let _=a("button","I don\'t meet these");_.type="button",_.className="gs-gate__not-me",_.setAttribute("data-gs-gate-not-me",""),p.append(_);let g=a("div");g.className="gs-gate__card gs-gate__exit";let d=a("p",Qa(e,n.locale));d.className="gs-gate__sorry";let v=a("button","Go back");v.type="button",v.className="gs-gate__not-me",v.setAttribute("data-gs-gate-back",""),g.append(d,v);let f=k=>{p.hidden=k,g.hidden=!k};_.onclick=()=>{r(!1),f(!0)},v.onclick=()=>{f(!1),u[0]?.focus?.()},f(Qo(t,e,o)==="not_qualified"),l.append(p,g);let x=()=>Array.from(l.querySelectorAll?.("input, button")??[]).filter(k=>!k.disabled&&!k.closest?.("[hidden]"));l.onkeydown=k=>{if(k.key!=="Tab")return;let w=x();if(!w.length)return;let b=w[0],N=w[w.length-1],L=s.activeElement;k.shiftKey&&(L===b||!l.contains?.(L))?(k.preventDefault(),N.focus()):!k.shiftKey&&(L===N||!l.contains?.(L))&&(k.preventDefault(),b.focus())};let E=k=>{l.isConnected&&!l.contains?.(k.target)&&x()[0]?.focus()};s.addEventListener?.("focusin",E);let S=()=>s.removeEventListener?.("focusin",E);for(let k of u)k.onchange=()=>{m.disabled=!u.every(w=>w.checked)};return new Promise(k=>{p.onsubmit=w=>{w.preventDefault?.(),u.every(b=>b.checked)&&(r(!0),S(),l.remove?.(),k())},(s.body??s.documentElement)?.append(l),u[0]?.focus?.()})}var W={notify:"/play/v1/games/{game}/notify",notifyConfirm:"/play/v1/games/{game}/notify/confirm",notifyResend:"/play/v1/games/{game}/notify/resend",runtime:"/play/v1/games/{game}/runtime",currentRound:"/play/v1/games/{game}/rounds/current",rounds:"/play/v1/games/{game}/rounds",roundsMine:"/play/v1/games/{game}/rounds/mine",nextRound:"/play/v1/games/{game}/rounds/next",round:"/play/v1/games/{game}/rounds/{round}",plays:"/play/v1/games/{game}/rounds/{round}/plays",session:"/play/v1/games/{game}/session",restoreSession:"/play/v1/games/{game}/session/restore",guestToken:"/play/v1/games/{game}/guest-token",gameToken:"/play/v1/games/{game}/game-token",commentsToken:"/play/v1/games/{game}/comments-token",commentsKeys:"/play/v1/comments-keys",roundState:"/play/v1/games/{game}/rounds/{round}/players/me",profile:"/play/v1/games/{game}/players/me/profile",identityOptions:"/play/v1/games/{game}/identity",identity:"/play/v1/games/{game}/players/me/identity",nameTicket:"/play/v1/games/{game}/name-ticket",recoveryCode:"/play/v1/games/{game}/players/me/recovery-code",declaration:"/play/v1/games/{game}/players/me/declaration",roundStats:"/play/v1/games/{game}/rounds/{round}/stats",leaderboard:"/play/v1/games/{game}/leaderboard",editionLeaderboard:"/play/v1/games/{game}/leaderboard/edition"};var Be={rooms:"/play/v1/games/{game}/rooms",roomJoin:"/play/v1/games/{game}/rooms/join",room:"/play/v1/games/{game}/rooms/{room}",roomStart:"/play/v1/games/{game}/rooms/{room}/start",roomLeave:"/play/v1/games/{game}/rooms/{room}/leave",roomPresence:"/play/v1/games/{game}/rooms/{room}/presence",roomPlay:"/play/v1/games/{game}/rooms/{room}/play",roomBoard:"/play/v1/games/{game}/rooms/{room}/board"};var Xo="penalty_v1";var Ja="balanced_v1",Zo={aimX:{min:-1200,max:1200},aimY:{min:-200,max:1200},power:{min:0,max:1e3}},er={postX:1e3,barY:1e3,postWidth:60,barHeight:60,ballRadius:40,keeperStart:{x:0,y:420}},Xa="shoot";function bt(e){return{op:Xa,model:Xo,shotIndex:e.shotIndex,aimX:e.aimX,aimY:e.aimY,power:e.power}}function _n(e){let t=e?.progress;if(!t||t.kind!=="shoot")return;let n=Array.isArray(t.shots)?t.shots:[];return{kind:"shoot",model:t.model??Xo,profile:t.profile??Ja,goals:typeof t.goals=="number"?t.goals:0,shots:n}}function vn(e){return e?.shots.at(-1)}function Za(e){return{...e.picks?{picks:e.picks}:{},...e.answers?{answers:e.answers}:{},...e.op?{op:e.op}:{},...e.centre!==void 0?{centre:e.centre}:{},...e.board!==void 0?{board:e.board}:{},...e.operation??{}}}var Sn=e=>`gamestage-session:${e}`;function rs(e,t=typeof localStorage>"u"?void 0:localStorage){return t?.getItem(Sn(e))??void 0}var F=(e,t,n,s)=>e.replace("{game}",encodeURIComponent(t)).replace("{round}",encodeURIComponent(n??"")).replace("{room}",encodeURIComponent(s??""));function is(){let e=new Uint8Array(12);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}var _t=class extends Error{status;code;retryable;detail;constructor(t,n,s,o,r={}){super(s),this.status=t,this.code=n,this.retryable=o,this.detail=r,this.name="PlayerApiError"}},ec=6e4;function tc(e){let t=e.split(".")[1];if(t)try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),s=n+"=".repeat((4-n.length%4)%4),o=JSON.parse(atob(s));return typeof o.exp=="number"&&Number.isFinite(o.exp)?o.exp*1e3:void 0}catch{return}}function tr(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=e.baseUrl.replace(/\\/+$/,""),s=e.storage??(typeof localStorage>"u"?void 0:localStorage),o=e.session??s?.getItem(Sn(e.game))??void 0,r;async function i(){return o||(r??=(async()=>{let f=await t(`${n}${F(W.session,e.game)}`,{method:"POST"});if(!f.ok)return;let x=await f.json();if(x.token)return o=x.token,s?.setItem(Sn(e.game),o),o})().finally(()=>{r=void 0}),r)}let a=e.now??Date.now,l,p;async function c(f=!1){return f&&(l=void 0),l&&a()<l.renewAt?l.token:(l=void 0,p??=(async()=>{let x=await d(F(W.guestToken,e.game),{method:"POST"});if(!x.token)throw new _t(200,"unknown","The Engine did not issue a guest token.",!1);let E=tc(x.token);return l=E===void 0?void 0:{token:x.token,renewAt:E-ec},x.token})().finally(()=>{p=void 0}),p)}async function u(){let f=await d(F(W.commentsToken,e.game),{method:"POST"});if(!f.token)throw new _t(200,"unknown","The Engine did not issue a comments token.",!1);return f.token}let h,m;async function _(){return h&&a()<h.renewAt?h.token:(m??=(async()=>{let f=await c(),x=await t(e.spaceAuthUrl??`${n}/api/auth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"jwt_bearer",assertion:f}).toString()}),E=await x.json().catch(()=>({}));if(!x.ok||!E.access_token)throw x.status<500&&(l=void 0),new _t(x.status,"space_sign_in_refused",E.message??"The Space did not accept the guest token.",x.status>=500);let S=(E.expires_in??3600)*1e3;return h={token:E.access_token,renewAt:a()+Math.max(S-6e4,0)},E.access_token})().finally(()=>{m=void 0}),m)}let g=()=>typeof e.identity=="function"?e.identity():e.identity;async function d(f,x,E=!0){let S=await i(),k=await g(),w=await t(`${n}${f}`,{...x,headers:{"content-type":"application/json",...S?{"x-gamestage-player":S}:{},...k?{authorization:`Bearer ${k}`}:{},...x?.headers??{}}}),b=await w.json().catch(()=>({}));if(!w.ok){let N=b.error;if(E&&w.status===401&&N?.code==="session_required")return o===S&&(o=void 0),d(f,x,!1);throw new _t(w.status,N?.code??"unknown",N?.message??w.statusText,N?.retryable??!1,N??{})}return b}return{guestToken:c,commentsToken:u,spaceToken:_,subscribeNotify:f=>d(F(W.notify,e.game),{method:"POST",body:JSON.stringify(f)}),confirmNotify:f=>d(F(W.notifyConfirm,e.game),{method:"POST",body:JSON.stringify(f)}),resendNotify:f=>d(F(W.notifyResend,e.game),{method:"POST",body:JSON.stringify(f)}),getRuntime:()=>d(F(W.runtime,e.game)),getCurrentRound:()=>d(F(W.currentRound,e.game)),getRound:f=>d(F(W.round,e.game,f)),getNextRound:()=>d(F(W.nextRound,e.game)),getRounds:()=>d(F(W.rounds,e.game)),getPlayedRounds:()=>d(F(W.roundsMine,e.game)),getRoundState:f=>d(F(W.roundState,e.game,f)),getRoundStats:f=>d(F(W.roundStats,e.game,f)),getProfile:()=>d(F(W.profile,e.game)),getIdentityOptions:()=>d(F(W.identityOptions,e.game)),createRoom:f=>d(F(Be.rooms,e.game),{method:"POST",body:JSON.stringify({name:f})}),joinRoom:(f,x)=>d(F(Be.roomJoin,e.game),{method:"POST",body:JSON.stringify({code:f,name:x})}),getRoom:f=>d(F(Be.room,e.game,void 0,f)),startRoom:f=>d(F(Be.roomStart,e.game,void 0,f),{method:"POST"}),leaveRoom:f=>d(F(Be.roomLeave,e.game,void 0,f),{method:"POST"}),roomPresence:f=>d(F(Be.roomPresence,e.game,void 0,f),{method:"POST"}),getRoomPlay:f=>d(F(Be.roomPlay,e.game,void 0,f)),getRoomBoard:f=>d(F(Be.roomBoard,e.game,void 0,f)),setIdentity:f=>d(F(W.identity,e.game),{method:"POST",body:JSON.stringify(f)}),getNameTicket:()=>d(F(W.nameTicket,e.game),{method:"POST"}),declare:f=>d(F(W.declaration,e.game),{method:"POST",body:JSON.stringify({gate:f,qualified:!0})}),getLeaderboard:()=>d(F(W.leaderboard,e.game)),getEditionLeaderboard:()=>d(F(W.editionLeaderboard,e.game)),getRecoveryStatus:()=>d(F(W.recoveryCode,e.game)),issueRecoveryCode:()=>d(F(W.recoveryCode,e.game),{method:"POST"}),restoreFromRecoveryCode:async f=>{let x=await d(F(W.restoreSession,e.game),{method:"POST",body:JSON.stringify({code:f})});return o=x.token,r=void 0,s?.setItem(Sn(e.game),o),x},play:v,shoot:(f,x,E)=>v(f,{operation:bt(x),roundVersion:x.roundVersion,challengeInstanceId:x.challengeInstanceId},E)};function v(f,x,E){return d(F(W.plays,e.game,f),{method:"POST",body:JSON.stringify({idempotency_key:E,round_version:x.roundVersion,challenge_instance_id:x.challengeInstanceId??null,payload:Za(x),...x.room?{room:x.room}:{}})})}}var vt=class extends Error{constructor(n,s,o){super(s);this.status=n;this.code=s;this.retryAfterSeconds=o;this.name="ArcadeError"}status;code;retryAfterSeconds;get retryable(){return this.code==="rate_limited"||this.code==="engine_busy"||this.status===0}get needsSignIn(){return this.code==="sign_in_required"}get runDidNotCount(){return/^(score_|duration_|run_)/.test(this.code)}},nc="/game-token";function as(e){let t=e.api.replace(/\\/$/,"")+(e.basePath??"/api/arcade"),n=e.fetch??fetch,s=e.newKey??(()=>crypto.randomUUID()),o=encodeURIComponent(e.game);async function r(){let a=await e.gameToken?.().catch(()=>{});return a?{token:a,prefix:nc}:{token:await e.token(),prefix:""}}async function i(a,l,p,c={}){let u=async()=>{let h;try{let{token:_,prefix:g}=await r();h=await n(t+g+l,{method:a,headers:{authorization:`Bearer ${_}`,...p===void 0?{}:{"content-type":"application/json"},...c},...p===void 0?{}:{body:JSON.stringify(p)}})}catch{throw new vt(0,"network_error")}let m=await h.json().catch(()=>({}));if(!h.ok)throw new vt(h.status,m.message??"unknown",m.retryAfterSeconds);return m.data};try{return await u()}catch(h){if(h instanceof vt&&h.status===0)return u();throw h}}return{start:a=>i("POST",`/games/${o}/runs`,{build:a.build},{"idempotency-key":s()}),finish:(a,l)=>i("POST",`/runs/${encodeURIComponent(a)}/result`,{score:l.score,playedMs:l.playedMs,metrics:l.metrics??{}}),board:(a="all-time",l={})=>{let p=new URLSearchParams;l.limit!==void 0&&p.set("limit",String(l.limit)),l.offset!==void 0&&p.set("offset",String(l.offset));let c=p.toString();return i("GET",`/boards/${o}/${encodeURIComponent(a)}${c?`?${c}`:""}`)},me:()=>i("GET",`/games/${o}/me`),setName:a=>i("PUT",`/games/${o}/me/name`,{ticket:a})}}var sc=e=>`edition-${e}`;var oc="\\u2764\\uFE0F",nr="other";function rc(e){if(!(typeof e!="string"||e.length===0||e.length>2048))try{let t=new URL(e.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.href.length<=2048?t.href:void 0}catch{return}}function ic(e){let n=(e??"").trim().toLowerCase().replace(/[^a-z0-9_.]/g,"").replace(/\\.{2,}/g,"."),s=/[a-z]/.test(n),r=(s?n:`fan${n?`_${n}`:""}`).slice(0,30);return(r.length>=3?r:s?r.padEnd(3,"0"):r.padEnd(3,"a"))||"fan"}function cs(e){let t=e.fetch??((...u)=>fetch(...u)),n,s,o=async(u=!1)=>{try{let h=await e.fanToken(u),m=await t(`${e.api}/api/auth/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"jwt_bearer",assertion:h}).toString()}),_=await m.json().catch(()=>({}));return!m.ok||!_.access_token?!u&&m.status<500?o(!0):null:(n=_.access_token,_.access_token)}catch{return null}},r=async()=>n||(s??=o().finally(()=>{s=void 0}),s);async function i(u,h,m=!1,_=!0){let g=_?await r():void 0;if(_&&!g)return null;try{let d=await t(`${e.api}${u}`,{...h,headers:{...h?.body!==void 0?{"content-type":"application/json"}:{},...g?{authorization:`Bearer ${g}`}:{},...h?.headers??{}}});if(_&&d.status===401&&!m)return n=void 0,s=void 0,i(u,h,!0);let v=await d.json().catch(()=>null);return{ok:d.ok,status:d.status,body:v}}catch{return null}}async function a(u,h,m=!1,_=!0){let g=await i(u,h,m,_);return g?.ok?g.body:null}async function l(u,h){let m=[],_=new Set,g;for(let d=0;d<20;d+=1){let v=g?`${u}&cursor=${encodeURIComponent(g)}`:u,f=await a(v,void 0,!1,h);if(!f||(Array.isArray(f.data)&&m.push(...f.data),g=f.meta?.page?.cursor_next,!g||_.has(g)))break;_.add(g)}return m}let p=`/api/v1/comments/topics/${encodeURIComponent(e.topicId)}`,c=u=>`${p}/messages/${encodeURIComponent(u)}`;return{suggestName:ic,async list(){return((await a(`/api/v1/comments/topics/${encodeURIComponent(e.topicId)}/messages?sort=oldest&top_level=true`,void 0,!1,!1))?.data??[]).sort((m,_)=>m.received_at-_.received_at)},async canPost(){return await r()!==null},async post(u,h){let m=rc(h?.avatarUrl),_=typeof h?.parentId=="string"&&h.parentId?h.parentId:void 0,d=(await a(p,{method:"POST",body:JSON.stringify({text:u,...m?{user_avatar_url:m}:{},..._?{parent_id:_}:{}})}))?.data?.message_id;return d?{message_id:d}:null},async replies(u){let h=await l(`${c(u)}/replies?sort=oldest&limit=100`,!1);return[...new Map(h.map(_=>[_.message_id,_])).values()].sort((_,g)=>_.received_at-g.received_at)},async react(u,h="\\u2764\\uFE0F"){let _=(await a(`${c(u)}/reactions`,{method:"POST",body:JSON.stringify({reaction_type:h})}))?.data;return typeof _?.count=="number"&&typeof _.user_reacted=="boolean"?{count:_.count,reacted:_.user_reacted}:null},async myReactions(){let u=await l(`/api/v1/comments/me/reactions?topic_id=${encodeURIComponent(e.topicId)}&limit=100`,!0),h=new Map;for(let m of u){if(typeof m?.message_id!="string"||!Array.isArray(m.reactions))continue;let _=h.get(m.message_id)??new Set;for(let g of m.reactions)typeof g=="string"&&_.add(g);h.set(m.message_id,_)}return h},async report(u,h=nr){let m=await i(`${c(u)}/reports`,{method:"POST",body:JSON.stringify({reason:h})});return m?m.ok||m.status===409&&m.body?.data?.code==="already_reported":!1},async remove(u){return(await a(`${p}/${encodeURIComponent(u)}`,{method:"DELETE"}))?.data?.deleted===!0},async me(){let h=(await a(`/api/v1/comments/me?topic_id=${encodeURIComponent(e.topicId)}`,void 0))?.data;return h&&typeof h.user_id=="string"?h:null},async setName(u){let m=(await a("/api/v1/comments/me/display-name",{method:"PUT",body:JSON.stringify({display_name:u})}))?.data;return m?.allowed!==!1&&m?.display_name?{display_name:m.display_name}:null}}}St();var wt=class extends Error{constructor(n,s,o){super(s);this.status=n;this.code=s;this.retryAfterSeconds=o;this.name="QuizError"}status;code;retryAfterSeconds;get retryable(){return bc.has(this.code)||this.status===0}get needsSignIn(){return this.code==="sign_in_required"}get questionClosed(){return this.code==="question_closed"}get needsNickname(){return this.code==="nickname_required"||this.code==="nickname_refused"||this.code==="nickname_taken"}},bc=new Set(["rate_limited","engine_busy","nickname_check_unavailable","question_not_open"]),Rr=5,_c="/game-token",vc=30;function _s(e){let t=e.api.replace(/\\/$/,"")+(e.basePath??"/api/quiz"),n=e.fetch??fetch,s=e.sleep??(c=>new Promise(u=>setTimeout(u,c))),o=e.retries??3,r=encodeURIComponent(e.game),i=c=>encodeURIComponent(c);async function a(){let c=await e.gameToken?.().catch(()=>{});return c?{token:c,prefix:_c}:{token:await e.token(),prefix:""}}async function l(c,u,h){let m=async()=>{let g;try{let{token:v,prefix:f}=await a();g=await n(t+f+u,{method:c,headers:{authorization:`Bearer ${v}`,...h===void 0?{}:{"content-type":"application/json"}},...h===void 0?{}:{body:JSON.stringify(h)}})}catch{throw new wt(0,"network_error")}let d=await g.json().catch(()=>({}));if(!g.ok){let v=d.message&&/^[a-z_]+$/.test(d.message)?d.message:g.status===429?"rate_limited":"unknown";throw new wt(g.status,v,d.retryAfterSeconds)}return d.data},_=0;for(let g=0;;g++)try{return await m()}catch(d){if(!(d instanceof wt)||!d.retryable||g>=o)throw d;let v=d.status===0?0:Math.min(d.retryAfterSeconds??1,vc);if(d.code==="question_not_open"){if(_>=Rr)throw d;v=Math.min(v,Rr-_),_+=v}await s(v*1e3)}}let p=(c={})=>{let u=new URLSearchParams;c.limit!==void 0&&u.set("limit",String(c.limit)),c.cursor!==void 0&&u.set("cursor",c.cursor);let h=u.toString();return h?`?${h}`:""};return{nickname:c=>l("POST",`/games/${r}/nickname`,{nickname:c}),me:()=>l("GET",`/games/${r}/me`),get:c=>l("GET",`/quizzes/${i(c)}`),questions:async c=>e.words?e.words(c):[],outcomes:async c=>e.outcomeWords?e.outcomeWords(c):[],outcomeShares:async c=>{try{let u=await l("GET",`/quizzes/${i(c)}/outcomes`),h=Array.isArray(u?.outcomes)?u.outcomes:[],m=typeof u?.total=="number"?u.total:0;return m<=0?[]:h.flatMap(_=>typeof _?.outcomeId=="string"&&typeof _?.count=="number"?[{outcomeId:_.outcomeId,share:Math.min(1,Math.max(0,_.count/m))}]:[])}catch{return[]}},start:c=>l("POST",`/quizzes/${i(c)}/plays`,{}),answer:(c,u)=>l("POST",`/quizzes/${i(c)}/answers`,{answers:u.map(h=>({question:h.question,option:h.option}))}),result:c=>l("GET",`/quizzes/${i(c)}/result`),board:(c,u)=>l("GET",`/quizzes/${i(c)}/board${p(u)}`),gameBoard:c=>l("GET",`/games/${r}/board${p(c)}`)}}function vs(e,t){let n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,s=n(t[_r]);if(!s)return;let o=yr.flatMap(a=>{let l=n(t[br(a)]),p=xn(t[Er(a)]);return l?[{id:a,text:l,...p?{image:p}:{}}]:[]}),r=xn(t[vr]),i=xn(t[wr]);return{id:e,question:s,options:o,...r?{image:{url:r,alt:n(t[Sr])??""}}:{},...i?{media:{url:i}}:{}}}function Ss(e,t){let n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,s=n(t[Cr]);if(!s)return;let o=n(t[Tr]),r=n(t[xr]),i=xn(t[kr]);return{id:e,name:s,...o?{verdict:o}:{},...r?{why:r}:{},...i?{image:{url:i,alt:n(t[Or])??""}}:{}}}function xn(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&typeof e.url=="string"?e.url:void 0;if(!(!t||!t.trim()))try{let n=new URL(t.trim());return n.protocol==="https:"?n.href:void 0}catch{return}}var Mr=["moment"];function Lr(e,t){let n=t?.id;return e==="side"&&(typeof n=="string"||typeof n=="number")?`side:${n}`:e}async function Dr(e,t){let n=globalThis.crypto?.subtle;if(!n)throw new Error("liveChannel needs WebCrypto (a browser, or Node 18+)");let s=new Uint8Array(await n.digest("SHA-1",new TextEncoder().encode(`gamestage/live/${e}/${t}`)));s[6]=s[6]&15|80,s[8]=s[8]&63|128;let o=[...s.subarray(0,16)].map(r=>r.toString(16).padStart(2,"0")).join("");return`l-${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function $r(e){return e.rows.map(t=>{let n={elapsed:0,sides:[]};return e.columns.forEach((s,o)=>{if(s==="elapsed")return void(n.elapsed=t[o]);let r=s.indexOf("."),i=Number(s.slice(0,r));(n.sides[i]??={})[s.slice(r+1)]=t[o]}),n})}function kn(e,t={}){let n=t.provider??"sportmonks",s=t.contest!==void 0?String(t.contest):null,o=new Map,r=new Map,i=new Set,a={state:"idle",contest:null,last:null},l=null,p=null,c=0,u=f=>{a={...a,...f};for(let x of[...i])x(a)},h=()=>o.get("state")?.sides.map(f=>f.id)??[],m=(f,x)=>f==="timeline"&&x&&typeof x=="object"&&"columns"in x?$r(x):x;function _(f,x,E){let S=m(f,x);o.set(Lr(f,S),S),a={...a,last:Date.now()};for(let k of r.get(f)??[])if(!(k.news&&E))try{k.fn(S)}catch(w){console.error(w)}}async function g(f){if(f===l)return;let x=++c;if(p?.(),p=null,o.clear(),l=f,!f)return u({state:"idle",contest:null,attempt:void 0,retryAt:void 0});if(!e.subscribeLive)return u({state:"unavailable",contest:f});u({state:"connecting",contest:f,attempt:void 0,retryAt:void 0});let E=await Dr(n,f);x===c&&(p=e.subscribeLive(E,{message:(S,k,w)=>_(S,k,w),synced:()=>u({last:a.last}),status:S=>u({...S,contest:f})}))}let d=()=>s??e.presentation.liveContest?.trim()??null;g(d()||null);let v=s?()=>{}:e.onPresentationChanged(()=>{g(d()||null)});return{get contest(){return l},get status(){return a},state:()=>o.get("state"),clock:()=>o.get("clock"),sides:()=>h().map(f=>o.get(`side:${f}`)).filter(f=>!!f),moments:()=>o.get("moments")??[],timeline:()=>o.get("timeline")??[],health:()=>o.get("health"),on(f,x,E={}){let S=E.news??Mr.includes(f),k={fn:x,news:S};if(r.set(f,[...r.get(f)??[],k]),!S)for(let[w,b]of o)(w===f||w.startsWith(`${f}:`))&&k.fn(b);return()=>r.set(f,(r.get(f)??[]).filter(w=>w!==k))},onStatus(f){return i.add(f),f(a),()=>i.delete(f)},stop(){c++,v(),p?.(),p=null,u({state:"idle"})}}}St();ls();ws();Vt();Vt();var Fr=new Map,jr=e=>{let t=Fr.get(e);if(t)return t;let n=new Promise((s,o)=>{if(typeof document>"u"){o(new Error("no document"));return}let r=document.createElement("script");r.src=e,r.async=!0,r.crossOrigin="anonymous",r.addEventListener("load",()=>s()),r.addEventListener("error",()=>o(new Error(`could not load ${e}`))),document.head.appendChild(r)});return Fr.set(e,n),n};var wc="https://fantenna.com/signal/v1.js";async function qr(e){if(!e.serviceUrl||!e.projectId)return null;await(e.load??jr)(wc);let n=globalThis.FantennaSignal;if(!n)throw new Error("the Signal tag loaded without defining itself");let s=n.init({applicationId:e.game,endpoint:"",writeKey:"",fantenna:!1,consent:!0,monterosa:{enabled:!0,serviceUrl:e.serviceUrl,projectId:e.projectId},onObservation:e.onObservation?o=>{e.onObservation?.({name:`signal_${o.type}`,at:(e.now??(()=>Date.now()))(),properties:{...o.properties,signal_event_id:o.id,observed_at:o.occurredAt}})}:void 0});return s.start?.(),{track(o,r){s.track(o,{gamestage_game:e.game,...r??{}})},stop(){s.setConsent(!1),s.stop()}}}var Es={atCapacity:{title:"Kitchen\'s at capacity",body:"This game is taking more players than it can serve right now. Nothing you did. Try again in a few minutes."},rateLimited:{title:"Too many requests from here",body:"This device is sending more requests than the game will take. Wait a moment and carry on."},cappedToday:{title:"That\'s all the plays for today",body:"This game has taken all the plays it can today. Nothing you did. Come back tomorrow."}};function Cs(e){return e==="capped_today"?"cappedToday":"atCapacity"}var lt="gamestage-busy";function Ts(e,t=Es){let n=s=>{let o=e?.[s];return typeof o=="string"&&o.trim()?o:void 0};return{atCapacity:{title:n("busyTitle")??t.atCapacity.title,body:n("busyMessage")??t.atCapacity.body},rateLimited:{title:n("rateLimitedTitle")??t.rateLimited.title,body:n("rateLimitedMessage")??t.rateLimited.body},cappedToday:{title:t.cappedToday.title,body:n("cappedTodayNote")??t.cappedToday.body}}}function xs(e,t={}){let n=t.document??globalThis.document??void 0,s=t.container??n?.body??null;if(!n||!s)return{close:()=>{}};let o=(t.copy??Es)[e];n.getElementById(lt)?.remove();let r=n.createElement("div");r.id=lt,r.setAttribute("role","alertdialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",`${lt}-title`),r.setAttribute("aria-describedby",`${lt}-body`),r.setAttribute("data-kind",e),t.retryAfterSeconds!==void 0&&r.setAttribute("data-retry-after",String(t.retryAfterSeconds)),r.style.cssText=["position:fixed","inset:0","z-index:2147483000","display:flex","align-items:flex-end","justify-content:center","padding:0","background:rgba(0,0,0,0.6)","font-family:inherit"].join(";");let i=n.createElement("div");i.style.cssText=["max-width:480px","width:100%","box-sizing:border-box","padding:20px 24px calc(24px + env(safe-area-inset-bottom, 0px))","border-radius:16px 16px 0 0","background:#fff","color:#111","text-align:center","box-shadow:0 -18px 40px -20px rgba(0,0,0,0.45)"].join(";");let a=n.createElement("div");a.setAttribute("aria-hidden","true"),a.style.cssText=["width:36px","height:4px","margin:0 auto 16px","border-radius:999px","background:rgba(17,17,17,0.18)"].join(";");let l=n.createElement("h2");l.id=`${lt}-title`,l.textContent=o.title,l.style.cssText="margin:0 0 8px;font-size:1.25rem;line-height:1.2";let p=n.createElement("p");p.id=`${lt}-body`,p.textContent=o.body,p.style.cssText="margin:0 0 20px;font-size:1rem;line-height:1.45";let c=n.createElement("button");c.type="button",c.textContent="Close",c.style.cssText=["appearance:none","border:0","cursor:pointer","padding:10px 20px","border-radius:999px","font:inherit","color:#fff","background:var(--gamestage-primary, #111)"].join(";");let u=()=>{n.removeEventListener("keydown",h),r.remove()},h=m=>{m.key==="Escape"&&u()};return c.addEventListener("click",u),r.addEventListener("click",m=>{m.target===r&&u()}),n.addEventListener("keydown",h),i.append(a,l,p,c),r.append(i),s.append(r),c.focus?.(),{close:u}}Wt();Ht();function ks(e){return`gamestage:sign-in:v1:${e}`}function Br(e,t){let n=t.toLowerCase(),s=`${e.toLowerCase()}.apps.`;if(!n.startsWith(s))return;let o=n.slice(s.length);return/^[a-z0-9.-]+\\.[a-z]{2,}$/.test(o)?`https://${o}`:void 0}function Ec(e){try{let t=e.split(".")[1],n=atob(t.replace(/-/g,"+").replace(/_/g,"/")),s=JSON.parse(n).exp;return typeof s=="number"?s:void 0}catch{return}}var Cc="anon:test.";function Tc(e){try{let t=e?.();return t?.startsWith(Cc)?t:void 0}catch{return}}function zr(e){let t=e.site??Br(e.game,e.hostname),n=e.fetch??(typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0),s=()=>e.messages??e.document?.defaultView??void 0,o=e.now??(()=>Date.now()),r=new Set,i=t&&n?"checking":"off",a,l,p,c=g=>{if(g!==i){i=g;for(let d of r)try{d(g)}catch{}}},u=g=>{try{if(!e.store||!e.mayRemember?.())return;e.store.setItem(ks(e.game),g)}catch{}},h=()=>{try{return e.store?.getItem(ks(e.game))??null}catch{return null}},m=()=>!t||!n?Promise.resolve(i):(l??=(async()=>{try{let g=Tc(e.session),d=await n(`${t}/hub/game-token`,{credentials:"include",cache:"no-store",...g?{headers:{"x-gamestage-player":g}}:{}}),v=d.ok?await d.json().catch(()=>({})):{};v.state==="granted"&&v.token?(a=v.token,c("granted"),u("granted")):v.state==="signed_out"?(a=void 0,c("signed-out")):v.state==="not_granted"?(a=void 0,c(h()==="dismissed"?"dismissed":"not-granted")):(a=void 0,c("not-available"))}catch{a=void 0,c("not-available")}return i})().finally(()=>{l=void 0}),l),_=()=>{p&&(s()?.removeEventListener("message",p.listener),p.host.remove(),p=void 0)};return{get state(){return i},begin:m,rememberedGranted:()=>h()==="granted",async token(){if(i!=="granted")return;let g=a?Ec(a):void 0;return a&&g!==void 0&&g-60>o()/1e3?a:(await m(),i==="granted"?a:void 0)},offer(g,d={}){let v=e.document,f=g.playAs?.trim();if(i!=="not-granted"||!v||!t||!f||p)return;let x=new URL(`${t}/hub/play-as`);x.searchParams.set("game",e.game),x.searchParams.set("label",f),g.detail?.trim()&&x.searchParams.set("detail",g.detail.trim()),g.dismiss?.trim()&&x.searchParams.set("dismiss",g.dismiss.trim()),d.accent&&x.searchParams.set("accent",d.accent),d.onAccent&&x.searchParams.set("on",d.onAccent),d.text&&x.searchParams.set("text",d.text);let E=v.createElement("div");E.setAttribute("data-gamestage-sign-in",""),E.style.cssText=["position:fixed","left:16px","right:16px","bottom:16px","z-index:2147483000","max-width:480px","margin:0 auto","padding:12px 16px","border-radius:16px","box-shadow:0 8px 28px rgba(0,0,0,.18)",`background:${d.surface??"Canvas"}`,"visibility:hidden"].join(";");let S=v.createElement("iframe");S.src=x.toString(),S.title=f.replaceAll("{name}","").trim(),S.style.cssText="display:block;width:100%;height:56px;border:0;background:transparent;color-scheme:normal",S.setAttribute("allowtransparency","true"),E.appendChild(S);let k=w=>{if(w.origin!==t||w.source!==S.contentWindow)return;let b=w.data;if(!(!b||b.type!=="gamestage-sign-in"))switch(b.state){case"ready":typeof b.height=="number"&&b.height>0&&b.height<400&&(S.style.height=`${Math.ceil(b.height)}px`),E.style.visibility="visible",c("offered");return;case"granted":_(),c("checking"),m();return;case"dismissed":_(),u("dismissed"),c("dismissed");return;default:_(),c("not-available")}};s()?.addEventListener("message",k),p={host:E,iframe:S,listener:k},v.body.appendChild(E)},async streak(){if(!(i!=="granted"||!t||!n))try{let g=await n(`${t}/hub/game-streak`,{credentials:"include",cache:"no-store"}),d=g.ok?await g.json().catch(()=>({})):{};return d.state==="granted"?d.streak:void 0}catch{return}},async request(g,d={},v){if(i==="granted"||i==="off"||i==="not-available")return i;if(i==="dismissed"&&c("not-granted"),i==="not-granted")return this.offer(g,d),i;if(i==="signed-out"&&t){let f=e.document,x=`${t}/hub/signin?return_to=${encodeURIComponent("/hub")}`,E=()=>{f?.visibilityState!=="hidden"&&(f?.removeEventListener("visibilitychange",E),m().then(()=>this.offer(g,d)))};f?.addEventListener("visibilitychange",E),(v??(S=>f?.defaultView?.open?.(S,"_blank")))(x)}return i},onChange(g){return r.add(g),()=>r.delete(g)},stop(){_(),r.clear()}}}Tn();function Hr(e){return`${dr}:${e}`}function Vr(e){return Object.entries(e).filter(t=>typeof t[1]=="boolean").sort(([t],[n])=>t.localeCompare(n))}function Os(e,t,n){return n===!0?!0:!t||!e?!1:e.querySelector(\'script[src*="user-consent"], script[src*="onetrust"], script[src*="cookielaw"]\')!=null}function xc(e){return{declared:!0,categories:{...e.categories}}}function As(e){let t=e.window??globalThis,n=e.policyVersion?.trim()||us,s=e.now??(()=>new Date),o=new Set,r=e.hostManagesConsent===!0||e.hostOwnsConsent===!0,i=null,a=new Set(Cn([...e.embedOrigins??[]])),l=()=>{try{return t?.localStorage}catch{return}},c=(()=>{try{let E=l()?.getItem(Hr(e.scope?.trim()||e.game));if(!E)return null;let S=ur(JSON.parse(E));return!S||S.source!=="fan"||S.policyVersion!==n?null:S}catch{return null}})(),u=null,h=E=>u!==null&&JSON.stringify(Vr(E))===u,m=()=>{let E=e.platform.consent();return!E.declared||h(E.categories)?null:E},_=(()=>{try{return!!(t&&t.parent&&t.parent!==t)}catch{return!0}})(),g=()=>{let E=m();return E?qt(E.categories,"host",{policyVersion:n,at:s()}):e.hostOwnsConsent?i:c??i},d=()=>{let E=x.reading();for(let S of[...o])S(E)},v=E=>{if(!_||E.source!==t?.parent||typeof E.origin!="string"||!a.has(E.origin))return;let S=E.data;!S||S.type!==lr||!S.categories||typeof S.categories!="object"||typeof S.policyVersion!="string"||S.policyVersion.trim()!==n||(i=qt(S.categories,"host",{policyVersion:n,at:s()}),d())};t?.addEventListener?.("message",v);let f=e.platform.onConsentChanged(()=>d()),x={reading(){let E=g();return E?xc(E):e.hostOwnsConsent?{declared:!0,categories:{necessary:!0,functional:!0}}:{declared:!1,categories:{necessary:!0}}},record:()=>g(),needed:()=>!r&&e.policy.analyticsRequiresConsent&&g()===null,hostDecides:()=>r||m()!==null,decide(E){if(x.hostDecides())return!1;let S=qt(E,"fan",{policyVersion:n,at:s()});c=S;try{l()?.setItem(Hr(e.scope?.trim()||e.game),JSON.stringify(S))}catch{}try{u=JSON.stringify(Vr(S.categories)),e.platform.declareConsent({...S.categories})}catch{}return d(),!0},onChange(E){return o.add(E),()=>o.delete(E)},stop(){t?.removeEventListener?.("message",v),f(),o.clear()}};return x}Tn();var Kr="gs-consent-style",kc=`\n.gs-consent{position:fixed;left:0;right:0;bottom:var(--gs-consent-clear,0px);z-index:2147483000;display:flex;justify-content:center;padding:12px 12px calc(12px + env(safe-area-inset-bottom));pointer-events:none;box-sizing:border-box}\n.gs-consent[hidden]{display:none}\n.gs-consent--top{bottom:auto;top:0;padding:calc(12px + env(safe-area-inset-top)) 12px 12px}\n.gs-consent__card{pointer-events:auto;position:relative;width:100%;max-width:26rem;box-sizing:border-box;display:grid;gap:12px;padding:16px 44px 16px 18px;border-radius:20px;border:1px solid rgba(0,0,0,.08);background:var(--gs-consent-surface,#fff);color:var(--gs-consent-ink,#1b1c1f);box-shadow:0 10px 30px rgba(0,0,0,.18);font-family:inherit;font-size:15px;line-height:1.45}\n.gs-consent__title{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n.gs-consent p{margin:0}\n.gs-consent a{color:var(--gs-consent-accent-ink,inherit);text-decoration:underline;text-decoration-color:var(--gs-consent-accent,currentColor);text-decoration-thickness:2px;text-underline-offset:4px}\n.gs-consent__row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}\n.gs-consent button{font:inherit;cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation}\n.gs-consent__pill{font-weight:600!important;font-size:15px;min-height:44px;min-width:6.5rem;padding:0 20px;border-radius:999px;box-sizing:border-box}\n.gs-consent__pill:active{transform:translateY(1px)}\n.gs-consent__accept{border:2px solid var(--gs-consent-accent,#1b1c1f);background:var(--gs-consent-accent,#1b1c1f);color:var(--gs-consent-on-accent,#fff)}\n.gs-consent__reject{border:2px solid currentColor;background:transparent;color:inherit}\n.gs-consent__close{position:absolute;top:6px;right:6px;width:40px;height:40px;border:0;border-radius:999px;background:transparent;color:inherit;font-size:22px!important;line-height:1;opacity:.7;display:grid;place-items:center;padding:0}\n.gs-consent__choose{border:0;background:none;color:inherit;text-decoration:underline;text-underline-offset:3px;font-size:14px;padding:4px 2px;min-height:44px}\n.gs-consent button:focus{outline:none}\n.gs-consent button:focus-visible,.gs-consent input:focus-visible,.gs-consent a:focus-visible,.gs-consent__card:focus-visible{outline:3px solid currentColor;outline-offset:2px}\n.gs-consent fieldset{border:0;margin:0;padding:0;display:grid;gap:8px}\n.gs-consent label{display:flex;gap:10px;align-items:flex-start;cursor:pointer}\n.gs-consent input[type=checkbox]{width:22px;height:22px;margin:1px 0 0;flex:none;accent-color:var(--gs-consent-accent,currentColor)}\n.gs-consent__note{font-size:14px}\n@media (min-width:720px){.gs-consent:not(.gs-consent--top) .gs-consent__card--bar{max-width:60rem;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:20px;padding:12px 52px 12px 20px}.gs-consent__card--bar .gs-consent__row{flex-wrap:nowrap}}\n.gs-consent-settings{font:inherit;font-size:inherit;background:none;border:0;color:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:0 .25em;margin:0 0 0 .75em;min-height:0;line-height:inherit;display:inline;vertical-align:baseline}\n.gs-consent-footer{display:block;text-align:center;padding:12px 16px calc(12px + env(safe-area-inset-bottom));font-size:14px}\n.gs-consent-footer .gs-consent-settings{margin:0}\n.gs-copyright-link{display:inline-block;white-space:nowrap;text-decoration:underline}\n.gs-consent-settings:focus{outline:none}\n.gs-consent-settings:focus-visible{outline:3px solid currentColor;outline-offset:2px}\n.gs-consent-room [data-gs-page]::after{content:"";display:block;block-size:var(--gs-consent-room,0px);pointer-events:none}\n`;function Oc(e){return e.footCoversMain&&!e.topCoversKept?"top":"foot"}function Is(e,t){let n=e.presentation??{},s={brand:n.consentBrandName,title:n.consentTitle,detail:n.consentDetail,accept:n.consentAcceptLabel,reject:n.consentRejectLabel,choose:n.consentChooseLabel,save:n.consentSaveLabel,analytics:n.consentAnalyticsLabel,marketing:n.consentMarketingLabel,functional:n.consentFunctionalLabel,settings:n.consentSettingsLabel},o={...fr,...t};for(let[r,i]of Object.entries(s))i&&i.trim()&&(o[r]=i);return o}var Wr=["analytics","marketing","functional"],Ac=Object.freeze({analytics:!0,marketing:!1,functional:!1});function Ps(e,t={}){let n=globalThis.document;if(!n.getElementById(Kr)){let P=n.createElement("style");P.id=Kr,P.textContent=kc,n.head.append(P)}let s=n.createElement("div");s.className="gs-consent",Ns(s),s.hidden=!0,s.dataset.gsComponent="consent",s.setAttribute("aria-live","polite"),n.body.append(s);let o=null,r=null,i=P=>{e.consent.decide(P),s.hidden=!0,_(),t.onDecided?.(P)},a=(P,I,G,j="")=>{let D=n.createElement("button");return D.type="button",D.textContent=P,D.dataset.gsPart=I,j&&(D.className=j),D.addEventListener("click",G),D};function l(P){let I=Is(e,t.words),G=e.consent.record()?.categories??{},j=n.createElement("div");j.className=P?"gs-consent__card":"gs-consent__card gs-consent__card--bar",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","false"),j.setAttribute("aria-labelledby","gs-consent-title"),j.tabIndex=-1;let D=n.createElement("h2");D.id="gs-consent-title",D.className="gs-consent__title",D.textContent=I.title;let V=n.createElement("p");V.textContent=pr(I.detail,I.brand);let R=e.presentation?.privacyPolicyUrl;if(R&&/^https?:\\/\\//.test(R)){let K=n.createElement("a");K.href=R,K.target="_blank",K.rel="noopener",K.textContent=I.policy,V.append(" ",K,".")}let re=a("\\xD7","dismiss",()=>{s.hidden=!0,_()},"gs-consent__close");re.setAttribute("aria-label",I.dismiss),j.append(D,re,V);let q=(K,Oe,ie,Le)=>a(K,Oe,Le,`gs-consent__pill gs-consent__${ie}`);if(P){let K=n.createElement("fieldset"),Oe=n.createElement("legend");Oe.className="gs-consent__note",Oe.textContent=I.necessary,K.append(Oe);let ie={};for(let Ee of Wr){let De=n.createElement("label"),ve=n.createElement("input");ve.type="checkbox",ve.checked=G[Ee]===!0,ve.dataset.gsPart=Ee,ie[Ee]=ve,De.append(ve,n.createTextNode(I[Ee])),K.append(De)}let Le=n.createElement("div");Le.className="gs-consent__row",Le.append(q(I.save,"save","accept",()=>i(Object.fromEntries(Wr.map(Ee=>[Ee,ie[Ee].checked])))),q(I.reject,"reject","reject",()=>i({analytics:!1,marketing:!1,functional:!1}))),j.append(K,Le)}else{let K=n.createElement("div");K.className="gs-consent__row",K.append(q(I.accept,"accept","accept",()=>i({...Ac})),q(I.reject,"reject","reject",()=>i({analytics:!1,marketing:!1,functional:!1})),a(I.choose,"choose",()=>N(!0,!0),"gs-consent__choose")),j.append(K)}return s.replaceChildren(j),j}let p=n.body,c=n.documentElement,u=p.style.paddingBottom,h=c.style.scrollPaddingBottom,m=()=>n.defaultView,_=()=>{s.hidden&&E();let P=s.querySelector(".gs-consent__card"),I=s.hidden||!P||s.classList.contains("gs-consent--top"),G=I?0:Math.ceil(m().innerHeight-P.getBoundingClientRect().top);p.style.paddingBottom=I?u:`calc(${u||"0px"} + ${G}px)`;let j=I?h:`${G}px`;c.style.scrollPaddingBottom!==j&&(c.style.scrollPaddingBottom=j);let D=I?"":`${G}px`;c.style.getPropertyValue("--gs-consent-room")!==D&&(D?c.style.setProperty("--gs-consent-room",D):c.style.removeProperty("--gs-consent-room")),c.classList.contains("gs-consent-room")===I&&c.classList.toggle("gs-consent-room",!I)},g=32,d=(P,I)=>{let G=Math.min(Math.max(I.left+I.width/2,0),n.documentElement.clientWidth-1),j=Math.min(Math.max(I.top+I.height/2,0),(n.defaultView?.innerHeight??1)-1),V=(typeof n.elementsFromPoint=="function"?n.elementsFromPoint(G,j):[]).find(R=>!s.contains(R));return!V||V===P||P.contains(V)||V.contains(P)},v=()=>{let P=n.defaultView;if(!P)return 0;let I=P.innerHeight,G=[];for(let D of Array.from(n.body.querySelectorAll("body *"))){if(s.contains(D))continue;let V=P.getComputedStyle(D).position;if(V!=="fixed"&&V!=="sticky")continue;let R=D.getBoundingClientRect();R.width===0||R.height===0||R.height>=I*.4||R.bottom<=0||d(D,R)&&G.push(R)}G.sort((D,V)=>V.bottom-D.bottom);let j=0;for(let D of G)I-D.bottom<=j+g&&(j=Math.max(j,I-D.top));return j},f=null,x="",E=()=>{f&&(f.style.paddingBottom=x),f=null},S=P=>{let I=n.querySelector(".gs-boot:not([data-done])");if(!I||!P||s.hidden||s.classList.contains("gs-consent--top"))return E();f!==I&&(E(),f=I,x=I.style.paddingBottom);let G=Math.ceil(m().innerHeight-P.getBoundingClientRect().top);I.style.paddingBottom=`calc(env(safe-area-inset-bottom, 0px) + ${G}px)`},k=()=>{if(!n.defaultView)return;s.style.setProperty("--gs-consent-clear",`${Math.ceil(v())}px`),s.classList.remove("gs-consent--top");let P=s.querySelector(".gs-consent__card");if(S(P),P&&!s.hidden){let I=P.getBoundingClientRect(),G=Array.from(n.querySelectorAll(\'.gs-boot__play, [data-gamestage-start], [data-gs-main], [data-gs-part="commit"]\')),j=(D,V)=>D.some(R=>{let re=R.getBoundingClientRect();return re.width===0||re.height===0||V.right<=re.left||re.right<=V.left||V.bottom<=re.top||re.bottom<=V.top?!1:d(R,re)});if(j(G,I)){s.classList.add("gs-consent--top"),E();let D=Array.from(n.querySelectorAll("[data-gs-keep-clear]")),V=D.length>0&&j(D,P.getBoundingClientRect());Oc({footCoversMain:!0,topCoversKept:V})==="foot"&&(s.classList.remove("gs-consent--top"),S(P))}}_()},w=typeof ResizeObserver=="function"?new ResizeObserver(()=>{_()}):null;m()?.addEventListener("resize",k),w?.observe(s);let b=!1;function N(P=!1,I=!1){Ns(s);let G=l(P);b=I||!s.hidden&&b,s.hidden=!1,_(),I&&G.focus({preventScroll:!0}),k()}let L=null,T=()=>{if(t.settingsIn!==void 0)return t.settingsIn;let P=n.querySelector(\'[data-gs-slot="privacy-settings"]\');if(P)return P;let I=n.querySelector(\'[data-gs-part="recovery"]\');if(I?.parentElement&&I.parentElement!==n.body)return I.parentElement;let G=n.querySelectorAll("footer");return G.length?G[G.length-1]:(L||(L=n.createElement("div"),L.className="gs-consent-footer",L.dataset.gsPart="settings-footer",n.body.append(L)),L)},H=()=>{let P=e.consent.hostDecides()?null:T();if(!P){o?.remove(),o=null,r?.remove(),r=null;return}o||(o=a(Is(e,t.words).settings,"settings",()=>N(!0,!0),"gs-consent-settings")),o.parentElement!==P&&P.append(o),r||(r=n.createElement("a"),r.className="gs-consent-settings gs-copyright-link",r.dataset.gsPart="copyright",r.href=gr,r.target="_blank",r.rel="noopener",r.textContent=Is(e,t.words).copyright),r.previousElementSibling!==o&&o.after(r),L&&P!==L&&(L.remove(),L=null)},te=!1,ce=typeof MutationObserver=="function"&&t.settingsIn===void 0?new MutationObserver(P=>{te||P.every(I=>s.contains(I.target)||(o?.contains(I.target)??!1))||(te=!0,queueMicrotask(()=>{te=!1,H()}))}):null;ce?.observe(n.body,{childList:!0,subtree:!0});let $=e.consent.onChange(()=>{H(),(e.consent.hostDecides()||!b&&!e.consent.needed())&&(s.hidden=!0,_())});H();let fe=!1,_e=typeof MutationObserver=="function"?new MutationObserver(P=>{s.hidden||fe||P.every(I=>I.target===n.body||s.contains(I.target)||I.target===f&&I.attributeName==="style")||(fe=!0,(m()?.requestAnimationFrame??setTimeout)(()=>{fe=!1,Ns(s),k()}))}):null;return _e?.observe(n.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","data-done","data-state"]}),e.consent.needed()&&!e.consent.hostDecides()&&N(!1),{open:()=>{e.consent.hostDecides()||N(!0,!0)},close:()=>{s.hidden=!0,_()},stop:()=>{$(),ce?.disconnect(),_e?.disconnect(),m()?.removeEventListener("resize",k),w?.disconnect(),E(),s.remove(),o?.remove(),L?.remove(),p.style.paddingBottom=u,c.style.scrollPaddingBottom=h,c.style.removeProperty("--gs-consent-room"),c.classList.remove("gs-consent-room")}}}function Yr(e){let t=e.match(/rgba?\\(\\s*(\\d+)[ ,]+(\\d+)[ ,]+(\\d+)/);if(!t)return null;let[n,s,o]=[t[1],t[2],t[3]].map(r=>{let i=Number(r)/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*n+.7152*s+.0722*o}function Qr(e,t){let n=Yr(e),s=Yr(t);return n===null||s===null?null:(Math.max(n,s)+.05)/(Math.min(n,s)+.05)}function Ns(e){let t=e.ownerDocument.defaultView;if(!t)return;let n=t.getComputedStyle(e.ownerDocument.documentElement),s=e.ownerDocument.createElement("span");e.append(s);let o=a=>(s.style.color="",s.style.color=a,t.getComputedStyle(s).color),r=[["--gs-backgroundContainerColour","--gs-onBackgroundContainerColour"],["--gs-backgroundMainColour","--gs-onBackgroundColour"]];for(let[a,l]of r){let p=n.getPropertyValue(a).trim(),c=n.getPropertyValue(l).trim();if(!p||!c)continue;let u=Qr(o(p),o(c));if(u!==null&&u>=4.5){e.style.setProperty("--gs-consent-surface",p),e.style.setProperty("--gs-consent-ink",c);break}}let i=[["--gs-highlightMainColour","--gs-onHighlightColour"],["--gamestage-primary",""],["--gs-primaryMainColour","--gs-onPrimaryColour"]];for(let[a,l]of i){let p=n.getPropertyValue(a).trim();if(!p)continue;let c=o(p),u=n.getPropertyValue(l||"--none").trim(),m=(u?[u,"#ffffff","#111111"]:["#ffffff","#111111"]).find(_=>(Qr(c,o(_))??0)>=4.5);if(m){e.style.setProperty("--gs-consent-accent",p),e.style.setProperty("--gs-consent-on-accent",m);break}}s.remove()}var An={heading:"Can\'t load the game right now",body:"Check your connection, then try again.",retry:"Try again"},Yt=class extends Error{code="unavailable";handled=!0;constructor(){super("Interaction Cloud did not answer and this device has no remembered settings, so the game has no words to show. The library has drawn its retry screen."),this.name="GamestageUnavailableError"}},Jr="gamestage-unavailable";function Xr(e){let t=e.document;if(!t?.body||typeof t.createElement!="function"||t.getElementById?.(Jr))return;let n=t.createElement("div");n.setAttribute("id",Jr),n.setAttribute("role","alert"),Object.assign(n.style,{position:"fixed",inset:"0",zIndex:"2147483647",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"16px",padding:"24px",background:"#111",color:"#fff",fontFamily:"system-ui, -apple-system, sans-serif",textAlign:"center"});let s=t.createElement("h1");s.textContent=An.heading,Object.assign(s.style,{fontSize:"22px",margin:"0",fontWeight:"700"});let o=t.createElement("p");o.textContent=An.body,Object.assign(o.style,{fontSize:"17px",margin:"0",opacity:"0.8"});let r=t.createElement("button");r.setAttribute("type","button"),r.textContent=An.retry,Object.assign(r.style,{fontSize:"17px",fontWeight:"700",minHeight:"48px",padding:"0 28px",borderRadius:"999px",border:"0",background:"#fff",color:"#111",cursor:"pointer",touchAction:"manipulation",userSelect:"none"}),r.addEventListener("click",()=>e.location?.reload()),n.appendChild(s),n.appendChild(o),n.appendChild(r),t.body.appendChild(n)}async function de(e){if(e===void 0)return{kind:"anonymous"};try{let t=typeof e=="function"?await e():e;return typeof t=="string"&&t.length>0?{kind:"identified",token:t}:{kind:"anonymous"}}catch{return{kind:"anonymous"}}}function me(e){return e.kind==="identified"?e.token:void 0}var Zr=e=>e.replace(/\\/+$/,"");async function Ic(e){let t=me(await de(e.identity));if(!t)return{kind:"anonymous"};let n=e.fetchImpl??globalThis.fetch,s=`${Zr(e.baseUrl)}/api/loyalty/v1/me`,o={Authorization:`Bearer ${t}`},r=await n(`${s}/points`,{headers:o});if(r.status===401||r.status===403)return{kind:"anonymous"};if(!r.ok)throw new Error(`Loyalty points read failed: ${r.status}`);let a=((await r.json()).items??[]).find(_=>_.programmeId===e.programmeId),{unlocked:l,stillToUnlock:p,catalogue:c}=await Nc(n,s,o);if(!a)return{kind:"standing",standing:{programmeId:e.programmeId,balance:0,enrolled:!1,statement:[],catalogue:c,unlocked:l,stillToUnlock:p}};let u=e.statementLimit??20,h=await n(`${s}/points/${encodeURIComponent(e.programmeId)}/statement?limit=${u}`,{headers:o}),m=h.ok?(await h.json()).lines??[]:[];return{kind:"standing",standing:{programmeId:a.programmeId,balance:a.balance,tier:a.tier,tiers:a.tiers,enrolled:!0,statement:m,catalogue:c,unlocked:l,stillToUnlock:p}}}async function Rs(e){if(!e.baseUrl)return null;let t=me(await de(e.identity));if(!t)return null;let n=e.fetchImpl??globalThis.fetch;try{let s=await n(`${Zr(e.baseUrl)}/api/loyalty/v1/me/streak`,{headers:{Authorization:`Bearer ${t}`}});return s.ok?Ms(await s.json()):null}catch{return null}}function Ms(e){let t=e??{};return typeof t.current!="number"||typeof t.best!="number"?null:{current:t.current,best:t.best,lastDay:t.lastDay??"",proved:t.proved===!0,nextMilestone:t.nextMilestone}}async function Nc(e,t,n){let[s,o]=await Promise.all([e(`${t}/rewards`,{headers:n}).catch(()=>{}),e(`${t}/products`,{headers:n}).catch(()=>{})]),r=s?.ok?((await s.json()).items??[]).map(c=>({instanceId:c.instance.instanceId,product:{productId:c.instance.product.productId,name:c.instance.product.name,description:c.instance.product.description,type:c.instance.product.type},campaignName:c.campaign?.name,awardedAt:c.awardedAt})):[],i=o?.ok?(await o.json()).items??[]:[],a=new Set(r.map(c=>c.product.productId)),l=i.map(c=>({productId:c.productId,name:c.name,description:c.description,type:c.type})),p=l.filter(c=>!a.has(c.productId));return{unlocked:r,stillToUnlock:p,catalogue:l}}function Pc(e){let t=e.round;if(!t)return"No round has been read yet.";let n=t.origin;return n?n.source==="studio"?`This round came from Studio: element ${n.element_id??"unknown"}`+(n.edition_id?` on edition ${n.edition_id}`:"")+`, as round ${t.id} version ${t.version}.`:`This round came from the game\'s manifest, as ${t.id} version ${t.version}.`:`This round is ${t.id}, and this Engine does not say where it came from. That is older than the field, not a manifest round.`}function Rc(e){return(e.performance?.getEntriesByType?.("resource")??[]).slice(-40).map(n=>{let s=n;return{name:s.name,status:s.responseStatus?String(s.responseStatus):"unknown",ms:Math.round(s.duration)}})}function Mc(e,t){let n=[Pc(e),"",`game ${e.game}`,`platform ${e.platform}`];e.offPlatformReason&&n.push(`not on ic ${e.offPlatformReason}`),e.ids?.project&&n.push(`project ${e.ids.project}`),e.ids?.event&&n.push(`edition ${e.ids.event}`),e.ids?.element&&n.push(`element ${e.ids.element}`),e.ids?.host&&n.push(`studio host ${e.ids.host}`),e.endpoints.playerApi&&n.push(`player api ${e.endpoints.playerApi}`),e.endpoints.mesh&&n.push(`mesh ${e.endpoints.mesh}`),n.push(`identity ${e.identity.signedIn?`${e.identity.kind}, signed in`:e.identity.kind}`),n.push(`consent ${e.consent.allowed?"granted":"not granted"}`);let s=Object.entries(e.presentation).filter(([,o])=>o);n.push(`producer ${s.length?s.map(([o])=>o).join(", "):"nothing set"}`),n.push("","requests");for(let o of Rc(t))n.push(` ${o.status.padEnd(7)} ${o.ms.toString().padStart(5)}ms ${o.name}`);return n.push("",`page ${t.location?.href??"unknown"}`),n.push(`when ${new Date().toISOString()}`),n.join(`\n`)}var ei="gsdebug",Lc="gamestage-debug";function Dc(e,t){let n=e.document,s=n.createElement("div");s.id="gamestage-debug",s.setAttribute("role","dialog"),s.setAttribute("aria-label","Gamestage diagnostics"),s.style.cssText=["position:fixed","inset:auto 0 0 0","max-height:70vh","overflow:auto","z-index:2147483647","background:#0b0f1c","color:#e8eaf2","font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace","padding:12px 14px","border-top:2px solid #e5484d","white-space:pre-wrap"].join(";");let o=n.createElement("div");o.style.cssText="display:flex;gap:8px;margin-bottom:10px";let r=n.createElement("button");r.textContent="Copy",r.style.cssText="font:inherit;padding:4px 10px;cursor:pointer",r.onclick=()=>{e.navigator.clipboard?.writeText(t).then(()=>r.textContent="Copied",()=>r.textContent="Select and copy")};let i=n.createElement("button");i.textContent="Close",i.style.cssText=r.style.cssText,i.onclick=()=>s.remove(),o.append(r,i);let a=n.createElement("div");return a.textContent=t,s.append(o,a),s}function ti(e,t){let n=t.document;if(!n)return()=>{};let s=()=>{n.getElementById("gamestage-debug")?.remove(),n.body?.append(Dc(t,Mc(e(),t)))},o="",r=i=>{let a=i.target;a?.isContentEditable||a?.tagName==="INPUT"||a?.tagName==="TEXTAREA"||i.key.length!==1||(o=(o+i.key.toLowerCase()).slice(-ei.length),o===ei&&s())};return n.addEventListener("keydown",r),t.location&&new URLSearchParams(t.location.search).has(Lc)&&t.setTimeout(s,0),()=>n.removeEventListener("keydown",r)}Wt();function Ls(e={}){let t=Kt(),n=new Map,s=[],o=new Set,r=new Set,i=new Set,a={...e.presentation??{}},l={declared:!1,categories:{}},p,c=!1,u=()=>{for(let g of[...o])g()},h=e.setInterval??((g,d)=>setInterval(g,d)),m=e.clearInterval??(g=>clearInterval(g)),_=e.pollMilliseconds??0;return _>0&&(p=h(u,_)),{kind:"local",offPlatformReason:e.offPlatformReason,clock:t,emitted:s,presentation:a,signInSettings:e.signInSettings??{enabled:!1},consent:()=>l,onConsentChanged(g){return r.add(g),()=>r.delete(g)},onPresentationChanged(g){return i.add(g),()=>i.delete(g)},setPresentation(g){for(let d of Object.keys(a))delete a[d];Object.assign(a,g);for(let d of[...i])d(a)},declareConsent(g){l={declared:!0,categories:{...g}};for(let d of[...r])d(l);return!0},onRoundAnnounced(g){return o.add(g),()=>o.delete(g)},subscribeLive(g,d){let v=e.liveSource;if(!v||typeof EventSource>"u")return d.status({state:"unavailable"}),()=>{};let f=!1;d.status({state:"connecting"});let x=`${v}${v.includes("?")?"&":"?"}channel=${encodeURIComponent(g)}`,E=new EventSource(x);return E.onmessage=S=>{try{let k=JSON.parse(S.data);d.message(k.class,k.body,!f)}catch{}},E.addEventListener("synced",()=>{f=!0,d.synced(),d.status({state:"live"})}),E.onerror=()=>{f=!1,d.status({state:typeof navigator<"u"&&navigator.onLine===!1?"offline":"reconnecting"})},()=>E.close()},announce:u,emit(g){s.push(g)},storage:{read:async g=>n.get(g)??null,write:async(g,d)=>{n.set(g,d)},remove:async g=>{n.delete(g)}},stop(){c||(c=!0,p!==void 0&&m(p),o.clear(),r.clear())}}}Ht();$s();function ii(e,t){let n=new Date(e);if(!Number.isNaN(n.getTime()))try{return n.toLocaleDateString("en-CA",{timeZone:t})}catch{return}}function ai(e){let t=new Date(`${e}T12:00:00Z`);return t.setUTCDate(t.getUTCDate()-1),t.toISOString().slice(0,10)}function Gc(e,t={}){let n=t.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",s=t.now??new Date,o=new Set;for(let u of e){if(u.amount<=0)continue;let h=ii(u.occurredAt,n);h&&o.add(h)}if(o.size===0)return{days:0,capped:!1,today:!1};let r=ii(s.toISOString(),n)??"",i=o.has(r),a=i?r:ai(r);if(!o.has(a))return{days:0,capped:!1,today:i};let l=0;for(;o.has(a);)l+=1,a=ai(a);let p=[...o].sort()[0],c=a<p;return{days:l,capped:c,today:i}}Vt();Us();Wt();St();function ci(e,t,n=Date.now(),s){if(!e?.can.results_available||!e.finalAt||n>=Date.parse(e.finalAt))return"";let o=new Date(e.finalAt).toLocaleString(s,{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"});return t.replaceAll("{finalAt}",o)}function Uc(e,t,n="label_provisional_result"){let s,o=()=>{clearTimeout(s),t.textContent=ci(e.round,e.presentation?.labels?.[n.replace(/^label_/,"")]??hr,e.now()),t.hidden=!t.textContent;let a=Date.parse(e.round?.finalAt??"")-e.now();a>0&&(s=setTimeout(o,Math.min(a,2147483647)))},r=e.onRoundChanged(o),i=e.onPresentationChanged(o);return o(),()=>{clearTimeout(s),r(),i()}}var di={open:"Your progress",showTitle:"Keep your progress",showDetail:"Save this code. It brings your name, scores and achievements back on another phone or browser. You only see it once.",private:"Keep it private. Anyone with this code can play as you.",replace:"Getting a new code stops the old one working.",get:"Get a recovery code",issueFailed:"That didn\'t work. Check your connection and try again.",copy:"Copy",copied:"Copied",share:"Share",enterTitle:"I\'ve played before",enterDetail:"Type the recovery code you saved to get your progress back.",submit:"Get my progress back",notRecognised:"That code isn\'t one we know. Check it against the one you saved.",restored:"Welcome back. Your progress is on this device now.",close:"Close"};var li="gs-recovery-style",Fc=`\n.gs-recovery-open{font:inherit;background:none;border:0;color:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;padding:.5rem 0;min-height:44px}\n.gs-recovery{border:0;border-radius:16px;padding:0;max-width:min(26rem,calc(100vw - 32px));width:100%;color:#1b1c1f;background:#fff;box-shadow:0 18px 48px rgba(0,0,0,.35)}\n.gs-recovery::backdrop{background:rgba(0,0,0,.55)}\n.gs-recovery__body{display:grid;gap:12px;padding:20px;font:17px/1.45 system-ui,sans-serif}\n.gs-recovery h2{margin:0;font-size:1.2rem}\n.gs-recovery p{margin:0}\n.gs-recovery__code{font:700 1.25rem/1.3 ui-monospace,Menlo,monospace;letter-spacing:.02em;text-align:center;padding:12px;border:1.5px solid #c9ccd3;border-radius:10px;background:#f4f5f7;user-select:all;overflow-wrap:anywhere}\n.gs-recovery__row{display:flex;gap:8px;flex-wrap:wrap}\n.gs-recovery button{font:inherit;font-weight:600;min-height:44px;padding:0 16px;border-radius:10px;border:1.5px solid #1b1c1f;background:#fff;color:#1b1c1f;cursor:pointer}\n.gs-recovery button.gs-recovery__primary{background:#1b1c1f;color:#fff}\n.gs-recovery button:disabled{opacity:.5;cursor:default}\n.gs-recovery input{font:16px/1.3 system-ui,sans-serif;min-height:44px;padding:0 12px;border:1.5px solid #c9ccd3;border-radius:10px}\n.gs-recovery input[aria-invalid=true]{border-color:#c62828;border-style:dashed}\n.gs-recovery__note{color:#50535c;font-size:.95rem}\n.gs-recovery__error{color:#c62828}\n.gs-recovery hr{border:0;border-top:1px solid #e3e5e9;margin:4px 0}\n`;function jc(e,t){let n=e.presentation??{},s={open:n.recoveryOpenLabel,showTitle:n.recoveryShowTitle,showDetail:n.recoveryShowDetail,private:n.recoveryPrivateNote,replace:n.recoveryReplaceNote,enterTitle:n.recoveryEnterTitle,enterDetail:n.recoveryEnterDetail,submit:n.recoverySubmitLabel,notRecognised:n.recoveryNotRecognised,restored:n.recoveryRestored,get:n.recoveryGetLabel,issueFailed:n.recoveryIssueFailed,copy:n.recoveryCopyLabel,copied:n.recoveryCopiedLabel,share:n.recoveryShareLabel,close:n.recoveryCloseLabel},o={...di,...t};for(let[r,i]of Object.entries(s))i&&i.trim()&&(o[r]=i);return o}function Y(e,t,n={},...s){let o=e.createElement(t),{dataset:r,...i}=n;return Object.assign(o,i),r&&Object.assign(o.dataset,r),o.append(...s),o}function qc(e,t,n={}){let s=t.ownerDocument;s.getElementById(li)||s.head.append(Y(s,"style",{id:li,textContent:Fc}));let o=()=>jc(e,n.words),r=Y(s,"button",{type:"button",className:"gs-recovery-open",textContent:o().open});r.dataset.gsPart="recovery";let i=Y(s,"dialog",{className:"gs-recovery"});i.setAttribute("aria-labelledby","gs-recovery-title"),t.append(r),s.body.append(i);function a(){let c=o(),u=Y(s,"div",{className:"gs-recovery__body"}),h=Y(s,"h2",{id:"gs-recovery-title",textContent:c.showTitle}),m=Y(s,"p",{className:"gs-recovery__code",hidden:!0});m.setAttribute("aria-label",c.showTitle);let _=Y(s,"button",{type:"button",textContent:c.copy,hidden:!0}),g=Y(s,"button",{type:"button",textContent:c.share,hidden:!0}),d=Y(s,"span",{className:"gs-recovery__note"});d.setAttribute("aria-live","polite");let v=Y(s,"button",{type:"button",className:"gs-recovery__primary",textContent:c.get}),f=Y(s,"p",{className:"gs-recovery__error",hidden:!0});f.setAttribute("role","alert"),v.addEventListener("click",async()=>{v.disabled=!0,f.hidden=!0;try{let L=await e.client.issueRecoveryCode();m.textContent=L.code,m.hidden=!1,_.hidden=!1,g.hidden=typeof navigator.share!="function",v.hidden=!0}catch{f.textContent=c.issueFailed,f.hidden=!1,v.disabled=!1}}),_.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(m.textContent??""),d.textContent=c.copied}catch{d.textContent=""}}),g.addEventListener("click",async()=>{try{await navigator.share({text:m.textContent??""})}catch{}});let x=Y(s,"h2",{textContent:c.enterTitle}),E=Y(s,"form");E.noValidate=!0;let S=Y(s,"label",{htmlFor:"gs-recovery-input",textContent:c.enterTitle});S.hidden=!0;let k=Y(s,"input",{id:"gs-recovery-input",type:"text",placeholder:"four words and two numbers"});k.setAttribute("inputmode","text"),k.setAttribute("autocomplete","off"),k.setAttribute("autocorrect","off"),k.setAttribute("autocapitalize","none"),k.setAttribute("spellcheck","false"),k.setAttribute("enterkeyhint","go");let w=Y(s,"p",{className:"gs-recovery__error",id:"gs-recovery-error",hidden:!0});w.setAttribute("role","alert");let b=Y(s,"button",{type:"submit",className:"gs-recovery__primary",textContent:c.submit});E.addEventListener("submit",async L=>{L.preventDefault();let T=k.value.trim();if(!T)return;let H=T;b.disabled=!0,w.hidden=!0,k.removeAttribute("aria-invalid");try{await e.client.restoreFromRecoveryCode(H),d.textContent=c.restored,w.hidden=!0,E.replaceChildren(Y(s,"p",{textContent:c.restored})),await n.onRestored?.()}catch{w.textContent=c.notRecognised,w.hidden=!1,k.setAttribute("aria-invalid","true"),k.setAttribute("aria-describedby","gs-recovery-error"),b.disabled=!1}}),E.append(S,k,w,b);let N=Y(s,"button",{type:"button",textContent:c.close});N.addEventListener("click",()=>i.close()),u.append(h,Y(s,"p",{textContent:c.showDetail}),v,m,Y(s,"div",{className:"gs-recovery__row"},_,g),d,Y(s,"p",{className:"gs-recovery__note",textContent:`${c.private} ${c.replace}`}),f,Y(s,"hr"),x,Y(s,"p",{textContent:c.enterDetail}),E,Y(s,"div",{className:"gs-recovery__row"},N)),i.replaceChildren(u)}let l=()=>{a(),i.showModal()};r.addEventListener("click",l);let p=e.onPresentationChanged?.(()=>{r.textContent=o().open});return()=>{r.removeEventListener("click",l),p?.(),r.remove(),i.remove()}}St();function In(e){let t=[],n=/\\[([^\\]]*)\\]/g,s=0;for(let o of e.matchAll(n))o.index>s&&t.push({text:e.slice(s,o.index),accent:!1}),o[1]&&t.push({text:o[1],accent:!0}),s=o.index+o[0].length;return s<e.length&&t.push({text:e.slice(s),accent:!1}),t.filter(o=>o.text.length>0)}function Fs(e){return In(e).map(t=>t.text).join("")}var Bc=["displayName","strapline","howToPlay","playButtonLabel","playAgainLabel","resultButtonLabel","shareButtonLabel","editionName","editionStrapline"];function zc(e,t={},n={}){let s=t.document??globalThis.document??void 0,o=e.displayName||n.displayName||void 0;for(let c of Bc){let u=c==="displayName"?o:e[c],h=t[c];if(h){if(!u){Hc(h);continue}Jt.has(h)?Jt.get(h).wrote=u:Jt.set(h,{text:h.textContent??"",hidden:h.hasAttribute?.("hidden")??!1,wrote:u}),h.textContent=u,h.removeAttribute("hidden")}}if(s)if(o)Qt.has(s)?Qt.get(s).wrote=o:Qt.set(s,{before:s.title,wrote:o}),s.title=o;else{let c=Qt.get(s);c&&s.title===c.wrote&&(s.title=c.before),Qt.delete(s)}let r=t.root??s?.documentElement??null;if(!r)return;let i={};if(e.primaryColour&&(i["--gamestage-primary"]=e.primaryColour,Object.assign(i,gi(e.primaryColour))),e.cssVariables){for(let[u,h]of Object.entries(e.cssVariables))h&&(i[`--gs-${u}`]=h);let c=e.cssVariables.highlightMainColour;c&&Object.assign(i,gi(c)),Object.assign(i,Si(e.cssVariables));for(let u of Yc){let h=Bt(e.cssVariables[u],e.uploadedFonts??[]);h&&(i[`--gs-${u}`]=h.family)}}let a=Ei(e);Object.assign(i,a.vars),Wc(s,a);let l=Bt(e.defaultFontFamily,e.uploadedFonts??[]);l&&(i["--gs-font-default"]=`"${l.family}", system-ui, sans-serif`),s&&sd(s,e.uploadedFonts),s&&Jc(s,e),e.logoAccentColour&&(i["--gs-title-accent"]=e.logoAccentColour),s&&ad(s,e.logoText,o),s&&cd(s,e,o),s&&qs(s,e.logoText,o);let p=ui.get(r)??new Set;for(let c of p)c in i||r.style.removeProperty(c);for(let[c,u]of Object.entries(i))r.style.setProperty(c,u);ui.set(r,new Set(Object.keys(i)))}var ui=new WeakMap,Jt=new WeakMap,Qt=new WeakMap;function Hc(e){let t=Jt.get(e);t&&(Jt.delete(e),e.textContent===t.wrote&&(e.textContent=t.text,t.hidden&&e.setAttribute?.("hidden","")))}var Vc={backgroundMainColour:["background"],onBackgroundColour:["ink"],backgroundContainerColour:["surface"],highlightMainColour:["interactive"],highlightVariantColour:["interactive-base"],onHighlightColour:["on-accent"],positiveMainColour:["positive"],positiveVariantColour:["positive-base"],negativeMainColour:["negative"],negativeVariantColour:["negative-base"],secondaryMainColour:["selected"],tertiaryMainColour:["reward"]};function Si(e){let t={};for(let[n,s]of Object.entries(Vc)){let o=e[n];if(o)for(let r of s)t[`--gs-color-${r}`]=o,t[`--gs-color-${r}-solid`]=o}return t}function gi(e){let t={},n=(o,r)=>{t[`--gs-color-${o}`]=r,t[`--gs-color-${o}-solid`]=r};n("interactive",e),n("interactive-hover",`color-mix(in oklab, ${e} 82%, white)`),n("interactive-base",`color-mix(in oklab, ${e} 68%, black)`);let s=Kc(e);return s!==void 0&&n("on-accent",s>.4?"#111111":"#ffffff"),t}function Kc(e){let t=e.trim(),n,s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(s){let a=s[1].length===3?s[1].split("").map(l=>l+l).join(""):s[1];n=[0,2,4].map(l=>parseInt(a.slice(l,l+2),16))}else{let a=/^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i.exec(t);a&&(n=a.slice(1,4).map(Number))}if(!n)return;let[o,r,i]=n.map(a=>{let l=a/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)});return .2126*o+.7152*r+.0722*i}var wi="[data-gamestage-title], :root:not(:has([data-gamestage-title])) h1";function Ei(e){let t={},n=[],s,o=e.cssVariables??{},r=o.fontTitleFamily??e.titleFont,i=o.fontTitleWeight??e.titleFontWeight,a=o.fontTitleTracking??e.titleLetterSpacing,l=o.fontTitleCase??e.titleCase,p=Bt(r,e.uploadedFonts??[]);if(p){t["--gs-title-font"]=`"${p.family}", var(--gs-font-display, system-ui), sans-serif`,n.push("font-family: var(--gs-title-font)");let m=p.stylesheetHref?Ir(r,i)?.weight:i;m!==void 0&&m!==""&&(t["--gs-title-weight"]=String(m),n.push("font-weight: var(--gs-title-weight)")),s=p.stylesheetHref}let c=Nr(a);c&&(t["--gs-title-tracking"]=c,n.push("letter-spacing: var(--gs-title-tracking)"));let u=Pr(l);u&&(t["--gs-title-case"]=u,n.push("text-transform: var(--gs-title-case)")),e.titleColour&&(t["--gs-title-colour"]=e.titleColour,n.push("color: var(--gs-title-colour)"));let h=n.length?`${wi} { ${n.join("; ")}; }`:"";return e.logoText&&(h+=`${h?" ":""}.gamestage-title-accent { color: var(--gs-title-accent, inherit); }`),{vars:t,css:h,fontHref:s}}var fi="gamestage-title-style",pi="gamestage-title-font";function Wc(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=e.getElementById(fi);if(t.css?(n||(n=e.createElement("style"),n.id=fi,e.head.appendChild(n)),n.textContent!==t.css&&(n.textContent=t.css)):n?.remove(),!t.fontHref){e.getElementById(pi)?.remove();return}Ti(e,pi,t.fontHref)}var mi="gamestage-font-preconnect",hi="gamestage-role-font-",Ci=["fontBodyFamily","fontNumberFamily","fontCTAFamily","fontLabelFamily","fontHighlightFamily"],Yc=["fontTitleFamily",...Ci];function Qc(e){if(e.getElementById(mi))return;let t=e.createElement("link");t.id=mi,t.rel="preconnect",t.href=ys,t.crossOrigin="anonymous",e.head.appendChild(t)}function Ti(e,t,n){Qc(e);let s=e.getElementById(t);s&&s.href===n||(s||(s=e.createElement("link"),s.id=t,s.rel="stylesheet",e.head.appendChild(s)),s.media="print",s.onload=()=>{s&&(s.media="all")},s.href=n)}function Jc(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=t.cssVariables??{},s=t.uploadedFonts??[],o=new Map,r=[t.defaultFontFamily,...Ci.map(i=>n[i])];for(let i of r){let a=Bt(i,s);if(!a?.stylesheetHref)continue;let l=a.family.toLowerCase().replace(/[^a-z0-9]+/g,"-");o.set(`${hi}${l}`,a.stylesheetHref)}for(let i of Array.from(e.head.children)){let a=i.id;i.tagName==="LINK"&&a.startsWith(hi)&&!o.has(a)&&i.remove()}for(let[i,a]of o)Ti(e,i,a)}var yi="gamestage-font-faces",bi="gamestage-font-preload-",Xc={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype"};function Zc(e){let t=e.trim();return!/^(https:)?\\/\\//i.test(t)||/["\'()\\\\\\s<>{}]/.test(t)?null:t}function ed(e){let t=e.split(/[?#]/)[0]?.split(".").pop()?.toLowerCase();return t?Xc[t]:void 0}function td(e){let t=[],n=new Set;for(let s of e??[]){let o=bs(s.name??""),r=Zc(s.url??"");if(!o||!r)continue;let i=o.toLowerCase().replace(/[^a-z0-9]+/g,"-");if(n.has(i))continue;n.add(i);let a=String(s.weight??"").trim();t.push({family:o,url:r,weight:/^\\d{2,4}$/.test(a)?a:"400",slug:i})}return t}function nd(e){let t=ed(e.url),n=t?`url("${e.url}") format("${t}")`:`url("${e.url}")`;return`@font-face { font-family: "${e.family}"; src: ${n}; font-weight: ${e.weight}; font-display: swap; }`}function sd(e,t){if(!e?.head||typeof e.createElement!="function")return;let n=td(t),s=e.getElementById(yi);if(!n.length)s?.remove();else{let r=n.map(nd).join(" ");s||(s=e.createElement("style"),s.id=yi,e.head.appendChild(s)),s.textContent!==r&&(s.textContent=r)}let o=new Map(n.map(r=>[`${bi}${r.slug}`,r]));for(let r of Array.from(e.head.children)){let i=r.id;r.tagName==="LINK"&&i.startsWith(bi)&&!o.has(i)&&r.remove()}for(let[r,i]of o){if(e.getElementById(r))continue;let a=e.createElement("link");a.id=r,a.rel="preload",a.as="font",a.href=i.url,a.crossOrigin="anonymous",e.head.appendChild(a)}}var Xt=new WeakMap,ze="data-gamestage-logo",od="gamestage-title-accent";function xi(e,t,n){let s=Array.from(e.querySelectorAll("[data-gamestage-title]"));if(s.length)return s;let o=new Set([t,Fs(n)].filter(Boolean).map(r=>r.trim().toLowerCase()));return Array.from(e.querySelectorAll("h1")).filter(r=>r.hasAttribute(ze)||o.has((r.textContent??"").trim().toLowerCase()))}function _i(e){let t=Xt.get(e);if(t?.text){for(let n of xi(e,t.name,t.text)){if(n.getAttribute(ze)===t.text&&n.textContent===Fs(t.text))continue;let s=In(t.text).map(o=>{if(!o.accent)return e.createTextNode(o.text);let r=e.createElement("span");return r.className=od,r.textContent=o.text,r});n.replaceChildren(...s),n.setAttribute(ze,t.text),t.name&&n.setAttribute("aria-label",t.name)}qs(e,t.text,t.name)}}var rd=20,js="data-gamestage-fit",vi=new WeakSet;function qs(e,t,n){if(typeof e.querySelectorAll!="function")return;let s=e.defaultView;if(!s||typeof s.getComputedStyle!="function")return;let o=t?.trim()||n;if(o){for(let r of xi(e,n,o))id(r,s);if(!vi.has(e)){vi.add(e);let r=()=>{let i=Xt.get(e);qs(e,i?.text,i?.name??n)};s.addEventListener?.("resize",r),e.fonts?.addEventListener?.("loadingdone",r),e.fonts?.ready?.then(r)}}}function id(e,t){if(!e.style)return;e.hasAttribute(js)&&(e.style.removeProperty("font-size"),e.style.removeProperty("white-space"),e.style.removeProperty("overflow-wrap"),e.removeAttribute(js));let n=e.clientWidth;if(!n)return;let s=e.style.whiteSpace;e.style.whiteSpace="nowrap";let o=e.scrollWidth;if(o<=n){e.style.whiteSpace=s;return}let r=parseFloat(t.getComputedStyle(e).fontSize);e.style.fontSize=`${Math.max(rd,Math.floor(r*n/o*.97))}px`,e.setAttribute(js,""),e.scrollWidth>n?(e.style.whiteSpace="normal",e.style.overflowWrap="anywhere"):e.style.whiteSpace=s}function ad(e,t,n){if(typeof e.querySelectorAll!="function")return;let s=Xt.get(e)??{},o=t?.trim()||void 0;if(!o){if(s.text)for(let i of Array.from(e.querySelectorAll(`[${ze}]`)))i.removeAttribute(ze),i.removeAttribute("aria-label"),n&&(i.textContent=n);s.observer?.disconnect(),Xt.set(e,{name:n});return}if(s.text!==o)for(let i of Array.from(e.querySelectorAll(`[${ze}]`)))i.removeAttribute(ze);s.text=o,s.name=n,Xt.set(e,s),_i(e);let r=e.defaultView;if(!s.observer&&r?.MutationObserver&&e.body){let i=!1;s.observer=new r.MutationObserver(()=>{i||(i=!0,queueMicrotask(()=>{i=!1,_i(e)}))}),s.observer.observe(e.body,{childList:!0,subtree:!0,characterData:!0})}}function cd(e,t,n){let s=e.defaultView,o=s?.gamestageSplash;if(!o?.update)return;let r=t.cssVariables??{};o.update({start:t.splashGradientStart||r.backgroundMainColour,end:t.splashGradientEnd||r.backgroundContainerColour,ink:t.titleColour,accent:t.logoAccentColour,play:t.splashPlayLabel,resume:t.splashContinueLabel,error:t.splashErrorText,retry:t.splashRetryLabel});let i=e.querySelector(".gs-boot__logo"),a=()=>s?.gamestageSplash?.fit?.(),l=t.logoText?.trim()||n;i&&l&&i.getAttribute(ze)!==l&&(i.replaceChildren(...In(l).map(p=>{if(!p.accent)return e.createTextNode(p.text);let c=e.createElement("span");return c.className="gs-boot__accent",c.textContent=p.text,c})),i.setAttribute(ze,l),n&&i.setAttribute("aria-label",n),a())}ds();var dd="US1 1 10;AG1 1 10;AI1 1 10;AS1 1 10;BB1 1 10;BM1 1 10;BS1 1 10;CA1 1 10;DM1 1 10;DO1 1 10;GD1 1 10;GU1 1 10;JM1 1 10;KN1 1 10;KY1 1 10;LC1 1 10;MP1 1 10;MS1 1 10;PR1 1 10;SX1 1 10;TC1 1 10;TT1 1 10;VC1 1 10;VG1 1 10;VI1 1 10;RU7 8 10;KZ7 8 10;EG20 0 10;ZA27 0 5.6.7.8.9;GR30 0 10;NL31 0 9.11;BE32 0 9;FR33 0 9;ES34 0 9;HU36 06 9;IT39 0 9.10;VA39 0 9.10;RO40 0 9;CH41 0 9;AT43 0 7.8.9.10.11.12.13;GB44 0 10;GG44 0 10;IM44 0 10;JE44 0 10;DK45 0 8;SE46 0 9;NO47 0 8;SJ47 0 8;PL48 0 9;DE49 0 10.11;PE51 0 9;MX52 0 10;CU53 0 8;AR54 0 10.11;BR55 0 10.11;CL56 0 9;CO57 0 10;VE58 0 10;MY60 0 9.10;AU61 0 9;CC61 0 9;CX61 0 9;ID62 0 9.10.11.12;PH63 0 10;NZ64 0 8.9.10;SG65 0 8;TH66 0 9;JP81 0 10;KR82 0 9.10;VN84 0 9;CN86 0 11;TR90 0 10;IN91 0 10;PK92 0 10;AF93 0 9;LK94 0 9;MM95 0 7.8.9.10;IR98 0 10;SS211 0 9;MA212 0 9;EH212 0 9;DZ213 0 9;TN216 0 8;LY218 0 9;GM220 0 7.9;SN221 0 9;MR222 0 8;ML223 0 8;GN224 0 9;CI225 10;BF226 0 8;NE227 0 8;TG228 0 8;BJ229 10;MU230 0 8;LR231 0 7.9;SL232 0 8;GH233 0 9;NG234 0 10;TD235 0 8;CF236 0 8;CM237 0 9;CV238 0 7;ST239 0 7;GQ240 0 9;GA241 7.8;CG242 9;CD243 0 7.9;AO244 0 9;GW245 0 9;IO246 0 7;AC247 0 5;SC248 0 7;SD249 0 9;RW250 0 9;ET251 0 9;SO252 0 7.8.9;DJ253 0 8;KE254 0 9;TZ255 0 9;UG256 0 9;BI257 0 8;MZ258 0 9;ZM260 0 9;MG261 0 9;RE262 0 9;YT262 0 9;ZW263 0 9;NA264 0 9;MW265 0 9;LS266 0 8;BW267 0 8;SZ268 0 8;KM269 0 7;SH290 0 5;TA290 0 4;ER291 0 7;AW297 0 7;FO298 0 6;GL299 0 6;GI350 0 8;PT351 0 9;LU352 0 9;IE353 0 9;IS354 0 7.9;AL355 0 9;MT356 0 8;CY357 0 8;FI358 0 6.7.8.9.10;AX358 0 6.7.8.9.10;BG359 0 8.9;LT370 0 8;LV371 0 8;EE372 0 7.8;MD373 0 8;AM374 0 8;BY375 8 9;AD376 0 6.9;MC377 0 8.9;SM378 0 8;UA380 0 9;RS381 0 8.9.10;ME382 0 8;XK383 0 8;HR385 0 8.9;SI386 0 8;BA387 0 8.9;MK389 0 8;CZ420 0 9;SK421 0 9;LI423 0 7.9;FK500 0 5;BZ501 0 7;GT502 0 8;SV503 0 8;HN504 0 8;NI505 0 8;CR506 0 8;PA507 0 7.8;PM508 0 6.9;HT509 0 8;GP590 0 9;BL590 0 9;MF590 0 9;BO591 0 8;GY592 0 7;EC593 0 9;GF594 0 9;PY595 0 9;MQ596 0 9;SR597 0 7;UY598 0 8;CW599 0 7.8;BQ599 0 7;TL670 0 8;NF672 0 6;BN673 0 7;NR674 0 7;PG675 0 8;TO676 0 7;SB677 0 5.7;VU678 0 7;FJ679 0 7;PW680 0 7;WF681 0 6;CK682 0 5;NU683 0 4.7;WS685 0 7.10;KI686 0 8;NC687 0 6;TV688 0 6.7;PF689 0 8;TK690 0 4.5.6.7;FM691 0 7;MH692 1 7;KP850 0 10;HK852 0 8;MO853 0 8;KH855 0 8.9;LA856 0 9.10;BD880 0 10;TW886 0 9;MV960 0 7;LB961 0 7.8;JO962 0 9;SY963 0 9;IQ964 0 10;KW965 0 8;SA966 0 9;YE967 0 9;OM968 0 8;PS970 0 9;AE971 0 9;IL972 0 9;BH973 0 8;QA974 0 8;BT975 0 8;MN976 0 8;NP977 0 10;TJ992 0 9;TM993 8 8;AZ994 0 9;GE995 0 9;KG996 0 9;UZ998 0 9",Nn=dd.split(";").map(e=>{let[t,n,s]=e.split(" ");return[t.slice(0,2),t.slice(2),n,s.split(".").map(Number)]});var Zt=new Map(Nn.map(e=>[e[0],e])),ld="GB",ud=`\n.gs-notify-form [hidden]{display:none!important}\n:where(.gs-notify-field){display:grid;gap:12px}\n:where(.gs-notify-via){display:flex;gap:4px;margin:0;padding:4px;border:0;border-radius:10px;background:var(--bg,#fff)}\n:where(.gs-notify-via legend){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}\n:where(.gs-notify-via label){flex:1;display:block;position:relative;cursor:pointer}\n:where(.gs-notify-via input){position:absolute;inset:0;margin:0;opacity:0;cursor:pointer}\n:where(.gs-notify-via span){display:block;padding:10px 12px;border-radius:8px;text-align:center;font-weight:600}\n:where(.gs-notify-via input:checked+span){background:var(--text,#222);color:var(--bg,#fff)}\n:where(.gs-notify-via input:focus-visible+span){outline:3px solid var(--text,#222);outline-offset:2px}\n:where(.gs-notify-phone){display:flex;gap:8px}\n:where(.gs-notify-country){position:relative;flex:none;display:flex;align-items:center;gap:6px;min-height:48px;padding:0 12px;border-radius:10px;background:var(--bg,#fff);white-space:nowrap}\n:where(.gs-notify-country)::after{content:"";width:7px;height:7px;margin:-4px 0 0 2px;border:solid currentColor;border-width:0 2px 2px 0;transform:rotate(45deg)}\n:where(.gs-notify-country select){position:absolute;inset:0;width:100%;opacity:0;cursor:pointer;font:inherit}\n:where(.gs-notify-country:focus-within){outline:3px solid var(--text,#222);outline-offset:3px}\n:where(.gs-notify-phone input){flex:1}\n.gs-notify-form .gs-notify-secondary{min-height:48px;padding:12px 20px;border:1.5px solid currentColor;border-radius:10px;background:transparent;color:inherit;font:inherit;font-weight:600;cursor:pointer}\n.gs-notify-form .gs-notify-secondary:disabled{opacity:.55;cursor:default}\n.gs-notify-form .gs-notify-link{min-height:0;padding:4px 0;border:0;background:none;color:inherit;font:inherit;text-decoration:underline;text-underline-offset:3px;cursor:pointer;justify-self:start}\n:where(.gs-notify-confirm){margin-top:16px}\n:where(.gs-notify-confirm input[name=code]){letter-spacing:.3em;font-variant-numeric:tabular-nums;max-width:12ch}\n:where(.gs-notify-error){margin:0;color:var(--gs-errorColour,#b3261e);font-weight:600}\n`;function gd(e){let t;try{t=new Intl.DisplayNames([e],{type:"region"})}catch{}return Nn.map(([n,s])=>({code:n,name:t?.of(n)??n,dial:`+${s}`})).sort((n,s)=>n.name.localeCompare(s.name,e))}function fd(e){return String.fromCodePoint(...[...e].map(t=>127397+t.charCodeAt(0)))}function pd(){let e=typeof navigator>"u"?[]:[...navigator.languages??[],navigator.language];for(let t of e){let n=t?.split("-").slice(1).find(s=>/^[A-Za-z]{2}$/.test(s))?.toUpperCase();if(n&&Zt.has(n))return n}return ld}function ki(e,t){let n=Zt.get(t);return n&&e.startsWith(n[1])?t:Nn.find(([,s])=>e.startsWith(s))?.[0]}function Bs(e,t){let n=e.trim().replace(/^00/,"+"),s=n.replace(/\\D/g,""),o=Zt.get(t);if(n.startsWith("+")){let c=ki(s,t);if(o=c?Zt.get(c):void 0,!o)return;s=s.slice(o[1].length)}else if(!o)return;let[,r,i,a]=o,l=c=>a.includes(c.length);i&&s.startsWith(i)?s=s.slice(i.length):!n.startsWith("+")&&s.startsWith(r)&&!l(s)&&l(s.slice(r.length))&&(s=s.slice(r.length));let p=`+${r}${s}`;return l(s)&&wn(p,"sms")?p:void 0}function md(e,t){let n=!1,s=!1,o="",r=typeof navigator>"u"?"en-GB":navigator.language||"en-GB",i,a=new Map,l,p=()=>{l!==void 0&&clearInterval(l),l=void 0},c=(g,d)=>{let v=g?.status??0,f=g?.message;return v>=400&&v<500&&f?f:d};if(typeof document<"u"&&document.head&&!document.head.querySelector?.("style[data-gs-notify]")){let g=document.createElement("style");g.setAttribute("data-gs-notify",""),g.textContent=ud,document.head.append(g)}let u=()=>{if(s)return;let g=e.round?.id??"",d=a.get(g)??{email:"",phone:"",country:pd(),message:"",pending:!1,saved:!1};a.set(g,d);let v=e.presentation.notify,f=JSON.stringify([g,n,v,d.message,d.pending,d.saved,d.awaiting]);if(f===o)return;o=f;let x=t.contains?.(document.activeElement),E=x?document.activeElement?.name:void 0;if(t.hidden=!n||!v?.enabled||!v.ownerName||!/^https:\\/\\//.test(v.privacyUrl)||!v.channels.length,t.replaceChildren(),t.hidden||!v)return;let S=v.labels,k=v.channels.includes("sms")?"sms":v.channels.includes("rcs")?"rcs":void 0,w=v.channels.includes("email");(!d.channel||(d.channel==="email"?!w:!k))&&(d.channel=k?"phone":"email");let b=(A,U)=>{let X=document.createElement(A);return U&&(X.textContent=U),X},N=t.id||"gs-notify",L=b("h2",S.title);L.id=`${N}-title`,t.setAttribute("aria-labelledby",L.id);let T=b("p");if(T.setAttribute("role","status"),T.hidden=!0,t.append(L,T),p(),d.saved){T.textContent=S.success,T.hidden=!1,x&&(T.tabIndex=-1,T.focus());return}if(d.awaiting){let A=d.awaiting,U=A.channel!=="email";T.textContent=A.note||A.sent,T.hidden=!1;let X=b("form");X.className="gs-notify-form gs-notify-confirm",X.noValidate=!0;let Z=b("input"),ne=b("p");if(U){Z.name="code",Z.id=`${N}-code`,Z.autocomplete="one-time-code",Z.inputMode="numeric",Z.maxLength=6,Z.value=A.code,ne.id=`${N}-code-error`,ne.className="gs-notify-error",ne.textContent=A.error,ne.hidden=!A.error,Z.setAttribute("aria-describedby",ne.id),A.error&&Z.setAttribute("aria-invalid","true");let oe=b("label",S.code);oe.append(Z);let y=b("div");y.className="gs-notify-field",y.append(oe,ne);let O=b("button",A.busy?S.pending:S.confirm);O.type="submit",O.disabled=A.busy,X.append(y,O),Z.oninput=()=>{A.code=Z.value.replace(/\\D/g,"").slice(0,6),Z.value!==A.code&&(Z.value=A.code),A.code.length===6&&!A.busy&&yn()}}let se=b("button");se.type="button",se.className="gs-notify-secondary";let Ft=()=>{let oe=Math.ceil((A.resendAt-Date.now())/1e3);se.disabled=oe>0||A.busy,se.textContent=oe>0?S.resend_wait.replaceAll("{seconds}",String(oe)):U?S.resend_code:S.resend_email,oe<=0&&p()};Ft(),A.resendAt>Date.now()&&(l=setInterval(Ft,1e3),l.unref?.());let yt=b("button",S.change_address);yt.type="button",yt.className="gs-notify-link",yt.onclick=()=>{d.awaiting=void 0,d.message="",u()},X.append(se,yt),t.append(X),U&&x&&Z.focus();let yn=async()=>{if(A.busy||A.code.length!==6){A.code.length!==6&&(A.error=S.code_incomplete,u());return}A.busy=!0,A.error="",u();try{if(await e.client.confirmNotify({roundId:g,channel:A.channel,address:A.address,code:A.code}),s)return;d.awaiting=void 0,d.saved=!0}catch(oe){A.error=c(oe,S.error),A.code=""}finally{A.busy=!1,!s&&e.round?.id===g&&u()}};X.onsubmit=oe=>{oe.preventDefault(),yn()},se.onclick=async()=>{A.busy=!0,u();try{let oe=await e.client.resendNotify({roundId:g,channel:A.channel,address:A.address});if(oe.status==="confirmed"){d.awaiting=void 0,d.saved=!0;return}A.resendAt=Date.now()+(oe.resendAfterSeconds??60)*1e3,A.note=S.resent,A.error=""}catch(oe){let y=Number(oe.detail?.retryAfterSeconds);Number.isFinite(y)&&y>0&&(A.resendAt=Date.now()+y*1e3),A.note=c(oe,S.error)}finally{A.busy=!1,!s&&e.round?.id===g&&u()}};return}let H=b("form");H.className="gs-notify-form",H.noValidate=!0;let te=new Map,ce=A=>{let U=te.get(A);U&&(U.hidden=!0,U.textContent=""),A.removeAttribute("aria-invalid")},$=b("input");$.type="email",$.name="email",$.autocomplete="email",$.inputMode="email",$.maxLength=254,$.value=d.email,$.oninput=()=>{d.email=$.value,wn($.value.trim(),"email")&&ce($)};let fe=(A,U)=>{let X=b("p");return X.id=`${N}-${U}-error`,X.className="gs-notify-error",X.hidden=!0,A.setAttribute("aria-describedby",X.id),te.set(A,X),X},_e=fe($,"email"),P=b("label",S.email_address);P.append($);let I=b("div");I.className="gs-notify-field",I.append(P,_e),i??=gd(r);let G=b("select");G.name="country",G.setAttribute("aria-label",S.country);for(let A of i){let U=b("option",`${A.name} (${A.dial})`);U.value=A.code,U.selected=A.code===d.country,G.append(U)}G.value=d.country;let j=b("span");j.setAttribute("aria-hidden","true");let D=()=>{j.textContent=`${fd(d.country)} +${Zt.get(d.country)?.[1]??""}`};D();let V=b("span");V.className="gs-notify-country",V.append(j,G);let R=b("input");R.type="tel",R.name="phone",R.id=`${N}-phone`,R.autocomplete="tel",R.inputMode="tel",R.maxLength=24,R.value=d.phone,R.oninput=()=>{let A=R.value.trim().replace(/^00/,"+"),U=A.startsWith("+")?ki(A.replace(/\\D/g,""),d.country):void 0;U&&U!==d.country&&(d.country=U,G.value=U,D()),d.phone=R.value,Bs(R.value,d.country)&&ce(R)},G.onchange=()=>{d.country=G.value,D(),Bs(R.value,d.country)&&ce(R),R.focus?.()};let re=b("label",S.mobile_number);re.htmlFor=R.id;let q=b("div");q.className="gs-notify-phone",q.append(V,R);let K=b("div");K.className="gs-notify-field";let Oe=fe(R,"phone");K.append(re,q,Oe);let ie=()=>{ce($),ce(R)},Le=()=>{I.hidden=d.channel!=="email",K.hidden=d.channel!=="phone"};if(w&&k){let A=b("fieldset");A.className="gs-notify-via",A.append(b("legend",S.via));for(let[U,X]of[["phone",S.sms],["email",S.email]]){let Z=b("label"),ne=b("input");ne.type="radio",ne.name=`${N}-via`,ne.value=U,ne.checked=d.channel===U,ne.onchange=()=>{d.channel=U,d.message="",T.hidden=!0,ie(),Le()},Z.append(ne,b("span",X)),A.append(Z)}H.append(A)}Le();let Ee=b("p",S.consent.replaceAll("{brand}",v.ownerName)+" "),De=b("a",S.privacy);De.href=v.privacyUrl,De.target="_blank",De.rel="noopener noreferrer",Ee.append(De);let ve=b("button",d.pending?S.pending:S.button);ve.disabled=d.pending,ve.type="submit",H.append(I,K,Ee,ve),t.append(H),T.textContent=d.message,T.hidden=!d.message,(E==="email"||E==="phone")&&(E==="email"?$:R).focus(),H.onsubmit=async A=>{if(A.preventDefault(),d.pending||!e.round||e.round.id!==g)return;d.email=$.value,d.phone=R.value;let U=d.channel==="email",X=U?$:R,Z=U?$.value.trim():Bs(R.value,d.country),ne=U?"email":k;if(ie(),!ne||!Z||!wn(Z,ne)){let se=U?_e:Oe;se.textContent=U?S.invalid_email:S.invalid_mobile,se.hidden=!1,X.setAttribute("aria-invalid","true"),X.focus?.();return}T.hidden=!1,d.pending=!0,o="",ve.disabled=!0,ve.textContent=S.pending,T.textContent="",d.message="";try{let se=await e.client.subscribeNotify({roundId:g,channel:ne,address:Z,consent:{wording:v.wording,termsVersion:v.termsVersion}});if(s)return;["subscribed","already_subscribed"].includes(se.status)?d.saved=!0:se.status==="pending_confirmation"?d.awaiting={channel:ne,address:Z,sent:se.fanMessage,code:"",error:"",note:"",busy:!1,resendAt:Date.now()+(se.resendAfterSeconds??60)*1e3}:d.message=se.fanMessage}catch(se){d.message=c(se,S.error)}finally{d.pending=!1,!s&&e.round?.id===g&&u()}}},h=async()=>{if(s||typeof document>"u"||document.visibilityState!=="visible")return;let g=e.round?.id??"",d=a.get(g),v=d?.awaiting,f=e.presentation.notify;if(!(!d||!v||v.channel!=="email"||v.busy||!f))try{let x=await e.client.subscribeNotify({roundId:g,channel:v.channel,address:v.address,consent:{wording:f.wording,termsVersion:f.termsVersion}});!s&&["subscribed","already_subscribed"].includes(x.status)&&d.awaiting===v&&(d.awaiting=void 0,d.saved=!0,u())}catch{}};typeof document<"u"&&document.addEventListener?.("visibilitychange",h);let m=e.onRoundChanged(()=>{n=!1,u()}),_=e.onPresentationChanged(u);return u(),{update(g){n=g?.finished===!0&&g.outcome==="pending",u()},destroy(){s=!0,p(),m(),_(),typeof document<"u"&&document.removeEventListener?.("visibilitychange",h),t.replaceChildren(),t.hidden=!0}}}var Hl=new Set(["comment"]);function ja(e){let n=e.outcome==="accepted"||e.outcome==="duplicate"?e.round_state?.progress?.guesses?.at(-1):void 0;return n?{...e,guessed:n}:e}function Rf(e,t){if(!t?.finished||t.outcome!=="won"||!e||e.plays<2)return null;let n=t.progress?.guesses;if(!Array.isArray(n)||n.length===0)return null;let s=n.length,o=0;for(let[r,i]of Object.entries(e.pick_shares??{}))typeof i!="number"||!(i>0)||(r==="X"||/^\\d+$/.test(r)&&Number(r)>s)&&(o+=i);return Math.max(0,Math.min(100,Math.round(o*100)))}function Vl(e){let t=e.GAMESTAGE_API,n=e.GAMESTAGE_GAME;if(!t||!n)throw new Error("This game has no Gamestage configuration. `window.GAMESTAGE_API` and `window.GAMESTAGE_GAME` are written by `gamestage deploy` and printed by `gamestage dev`.");return{api:t,game:n}}function hn(e,t){let n=new URLSearchParams(t??""),s=o=>{let r=n.get(o);return r&&r.trim()?r.trim():void 0};return{host:s("h")??e.GAMESTAGE_IC_HOST,projectId:s("p")??e.GAMESTAGE_IC_PROJECT,eventId:s("e")??e.GAMESTAGE_IC_EVENT,locale:s("locale")??e.GAMESTAGE_LOCALE,theme:s("theme")??e.GAMESTAGE_THEME}}function Ko(e,t=globalThis.navigator){let n=e.locale??t?.languages?.[0]??t?.language;return n&&n.trim().split(/[-_]/)[0].toLowerCase()||void 0}var qa=3e4;async function Kl(e,t,n){let s=`${e.replace(/\\/+$/,"")}/public/v1/platform/${encodeURIComponent(t)}`;try{let o=AbortSignal.timeout?AbortSignal.timeout(qa):void 0,r=await n(s,o?{signal:o}:void 0);if(!r.ok)return{because:r.status===404?`${t} is not on Interaction Cloud: the control plane answered 404.`:`asking for this game\'s platform ids answered ${r.status}.`};let i=await r.json(),a=typeof i.project=="string"?i.project:void 0,l=typeof i.host=="string"?i.host:void 0,p=typeof i.name=="string"&&i.name.trim()?i.name:void 0;if(!a||!l)return{because:"the control plane answered without both a project and a host, so there is nothing connectable to use."};let c=typeof i.analytics_url=="string"&&/^https:\\/\\//.test(i.analytics_url)?i.analytics_url:void 0,u=i.services?.comments,h=typeof u?.topic_id=="string"&&typeof u.api=="string"&&/^https:\\/\\//.test(u.api)?{topicId:u.topic_id,api:u.api}:void 0;return{host:l,projectId:a,name:p,analyticsUrl:c,comments:h}}catch(o){return{because:o instanceof Error&&(o.name==="TimeoutError"||o.name==="AbortError")?`the control plane did not answer within ${qa/1e3}s, so this page is playing the round without a Studio connection. A producer\'s words and live updates will reach the next load.`:`asking for this game\'s platform ids failed: ${o instanceof Error?o.message:String(o)}`}}}function Wl(e,t){return t?{...e,forms:t}:e}async function Yl(e,t,n){let s=hn(e,t),o=s.host,r=s.projectId,i=s.eventId,a,l,p,c;if((!o||!r)&&e.GAMESTAGE_IC_LOOKUP&&n?.api&&n?.game){n?.step?.("looking-up");let u=await Kl(n.api,n.game,n.fetch??fetch);o??=u.host,r??=u.projectId,l=u.name,p=u.analyticsUrl,c=u.comments,a=u.because}else(!o||!r)&&e.GAMESTAGE_IC_LOOKUP&&(a="this page carries no Interaction Cloud ids and no API to ask for them.");if((!o||!r)&&e.GAMESTAGE_IC_LOOKUP)throw new Error(a??"this game could not reach Interaction Cloud and there is no reason recorded.");return!o||!r?{deployedName:l,projectId:r,platform:Ls({pollMilliseconds:5e3,offPlatformReason:a,...typeof e.GAMESTAGE_LIVE_SOURCE=="string"?{liveSource:e.GAMESTAGE_LIVE_SOURCE}:{},presentation:Wl(at(e.GAMESTAGE_PRESENTATION,Ko(s)),Ar(e.GAMESTAGE_PRESENTATION)),signInSettings:zt(e.GAMESTAGE_PRESENTATION,Ko(s))})}:{deployedName:l,projectId:r,analyticsUrl:p,comments:c,platform:await Ql({host:o,projectId:r,eventId:i,locale:Ko(s),settingsConsent:n?.settingsConsent},n?.step)}}async function Ql(e,t){t?.("loading-kits");let n=await Promise.resolve().then(()=>(Fa(),Ua));return t?.("opening"),n.createMonterosaPlatform(e)}async function Mf(e={}){let t=e.globals??globalThis.window??globalThis,{api:n,game:s}=Vl(t),o=e.search??globalThis.location?.search,r=y=>{try{e.onStep?.(y)}catch{}},i=()=>({declared:!1,categories:{}}),a=e.platform!==void 0?Promise.resolve({platform:e.platform,deployedName:void 0}):Yl(t,o,{api:n,game:s,fetch:e.fetch,step:r,settingsConsent:()=>i()});a.catch(()=>{});let l=t.location??globalThis.location,p=e.signIn!==!0||typeof document>"u"||!l?.hostname?void 0:zr({game:s,hostname:l.hostname,fetch:e.fetch,document,store:globalThis.localStorage,mayRemember:()=>Et(i(),"functional"),session:()=>rs(s)});p?.state==="off"&&p.stop();let c=p&&p.state!=="off"?p:void 0,h=!me(await de(e.identity))&&c?c.begin():void 0;h&&c?.rememberedGranted()&&await Promise.race([h,new Promise(y=>setTimeout(y,1500))]);let m=async()=>me(await de(e.identity))??await c?.token()??void 0,_=await de(m),g=t.GAMESTAGE_HOST_OWNS_CONSENT===!0,d={analyticsRequiresConsent:g||(e.consent?.analyticsRequiresConsent??!0)},v,f=()=>v?.reading()??{declared:!1,categories:{necessary:!0}},x=Ur({policy:d,destinations:e.destinations??[],consent:f}),E=null,S=!1,k=()=>{if(E||S)return;let y=Zl(T.presentation?.analyticsUrl,ce);!y||!te||ct(d,f())&&(S=!0,qr({game:s,projectId:te,serviceUrl:y,now:()=>T.clock.now(),onObservation:O=>{x.track(O)}}).then(O=>{E=O}).catch(()=>{}).finally(()=>{S=!1}))},w=()=>{E?.stop(),E=null},b=tr({baseUrl:n,game:s,fetch:e.fetch,identity:async()=>(_=await de(m),me(_))}),N=t.GAMESTAGE_FORMAT==="arcade"||t.GAMESTAGE_FORMAT==="mystery"||t.GAMESTAGE_FORMAT==="quiz";N||r("fetching-round");let L=N?Promise.resolve({ok:"none"}):b.getCurrentRound().then(y=>({ok:!0,value:y}),y=>({ok:!1,cause:y})),{platform:T,deployedName:H,projectId:te,analyticsUrl:ce,comments:$}=await a;if(T.settingsSource?.()==="none"){let y=t,O=globalThis;throw Xr({document:y.document??O.document,location:y.location??O.location}),new Yt}let fe=ts(t),_e=()=>ar(ir(T.presentation?.gate,fe),g),P=_e(),I=bn(P,s),G=async(y=P)=>{if(!y)return!1;try{return await b.declare(jt(y)),!0}catch{return!1}},j=I.then(()=>G()),D,V=()=>{if(D)return D;let y=_e()??P;return y?(P=y,D=(async()=>(os(s),await bn(y,s),G(y)))().finally(()=>{D=void 0}),D):Promise.resolve(!1)};v=As({platform:T,policy:d,game:s,scope:e.consentScope,policyVersion:T.presentation?.consentPolicyVersion,embedOrigins:T.presentation?.embedOrigins,hostManagesConsent:Os(typeof document>"u"?void 0:document,T.presentation?.oneTrustId,g),hostOwnsConsent:g}),i=f,v.onChange(y=>{ct(d,y)?k():w(),T.rememberSettings?.()}),T.rememberSettings?.(),k();let R,re={reading:f,allowed:()=>dt(d,f()),record:()=>v?.record()??null,needed:()=>v?.needed()??d.analyticsRequiresConsent,hostDecides:()=>v?.hostDecides()??!1,decide:y=>v?.decide(y)??!1,declare:y=>v?.decide(y)??!1,onChange:y=>v?.onChange(y)??(()=>{}),openSettings:()=>R?.open()};if(await I,typeof document<"u"&&e.consentBanner!==!1&&!g&&(R=Ps({presentation:T.presentation,consent:re},e.consentBanner??{})),c&&h){let y=()=>{if(re.needed())return;let O=T.presentation??{},pe=O.cssVariables??{};c.offer({playAs:O.signInPlayAsLabel,detail:O.signInDetail,dismiss:O.signInDismissLabel},{accent:pe.highlightMainColour??O.primaryColour,onAccent:pe.onHighlightMainColour,surface:pe.backgroundMainColour,text:pe.onBackgroundMainColour})};h.then(y),re.onChange(()=>y()),c.onChange(O=>{O==="granted"&&de(m).then(pe=>{_=pe})})}let q,K=new Set,Oe=async(y=!1)=>{if(!N)try{let O=await b.getCurrentRound();return Ct(T.clock,O.server_time),q=O,O}catch(O){if(y)throw O;return}},ie=await L,Le=ie.ok==="none"||ie.ok===!1&&ie.cause instanceof Error&&ie.cause.status===404&&["not_found","no_round"].includes(ie.cause.code??"");if(ie.ok===!1&&!Le)throw ie.cause;ie.ok===!0&&(Ct(T.clock,ie.value.server_time),q=ie.value);let Ee=(y,O)=>y!==void 0&&y.id===O.id&&y.version===O.version&&(y.settled_revision??0)===(O.settled_revision??0)&&y.provisional===O.provisional&&y.challenge_instance_id===O.challenge_instance_id,De,ve=T.onRoundAnnounced(()=>{(async()=>{let y=q,O=await Oe();if(O&&!Ee(y,O))for(let pe of[...K])pe(O)})()},()=>!!(q&&(q.provisional===!0||q.awaits_settlement===!0&&!q.can.results_available&&(q.can.closed||(q.locks_at?T.clock.now()>=Date.parse(q.locks_at):De===q.id))))),A=!1,U=(()=>{let y=Ts(T.presentation),O=e.busy?.copy;return{atCapacity:{...y.atCapacity,...O?.atCapacity??{}},rateLimited:{...y.rateLimited,...O?.rateLimited??{}},cappedToday:{...y.cappedToday,...O?.cappedToday??{}}}})();function X(y,O){if(e.busy?.enabled!==!1)try{xs(y,{copy:U,...e.busy?.container===void 0?{}:{container:e.busy.container},...e.busy?.document?{document:e.busy.document}:{},...O===void 0?{}:{retryAfterSeconds:O}})}catch{}}let Z=typeof globalThis.document>"u"?()=>{}:ti(()=>({game:s,platform:T.kind,offPlatformReason:T.offPlatformReason,ids:{project:T.projectId??hn(t,o).projectId,event:hn(t,o).eventId,host:hn(t,o).host},round:q?{id:q.id,version:q.version,number:q.number,origin:q.origin}:void 0,endpoints:{playerApi:n,mesh:hn(t,o).host},identity:{kind:_.kind,signedIn:_.kind!=="anonymous"},consent:{allowed:dt(d,f())},presentation:T.presentation}),globalThis),ne=!!e?.optimistic&&q?.can.optimistic_play===!0,se,Ft=as({api:n,game:s,fetch:e.fetch,token:async()=>me(await de(e.identity))??b.spaceToken(),gameToken:async()=>me(await de(e.identity))?void 0:await c?.token()}),yt=_s({api:n,game:s,fetch:e.fetch,token:async()=>me(await de(e.identity))??b.spaceToken(),gameToken:async()=>me(await de(e.identity))?void 0:await c?.token(),words:async y=>(await T.elementFields?.(y)??[]).flatMap(O=>vs(O.id,O.fields)??[]),outcomeWords:async y=>(await T.elementFields?.(y)??[]).flatMap(O=>Ss(O.id,O.fields)??[])}),yn=t.GAMESTAGE_FORMAT==="arcade"?Xl(b,Ft,{returning:rs(s)!==void 0||!!me(_)}):b,oe=$?cs({api:$.api,topicId:$.topicId,fanToken:()=>b.commentsToken(),fetch:e.fetch}):null;return await j,{platform:T.kind,optimistic:ne,id:s,get eventId(){return T.eventId},client:yn,arcade:Ft,quiz:yt,comments:oe,streak:async()=>!me(await de(e.identity))&&c?.state==="granted"?Ms(await c.streak()):Rs({baseUrl:e.loyalty?.baseUrl,identity:m,fetchImpl:e.fetch}),presentation:T.presentation,get signInSettings(){return T.signInSettings},get needsSignIn(){return!!T.signInSettings?.enabled&&!me(_)},settingsSource:()=>T.settingsSource?.()??"studio",analytics:x,now:()=>T.clock.now(),deployedName:H,projectId:te,offPlatformReason:T.offPlatformReason,get identity(){return _},async refreshIdentity(){return _=await de(m),_},signIn:{get state(){return c?.state??"off"},onChange(y){return c?.onChange(y)??(()=>{})},requiredFor(y){return Hl.has(y)},async request(){if(!c)return"off";let y=T.presentation??{},O=y.cssVariables??{};return c.request({playAs:y.signInPlayAsLabel,detail:y.signInDetail,dismiss:y.signInDismissLabel},{accent:O.highlightMainColour??y.primaryColour,onAccent:O.onHighlightMainColour,surface:O.backgroundMainColour,text:O.onBackgroundMainColour})}},get round(){return q},onRoundChanged(y){return K.add(y),()=>K.delete(y)},async playNext(){let y=await b.getNextRound();if(y.status!=="ready"||!y.round)return"exhausted";Ct(T.clock,y.server_time),q=y.round;for(let O of K)O(y.round);return"ready"},onPresentationChanged(y){return T.onPresentationChanged(y)},live(y){return y?kn(T,y):se??=kn(T)},async play(y){let O=q??await Oe();if(!O)throw new Error("There is no round to play. The Engine did not return one.");let pe=y.idempotencyKey??is(),Ae=async()=>{try{return await b.play(O.id,{...y.picks?{picks:y.picks}:{},...y.answers?{answers:y.answers}:{},...y.op?{op:y.op}:{},...y.centre!==void 0?{centre:y.centre}:{},...y.board!==void 0?{board:y.board}:{},...y.operation?{operation:y.operation}:{},...y.room?{room:y.room}:{},roundVersion:O.version},pe)}catch(Ie){throw Ie?.status===429&&X("rateLimited"),Ie&&typeof Ie=="object"&&(Ie.idempotency_key=pe),Ie}},$e=await Ae();if($e.outcome==="rejected"&&$e.reason==="declaration_required"&&await V()&&($e=await Ae()),$e.outcome==="busy"){let Ie=$e;X(Cs(Ie.reason),Ie.retry_after_seconds)}return Ct(T.clock,$e.server_time),($e.outcome==="accepted"||$e.outcome==="duplicate")&&(De=O.id),{...$e,idempotency_key:pe}},async shoot(y){let{idempotencyKey:O,...pe}=y,Ae=await this.play({operation:bt(pe),idempotencyKey:O}),Ie=Ae.outcome==="accepted"||Ae.outcome==="duplicate"?vn(_n(Ae.round_state)):void 0;return Ie?{...Ae,shot:Ie}:Ae},async draw(y={}){let O=await this.play({operation:{op:"draw"},idempotencyKey:y.idempotencyKey}),Ae=O.outcome==="accepted"||O.outcome==="duplicate"?O.round_state?.progress?.drawn?.at(-1):void 0;return Ae?{...O,drawn:Ae}:O},async solve(y,O={}){return this.play({operation:{op:"solve",text:y},idempotencyKey:O.idempotencyKey})},async guess(y,O={}){return ja(await this.play({operation:{op:"guess",value:y},idempotencyKey:O.idempotencyKey}))},async skip(y={}){return ja(await this.play({operation:{op:"skip"},idempotencyKey:y.idempotencyKey}))},track(y,O={}){return E?.track(y,O),x.track({name:y,properties:O,at:T.clock.now()})},consent:re,storage:{read:y=>dt(d,f())?T.storage.read(y):Promise.resolve(null),write:async(y,O)=>dt(d,f())?(await T.storage.write(y,O),!0):!1,remove:async y=>dt(d,f())?(await T.storage.remove(y),!0):!1},stop(){Z(),!A&&(A=!0,ve(),K.clear(),w(),R?.stop(),v?.stop(),c?.stop(),T.stop())}}}var Jl=5e3;function Xl(e,t,{returning:n}){let s=async()=>{try{let{ticket:r}=await e.getNameTicket();await t.setName(r)}catch(r){let i=r?.code??"unknown";console.warn(`gamestage: the chosen name did not reach the board (${i}). Play carries on.`)}},o=async()=>{let r;try{await Promise.race([s(),new Promise(i=>r=setTimeout(i,Jl))])}finally{clearTimeout(r)}};return n&&e.getProfile().then(r=>r.name_chosen?s():void 0).catch(()=>{}),{...e,async setIdentity(r){let i=await e.setIdentity(r);return r.name&&await o(),i}}}function Zl(e,t){if(t)return e?.trim()||t}export{Gr as ANALYTICS_CATEGORY,vt as ArcadeError,lt as BUSY_MODAL_ID,Es as DEFAULT_BUSY_COPY,nr as DEFAULT_REPORT_REASON,er as GOAL_GEOMETRY,Yt as GamestageUnavailableError,oc as HEART,wt as QuizError,si as SETTINGS_CACHE_CATEGORY,Zo as SHOOT_INPUT,wi as TITLE_SELECTOR,An as UNAVAILABLE_COPY,ct as analyticsAllowed,zc as applyPresentation,Cs as busyKindFor,as as createArcadeClient,Kt as createClock,cs as createCommentsClient,As as createConsentState,kn as createLiveContest,Ls as createLocalPlatform,Ql as createMonterosaPlatform,_s as createQuizClient,sc as editionBoard,On as flatten,os as forgetGate,Si as gamestageUiTokens,ts as gateFrom,jt as gateKey,Et as granted,Rf as guessBetterThan,Jo as hasDeclared,Os as hostRunsConsentManager,Gs as hostname,vn as latestShot,Ko as localeFor,Ps as mountConsent,md as mountNotify,Uc as mountProvisionalResult,qc as mountRecovery,is as newIdempotencyKey,bn as passGate,ns as placeNames,hn as platformIds,ci as provisionalResultText,Ss as quizOutcomeFromFields,vs as quizWordsFromFields,Ic as readLoyalty,Rs as readStreak,Ts as resolveBusyCopy,de as resolveIdentity,Ct as sampleIso,oi as settingsCacheAllowed,bt as shootOperation,_n as shootProgressOf,xs as showBusyModal,ks as signInMemoryKey,Zl as signalAddress,Br as siteForGame,Mf as start,dt as storageAllowed,Gc as streakFrom,Ei as titleTreatment,me as tokenOf};\n/*! Bundled license information:\n\n@monterosa/sdk-util/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @preserve\n * Global object polyfill.\n * Based on MDN article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\n *\n * @internal\n *\n * @returns typeof globalThis\n *)\n (**\n * @license\n * fromentries.ts\n * util\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * checksum.ts\n * util\n *\n * Copyright \xA9 2025 Monterosa. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-util\n *\n * Copyright \xA9 2022-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-core/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2023-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2021-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-core\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-bridge-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2022-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-bridge-kit\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-storage-kit/dist/index.js:\n (**\n * @license\n * types.ts\n * storage-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * storage_impl.ts\n * storage-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-storage-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * api.ts\n * storage-kit\n *\n * Copyright \xA9 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-enmasse-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-enmasse-kit\n *\n * Copyright \xA9 2023-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-connect-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-connect-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-connect-kit\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-consent-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright \xA9 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-analytics-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-analytics-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-analytics-kit\n *\n * Copyright \xA9 2025-2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-interact-interop/dist/index.js:\n (**\n * @license\n * api.ts\n * interact-interop\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n\n@monterosa/sdk-interact-kit/dist/index.js:\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2022 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2022-2024 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2023 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n (**\n * @license\n * @monterosa/sdk-interact-kit\n *\n * Copyright \xA9 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n *)\n*/\n//# sourceMappingURL=https://gamestage.ai/client/0.117.0/gamestage.js.map\n',fs="8222b771c7e42d0e",Tn="gamestage.js",gs="0.117.0",mde=`<!doctype html>
|
|
900
900
|
<html lang="en">
|
|
901
901
|
<head>
|
|
902
902
|
<meta charset="utf-8" />
|
package/package.json
CHANGED