@indiegems/gem-web-sdk 22.0.0 → 23.0.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/CHANGELOG.md +47 -0
- package/dist/conformance.d.ts +4 -1
- package/dist/function.d.ts +9 -1
- package/dist/game.d.ts +40 -2
- package/dist/gem-web-sdk.bridge.js +2 -2
- package/dist/gem-web-sdk.conformance.js +3 -3
- package/dist/gem-web-sdk.esm.js +3 -3
- package/dist/gem-web-sdk.function.js +3 -3
- package/dist/gem-web-sdk.game.js +3 -3
- package/dist/gem-web-sdk.min.js +3 -3
- package/dist/gem-web-sdk.sdk.js +3 -3
- package/dist/gem-web-sdk.server.js +2 -2
- package/dist/index.d.ts +54 -6
- package/dist/sdk.d.ts +40 -2
- package/docs/api/api-reference-function.md +129 -9
- package/docs/api/api-reference-game.md +141 -13
- package/docs/api/api-reference-server.md +7 -1
- package/docs/api/reference.json +165 -9
- package/docs/changelog.md +47 -0
- package/docs/friends.md +120 -15
- package/docs/getting-started.md +7 -1
- package/docs/inventory-and-catalogs.md +29 -11
- package/docs/manifest.json +16 -16
- package/docs/rooms-and-matches.md +6 -3
- package/docs/server-bundles.md +2 -2
- package/docs/serverless-functions.md +21 -0
- package/docs/trading-and-gifting.md +12 -9
- package/package.json +1 -1
- package/schema/bridge.v1.json +225 -0
- package/schema/capabilities.public.json +14 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ut=Object.defineProperty;var i=(r,t)=>ut(r,"name",{value:t,configurable:true});var u="gem-web-bridge",A={min:1,max:1},mt=65536,Oe=8,oe=5e3,Me=1024,T=1e4,M=Object.create(null),ae="__malformed";var we=Object.create(null),pt=Object.freeze([["gem.asyncOpponents.","asyncOpponents"],["gem.vibration.","vibration"],["gem.viewport.","reservedAreas"],["gem.moments.","moments"],["gem.prefs.","audioChannels"],["gem.share.","shareRemap"]]);function se(r){let t=we[r];if(t!==void 0)return t;for(let[e,n]of pt)if(r.startsWith(e))return n}i(se,"capabilityFor");function K(r){let t=/^([a-z][a-z0-9+.-]*):\/\/([a-z0-9.-]+|\[[0-9a-f:.]+\])(:([0-9]{1,5}))?$/i.exec(r);return t===null?false:t[4]===void 0||Number(t[4])<=65535}i(K,"isOrigin");function gt(r){let t;try{t=new URL(r);}catch{return false}return t.username!==""||t.password!==""?false:t.protocol==="https:"?true:t.protocol==="http:"&&(t.hostname==="localhost"||t.hostname==="127.0.0.1")}i(gt,"isSafeHttpUrl");function ft(r){return /^[a-z]{2,8}(-[a-z0-9]{1,8})*$/i.test(r)}i(ft,"isBcp47");function ht(r){return /^[a-z_]+$/.test(r)}i(ht,"isCode");function yt(r){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)||/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/.test(r)&&!r.includes("--")}i(yt,"isGameRef");function be(r,t,e){if(t>Oe)return `nesting deeper than ${Oe}`;if(++e.nodes>oe)return `more than ${oe} values`;if(e.bytes>e.cap)return `over the ${e.cap} byte limit`;if(r==null)return e.bytes+=4,null;let n=typeof r;if(n==="boolean")return e.bytes+=5,null;if(n==="number")return e.bytes+=8,null;if(n==="string")return e.bytes+=r.length*3+2,null;if(n!=="object")return `${n} is not plain data`;let o=r;if(e.seen.has(o))return "a repeated or cyclic object reference";if(e.seen.add(o),Array.isArray(r)){if(r.length>Me)return `an array of ${r.length} entries, over the ${Me} limit`;e.bytes+=2;for(let s of r){let c=be(s,t+1,e);if(c)return c}return null}let a=Object.getPrototypeOf(r);if(a!==Object.prototype&&a!==null)return "a value that is not a plain object";e.bytes+=2;let d=r;for(let s in d){if(!Object.prototype.hasOwnProperty.call(d,s))continue;if(++e.nodes>oe)return `more than ${oe} values`;if(e.bytes+=s.length*3+4,e.bytes>e.cap)return `over the ${e.cap} byte limit`;let c=be(d[s],t+1,e);if(c)return c}return null}i(be,"walk");function bt(r,t=mt){let e={nodes:0,bytes:0,seen:new Set,cap:t},n=be(r,0,e);return n?`message contains ${n}`:e.bytes>t?`message is over the ${t} byte limit`:null}i(bt,"validateSize");var vt={origin:[K,"not a well-formed origin"],url:[gt,"not a safe absolute http(s) URL"],bcp47:[ft,"not a well-formed BCP 47 tag"],code:[ht,"not a code of lower-case letters and underscores"],gameRef:[yt,"not a game id or web address"]};function Ge(r,t,e){for(let n of t){let o=e===""?n[0]:`${e}.${n[0]}`,a=r[n[0]];if(a==null){if(n[1]<"a")continue;return `${o}: required`}let d=ve(a,n,o);if(d)return d}return null}i(Ge,"checkFields");function ve(r,t,e){let n=t[1].toLowerCase();switch(n){case "u":return typeof r=="boolean"?null:ve(r,typeof r=="string"?[t[0],"s",t[2]]:[t[0],"n",t[3],t[4]],e);case "s":{if(typeof r!="string")return `${e}: expected string`;if(r.length>t[2])return `${e}: exceeds ${t[2]} characters`;if(t[3]){let[o,a]=vt[t[3]];if(!o(r))return `${e}: ${a}`}return null}case "n":case "i":return typeof r!="number"||!(n=="i"?Number.isInteger:Number.isFinite)(r)?`${e}: expected ${n=="i"?"integer":"number"}`:r<t[2]||r>t[3]?`${e}: out of range ${t[2]}..${t[3]}`:null;case "b":return typeof r=="boolean"?null:`${e}: expected boolean`;case "e":{let o=t[2];return o.includes(r)?null:`${e}: not one of ${o.join("|")}`}case "o":return typeof r!="object"||r===null||Array.isArray(r)?`${e}: expected object`:Ge(r,t[2],e);case "j":return typeof r!="object"||r===null||Array.isArray(r)?`${e}: expected a plain object`:null;case "a":{if(!Array.isArray(r))return `${e}: expected array`;if(r.length>t[2])return `${e}: exceeds ${t[2]} items`;let o=t[3],a=`${e}[]`;for(let d of r){if(d==null){if(o[1]<"a")continue;return `${a}: required`}let s=ve(d,o,a);if(s)return s}return null}default:return `${e}: unknown kind ${String(n)}`}}i(ve,"checkValue");var Le=Object.create(null);function l(r,t,e,n,o){return M[r]=e,n&&(we[r]=n),Le[r]=a=>{let d=bt(a,o);if(d)return d;if(typeof a!="object"||a===null||Array.isArray(a))return "message: expected object";let s=a;return s.gem!==u?"gem: wrong protocol marker":s.type!==r?`type: expected ${r}`:Ge(s,t,"")}}i(l,"makeValidator");var J=["","s",64],m=["requestId","s",64],z=["matchId","s",64],P=["reason","S",64,"code"],I=["outcome","e",["ok","declined","unavailable"]];l("gem.handshake",[["versions","o",[["min","i",1,1e3],["max","i",1,1e3]]],["capabilities","A",64,J],["embedder","s",2048,"origin"],["unbidden","B"]],30);l("gem.handshake.accept",[["v","i",1,1e3],["capabilities","A",64,J]],5);l("gem.token",[["token","s",4096],["requestId","S",64],["generation","i",0,2147483647],["apiBaseUrl","S",512,"url"],["playerId","s",64],["gameId","s",64],["channel","e",["dev","test","release"]],["gameVersion","S",64],["expiresAt","i",0,4102444800],["chainEndsAt","i",0,4102444800],["allowDevTools","B"]],30);l("gem.token.denied",[m,["retryable","b"],["retryAfterMs","I",0,36e5],["reason","e",["chain_exhausted","unavailable"]],["correlationId","s",64]],30);l("gem.player",[["untrusted","o",[["displayName","s",64],["displayTag","S",80],["displayHandle","s",80]]],["playerId","S",64],["discriminator","S",8],["avatarIconUrl","S",2048,"url"],["avatarIconId","S",64],["avatar3dId","S",64],["avatar3dModelUrl","S",2048,"url"],["avatar3dIconUrl","S",2048,"url"],["avatars3d","A",8,["","o",[["family","s",32],["id","s",64],["modelUrl","s",256,"url"],["iconUrl","s",256,"url"]]]],["badges","A",2,["","o",[["itemId","s",64],["iconUrl","s",2048,"url"]]]],["displayTag","s",8],["avatarUrl","S",2048,"url"],["boost","O",[["multipliers","a",8,["","o",[["currencyId","s",64],["currencySlug","s",32],["multiplierBp","i",1e4,1e6]]]],["expiresInDays","I",1,7]]]],12);l("gem.pause",[["paused","b"]],120);l("gem.prefs",[["reducedMotion","b"],["muted","b"],["showFrameStats","B"],["music","B"],["sounds","B"],["locale","s",35,"bcp47"],["recommended","O",[["volume","i",0,100],["batterySaver","b"],["keyboardLayout","e",["wasd","arrows"]],["gamepadConfirm","e",["south","east"]],["vibration","b"],["lookSensitivity","I",20,400],["gamepadLookSensitivity","I",20,400],["invertLookY","B"],["touchMovement","S",16,"code"],["graphicsQuality","S",16,"code"],["graphicsQualityAuto","B"],["colorHelp","B"]]]],60);l("gem.cohorts",[["cohorts","a",8,["","o",[["experimentId","s",36],["variantKey","s",32]]]]],12,"cohorts");l("gem.earnAllowanceChanged",[],30,"earnAllowance");l("gem.viewport",[["insets","o",[["top","i",0,4096],["right","i",0,4096],["bottom","i",0,4096],["left","i",0,4096]]],["reserved","A",4,["","o",[["x","i",0,16384],["y","i",0,16384],["width","i",0,16384],["height","i",0,16384],["control","O",[["x","i",0,16384],["y","i",0,16384],["width","i",0,16384],["height","i",0,16384]]]]]]],60,"viewport");l("gem.deviceSettings",[["settings","J"]],12,"deviceSettings");l("gem.willTerminate",[["reason","e",["grant_expiring","session_ended","navigating","kill_switch"]],["graceMs","i",0,6e4]],10);l("gem.roomEvent",[["event","e",["updated","match_started","match_ready","match_failed","version_stale"]],["roomId","s",64],["matchId","S",64],["version","I",0,2147483647],["reason","S",64],["platform","E",["universal","mobile"]]],120,"rooms");l("gem.socketState",[["connected","b"],["reason","E",["connecting","dropped","watchdog","terminal"]]],12,"socketState");l("gem.seatedEvent",[["roomId","s",64]],60,"partySeating");l("gem.autoStartFailedEvent",[["roomId","s",64],["code","s",64]],30,"autoStartFailure");l("gem.ticketEvent",[["event","e",["queued","matched","expired","cancelled","failed"]],["ticketId","s",64],["partySize","I",1,64],["queuedAt","I",0,4102444800],["expiresAt","I",0,4102444800],["reason","S",64],["roomId","S",64]],60,"ticketEvents");l("gem.signalEvent",[["event","e",["hello","offer","answer","ice","peerJoined","peerLeft","migration","matchEnded","error"]],z,["data","j"]],1800,"p2p");l("gem.relayDraining",[z,["clusterTargetId","s",64],["relayIps","a",16,J],["drainingSince","s",40],["deadline","s",40]],60,"p2pRelayDrain");l("gem.dedicatedEvent",[["event","e",["answer","error","matchEnded"]],z,["sdp","S",10240],["sessionId","S",64],["code","S",64],["message","S",256],["reason","S",64]],120,"dedicated");l("gem.partyResult",[m,["partyId","S",64]],30,"parties");l("gem.clusterTarget",[["clusterTargetId","s",64],["clusterTargetIds","A",3,J]],12,"clusterTarget");l("gem.graphicsRoutes",[["entries","a",32,["","o",[["gpu","s",32],["route","S",32],["host","S",32]]]]],12,"graphicsRoutes");l("gem.devtools",[["action","e",["open","close","toggle"]]],30,"devtools");l("gem.screenshot",[["maxWidth","i",1,7680],["maxHeight","i",1,4320]],6,"screenshot");l("gem.screenshot.denied",[["reason","e",["not_wired","no_source","unsupported","unreadable","tainted","too_large","busy","declined","failed"]],["retryable","b"]],12,"screenshot");l("gem.requestContext",[],12,"feedbackContext");l("gem.gameContext",[["context","j"]],12,"feedbackContext");l("gem.signal",[["signal","e",["join","offer","answer","ice","migrationAck","hostUnreachable"]],z,["data","j"]],1200,"p2p");l("gem.dedicatedOffer",[z,["sdp","s",10240],["intent","e",["initial","ice_restart","full_reconnect"]]],60,"dedicated");l("gem.partyRequest",[m],12,"parties");l("gem.ready",[],5);l("gem.engaged",[],5,"engagement");l("gem.progress",[["loaded","i",0,1099511627776],["total","i",0,1099511627776]],600);l("gem.requestToken",[m,["reason","e",["initial","expiring","rejected"]]],12);l("gem.requestLocalServer",[m,["gameRoomId","s",64]],6,"localHost");l("gem.localServer",[m,["serverId","S",128]],30,"localHost");l("gem.localServer.denied",[m,["retryable","b"],["reason","e",["refused","unavailable"]]],30,"localHost");l("gem.exit",[["reason","S",64]],5);l("gem.openExternal",[["url","s",2048,"url"]],6);l("gem.requestFullscreen",[["enabled","b"]],30);l("gem.audioState",[["muted","b"]],120,"audioState");l("gem.rewardCue",[["currencySlug","s",32],["cueId","S",64],["expected","I",1,1e9],["origin","O",[["x","i",0,16384],["y","i",0,16384]]]],60,"rewardCue");l("gem.rewardPresentation",[["mode","e",["arcade","game"]]],12,"rewardPresentation");l("gem.walletDisplay",[["visible","b"],["currencies","A",8,J],["score","B"]],60,"walletDisplay");l("gem.controlsDeclare",[["uses","o",[["lookSensitivity","S",16,"code"],["gamepadLookSensitivity","S",16,"code"],["invertLookY","S",16,"code"],["touchMovement","S",16,"code"]]]],60,"controls");l("gem.menu",[["settings","b"],["items","A",4,["","o",[["id","s",32],["label","s",40]]]]],60,"gameMenu");l("gem.menuSelect",[["entry","e",["settings","item"]],["id","S",32]],60,"gameMenu");l("gem.gemCorner",[["corner","e",["top-left","top-right","bottom-left","bottom-right"]]],12,"gemCorner");l("gem.menuStyle",[["ground","S",7],["accent","S",7]],12,"menuStyle");l("gem.settingsDeclare",[["settings","a",8,["","o",[["id","s",40],["label","s",40],["kind","e",["toggle","slider","choice"]],["value","u",40,-1e6,1e6],["quick","B"],["icon","S",16,"code"],["min","N",-1e6,1e6],["max","N",-1e6,1e6],["step","N",0,1e6],["options","A",4,["","o",[["id","s",40],["label","s",40]]]]]]]],120,"gameSettings");l("gem.settingChange",[["id","s",40],["value","u",40,-1e6,1e6]],120,"gameSettings");l("gem.requestShare",[["requestId","S",64],["params","a",16,["","o",[["key","s",64],["value","s",512]]]]],6,"share");l("gem.shareResult",[m,["outcome","e",["accepted","refused"]],P,["key","S",64]],30,"shareResult");l("gem.requestAvatarPicker",[["tab","E",["2d","3d"]]],6,"avatarPicker");l("gem.vibrate",[["pattern","a",99,["","i",0,1e4]]],600,"vibration");l("gem.frameStats",[["fps","i",0,1e3],["frameTimeP95Ms","i",0,1e5],["counts","E",["pageFrames","gameDraws"]]],120,"frameStats");l("gem.portraitBorders",[["name","S",40]],60,"portraitBorders");l("gem.error",[["code","e",["version_mismatch","handshake_timeout","handshake_duplicate","invalid_message","rate_limited","token_unavailable","unsupported","unsupported_capability","internal"]],["message","S",256]],60);l("gem.requestPurchase",[m,["purchaseKind","e",["item","recipe"]],["targetId","s",64],["currencySlug","s",32],["quantity","I",1,10],["catalogId","S",64],["origin","E",["sheet","direct_refused"]]],12,"purchases");l("gem.requestAvatar3dPurchase",[m,["itemId","s",64],["currencySlug","s",32]],12,"avatar3dPurchases");l("gem.purchaseResult",[m,I,P,["purchaseId","S",64]],30,"purchases");l("gem.purchaseSettled",[["purchaseKind","e",["item","recipe"]],["targetId","s",64],["catalogId","S",64],["quantity","i",1,10],["purchaseId","S",64]],30,"purchaseSettled");l("gem.deviceSettings.put",[m,["settings","j"]],30,"deviceSettings");l("gem.deviceSettings.result",[m,["outcome","e",["stored","too_large","unavailable"]]],30,"deviceSettings");l("gem.requestAd",[m,["placement","s",32],["format","e",["interstitial","rewarded"]]],6,"ads");l("gem.adResult",[m,["outcome","e",["shown","no_ad","unavailable"]]],12,"ads");l("gem.signalMoment",[m,["kind","e",["level_end","run_end","match_end","menu_return","other_break"]],["placement","S",32],["wall","B"]],6,"moments");l("gem.momentResult",[m,["shown","b"]],12,"moments");l("gem.requestSignIn",[m],6,"signIn");l("gem.signInResult",[m,["outcome","e",["signed_in","declined","unavailable"]]],12,"signIn");l("gem.requestFriendChallenge",[m,["playerId","s",64],["template","s",64],["params","J"]],12,"friendChallenges");l("gem.friendChallengeResult",[m,["outcome","e",["accepted","cancelled","refused","unavailable","rate_limited","invalid"]],["code","S",64],["param","S",64],["channel","S",16],["configVersion","I",0,9007199254740991],["retryAfterMs","I",0,864e5],["detail","S",300]],30,"friendChallenges");l("gem.requestAppLinks",[m],12,"appLinks");l("gem.appLinksResult",[m,I,P,["arcade","O",[["store","e",["app_store","google_play"]]]],["game","O",[["store","e",["app_store","google_play"]]]]],30,"appLinks");l("gem.requestOpenApp",[m,["target","e",["arcade","game"]]],6,"appLinks");l("gem.openAppResult",[m,I,P],30,"appLinks");l("gem.requestOpenGame",[m,["ref","s",40,"gameRef"]],6,"openGame");l("gem.openGameResult",[m,I,P],30,"openGame");l("gem.requestSimilarGames",[m,["limit","I",1,24]],12,"openGame");l("gem.similarGamesResult",[m,I,P,["games","a",24,["","o",[["gameId","s",36,"gameRef"],["slug","S",40,"gameRef"],["iconUrl","s",1024,"url"],["capsuleLandscapeUrl","s",1024,"url"],["capsulePortraitUrl","s",1024,"url"],["previewVideoUrl","S",1024,"url"],["previewPosterUrl","S",1024,"url"],["untrusted","o",[["name","s",64],["tagline","s",64],["shortDescription","s",320],["tags","a",10,["","s",32]]]]]]]],30,"openGame",524288);l("gem.requestStoreOffers",[m],12,"store");l("gem.storeOffersResult",[m,I,P,["offers","a",32,["","o",[["skuId","s",64],["kind","e",["gem_pack","boost","pass","bundle"]],["name","s",80],["description","s",400],["imageUrl","S",1024,"url"],["priceDisplay","s",32],["grant","O",[["currency","s",32],["amount","i",1,1e9]]]]]]],30,"store",262144);l("gem.requestStorePurchase",[m,["skuId","s",64]],12,"store");l("gem.storePurchaseResult",[m,I,P],30,"store");l("gem.storePurchaseSettled",[["skuId","s",64]],30,"store");l("gem.requestStoreOfferSheet",[m,["skuId","s",64]],12,"storeOfferSheet");l("gem.storeOfferSheetResult",[m,I,P],30,"storeOfferSheet");var $=Object.freeze(Le);M.__malformed=60;Object.freeze(M);Object.freeze(we);var _t=/^[a-z0-9][a-z0-9_-]{0,39}$/;function St(r){return typeof r=="string"&&_t.test(r)}i(St,"isBorderName");function _e(r){if(r===null||St(r))return r;let t=typeof r=="string"?JSON.stringify(r.length>48?`${r.slice(0,48)}\u2026`:r):`a value of type ${typeof r}`;console.warn(`[gem] showPortraitBorders: ${t} is not a border name, so nothing was sent. A name is 1 to 40 of a-z, 0-9, _ and -, starting with a letter or digit, exactly as your store page declares it under media.portrait_borders. Pass null for no art.`);}i(_e,"checkBorderName");function De(r){return typeof r=="string"&&/^[\w-]{1,64}$/.test(r)}i(De,"isCueId");var C={now:i(()=>Date.now(),"now"),setTimeout:i((r,t)=>setTimeout(r,t),"setTimeout"),clearTimeout:i(r=>clearTimeout(r),"clearTimeout")},X=class{constructor(t=C){this.clock=t;}clock;static{i(this,"RateLimiter");}tokens=new Map;lastRefill=new Map;allow(t){let e=M[t];if(e===void 0)return false;let n=this.clock.now(),o=this.lastRefill.get(t)??n,a=this.tokens.get(t)??e,d=Math.max(0,n-o),s=Math.min(e,a+d*e/6e4);return s<1?(this.tokens.set(t,s),this.lastRefill.set(t,n),false):(this.tokens.set(t,s-1),this.lastRefill.set(t,n),true)}};function Y(r,t){return r.toLowerCase()===t.toLowerCase()}i(Y,"originsEqual");function F(r){let t=r.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="[::1]"||t==="::1"?true:/^127(\.\d{1,3}){3}$/.test(t)}i(F,"isLoopbackHostname");function Se(r,t){if(typeof t!="string"||t==="")return false;let e,n;try{e=new URL(r),n=new URL(t);}catch{return false}return e.protocol!=="http:"&&e.protocol!=="https:"||n.protocol!=="http:"&&n.protocol!=="https:"||e.username!==""||e.password!==""||e.pathname!=="/"||e.search!==""||e.hash!==""||e.port===""?false:F(e.hostname)&&F(n.hostname)}i(Se,"isLoopbackDevHostEmbedder");function $e(r,t){if(r.min>r.max||t.min>t.max)return null;let e=Math.min(r.max,t.max),n=Math.max(r.min,t.min);return e>=n?e:null}i($e,"negotiateVersion");var Ne="[gem: use gem.text.toPlain()]",Fe=new Set,qe;function Rt(r){try{if(Fe.has(r))return;let t=globalThis.location;if(qe??=!!t?.port&&F(t.hostname??""),!qe)return;Fe.add(r),console.warn(`[gem] ${r} is PlayerText, turned into a string: players see ${Ne}. Render text.toPlain(value) (text is in @indiegems/gem-web-sdk/sdk).
|
|
2
|
-
${new Error().stack}`);}catch{}}i(Rt,"warnStringified");var le=class{static{i(this,"PlayerText");}#e;#t;constructor(t,e="player text"){this.#e=t,this.#t=e,Object.freeze(this);}toString(){return Rt(this.#t),Ne}toJSON(){return this.toString()}get[Symbol.toStringTag](){return "PlayerText"}static unwrap(t){return t.#e}};function G(r,t){return new le(r,t)}i(G,"asPlayerText");function je(r){return Math.min(16384,Math.max(0,Math.round(Number.isFinite(r)?r:0)))}i(je,"cuePoint");function We(r,t){if(r!==true)return {visible:false};let e=[],n=false;for(let o of Array.isArray(t)?t:[])o==="score"?n=true:typeof o=="string"&&o.length>0&&o.length<=64&&!e.includes(o)&&e.push(o);return !n&&e.length===0?{visible:true}:{visible:true,currencies:e.slice(0,8),score:n}}i(We,"walletState");function He(r){let t=[];for(let e of Array.isArray(r)?r:[]){if(t.length===4)break;if(typeof e!="object"||e===null)continue;let{id:n,label:o}=e;typeof n!="string"||n.length===0||n.length>32||typeof o!="string"||o.trim().length===0||t.some(a=>a.id===n)||t.push({id:n,label:o.trim().slice(0,40)});}return t.length===0?{settings:false}:{settings:false,items:t}}i(He,"menuState");function Ue(r,t){return Math.min(t,Math.max(0,Math.round(Number.isFinite(r)?r:0)))}i(Ue,"clampStat");function kt(r){let t=r.untrusted,e=G(t.displayName,"gem.player.displayName"),n=t.displayTag||t.displayHandle,o=n?G(n,"gem.player.displayTag"):void 0,a=r.discriminator||r.displayTag,d=a&&/^[0-9]{1,8}$/.test(a)?a:void 0,s=r.avatarIconUrl||r.avatarUrl,c=/^[\da-f]{8}(-[\da-f]{4}){3}-[\da-f]{12}$/i,y=r.avatarIconId,v=r.avatar3dId,b={displayName:e,displayHandle:o??e,badges:(r.badges??[]).map(w=>({itemId:w.itemId,iconUrl:w.iconUrl}))};r.playerId&&(b.playerId=r.playerId),d&&(b.discriminator=d),o&&(b.displayTag=o),s&&(b.avatarIconUrl=b.avatarUrl=s),y&&c.test(y)&&(b.avatarIconId=y),v&&c.test(v)&&(b.avatar3dId=v),r.avatar3dModelUrl&&(b.avatar3dModelUrl=r.avatar3dModelUrl),r.avatar3dIconUrl&&(b.avatar3dIconUrl=r.avatar3dIconUrl),r.avatars3d&&(b.avatars3d=r.avatars3d.filter(w=>c.test(w.id)&&/^[a-z][a-z0-9_]*$/.test(w.family)).filter((w,fe,he)=>he.findIndex(ye=>ye.family==w.family)==fe).map(({family:w,id:fe,modelUrl:he,iconUrl:ye})=>({family:w,id:fe,modelUrl:he,iconUrl:ye})));let x=r.boost,V=(x?.multipliers??[]).map(w=>({currencyId:w.currencyId,currencySlug:w.currencySlug,multiplier:w.multiplierBp/1e4})),ge=V.some(w=>w.multiplier>1);return b.boost=ge&&x?.expiresInDays?{active:ge,multipliers:V,expiresInDays:x.expiresInDays}:{active:ge,multipliers:V},b}i(kt,"playerFromWire");var At=1e4,xt=["appLinks","openGame","store","storeOfferSheet"],Pt=["token","pause","menuSelect","settingChange","prefs","cohorts","viewport","willTerminate","localServer","roomEvent","seatedEvent","autoStartFailedEvent","ticketEvent","socketState","signalEvent","relayDraining","dedicatedEvent","clusterTarget","graphicsRoutes","partyResult","purchaseResult","purchaseSettled","shareResult","deviceSettings","adResult","momentResult","signInResult","friendChallengeResult"],Et=new WeakMap;var q=class{constructor(t){this.options=t;if(t.expectedSource===void 0||t.expectedSource===null)throw new Error("GemFrame: expectedSource is required and must not be null \u2014 pass window.parent. The handshake transfers the MessagePort, and origin alone does not say WHICH document on that origin sent it.");this.expectedSource=t.expectedSource,this.clock=t.clock??C,this.inbound=new X(this.clock),this.outbound=new X(this.clock);}options;static{i(this,"GemFrame");}state="waiting";port=null;version=null;peerCapabilities=[];unbidden=false;engagedSent=false;readyPending=false;readySent=false;settleWaiters=[];clock;inbound;outbound;expectedSource;get currentState(){return this.state}get parentCapabilities(){return this.peerCapabilities}parentSupports(t){return this.peerCapabilities.includes(t)}get protocolVersion(){return this.version}get unbiddenLaunch(){return this.unbidden}handleWindowMessage(t){if(t.source!==this.expectedSource)return this.refuse(t,"handshake did not come from the expected embedder window"),false;if(!(this.options.allowedEmbedders.some(s=>Y(s,t.origin))||Se(t.origin,this.options.selfOrigin)||(Et.get(this)??[]).some(s=>Y(s,t.origin))))return this.refuse(t,`embedder '${t.origin}' is not in allowedEmbedders`),this.state==="waiting"&&this.transition("refused"),false;if(this.state==="connected")return this.fail("handshake_duplicate","this document already has a port"),false;if(this.state!=="waiting")return false;let n=$["gem.handshake"]?.(t.data);if(n)return this.refuse(t,`malformed handshake: ${n}`),false;let o=t.data;if(!Y(o.embedder,t.origin))return this.refuse(t,`handshake claims embedder '${o.embedder}' but arrived from '${t.origin}'`),false;let a=t.ports?.[0];if(!a)return this.refuse(t,"handshake transferred no MessagePort"),false;let d=$e(A,o.versions);return d===null?(a.onmessage=null,a.postMessage({gem:u,type:"gem.error",code:"version_mismatch",message:`frame supports v${A.min}..v${A.max}`}),a.close(),this.transition("refused"),this.options.onError?.("version_mismatch"),false):(this.port=a,this.version=d,a.onmessage=s=>this.receive(s.data,s.ports??[]),a.start?.(),this.peerCapabilities=o.capabilities??[],this.unbidden=o.unbidden===true,a.postMessage({gem:u,type:"gem.handshake.accept",v:d,...this.options.capabilities===void 0?{}:{capabilities:[...this.options.capabilities]}}),this.transition("connected"),this.readyPending&&(this.readyPending=false,this.ready()),true)}ready(){if(this.state!=="connected"||!this.port){this.readyPending=true;return}if(this.readySent){this.options.onDropped?.("internal","gem.ready was already sent; duplicate suppressed");return}this.readySent=true,this.send({gem:u,type:"gem.ready"});}settled(t=At){return this.state!=="waiting"?Promise.resolve(this.state):new Promise(e=>{let n=i(a=>{this.clock.clearTimeout(o),e(a);},"waiter"),o=this.clock.setTimeout(()=>{let a=this.settleWaiters.indexOf(n);a>=0&&this.settleWaiters.splice(a,1),e(this.state);},t);this.settleWaiters.push(n);})}progress(t,e){this.send({gem:u,type:"gem.progress",loaded:t,total:e});}requestToken(t,e){this.send({gem:u,type:"gem.requestToken",requestId:t,reason:e});}requestLocalServer(t,e){return this.parentSupports("localHost")?(this.send({gem:u,type:"gem.requestLocalServer",requestId:t,gameRoomId:e}),true):false}exit(t){this.send(t===void 0?{gem:u,type:"gem.exit"}:{gem:u,type:"gem.exit",reason:t});}openExternal(t){this.send({gem:u,type:"gem.openExternal",url:t});}requestFullscreen(t){this.send({gem:u,type:"gem.requestFullscreen",enabled:t});}reportMuted(t){return this.gated("audioState")?(this.send({gem:u,type:"gem.audioState",muted:t}),true):false}reportEngaged(){return this.engagedSent||!this.gated("engagement")||!this.send({gem:u,type:"gem.engaged"})?false:(this.engagedSent=true,true)}cueReward(t){if(!this.gated("rewardCue"))return false;let e={gem:u,type:"gem.rewardCue",currencySlug:String(t.currencySlug).slice(0,32)};return De(t.cueId)&&(e.cueId=t.cueId),t.expected!==void 0&&Number.isFinite(t.expected)&&t.expected>=1&&(e.expected=Math.min(1e9,Math.round(t.expected))),t.origin&&(e.origin={x:je(t.origin.x),y:je(t.origin.y)}),this.send(e),true}showPortraitBorders(t){let e=_e(t);return e===void 0||!this.gated("portraitBorders")?false:this.send(e===null?{gem:u,type:"gem.portraitBorders"}:{gem:u,type:"gem.portraitBorders",name:e})}setWalletVisible(t,e){return this.gated("walletDisplay")?this.send({gem:u,type:"gem.walletDisplay",...We(t,e?.only)}):false}setMenu(t){return this.gated("gameMenu")?this.send({gem:u,type:"gem.menu",...He(t)}):false}declareSettings(t){return this.gated("gameSettings")?this.send({gem:u,type:"gem.settingsDeclare",settings:t}):false}setGemCorner(t){return this.gated("gemCorner")?this.send({gem:u,type:"gem.gemCorner",corner:t}):false}setRewardPresentation(t){return this.gated("rewardPresentation")?this.send({gem:u,type:"gem.rewardPresentation",mode:t}):false}setMenuStyle(t){return this.gated("menuStyle")?this.send(t===null?{gem:u,type:"gem.menuStyle"}:{gem:u,type:"gem.menuStyle",ground:t.ground,accent:t.accent}):false}requestShare(t,e){return this.gated("share")?this.send({gem:u,type:"gem.requestShare",...e===void 0?{}:{requestId:e},params:t.map(({key:n,value:o})=>({key:n,value:o}))}):false}requestAvatarPicker(t){return this.gated("avatarPicker")?this.send({gem:u,type:"gem.requestAvatarPicker",...t==="2d"||t==="3d"?{tab:t}:{}}):false}requestVibrate(t){return this.gated("vibration")?this.send({gem:u,type:"gem.vibrate",pattern:[...t]}):false}reportFrameStats(t){return this.gated("frameStats")?(this.send({gem:u,type:"gem.frameStats",fps:Ue(t.fps,1e3),frameTimeP95Ms:Ue(t.frameTimeP95Ms,1e5),counts:t.counts==="gameDraws"?"gameDraws":"pageFrames"}),true):false}sendGameContext(t){return this.state!=="connected"?false:(this.send({gem:u,type:"gem.gameContext",context:t}),true)}signal(t,e,n){this.send({gem:u,type:"gem.signal",signal:t,matchId:e,data:n});}dedicatedOffer(t,e,n){this.send({gem:u,type:"gem.dedicatedOffer",matchId:t,sdp:e,intent:n});}requestParty(t){return this.send({gem:u,type:"gem.partyRequest",requestId:t})}requestPurchase(t,e,n,o,a,d,s){return this.send({gem:u,type:"gem.requestPurchase",requestId:t,purchaseKind:e,targetId:n,currencySlug:o,...a===void 0?{}:{quantity:a},...d===void 0?{}:{catalogId:d},...s===void 0?{}:{origin:s}})}requestAvatar3dPurchase(t,e,n){return this.parentSupports("avatar3dPurchases")?this.send({gem:u,type:"gem.requestAvatar3dPurchase",requestId:t,itemId:e,currencySlug:n}):false}putDeviceSettings(t,e){return this.send({gem:u,type:"gem.deviceSettings.put",requestId:t,settings:e})}requestAd(t,e,n){return this.send({gem:u,type:"gem.requestAd",requestId:t,placement:e,format:n})}signalMoment(t,e,n,o){return this.send({gem:u,type:"gem.signalMoment",requestId:t,kind:e,...n===void 0?{}:{placement:n},...o===true?{wall:true}:{}})}readyCalled(){return this.readySent||this.readyPending}requestSignIn(t){return this.send({gem:u,type:"gem.requestSignIn",requestId:t})}requestFriendChallenge(t,e,n,o){return this.send({gem:u,type:"gem.requestFriendChallenge",requestId:t,playerId:e,template:n,...o===void 0?{}:{params:o}})}requestArcade(t){return this.gated(se(t.type))&&this.send({gem:u,...t})}close(){this.port&&(this.port.onmessage=null,this.port.close(),this.port=null),this.state!=="refused"&&this.transition("closed");}transition(t){if(this.state!==t){this.state=t;for(let e of this.settleWaiters.splice(0))e(t);this.options.onStateChange?.(t);}}refuseMalformed(t,e){if(!this.inbound.allow(ae)){this.options.onDropped?.(t,e);return}this.fail(t,e);}dropUnknownType(t){this.inbound.allow(ae)&&this.options.onDropped?.("unsupported",`ignored unknown message type '${t}'`);}refuse(t,e){t.ports?.[0]?.close?.(),this.inbound.allow(ae)&&this.options.onRefused?.(e);}fail(t,e){this.options.onError?.(t,e),this.state==="connected"&&this.port&&this.send({gem:u,type:"gem.error",code:t,...e===void 0?{}:{message:e}});}gated(t){return this.state==="connected"&&this.parentSupports(t)}send(t){if(this.state!=="connected"||!this.port)return this.options.onDropped?.("internal",`dropped ${String(t.type)} before connect`),false;let e=t.type;if(!this.outbound.allow(e))return this.options.onError?.("rate_limited",`frame exceeded its own limit for ${e}`),false;let n=$[e]?.(t);return n?(this.options.onError?.("internal",`refusing to send malformed ${e}: ${n}`),false):(this.port.postMessage(this.version===null?t:{...t,v:this.version}),true)}receive(t,e=[]){let n=false;try{n=this.dispatchInbound(t,e);}finally{n||Be(e);}}dispatchInbound(t,e){if(this.state!=="connected")return false;let n=typeof t=="object"&&t!==null?t.type:void 0;if(typeof n!="string")return this.refuseMalformed("invalid_message","message has no type"),false;let o=$[n];if(!o)return this.dropUnknownType(n),false;if(!this.inbound.allow(n))return this.fail("rate_limited",`parent exceeded the limit for ${n}`),false;let a=se(n);if(a!==void 0&&!this.options.capabilities?.includes(a))return this.fail("unsupported_capability",`${n} requires the '${a}' capability, which this frame did not advertise`),false;let d=o(t);if(d)return this.fail("invalid_message",`${n}: ${d}`),false;let s=t;if(s.v!==this.version)return this.fail("invalid_message",`${n}: expected v ${String(this.version)}`),false;switch(n){case "gem.earnAllowanceChanged":this.options.onEarnAllowanceChanged?.();break;case "gem.devtools":this.options.onDevtools?.(s.action);break;case "gem.requestContext":this.options.onRequestContext?.();break;case "gem.screenshot":{let c=e[0];if(!c){this.options.onError?.("invalid_message","gem.screenshot transferred no MessagePort");break}let y={maxWidth:s.maxWidth,maxHeight:s.maxHeight};if(!this.options.onScreenshot){c.close(),this.screenshotDenied("not_wired",false);break}return Be(e.slice(1)),this.options.onScreenshot(y,c,(v,b)=>this.screenshotDenied(v,b)),true}case "gem.token.denied":this.options.onTokenDenied?.(s);break;case "gem.localServer.denied":this.options.onLocalServerDenied?.(s);break;case "gem.player":{this.options.onPlayer?.(kt(s));break}case "gem.deviceSettings.result":this.options.onDeviceSettingsResult?.(s);break;case "gem.error":this.options.onError?.(s.code,s.message);break;default:if(Pt.includes(n.slice(4))){this.options[`on${n[4].toUpperCase()}${n.slice(5)}`]?.(s);break}if(xt.includes(se(n))){this.options.onArcadeAnswer?.(s);break}this.fail("unsupported",`no frame handler for '${n}'`);}return false}screenshotDenied(t,e){this.send({gem:u,type:"gem.screenshot.denied",reason:t,retryable:e});}};function Be(r){for(let t of r)try{t?.close?.();}catch{}}i(Be,"closeAll");globalThis.__gemWebSdkVersion="[gem-web-sdk:sdkVersion:22.0.0]";var Ve=["if-match","if-none-match"];var Ot={unknown_currency:1,currency_not_in_game_payable:1,not_purchasable:1,no_price_in_currency:1,busy:1,cancelled:1,insufficient_funds:1,price_mismatch:1,config_version_stale:1,platform_currency_unavailable:1,not_available:1,recipe_locked:1,already_owned:1,guest_upgrade_required:1,recipe_on_cooldown:1,recipe_max_uses_exceeded:1,item_max_stack_exceeded:1,recipe_costs_unmet:1,quantity_invalid:1,error:1};new Set(Object.keys(Ot));new Set(Ve);new TextEncoder;var Je=["explicit","stale_cleanup","game_room_closed","replaced","migration_failed","host_left","insufficient_players","all_left","expired","migration_rate_exceeded","game_room_gone","failed","idle","reclaimed"];new Set(Je);new TextEncoder;new TextDecoder;new TextEncoder;var cn=8;(class{constructor(t=cn){this.perMinute=t;}perMinute;static{i(this,"CredentialPacing");}sent=[];delayUntilAllowed(t){return this.prune(t),this.sent.length<this.perMinute?0:Math.max(0,(this.sent[0]??t)+6e4-t)}record(t){this.prune(t),this.sent.push(t);}prune(t){let e=0;for(let n of this.sent)n<=t&&t-n<6e4&&(this.sent[e++]=n);this.sent.length=e;}});function p(r){return t=>typeof t=="string"&&t.length>0&&t.length<=r?t:void 0}i(p,"text");function O(r,t){return e=>typeof e=="number"&&Number.isInteger(e)&&e>=r&&e<=t?e:void 0}i(O,"integer");function N(...r){return t=>typeof t=="string"&&r.includes(t)?t:void 0}i(N,"oneOf");function Xe(r){return typeof r=="boolean"?r:void 0}i(Xe,"flag");var _=p(64),te=O(0,2147483647);function de(r){if(!Array.isArray(r))return;let t=[];for(let e of r){if(t.length>=64)break;let n=_(e);typeof n=="string"&&t.push(n);}return t}i(de,"ids");function g(r,t,e){return {to:r,from:t,read:e,required:true}}i(g,"required");function f(r,t,e){return {to:r,from:t,read:e,required:false}}i(f,"optional");var gn=i(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return;let t=r,e=N("disconnected","failed","closed")(t.iceState),n=O(0,4102444800)(t.lastSeenAt);if(!(e===void 0&&n===void 0))return {...e===void 0?{}:{ice_state:e},...n===void 0?{}:{last_seen_timestamp:n}}},"evidence");Object.freeze(Object.assign(Object.create(null),{join:{type:"p2p_join",gameScoped:true,args:[]},offer:{type:"p2p_offer",gameScoped:false,args:[g("sdp","sdp",p(10240)),g("signaling_intent","intent",N("initial","ice_restart","full_reconnect")),f("sdp_hash","sdpHash",p(128))]},answer:{type:"p2p_answer",gameScoped:false,args:[g("peer_id","peerId",_),g("sdp","sdp",p(10240)),g("assigned_peer_id","assignedPeerId",O(0,4294967295)),f("sdp_hash","sdpHash",p(128))]},ice:{type:"p2p_ice_candidate",gameScoped:false,args:[g("peer_id","peerId",_),g("candidate","candidate",p(512)),f("sdp_mid","sdpMid",p(64)),f("sdp_mline_index","sdpMLineIndex",O(0,255))]},migrationAck:{type:"p2p_migration_ack",gameScoped:false,args:[g("host_epoch","hostEpoch",te)]},hostUnreachable:{type:"p2p_report_host_unreachable",gameScoped:false,args:[g("host_epoch","hostEpoch",te),f("evidence","evidence",gn)]}}));Object.freeze(Object.assign(Object.create(null),{p2p_hello:"hello",p2p_sdp_offer:"offer",p2p_sdp_answer:"answer",p2p_ice_candidate:"ice",p2p_peer_joined:"peerJoined",p2p_peer_left:"peerLeft",p2p_host_migration:"migration",p2p_match_ended:"matchEnded",p2p_error:"error",p2p_relay_draining:"relayDraining"}));var fn=16,hn=i(r=>de(r)?.slice(0,fn),"relayIps");Object.freeze(Object.assign(Object.create(null),{hello:[g("playerId","player_id",_),g("hostPlayerId","host_player_id",_),g("hostEpoch","host_epoch",te),f("members","members",de)],offer:[g("fromPlayerId","from_player_id",_),g("sdp","sdp",p(10240)),f("sessionId","signaling_session_id",p(128)),f("sdpHash","sdp_hash",p(128)),f("iceUfrag","ice_ufrag",p(64)),f("intent","signaling_intent",N("initial","ice_restart","full_reconnect"))],answer:[g("fromPlayerId","from_player_id",_),g("sdp","sdp",p(10240)),f("sessionId","signaling_session_id",p(128)),f("sdpHash","sdp_hash",p(128)),f("iceUfrag","ice_ufrag",p(64)),f("assignedPeerId","assigned_peer_id",O(0,4294967295))],ice:[g("fromPlayerId","from_player_id",_),g("candidate","candidate",p(512)),f("sdpMid","sdp_mid",p(64)),f("sdpMLineIndex","sdp_m_line_index",O(0,255)),f("sdpMLineIndexAlt","sdp_mline_index",O(0,255))],peerJoined:[g("playerId","player_id",_)],peerLeft:[g("playerId","player_id",_),f("reason","reason",p(64))],migration:[g("hostPlayerId","new_host_player_id",_),g("hostEpoch","host_epoch",te),f("reason","reason",p(64)),f("kickedPlayerIds","kicked_player_ids",de),f("migrationComplete","migration_complete",Xe)],matchEnded:[f("reason","reason",p(64))],error:[f("code","code",p(64)),f("message","message",p(256))],relayDraining:[g("clusterTargetId","cluster_target_id",_),g("relayIps","relay_ips",hn),g("drainingSince","draining_since",p(40)),g("deadline","deadline",p(40))]}));Object.freeze(Object.assign(Object.create(null),{party_invite_received:"inviteReceived",party_member_joined:"memberJoined",party_member_left:"memberLeft",party_member_kicked:"memberKicked",party_leader_transferred:"leaderTransferred",party_updated:"updated",party_disbanded:"disbanded",party_game_room_joined:"gameRoomJoined",party_game_room_left:"gameRoomLeft"}));function Sn(r,t){return Object.freeze({route:r,listed:t})}i(Sn,"answer");Object.freeze(Object.assign(Object.create(null),{webrtc_sdp_answer:"answer",webrtc_error:"error",match_ended:"matchEnded"}));Object.freeze(Object.assign(Object.create(null),{answer:[g("sdp","sdp",p(10240)),f("sessionId","session_id",p(64))],error:[f("code","code",p(64)),f("message","message",p(256))],matchEnded:[f("reason","reason",p(64))]}));var st=Object.freeze(["https://gemarcade.com","https://developer.gemarcade.com","http://gemarcade.localhost","gemarcade://localhost"]);var H=class extends Error{constructor(e,n){super(`[${e}] ${n}`);this.caseId=e;this.name="ParentConformanceError";}caseId;static{i(this,"ParentConformanceError");}},jw=6,lt="https://game.conformance.invalid",dr="https://stranger.conformance.invalid",Ie=M["gem.handshake"]??1,ie=6e4,ue=class{static{i(this,"KitClock");}current=1e6;seq=0;pending=new Map;now(){return this.current}setTimeout(t,e){let n=++this.seq;return this.pending.set(n,{at:this.current+Math.max(0,e),fn:t}),n}clearTimeout(t){this.pending.delete(t);}get pendingTimers(){return this.pending.size}advance(t){let e=this.current+t;for(;;){let n;for(let o of this.pending)o[1].at<=e&&(n===void 0||o[1].at<n[1].at)&&(n=o);if(n===void 0)break;this.pending.delete(n[0]),this.current=n[1].at,n[1].fn();}this.current=e;}},dt=Object.freeze({conformance:"parent-window"}),me=class{constructor(t,e,n,o){this.caseId=t;this.options=n;let a=o??n.frameOrigin??lt,d={frame:{postMessage:i((s,c,y)=>{this.offers.push({data:s,targetOrigin:c,transfer:y??[],at:this.clock.now()});},"postMessage")},frameOrigin:a,embedderOrigin:n.embedderOrigin,clock:this.clock,makeChannel:i(()=>{let s=new MessageChannel,c={port1:s.port1,port2:s.port2,closed:false},y=s.port1.close.bind(s.port1);return s.port1.close=()=>{c.closed=true,y();},this.count(s.port1),this.count(s.port2),this.minted.push(c),s},"makeChannel"),reportError:i((s,c)=>{this.errors.push(c===void 0?{code:s}:{code:s,message:c});},"reportError")};Object.defineProperty(d,"userActivation",{enumerable:true,get:i(()=>this.activation===void 0?void 0:{...this.activation},"get")}),this.parent=e(d);}caseId;options;static{i(this,"Rig");}clock=new ue;frameClock=new ue;offers=[];minted=[];parent;activation={isActive:false};errors=[];inFlight=0;frames=[];get frameOrigin(){return this.options.frameOrigin??lt}fail(t){throw new H(this.caseId,t)}count(t){let e=t.postMessage.bind(t);t.postMessage=((...n)=>{this.inFlight+=1,e(...n);}),t.addEventListener("message",()=>{this.inFlight-=1;});}async flush(){let t=i(()=>new Promise(e=>setTimeout(e,0)),"turn");await t(),await t();for(let e=0;this.inFlight>0&&e<200;e++)await t();}advance(t,e=250){for(let n=0;n<t;n+=e){let o=Math.min(e,t-n);this.clock.advance(o),this.frameClock.advance(o);}}start(){try{this.parent.start();}catch(t){this.fail(`start() threw: ${ct(t)}`);}this.offers.length===0&&this.fail("start() posted no handshake to the frame window. The offer must be posted at start, on the window the fixture names as `frame`.");}latest(){let t=this.offers[this.offers.length-1];return t===void 0&&this.fail("no handshake has been offered"),t}transferred(t){t.transfer.length!==1&&this.fail(`an offer transferred ${t.transfer.length} objects; it must transfer exactly one MessagePort.`);let e=this.minted.find(n=>n.port2===t.transfer[0]);return e===void 0&&this.fail("an offer transferred a port the fixture did not mint. Take every offer\u2019s channel from `fixture.makeChannel`, so the kit can see which ports the parent closes."),e}frame(t){let e=t??[...new Set([...st,...this.options.allowedEmbedders??[]])],n=[],o=new q({allowedEmbedders:e,expectedSource:dt,selfOrigin:this.frameOrigin,clock:this.frameClock,onRefused:i(a=>n.push(a),"onRefused")});return o.kitRefusals=n,this.frames.push(o),o}deliver(t,e){let n=this.transferred(e);return t.handleWindowMessage({data:e.data,origin:this.options.embedderOrigin,source:dt,ports:[n.port2]})}answer(t,e,n=[]){this.transferred(t).port2.postMessage({gem:u,type:"gem.handshake.accept",v:e,capabilities:[...n]});}advertised(){let t=this.latest().data.capabilities;return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async raw(t){let e=this.latest(),n=this.transferred(e),o=[];n.port2.onmessage=s=>{s.data!==null&&typeof s.data=="object"&&o.push(s.data);};let a=Math.min(W(this).max,A.max);this.answer(e,a,t),await this.flush(),this.state()!=="connected"&&this.fail(`a hand-written frame accepted at v${a}, and the parent reports '${this.state()}'.`);let d=0;return {received:o,ask:i(async(s,c,y)=>{let v=`conformance-${++d}`;return this.activation=y==="missing"?void 0:{isActive:y==="pressed"},n.port2.postMessage({gem:u,type:s,v:a,requestId:v,...c}),await this.flush(),this.activation={isActive:false},v},"ask"),answers:i(s=>o.filter(c=>c.requestId===s),"answers")}}surfaces(t){let e=this.parent.surfacesShown;return typeof e!="number"&&this.fail(`${t}, so the kit must see what it shows: expose \`surfacesShown\` on the adapter (every checkout, card, QR code, toast or tab the parent opened for a game).`),e}offersInAnyMinute(){let t=0;for(let e=0;e<this.offers.length;e++){let n=this.offers[e].at,o=0;for(let a=e;a<this.offers.length&&this.offers[a].at<n+ie;a++)o++;t=Math.max(t,o);}return t}state(){return this.parent.state}dispose(){try{this.parent.close();}catch{}for(let t of this.frames)t.close();for(let t of this.minted)try{t.port1.close(),t.port2.close();}catch{}}};function ct(r){return r instanceof Error?r.message:String(r)}i(ct,"describe");function cr(r){return r.kitRefusals??[]}i(cr,"refusalsOf");function W(r){let t=r.latest().data.versions,e=t?.min,n=t?.max;return (typeof e!="number"||typeof n!="number")&&r.fail("the handshake carries no numeric `versions.min` / `versions.max`"),{min:e,max:n}}i(W,"offeredRange");async function h(r,t,e,n){let o=new me(r,t,e);try{await n(o);}finally{o.dispose();}}i(h,"withRig");async function ne(r){let t=r.frame();return r.deliver(t,r.latest())||r.fail(`a game built with this SDK refused the handshake from ${r.options.embedderOrigin}: ${cr(t).join("; ")||"no reason recorded"}. A production origin the SDK does not carry needs an SDK that lists it; a non-production one goes in \`allowedEmbedders\` here, as a game would name it.`),await r.flush(),r.state()!=="connected"&&r.fail(`the frame accepted, but the parent reports '${r.state()}' rather than 'connected'.`),t}i(ne,"connect");var E=["appLinks","openGame","store","storeOfferSheet"],ur="00000000-0000-4000-8000-00000000c0de",pe="conformance-unknown-sku",Ce={appLinks:{type:"gem.requestOpenApp",fields:{target:"arcade"}},openGame:{type:"gem.requestOpenGame",fields:{ref:ur}},store:{type:"gem.requestStorePurchase",fields:{skuId:pe}},storeOfferSheet:{type:"gem.requestStoreOfferSheet",fields:{skuId:pe}}},mr=["appLinks","openGame"],pr=[["store","gem.requestStorePurchase"],["storeOfferSheet","gem.requestStoreOfferSheet"]];function ce(r,t,e,n,o){let a=t.answers(e);a.length!==1&&r.fail(`${o}: the parent sent ${a.length} answers; it owes exactly one.`);let[d]=a;(d.outcome!=="declined"||d.reason!=="busy")&&r.fail(`${o}: answered ${JSON.stringify(d.outcome)} / ${JSON.stringify(d.reason)}, not 'declined' / 'busy'.`);let s=r.surfaces(o);s!==n&&r.fail(`${o}: the parent showed ${s-n} surface(s); it must show nothing.`);}i(ce,"expectBusy");async function B(r,t,e="gem.requestStorePurchase",n="pressed",o=""){let a=await t.ask("gem.requestStoreOffers",{},"unpressed"),[d]=t.answers(a),c=(d?.offers??[])[0]?.skuId;(d?.outcome!=="ok"||typeof c!="string")&&r.fail(`the parent advertises \`store\` but listed no offer to a signed-in player (${JSON.stringify(d?.outcome)} / ${JSON.stringify(d?.reason)}). Give the adapter's store a signed-in player and at least one SKU, so the kit can open a checkout.`);let y=r.surfaces("the parent advertises `store`"),v=await t.ask(e,{skuId:c},n),b=r.surfaces("the parent advertises `store`");if(b!==y+1){let x=n==="pressed"?"a pressed":n==="unpressed"?"an unpressed":"with no userActivation API, a",V=t.answers(v);r.fail(`${o}${x} ${e} of the listed SKU ${JSON.stringify(c)} showed ${b-y} surface(s) and was answered ${JSON.stringify(V)}; it must open exactly one. A store purchase needs no press, and nothing backs off after the player closes a checkout: a player who wants to pay can always pay.`);}return t.answers(v).length>0&&r.fail(`${e} was answered while what it opened was still open. Answer once the player has acted, so the kit can hold it open.`),{requestId:v,skuId:c,shown:b}}i(B,"openStoreCheckout");function re(r){typeof r.parent.dismiss!="function"&&r.fail("the parent advertises `store`, so the kit must be able to close its checkout: expose `dismiss()` on the adapter (the player closing the checkout without paying)."),r.parent.dismiss();}i(re,"dismiss");var gr=["*","null","","https://game.conformance.invalid/","https://game.conformance.invalid/play"],fr=[{id:"origin.refuses-imprecise-target",title:"refuses a frame origin that is not one exact origin, before anything is posted",async run(r,t){for(let e of gr){let n=JSON.stringify(e),o,a=false;try{o=new me(this.id,r,{...t,frameOrigin:e},e),o.parent.start();}catch(d){if(d instanceof H)throw d;a=true;}try{if((o?.offers??[]).some(s=>s.targetOrigin==="*"||s.targetOrigin===e))throw new H(this.id,`with frame origin ${n} the parent posted the handshake anyway \u2014 the offer transfers the session port, so an imprecise target hands the session to whatever the frame has navigated to.`);if(!a)throw new H(this.id,`a frame origin of ${n} was accepted. Refuse it at construction or at start(), by throwing.`)}finally{o?.dispose();}}}},{id:"handshake.targets-frame-origin",title:"posts a valid handshake to exactly the frame origin, naming the page\u2019s own origin",async run(r,t){await h(this.id,r,t,e=>{e.start(),e.advance(T);for(let a of e.offers){a.targetOrigin!==e.frameOrigin&&e.fail(`an offer was posted with targetOrigin ${JSON.stringify(a.targetOrigin)}, not the frame origin ${e.frameOrigin}.`),e.transferred(a);let d=$["gem.handshake"]?.(a.data);d&&e.fail(`the handshake does not validate against the schema: ${d}`);let s=a.data;s.gem!==u&&e.fail(`the handshake's \`gem\` is not ${u}`),s.embedder!==t.embedderOrigin&&e.fail(`the handshake names embedder ${JSON.stringify(s.embedder)}, but the page is served from ${t.embedderOrigin}. Every game compares the two and refuses a mismatch: name the origin the page is actually served from.`);}let{min:n,max:o}=W(e);n>o&&e.fail(`the offered range is empty: min ${n} > max ${o}`),(o<A.min||n>A.max)&&e.fail(`the offered range v${n}\u2013v${o} shares no version with this SDK (v${A.min}\u2013v${A.max}).`);});}},{id:"handshake.default-game-connects",title:"connects to a game that names no embedders, at the highest common version",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=await ne(e),{max:o}=W(e),a=Math.min(o,A.max);n.protocolVersion!==a&&e.fail(`the frame chose v${String(n.protocolVersion)}, expected v${a}`),e.parent.protocolVersion!==n.protocolVersion&&e.fail(`the parent reports v${String(e.parent.protocolVersion)} while the frame chose v${String(n.protocolVersion)}. Adopt the version on the accept.`);});}},{id:"handshake.refusal-is-not-a-verdict",title:"keeps offering, still handshaking, when a game refuses this page",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=e.frame([dr]);e.deliver(n,e.latest())&&e.fail("a frame that does not allow this page accepted it \u2014 the kit is misconfigured"),await e.flush();let o=e.offers.length;e.advance(T*3),await e.flush(),e.state()!=="handshaking"&&e.fail(`after a refusal and ${T*3}ms the parent reports '${e.state()}'. A refusing game answers nothing, by design, so silence is not evidence: stay handshaking until the page closes the bridge.`),e.offers.length<=o&&e.fail("the parent stopped offering after a refusal; keep offering on the cadence.");});}},{id:"version.adopts-frame-choice",title:"adopts the version the frame chose from inside the offered range",async run(r,t){await h(this.id,r,t,async e=>{e.start();let{min:n}=W(e);e.answer(e.latest(),n),await e.flush(),(e.state()!=="connected"||e.parent.protocolVersion!==n)&&e.fail(`answered with v${n}, the bottom of the offered range, the parent reports '${e.state()}' at v${String(e.parent.protocolVersion)}.`);});}},{id:"version.refuses-out-of-range",title:"never connects at a version outside the range it offered",async run(r,t){for(let e of ["above","below"])await h(this.id,r,t,async n=>{n.start();let{min:o,max:a}=W(n),d=e==="above"?a+1:o-1;n.answer(n.latest(),d),await n.flush(),(n.state()==="connected"||n.parent.protocolVersion===d)&&n.fail(`answered with v${d}, outside the offered v${o}\u2013v${a}, the parent connected. A frame choosing a version this parent never offered is not a session.`);});}},{id:"lifecycle.reoffers-on-fresh-ports",title:"re-offers on a fresh port while unanswered, inside the contract\u2019s budget",async run(r,t){await h(this.id,r,t,e=>{e.start(),e.advance(T*2),e.offers.length<2&&e.fail(`one offer in ${T*2}ms. A message to a document that is not listening yet is lost, not queued: re-offer until something answers.`);let n=e.offers.map(a=>e.transferred(a).port2);new Set(n).size!==n.length&&e.fail("an offer re-used a port; each offer needs its own channel."),e.advance(ie*2);let o=e.offersInAnyMinute();o>Ie&&e.fail(`${o} offers inside one minute; the contract budgets ${Ie} \`gem.handshake\` per minute.`);});}},{id:"lifecycle.late-answer-adopts-and-closes-the-rest",title:"adopts the offer a late frame answers, and closes every other offered port",async run(r,t){await h(this.id,r,t,async e=>{e.start(),e.advance(T*2);let n=e.transferred(e.latest());await ne(e),n.closed&&e.fail("the parent closed the port the frame answered on.");let o=e.minted.filter(a=>a!==n&&!a.closed).length;o>0&&e.fail(`${o} unanswered offer port(s) still open after connecting. Close every other offer when one is answered.`);});}},{id:"lifecycle.no-offers-after-connect",title:"stops offering once connected",async run(r,t){await h(this.id,r,t,async e=>{e.start(),await ne(e);let n=e.offers.length;e.advance(ie*5,1e3),e.offers.length!==n&&e.fail(`${e.offers.length-n} offer(s) after the session connected.`);});}},{id:"lifecycle.duplicate-accept-keeps-session",title:"keeps the session when a second accept arrives, even an out-of-range one",async run(r,t){await h(this.id,r,t,async e=>{e.start(),await ne(e);let n=e.parent.protocolVersion;e.answer(e.latest(),W(e).max+1),await e.flush(),(e.state()!=="connected"||e.parent.protocolVersion!==n)&&e.fail(`a second accept moved the parent to '${e.state()}' at v${String(e.parent.protocolVersion)}. One answer settles the handshake.`);});}},{id:"lifecycle.close-releases-everything",title:"on close, releases every port and timer and offers nothing more",async run(r,t){await h(this.id,r,t,e=>{e.start(),e.advance(T),e.parent.close(),e.state()!=="closed"&&e.fail(`after close() the parent reports '${e.state()}'`);let n=e.minted.filter(a=>!a.closed).length;n>0&&e.fail(`${n} offer port(s) left open after close().`),e.clock.pendingTimers>0&&e.fail(`${e.clock.pendingTimers} timer(s) still armed after close().`);let o=e.offers.length;e.advance(ie*2,1e3),e.offers.length!==o&&e.fail("the parent offered again after close().");}),await h(this.id,r,t,async e=>{e.start(),await ne(e),e.parent.close(),e.state()!=="closed"&&e.fail(`after close() the parent reports '${e.state()}'`),e.minted.filter(o=>!o.closed).length>0&&e.fail("the session port is still open after close().");});}},{id:"lifecycle.unanswered-offers-are-bounded",title:"holds at most about a minute of unanswered offer ports, however long it runs",async run(r,t){await h(this.id,r,t,e=>{e.start(),e.advance(ie*10,1e3);let n=e.minted.filter(o=>!o.closed).length;n>Ie+1&&e.fail(`${n} unanswered offer ports open after ten minutes. Close offers nothing answered within a grace (a minute is the reference), or the loop leaks a channel per tick for as long as the page holds the frame.`);});}},{id:"capability.unadvertised-is-refused",title:"refuses an arcade-feature or store ask under a capability either side did not advertise, answering nothing and showing nothing",async run(r,t){for(let e of E)await h(this.id,r,t,async n=>{n.start();let o=n.advertised().includes(e),a=E.filter(x=>!o||x!==e),d=await n.raw(a),s=n.parent.surfacesShown,{type:c,fields:y}=Ce[e],v=await d.ask(c,y,"pressed"),b=o?"the frame":"the parent";d.answers(v).length>0&&n.fail(`${c} under '${e}', which ${b} did not advertise, was answered. Refuse it before anything else and send nothing back.`),n.parent.surfacesShown!==s&&n.fail(`${c} under unadvertised '${e}' showed a surface.`),n.errors.some(x=>x.code==="unsupported_capability")||n.fail(`${c} under '${e}', which ${b} did not advertise, was not reported as 'unsupported_capability'. Report it through \`fixture.reportError\` (what GemHost calls onError).`);});}},{id:"acting.refuses-without-activation",title:"answers an ask to leave the game (open app, open game) with no press \u2014 or no activation API \u2014 declined / busy, showing nothing",async run(r,t){for(let e of mr)for(let n of ["unpressed","missing"])await h(this.id,r,t,async o=>{if(o.start(),!o.advertised().includes(e))return;let a=await o.raw(E),d=o.surfaces(`the parent advertises '${e}'`),{type:s,fields:c}=Ce[e],y=await a.ask(s,c,n);ce(o,a,y,d,n==="missing"?`${s} with no userActivation API (it must fail closed)`:`${s} with no press`);});}},{id:"store.unknown-sku-is-unavailable",title:"answers a store purchase of a SKU it does not list unavailable, showing nothing",async run(r,t){await h(this.id,r,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let n=await e.raw(E),o=e.surfaces("the parent advertises `store`"),a=await n.ask("gem.requestStorePurchase",{skuId:pe},"pressed"),d=n.answers(a);(d.length!==1||d[0].outcome!=="unavailable")&&e.fail(`a pressed purchase of an unknown SKU was answered ${JSON.stringify(d)}; it owes exactly one 'unavailable'.`),e.surfaces("the parent advertises `store`")!==o&&e.fail("a purchase of an unknown SKU showed a surface; it must show nothing.");});}},{id:"acting.second-ask-is-busy",title:"answers any acting ask declined / busy, showing nothing, while a store checkout is open",async run(r,t){await h(this.id,r,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let n=await e.raw(E),o=await B(e,n),a=await n.ask("gem.requestStorePurchase",{skuId:o.skuId},"pressed");ce(e,n,a,o.shown,"a second store purchase while one is open");for(let s of ["appLinks","openGame","storeOfferSheet"]){if(!e.advertised().includes(s))continue;let{type:c,fields:y}=Ce[s],v=await n.ask(c,y,"pressed");ce(e,n,v,o.shown,`${c} while a store checkout is open`);}re(e),await e.flush();let[d]=n.answers(o.requestId);(d?.outcome!=="declined"||d.reason!=="cancelled")&&e.fail(`the closed checkout was answered ${JSON.stringify(d?.outcome)} / ${JSON.stringify(d?.reason)}, not 'declined' / 'cancelled'.`);});}},{id:"store.no-press-needed",title:"opens a store checkout, or an offer sheet, for an ask with no press or no activation API",async run(r,t){for(let[e,n]of pr)for(let o of ["unpressed","missing"])await h(this.id,r,t,async a=>{if(a.start(),!a.advertised().includes(e))return;let d=await a.raw(E),s=await B(a,d,n,o);re(a),await a.flush();let[c]=d.answers(s.requestId);(c?.outcome!=="declined"||c.reason!=="cancelled")&&a.fail(`the closed ${n} asked with no press was answered ${JSON.stringify(c?.outcome)} / ${JSON.stringify(c?.reason)}, not 'declined' / 'cancelled'.`);});}},{id:"store.no-back-off",title:"opens the checkout again for the next store purchase, however many times the player closed one",async run(r,t){await h(this.id,r,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let n=await e.raw(E);for(let o=1;o<=5;o+=1){let a=await B(e,n,"gem.requestStorePurchase","pressed",o===1?"":`straight after the player dismissed one (round ${o}), `);re(e),await e.flush();let[d]=n.answers(a.requestId);(d?.outcome!=="declined"||d.reason!=="cancelled")&&e.fail(`closed checkout ${o} was answered ${JSON.stringify(d?.outcome)} / ${JSON.stringify(d?.reason)}, not 'declined' / 'cancelled'.`);}e.advertised().includes("storeOfferSheet")&&await B(e,n,"gem.requestStoreOfferSheet","pressed","straight after the player dismissed a checkout, ");});}},{id:"sheet.needs-store",title:"advertises storeOfferSheet only beside store",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=e.advertised();n.includes("storeOfferSheet")&&!n.includes("store")&&e.fail("the parent advertises `storeOfferSheet` without `store`. A game takes its SKU from gem.storeOffersResult and hears a pending purchase settle through gem.storePurchaseSettled, and both are gated on `store`.");});}},{id:"settled.needs-purchases",title:"advertises purchaseSettled only beside purchases",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=e.advertised();n.includes("purchaseSettled")&&!n.includes("purchases")&&e.fail("the parent advertises `purchaseSettled` without `purchases`. gem.purchaseSettled reports a purchase the game asked for through gem.requestPurchase, which is gated on `purchases`.");});}},{id:"share.extras-need-share",title:"advertises shareResult and shareRemap only beside share",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=e.advertised();if(!n.includes("share"))for(let o of ["shareResult","shareRemap"])n.includes(o)&&e.fail(`the parent advertises \`${o}\` without \`share\`. Both describe what the parent does with gem.requestShare, which is gated on \`share\`.`);});}},{id:"share.refusal-is-answered",title:"answers a share naming embedder refused / reserved_key, naming the key, when it advertises shareResult",async run(r,t){await h(this.id,r,t,async e=>{e.start();let n=e.advertised();if(!n.includes("share")||!n.includes("shareResult"))return;let o=await e.raw(["share","shareResult"]),a=e.parent.surfacesShown,d=await o.ask("gem.requestShare",{params:[{key:"embedder",value:"x"}]},"pressed"),s=o.answers(d);s.length!==1&&e.fail(`a share naming \`embedder\` was answered ${s.length} times; a parent that advertises \`shareResult\` owes exactly one gem.shareResult for a request carrying a requestId.`);let[c]=s;(c.type!=="gem.shareResult"||c.outcome!=="refused"||c.reason!=="reserved_key"||c.key!=="embedder")&&e.fail(`a share naming \`embedder\` was answered ${JSON.stringify(c)}; it owes gem.shareResult 'refused' / 'reserved_key' with key 'embedder'. No parent carries embedder in a share link, remapping or not.`),typeof a=="number"&&e.parent.surfacesShown!==a&&e.fail("a refused share showed a surface; it must show nothing.");});}},{id:"sheet.unknown-sku-is-unavailable",title:"answers an offer sheet for a SKU it does not list unavailable, showing nothing",async run(r,t){await h(this.id,r,t,async e=>{if(e.start(),!e.advertised().includes("storeOfferSheet"))return;let n=await e.raw(E),o=e.surfaces("the parent advertises `storeOfferSheet`"),a=await n.ask("gem.requestStoreOfferSheet",{skuId:pe},"pressed"),d=n.answers(a);(d.length!==1||d[0].outcome!=="unavailable")&&e.fail(`a pressed offer sheet for an unknown SKU was answered ${JSON.stringify(d)}; it owes exactly one 'unavailable'.`),e.surfaces("the parent advertises `storeOfferSheet`")!==o&&e.fail("an offer sheet for an unknown SKU showed a surface; it must show nothing.");});}},{id:"sheet.shares-the-slot",title:"holds the acting slot while an offer sheet is open, and opens either store ask again once the player leaves it",async run(r,t){await h(this.id,r,t,async e=>{if(e.start(),!e.advertised().includes("storeOfferSheet"))return;let n=await e.raw(E),o=await B(e,n,"gem.requestStoreOfferSheet"),a=await n.ask("gem.requestStorePurchase",{skuId:o.skuId},"pressed");ce(e,n,a,o.shown,"a store purchase while an offer sheet is open"),re(e),await e.flush();let[d]=n.answers(o.requestId);(d?.outcome!=="declined"||d.reason!=="cancelled")&&e.fail(`the closed offer sheet was answered ${JSON.stringify(d?.outcome)} / ${JSON.stringify(d?.reason)}, not 'declined' / 'cancelled'.`);for(let s of ["gem.requestStoreOfferSheet","gem.requestStorePurchase"])await B(e,n,s,"pressed","straight after the player left a sheet, "),re(e),await e.flush();});}}],hr=Object.freeze(fr);async function Uw(r,t){if(!K(t.embedderOrigin))throw new Error(`runParentConformance: embedderOrigin must be one exact origin, got ${JSON.stringify(t.embedderOrigin)}`);let e=[];for(let n of hr)try{await n.run(r,t),e.push({id:n.id,title:n.title,ok:!0});}catch(o){e.push({id:n.id,title:n.title,ok:false,message:ct(o)});}return e}i(Uw,"runParentConformance");
|
|
3
|
-
export{
|
|
1
|
+
var yt=Object.defineProperty;var i=(n,t)=>yt(n,"name",{value:t,configurable:true});var u="gem-web-bridge",A={min:1,max:1},bt=65536,$e=8,le=5e3,De=1024,I=1e4,G=Object.create(null),de="__malformed";var Re=Object.create(null),vt=Object.freeze([["gem.asyncOpponents.","asyncOpponents"],["gem.vibration.","vibration"],["gem.viewport.","reservedAreas"],["gem.moments.","moments"],["gem.prefs.","audioChannels"],["gem.share.","shareRemap"]]);function ce(n){let t=Re[n];if(t!==void 0)return t;for(let[e,r]of vt)if(n.startsWith(e))return r}i(ce,"capabilityFor");function z(n){let t=/^([a-z][a-z0-9+.-]*):\/\/([a-z0-9.-]+|\[[0-9a-f:.]+\])(:([0-9]{1,5}))?$/i.exec(n);return t===null?false:t[4]===void 0||Number(t[4])<=65535}i(z,"isOrigin");function wt(n){let t;try{t=new URL(n);}catch{return false}return t.username!==""||t.password!==""?false:t.protocol==="https:"?true:t.protocol==="http:"&&(t.hostname==="localhost"||t.hostname==="127.0.0.1")}i(wt,"isSafeHttpUrl");function _t(n){return /^[a-z]{2,8}(-[a-z0-9]{1,8})*$/i.test(n)}i(_t,"isBcp47");function St(n){return /^[a-z_]+$/.test(n)}i(St,"isCode");function Rt(n){return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)||/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/.test(n)&&!n.includes("--")}i(Rt,"isGameRef");function _e(n,t,e){if(t>$e)return `nesting deeper than ${$e}`;if(++e.nodes>le)return `more than ${le} values`;if(e.bytes>e.cap)return `over the ${e.cap} byte limit`;if(n==null)return e.bytes+=4,null;let r=typeof n;if(r==="boolean")return e.bytes+=5,null;if(r==="number")return e.bytes+=8,null;if(r==="string")return e.bytes+=n.length*3+2,null;if(r!=="object")return `${r} is not plain data`;let o=n;if(e.seen.has(o))return "a repeated or cyclic object reference";if(e.seen.add(o),Array.isArray(n)){if(n.length>De)return `an array of ${n.length} entries, over the ${De} limit`;e.bytes+=2;for(let s of n){let c=_e(s,t+1,e);if(c)return c}return null}let a=Object.getPrototypeOf(n);if(a!==Object.prototype&&a!==null)return "a value that is not a plain object";e.bytes+=2;let l=n;for(let s in l){if(!Object.prototype.hasOwnProperty.call(l,s))continue;if(++e.nodes>le)return `more than ${le} values`;if(e.bytes+=s.length*3+4,e.bytes>e.cap)return `over the ${e.cap} byte limit`;let c=_e(l[s],t+1,e);if(c)return c}return null}i(_e,"walk");function kt(n,t=bt){let e={nodes:0,bytes:0,seen:new Set,cap:t},r=_e(n,0,e);return r?`message contains ${r}`:e.bytes>t?`message is over the ${t} byte limit`:null}i(kt,"validateSize");var At={origin:[z,"not a well-formed origin"],url:[wt,"not a safe absolute http(s) URL"],bcp47:[_t,"not a well-formed BCP 47 tag"],code:[St,"not a code of lower-case letters and underscores"],gameRef:[Rt,"not a game id or web address"]};function Fe(n,t,e){for(let r of t){let o=e===""?r[0]:`${e}.${r[0]}`,a=n[r[0]];if(a==null){if(r[1]<"a")continue;return `${o}: required`}let l=Se(a,r,o);if(l)return l}return null}i(Fe,"checkFields");function Se(n,t,e){let r=t[1].toLowerCase();switch(r){case "u":return typeof n=="boolean"?null:Se(n,typeof n=="string"?[t[0],"s",t[2]]:[t[0],"n",t[3],t[4]],e);case "s":{if(typeof n!="string")return `${e}: expected string`;if(n.length>t[2])return `${e}: exceeds ${t[2]} characters`;if(t[3]){let[o,a]=At[t[3]];if(!o(n))return `${e}: ${a}`}return null}case "n":case "i":return typeof n!="number"||!(r=="i"?Number.isInteger:Number.isFinite)(n)?`${e}: expected ${r=="i"?"integer":"number"}`:n<t[2]||n>t[3]?`${e}: out of range ${t[2]}..${t[3]}`:null;case "b":return typeof n=="boolean"?null:`${e}: expected boolean`;case "e":{let o=t[2];return o.includes(n)?null:`${e}: not one of ${o.join("|")}`}case "o":return typeof n!="object"||n===null||Array.isArray(n)?`${e}: expected object`:Fe(n,t[2],e);case "j":return typeof n!="object"||n===null||Array.isArray(n)?`${e}: expected a plain object`:null;case "a":{if(!Array.isArray(n))return `${e}: expected array`;if(n.length>t[2])return `${e}: exceeds ${t[2]} items`;let o=t[3],a=`${e}[]`;for(let l of n){if(l==null){if(o[1]<"a")continue;return `${a}: required`}let s=Se(l,o,a);if(s)return s}return null}default:return `${e}: unknown kind ${String(r)}`}}i(Se,"checkValue");var qe=Object.create(null);function d(n,t,e,r,o){return G[n]=e,r&&(Re[n]=r),qe[n]=a=>{let l=kt(a,o);if(l)return l;if(typeof a!="object"||a===null||Array.isArray(a))return "message: expected object";let s=a;return s.gem!==u?"gem: wrong protocol marker":s.type!==n?`type: expected ${n}`:Fe(s,t,"")}}i(d,"makeValidator");var X=["","s",64],m=["requestId","s",64],Y=["matchId","s",64],P=["reason","S",64,"code"],T=["outcome","e",["ok","declined","unavailable"]];d("gem.handshake",[["versions","o",[["min","i",1,1e3],["max","i",1,1e3]]],["capabilities","A",64,X],["embedder","s",2048,"origin"],["unbidden","B"]],30);d("gem.handshake.accept",[["v","i",1,1e3],["capabilities","A",64,X]],5);d("gem.token",[["token","s",4096],["requestId","S",64],["generation","i",0,2147483647],["apiBaseUrl","S",512,"url"],["playerId","s",64],["gameId","s",64],["channel","e",["dev","test","release"]],["gameVersion","S",64],["expiresAt","i",0,4102444800],["chainEndsAt","i",0,4102444800],["allowDevTools","B"]],30);d("gem.token.denied",[m,["retryable","b"],["retryAfterMs","I",0,36e5],["reason","e",["chain_exhausted","unavailable"]],["correlationId","s",64]],30);d("gem.player",[["untrusted","o",[["displayName","s",64],["displayTag","S",80],["displayHandle","s",80]]],["playerId","S",64],["discriminator","S",8],["avatarIconUrl","S",2048,"url"],["avatarIconId","S",64],["avatar3dId","S",64],["avatar3dModelUrl","S",2048,"url"],["avatar3dIconUrl","S",2048,"url"],["avatars3d","A",8,["","o",[["family","s",32],["id","s",64],["modelUrl","s",256,"url"],["iconUrl","s",256,"url"]]]],["badges","A",2,["","o",[["itemId","s",64],["iconUrl","s",2048,"url"]]]],["displayTag","s",8],["avatarUrl","S",2048,"url"],["boost","O",[["multipliers","a",8,["","o",[["currencyId","s",64],["currencySlug","s",32],["multiplierBp","i",1e4,1e6]]]],["expiresInDays","I",1,7]]]],12);d("gem.pause",[["paused","b"]],120);d("gem.prefs",[["reducedMotion","b"],["muted","b"],["showFrameStats","B"],["music","B"],["sounds","B"],["locale","s",35,"bcp47"],["recommended","O",[["volume","i",0,100],["batterySaver","b"],["keyboardLayout","e",["wasd","arrows"]],["gamepadConfirm","e",["south","east"]],["vibration","b"],["lookSensitivity","I",20,400],["gamepadLookSensitivity","I",20,400],["invertLookY","B"],["touchMovement","S",16,"code"],["graphicsQuality","S",16,"code"],["graphicsQualityAuto","B"],["colorHelp","B"]]]],60);d("gem.cohorts",[["cohorts","a",8,["","o",[["experimentId","s",36],["variantKey","s",32]]]]],12,"cohorts");d("gem.earnAllowanceChanged",[],30,"earnAllowance");d("gem.inventoryChanged",[],30,"inventoryChanged");d("gem.viewport",[["insets","o",[["top","i",0,4096],["right","i",0,4096],["bottom","i",0,4096],["left","i",0,4096]]],["reserved","A",4,["","o",[["x","i",0,16384],["y","i",0,16384],["width","i",0,16384],["height","i",0,16384],["control","O",[["x","i",0,16384],["y","i",0,16384],["width","i",0,16384],["height","i",0,16384]]]]]]],60,"viewport");d("gem.deviceSettings",[["settings","J"]],12,"deviceSettings");d("gem.willTerminate",[["reason","e",["grant_expiring","session_ended","navigating","kill_switch"]],["graceMs","i",0,6e4]],10);d("gem.roomEvent",[["event","e",["updated","match_started","match_ready","match_failed","version_stale"]],["roomId","s",64],["matchId","S",64],["version","I",0,2147483647],["reason","S",64],["platform","E",["universal","mobile"]]],120,"rooms");d("gem.socketState",[["connected","b"],["reason","E",["connecting","dropped","watchdog","terminal"]]],12,"socketState");d("gem.seatedEvent",[["roomId","s",64]],60,"partySeating");d("gem.autoStartFailedEvent",[["roomId","s",64],["code","s",64]],30,"autoStartFailure");d("gem.ticketEvent",[["event","e",["queued","matched","expired","cancelled","failed"]],["ticketId","s",64],["partySize","I",1,64],["queuedAt","I",0,4102444800],["expiresAt","I",0,4102444800],["reason","S",64],["roomId","S",64]],60,"ticketEvents");d("gem.signalEvent",[["event","e",["hello","offer","answer","ice","peerJoined","peerLeft","migration","matchEnded","error"]],Y,["data","j"]],1800,"p2p");d("gem.relayDraining",[Y,["clusterTargetId","s",64],["relayIps","a",16,X],["drainingSince","s",40],["deadline","s",40]],60,"p2pRelayDrain");d("gem.dedicatedEvent",[["event","e",["answer","error","matchEnded"]],Y,["sdp","S",10240],["sessionId","S",64],["code","S",64],["message","S",256],["reason","S",64]],120,"dedicated");d("gem.partyResult",[m,["partyId","S",64]],30,"parties");d("gem.clusterTarget",[["clusterTargetId","s",64],["clusterTargetIds","A",3,X]],12,"clusterTarget");d("gem.graphicsRoutes",[["entries","a",32,["","o",[["gpu","s",32],["route","S",32],["host","S",32]]]]],12,"graphicsRoutes");d("gem.devtools",[["action","e",["open","close","toggle"]]],30,"devtools");d("gem.screenshot",[["maxWidth","i",1,7680],["maxHeight","i",1,4320]],6,"screenshot");d("gem.screenshot.denied",[["reason","e",["not_wired","no_source","unsupported","unreadable","tainted","too_large","busy","declined","failed"]],["retryable","b"]],12,"screenshot");d("gem.requestContext",[],12,"feedbackContext");d("gem.gameContext",[["context","j"]],12,"feedbackContext");d("gem.signal",[["signal","e",["join","offer","answer","ice","migrationAck","hostUnreachable"]],Y,["data","j"]],1200,"p2p");d("gem.dedicatedOffer",[Y,["sdp","s",10240],["intent","e",["initial","ice_restart","full_reconnect"]]],60,"dedicated");d("gem.partyRequest",[m],12,"parties");d("gem.ready",[],5);d("gem.engaged",[],5,"engagement");d("gem.progress",[["loaded","i",0,1099511627776],["total","i",0,1099511627776]],600);d("gem.requestToken",[m,["reason","e",["initial","expiring","rejected"]]],12);d("gem.requestLocalServer",[m,["gameRoomId","s",64]],6,"localHost");d("gem.localServer",[m,["serverId","S",128]],30,"localHost");d("gem.localServer.denied",[m,["retryable","b"],["reason","e",["refused","unavailable"]]],30,"localHost");d("gem.exit",[["reason","S",64]],5);d("gem.openExternal",[["url","s",2048,"url"]],6);d("gem.requestFullscreen",[["enabled","b"]],30);d("gem.audioState",[["muted","b"]],120,"audioState");d("gem.rewardCue",[["currencySlug","s",32],["cueId","S",64],["expected","I",1,1e9],["origin","O",[["x","i",0,16384],["y","i",0,16384]]]],60,"rewardCue");d("gem.rewardPresentation",[["mode","e",["arcade","game"]]],12,"rewardPresentation");d("gem.walletDisplay",[["visible","b"],["currencies","A",8,X],["score","B"]],60,"walletDisplay");d("gem.controlsDeclare",[["uses","o",[["lookSensitivity","S",16,"code"],["gamepadLookSensitivity","S",16,"code"],["invertLookY","S",16,"code"],["touchMovement","S",16,"code"]]]],60,"controls");d("gem.menu",[["settings","b"],["items","A",4,["","o",[["id","s",32],["label","s",40]]]]],60,"gameMenu");d("gem.menuSelect",[["entry","e",["settings","item"]],["id","S",32]],60,"gameMenu");d("gem.gemCorner",[["corner","e",["top-left","top-right","bottom-left","bottom-right"]]],12,"gemCorner");d("gem.menuStyle",[["ground","S",7],["accent","S",7]],12,"menuStyle");d("gem.settingsDeclare",[["settings","a",8,["","o",[["id","s",40],["label","s",40],["kind","e",["toggle","slider","choice"]],["value","u",40,-1e6,1e6],["quick","B"],["icon","S",16,"code"],["min","N",-1e6,1e6],["max","N",-1e6,1e6],["step","N",0,1e6],["options","A",4,["","o",[["id","s",40],["label","s",40]]]]]]]],120,"gameSettings");d("gem.settingChange",[["id","s",40],["value","u",40,-1e6,1e6]],120,"gameSettings");d("gem.requestShare",[["requestId","S",64],["params","a",16,["","o",[["key","s",64],["value","s",512]]]]],6,"share");d("gem.shareResult",[m,["outcome","e",["accepted","refused"]],P,["key","S",64]],30,"shareResult");d("gem.requestAvatarPicker",[["tab","E",["2d","3d"]]],6,"avatarPicker");d("gem.vibrate",[["pattern","a",99,["","i",0,1e4]]],600,"vibration");d("gem.frameStats",[["fps","i",0,1e3],["frameTimeP95Ms","i",0,1e5],["counts","E",["pageFrames","gameDraws"]]],120,"frameStats");d("gem.portraitBorders",[["name","S",40]],60,"portraitBorders");d("gem.error",[["code","e",["version_mismatch","handshake_timeout","handshake_duplicate","invalid_message","rate_limited","token_unavailable","unsupported","unsupported_capability","internal"]],["message","S",256]],60);d("gem.requestPurchase",[m,["purchaseKind","e",["item","recipe"]],["targetId","s",64],["currencySlug","s",32],["quantity","I",1,10],["catalogId","S",64],["origin","E",["sheet","direct_refused"]]],12,"purchases");d("gem.requestAvatar3dPurchase",[m,["itemId","s",64],["currencySlug","s",32]],12,"avatar3dPurchases");d("gem.purchaseResult",[m,T,P,["purchaseId","S",64]],30,"purchases");d("gem.purchaseSettled",[["purchaseKind","e",["item","recipe"]],["targetId","s",64],["catalogId","S",64],["quantity","i",1,10],["purchaseId","S",64]],30,"purchaseSettled");d("gem.deviceSettings.put",[m,["settings","j"]],30,"deviceSettings");d("gem.deviceSettings.result",[m,["outcome","e",["stored","too_large","unavailable"]]],30,"deviceSettings");d("gem.requestAd",[m,["placement","s",32],["format","e",["interstitial","rewarded"]]],6,"ads");d("gem.adResult",[m,["outcome","e",["shown","no_ad","unavailable"]]],12,"ads");d("gem.signalMoment",[m,["kind","e",["level_end","run_end","match_end","menu_return","other_break"]],["placement","S",32],["wall","B"]],6,"moments");d("gem.momentResult",[m,["shown","b"]],12,"moments");d("gem.requestSignIn",[m],6,"signIn");d("gem.signInResult",[m,["outcome","e",["signed_in","declined","unavailable"]]],12,"signIn");d("gem.requestFriendChallenge",[m,["playerId","s",64],["template","s",64],["params","J"]],12,"friendChallenges");d("gem.friendChallengeResult",[m,["outcome","e",["accepted","cancelled","refused","unavailable","rate_limited","invalid"]],["code","S",64],["param","S",64],["channel","S",16],["configVersion","I",0,9007199254740991],["retryAfterMs","I",0,864e5],["detail","S",300]],30,"friendChallenges");d("gem.requestPlayInvite",[m,["params","A",16,["","o",[["key","s",64],["value","s",512]]]]],6,"playInvites");d("gem.playInviteResult",[m,["shown","b"]],12,"playInvites");d("gem.inviteParams",[["params","A",16,["","o",[["key","s",64],["value","s",512]]]]],30,"playInvites");d("gem.requestAppLinks",[m],12,"appLinks");d("gem.appLinksResult",[m,T,P,["arcade","O",[["store","e",["app_store","google_play"]]]],["game","O",[["store","e",["app_store","google_play"]]]]],30,"appLinks");d("gem.requestOpenApp",[m,["target","e",["arcade","game"]]],6,"appLinks");d("gem.openAppResult",[m,T,P],30,"appLinks");d("gem.requestOpenGame",[m,["ref","s",40,"gameRef"]],6,"openGame");d("gem.openGameResult",[m,T,P],30,"openGame");d("gem.requestSimilarGames",[m,["limit","I",1,24]],12,"openGame");d("gem.similarGamesResult",[m,T,P,["games","a",24,["","o",[["gameId","s",36,"gameRef"],["slug","S",40,"gameRef"],["iconUrl","s",1024,"url"],["capsuleLandscapeUrl","s",1024,"url"],["capsulePortraitUrl","s",1024,"url"],["previewVideoUrl","S",1024,"url"],["previewPosterUrl","S",1024,"url"],["untrusted","o",[["name","s",64],["tagline","s",64],["shortDescription","s",320],["tags","a",10,["","s",32]]]]]]]],30,"openGame",524288);d("gem.requestStoreOffers",[m],12,"store");d("gem.storeOffersResult",[m,T,P,["offers","a",32,["","o",[["skuId","s",64],["kind","e",["gem_pack","boost","pass","bundle"]],["name","s",80],["description","s",400],["imageUrl","S",1024,"url"],["priceDisplay","s",32],["grant","O",[["currency","s",32],["amount","i",1,1e9]]]]]]],30,"store",262144);d("gem.requestStorePurchase",[m,["skuId","s",64]],12,"store");d("gem.storePurchaseResult",[m,T,P],30,"store");d("gem.storePurchaseSettled",[["skuId","s",64]],30,"store");d("gem.requestStoreOfferSheet",[m,["skuId","s",64]],12,"storeOfferSheet");d("gem.storeOfferSheetResult",[m,T,P],30,"storeOfferSheet");var L=Object.freeze(qe);G.__malformed=60;Object.freeze(G);Object.freeze(Re);var Pt=/^[a-z0-9][a-z0-9_-]{0,39}$/;function Et(n){return typeof n=="string"&&Pt.test(n)}i(Et,"isBorderName");function ke(n){if(n===null||Et(n))return n;let t=typeof n=="string"?JSON.stringify(n.length>48?`${n.slice(0,48)}\u2026`:n):`a value of type ${typeof n}`;console.warn(`[gem] showPortraitBorders: ${t} is not a border name, so nothing was sent. A name is 1 to 40 of a-z, 0-9, _ and -, starting with a letter or digit, exactly as your store page declares it under media.portrait_borders. Pass null for no art.`);}i(ke,"checkBorderName");function Ne(n){return typeof n=="string"&&/^[\w-]{1,64}$/.test(n)}i(Ne,"isCueId");var C={now:i(()=>Date.now(),"now"),setTimeout:i((n,t)=>setTimeout(n,t),"setTimeout"),clearTimeout:i(n=>clearTimeout(n),"clearTimeout")},Q=class{constructor(t=C){this.clock=t;}clock;static{i(this,"RateLimiter");}tokens=new Map;lastRefill=new Map;allow(t){let e=G[t];if(e===void 0)return false;let r=this.clock.now(),o=this.lastRefill.get(t)??r,a=this.tokens.get(t)??e,l=Math.max(0,r-o),s=Math.min(e,a+l*e/6e4);return s<1?(this.tokens.set(t,s),this.lastRefill.set(t,r),false):(this.tokens.set(t,s-1),this.lastRefill.set(t,r),true)}};function Z(n,t){return n.toLowerCase()===t.toLowerCase()}i(Z,"originsEqual");function F(n){let t=n.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="[::1]"||t==="::1"?true:/^127(\.\d{1,3}){3}$/.test(t)}i(F,"isLoopbackHostname");function Ae(n,t){if(typeof t!="string"||t==="")return false;let e,r;try{e=new URL(n),r=new URL(t);}catch{return false}return e.protocol!=="http:"&&e.protocol!=="https:"||r.protocol!=="http:"&&r.protocol!=="https:"||e.username!==""||e.password!==""||e.pathname!=="/"||e.search!==""||e.hash!==""||e.port===""?false:F(e.hostname)&&F(r.hostname)}i(Ae,"isLoopbackDevHostEmbedder");function je(n,t){if(n.min>n.max||t.min>t.max)return null;let e=Math.min(n.max,t.max),r=Math.max(n.min,t.min);return e>=r?e:null}i(je,"negotiateVersion");var We="[gem: use gem.text.toPlain()]",Ue=new Set,Be;function It(n){try{if(Ue.has(n))return;let t=globalThis.location;if(Be??=!!t?.port&&F(t.hostname??""),!Be)return;Ue.add(n),console.warn(`[gem] ${n} is PlayerText, turned into a string: players see ${We}. Render text.toPlain(value) (text is in @indiegems/gem-web-sdk/sdk).
|
|
2
|
+
${new Error().stack}`);}catch{}}i(It,"warnStringified");var ue=class{static{i(this,"PlayerText");}#e;#t;constructor(t,e="player text"){this.#e=t,this.#t=e,Object.freeze(this);}toString(){return It(this.#t),We}toJSON(){return this.toString()}get[Symbol.toStringTag](){return "PlayerText"}static unwrap(t){return t.#e}};function $(n,t){return new ue(n,t)}i($,"asPlayerText");function He(n){return Math.min(16384,Math.max(0,Math.round(Number.isFinite(n)?n:0)))}i(He,"cuePoint");function Je(n,t){if(n!==true)return {visible:false};let e=[],r=false;for(let o of Array.isArray(t)?t:[])o==="score"?r=true:typeof o=="string"&&o.length>0&&o.length<=64&&!e.includes(o)&&e.push(o);return !r&&e.length===0?{visible:true}:{visible:true,currencies:e.slice(0,8),score:r}}i(Je,"walletState");function ze(n){let t=[];for(let e of Array.isArray(n)?n:[]){if(t.length===4)break;if(typeof e!="object"||e===null)continue;let{id:r,label:o}=e;typeof r!="string"||r.length===0||r.length>32||typeof o!="string"||o.trim().length===0||t.some(a=>a.id===r)||t.push({id:r,label:o.trim().slice(0,40)});}return t.length===0?{settings:false}:{settings:false,items:t}}i(ze,"menuState");function Ve(n,t){return Math.min(t,Math.max(0,Math.round(Number.isFinite(n)?n:0)))}i(Ve,"clampStat");function Tt(n){let t=n.untrusted,e=$(t.displayName,"gem.player.displayName"),r=t.displayTag||t.displayHandle,o=r?$(r,"gem.player.displayTag"):void 0,a=n.discriminator||n.displayTag,l=a&&/^[0-9]{1,8}$/.test(a)?a:void 0,s=n.avatarIconUrl||n.avatarUrl,c=/^[\da-f]{8}(-[\da-f]{4}){3}-[\da-f]{12}$/i,y=n.avatarIconId,b=n.avatar3dId,v={displayName:e,displayHandle:o??e,badges:(n.badges??[]).map(w=>({itemId:w.itemId,iconUrl:w.iconUrl}))};n.playerId&&(v.playerId=n.playerId),l&&(v.discriminator=l),o&&(v.displayTag=o),s&&(v.avatarIconUrl=v.avatarUrl=s),y&&c.test(y)&&(v.avatarIconId=y),b&&c.test(b)&&(v.avatar3dId=b),n.avatar3dModelUrl&&(v.avatar3dModelUrl=n.avatar3dModelUrl),n.avatar3dIconUrl&&(v.avatar3dIconUrl=n.avatar3dIconUrl),n.avatars3d&&(v.avatars3d=n.avatars3d.filter(w=>c.test(w.id)&&/^[a-z][a-z0-9_]*$/.test(w.family)).filter((w,be,ve)=>ve.findIndex(we=>we.family==w.family)==be).map(({family:w,id:be,modelUrl:ve,iconUrl:we})=>({family:w,id:be,modelUrl:ve,iconUrl:we})));let x=n.boost,J=(x?.multipliers??[]).map(w=>({currencyId:w.currencyId,currencySlug:w.currencySlug,multiplier:w.multiplierBp/1e4})),ye=J.some(w=>w.multiplier>1);return v.boost=ye&&x?.expiresInDays?{active:ye,multipliers:J,expiresInDays:x.expiresInDays}:{active:ye,multipliers:J},v}i(Tt,"playerFromWire");var Ct=1e4,Ot=["appLinks","openGame","store","storeOfferSheet"],Mt=["token","pause","menuSelect","settingChange","prefs","cohorts","viewport","willTerminate","localServer","roomEvent","seatedEvent","autoStartFailedEvent","ticketEvent","socketState","signalEvent","relayDraining","dedicatedEvent","clusterTarget","graphicsRoutes","partyResult","purchaseResult","purchaseSettled","inventoryChanged","shareResult","deviceSettings","adResult","momentResult","signInResult","friendChallengeResult","playInviteResult"],Gt=new WeakMap;var q=class{constructor(t){this.options=t;if(t.expectedSource===void 0||t.expectedSource===null)throw new Error("GemFrame: expectedSource is required and must not be null \u2014 pass window.parent. The handshake transfers the MessagePort, and origin alone does not say WHICH document on that origin sent it.");this.expectedSource=t.expectedSource,this.clock=t.clock??C,this.inbound=new Q(this.clock),this.outbound=new Q(this.clock);}options;static{i(this,"GemFrame");}state="waiting";port=null;version=null;peerCapabilities=[];unbidden=false;engagedSent=false;readyPending=false;readySent=false;settleWaiters=[];clock;inbound;outbound;expectedSource;get currentState(){return this.state}get parentCapabilities(){return this.peerCapabilities}parentSupports(t){return this.peerCapabilities.includes(t)}get protocolVersion(){return this.version}get unbiddenLaunch(){return this.unbidden}handleWindowMessage(t){if(t.source!==this.expectedSource)return this.refuse(t,"handshake did not come from the expected embedder window"),false;if(!(this.options.allowedEmbedders.some(s=>Z(s,t.origin))||Ae(t.origin,this.options.selfOrigin)||(Gt.get(this)??[]).some(s=>Z(s,t.origin))))return this.refuse(t,`embedder '${t.origin}' is not in allowedEmbedders`),this.state==="waiting"&&this.transition("refused"),false;if(this.state==="connected")return this.fail("handshake_duplicate","this document already has a port"),false;if(this.state!=="waiting")return false;let r=L["gem.handshake"]?.(t.data);if(r)return this.refuse(t,`malformed handshake: ${r}`),false;let o=t.data;if(!Z(o.embedder,t.origin))return this.refuse(t,`handshake claims embedder '${o.embedder}' but arrived from '${t.origin}'`),false;let a=t.ports?.[0];if(!a)return this.refuse(t,"handshake transferred no MessagePort"),false;let l=je(A,o.versions);return l===null?(a.onmessage=null,a.postMessage({gem:u,type:"gem.error",code:"version_mismatch",message:`frame supports v${A.min}..v${A.max}`}),a.close(),this.transition("refused"),this.options.onError?.("version_mismatch"),false):(this.port=a,this.version=l,a.onmessage=s=>this.receive(s.data,s.ports??[]),a.start?.(),this.peerCapabilities=o.capabilities??[],this.unbidden=o.unbidden===true,a.postMessage({gem:u,type:"gem.handshake.accept",v:l,...this.options.capabilities===void 0?{}:{capabilities:[...this.options.capabilities]}}),this.transition("connected"),this.readyPending&&(this.readyPending=false,this.ready()),true)}ready(){if(this.state!=="connected"||!this.port){this.readyPending=true;return}if(this.readySent){this.options.onDropped?.("internal","gem.ready was already sent; duplicate suppressed");return}this.readySent=true,this.send({gem:u,type:"gem.ready"});}settled(t=Ct){return this.state!=="waiting"?Promise.resolve(this.state):new Promise(e=>{let r=i(a=>{this.clock.clearTimeout(o),e(a);},"waiter"),o=this.clock.setTimeout(()=>{let a=this.settleWaiters.indexOf(r);a>=0&&this.settleWaiters.splice(a,1),e(this.state);},t);this.settleWaiters.push(r);})}progress(t,e){this.send({gem:u,type:"gem.progress",loaded:t,total:e});}requestToken(t,e){this.send({gem:u,type:"gem.requestToken",requestId:t,reason:e});}requestLocalServer(t,e){return this.parentSupports("localHost")?(this.send({gem:u,type:"gem.requestLocalServer",requestId:t,gameRoomId:e}),true):false}exit(t){this.send(t===void 0?{gem:u,type:"gem.exit"}:{gem:u,type:"gem.exit",reason:t});}openExternal(t){this.send({gem:u,type:"gem.openExternal",url:t});}requestFullscreen(t){this.send({gem:u,type:"gem.requestFullscreen",enabled:t});}reportMuted(t){return this.gated("audioState")?(this.send({gem:u,type:"gem.audioState",muted:t}),true):false}reportEngaged(){return this.engagedSent||!this.gated("engagement")||!this.send({gem:u,type:"gem.engaged"})?false:(this.engagedSent=true,true)}cueReward(t){if(!this.gated("rewardCue"))return false;let e={gem:u,type:"gem.rewardCue",currencySlug:String(t.currencySlug).slice(0,32)};return Ne(t.cueId)&&(e.cueId=t.cueId),t.expected!==void 0&&Number.isFinite(t.expected)&&t.expected>=1&&(e.expected=Math.min(1e9,Math.round(t.expected))),t.origin&&(e.origin={x:He(t.origin.x),y:He(t.origin.y)}),this.send(e),true}showPortraitBorders(t){let e=ke(t);return e===void 0||!this.gated("portraitBorders")?false:this.send(e===null?{gem:u,type:"gem.portraitBorders"}:{gem:u,type:"gem.portraitBorders",name:e})}setWalletVisible(t,e){return this.gated("walletDisplay")?this.send({gem:u,type:"gem.walletDisplay",...Je(t,e?.only)}):false}setMenu(t){return this.gated("gameMenu")?this.send({gem:u,type:"gem.menu",...ze(t)}):false}declareSettings(t){return this.gated("gameSettings")?this.send({gem:u,type:"gem.settingsDeclare",settings:t}):false}setGemCorner(t){return this.gated("gemCorner")?this.send({gem:u,type:"gem.gemCorner",corner:t}):false}setRewardPresentation(t){return this.gated("rewardPresentation")?this.send({gem:u,type:"gem.rewardPresentation",mode:t}):false}setMenuStyle(t){return this.gated("menuStyle")?this.send(t===null?{gem:u,type:"gem.menuStyle"}:{gem:u,type:"gem.menuStyle",ground:t.ground,accent:t.accent}):false}requestShare(t,e){return this.gated("share")?this.send({gem:u,type:"gem.requestShare",...e===void 0?{}:{requestId:e},params:t.map(({key:r,value:o})=>({key:r,value:o}))}):false}requestAvatarPicker(t){return this.gated("avatarPicker")?this.send({gem:u,type:"gem.requestAvatarPicker",...t==="2d"||t==="3d"?{tab:t}:{}}):false}requestVibrate(t){return this.gated("vibration")?this.send({gem:u,type:"gem.vibrate",pattern:[...t]}):false}reportFrameStats(t){return this.gated("frameStats")?(this.send({gem:u,type:"gem.frameStats",fps:Ve(t.fps,1e3),frameTimeP95Ms:Ve(t.frameTimeP95Ms,1e5),counts:t.counts==="gameDraws"?"gameDraws":"pageFrames"}),true):false}sendGameContext(t){return this.state!=="connected"?false:(this.send({gem:u,type:"gem.gameContext",context:t}),true)}signal(t,e,r){this.send({gem:u,type:"gem.signal",signal:t,matchId:e,data:r});}dedicatedOffer(t,e,r){this.send({gem:u,type:"gem.dedicatedOffer",matchId:t,sdp:e,intent:r});}requestParty(t){return this.send({gem:u,type:"gem.partyRequest",requestId:t})}requestPurchase(t,e,r,o,a,l,s){return this.send({gem:u,type:"gem.requestPurchase",requestId:t,purchaseKind:e,targetId:r,currencySlug:o,...a===void 0?{}:{quantity:a},...l===void 0?{}:{catalogId:l},...s===void 0?{}:{origin:s}})}requestAvatar3dPurchase(t,e,r){return this.parentSupports("avatar3dPurchases")?this.send({gem:u,type:"gem.requestAvatar3dPurchase",requestId:t,itemId:e,currencySlug:r}):false}putDeviceSettings(t,e){return this.send({gem:u,type:"gem.deviceSettings.put",requestId:t,settings:e})}requestAd(t,e,r){return this.send({gem:u,type:"gem.requestAd",requestId:t,placement:e,format:r})}signalMoment(t,e,r,o){return this.send({gem:u,type:"gem.signalMoment",requestId:t,kind:e,...r===void 0?{}:{placement:r},...o===true?{wall:true}:{}})}readyCalled(){return this.readySent||this.readyPending}requestSignIn(t){return this.send({gem:u,type:"gem.requestSignIn",requestId:t})}requestFriendChallenge(t,e,r,o){return this.send({gem:u,type:"gem.requestFriendChallenge",requestId:t,playerId:e,template:r,...o===void 0?{}:{params:o}})}requestArcade(t){return this.gated(ce(t.type))&&this.send({gem:u,...t})}close(){this.port&&(this.port.onmessage=null,this.port.close(),this.port=null),this.state!=="refused"&&this.transition("closed");}transition(t){if(this.state!==t){this.state=t;for(let e of this.settleWaiters.splice(0))e(t);this.options.onStateChange?.(t);}}refuseMalformed(t,e){if(!this.inbound.allow(de)){this.options.onDropped?.(t,e);return}this.fail(t,e);}dropUnknownType(t){this.inbound.allow(de)&&this.options.onDropped?.("unsupported",`ignored unknown message type '${t}'`);}refuse(t,e){t.ports?.[0]?.close?.(),this.inbound.allow(de)&&this.options.onRefused?.(e);}fail(t,e){this.options.onError?.(t,e),this.state==="connected"&&this.port&&this.send({gem:u,type:"gem.error",code:t,...e===void 0?{}:{message:e}});}gated(t){return this.state==="connected"&&this.parentSupports(t)}send(t){if(this.state!=="connected"||!this.port)return this.options.onDropped?.("internal",`dropped ${String(t.type)} before connect`),false;let e=t.type;if(!this.outbound.allow(e))return this.options.onError?.("rate_limited",`frame exceeded its own limit for ${e}`),false;let r=L[e]?.(t);return r?(this.options.onError?.("internal",`refusing to send malformed ${e}: ${r}`),false):(this.port.postMessage(this.version===null?t:{...t,v:this.version}),true)}receive(t,e=[]){let r=false;try{r=this.dispatchInbound(t,e);}finally{r||Ke(e);}}dispatchInbound(t,e){if(this.state!=="connected")return false;let r=typeof t=="object"&&t!==null?t.type:void 0;if(typeof r!="string")return this.refuseMalformed("invalid_message","message has no type"),false;let o=L[r];if(!o)return this.dropUnknownType(r),false;if(!this.inbound.allow(r))return this.fail("rate_limited",`parent exceeded the limit for ${r}`),false;let a=ce(r);if(a!==void 0&&!this.options.capabilities?.includes(a))return this.fail("unsupported_capability",`${r} requires the '${a}' capability, which this frame did not advertise`),false;let l=o(t);if(l)return this.fail("invalid_message",`${r}: ${l}`),false;let s=t;if(s.v!==this.version)return this.fail("invalid_message",`${r}: expected v ${String(this.version)}`),false;switch(r){case "gem.earnAllowanceChanged":this.options.onEarnAllowanceChanged?.();break;case "gem.devtools":this.options.onDevtools?.(s.action);break;case "gem.requestContext":this.options.onRequestContext?.();break;case "gem.screenshot":{let c=e[0];if(!c){this.options.onError?.("invalid_message","gem.screenshot transferred no MessagePort");break}let y={maxWidth:s.maxWidth,maxHeight:s.maxHeight};if(!this.options.onScreenshot){c.close(),this.screenshotDenied("not_wired",false);break}return Ke(e.slice(1)),this.options.onScreenshot(y,c,(b,v)=>this.screenshotDenied(b,v)),true}case "gem.token.denied":this.options.onTokenDenied?.(s);break;case "gem.localServer.denied":this.options.onLocalServerDenied?.(s);break;case "gem.player":{this.options.onPlayer?.(Tt(s));break}case "gem.deviceSettings.result":this.options.onDeviceSettingsResult?.(s);break;case "gem.error":this.options.onError?.(s.code,s.message);break;default:if(Mt.includes(r.slice(4))){this.options[`on${r[4].toUpperCase()}${r.slice(5)}`]?.(s);break}if(Ot.includes(ce(r))){this.options.onArcadeAnswer?.(s);break}this.fail("unsupported",`no frame handler for '${r}'`);}return false}screenshotDenied(t,e){this.send({gem:u,type:"gem.screenshot.denied",reason:t,retryable:e});}};function Ke(n){for(let t of n)try{t?.close?.();}catch{}}i(Ke,"closeAll");globalThis.__gemWebSdkVersion="[gem-web-sdk:sdkVersion:23.0.0]";var Xe=["if-match","if-none-match"];var Ft={unknown_currency:1,currency_not_in_game_payable:1,not_purchasable:1,no_price_in_currency:1,busy:1,cancelled:1,insufficient_funds:1,price_mismatch:1,config_version_stale:1,platform_currency_unavailable:1,not_available:1,recipe_locked:1,already_owned:1,guest_upgrade_required:1,recipe_on_cooldown:1,recipe_max_uses_exceeded:1,item_max_stack_exceeded:1,recipe_costs_unmet:1,quantity_invalid:1,error:1};new Set(Object.keys(Ft));new Set(Xe);new TextEncoder;var Ze=["explicit","stale_cleanup","game_room_closed","replaced","migration_failed","host_left","insufficient_players","all_left","expired","migration_rate_exceeded","game_room_gone","failed","idle","reclaimed"];new Set(Ze);new TextEncoder;new TextDecoder;new TextEncoder;var vn=8;(class{constructor(t=vn){this.perMinute=t;}perMinute;static{i(this,"CredentialPacing");}sent=[];delayUntilAllowed(t){return this.prune(t),this.sent.length<this.perMinute?0:Math.max(0,(this.sent[0]??t)+6e4-t)}record(t){this.prune(t),this.sent.push(t);}prune(t){let e=0;for(let r of this.sent)r<=t&&t-r<6e4&&(this.sent[e++]=r);this.sent.length=e;}});function p(n){return t=>typeof t=="string"&&t.length>0&&t.length<=n?t:void 0}i(p,"text");function M(n,t){return e=>typeof e=="number"&&Number.isInteger(e)&&e>=n&&e<=t?e:void 0}i(M,"integer");function N(...n){return t=>typeof t=="string"&&n.includes(t)?t:void 0}i(N,"oneOf");function tt(n){return typeof n=="boolean"?n:void 0}i(tt,"flag");var _=p(64),re=M(0,2147483647);function me(n){if(!Array.isArray(n))return;let t=[];for(let e of n){if(t.length>=64)break;let r=_(e);typeof r=="string"&&t.push(r);}return t}i(me,"ids");function g(n,t,e){return {to:n,from:t,read:e,required:true}}i(g,"required");function f(n,t,e){return {to:n,from:t,read:e,required:false}}i(f,"optional");var Rn=i(n=>{if(typeof n!="object"||n===null||Array.isArray(n))return;let t=n,e=N("disconnected","failed","closed")(t.iceState),r=M(0,4102444800)(t.lastSeenAt);if(!(e===void 0&&r===void 0))return {...e===void 0?{}:{ice_state:e},...r===void 0?{}:{last_seen_timestamp:r}}},"evidence");Object.freeze(Object.assign(Object.create(null),{join:{type:"p2p_join",gameScoped:true,args:[]},offer:{type:"p2p_offer",gameScoped:false,args:[g("sdp","sdp",p(10240)),g("signaling_intent","intent",N("initial","ice_restart","full_reconnect")),f("sdp_hash","sdpHash",p(128))]},answer:{type:"p2p_answer",gameScoped:false,args:[g("peer_id","peerId",_),g("sdp","sdp",p(10240)),g("assigned_peer_id","assignedPeerId",M(0,4294967295)),f("sdp_hash","sdpHash",p(128))]},ice:{type:"p2p_ice_candidate",gameScoped:false,args:[g("peer_id","peerId",_),g("candidate","candidate",p(512)),f("sdp_mid","sdpMid",p(64)),f("sdp_mline_index","sdpMLineIndex",M(0,255))]},migrationAck:{type:"p2p_migration_ack",gameScoped:false,args:[g("host_epoch","hostEpoch",re)]},hostUnreachable:{type:"p2p_report_host_unreachable",gameScoped:false,args:[g("host_epoch","hostEpoch",re),f("evidence","evidence",Rn)]}}));Object.freeze(Object.assign(Object.create(null),{p2p_hello:"hello",p2p_sdp_offer:"offer",p2p_sdp_answer:"answer",p2p_ice_candidate:"ice",p2p_peer_joined:"peerJoined",p2p_peer_left:"peerLeft",p2p_host_migration:"migration",p2p_match_ended:"matchEnded",p2p_error:"error",p2p_relay_draining:"relayDraining"}));var kn=16,An=i(n=>me(n)?.slice(0,kn),"relayIps");Object.freeze(Object.assign(Object.create(null),{hello:[g("playerId","player_id",_),g("hostPlayerId","host_player_id",_),g("hostEpoch","host_epoch",re),f("members","members",me)],offer:[g("fromPlayerId","from_player_id",_),g("sdp","sdp",p(10240)),f("sessionId","signaling_session_id",p(128)),f("sdpHash","sdp_hash",p(128)),f("iceUfrag","ice_ufrag",p(64)),f("intent","signaling_intent",N("initial","ice_restart","full_reconnect"))],answer:[g("fromPlayerId","from_player_id",_),g("sdp","sdp",p(10240)),f("sessionId","signaling_session_id",p(128)),f("sdpHash","sdp_hash",p(128)),f("iceUfrag","ice_ufrag",p(64)),f("assignedPeerId","assigned_peer_id",M(0,4294967295))],ice:[g("fromPlayerId","from_player_id",_),g("candidate","candidate",p(512)),f("sdpMid","sdp_mid",p(64)),f("sdpMLineIndex","sdp_m_line_index",M(0,255)),f("sdpMLineIndexAlt","sdp_mline_index",M(0,255))],peerJoined:[g("playerId","player_id",_)],peerLeft:[g("playerId","player_id",_),f("reason","reason",p(64))],migration:[g("hostPlayerId","new_host_player_id",_),g("hostEpoch","host_epoch",re),f("reason","reason",p(64)),f("kickedPlayerIds","kicked_player_ids",me),f("migrationComplete","migration_complete",tt)],matchEnded:[f("reason","reason",p(64))],error:[f("code","code",p(64)),f("message","message",p(256))],relayDraining:[g("clusterTargetId","cluster_target_id",_),g("relayIps","relay_ips",An),g("drainingSince","draining_since",p(40)),g("deadline","deadline",p(40))]}));Object.freeze(Object.assign(Object.create(null),{party_invite_received:"inviteReceived",party_member_joined:"memberJoined",party_member_left:"memberLeft",party_member_kicked:"memberKicked",party_leader_transferred:"leaderTransferred",party_updated:"updated",party_disbanded:"disbanded",party_game_room_joined:"gameRoomJoined",party_game_room_left:"gameRoomLeft"}));function Cn(n,t){return Object.freeze({route:n,listed:t})}i(Cn,"answer");Object.freeze(Object.assign(Object.create(null),{webrtc_sdp_answer:"answer",webrtc_error:"error",match_ended:"matchEnded"}));Object.freeze(Object.assign(Object.create(null),{answer:[g("sdp","sdp",p(10240)),f("sessionId","session_id",p(64))],error:[f("code","code",p(64)),f("message","message",p(256))],matchEnded:[f("reason","reason",p(64))]}));var ut=Object.freeze(["https://gemarcade.com","https://developer.gemarcade.com","http://gemarcade.localhost","gemarcade://localhost"]);var K=class extends Error{constructor(e,r){super(`[${e}] ${r}`);this.caseId=e;this.name="ParentConformanceError";}caseId;static{i(this,"ParentConformanceError");}},u_=7,mt="https://game.conformance.invalid",pt="00000000-0000-4000-8000-0000000c0de7",gt="release",hr="https://stranger.conformance.invalid",Me=G["gem.handshake"]??1,se=6e4,ge=class{static{i(this,"KitClock");}current=1e6;seq=0;pending=new Map;now(){return this.current}setTimeout(t,e){let r=++this.seq;return this.pending.set(r,{at:this.current+Math.max(0,e),fn:t}),r}clearTimeout(t){this.pending.delete(t);}get pendingTimers(){return this.pending.size}advance(t){let e=this.current+t;for(;;){let r;for(let o of this.pending)o[1].at<=e&&(r===void 0||o[1].at<r[1].at)&&(r=o);if(r===void 0)break;this.pending.delete(r[0]),this.current=r[1].at,r[1].fn();}this.current=e;}},ft=Object.freeze({conformance:"parent-window"}),fe=class{constructor(t,e,r,o){this.caseId=t;this.options=r;let a=o??r.frameOrigin??mt,l={gameId:pt,channel:gt,frame:{postMessage:i((s,c,y)=>{this.offers.push({data:s,targetOrigin:c,transfer:y??[],at:this.clock.now()});},"postMessage")},frameOrigin:a,embedderOrigin:r.embedderOrigin,clock:this.clock,makeChannel:i(()=>{let s=new MessageChannel,c={port1:s.port1,port2:s.port2,closed:false},y=s.port1.close.bind(s.port1);return s.port1.close=()=>{c.closed=true,y();},this.count(s.port1),this.count(s.port2),this.minted.push(c),s},"makeChannel"),reportError:i((s,c)=>{this.errors.push(c===void 0?{code:s}:{code:s,message:c});},"reportError")};Object.defineProperty(l,"userActivation",{enumerable:true,get:i(()=>this.activation===void 0?void 0:{...this.activation},"get")}),this.parent=e(l);}caseId;options;static{i(this,"Rig");}clock=new ge;frameClock=new ge;offers=[];minted=[];parent;activation={isActive:false};errors=[];inFlight=0;frames=[];get frameOrigin(){return this.options.frameOrigin??mt}get gameId(){return pt}get channel(){return gt}fail(t){throw new K(this.caseId,t)}count(t){let e=t.postMessage.bind(t);t.postMessage=((...r)=>{this.inFlight+=1,e(...r);}),t.addEventListener("message",()=>{this.inFlight-=1;});}async flush(){let t=i(()=>new Promise(e=>setTimeout(e,0)),"turn");await t(),await t();for(let e=0;this.inFlight>0&&e<200;e++)await t();}advance(t,e=250){for(let r=0;r<t;r+=e){let o=Math.min(e,t-r);this.clock.advance(o),this.frameClock.advance(o);}}start(){try{this.parent.start();}catch(t){this.fail(`start() threw: ${Le(t)}`);}this.offers.length===0&&this.fail("start() posted no handshake to the frame window. The offer must be posted at start, on the window the fixture names as `frame`.");}latest(){let t=this.offers[this.offers.length-1];return t===void 0&&this.fail("no handshake has been offered"),t}transferred(t){t.transfer.length!==1&&this.fail(`an offer transferred ${t.transfer.length} objects; it must transfer exactly one MessagePort.`);let e=this.minted.find(r=>r.port2===t.transfer[0]);return e===void 0&&this.fail("an offer transferred a port the fixture did not mint. Take every offer\u2019s channel from `fixture.makeChannel`, so the kit can see which ports the parent closes."),e}frame(t){let e=t??[...new Set([...ut,...this.options.allowedEmbedders??[]])],r=[],o=new q({allowedEmbedders:e,expectedSource:ft,selfOrigin:this.frameOrigin,clock:this.frameClock,onRefused:i(a=>r.push(a),"onRefused")});return o.kitRefusals=r,this.frames.push(o),o}deliver(t,e){let r=this.transferred(e);return t.handleWindowMessage({data:e.data,origin:this.options.embedderOrigin,source:ft,ports:[r.port2]})}answer(t,e,r=[]){this.transferred(t).port2.postMessage({gem:u,type:"gem.handshake.accept",v:e,capabilities:[...r]});}advertised(){let t=this.latest().data.capabilities;return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async raw(t){let e=this.latest(),r=this.transferred(e),o=[];r.port2.onmessage=s=>{s.data!==null&&typeof s.data=="object"&&o.push(s.data);};let a=Math.min(V(this).max,A.max);this.answer(e,a,t),await this.flush(),this.state()!=="connected"&&this.fail(`a hand-written frame accepted at v${a}, and the parent reports '${this.state()}'.`);let l=0;return {received:o,ask:i(async(s,c,y)=>{let b=`conformance-${++l}`;return this.activation=y==="missing"?void 0:{isActive:y==="pressed"},r.port2.postMessage({gem:u,type:s,v:a,requestId:b,...c}),await this.flush(),this.activation={isActive:false},b},"ask"),answers:i(s=>o.filter(c=>c.requestId===s),"answers")}}surfaces(t){let e=this.parent.surfacesShown;return typeof e!="number"&&this.fail(`${t}, so the kit must see what it shows: expose \`surfacesShown\` on the adapter (every checkout, card, QR code, toast or tab the parent opened for a game).`),e}offersInAnyMinute(){let t=0;for(let e=0;e<this.offers.length;e++){let r=this.offers[e].at,o=0;for(let a=e;a<this.offers.length&&this.offers[a].at<r+se;a++)o++;t=Math.max(t,o);}return t}state(){return this.parent.state}dispose(){try{this.parent.close();}catch{}for(let t of this.frames)t.close();for(let t of this.minted)try{t.port1.close(),t.port2.close();}catch{}}};function Le(n){return n instanceof Error?n.message:String(n)}i(Le,"describe");function yr(n){return n.kitRefusals??[]}i(yr,"refusalsOf");function V(n){let t=n.latest().data.versions,e=t?.min,r=t?.max;return (typeof e!="number"||typeof r!="number")&&n.fail("the handshake carries no numeric `versions.min` / `versions.max`"),{min:e,max:r}}i(V,"offeredRange");async function h(n,t,e,r){let o=new fe(n,t,e);try{await r(o);}finally{o.dispose();}}i(h,"withRig");async function ie(n){let t=n.frame();return n.deliver(t,n.latest())||n.fail(`a game built with this SDK refused the handshake from ${n.options.embedderOrigin}: ${yr(t).join("; ")||"no reason recorded"}. A production origin the SDK does not carry needs an SDK that lists it; a non-production one goes in \`allowedEmbedders\` here, as a game would name it.`),await n.flush(),n.state()!=="connected"&&n.fail(`the frame accepted, but the parent reports '${n.state()}' rather than 'connected'.`),t}i(ie,"connect");var E=["appLinks","openGame","store","storeOfferSheet"],ht="00000000-0000-4000-8000-00000000c0de",he="conformance-unknown-sku",Ge={appLinks:{type:"gem.requestOpenApp",fields:{target:"arcade"}},openGame:{type:"gem.requestOpenGame",fields:{ref:ht}},store:{type:"gem.requestStorePurchase",fields:{skuId:he}},storeOfferSheet:{type:"gem.requestStoreOfferSheet",fields:{skuId:he}}},br=["appLinks","openGame"],vr=[["store","gem.requestStorePurchase"],["storeOfferSheet","gem.requestStoreOfferSheet"]];function pe(n,t,e,r,o){let a=t.answers(e);a.length!==1&&n.fail(`${o}: the parent sent ${a.length} answers; it owes exactly one.`);let[l]=a;(l.outcome!=="declined"||l.reason!=="busy")&&n.fail(`${o}: answered ${JSON.stringify(l.outcome)} / ${JSON.stringify(l.reason)}, not 'declined' / 'busy'.`);let s=n.surfaces(o);s!==r&&n.fail(`${o}: the parent showed ${s-r} surface(s); it must show nothing.`);}i(pe,"expectBusy");async function B(n,t,e="gem.requestStorePurchase",r="pressed",o=""){let a=await t.ask("gem.requestStoreOffers",{},"unpressed"),[l]=t.answers(a),c=(l?.offers??[])[0]?.skuId;(l?.outcome!=="ok"||typeof c!="string")&&n.fail(`the parent advertises \`store\` but listed no offer to a signed-in player (${JSON.stringify(l?.outcome)} / ${JSON.stringify(l?.reason)}). Give the adapter's store a signed-in player and at least one SKU, so the kit can open a checkout.`);let y=n.surfaces("the parent advertises `store`"),b=await t.ask(e,{skuId:c},r),v=n.surfaces("the parent advertises `store`");if(v!==y+1){let x=r==="pressed"?"a pressed":r==="unpressed"?"an unpressed":"with no userActivation API, a",J=t.answers(b);n.fail(`${o}${x} ${e} of the listed SKU ${JSON.stringify(c)} showed ${v-y} surface(s) and was answered ${JSON.stringify(J)}; it must open exactly one. A store purchase needs no press, and nothing backs off after the player closes a checkout: a player who wants to pay can always pay.`);}return t.answers(b).length>0&&n.fail(`${e} was answered while what it opened was still open. Answer once the player has acted, so the kit can hold it open.`),{requestId:b,skuId:c,shown:v}}i(B,"openStoreCheckout");function oe(n){typeof n.parent.dismiss!="function"&&n.fail("the parent advertises `store`, so the kit must be able to close its checkout: expose `dismiss()` on the adapter (the player closing the checkout without paying)."),n.parent.dismiss();}i(oe,"dismiss");var wr="game_inventory_changed",_r=1e4;function W(n,t){return {v:1,type:wr,data:{game_id:n,channel:t,entity_id:"conformance-entity",balance_after:500},ts:179e7}}i(W,"inventoryEvent");function Sr(n,t){try{n.parent.deliverSocket(t);}catch(e){n.fail(`deliverSocket threw: ${Le(e)}`);}}i(Sr,"deliverSocket");function Rr(n,t){return n.received.filter(e=>e.type===t)}i(Rr,"sentOf");async function ae(n,t,e=true){if(typeof n.parent.deliverSocket!="function")return null;n.start();let r=await n.raw(t);if(!e)return r;await r.ask("gem.requestToken",{reason:"initial"},"unpressed");let o=Rr(r,"gem.token"),a=o[o.length-1];return a===void 0&&n.fail("the adapter exposes `deliverSocket`, so the kit needs a session with a token: answer the frame's gem.requestToken with a gem.token naming `fixture.gameId` and `fixture.channel`."),(a.gameId!==n.gameId||a.channel!==n.channel)&&n.fail(`the parent's gem.token named game ${JSON.stringify(a.gameId)} on ${JSON.stringify(a.channel)}; the kit's session is ${n.gameId} on ${n.channel}. Name the game and channel from \`fixture.gameId\` and \`fixture.channel\`.`),r}i(ae,"socketSession");async function H(n,t,e){let r=t.received.length;for(let o of e)Sr(n,o);return await n.flush(),n.advance(_r),await n.flush(),t.received.slice(r)}i(H,"deliverAndSettle");var kr=["*","null","","https://game.conformance.invalid/","https://game.conformance.invalid/play"],Ar=[{id:"origin.refuses-imprecise-target",title:"refuses a frame origin that is not one exact origin, before anything is posted",async run(n,t){for(let e of kr){let r=JSON.stringify(e),o,a=false;try{o=new fe(this.id,n,{...t,frameOrigin:e},e),o.parent.start();}catch(l){if(l instanceof K)throw l;a=true;}try{if((o?.offers??[]).some(s=>s.targetOrigin==="*"||s.targetOrigin===e))throw new K(this.id,`with frame origin ${r} the parent posted the handshake anyway \u2014 the offer transfers the session port, so an imprecise target hands the session to whatever the frame has navigated to.`);if(!a)throw new K(this.id,`a frame origin of ${r} was accepted. Refuse it at construction or at start(), by throwing.`)}finally{o?.dispose();}}}},{id:"handshake.targets-frame-origin",title:"posts a valid handshake to exactly the frame origin, naming the page\u2019s own origin",async run(n,t){await h(this.id,n,t,e=>{e.start(),e.advance(I);for(let a of e.offers){a.targetOrigin!==e.frameOrigin&&e.fail(`an offer was posted with targetOrigin ${JSON.stringify(a.targetOrigin)}, not the frame origin ${e.frameOrigin}.`),e.transferred(a);let l=L["gem.handshake"]?.(a.data);l&&e.fail(`the handshake does not validate against the schema: ${l}`);let s=a.data;s.gem!==u&&e.fail(`the handshake's \`gem\` is not ${u}`),s.embedder!==t.embedderOrigin&&e.fail(`the handshake names embedder ${JSON.stringify(s.embedder)}, but the page is served from ${t.embedderOrigin}. Every game compares the two and refuses a mismatch: name the origin the page is actually served from.`);}let{min:r,max:o}=V(e);r>o&&e.fail(`the offered range is empty: min ${r} > max ${o}`),(o<A.min||r>A.max)&&e.fail(`the offered range v${r}\u2013v${o} shares no version with this SDK (v${A.min}\u2013v${A.max}).`);});}},{id:"handshake.default-game-connects",title:"connects to a game that names no embedders, at the highest common version",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=await ie(e),{max:o}=V(e),a=Math.min(o,A.max);r.protocolVersion!==a&&e.fail(`the frame chose v${String(r.protocolVersion)}, expected v${a}`),e.parent.protocolVersion!==r.protocolVersion&&e.fail(`the parent reports v${String(e.parent.protocolVersion)} while the frame chose v${String(r.protocolVersion)}. Adopt the version on the accept.`);});}},{id:"handshake.refusal-is-not-a-verdict",title:"keeps offering, still handshaking, when a game refuses this page",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=e.frame([hr]);e.deliver(r,e.latest())&&e.fail("a frame that does not allow this page accepted it \u2014 the kit is misconfigured"),await e.flush();let o=e.offers.length;e.advance(I*3),await e.flush(),e.state()!=="handshaking"&&e.fail(`after a refusal and ${I*3}ms the parent reports '${e.state()}'. A refusing game answers nothing, by design, so silence is not evidence: stay handshaking until the page closes the bridge.`),e.offers.length<=o&&e.fail("the parent stopped offering after a refusal; keep offering on the cadence.");});}},{id:"version.adopts-frame-choice",title:"adopts the version the frame chose from inside the offered range",async run(n,t){await h(this.id,n,t,async e=>{e.start();let{min:r}=V(e);e.answer(e.latest(),r),await e.flush(),(e.state()!=="connected"||e.parent.protocolVersion!==r)&&e.fail(`answered with v${r}, the bottom of the offered range, the parent reports '${e.state()}' at v${String(e.parent.protocolVersion)}.`);});}},{id:"version.refuses-out-of-range",title:"never connects at a version outside the range it offered",async run(n,t){for(let e of ["above","below"])await h(this.id,n,t,async r=>{r.start();let{min:o,max:a}=V(r),l=e==="above"?a+1:o-1;r.answer(r.latest(),l),await r.flush(),(r.state()==="connected"||r.parent.protocolVersion===l)&&r.fail(`answered with v${l}, outside the offered v${o}\u2013v${a}, the parent connected. A frame choosing a version this parent never offered is not a session.`);});}},{id:"lifecycle.reoffers-on-fresh-ports",title:"re-offers on a fresh port while unanswered, inside the contract\u2019s budget",async run(n,t){await h(this.id,n,t,e=>{e.start(),e.advance(I*2),e.offers.length<2&&e.fail(`one offer in ${I*2}ms. A message to a document that is not listening yet is lost, not queued: re-offer until something answers.`);let r=e.offers.map(a=>e.transferred(a).port2);new Set(r).size!==r.length&&e.fail("an offer re-used a port; each offer needs its own channel."),e.advance(se*2);let o=e.offersInAnyMinute();o>Me&&e.fail(`${o} offers inside one minute; the contract budgets ${Me} \`gem.handshake\` per minute.`);});}},{id:"lifecycle.late-answer-adopts-and-closes-the-rest",title:"adopts the offer a late frame answers, and closes every other offered port",async run(n,t){await h(this.id,n,t,async e=>{e.start(),e.advance(I*2);let r=e.transferred(e.latest());await ie(e),r.closed&&e.fail("the parent closed the port the frame answered on.");let o=e.minted.filter(a=>a!==r&&!a.closed).length;o>0&&e.fail(`${o} unanswered offer port(s) still open after connecting. Close every other offer when one is answered.`);});}},{id:"lifecycle.no-offers-after-connect",title:"stops offering once connected",async run(n,t){await h(this.id,n,t,async e=>{e.start(),await ie(e);let r=e.offers.length;e.advance(se*5,1e3),e.offers.length!==r&&e.fail(`${e.offers.length-r} offer(s) after the session connected.`);});}},{id:"lifecycle.duplicate-accept-keeps-session",title:"keeps the session when a second accept arrives, even an out-of-range one",async run(n,t){await h(this.id,n,t,async e=>{e.start(),await ie(e);let r=e.parent.protocolVersion;e.answer(e.latest(),V(e).max+1),await e.flush(),(e.state()!=="connected"||e.parent.protocolVersion!==r)&&e.fail(`a second accept moved the parent to '${e.state()}' at v${String(e.parent.protocolVersion)}. One answer settles the handshake.`);});}},{id:"lifecycle.close-releases-everything",title:"on close, releases every port and timer and offers nothing more",async run(n,t){await h(this.id,n,t,e=>{e.start(),e.advance(I),e.parent.close(),e.state()!=="closed"&&e.fail(`after close() the parent reports '${e.state()}'`);let r=e.minted.filter(a=>!a.closed).length;r>0&&e.fail(`${r} offer port(s) left open after close().`),e.clock.pendingTimers>0&&e.fail(`${e.clock.pendingTimers} timer(s) still armed after close().`);let o=e.offers.length;e.advance(se*2,1e3),e.offers.length!==o&&e.fail("the parent offered again after close().");}),await h(this.id,n,t,async e=>{e.start(),await ie(e),e.parent.close(),e.state()!=="closed"&&e.fail(`after close() the parent reports '${e.state()}'`),e.minted.filter(o=>!o.closed).length>0&&e.fail("the session port is still open after close().");});}},{id:"lifecycle.unanswered-offers-are-bounded",title:"holds at most about a minute of unanswered offer ports, however long it runs",async run(n,t){await h(this.id,n,t,e=>{e.start(),e.advance(se*10,1e3);let r=e.minted.filter(o=>!o.closed).length;r>Me+1&&e.fail(`${r} unanswered offer ports open after ten minutes. Close offers nothing answered within a grace (a minute is the reference), or the loop leaks a channel per tick for as long as the page holds the frame.`);});}},{id:"capability.unadvertised-is-refused",title:"refuses an arcade-feature or store ask under a capability either side did not advertise, answering nothing and showing nothing",async run(n,t){for(let e of E)await h(this.id,n,t,async r=>{r.start();let o=r.advertised().includes(e),a=E.filter(x=>!o||x!==e),l=await r.raw(a),s=r.parent.surfacesShown,{type:c,fields:y}=Ge[e],b=await l.ask(c,y,"pressed"),v=o?"the frame":"the parent";l.answers(b).length>0&&r.fail(`${c} under '${e}', which ${v} did not advertise, was answered. Refuse it before anything else and send nothing back.`),r.parent.surfacesShown!==s&&r.fail(`${c} under unadvertised '${e}' showed a surface.`),r.errors.some(x=>x.code==="unsupported_capability")||r.fail(`${c} under '${e}', which ${v} did not advertise, was not reported as 'unsupported_capability'. Report it through \`fixture.reportError\` (what GemHost calls onError).`);});}},{id:"acting.refuses-without-activation",title:"answers an ask to leave the game (open app, open game) with no press \u2014 or no activation API \u2014 declined / busy, showing nothing",async run(n,t){for(let e of br)for(let r of ["unpressed","missing"])await h(this.id,n,t,async o=>{if(o.start(),!o.advertised().includes(e))return;let a=await o.raw(E),l=o.surfaces(`the parent advertises '${e}'`),{type:s,fields:c}=Ge[e],y=await a.ask(s,c,r);pe(o,a,y,l,r==="missing"?`${s} with no userActivation API (it must fail closed)`:`${s} with no press`);});}},{id:"store.unknown-sku-is-unavailable",title:"answers a store purchase of a SKU it does not list unavailable, showing nothing",async run(n,t){await h(this.id,n,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let r=await e.raw(E),o=e.surfaces("the parent advertises `store`"),a=await r.ask("gem.requestStorePurchase",{skuId:he},"pressed"),l=r.answers(a);(l.length!==1||l[0].outcome!=="unavailable")&&e.fail(`a pressed purchase of an unknown SKU was answered ${JSON.stringify(l)}; it owes exactly one 'unavailable'.`),e.surfaces("the parent advertises `store`")!==o&&e.fail("a purchase of an unknown SKU showed a surface; it must show nothing.");});}},{id:"acting.second-ask-is-busy",title:"answers any acting ask declined / busy, showing nothing, while a store checkout is open",async run(n,t){await h(this.id,n,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let r=await e.raw(E),o=await B(e,r),a=await r.ask("gem.requestStorePurchase",{skuId:o.skuId},"pressed");pe(e,r,a,o.shown,"a second store purchase while one is open");for(let s of ["appLinks","openGame","storeOfferSheet"]){if(!e.advertised().includes(s))continue;let{type:c,fields:y}=Ge[s],b=await r.ask(c,y,"pressed");pe(e,r,b,o.shown,`${c} while a store checkout is open`);}oe(e),await e.flush();let[l]=r.answers(o.requestId);(l?.outcome!=="declined"||l.reason!=="cancelled")&&e.fail(`the closed checkout was answered ${JSON.stringify(l?.outcome)} / ${JSON.stringify(l?.reason)}, not 'declined' / 'cancelled'.`);});}},{id:"store.no-press-needed",title:"opens a store checkout, or an offer sheet, for an ask with no press or no activation API",async run(n,t){for(let[e,r]of vr)for(let o of ["unpressed","missing"])await h(this.id,n,t,async a=>{if(a.start(),!a.advertised().includes(e))return;let l=await a.raw(E),s=await B(a,l,r,o);oe(a),await a.flush();let[c]=l.answers(s.requestId);(c?.outcome!=="declined"||c.reason!=="cancelled")&&a.fail(`the closed ${r} asked with no press was answered ${JSON.stringify(c?.outcome)} / ${JSON.stringify(c?.reason)}, not 'declined' / 'cancelled'.`);});}},{id:"store.no-back-off",title:"opens the checkout again for the next store purchase, however many times the player closed one",async run(n,t){await h(this.id,n,t,async e=>{if(e.start(),!e.advertised().includes("store"))return;let r=await e.raw(E);for(let o=1;o<=5;o+=1){let a=await B(e,r,"gem.requestStorePurchase","pressed",o===1?"":`straight after the player dismissed one (round ${o}), `);oe(e),await e.flush();let[l]=r.answers(a.requestId);(l?.outcome!=="declined"||l.reason!=="cancelled")&&e.fail(`closed checkout ${o} was answered ${JSON.stringify(l?.outcome)} / ${JSON.stringify(l?.reason)}, not 'declined' / 'cancelled'.`);}e.advertised().includes("storeOfferSheet")&&await B(e,r,"gem.requestStoreOfferSheet","pressed","straight after the player dismissed a checkout, ");});}},{id:"sheet.needs-store",title:"advertises storeOfferSheet only beside store",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=e.advertised();r.includes("storeOfferSheet")&&!r.includes("store")&&e.fail("the parent advertises `storeOfferSheet` without `store`. A game takes its SKU from gem.storeOffersResult and hears a pending purchase settle through gem.storePurchaseSettled, and both are gated on `store`.");});}},{id:"settled.needs-purchases",title:"advertises purchaseSettled only beside purchases",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=e.advertised();r.includes("purchaseSettled")&&!r.includes("purchases")&&e.fail("the parent advertises `purchaseSettled` without `purchases`. gem.purchaseSettled reports a purchase the game asked for through gem.requestPurchase, which is gated on `purchases`.");});}},{id:"share.extras-need-share",title:"advertises shareResult and shareRemap only beside share",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=e.advertised();if(!r.includes("share"))for(let o of ["shareResult","shareRemap"])r.includes(o)&&e.fail(`the parent advertises \`${o}\` without \`share\`. Both describe what the parent does with gem.requestShare, which is gated on \`share\`.`);});}},{id:"share.refusal-is-answered",title:"answers a share naming embedder refused / reserved_key, naming the key, when it advertises shareResult",async run(n,t){await h(this.id,n,t,async e=>{e.start();let r=e.advertised();if(!r.includes("share")||!r.includes("shareResult"))return;let o=await e.raw(["share","shareResult"]),a=e.parent.surfacesShown,l=await o.ask("gem.requestShare",{params:[{key:"embedder",value:"x"}]},"pressed"),s=o.answers(l);s.length!==1&&e.fail(`a share naming \`embedder\` was answered ${s.length} times; a parent that advertises \`shareResult\` owes exactly one gem.shareResult for a request carrying a requestId.`);let[c]=s;(c.type!=="gem.shareResult"||c.outcome!=="refused"||c.reason!=="reserved_key"||c.key!=="embedder")&&e.fail(`a share naming \`embedder\` was answered ${JSON.stringify(c)}; it owes gem.shareResult 'refused' / 'reserved_key' with key 'embedder'. No parent carries embedder in a share link, remapping or not.`),typeof a=="number"&&e.parent.surfacesShown!==a&&e.fail("a refused share showed a surface; it must show nothing.");});}},{id:"sheet.unknown-sku-is-unavailable",title:"answers an offer sheet for a SKU it does not list unavailable, showing nothing",async run(n,t){await h(this.id,n,t,async e=>{if(e.start(),!e.advertised().includes("storeOfferSheet"))return;let r=await e.raw(E),o=e.surfaces("the parent advertises `storeOfferSheet`"),a=await r.ask("gem.requestStoreOfferSheet",{skuId:he},"pressed"),l=r.answers(a);(l.length!==1||l[0].outcome!=="unavailable")&&e.fail(`a pressed offer sheet for an unknown SKU was answered ${JSON.stringify(l)}; it owes exactly one 'unavailable'.`),e.surfaces("the parent advertises `storeOfferSheet`")!==o&&e.fail("an offer sheet for an unknown SKU showed a surface; it must show nothing.");});}},{id:"sheet.shares-the-slot",title:"holds the acting slot while an offer sheet is open, and opens either store ask again once the player leaves it",async run(n,t){await h(this.id,n,t,async e=>{if(e.start(),!e.advertised().includes("storeOfferSheet"))return;let r=await e.raw(E),o=await B(e,r,"gem.requestStoreOfferSheet"),a=await r.ask("gem.requestStorePurchase",{skuId:o.skuId},"pressed");pe(e,r,a,o.shown,"a store purchase while an offer sheet is open"),oe(e),await e.flush();let[l]=r.answers(o.requestId);(l?.outcome!=="declined"||l.reason!=="cancelled")&&e.fail(`the closed offer sheet was answered ${JSON.stringify(l?.outcome)} / ${JSON.stringify(l?.reason)}, not 'declined' / 'cancelled'.`);for(let s of ["gem.requestStoreOfferSheet","gem.requestStorePurchase"])await B(e,r,s,"pressed","straight after the player left a sheet, "),oe(e),await e.flush();});}},{id:"inventory.own-game-relayed",title:"relays this game's own game_inventory_changed as one field-free gem.inventoryChanged, and coalesces a burst",async run(n,t){await h(this.id,n,t,async e=>{let r=await ae(e,["inventoryChanged"]);if(r===null)return;let o=await H(e,r,[W(e.gameId,e.channel)]),a=o.filter(b=>b.type==="gem.inventoryChanged");(a.length!==1||o.length!==1)&&e.fail(`one game_inventory_changed for this game and channel put ${a.length} gem.inventoryChanged and ${o.length-a.length} other message(s) on the frame; it owes exactly one gem.inventoryChanged.`);let l=Object.keys(a[0]).filter(b=>!["gem","type","v"].includes(b));l.length>0&&e.fail(`gem.inventoryChanged carried ${l.map(b=>JSON.stringify(b)).join(", ")}. It carries no field: copy nothing from the socket event.`);let s=L["gem.inventoryChanged"]?.(a[0]);s&&e.fail(`gem.inventoryChanged fails the contract: ${s}`);let y=(await H(e,r,Array.from({length:10},()=>W(e.gameId,e.channel)))).filter(b=>b.type==="gem.inventoryChanged").length;(y<1||y>2)&&e.fail(`a burst of 10 game_inventory_changed inside a second put ${y} gem.inventoryChanged on the frame; coalesce it to one, then at most one trailing send.`);});}},{id:"inventory.other-game-never-relayed",title:"never relays another game's, or another channel's, game_inventory_changed",async run(n,t){await h(this.id,n,t,async e=>{let r=await ae(e,["inventoryChanged"]);if(r===null)return;let o=e.channel==="release"?"dev":"release";for(let[a,l]of [["another game",W(ht,e.channel)],["this game on another channel",W(e.gameId,o)]]){let s=await H(e,r,[l]);s.length>0&&e.fail(`game_inventory_changed for ${a} put ${JSON.stringify(s.map(c=>c.type))} on the frame. Relay only the token's own game and channel: another game's change tells this game when another game paid the player.`);}});}},{id:"inventory.before-token-never-relayed",title:"relays no game_inventory_changed before a token has named the game",async run(n,t){await h(this.id,n,t,async e=>{let r=await ae(e,["inventoryChanged"],!1);if(r===null)return;let o=await H(e,r,[W(e.gameId,e.channel)]);o.length>0&&e.fail(`before any token, game_inventory_changed put ${JSON.stringify(o.map(a=>a.type))} on the frame. Until a token has gone out there is no game to attribute it to.`);});}},{id:"inventory.unadvertised-not-sent",title:"sends no gem.inventoryChanged to a frame that did not advertise inventoryChanged",async run(n,t){await h(this.id,n,t,async e=>{let r=await ae(e,[]);if(r===null)return;let o=await H(e,r,[W(e.gameId,e.channel)]);o.length>0&&e.fail(`to a frame that advertised nothing, game_inventory_changed put ${JSON.stringify(o.map(a=>a.type))} on it. Send gem.inventoryChanged only when the frame advertised \`inventoryChanged\`: an older SDK drops it unread.`);});}},{id:"inventory.wallet-events-never-relayed",title:"relays nothing from a platform wallet event, even one naming this game",async run(n,t){await h(this.id,n,t,async e=>{let r=await ae(e,["inventoryChanged"]);if(r===null)return;let o={game_id:e.gameId,channel:e.channel};for(let[a,l]of [["platform_grant_fired",{...o,currency_id:"gems",granted:50,game_total:50,game_max:500,total:500}],["platform_funded_game_inventory_purchase_completed",{...o,purchase_id:"p",kind:"item",target:"t",qty:1,balance_after:450}],["platform_daily_maximum_reached",{...o,currency_id:"gems",limit:500}],["purchase_completed",{...o,purchase_id:"p",package_id:"k"}]]){let s=await H(e,r,[{v:1,type:a,data:l,ts:179e7}]);s.length>0&&e.fail(`${a} put ${JSON.stringify(s.map(c=>c.type))} on the frame. A wallet event describes the platform wallet across every game; relay nothing from it.`);}});}}],xr=Object.freeze(Ar);async function m_(n,t){if(!z(t.embedderOrigin))throw new Error(`runParentConformance: embedderOrigin must be one exact origin, got ${JSON.stringify(t.embedderOrigin)}`);let e=[];for(let r of xr)try{await r.run(n,t),e.push({id:r.id,title:r.title,ok:!0});}catch(o){e.push({id:r.id,title:r.title,ok:false,message:Le(o)});}return e}i(m_,"runParentConformance");
|
|
3
|
+
export{xr as PARENT_CONFORMANCE_CASES,u_ as PARENT_CONFORMANCE_VERSION,K as ParentConformanceError,m_ as runParentConformance};//# sourceMappingURL=gem-web-sdk.conformance.js.map
|
|
4
4
|
//# sourceMappingURL=gem-web-sdk.conformance.js.map
|