@idosgames/core 0.11.0 → 0.13.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 +55 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +542 -45
- package/dist/index.d.ts +542 -45
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var zod=require('zod'),Ci=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ci__default=/*#__PURE__*/_interopDefault(Ci);var Jt=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function qc(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function $n(){return Ec()??qc()}function Ec(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var Zn="https://api.idosgames.com";function Jn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??Zn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??$n(),locale:o.locale??Gc(),appVersion:o.appVersion??""}}function Gc(){try{return globalThis.navigator?.language??""}catch{return ""}}var At=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},Ot=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function Ut(){return globalThis.Telegram?.WebApp??null}function M(){return crypto.randomUUID()}var Yn="idos_device_id",Bt=class{storage;constructor(e=new At){this.storage=e;}getPlatform(){return Ut()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=Ut()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=Ut()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Yn);return e||(e=M(),this.storage.setString(Yn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=Ut();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=Ut();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var ks="idos_acq",Xn=["gclid","fbclid","ttclid","msclkid","yclid"],Nc=["ref","r"],jc=["ref_","ref-","ref=","r_","r-"];var bt=class{constructor(e){this.platform=e;}platform;capture(){let e=this.readFromEnvironment();Fc(e)&&this.store({signal:e,capturedAt:Date.now()});}buildForLogin(e){let t=this.read(),i=t?{...t.signal}:{},r=Wc(this.platform.getDeviceModel());return r&&(i.OsVersion=r),e&&(i.AppVersion=e),Object.keys(i).length>0?i:void 0}clear(){this.platform.storage.remove(ks);}static detectDevicePlatform(e){let t=(e||"").toLowerCase();return t.includes("android")?"Android":/iphone|ipad|ipod/.test(t)?"iOS":"Web"}static parseReferralCode(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.includes("://")||t.includes("?")){let i=io(to(t));if(i)return i}return ai(t)}readFromEnvironment(){let e={},t=to(this.platform.getFullURL());xt(e,"UtmSource",t.get("utm_source")),xt(e,"UtmMedium",t.get("utm_medium")),xt(e,"UtmCampaign",t.get("utm_campaign")),xt(e,"UtmTerm",t.get("utm_term")),xt(e,"UtmContent",t.get("utm_content")),xt(e,"ClaimToken",t.get("idos_click"));for(let k of Xn){let N=t.get(k);if(N){e.ClickID=N;break}}let i=this.platform.getStartParameter()??"",r=_c(i);if(r){for(let k of Vc)xt(e,k,r.get(ro[k])??null);for(let k of Xn){let N=r.get(k);if(N){e.ClickID=N;break}}}let s=ai(r?r.get("ref")??r.get("r")??"":i),a=io(t),p=s||a;p&&(e.ReferralCode=p,e.ChannelHint=s?"telegram":"query");let x=this.platform.getReferrer?.();return x&&(e.Referrer=x),e}read(){try{let e=this.platform.storage.getString(ks);if(!e)return null;let t=JSON.parse(e);return !t?.signal||typeof t.capturedAt!="number"?null:Date.now()-t.capturedAt>2592e6?(this.clear(),null):t}catch{return null}}store(e){try{this.platform.storage.setString(ks,JSON.stringify(e));}catch{}}};function Fc(o){return !!(o.UtmSource||o.UtmMedium||o.UtmCampaign||o.ClickID||o.Referrer||o.ReferralCode||o.ClaimToken)}function xt(o,e,t){t&&(o[e]=t);}var eo="a1_",ro={UtmSource:"utm_source",UtmMedium:"utm_medium",UtmCampaign:"utm_campaign",UtmTerm:"utm_term",UtmContent:"utm_content"},Vc=Object.keys(ro);function _c(o){let e=(o||"").trim();if(!e.startsWith(eo))return null;let t=e.slice(eo.length);if(!t)return null;try{let i=t.replace(/-/g,"+").replace(/_/g,"/"),r=atob(i+"=".repeat((4-i.length%4)%4)),s=Uint8Array.from(r,x=>x.charCodeAt(0)),a=new TextDecoder().decode(s),p=new URLSearchParams(a);return [...p.keys()].length>0?p:null}catch{return null}}function to(o){try{let e=o.indexOf("?");return new URLSearchParams(e>=0?o.slice(e):"")}catch{return new URLSearchParams}}function io(o){for(let e of Nc){let t=o.get(e);if(t)return ai(t)}return null}function ai(o){let e=(o||"").trim();if(!e)return null;for(let t of jc)if(e.toLowerCase().startsWith(t)){e=e.slice(t.length).trim();break}return e||null}function Wc(o){let e=o||"",t=/android\s+(\d+)/i.exec(e);if(t)return t[1];let i=/(?:iphone )?os\s+(\d+)[._]/i.exec(e);if(i)return i[1]}var so="idos_usage_pending",no="idos_usage_session",oo="idos_usage_closed_session",ao="idos_usage_new_session",lo="idos_usage_last_activity",Yt=class{constructor(e){this.ctx=e;}ctx;pendingSeconds=0;currentSessionSeconds=0;pendingClosedSessionSeconds=0;isNewSessionPending=false;lastTickAt=0;suspendedAt=null;countingPaused=false;timer=null;started=false;flushing=false;start(){this.started||typeof window>"u"||(this.started=true,this.restore(),this.lastTickAt=Date.now(),this.countingPaused=typeof document<"u"&&document.visibilityState==="hidden",this.timer=setInterval(()=>this.tick(),200*1e3),window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide));}async stop(){this.started&&(this.started=false,this.timer&&(clearInterval(this.timer),this.timer=null),typeof window<"u"&&(window.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide)),this.accumulate(),this.closeCurrentSession(false),await this.flush());}onVisibilityChange=()=>{if(!(typeof document>"u")){if(document.visibilityState==="hidden"){this.accumulate(),this.countingPaused=true,this.suspendedAt=Date.now(),this.flush();return}this.countingPaused=false,this.suspendedAt!==null&&((Date.now()-this.suspendedAt)/1e3>=1800&&this.closeCurrentSession(true),this.suspendedAt=null),this.lastTickAt=Date.now();}};onPageHide=()=>{this.accumulate(),this.persist(),this.flush();};tick(){this.accumulate(),this.flush();}accumulate(){let e=Date.now(),t=Math.floor((e-this.lastTickAt)/1e3);this.lastTickAt=e,!(t<=0)&&(this.countingPaused||(this.pendingSeconds+=t,this.currentSessionSeconds+=t,this.persist()));}closeCurrentSession(e){let t=Math.floor(this.currentSessionSeconds);t>0&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t)),this.currentSessionSeconds=0,e&&(this.isNewSessionPending=true),this.persist();}async flush(){if(this.flushing||this.pendingSeconds<=0&&this.pendingClosedSessionSeconds<=0&&!this.isNewSessionPending)return;let e=this.pendingSeconds,t=this.pendingClosedSessionSeconds,i=this.isNewSessionPending;this.flushing=true,this.pendingSeconds=0,this.pendingClosedSessionSeconds=0,this.isNewSessionPending=false,this.persist();try{(await this.ctx.userService.addUsageTime(e,i,t)).ok||(this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist());}catch{this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist();}finally{this.flushing=false;}}restore(){this.pendingSeconds=this.readNumber(so),this.currentSessionSeconds=this.readNumber(no),this.pendingClosedSessionSeconds=this.readNumber(oo),this.isNewSessionPending=this.readNumber(ao)!==0;let e=this.readNumber(lo);this.currentSessionSeconds>0&&e>0&&(Date.now()-e)/1e3>=1800&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,Math.floor(this.currentSessionSeconds)),this.currentSessionSeconds=0);}persist(){this.writeNumber(so,this.pendingSeconds),this.writeNumber(no,this.currentSessionSeconds),this.writeNumber(oo,this.pendingClosedSessionSeconds),this.writeNumber(ao,this.isNewSessionPending?1:0),this.writeNumber(lo,Date.now());}readNumber(e){let t=this.ctx.platform.storage.getString(e),i=t?Number(t):0;return Number.isFinite(i)&&i>0?i:0}writeNumber(e,t){try{this.ctx.platform.storage.setString(e,String(Math.floor(t)));}catch{}}};var He={Virtual:"Virtual",Crypto:"Crypto"},qt=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),li={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},ui=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),it={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},ci=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),Qc={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},pi=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),Kc={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},di=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),Hc={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Xt=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),Ce={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function co(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return uo(e);let t=o.cordova?.platformId;return t?uo(t):o.navigator?.userAgent??""?it.Web:it.Unknown}function uo(o){let e=o.toLowerCase();return e==="android"?it.Android:e==="ios"?it.Ios:e==="web"?it.Web:it.Unknown}function mt(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function $c(o){return o.ok}function Zc(o){return !o.ok}var B=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),j=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var ws=zod.z.object({Type:ui.nullish(),CurrencyID:zod.z.string().nullish(),Amount:B.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),Jc=zod.z.object({Type:di.nullish(),EntityID:zod.z.string()}),Yc=zod.z.object({Address:Jc.nullish(),Amount:B.nullish(),Source:zod.z.string().nullish()}),Re=zod.z.object({Entries:zod.z.array(ws).nullish(),EventTokens:zod.z.array(Yc).nullish()}),po=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:Re.nullish()}),G=zod.z.object({Standard:Re.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(po).nullish()}),lt=zod.z.object({Standard:Re.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(po).nullish()}),v=zod.z.object({Grant:G.nullish(),Consume:lt.nullish()}),Dt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:v.nullish(),ToResult:v.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:Re.nullish()});var Xc=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),ep={Completed:"Completed",Started:"Started",StepReached:"StepReached"},tp=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),_=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:Xc.nullish(),Tutorial:tp.nullish(),Platforms:zod.z.array(ci).nullish()}).passthrough();var ie=zod.z.object({TotalCap:zod.z.number().nullish(),DailyCap:zod.z.number().nullish(),DailyWeightCap:zod.z.number().nullish(),PerActivationCap:zod.z.number().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish()}).passthrough();var ip=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),rp=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),sp=zod.z.object({AnchorUtc:zod.z.string().nullish(),MaxCycles:zod.z.number().nullish(),PauseBetweenPhasesSec:zod.z.number().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish()}).passthrough();zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();var np=zod.z.object({Reset:zod.z.string().nullish(),IntervalSeconds:zod.z.number().nullish(),AnchorUtc:zod.z.string().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();zod.z.object({SourceType:zod.z.string().nullish(),TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Ne=zod.z.object({SourceType:zod.z.string().nullish(),BaseWeight:zod.z.number().nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish(),TileTypeFilter:zod.z.array(zod.z.string()).nullish(),TileIndexFilter:zod.z.array(zod.z.number()).nullish(),ChanceOutcomeFilter:zod.z.array(zod.z.string()).nullish(),OutcomeFilter:zod.z.array(zod.z.string()).nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Limits:ie.nullish()}).passthrough(),re=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:rp.nullish(),Chain:sp.nullish(),Cyclic:np.nullish(),ActivationTriggers:zod.z.array(Ne).nullish(),Relative:ip.nullish()}).passthrough();var op={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},ap=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),lp={Step:"Step",Linear:"Linear",Geometric:"Geometric"},up=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),cp=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Base:zod.z.number().nullish(),Shape:ap.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(cp).nullish(),Interpolation:up.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var pp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:G.nullish()}).passthrough(),dp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Ms=zod.z.object({Bundles:zod.z.array(pp).nullish(),Multipliers:zod.z.array(dp).nullish()}).passthrough();var hp=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),hi=zod.z.object({Source:hp.nullish(),SourceKey:zod.z.string().nullish(),Curve:Pe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:Re.nullish(),ExcludeRewards:Re.nullish()}).passthrough(),Te=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:G.nullish(),BonusRewards:G.nullish(),SeasonTierRewards:Ms.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),Et=zod.z.object({Milestones:zod.z.record(zod.z.string(),Te).nullish()}).passthrough();var K=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var mp=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),zt=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxBalance:zod.z.number().nullish(),MaxPerGrant:zod.z.number().nullish(),DailyEarnCap:zod.z.number().nullish(),BurnOnEventEnd:zod.z.boolean().nullish(),BurnConversion:mp.nullish()}).passthrough();var ae=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),rt=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(ae(o)),Resources:v.nullish()});var fp={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},ho=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),gp=zod.z.object({}).passthrough().transform(o=>o),yp=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:B.nullish(),PointsCurrent:B.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),As=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:B.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:ho}),mo=zod.z.object({State:gp.nullish(),PointsTracks:zod.z.record(zod.z.string(),yp).nullish()}),Os=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:ho.nullish(),Resources:v.nullish()}),Us=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:B.nullish(),Resources:v.nullish()}),fo=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:v.nullish()}),go=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(As).nullish()}),yo=zod.z.array(ae(Os)),Ro=zod.z.array(ae(Us)),Rp={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Cp=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),Sp={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},xp=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Co=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Cp.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Ne).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Bs=zod.z.object({Milestones:K.nullish(),Linking:K.nullish(),Availability:K.nullish(),Reward:K.nullish(),Objectives:K.nullish()}).passthrough(),bp=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),So=zod.z.object({CycleIDs:zod.z.array(zod.z.string()).nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(zod.z.string()).nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:xp.nullish()}).passthrough(),xo=zod.z.object({Schedule:re.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),bo=zod.z.object({Grant:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Dp=zod.z.object({QuestID:zod.z.string().nullish(),Identity:bp.nullish(),Linking:So.nullish(),Availability:xo.nullish(),Objectives:zod.z.record(zod.z.string(),Co).nullish(),Reward:bo.nullish(),Presets:Bs.nullish()}).passthrough(),zp=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:_.nullish(),Reward:G.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Pp=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:_.nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:Bs.nullish(),PointsToken:zt.nullish()}).passthrough(),vp=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish(),Linking:zod.z.record(zod.z.string(),So).nullish(),Availability:zod.z.record(zod.z.string(),xo).nullish(),Reward:zod.z.record(zod.z.string(),bo).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Co)).nullish()}).passthrough(),Tp=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Gate:_.nullish(),PointsToken:zt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),zp).nullish(),Phases:zod.z.record(zod.z.string(),Pp).nullish(),Presets:Bs.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fi=zod.z.object({Cycles:zod.z.record(zod.z.string(),Tp).nullish(),Quests:zod.z.record(zod.z.string(),Dp).nullish(),Presets:vp.nullish()}).passthrough(),Ze={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Ip={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},kp=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),wp={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Mp=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),Ap={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},Op=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),Up={GameLoop:"GameLoop"},Bp={Raid:"Raid",Attack:"Attack"},Lp=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qp=zod.z.object({Mode:kp.nullish(),Triggers:zod.z.array(Ne).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),Ep=zod.z.object({Grant:G.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Gp=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),Np=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:Gp.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),jp=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),Ls=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:Lp.nullish(),Completion:qp.nullish(),Effects:Ep.nullish(),Script:Np.nullish(),Policy:jp.nullish()}).passthrough(),Fp=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Do=zod.z.object({Schedule:re.nullish(),Gate:_.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Ne.nullish()}).passthrough(),zo=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Mp.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Po=zod.z.object({Grant:G.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),Vp=zod.z.object({Availability:K.nullish(),Policy:K.nullish(),Reward:K.nullish(),Steps:K.nullish()}).passthrough(),_p=zod.z.object({FlowID:zod.z.string().nullish(),Identity:Fp.nullish(),Availability:Do.nullish(),Policy:zo.nullish(),Steps:zod.z.record(zod.z.string(),Ls).nullish(),Reward:Po.nullish(),Presets:Vp.nullish()}).passthrough(),Wp=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),Qp=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Wp.nullish()}).passthrough(),Kp=zod.z.object({Availability:zod.z.record(zod.z.string(),Do).nullish(),Policy:zod.z.record(zod.z.string(),zo).nullish(),Reward:zod.z.record(zod.z.string(),Po).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Ls)).nullish()}).passthrough(),vo=zod.z.object({Flows:zod.z.record(zod.z.string(),_p).nullish(),Settings:Qp.nullish(),Presets:Kp.nullish()}).passthrough(),Hp=zod.z.object({}).passthrough().transform(o=>o),To=zod.z.object({FlowID:zod.z.string(),Status:Op,CurrentStepID:zod.z.string().nullish(),CurrentStep:Ls.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),Io=zod.z.object({State:Hp.nullish(),Flows:zod.z.array(To).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),gt=zod.z.object({Flow:To.nullish()}).passthrough(),ko=zod.z.object({FlowID:zod.z.string().nullish(),Granted:v.nullish()}).passthrough(),wo=zod.z.array(ae(gt)),Mo=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),je={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var gi=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var yi=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Ao(o){return o===429||o>=500&&o<=599}function qs(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function Es(o){return new Promise(e=>setTimeout(e,o))}var $p=12e3,Zp=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(As).nullish(),TutorialProgress:zod.z.array(Mo).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),Ri=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new yi;inFlightRequests=0;sessionRefreshHandler=null;constructor(e){this.baseUrl=e.baseUrl,this.emitter=e.emitter,this.fetchImpl=e.fetchImpl??globalThis.fetch.bind(globalThis),this.debugLogging=e.debugLogging??false,this.throttler=new gi(e.throttleMs),this.clientPlatform=e.clientPlatform??it.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),x=r.ticket??null,k=r.silent??!1,N=r.timeoutMs??$p,ge=r.autoRetry??!0,xe=!1,Ae=0;for(;;){let et;try{et=await this.doFetch(a,p,x,N);}catch{if(ge&&Ae<3){Ae++,await Es(qs(Ae));continue}return this.connectionFailure("Internet Connection Error",k)}let tt=et.status;if(tt>=200&&tt<300)return await this.parseSuccess(et,i,k,e);if(tt===401){if(!xe&&this.sessionRefreshHandler){xe=!0;let at=null;try{at=await this.sessionRefreshHandler();}catch{at=null;}if(at){x=at;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Ao(tt)){if(ge&&Ae<3){Ae++,await Es(qs(Ae));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${tt})`,k)}return await this.handleWebError(et,tt,k)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,i,r){let s=new AbortController,a=setTimeout(()=>{s.abort();},r);try{let p={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return i&&(p.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",i)}let p=Zp.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let xe=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",xe),n("server",xe)}let x=p.data.QuestProgress;x&&x.length>0&&this.emitter.emit("quest:systemProgress",x);let k=p.data.TutorialProgress;k&&k.length>0&&this.emitter.emit("tutorial:systemProgress",k);let N=p.data.StateVersions;N&&Object.keys(N).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:N});let ge=t.safeParse(p.data.Data);if(!ge.success){let xe=`Validation error (${r}): ${ge.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",xe),i||this.emitter.emit("error:global",xe),n("validation",xe)}return mt(ge.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;r=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{r=`HTTP ${t}: ${s}`;}}catch{}return i||this.emitter.emit("error:global",r),n("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),n("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),n("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function Nt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function ei(o){return `${Nt(o)}T00:00:00.000Z`}function Uo(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Bo(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function Lo(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,x=new Map,k=new Map,N=new Map,ge=new Map,xe=new Map,Ae=new Map,et=new Map,tt=e.Grant?.PremiumTiers??[],at=tt.length;for(let ue=0;;ue++){let ye,Y;if(ue===0)ye=e.Grant?.Standard?.Entries,Y=false;else if(ue-1<at)ye=tt[ue-1]?.Resources?.Entries,Y=false;else if(ue===1+at)ye=e.Consume?.Standard?.Entries,Y=true;else break;if(ye)for(let $ of ye){if($.Type==null)continue;let Z=Math.max(0,$.Amount??0);if(!(Z<=0))switch($.Type){case "VirtualCurrency":{if(!$.CurrencyID)continue;let J=Y?x:p;J.set($.CurrencyID,(J.get($.CurrencyID)??0)+Z);break}case "CryptoCurrency":{if(!$.CurrencyID)continue;let J=Y?N:k;J.set($.CurrencyID,(J.get($.CurrencyID)??new Ci__default.default(0)).plus(Z));break}case "Item":{if(!$.ItemID)continue;let J=Yp(t,$.CatalogID,$.ItemID),te=(J?J.IsStackable??true:true)?Y?xe:ge:Y?et:Ae;te.set($.ItemID,(te.get($.ItemID)??0)+Z);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||x.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ue of new Set([...p.keys(),...x.keys()])){let ye=p.get(ue)??0,Y=x.get(ue)??0,$=ye-Y,Z=s.VirtualCurrencies[ue];Z?(Z.Amount+=$,Z.UpdatedAt=a,Z.Daily&&Nt(Z.Daily.PeriodStartUtc)===Nt(i)?(Z.Daily.Earned+=ye,Z.Daily.Spent+=Y):Z.Daily={PeriodStartUtc:ei(i),Earned:ye,Spent:Y}):s.VirtualCurrencies[ue]={Amount:$,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:ei(i),Earned:ye,Spent:Y}};}}if(r.ccChanged=k.size>0||N.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ue of new Set([...k.keys(),...N.keys()])){let ye=k.get(ue)??new Ci__default.default(0),Y=N.get(ue)??new Ci__default.default(0),$=ye.minus(Y),Z=s.CryptoCurrencies[ue];Z?(Z.Amount=new Ci__default.default(Z.Amount).plus($).toString(),Z.UpdatedAt=a):s.CryptoCurrencies[ue]={Amount:$.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=ge.size>0||xe.size>0||Ae.size>0||et.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ue=s.UnstackableItems,ye=new Set([...ge.keys(),...xe.keys(),...Ae.keys(),...et.keys()]);for(let Y of ye){let $=(ge.get(Y)??0)-(xe.get(Y)??0),Z=(Ae.get(Y)??0)-(et.get(Y)??0),J=$+Z,Ge=s.Items[Y];Ge?($!==0&&(Ge.StackableAmount+=$),Z!==0&&(Ge.UnstackableAmount+=Z),J!==0&&(Ge.TotalAmount+=J)):s.Items[Y]={StackableAmount:Math.max(0,$),UnstackableAmount:Math.max(0,Z),TotalAmount:Math.max(0,J)};}for(let[Y,$]of et){if($<=0)continue;let Z=Object.values(ue).filter(J=>J.ItemID===Y&&J.EquippedSlot==null&&(J.ExpiresAt==null||new Date(J.ExpiresAt)>i)).sort(Jp).slice(0,$).map(J=>J.ItemInstanceID);for(let J of Z)delete ue[J];}for(let[Y,$]of Ae){let Z=Xp(t,Y);for(let J=0;J<$;J++){let Ge=M();ue[Ge]={ItemInstanceID:Ge,ItemID:Y,CatalogID:Z,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Lc=o.EventToken;for(let ue=0;;ue++){let ye,Y;if(ue===0)ye=e.Grant?.Standard?.EventTokens,Y=false;else if(ue-1<at)ye=tt[ue-1]?.Resources?.EventTokens,Y=false;else if(ue===1+at)ye=e.Consume?.Standard?.EventTokens,Y=true;else break;if(!(!ye||ye.length===0))for(let $ of ye){let Z=$.Address;if(!Z||Z.Type==null)continue;let J=$.Amount??0;if(J<=0)continue;let Ge=ed(Lc,Z.Type);if(!Ge)continue;let te=Ge[Z.EntityID];te||(te={},Ge[Z.EntityID]=te),te.Balance??={Current:0,TotalEarned:0,TotalSpent:0},te.Daily??={Date:ei(i),TotalEarned:0},te.Meta??={};let Zt=$.Source&&$.Source.length>0?$.Source:"CustomAction";Y?(te.Balance.Current-=J,te.Balance.TotalSpent+=J):(te.Balance.Current+=J,te.Balance.TotalEarned+=J,Nt(te.Daily.Date)!==Nt(i)&&(te.Daily={Date:ei(i),TotalEarned:0}),te.Daily.TotalEarned+=J,te.Daily.EarnedBySource??={},te.Daily.EarnedBySource[Zt]=(te.Daily.EarnedBySource[Zt]??0)+J,te.Daily.TriggersBySource??={},te.Daily.TriggersBySource[Zt]=(te.Daily.TriggersBySource[Zt]??0)+1,te.Daily.LastTriggerBySource??={},te.Daily.LastTriggerBySource[Zt]=a,te.Meta.JoinedAtUtc||(te.Meta.JoinedAtUtc=a),te.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function Jp(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function Yp(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let s=r.Items?.[t];if(s)return s}}}function Xp(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function ed(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function Gs(o,e){return o===e||o.startsWith(`${e}:`)}var Si=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=Lo(this.currentState,e,t,i);r.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),r.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(r.vcChanged||r.ccChanged||r.itemsChanged||r.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof Ci__default.default?t:new Ci__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new Ci__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=Uo(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},this.markMilestoneClaimed(i.Milestone,t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={};for(let a of i.ClaimedPointMilestoneIDs??[])this.markMilestoneClaimed(s.Milestone,a);}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(Gs(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,s]of Object.entries(this.currentState.EventToken.TimedEvent))!Gs(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){e.Claims??={};let i=e.Claims[t]??={};i.ClaimedAt??=new Date().toISOString(),i.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.PendingActivationReward=false,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var xi=class{config=null;sections=new Map;itemDefs;currencyDefs;get titlePublicConfiguration(){return this.config}patchSection(e,t){this.sections.set(e,t);}getSection(e){return this.sections.get(e)}applyTitlePublicConfiguration(e){this.config=e&&typeof e=="object"?e:null;}get itemDefinitions(){return this.itemDefs??this.config?.Item??void 0}applyItemDefinitions(e){this.itemDefs=e;}get currencyDefinitions(){return this.currencyDefs??this.config?.Currency??void 0}applyCurrencyDefinitions(e){this.currencyDefs=e;}};var bi=class{user;config;constructor(e){this.user=new Si(e),this.config=new xi;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Di=class{constructor(e,t){this.storage=e;this.authTypeKey=`Saved_AuthType_${t}`,this.emailKey=`Saved_Auth_Email_${t}`,this.passwordKey=`Saved_Auth_Password_${t}`;}storage;authTypeKey;emailKey;passwordKey;get lastAuthType(){let e=this.storage.getString(this.authTypeKey);return td(e)?e:Ce.None}saveAuthType(e){this.storage.setString(this.authTypeKey,e);}get savedEmail(){return this.storage.getString(this.emailKey)??""}get savedPassword(){return this.storage.getString(this.passwordKey)??""}saveEmailAndPassword(e,t){this.storage.setString(this.emailKey,e),this.storage.setString(this.passwordKey,t);}clear(){this.storage.remove(this.authTypeKey),this.storage.remove(this.emailKey),this.storage.remove(this.passwordKey);}};function td(o){return o!==null&&Object.values(Ce).includes(o)}var id=8,rd=100,sd=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,qo=["GameLoop"],zi=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=Ce.None;sessionEmail="";sessionPassword="";pendingRegistration=null;get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),Attribution:this.ctx.acquisition.buildForLogin(this.ctx.settings.appVersion)}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(Ce.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return n("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Ce.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);return r.ok?(this.pendingRegistration={email:e,password:t},mt({codeTtlMinutes:r.data.CodeTtlMinutes??0,resendCooldownSeconds:r.data.ResendCooldownSeconds??0})):r}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.VerificationCode=t;let r=await this.ctx.api.authentication.confirmEmailRegistration(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Ce.Email);return s.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,s}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let i=await this.ctx.api.authentication.resendVerificationCode(t);return i.ok?mt(void 0):i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(r);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(Ce.Wallet)):s}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Ce.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case Ce.Email:return this.loginWithEmail(t,i);case Ce.Device:case Ce.None:return this.loginWithDeviceID();case Ce.Telegram:return this.loginWithTelegram();default:return Promise.resolve(n("client",`Cannot auto-login: last session used "${e}", which requires a fresh token from the platform SDK. Obtain a new token and call the matching login method (e.g. loginWithGoogle) instead of autoLogin().`))}}async refreshSession(){if(this.refreshing)return null;let e=this.sessionAuthType!==Ce.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===Ce.None)return null;this.refreshing=true;try{return (await this.replay(e,this.sessionEmail||this.ctx.authStore.savedEmail,this.sessionPassword||this.ctx.authStore.savedPassword)).ok&&this.authContext?this.authContext.clientSessionTicket:null}catch{return null}finally{this.refreshing=false;}}logout(){this.authContext=null,this.forgetSession(),this.ctx.authStore.clear(),this.ctx.data.reset(),this.ctx.emitter.emit("auth:loggedOut",void 0);}static isValidEmail(e){return e.length>0&&sd.test(e)}static isValidPasswordLength(e){return e.length>=id&&e.length<=rd}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=Ce.None,this.sessionEmail="",this.sessionPassword="";}applyAuthContext(e){this.authContext={userID:e.TitleUserID,clientSessionTicket:e.TitleClientSessionTicket,clientSessionTicketExpiration:e.TitleClientSessionTicketExpiration,platformUserID:e.PlatformUserID??void 0,platformAuthToken:e.PlatformAuthToken??void 0,platformAuthTokenExpiration:e.PlatformAuthTokenExpiration??void 0};}async fetchAndApplyClientState(e){let t=await this.ctx.userService.getClientStateExcept(qo,qo);return t.ok&&(this.sessionAuthType=e,this.rememberSession?this.ctx.authStore.saveAuthType(e):this.ctx.authStore.clear(),this.ctx.emitter.emit("auth:loggedIn",void 0)),t}};var nd="idos:cfg",jt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Eo(t)}`:e&&e.length>0?`f:${Eo(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${nd}:${this.titleId}:${e}`}};function Eo(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var Go="idos:loc",Ft=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,s]of Object.entries(t))typeof s=="number"&&s>0&&(i[r]=s);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${Go}:${this.titleId}:${e}`}versionsKey(){return `${Go}:${this.titleId}:versions`}};var od="idos:state",Pi=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let s={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${od}:${this.titleId}:${e}`}};function ad(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,s]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=s);return i}function js(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[s,a]of Object.entries(t))i[s]===a&&s in e&&(r[s]=e[s]);return r}function ld(o){return {...o??{}}}function Fs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var vi=class{constructor(e){this.cache=e;}cache;loadedFor=null;epoch=null;versions={};state=null;dirty=false;async load(e){if(this.loadedFor===e)return;let t=await this.cache.read(e);this.loadedFor=e,this.epoch=t?.e??null,this.versions=t?{...t.v}:{},this.state=t?.s??null,this.dirty=false;}get cachedState(){return this.state}get currentEpoch(){return this.epoch}versionsFor(e){if(!this.epoch)return;let t=ad(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let s=this.versions[i];s!==void 0&&r===s+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=ld(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var No=n("server","Title configuration is unavailable (CDN and API both failed)."),Ti=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:M()}:null}get configCache(){return this.cache??=new jt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new Ft(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new vi(new Pi(this.ctx.settings.configStorage,this.ctx.settings.titleID))}versionStore;noteStateVersions(e,t){this.ctx.auth.context?.userID&&this.stateStore.currentEpoch&&this.stateStore.noteMutation(e,t);}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=jt.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),s=await this.ctx.api.user.getClientState(e);if(!s.ok)return s;let a=await this.resolveTitleConfig(s.data,t,i,{Fields:e.TitleFields});return a==null?No:(this.finishStateHandshake(s.data,r),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(r),s)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=js(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=Fs(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let s=e.TitleConfigVersion;if(i&&s&&i.v===s)return i.c;if(e.TitleConfigUrl){let p=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(p!=null)return s&&await this.configCache.write(t,s,p),p}let a=await this.fetchConfigFromApi(r);return a!=null?(s&&await this.configCache.write(t,s,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=jt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let x=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return x==null?No:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,x,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,x=s.Locale??e;return p>0&&await this.localizationCache.write(x,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=js(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=s;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=Fs(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,x=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let k=this.ctx.data.user.state;s&&k&&k.GameLoop==null&&(k.GameLoop=p);let N=this.ctx.data.config.titlePublicConfiguration;a&&N&&N.GameLoop==null&&(N.GameLoop=x),this.ctx.emitter.emit("user:clientStateReceived",e);}};var ki=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,s,a){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===He.Crypto||i===He.Crypto)return n("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${M()}`},x=await this.ctx.api.currency.convert(p);if(x.ok){let k=x.data,N={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:k.SourceID,Amount:k.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:k.TargetID,Amount:k.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(N,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",k);}return x}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof Ci__default.default?s:new Ci__default.default(s);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return n("client","Source and target must differ.");if(e===He.Virtual&&i===He.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===He.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${M()}`},k=await this.ctx.api.currency.cryptoConvert(x);if(k.ok){let N=k.data,ge=[],xe=[];if(N.SourceType===He.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:N.SourceID,Amount:Math.trunc(Number(N.SourceSpent))}),N.TargetType===He.Virtual&&xe.push({Type:"VirtualCurrency",CurrencyID:N.TargetID,Amount:Math.trunc(Number(N.TargetCredited))}),ge.length>0||xe.length>0){let Ae={Consume:ge.length>0?{Standard:{Entries:ge}}:null,Grant:xe.length>0?{Standard:{Entries:xe}}:null};this.ctx.data.user.applyResourceOperation(Ae,this.ctx.data.config.itemDefinitions);}N.SourceType===He.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.SourceID,new Ci__default.default(N.SourceSpent).negated(),N.ServerTimeUtc),N.TargetType===He.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.TargetID,new Ci__default.default(N.TargetCredited),N.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",N);}return k}};var wi=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,i){let r=e.trim();if(!r)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:r,SelectedOptionID:i,RelatedEntityID:`upgrade_item_${r}_${M()}`};t&&t.length>0&&(s.FodderInstanceIDs=[...t]);let a=await this.ctx.api.item.upgradeLevel(s);return a.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",a.data)),a}async upgradeLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var ud="Store",Mi=class{constructor(e){this.ctx=e;}ctx;storefront=null;storefrontLoadedAt=0;async purchase(e,t=1,i){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,StoreID:i?.slot?.storeID,SectionID:i?.slot?.sectionID,SlotID:i?.slot?.slotID,RelatedEntityID:`store_buy_${e}_${r.userID}_${M()}`},a=await this.ctx.api.store.purchase(s);if(a.ok){let p=a.data;this.ctx.data.user.patchStorePurchase(e,t,p.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",p);}return a}async purchaseBatch(e){if(!e||e.length===0)return n("client","purchases is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ud,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getStorefront(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getStorefront(e);return t.ok&&(this.storefront=t.data,this.storefrontLoadedAt=Date.now(),this.ctx.emitter.emit("store:storefrontLoaded",t.data)),t}get cachedStorefront(){return this.storefront}nextRefreshAtUtc(){let e=null;for(let t of this.storefront?.Stores??[])for(let i of t.Sections??[])for(let r of i.Slots??[]){let s=r.RefreshesAtUtc;s&&(e===null||Date.parse(s)<Date.parse(e))&&(e=s);}return e}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.store.getUserState(e);return t.ok&&(this.ctx.data.user.applyStore(t.data),this.ctx.emitter.emit("store:userStateLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ai=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID,TransactionID:i?.transactionID},s=await this.ctx.api.purchase.validatePurchase(r);return s.ok&&s.data.Granted&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),s}async validatePurchasesBatch(e){if(!e||e.length===0)return n("client","receipts is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e};return this.ctx.api.purchase.validatePurchasesBatch(t)}};var Oi=class{constructor(e){this.ctx=e;}ctx;get platform(){return this.ctx.clientPlatform}availableOptions(e){return e?Object.entries(e).filter(([,t])=>t!=null).map(([t,i])=>({...i,OptionID:i.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,i)=>(t.OptionID??"").localeCompare(i.OptionID??"")):[]}isAvailable(e){if(!e)return false;let t=e.AllowedPlatforms;return !t||t.length===0?true:t.includes(this.platform)}requirementOf(e){let t=this.storeProductOf(e.Cost);return t?{option:e,kind:"store",productID:t}:{option:e,kind:"resources",shortfall:this.cryptoShortfallOf(e.Cost)??void 0}}storeProductOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t)if(i?.Type===li.Purchase&&i.ProductID)return i.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t){if(i?.Type!==li.CryptoCurrency||!i.CurrencyID)continue;let r=Number(i.Amount??0);if(!(r>0))continue;let s=this.cryptoBalance(i.CurrencyID);return s>=r?null:{currencyID:i.CurrencyID,required:r,available:s,missing:r-s}}return null}cryptoBalance(e){let i=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(i?.Amount??0)}};var cd="Lootbox",Ui=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(cd,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i,r){if(!e)return n("client","LootboxID is required.");if(t<1)return n("client","Count must be at least 1.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,Payment:r,RelatedEntityID:`lootbox_${e}_${i??"default"}_${M()}`},a=await this.ctx.api.lootbox.open(s);if(a.ok){let p=a.data;p.TriggeredPity&&p.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,p.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(p.Inventory),this.ctx.emitter.emit("lootbox:opened",p);}return a}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var pd="Reward";function Vs(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Bi=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(pd,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${M()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchDailyCalendarState(s.CalendarID,s.DailyState),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",s);}return r}async collectIdleAccrual(e){if(!Vs(e))return n("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${M()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!Vs(e))return n("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${M()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!Vs(e))return n("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${M()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var dd="Tutorial",Li=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(dd,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${M()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!t||t.length===0)return n("client","stepIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${M()}`},s=await this.ctx.api.tutorial.completeStepsBatch(r);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${M()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let s=e?.trim(),a=t?.trim();if(!s)return n("client","FlowID is required.");if(!a)return n("client","StepID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let p={...this.ctx.buildAuthedBaseRequest(),FlowID:s,StepID:a};r?.relatedEntityID&&(p.RelatedEntityID=r.relatedEntityID);let x=await i(p);return x.ok&&(this.applyFlowView(x.data),this.ctx.emitter.emit("tutorial:stepChanged",x.data)),x}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var qi=class{constructor(e){this.ctx=e;}ctx;async getState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.getCommunityMarketingState(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:stateLoaded",t.data),t}async getEarnings(e=0){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e>0&&(t.Limit=e);let i=await this.ctx.api.communityMarketing.getEarnings(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:earningsLoaded",i.data),i}async claim(e){if(!e)return n("client","campaignID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CampaignID=e;let i=await this.ctx.api.communityMarketing.claim(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:claimed",i.data),i}async withdrawCryptoReward(e,t,i){if(!e)return n("client","campaignID is required.");if(!t)return n("client","walletAddress is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.CampaignID=e,r.WalletAddress=t,i&&(r.Amount=i);let s=await this.ctx.api.communityMarketing.withdrawCryptoReward(r);return s.ok&&this.ctx.emitter.emit("communityMarketing:withdrawn",s.data),s}async checkJoinEligibility(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.checkJoinEligibility(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:eligibilityChecked",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hd="Chat",Ei=class{constructor(e){this.ctx=e;}ctx;cursors=new Map;async getChatDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.chat.getChatDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(hd,t.data),this.ctx.emitter.emit("chat:definitionsLoaded",t.data)),t}async getChannels(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&(t.Locale=e);let i=await this.ctx.api.chat.getChannels(t);return i.ok&&this.ctx.emitter.emit("chat:channelsLoaded",i.data),i}async poll(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&(t.Locale=e),this.cursors.size>0&&(t.Cursors=[...this.cursors.values()]);let i=await this.ctx.api.chat.poll(t);if(!i.ok)return i;for(let r of i.data.Rooms??[])r.NextCursor&&r.RoomID&&this.cursors.set(r.RoomID,r.NextCursor),r.Messages&&r.Messages.length>0&&this.ctx.emitter.emit("chat:messages",r);return i}async getHistory(e,t,i){let r=this.baseRequest();return r?(r.RoomID=e,t&&(r.Before=t),i&&(r.Limit=i),this.ctx.api.chat.getHistory(r)):n("unauthorized","Not logged in.")}async sendMessage(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ChannelID=e,r.Text=t,i&&(r.Locale=i);let s=await this.ctx.api.chat.sendMessage(r);return s.ok&&this.ctx.emitter.emit("chat:sent",s.data),s}async sendDirect(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.Text=t;let r=await this.ctx.api.chat.sendMessage(i);return r.ok&&this.ctx.emitter.emit("chat:sent",r.data),r}async openDirectChannel(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.openDirectChannel(t)):n("unauthorized","Not logged in.")}async getConversations(){let e=this.baseRequest();return e?this.ctx.api.chat.getConversations(e):n("unauthorized","Not logged in.")}async markRead(e,t){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.Cursors=[t??this.cursors.get(e)??{RoomID:e}];let r=await this.ctx.api.chat.markRead(i);return r.ok&&this.ctx.emitter.emit("chat:read",{roomID:e}),r}async joinChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.joinChannel(t)):n("unauthorized","Not logged in.")}async leaveChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.leaveChannel(t)):n("unauthorized","Not logged in.")}async reportMessage(e,t,i,r){let s=this.baseRequest();return s?(s.RoomID=e,s.MessageID=t,s.Reason=i,r&&(s.Comment=r),this.ctx.api.chat.reportMessage(s)):n("unauthorized","Not logged in.")}async ignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.ignoreUser(t)):n("unauthorized","Not logged in.")}async unignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.unignoreUser(t)):n("unauthorized","Not logged in.")}resetCursors(){this.cursors.clear();}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var md={WebPush:"WebPush",Fcm:"Fcm",Apns:"Apns"},fd=zod.z.enum(["WebPush","Fcm","Apns"]).catch("WebPush"),gd={Player:"player",Title:"title",Creator:"creator"},Vt={GetPushConfig:"GetPushConfig",SubscribePush:"SubscribePush",UnsubscribePush:"UnsubscribePush",GetPushSubscriptions:"GetPushSubscriptions"},jo=zod.z.object({Configured:zod.z.boolean().nullish(),PublicKey:zod.z.string().nullish()}).passthrough(),yd=zod.z.object({TitleID:zod.z.string().nullish(),Topic:zod.z.string().nullish()}).passthrough(),_s=zod.z.object({EndpointHash:zod.z.string().nullish(),Transport:fd.nullish(),Locale:zod.z.string().nullish(),Topics:zod.z.array(yd).nullish()}).passthrough(),Fo=zod.z.object({Configured:zod.z.boolean().nullish(),Subscriptions:zod.z.array(_s).nullish()}).passthrough(),ut={Unsupported:"unsupported",Idle:"idle",Subscribed:"subscribed",Blocked:"blocked",Embedded:"embedded"};var Rd="IDOS_PLATFORM_PUSH_REQUEST",Cd="IDOS_PLATFORM_PUSH_RESPONSE",Vo=["https://idosgames.com","https://www.idosgames.com"];function _o(o){if(typeof window>"u"||window.self===window.top)return Promise.resolve(false);let e=window.parent;if(!e)return Promise.resolve(false);let t=`push-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;return new Promise(i=>{let r=false,s=x=>{r||(r=true,window.removeEventListener("message",a),clearTimeout(p),i(x));},a=x=>{let k=x?.data;!k||k.type!==Cd||k.requestId!==t||Vo.includes(x.origin)&&s(k.ok===true);},p=setTimeout(()=>s(false),12e4);window.addEventListener("message",a);for(let x of Vo)try{e.postMessage({type:Rd,requestId:t,titleID:o},x);}catch{}})}var Gi=class{constructor(e){this.ctx=e;}ctx;cachedConfig=null;async getConfig(e=false){if(!e&&this.cachedConfig)return this.cachedConfig;let t=this.baseRequest();if(!t)return {Configured:false,PublicKey:null};let i=await this.ctx.api.push.getPushConfig(t),r=i.ok?i.data:{Configured:false,PublicKey:null};return this.cachedConfig=r,i.ok&&this.ctx.emitter.emit("push:configLoaded",r),r}async getState(){let e=await this.getConfig();if(!e.Configured||!e.PublicKey)return ut.Unsupported;if(this.isEmbedded())return ut.Embedded;if(!this.isSupported())return ut.Unsupported;let t=Notification.permission;return t==="denied"?ut.Blocked:t!=="granted"?ut.Idle:await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()?ut.Subscribed:ut.Idle}async subscribe(e={}){let t=await this.getConfig();if(!t.Configured||!t.PublicKey)return n("client","Push notifications are not available for this title.");if(this.isEmbedded())return await _o(this.ctx.settings.titleID)?mt({Where:"portal",Subscription:null}):n("client","The portal did not complete the subscription.");if(!this.isSupported())return n("client","This browser has no Push API.");let i=await Notification.requestPermission();if(i!=="granted")return n("client",i==="denied"?"The player blocked notifications for this site.":"The player dismissed the permission prompt.");let r=await navigator.serviceWorker.register(e.swPath??"./sw.js");await navigator.serviceWorker.ready;let a=await r.pushManager.getSubscription()??await r.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:Sd(t.PublicKey)}),p=this.baseRequest();if(!p)return n("unauthorized","Not logged in.");let x=a.toJSON();p.PushEndpoint=x.endpoint,p.PushP256dh=x.keys?.p256dh,p.PushAuth=x.keys?.auth,p.PushTransport="WebPush",p.PushLocale=e.locale??navigator.language,p.PushTimezoneOffsetMinutes=-new Date().getTimezoneOffset();let k=await this.ctx.api.push.subscribePush(p);return k.ok?(this.ctx.emitter.emit("push:subscribed",k.data),mt({Where:"game",Subscription:k.data})):k}async unsubscribe(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");if(this.isSupported()){let r=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();r&&(e.PushEndpoint=r.endpoint,await r.unsubscribe());}if(!e.PushEndpoint)return n("client","This browser has no push subscription to remove.");let t=await this.ctx.api.push.unsubscribePush(e);return t.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),t}async getSubscriptions(){let e=this.baseRequest();return e?await this.ctx.api.push.getPushSubscriptions(e):n("unauthorized","Not logged in.")}async unsubscribeByHash(e){if(!e)return n("client","endpointHash is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.PushEndpointHash=e;let i=await this.ctx.api.push.unsubscribePush(t);return i.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),i}isSupported(){return typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}isEmbedded(){return typeof window<"u"&&window.self!==window.top}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};function Sd(o){let e=o.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(o.length/4)*4,"="),t=atob(e),i=new ArrayBuffer(t.length),r=new Uint8Array(i);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return i}var Ni=Object.freeze({}),ji=class{constructor(e){this.ctx=e;}ctx;table={...Ni};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new Ft(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?xd(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Ni},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let x=await this.loadTableFromApi(a);x.ok&&(p=x.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...Ni},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:M()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(Wo(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let s=r.data,a=s.Locale??Wo(e),p=s.Version??0;if(s.NotModified){let k=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:k?.t??{...Ni},fallbackLocale:s.FallbackLocale??null}}}let x=s.Entries??{};return p>0&&await this.cache.write(a,p,x),{ok:true,data:{locale:a,table:x,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function xd(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function Wo(o){return o.trim().replace(/_/g,"-").toLowerCase()}var bd="Quest",Fi=class{constructor(e){this.ctx=e;}ctx;async getQuestDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.getQuestDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(bd,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${M()}`},a=await this.ctx.api.quest.claimQuestReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchQuestStatus(p.QuestID,p.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",p);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return n("client","quests is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${M()}`},a=await this.ctx.api.quest.claimMilestoneReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchMilestoneClaimed(p.CycleID,p.MilestoneID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",p);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!r&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${M()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(s);if(a.ok){let p=a.data;this.ctx.data.user.patchGroupCompletionClaimed(p.CycleID,p.GroupCompletionID),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",p);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return n("client","MetricID is required.");if(t<0)return n("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(r);return s.ok&&(this.ctx.data.user.patchQuestProgressUpdates(s.data.Updates),this.ctx.emitter.emit("quest:progressAdded",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Dd="TimedEvent",Vi=class{constructor(e){this.ctx=e;}ctx;async getActiveEvents(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getActiveEvents(e);return t.ok&&(this.ctx.data.user.applyActiveEvents(t.data),this.ctx.emitter.emit("timedEvent:activeEventsLoaded",t.data)),t}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dd,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},k=await this.ctx.api.timedEvent.grantTokens(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",k.data)),k}async spendTokens(e,t,i){if(!t)return n("client","LteID is required.");if(i<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},s=await this.ctx.api.timedEvent.spendTokens(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",s.data)),s}async claimMilestone(e,t,i){if(!t||!i)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},s=await this.ctx.api.timedEvent.claimMilestone(r);if(s.ok){let a=s.data;this.ctx.data.user.applyResourceOperation(a.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return s}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return n("client","spends is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return n("client","grants is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourceOperation(r.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zd="Leaderboard",_i=class{constructor(e){this.ctx=e;}ctx;cycleDocID(e){return `${this.ctx.settings.titleID}_${e}`}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.leaderboard.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(zd,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let x=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),x.NewScore,x.NewScore,x.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",x);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pd="Season",Wi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Pd,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return n("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","Amount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${M()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return n("client","SeasonChainID is required.");if(t<=0)return n("client","TierNumber must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${M()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let s=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",s);}return r}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${M()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let x=p.Data?.TierNumber;p.Success&&typeof x=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,x);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vd="Premium",Qi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(vd,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,x){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let k={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:x,RelatedEntityID:`premium_iap_${e}_${t}`},N=await this.ctx.api.premium.purchaseRealMoney(k);if(N.ok){let ge=N.data;ge.Premium&&this.ctx.data.user.applyPremium(ge.Premium),this.ctx.data.user.applyResourceOperation(ge.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",ge);}return N}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Td="Character",Ki=class{constructor(e){this.ctx=e;}ctx;async getCharacterDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getCharacterDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Td,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${M()}`},r=await this.ctx.api.character.unlockCharacter(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.StatLevels??={},a.Equipment??={},s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",s);}return r}async upgradeStatLevel(e,t,i){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${M()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(r);if(s.ok){let a=s.data;this.ctx.data.user.patchCharacter(a.CharacterID,p=>{p.StatLevels??={},p.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(p.Power=a.Power),p.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return s}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${M()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let s=r.data;this.ctx.data.user.patchCharacter(s.CharacterID,a=>{a.Level=s.NewLevel,s.Power!=null&&(a.Power=s.Power),a.UpdatedAt=s.ServerTimeUtc,s.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",s);}return r}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let s=r.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockCharactersBatch(e){if(!e||e.length===0)return n("client","characterIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.Level=r.NewLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return n("client","upgrades is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,s=>{s.StatLevels??={},s.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,s]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,s);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of i)r.patchCharacterEquipment(e,s,null);r.patchCharacter(e,s=>{t.Power!=null&&(s.Power=t.Power),s.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let s of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,s,null);t.patchCharacter(i,s=>{r.Power!=null&&(s.Power=r.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Id="Match",Hi=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${M()}`},k=await this.ctx.api.match.createMatch(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",k.data)),k}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${M()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let x=p.data,k=this.ctx.data.config.itemDefinitions;if(x.Resources)this.ctx.data.user.applyResourceOperation(x.Resources,k);else if(x.ResourcesDual){let N=x.ResourcesDual;N.FromUserID===s.userID&&N.FromResult?this.ctx.data.user.applyResourceOperation(N.FromResult,k):N.ToUserID===s.userID&&N.ToResult&&this.ctx.data.user.applyResourceOperation(N.ToResult,k);}this.ctx.emitter.emit("match:instantBattleCompleted",x);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Id,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var kd="Craft",$i=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(kd,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r){if(!e)return n("client","CraftID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${s.userID}_${M()}`},p=await this.ctx.api.craft.craft(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",p.data)),p}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var wd="Collection",Zi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(wd,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1,r){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${M()}`},p=await this.ctx.api.collection.openPack(a);return p.ok&&(this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",p.data)),p}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${M()}`},a=await this.ctx.api.collection.openCollectionChest(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${M()}`},s=await this.ctx.api.collection.useCollectibleJoker(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",s.data)),s}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${M()}`},s=await this.ctx.api.collection.claimSetReward(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",s.data)),s}async claimSetRewardsBatch(e){if(!e||e.length===0)return n("client","sets is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let s of i.data)!r&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${M()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${M()}`},k=await this.ctx.api.collection.sendTradeOffer(x);return k.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",k.data),k}async cancelTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${M()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${M()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${M()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Md="CoopEvent",Ji=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Md,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return n("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return n("client","GroupID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return n("client","CoopChainID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1,r){if(!e||!t)return n("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,SelectedOptionID:r,RelatedEntityID:M()},a=await this.ctx.api.coopEvent.spin(s);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",a.data)),a}async claimObjectReward(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return n("client","GroupID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ad="DealOffer",Yi=class{constructor(e){this.ctx=e;}ctx;async getDefinition(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getDefinition(e);return t.ok&&t.data.DealOfferDefinitions&&(this.ctx.data.config.patchSection(Ad,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${M()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i,r){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=i&&i.trim().length>0?i.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:s??`deal_exec_${e}_${t}_${M()}`},p=await this.ctx.api.dealOffer.executeNode(a);return p.ok&&(p.data.Idempotent||this.ctx.data.user.applyResourceOperation(p.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",p.data)),p}async recordShow(e){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${M()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return n("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${M()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${M()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Od="Referral",Xi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(Od,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=bt.parseReferralCode(e)?.toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferrerUserID&&this.ctx.data.user.patchReferralSubscription(a.ReferrerUserID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var er=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getOutgoingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ud="TimedBoost";function Bd(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var tr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ud,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e,t){let i=e.trim();if(!Bd(i))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BoostID:i,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${i}_${M()}`},s=await this.ctx.api.timedBoost.activate(r);if(s.ok){let a=s.data;if(a.ActivatedBoost){let p=a.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(a.ActivatedBoost,p);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",a);}return s}async cleanupExpired(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ct={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Ld={Client:"Client",Server:"Server",System:"System"},qd=zod.z.enum(["Client","Server","System"]).catch("Client"),Ed=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:qd.nullish(),ExpiresAt:u.nullish()}).passthrough(),ir=zod.z.record(zod.z.string(),Ed),Qo=zod.z.object({Version:zod.z.number().nullish(),Private:ir.nullish(),Public:ir.nullish(),ReadOnly:ir.nullish()}),Ws=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:ir.nullish()}),Qs=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Gd=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Ko=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Gd).nullish()}),Ho=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),$o=zod.z.object({Results:zod.z.array(Ws).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Nd={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},jd=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),Fd=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:jd.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),rr=zod.z.object({Keys:zod.z.record(zod.z.string(),Fd).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),Je={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Vd="UserCustomData";function Zo(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var sr=class{constructor(e){this.ctx=e;}ctx;async getUserCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getUserCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Vd,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return n("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,ct.Private)}async setPublicData(e,t){return this.setData(e,t,ct.Public)}async setData(e,t,i){let r=e.trim();if(!Zo(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t==null)return n("client","Value is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},p=await(i===ct.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let x=p.data;this.ctx.data.user.patchUserCustomDataKey(i,x.KeyID,t,x.Version??0,x.ExpiresAt),this.ctx.emitter.emit(i===ct.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",x);}return p}async deleteKey(e,t){let i=e.trim();if(!Zo(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==ct.Private&&t!==ct.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(r);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),s}async batchSet(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let s=r.Bucket??ct.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return n("client","At least one item is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return n("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var _d="TitleCustomDataDefinitions",Jo=50;function Wd(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function Ks(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Qd(o){let e={};for(let[t,i]of Object.entries(o))Ks(i)||(e[t]=i);return e}var nr=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_d,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(s=>s.trim()).filter(s=>s.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(s=>!Wd(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>Jo)return n("client",`At most ${Jo} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Ks(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!Ks(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Qd(this.runtimeCache),e.Runtime=this.runtimeCache):e.Runtime&&(this.runtimeCache=e.Runtime),e.RuntimeVersion!=null&&(this.lastRuntimeVersion=e.RuntimeVersion),this.ctx.emitter.emit("titleCustomData:publicDataLoaded",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var or=class{constructor(e){this.ctx=e;}ctx;async getTitlePublicConfiguration(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getTitlePublicConfiguration(e);return t.ok&&(this.ctx.data.config.applyTitlePublicConfiguration(t.data),this.ctx.emitter.emit("title:publicConfigurationReceived",t.data)),t}async getCurrencyDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getCurrencyDefinitions(e);return t.ok&&(this.ctx.data.config.applyCurrencyDefinitions(t.data),this.ctx.emitter.emit("title:currencyDefinitionsReceived",t.data)),t}async getItemDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getItemDefinitions(e);return t.ok&&(this.ctx.data.config.applyItemDefinitions(t.data),this.ctx.emitter.emit("title:itemDefinitionsReceived",t.data)),t}async getServerTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getServerTime(e);return t.ok&&this.ctx.emitter.emit("title:serverTimeReceived",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Kd=15,Hd="GameLoop",$d="BoardDefinition",ar=class{constructor(e){this.ctx=e;}ctx;get itemDefs(){return this.ctx.data.config.itemDefinitions}async getGameLoops(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getGameLoops(e);return t.ok&&(this.ctx.data.config.patchSection(Hd,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection($d,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return n("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=Bo(new Date,Kd);this.ctx.data.user.patchBoardState(p=>{p.Position=s.NewPosition,p.CyclesCompleted=(p.CyclesCompleted??0)+(s.CyclesCompletedDelta??0),p.LastRollAtUtc=new Date().toISOString(),s.ActionRequired&&s.ActionData?p.Pending={Type:s.ActionRequired,TargetUserID:s.ActionData.TargetUserID,TargetPublicData:s.ActionData.PublicData,TargetBuildingStates:s.ActionData.TargetBuildingStates??void 0,TargetHasShield:s.ActionData.TargetHasShield??void 0,RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a}:s.SpecialModeOffer&&(p.Pending={Type:"SPECIAL",RollMultiplier:s.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:s.SpecialModeOffer.ModeID??void 0,Choices:s.SpecialModeOffer.Choices??void 0}});}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),s.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",s);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.IsBotTarget&&s.Operation?this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs):!s.IsBotTarget&&s.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(s.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",s);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(r);if(s.ok){let a=s.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return s}async boardLoopRaidFast(e){if(!e.length)return n("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let s=r.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return n("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${M()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let s=r.data;s.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(s.BuiltIndex,a=>{s.NewLevel!=null&&(a.Level=s.NewLevel),a.IsDamaged=false,s.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",s);}return r}async boardSpecialChoose(e,t){if(!e)return n("client","choiceID must not be empty.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${i.userID}_${M()}`},s=await this.ctx.api.gameLoop.boardSpecialChoose(r);if(s.ok){let a=s.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(x=>{x.ChoiceID=e,x.ChosenMode=a.Mode??"Timed",x.StartedAtUtc=a.StartedAtUtc??null,x.DurationSeconds=a.DurationSeconds??null,x.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourceOperation(a.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return s}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${M()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let s=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=s.AdViewsUsed??0,a.AccumulatedMultiplier=s.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",s);}return r}async boardSpecialClaim(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${M()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},r=await this.ctx.api.gameLoop.boardSpecialClaim(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",s);}return r}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var lr=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let s=e.trim();if(!s)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:s,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var Yo=zod.z.object({ServerTimeUtc:u,SourceType:qt,SourceID:zod.z.string(),TargetType:qt,TargetID:zod.z.string(),SourceSpent:B,FeeAmount:B,RateApplied:j,TargetCredited:B}),Xo=zod.z.object({ServerTimeUtc:u,SourceType:qt,SourceID:zod.z.string(),TargetType:qt,TargetID:zod.z.string(),SourceSpent:j,FeeAmount:j,RateApplied:j,TargetCredited:j}),ur={Convert:"Convert",CryptoConvert:"CryptoConvert"},Zd={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},ea=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Jd={Automatic:"Automatic",Manual:"Manual"},Yd=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),Xd=zod.z.object({ValueInUSD:j.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),eh=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),th=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),ih=zod.z.object({TargetCurrencyType:qt.nullish(),TargetCurrencyID:zod.z.string(),Rate:j.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),ta=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Yd.nullish(),Fee:zod.z.number().nullish(),Targets:zod.z.array(ih).nullish()}).passthrough(),ia=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),rh=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Xd.nullish(),Recharge:eh.nullish(),Conversion:ta.nullish(),Permissions:th.nullish(),Audit:ia.nullish(),Status:ea.nullish()}).passthrough(),sh=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinWithdraw:j.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),nh=zod.z.object({DailyWithdrawUsd:j.nullish(),MonthlyWithdrawUsd:j.nullish(),KycRequiredAboveUsd:j.nullish()}).passthrough(),oh=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Hs=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:j.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:j.nullish(),CommunityMarketingDepositSharePercent:j.nullish(),WithdrawalBurnPercent:j.nullish(),Networks:zod.z.array(sh).nullish(),Limits:nh.nullish(),Permissions:oh.nullish(),Conversion:ta.nullish(),Audit:ia.nullish(),Status:ea.nullish()}).passthrough(),cr=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),rh).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hs).nullish()}).passthrough();var ra=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:lt.nullish(),AllowedPlatforms:zod.z.array(ci).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ee=zod.z.record(zod.z.string(),ra),ah=zod.z.object({Store:pi,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var sa=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),$s=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:B.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),sa).nullish(),UpdatedAt:u.nullish()}).passthrough(),lh=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),uh=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:lh.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),yt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),uh).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),na=zod.z.object({Characters:zod.z.record(zod.z.string(),$s).nullish()}),Zs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:v.nullish()}),Js=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:v.nullish()}),oa=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),sa).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:yt.nullish()}),aa=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:yt.nullish()}),ch=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),la=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),ch).nullish(),Inventory:yt.nullish()}),Ys=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:v.nullish()}),ua=rt(Ys),ca=rt(Js),pa=rt(Zs),da=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),ha=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish(),BaseStatValue:zod.z.number().nullish(),ValueCurve:Pe.nullish(),RankCurve:Pe.nullish(),Requirements:zod.z.array(da).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ph=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(da).nullish(),AllowedRarityIDs:zod.z.array(zod.z.string()).nullish(),AllowedItemTags:zod.z.array(zod.z.string()).nullish(),MinItemLevel:zod.z.number().nullish(),MaxItemLevel:zod.z.number().nullish()}).passthrough(),ma=zod.z.object({Slots:zod.z.record(zod.z.string(),ph).nullish()}).passthrough(),dh=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Lore:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),hh=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),mh=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:ee.nullish()}).passthrough(),fh=zod.z.object({Stats:K.nullish(),Levels:K.nullish(),Equipment:K.nullish()}).passthrough(),fa=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish()}).passthrough(),gh=zod.z.object({CharacterID:zod.z.string(),Identity:dh.nullish(),Classification:hh.nullish(),Unlock:mh.nullish(),Presets:fh.nullish(),Equipment:ma.nullish(),Stats:zod.z.record(zod.z.string(),ha).nullish(),RankLadder:fa.nullish(),RankStatCurve:Pe.nullish(),StatMaxLevelCurve:Pe.nullish()}).passthrough(),yh=zod.z.object({Stats:zod.z.record(zod.z.string(),ha).nullish()}).passthrough(),Rh=zod.z.object({RankLadder:fa.nullish()}).passthrough(),Ch=zod.z.object({Equipment:ma.nullish()}).passthrough(),Sh=zod.z.object({Stats:zod.z.record(zod.z.string(),yh).nullish(),Levels:zod.z.record(zod.z.string(),Rh).nullish(),Equipment:zod.z.record(zod.z.string(),Ch).nullish()}).passthrough(),pr=zod.z.object({Definitions:zod.z.record(zod.z.string(),gh).nullish(),Presets:Sh.nullish()}).passthrough(),qe={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var xh={EVM:"EVM",Solana:"Solana"},bh=zod.z.enum(["EVM","Solana"]).catch("EVM"),Dh={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},zh=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),Ph={Token:"Token",Nft:"Nft"},ga=zod.z.enum(["Token","Nft"]).catch("Token"),vh={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Th=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),Ih={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},kh=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),wh={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Xs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),ya={GameTopUp:"game_topup",CommunityReward:"community_reward"};function dr(o){let e=o?.trim();return e||ya.GameTopUp}var Mh={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ra=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),Ah=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Ca=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Oh=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:bh.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ca.nullish(),NftCollections:zod.z.array(Ah).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Uh=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ca.nullish()}).passthrough(),Bh=zod.z.object({MinAccountAgeDays:zod.z.number().nullish(),MultiAccountCheckEnabled:zod.z.boolean().nullish(),BanOnSharedWithdrawalAddress:zod.z.boolean().nullish(),PendingWithdrawalTtlHours:zod.z.number().nullish()}).passthrough();var Lh=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),qh=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:j.nullish(),BalanceSource:Lh.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Eh=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(qh).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),en=zod.z.object({SystemState:Uh.nullish(),Networks:zod.z.record(zod.z.string(),Oh).nullish(),AccountSafety:Bh.nullish(),WalletLogin:Eh.nullish()}).passthrough(),Gh=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:zh.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Sa=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:ga.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:j.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Nh=zod.z.object({Status:Th.nullish(),Tier:kh.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),jh=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:j.nullish(),DepositsVolumeUsd:j.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:j.nullish(),WithdrawalsVolumeUsd:j.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),Fh=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:j.nullish(),TotalWithdrawalsVolumeUsd:j.nullish(),PerCurrency:zod.z.record(zod.z.string(),jh).nullish()}).passthrough(),Vh=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),_h=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),PerCollection:zod.z.record(zod.z.string(),Vh).nullish()}).passthrough(),Wh=zod.z.object({Tokens:Fh.nullish(),Nfts:_h.nullish()}).passthrough(),Qh=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:j.nullish(),MinBalance:j.nullish()}).passthrough(),Kh=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Qh).nullish()}).passthrough(),Hh=zod.z.object({Version:zod.z.number().nullish(),Stats:Wh.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Gh).nullish(),LastWalletLogin:Kh.nullish(),PendingWithdrawals:zod.z.array(Sa).nullish(),Kyc:Nh.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),$h=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:j,FrozenDelta:j,UpdatedAt:u}).passthrough(),hr=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),$h).nullish(),PendingAdded:Sa.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Zh=zod.z.object({Amount:j,Frozen:j,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Jh=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ra.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:j.nullish(),Status:Xs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:j.nullish(),NetPayoutAmount:j.nullish()}).passthrough(),Yh=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ra.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:j.nullish(),Status:Xs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),xa=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),tn=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(xa).nullish(),Signature:zod.z.string().nullish()}).passthrough(),rn=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(xa).nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),ba=zod.z.object({Blockchain:en.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Hs).nullish()}).passthrough(),Da=zod.z.object({State:Hh.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Zh).nullish()}).passthrough(),za=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),AmountUsd:j.nullish(),StateDelta:hr.nullish()}).passthrough(),Pa=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:v.nullish(),Inventory:yt.nullish()}).passthrough(),va=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),NetAmountNative:j.nullish(),BurnAmountNative:j.nullish(),AmountUsd:j.nullish(),ExpiresAt:u.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish(),StateDelta:hr.nullish()}).passthrough(),Ta=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:v.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish(),StateDelta:hr.nullish(),Inventory:yt.nullish()}).passthrough(),Ia=zod.z.object({TokenTransactions:zod.z.array(Jh).nullish(),NFTTransactions:zod.z.array(Yh).nullish()}).passthrough(),sn=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:j.nullish(),AmountUsd:j.nullish(),Target:zod.z.string().nullish()}).passthrough(),ka=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:ga.nullish(),EvmSignature:tn.nullish(),SolanaSignature:rn.nullish()}).passthrough(),wa=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Xs.nullish(),StateDelta:hr.nullish()}).passthrough(),Ee={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Xh="Blockchain",mr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Xh,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Ci__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=dr(s);let p=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return p.ok&&p.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(p.data.CurrencyID,new Ci__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.NetworkID=t,x.WalletAddress=i,x.Amount=r,x.Category=dr(s),a!==void 0&&(x.Level=a),p&&(x.ItemInstanceID=p);let k=await this.ctx.api.blockchain.requestNFTWithdrawal(x);return k.ok&&(this.ctx.data.user.applyResourceOperation(k.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",k.data)),k}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return n("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Se=zod.z.object({Username:zod.z.string().nullish(),Country:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Premium:zod.z.boolean().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),BoardRank:zod.z.number().nullish()}).passthrough();var em={Head:"Head",Torso:"Torso",Legs:"Legs"},fr=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),tm={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},nn=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),Oa=zod.z.object({AttackTarget:fr,DefenseTarget:fr});var im=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),rm=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:fr.nullish(),DefenseZone:fr.nullish(),HitType:im.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),sm=zod.z.object({MaxHp:zod.z.number().nullish(),CurrentHp:zod.z.number().nullish(),Damage:zod.z.number().nullish(),AttackSpeed:zod.z.number().nullish(),CritChance:zod.z.number().nullish(),CritMultiplier:zod.z.number().nullish(),Armor:zod.z.number().nullish(),DodgeChance:zod.z.number().nullish()}).passthrough(),nm=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),Aa=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:$s.nullish(),BattleStrategy:zod.z.array(Oa).nullish(),UnstackableItems:zod.z.record(zod.z.string(),nm).nullish(),Stats:sm.nullish()}).passthrough(),om=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:Re.nullish(),NetReward:Re.nullish(),BattleLog:zod.z.array(rm).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:Aa.nullish(),P2BattleProfile:Aa.nullish()}).passthrough(),Ua=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Oa).nullish(),TargetUserID:zod.z.string().nullish(),Entry:Re.nullish(),CreationCostPaid:Re.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:nn.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),Ba=zod.z.object({Status:nn,MatchID:zod.z.string(),Entry:Re.nullish(),Resources:v.nullish()}),La=zod.z.object({Match:Ua.nullish()}),qa=zod.z.object({MatchID:zod.z.string(),Status:nn,Resources:v.nullish()}),Ea=zod.z.object({Battle:om.nullish(),Resources:v.nullish(),ResourcesDual:Dt.nullish()}),on=zod.z.object({Matches:zod.z.array(Ua).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),nt={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var am=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var lm=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),um=zod.z.object({HealthStatID:zod.z.string().nullish(),DamageStatID:zod.z.string().nullish(),ArmorStatID:zod.z.string().nullish(),AttackSpeedStatID:zod.z.string().nullish(),CritChanceStatID:zod.z.string().nullish(),CritDamageStatID:zod.z.string().nullish(),DodgeStatID:zod.z.string().nullish(),AllMightStatID:zod.z.string().nullish()}).passthrough(),cm=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),pm=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish(),ArmorMode:cm.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),dm=zod.z.object({Kind:lm.nullish(),Constant:zod.z.number().nullish(),VariableID:zod.z.string().nullish(),Argument:zod.z.string().nullish(),Curve:Pe.nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),hm=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(dm).nullish()}).passthrough(),Pt=zod.z.object({Terms:zod.z.array(hm).nullish()}).passthrough(),mm=zod.z.object({Health:Pt.nullish(),Damage:Pt.nullish(),Armor:Pt.nullish(),AttackSpeed:Pt.nullish(),CritChance:Pt.nullish(),CritDamage:Pt.nullish(),Dodge:Pt.nullish()}).passthrough(),Ga=zod.z.object({StatMapping:um.nullish(),Combat:pm.nullish(),Formula:mm.nullish()}).passthrough(),fm=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),an=zod.z.object({Kind:am.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:di.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),Na=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(an).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),ja=zod.z.object({PriceOptions:ee.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ie.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),gm=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:fm.nullish(),Entry:Na.nullish(),Creation:ja.nullish(),Settings:Ga.nullish()}).passthrough(),ym=zod.z.object({Rules:zod.z.record(zod.z.string(),gm).nullish(),Defaults:Ga.nullish(),EntryDefaults:Na.nullish(),CreationDefaults:ja.nullish()}).passthrough(),ln=zod.z.object({InstantBattle:ym.nullish()}).passthrough(),Fa=ln;var Rm={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},un=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),Cm={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},cn=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),Sm={Burn:"Burn",Ledger:"Ledger"},xm=zod.z.enum(["Burn","Ledger"]).catch("Burn"),yr={Item:"Item",VirtualCurrency:"VirtualCurrency"},pn=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),bm=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:B.nullish()}).passthrough(),Dm=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(an).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),zm=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:B.nullish(),Sink:xm.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),bm).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Pm=zod.z.object({AllowedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedItemIDs:zod.z.array(zod.z.string()).nullish(),AllowUnstackableWithState:zod.z.boolean().nullish()}).passthrough(),vm=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ie.nullish(),BuyLimits:ie.nullish(),ListingFeeOptions:ee.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Tm=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:B.nullish(),BidLimits:ie.nullish()}).passthrough(),Im=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ie.nullish(),FillLimits:ie.nullish()}).passthrough(),km=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ie.nullish()}).passthrough(),wm=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),dn=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:_.nullish(),Schedule:re.nullish(),PricePolicy:Dm.nullish(),Commission:zm.nullish(),Tradability:Pm.nullish(),Listings:vm.nullish(),Auctions:Tm.nullish(),BuyOrders:Im.nullish(),DirectTrades:km.nullish(),Matching:wm.nullish()}).passthrough(),Va=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:B.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),Mm=zod.z.object({BidAxisType:ui.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:B.nullish(),CurrentBid:B.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(Va).nullish()}).passthrough(),gr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Am=zod.z.object({Create:gr.nullish(),Buy:gr.nullish(),Sell:gr.nullish(),Bid:gr.nullish()}).passthrough(),Om=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Um=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Om.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:un.nullish(),Status:cn.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Se.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:B.nullish(),GoodsInstances:zod.z.array(Um).nullish(),Price:Re.nullish(),Auction:Mm.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Bm=zod.z.object({GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(un,B).nullish(),ListingCount:B.nullish(),AuctionCount:B.nullish(),BuyOrderCount:B.nullish()}).passthrough(),_a=zod.z.object({Definitions:dn.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),hn=zod.z.object({Offers:zod.z.array(pt).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Wa=zod.z.object({Groups:zod.z.array(Bm).nullish()}).passthrough(),Qa=zod.z.object({Offer:pt.nullish()}).passthrough(),Ve=zod.z.object({OfferID:zod.z.string().nullish(),Status:cn.nullish(),Settlement:Dt.nullish(),Resources:v.nullish(),CommissionTaken:Re.nullish()}).passthrough(),ti=zod.z.object({OfferID:zod.z.string().nullish(),Offer:pt.nullish(),Resources:v.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ve.nullish()}).passthrough(),Ka=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:B.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:v.nullish()}).passthrough(),Ha=zod.z.object({MyOffers:zod.z.array(pt).nullish(),MyLeadingBids:zod.z.array(pt).nullish(),MyBuyOrders:zod.z.array(pt).nullish(),IncomingTrades:zod.z.array(pt).nullish(),OutgoingTrades:zod.z.array(pt).nullish(),Claimables:zod.z.array(pt).nullish(),DrainedRefunds:zod.z.array(Va).nullish(),Limits:Am.nullish()}).passthrough(),Lm=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:un.nullish(),FinalStatus:cn.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:pn.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:B.nullish(),PricePaid:Re.nullish(),CommissionTaken:Re.nullish(),CompletedAt:u.nullish()}).passthrough(),$a=zod.z.object({Entries:zod.z.array(Lm).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),pe={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var qm="Marketplace",Rr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(qm,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.PriceBundle=r,x.DurationHours=s,x.ItemInstanceIDs=a,x.SelectedOptionID=p;let k=await this.ctx.api.marketplace.createListing(x);return this.applyCreateOfferResult(k,"marketplace:listingCreated"),k}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(r,i);if(s)return s;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.BidAxisType=r,x.BidCurrencyID=p.bidCurrencyID,x.BidCatalogID=p.bidCatalogID,x.BidItemID=p.bidItemID,x.StartingBid=s,x.DurationHours=a,x.ItemInstanceIDs=p.itemInstanceIDs,x.SelectedOptionID=p.selectedOptionID;let k=await this.ctx.api.marketplace.createAuction(x);return this.applyCreateOfferResult(k,"marketplace:auctionCreated"),k}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=s;let p=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(p,"marketplace:buyOrderCreated"),p}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","ItemID is required.");let a=this.baseRequest();if(!a)return n("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=s;let p=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(p,"marketplace:directTradeCreated"),p}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let s=await t(r);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,s.data)),s}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=yr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=yr.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):n("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cr=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return n("client","RoomID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!i)return n("client","SignalKind is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.TargetUserID=t,s.SignalKind=i,s.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(s);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let s=await this.ctx.api.multiplayer.setMemberState(r);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Za=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),Ja=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),be=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),Ya=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),Be={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var Sr=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return O(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,Za,{ticket:null})}loginWithDeviceID(e){return this.login(Be.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Be.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Be.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Be.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(Be.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(Be.RegisterWithEmail),e,Ja,{ticket:null})}confirmEmailRegistration(e){return this.login(Be.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(Be.ResendVerificationCode),e,be,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Be.RequestWalletChallenge),e,Ya,{ticket:null})}loginWithWallet(e){return this.login(Be.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Be.ForgotPassword),e,be,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Be.ResetPassword),e,be,{ticket:null})}};var Em={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},Xa=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),Gm=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),el=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),Gm).nullish(),MissingKeyMode:Xa.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),Nm=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),tl=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:Nm.nullish()}).passthrough(),xr={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},jm=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),il=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:Xa.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(jm).nullish()}).passthrough(),rl=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var mn=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:tl.nullish()}).passthrough().transform(o=>o),sl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),nl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),ol=zod.z.object({}).passthrough().transform(o=>o),al=zod.z.object({}).passthrough().transform(o=>o),ll=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),ul=zod.z.object({Username:zod.z.string()}),We={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var br=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return O(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(We.GetClientState,e.UserID),e,mn,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(We.GetClientStateExcept,e.UserID),e,mn,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(We.GetStateVersions,e.UserID),e,sl,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(We.GetUserState,e.UserID),e,nl,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(We.GetInventory,e.UserID),e,ol,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(We.GetEventTokens,e.UserID),e,al,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(We.GetUsageTime,e.UserID),e,ll,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(We.AddUsageTime,e.UserID),e,be,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(We.DeleteUserAccount,e.UserID),e,be,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(We.ChangeUsername,e.UserID),e,ul,{ticket:e.ClientSessionTicket})}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(ur.Convert,e,Yo)}cryptoConvert(e){return this.send(ur.CryptoConvert,e,Xo)}};var Fm=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),fn=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:v.nullish(),FodderConsumed:zod.z.array(Fm).nullish()}),cl=zod.z.array(ae(fn)),zr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Vm={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},_m=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Wm={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},Qm=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),Km=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Hm=zod.z.object({Networks:zod.z.record(zod.z.string(),Km).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),$m=zod.z.object({FlatBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),PercentBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Power:zod.z.number().nullish()}).passthrough(),Zm=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),UseRequirements:zod.z.record(zod.z.string(),zod.z.number()).nullish(),AllowedCharacterIDs:zod.z.array(zod.z.string()).nullish(),AllowedSlotIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Jm=zod.z.object({ValuationMode:_m.nullish(),WeightCurve:Pe.nullish(),Selection:Qm.nullish()}).passthrough(),Ym=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:ee.nullish(),CostCurve:Pe.nullish(),FlatBonusCurve:Pe.nullish(),PercentBonusCurve:Pe.nullish(),PowerCurve:Pe.nullish(),Fodder:Jm.nullish()}).passthrough(),Xm=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),ef=zod.z.object({ItemID:zod.z.string(),CatalogID:zod.z.string(),ItemClass:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),CustomData:zod.z.string().nullish(),IsStackable:zod.z.boolean().nullish(),IsTradable:zod.z.boolean().nullish(),Weight:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),NFT:Hm.nullish(),Stats:$m.nullish(),Equipment:Zm.nullish(),Upgrade:Ym.nullish(),Metadata:Xm.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),tf=zod.z.object({Items:zod.z.record(zod.z.string(),ef).nullish()}).passthrough(),Pr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),tf).nullish()}).passthrough();var vr=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",zr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,fn,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",zr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,cl,{ticket:e.ClientSessionTicket})}};var gn=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:v.nullish()}),pl=zod.z.array(ae(gn)),rf=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),sf=zod.z.object({SlotKey:zod.z.string(),InstanceKey:zod.z.string(),OfferID:zod.z.string().nullish(),Purchases:zod.z.number(),LastPurchasedAt:u}),dl=zod.z.object({Purchases:zod.z.record(zod.z.string(),rf).nullish(),Rotations:zod.z.record(zod.z.string(),sf).nullish()}).passthrough().transform(o=>o),Ct=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),yn=zod.z.object({Schedule:re.nullish(),Gate:_.nullish()}).passthrough(),nf={Fixed:"Fixed",Title:"Title",Player:"Player"},of=zod.z.object({OfferID:zod.z.string().nullish(),Weight:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),af=zod.z.object({Mode:zod.z.string().nullish(),OfferID:zod.z.string().nullish(),Pool:zod.z.array(of).nullish(),Salt:zod.z.string().nullish(),PerInstanceCap:zod.z.number().nullish()}).passthrough(),lf=zod.z.object({SlotID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Rotation:af.nullish()}).passthrough(),uf=zod.z.object({SectionID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Slots:zod.z.record(zod.z.string(),lf).nullish(),UniqueOffersInSection:zod.z.boolean().nullish()}).passthrough(),cf=zod.z.object({Sections:zod.z.record(zod.z.string(),uf).nullish()}).passthrough(),pf=zod.z.object({StoreID:zod.z.string().nullish(),Identity:Ct.nullish(),Availability:yn.nullish(),Layout:cf.nullish()}).passthrough(),df=zod.z.object({Options:ee.nullish(),CompareAt:zod.z.record(zod.z.string(),lt).nullish()}).passthrough(),hf=zod.z.object({Grant:G.nullish()}).passthrough(),mf=zod.z.object({Schedule:re.nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),ff=zod.z.object({OfferID:zod.z.string().nullish(),Identity:Ct.nullish(),Pricing:df.nullish(),Reward:hf.nullish(),Availability:mf.nullish()}).passthrough(),Tr=zod.z.object({Stores:zod.z.record(zod.z.string(),pf).nullish(),StoreOffers:zod.z.record(zod.z.string(),ff).nullish()}).passthrough(),gf=zod.z.object({PurchasedTotal:zod.z.number(),PurchasedToday:zod.z.number(),PurchasedThisRotation:zod.z.number(),RemainingTotal:zod.z.number().nullish(),RemainingToday:zod.z.number().nullish(),IsFirstPurchaseAvailable:zod.z.boolean(),SoldOut:zod.z.boolean(),AvailableAtUtc:u.nullish()}).passthrough(),yf=zod.z.object({OptionID:zod.z.string(),Name:zod.z.string().nullish(),Cost:lt.nullish(),CompareAtCost:lt.nullish(),DiscountPercent:zod.z.number().nullish(),IsFree:zod.z.boolean(),IsAdPaid:zod.z.boolean(),IsStorePaid:zod.z.boolean(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Rf=zod.z.object({OfferID:zod.z.string(),Identity:Ct.nullish(),PriceOptions:zod.z.array(yf).nullish(),Rewards:G.nullish(),State:gf.nullish()}).passthrough(),Cf=zod.z.object({SlotID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),RotationMode:zod.z.string().nullish(),RotationInstanceKey:zod.z.string().nullish(),RefreshesAtUtc:u.nullish(),RemainingThisRotation:zod.z.number().nullish(),Offer:Rf.nullish()}).passthrough(),Sf=zod.z.object({SectionID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),Slots:zod.z.array(Cf).nullish()}).passthrough(),xf=zod.z.object({StoreID:zod.z.string(),Identity:Ct.nullish(),SortOrder:zod.z.number(),ScheduleInstanceKey:zod.z.string().nullish(),ExpiresAtUtc:u.nullish(),Sections:zod.z.array(Sf).nullish()}).passthrough(),hl=zod.z.object({ServerTimeUtc:u,Stores:zod.z.array(xf).nullish(),AdCreditBalance:zod.z.number()}).passthrough(),vt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch",GetStorefront:"GetStorefront"},bf="OFFER_NOT_IN_ROTATION";var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(vt.Purchase,e,gn)}purchaseBatch(e){return this.send(vt.PurchaseBatch,e,pl)}getDefinitions(e){return this.send(vt.GetDefinitions,e,Tr)}getUserState(e){return this.send(vt.GetUserState,e,dl)}getStorefront(e){return this.send(vt.GetStorefront,e,hl)}};var Df={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},zf=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),Pf=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ie.nullish()}).passthrough(),vf=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),Tf=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:zf.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:Pf.nullish(),Refund:vf.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ml=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Tf).nullish()}).passthrough(),fl=zod.z.object({ProductID:zod.z.string().nullish(),TotalPurchases:zod.z.number().nullish(),DailyPurchases:zod.z.number().nullish(),DailyResetUtc:u.nullish(),LastPurchasedAt:u.nullish(),Owned:zod.z.boolean().nullish(),Refunded:zod.z.boolean().nullish(),PurchaseBlocked:zod.z.boolean().nullish()}).passthrough(),gl=zod.z.object({Products:zod.z.record(zod.z.string(),fl).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),If={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},kf=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),Rn=zod.z.object({ServerTimeUtc:u,Store:pi.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:kf.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:v.nullish(),ProductState:fl.nullish()}).passthrough(),yl=rt(Rn),_t={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(_t.GetDefinitions,e,ml)}getUserState(e){return this.send(_t.GetUserState,e,gl)}validatePurchase(e){return this.send(_t.ValidatePurchase,e,Rn)}validatePurchasesBatch(e){return this.send(_t.ValidatePurchasesBatch,e,yl)}};var wf=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Rl=zod.z.object({Reward:G.nullish(),Weight:zod.z.number().nullish(),AmountRange:wf.nullish()}).passthrough(),Wt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Rl).nullish()}).passthrough(),Qt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Rl).nullish()}).passthrough(),Mf=zod.z.object({RewardSlots:zod.z.array(Wt).nullish()}).passthrough(),Af=zod.z.object({PityRules:zod.z.array(Qt).nullish()}).passthrough(),wr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Mf).nullish(),PityPresets:zod.z.record(zod.z.string(),Af).nullish()}).passthrough();var Of=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Cl=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:v.nullish(),Inventory:yt.nullish(),Results:zod.z.array(v).nullish(),TriggeredPity:zod.z.array(Of).nullish()}),Uf=zod.z.object({RewardSlots:K.nullish(),PityRules:K.nullish()}).passthrough(),Bf=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:B.nullish()}).passthrough(),Lf=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:ee.nullish(),RewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Uf.nullish(),RewardMultiplier:hi.nullish(),SupplyLimits:zod.z.array(Bf).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Cn=zod.z.object({Definitions:zod.z.record(zod.z.string(),Lf).nullish(),RewardPools:wr.nullish()}).passthrough(),Sl=zod.z.object({LootboxDefinitions:Cn.nullish()}),Mr={GetDefinitions:"GetDefinitions",Open:"Open"};var Ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Mr.GetDefinitions,e,Sl)}open(e){return this.send(Mr.Open,e,Cl)}};var qf=zod.z.object({}).passthrough().transform(o=>o),Ef=zod.z.object({}).passthrough().transform(o=>o),Gf=zod.z.object({}).passthrough().transform(o=>o),Nf=zod.z.object({}).passthrough().transform(o=>o),jf=zod.z.object({}).passthrough().transform(o=>o),xl=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:qf,Resources:v.nullish()}),bl=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:B.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Ef,Resources:v.nullish()}),Dl=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Gf,Resources:v.nullish()}),zl=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:Nf,Resources:v.nullish()}),Pl=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:B.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Ff=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),Vf=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:G.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),_f=zod.z.object({CalendarID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Days:zod.z.array(Vf).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Wf=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Qf=zod.z.object({BaseRatePerSecond:zod.z.number().nullish(),PowerCoefficient:zod.z.number().nullish(),BoardRankCoefficient:zod.z.number().nullish(),EquipmentBonusEnabled:zod.z.boolean().nullish(),EquipmentCharacterID:zod.z.string().nullish(),PremiumMultipliers:zod.z.array(Wf).nullish()}).passthrough(),Kf=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:_.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Hf=zod.z.object({AccrualID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rate:Qf.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Kf.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),$f=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:G.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zf=zod.z.object({ComebackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array($f).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Jf=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxClaimsPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish(),TotalClaimLimit:zod.z.number().nullish()}).passthrough(),Yf=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:G.nullish(),Limits:ie.nullish(),PremiumLimitOverrides:zod.z.array(Jf).nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Sn=zod.z.object({TierRewards:Ff.nullish(),MilestoneRewardMultiplier:hi.nullish(),DailyCalendars:zod.z.record(zod.z.string(),_f).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Hf).nullish(),Comebacks:zod.z.record(zod.z.string(),Zf).nullish(),Claims:zod.z.record(zod.z.string(),Yf).nullish()}).passthrough(),vl=zod.z.object({RewardDefinitions:Sn.nullish()}),Tl=zod.z.object({Rewards:jf.nullish()}),dt={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(dt.GetRewardDefinitions,e,vl)}getUserRewardsState(e){return this.send(dt.GetUserRewardsState,e,Tl)}getMilestoneRewardMultiplier(e){return this.send(dt.GetMilestoneRewardMultiplier,e,Pl)}claimDailyReward(e){return this.send(dt.ClaimDailyReward,e,xl)}collectIdleAccrual(e){return this.send(dt.CollectIdleAccrual,e,bl)}claimComebackReward(e){return this.send(dt.ClaimComebackReward,e,Dl)}claimReward(e){return this.send(dt.ClaimReward,e,zl)}};var Ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(je.GetTutorialDefinitions,e,vo)}getUserTutorialState(e){return this.send(je.GetUserTutorialState,e,Io)}startFlow(e){return this.send(je.StartFlow,e,gt)}reportStepShown(e){return this.send(je.ReportStepShown,e,gt)}completeStep(e){return this.send(je.CompleteStep,e,gt)}completeStepsBatch(e){return this.send(je.CompleteStepsBatch,e,wo)}skipStep(e){return this.send(je.SkipStep,e,gt)}skipFlow(e){return this.send(je.SkipFlow,e,gt)}claimFlowReward(e){return this.send(je.ClaimFlowReward,e,ko)}resetFlow(e){return this.send(je.ResetFlow,e,gt)}};var Xf={Open:"Open",Application:"Application"},eg=zod.z.enum(["Open","Application"]).catch("Open"),tg={Pending:"Pending",Approved:"Approved",Rejected:"Rejected",Suspended:"Suspended",Left:"Left"},Il=zod.z.enum(["Pending","Approved","Rejected","Suspended","Left"]).catch("Pending"),ig={VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency"},xn=zod.z.enum(["VirtualCurrency","CryptoCurrency"]).catch("VirtualCurrency"),rg={Views:"Views",Likes:"Likes",Comments:"Comments",Shares:"Shares"};zod.z.enum(["Views","Likes","Comments","Shares"]).catch("Views");var Tt={GetCommunityMarketingState:"GetCommunityMarketingState",GetEarnings:"GetEarnings",Claim:"Claim",WithdrawCryptoReward:"WithdrawCryptoReward",CheckJoinEligibility:"CheckJoinEligibility"},sg=zod.z.object({CampaignID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IsRunning:zod.z.boolean().nullish()}).passthrough(),kl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),CreatorPortalUrl:zod.z.string().nullish(),ParticipationMode:eg.nullish(),IsCreator:zod.z.boolean().nullish(),CreatorStatus:Il.nullish(),VerificationCode:zod.z.string().nullish(),TeamID:zod.z.string().nullish(),Campaigns:zod.z.array(sg).nullish()}).passthrough(),ng=zod.z.object({Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),CountedMetrics:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ReachedMilestones:zod.z.array(zod.z.string()).nullish(),CappedBySubmissionLimit:zod.z.boolean().nullish(),CappedByCreatorLimit:zod.z.boolean().nullish()}).passthrough(),og=zod.z.object({CampaignID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),CurrencyID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),Granted:zod.z.number().nullish(),Paid:zod.z.number().nullish(),Overpaid:zod.z.number().nullish(),Claimable:zod.z.number().nullish(),BySubmission:zod.z.record(zod.z.string(),ng).nullish(),ComputedAt:zod.z.string().nullish()}).passthrough(),ag=zod.z.object({PayoutID:zod.z.string().nullish(),CampaignID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),NetworkID:zod.z.string().nullish(),PaidAt:zod.z.string().nullish()}).passthrough(),wl=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),HoldDays:zod.z.number().nullish(),Campaigns:zod.z.array(og).nullish(),Payouts:zod.z.array(ag).nullish()}).passthrough(),Ml=zod.z.object({CampaignID:zod.z.string().nullish(),PayoutID:zod.z.string().nullish(),Claimed:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:xn.nullish(),NetworkID:zod.z.string().nullish(),RemainingFraction:zod.z.number().nullish(),IdempotentReplay:zod.z.boolean().nullish(),Message:zod.z.string().nullish()}).passthrough(),lg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.string().nullish()}).passthrough(),ug=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),Signature:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(lg).nullish()}).passthrough(),cg=zod.z.object({Kind:zod.z.string().nullish(),Target:zod.z.string().nullish(),Required:zod.z.number().nullish(),Actual:zod.z.number().nullish(),Passed:zod.z.boolean().nullish()}).passthrough(),Al=zod.z.object({Passed:zod.z.boolean().nullish(),Approved:zod.z.boolean().nullish(),Status:Il.nullish(),WalletMissing:zod.z.boolean().nullish(),WalletConnectAllowed:zod.z.boolean().nullish(),Conditions:zod.z.array(cg).nullish()}).passthrough(),pg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),dg=zod.z.object({ProgramID:zod.z.string().nullish(),Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(pg).nullish(),SignatureHex:zod.z.string().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Ol=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:zod.z.number().nullish(),NetAmountNative:zod.z.number().nullish(),BurnAmountNative:zod.z.number().nullish(),AmountUsd:zod.z.number().nullish(),ExpiresAt:zod.z.string().nullish(),EvmSignature:ug.nullish(),SolanaSignature:dg.nullish()}).passthrough();var Br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CommunityMarketing",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCommunityMarketingState(e){return this.send(Tt.GetCommunityMarketingState,e,kl)}getEarnings(e){return this.send(Tt.GetEarnings,e,wl)}claim(e){return this.send(Tt.Claim,e,Ml)}checkJoinEligibility(e){return this.send(Tt.CheckJoinEligibility,e,Al)}withdrawCryptoReward(e){return this.send(Tt.WithdrawCryptoReward,e,Ol)}};var hg={Global:"Global",Announcement:"Announcement",Group:"Group"},Bl=zod.z.enum(["Global","Announcement","Group"]).catch("Global"),mg={None:"None",Language:"Language",Region:"Region"},fg=zod.z.enum(["None","Language","Region"]).catch("None"),gg={Anyone:"Anyone",Friends:"Friends"},yg=zod.z.enum(["Anyone","Friends"]).catch("Anyone"),Rg={Reject:"Reject",Mask:"Mask"},Cg=zod.z.enum(["Reject","Mask"]).catch("Reject"),Sg={Player:"Player",Publisher:"Publisher",System:"System"},xg=zod.z.enum(["Player","Publisher","System"]).catch("Player"),bg={Spam:"Spam",Abuse:"Abuse",Scam:"Scam",Inappropriate:"Inappropriate",Other:"Other"};zod.z.enum(["Spam","Abuse","Scam","Inappropriate","Other"]).catch("Other");var Dg=zod.z.object({DisplayNameKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IconPath:zod.z.string().nullish(),JoinedByDefault:zod.z.boolean().nullish()}).passthrough(),Ll=zod.z.object({Gate:_.nullish(),Schedule:re.nullish()}).passthrough(),ql=zod.z.object({Gate:_.nullish(),Limits:ie.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),El=zod.z.object({HotTailSize:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish()}).passthrough(),zg=zod.z.object({Availability:K.nullish(),Write:K.nullish(),Retention:K.nullish()}).passthrough(),Pg=zod.z.object({ChannelID:zod.z.string().nullish(),Identity:Dg.nullish(),Type:Bl.nullish(),GroupSource:zod.z.string().nullish(),Partitioning:fg.nullish(),Capacity:zod.z.number().nullish(),Availability:Ll.nullish(),Write:ql.nullish(),Retention:El.nullish(),Presets:zg.nullish()}).passthrough(),vg=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Gate:_.nullish(),WhoCanMessage:yg.nullish(),Limits:ie.nullish(),MaxLength:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish(),MaxConversations:zod.z.number().nullish()}).passthrough(),Tg=zod.z.object({BlockedTerms:zod.z.array(zod.z.string()).nullish(),BlockedTermAction:Cg.nullish(),MaxIgnoreListSize:zod.z.number().nullish(),ReportsEnabled:zod.z.boolean().nullish(),ReportLimits:ie.nullish()}).passthrough(),Ig=zod.z.object({MinIntervalSeconds:zod.z.number().nullish(),MaxMessagesPerPoll:zod.z.number().nullish(),MaxHistoryPageSize:zod.z.number().nullish()}).passthrough(),kg=zod.z.object({Availability:zod.z.record(zod.z.string(),Ll).nullish(),Write:zod.z.record(zod.z.string(),ql).nullish(),Retention:zod.z.record(zod.z.string(),El).nullish()}).passthrough(),Gl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Channels:zod.z.record(zod.z.string(),Pg).nullish(),Direct:vg.nullish(),Moderation:Tg.nullish(),Polling:Ig.nullish(),Presets:kg.nullish()}).passthrough(),wg=zod.z.object({LastReadAt:zod.z.string().nullish(),LastReadMessageID:zod.z.string().nullish(),Left:zod.z.boolean().nullish()}).passthrough(),Ul=zod.z.object({LastAt:zod.z.string().nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:zod.z.string().nullish(),TotalCount:zod.z.number().nullish(),LastTextHash:zod.z.string().nullish()}).passthrough();zod.z.object({MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish(),Ignored:zod.z.array(zod.z.string()).nullish(),Channels:zod.z.record(zod.z.string(),wg).nullish(),Limits:zod.z.record(zod.z.string(),Ul).nullish(),ReportLimits:Ul.nullish()}).passthrough();var bn=zod.z.object({RoomID:zod.z.string().nullish(),SentAt:zod.z.string().nullish(),MessageID:zod.z.string().nullish()}).passthrough(),Lr=zod.z.object({RoomID:zod.z.string().nullish(),ChannelID:zod.z.string().nullish(),MessageID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderProfile:Se.nullish(),AuthorType:xg.nullish(),Text:zod.z.string().nullish(),SentAt:zod.z.string().nullish()}).passthrough(),Mg=zod.z.object({ChannelID:zod.z.string().nullish(),RoomID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:Bl.nullish(),CanWrite:zod.z.boolean().nullish(),WriteBlockedReason:zod.z.string().nullish(),SlowModeSeconds:zod.z.number().nullish(),MaxLength:zod.z.number().nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),Nl=zod.z.object({Channels:zod.z.array(Mg).nullish(),PollIntervalSeconds:zod.z.number().nullish(),MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish()}).passthrough(),Ag=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(Lr).nullish(),NextCursor:bn.nullish(),UnreadCount:zod.z.number().nullish(),ServedFromDatabase:zod.z.boolean().nullish()}).passthrough(),jl=zod.z.object({Rooms:zod.z.array(Ag).nullish(),PollIntervalSeconds:zod.z.number().nullish()}).passthrough(),Fl=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(Lr).nullish(),NextBefore:bn.nullish()}).passthrough(),Vl=zod.z.object({Message:Lr.nullish(),Moderated:zod.z.boolean().nullish()}).passthrough(),_l=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:Se.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:Se.nullish(),LastMessage:Lr.nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),Wl=zod.z.object({Conversations:zod.z.array(Og).nullish()}).passthrough(),Kt=zod.z.object({Ignored:zod.z.array(zod.z.string()).nullish(),Cursor:bn.nullish(),Joined:zod.z.boolean().nullish()}).passthrough(),Ql=zod.z.object({ReportID:zod.z.string().nullish(),AlreadyReported:zod.z.boolean().nullish()}).passthrough(),we={GetChatDefinitions:"GetChatDefinitions",GetChannels:"GetChannels",Poll:"Poll",GetHistory:"GetHistory",GetConversations:"GetConversations",SendMessage:"SendMessage",OpenDirectChannel:"OpenDirectChannel",MarkRead:"MarkRead",JoinChannel:"JoinChannel",LeaveChannel:"LeaveChannel",ReportMessage:"ReportMessage",IgnoreUser:"IgnoreUser",UnignoreUser:"UnignoreUser"};var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Chat",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getChatDefinitions(e){return this.send(we.GetChatDefinitions,e,Gl)}getChannels(e){return this.send(we.GetChannels,e,Nl)}poll(e){return this.send(we.Poll,e,jl)}getHistory(e){return this.send(we.GetHistory,e,Fl)}getConversations(e){return this.send(we.GetConversations,e,Wl)}sendMessage(e){return this.send(we.SendMessage,e,Vl)}openDirectChannel(e){return this.send(we.OpenDirectChannel,e,_l)}markRead(e){return this.send(we.MarkRead,e,Kt)}joinChannel(e){return this.send(we.JoinChannel,e,Kt)}leaveChannel(e){return this.send(we.LeaveChannel,e,Kt)}reportMessage(e){return this.send(we.ReportMessage,e,Ql)}ignoreUser(e){return this.send(we.IgnoreUser,e,Kt)}unignoreUser(e){return this.send(we.UnignoreUser,e,Kt)}};var Er=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Push",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getPushConfig(e){return this.send(Vt.GetPushConfig,e,jo)}subscribePush(e){return this.send(Vt.SubscribePush,e,_s)}unsubscribePush(e){return this.send(Vt.UnsubscribePush,e,be)}getPushSubscriptions(e){return this.send(Vt.GetPushSubscriptions,e,Fo)}};var Gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(xr.GetLocalizationManifest,e,il)}getLocalizationTable(e){return this.send(xr.GetLocalizationTable,e,rl)}};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Ze.GetQuestDefinitions,e,fi)}getUserQuestState(e){return this.send(Ze.GetUserQuestState,e,mo)}refreshQuestCycles(e){return this.send(Ze.RefreshQuestCycles,e,be)}claimQuestReward(e){return this.send(Ze.ClaimQuestReward,e,Os)}claimQuestRewardsBatch(e){return this.send(Ze.ClaimQuestRewardsBatch,e,yo)}claimMilestoneReward(e){return this.send(Ze.ClaimMilestoneReward,e,Us)}claimMilestoneRewardsBatch(e){return this.send(Ze.ClaimMilestoneRewardsBatch,e,Ro)}claimGroupCompletionReward(e){return this.send(Ze.ClaimGroupCompletionReward,e,fo)}addQuestProgress(e){return this.send(Ze.AddQuestProgress,e,go)}};var Kl=zod.z.object({}).passthrough().transform(o=>o);var Ug=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),Bg=zod.z.object({Schedule:zod.z.array(Ug).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Lg=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),qg=zod.z.object({Milestones:K.nullish()}).passthrough(),Dn=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Category:zod.z.string().nullish(),Token:zt.nullish(),TokenSources:zod.z.array(Ne).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:qg.nullish(),BonusWindow:Bg.nullish()}).passthrough(),Eg=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Dn.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Gg=zod.z.object({TimedEventID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:re.nullish(),Content:Dn.nullish(),Events:zod.z.array(Eg).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ng=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),jg=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish()}).passthrough(),jr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Gg).nullish(),Settings:Ng.nullish(),Presets:jg.nullish()}).passthrough(),Fg=zod.z.object({Type:Xt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Dn.nullish(),Progress:Kl.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:Te.nullish(),BonusWindow:Lg.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Hl=zod.z.object({ActiveEvents:zod.z.array(Fg).nullish()}).passthrough(),$l=zod.z.object({Tokens:zod.z.record(zod.z.string(),Kl).nullish()}),zn=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),Resources:v.nullish()}),Pn=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:v.nullish()}),Vg=zod.z.object({Type:Xt.nullish(),LteID:zod.z.string().nullish(),Resources:v.nullish()}),vn=zod.z.array(ae(Pn)),Zl=zod.z.array(ae(zn)),Jl=zod.z.array(ae(Vg)),Qe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Qe.GetActiveEvents,e,Hl)}getDefinitions(e){return this.send(Qe.GetDefinitions,e,jr)}getUserLteState(e){return this.send(Qe.GetUserLteState,e,$l)}grantTokens(e){return this.send(Qe.GrantTokens,e,v)}spendTokens(e){return this.send(Qe.SpendTokens,e,zn)}claimMilestone(e){return this.send(Qe.ClaimMilestone,e,Pn)}claimMilestonesBatch(e){return this.send(Qe.ClaimMilestonesBatch,e,vn)}claimAllMilestones(e){return this.send(Qe.ClaimAllMilestones,e,vn)}spendTokensBatch(e){return this.send(Qe.SpendTokensBatch,e,Zl)}grantTokensBatch(e){return this.send(Qe.GrantTokensBatch,e,Jl)}};var _g=zod.z.object({UserID:zod.z.string(),Score:B.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Se.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),ii=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:B.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(_g).nullish(),BracketID:zod.z.string().nullish()}),Wg=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:B.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Vr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:B.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:B.nullish(),MilestoneTokensEarned:B.nullish(),NextMilestone:Te.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Wg).nullish()}),_r=zod.z.object({LeaderboardID:zod.z.string(),NewScore:B,CycleVersion:zod.z.number()}),Wr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:v.nullish()}),Qr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:v.nullish()}),Yl=zod.z.array(ae(ii)),Xl=zod.z.array(ae(Vr)),eu=zod.z.array(ae(Wr)),tu=zod.z.array(ae(Qr)),iu=zod.z.array(ae(_r)),Qg=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ae(Wr).nullish(),Milestones:zod.z.array(ae(Qr)).nullish()}),ru=zod.z.array(Qg),Kg=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ae(ii).nullish(),Progress:ae(Vr).nullish()}),su=zod.z.array(Kg),Hg=zod.z.string(),nu=zod.z.object({Rank:zod.z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Ms.nullish()}).passthrough(),$g=zod.z.object({RankRewards:zod.z.array(nu).nullish()}).passthrough(),Zg=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Jg=zod.z.object({Milestones:K.nullish(),RankRewards:K.nullish()}).passthrough(),Yg=zod.z.object({LeaderboardID:zod.z.string(),DisplayName:zod.z.string().nullish(),ScoreDisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsEnabled:zod.z.boolean().nullish(),ScoreAggregation:Hg.nullish(),Schedule:re.nullish(),ChainEvents:zod.z.array(Zg).nullish(),Gate:_.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(nu).nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),Presets:Jg.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Ne).nullish()}).passthrough(),Xg=zod.z.object({Milestones:zod.z.record(zod.z.string(),Et).nullish(),RankRewards:zod.z.record(zod.z.string(),$g).nullish()}).passthrough(),Kr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Yg).nullish(),Presets:Xg.nullish()}).passthrough(),ve={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var Hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ve.GetDefinitions,e,Kr)}getLeaderboard(e){return this.send(ve.GetLeaderboard,e,ii)}getMyProgress(e){return this.send(ve.GetMyProgress,e,Vr)}submitScore(e){return this.send(ve.SubmitScore,e,_r)}submitScoreFromSource(e){return this.send(ve.SubmitScoreFromSource,e,_r)}claimCycleReward(e){return this.send(ve.ClaimCycleReward,e,Wr)}claimMilestone(e){return this.send(ve.ClaimMilestone,e,Qr)}getFriendsLeaderboard(e){return this.send(ve.GetFriendsLeaderboard,e,ii)}getLeaderboardsBatch(e){return this.send(ve.GetLeaderboardsBatch,e,Yl)}getProgressBatch(e){return this.send(ve.GetProgressBatch,e,Xl)}claimCycleRewardsBatch(e){return this.send(ve.ClaimCycleRewardsBatch,e,eu)}claimMilestonesBatch(e){return this.send(ve.ClaimMilestonesBatch,e,tu)}submitScoresBatch(e){return this.send(ve.SubmitScoresBatch,e,iu)}claimAllRewardsBatch(e){return this.send(ve.ClaimAllRewardsBatch,e,ru)}getOverviewBatch(e){return this.send(ve.GetOverviewBatch,e,su)}};var Tn=zod.z.object({}).passthrough().transform(o=>o),ou=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>cu).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:B.nullish(),UserState:Tn.nullish(),NextTier:zod.z.lazy(()=>uu).nullish()}).passthrough(),au=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:B.nullish(),NewStatusTokens:B.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),In=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:v.nullish()}),lu=rt(In);var uu=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:B.nullish(),TierReachedReward:G.nullish()}).passthrough(),cu=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:B.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(uu).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var ey=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Seasons:zod.z.array(cu).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:_.nullish()}).passthrough(),$r=zod.z.object({Chains:zod.z.record(zod.z.string(),ey).nullish()}).passthrough(),St={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,$r)}getActiveSeason(e){return this.send(St.GetActiveSeason,e,ou)}getUserState(e){return this.send(St.GetUserState,e,Tn)}grantStatusTokens(e){return this.send(St.GrantStatusTokens,e,au)}claimTierReward(e){return this.send(St.ClaimTierReward,e,In)}claimTierRewardsBatch(e){return this.send(St.ClaimTierRewardsBatch,e,lu)}};var ty={Apple:"Apple",Google:"Google"},pu=zod.z.object({}).passthrough().transform(o=>o),iy=zod.z.object({PremiumID:zod.z.string().nullish(),PurchaseDate:zod.z.string().nullish(),ExpirationDate:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),IsAutoRenewEnabled:zod.z.boolean().nullish()}).passthrough(),ry=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:ee.nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kn=zod.z.object({Definitions:zod.z.record(zod.z.string(),ry).nullish()}).passthrough(),du=zod.z.object({Premium:kn.nullish()}),hu=zod.z.object({ServerTimeUtc:u.nullish(),Premium:pu.nullish()}),Jr=zod.z.object({ServerTimeUtc:u.nullish(),Premium:pu.nullish(),Subscription:iy.nullish(),Resources:v.nullish()}),It={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(It.GetDefinitions,e,du)}getUserState(e){return this.send(It.GetUserState,e,hu)}activateTrial(e){return this.send(It.ActivateTrial,e,Jr)}purchaseItemOrCurrency(e){return this.send(It.PurchaseWithResources,e,Jr)}purchaseRealMoney(e){return this.send(It.PurchaseRealMoney,e,Jr)}};var Xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(qe.GetCharacterDefinitions,e,pr)}getUserCharacters(e){return this.send(qe.GetUserCharacters,e,na)}unlockCharacter(e){return this.send(qe.UnlockCharacter,e,Ys)}upgradeStatLevel(e){return this.send(qe.UpgradeStatLevel,e,Zs)}upgradeCharacterLevel(e){return this.send(qe.UpgradeCharacterLevel,e,Js)}equipItems(e){return this.send(qe.EquipItems,e,oa)}unequipItems(e){return this.send(qe.UnequipItems,e,aa)}unequipAllCharacters(e){return this.send(qe.UnequipAllCharacters,e,la)}unlockCharactersBatch(e){return this.send(qe.UnlockCharactersBatch,e,ua)}upgradeCharacterLevelsBatch(e){return this.send(qe.UpgradeCharacterLevelsBatch,e,ca)}upgradeStatLevelsBatch(e){return this.send(qe.UpgradeStatLevelsBatch,e,pa)}};var es=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(nt.CreateMatch,e,Ba)}updateMatch(e){return this.send(nt.UpdateMatch,e,La)}cancelMatch(e){return this.send(nt.CancelMatch,e,qa)}instantBattle(e){return this.send(nt.InstantBattle,e,Ea)}saveStrategy(e){return this.send(nt.SaveStrategy,e,be)}getMyMatches(e){return this.send(nt.GetMyMatches,e,on)}getAvailableMatches(e){return this.send(nt.GetAvailableMatches,e,on)}getDefinitions(e){return this.send(nt.GetDefinitions,e,Fa)}};var sy={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},mu=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),ny=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:ws.nullish()}),fu=zod.z.object({ServerTimeUtc:u,Type:mu.nullish(),CraftID:zod.z.string(),CraftedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),InputRarity:zod.z.string().nullish(),OutputRarity:zod.z.string().nullish(),Resources:v.nullish(),Results:zod.z.array(ny).nullish()}),oy=zod.z.object({CraftID:zod.z.string().nullish(),Type:mu.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:ee.nullish()}).passthrough(),wn=zod.z.object({Definitions:zod.z.record(zod.z.string(),oy).nullish()}).passthrough(),gu=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:wn.nullish()}),ts={GetDefinitions:"GetDefinitions",Craft:"Craft"};var is=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ts.GetDefinitions,e,gu)}craft(e){return this.send(ts.Craft,e,fu)}};var ay={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},ly=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),yu=zod.z.object({}).passthrough().transform(o=>o),Ht=zod.z.object({CollectibleID:zod.z.string(),Rarity:zod.z.number().nullish(),IsSpecial:zod.z.boolean().nullish(),IsDuplicate:zod.z.boolean().nullish(),CollectionCurrencyConverted:zod.z.number().nullish()}),Ru=zod.z.object({GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish()}),Cu=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(Ru).nullish(),GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish(),NewCollectionCurrencyBalance:B.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:v.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Su=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(Ru).nullish(),GrantedCollectibles:zod.z.array(Ht).nullish(),DuplicateCollectibles:zod.z.array(Ht).nullish(),CollectionCurrencyEarned:B.nullish(),NewCollectionCurrencyBalance:B.nullish(),Resources:v.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),xu=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:v.nullish()}),Mn=zod.z.object({SetID:zod.z.string(),Resources:v.nullish()}),bu=zod.z.array(ae(Mn)),Du=zod.z.object({Resources:v.nullish()}),uy=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Se.nullish(),OfferedCollectibleID:zod.z.string().nullish(),OfferedCollectibleIsSpecial:zod.z.boolean().nullish(),ReceiverUserID:zod.z.string().nullish(),RequestedCollectibleID:zod.z.string().nullish(),RequestedCollectibleIsSpecial:zod.z.boolean().nullish(),Status:ly.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),zu=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:v.nullish()}),Pu=zod.z.object({OfferID:zod.z.string(),Resources:v.nullish()}),vu=zod.z.object({OfferID:zod.z.string(),ReceivedCollectibleID:zod.z.string().nullish(),ReceivedIsSpecial:zod.z.boolean().nullish(),SentCollectibleID:zod.z.string().nullish(),SentCollectibleIsSpecial:zod.z.boolean().nullish(),Transfer:zod.z.unknown().nullish()}),Tu=zod.z.object({OfferID:zod.z.string(),Resources:v.nullish()}),An=zod.z.object({Offers:zod.z.array(uy).nullish()}),cy=zod.z.object({CollectibleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rarity:zod.z.number().nullish(),HasSpecialVersion:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish()}).passthrough(),py=zod.z.object({SetID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SortOrder:zod.z.number().nullish(),Collectibles:zod.z.array(cy).nullish(),SetCompletionReward:G.nullish()}).passthrough(),dy=zod.z.object({CollectionID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SeasonChainID:zod.z.string().nullish(),Sets:zod.z.array(py).nullish(),GrandPrize:G.nullish()}).passthrough(),Iu=zod.z.object({BonusRewardSlots:K.nullish(),PityRules:K.nullish()}).passthrough(),hy=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:ee.nullish(),BonusRewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Iu.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),my=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),fy=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array(Wt).nullish(),PityRules:zod.z.array(Qt).nullish(),Presets:Iu.nullish(),Tier:zod.z.number().nullish()}).passthrough(),gy=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),rs=zod.z.object({Collections:zod.z.record(zod.z.string(),dy).nullish(),PackTypes:zod.z.record(zod.z.string(),hy).nullish(),CollectionChests:zod.z.array(fy).nullish(),DuplicateConversions:zod.z.array(my).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(gy).nullish(),RewardPools:wr.nullish()}).passthrough(),Ie={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var ss=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ie.GetDefinitions,e,rs)}getUserState(e){return this.send(Ie.GetUserState,e,yu)}openPack(e){return this.send(Ie.OpenPack,e,Cu)}openCollectionChest(e){return this.send(Ie.OpenCollectionChest,e,Su)}useCollectibleJoker(e){return this.send(Ie.UseCollectibleJoker,e,xu)}claimSetReward(e){return this.send(Ie.ClaimSetReward,e,Mn)}claimSetRewardsBatch(e){return this.send(Ie.ClaimSetRewardsBatch,e,bu)}claimGrandPrize(e){return this.send(Ie.ClaimGrandPrize,e,Du)}sendTradeOffer(e){return this.send(Ie.SendTradeOffer,e,zu)}cancelTradeOffer(e){return this.send(Ie.CancelTradeOffer,e,Pu)}acceptTradeOffer(e){return this.send(Ie.AcceptTradeOffer,e,vu)}declineTradeOffer(e){return this.send(Ie.DeclineTradeOffer,e,Tu)}getMyTradeOffers(e){return this.send(Ie.GetMyTradeOffers,e,An)}getIncomingTradeOffers(e){return this.send(Ie.GetIncomingTradeOffers,e,An)}};var yy=zod.z.object({}).passthrough().transform(o=>o),Ry={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Cy={Active:"Active",Left:"Left",Replaced:"Replaced"},Sy=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),xy=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Se.nullish(),BuildObjectsProgress:Sy.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),by=zod.z.object({Index:zod.z.number().nullish(),OwnerUserID:zod.z.string().nullish(),CurrentProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish(),IsCompleted:zod.z.boolean().nullish()}).passthrough(),Dy=zod.z.object({Objects:zod.z.array(by).nullish()}).passthrough(),ku=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CoopChainID:zod.z.string().nullish(),CoopEventID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),Members:zod.z.array(xy).nullish(),BuildObjectsState:Dy.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),wu=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),zy=zod.z.string(),On=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Weight:zod.z.number().nullish(),MinProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish()}).passthrough(),Py=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:G.nullish()}).passthrough(),vy=zod.z.object({Objects:zod.z.array(Py).nullish(),PriceOptions:ee.nullish(),SpinnerTable:zod.z.array(On).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Ty=zod.z.object({CoopEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),EventType:zy.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:vy.nullish(),GrandPrize:G.nullish()}).passthrough(),Iy=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:re.nullish(),Events:zod.z.array(Ty).nullish(),Gate:_.nullish()}).passthrough(),Mu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:yy.nullish(),ActiveGroup:ku.nullish()}),Un=zod.z.object({ServerTimeUtc:u.nullish(),Group:ku.nullish(),SecondsRemaining:B.nullish()}),Au=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:v.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:On.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(On).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:B.nullish(),MaxProgress:B.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Bn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:v.nullish()}),Ou=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),ns=zod.z.object({Chains:zod.z.record(zod.z.string(),Iy).nullish()}).passthrough(),Ye={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var os=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ye.GetDefinitions,e,ns)}getActiveEvent(e){return this.send(Ye.GetActiveEvent,e,wu)}getUserState(e){return this.send(Ye.GetUserState,e,Mu)}getGroupState(e){return this.send(Ye.GetGroupState,e,Un)}joinOrCreateGroup(e){return this.send(Ye.JoinOrCreateGroup,e,Un)}spin(e){return this.send(Ye.Spin,e,Au)}claimObjectReward(e){return this.send(Ye.ClaimObjectReward,e,Bn)}claimGrandPrize(e){return this.send(Ye.ClaimGrandPrize,e,Bn)}leaveGroup(e){return this.send(Ye.LeaveGroup,e,Ou)}};var ky={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},wy={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},My=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),Ay=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Uu=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),My).nullish(),Tracks:zod.z.record(zod.z.string(),Ay).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Oy=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:Uu.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),Uy=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),By=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),Uy).nullish()}).passthrough(),Ly=zod.z.object({Slots:zod.z.record(zod.z.string(),Oy).nullish(),OfferHistory:zod.z.record(zod.z.string(),By).nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),qy={Purchase:"Purchase",FreeClaim:"FreeClaim",RewardedVideo:"RewardedVideo",Info:"Info"},Ey={Eq:"Eq",Gte:"Gte",Lte:"Lte"},Gy=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),as=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Bu=zod.z.object({Schedule:re.nullish(),Gate:_.nullish()}).passthrough(),Lu=zod.z.object({AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Ny=zod.z.object({Identity:K.nullish(),Availability:K.nullish(),Behaviour:K.nullish()}).passthrough(),jy=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Identity:as.nullish(),Availability:Bu.nullish(),Behaviour:Lu.nullish(),Queue:zod.z.array(Gy).nullish(),Presets:Ny.nullish()}).passthrough(),Fy=zod.z.object({ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),Vy=zod.z.object({RewardedVideo:Fy.nullish()}).passthrough(),_y=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Wy=zod.z.object({Identity:K.nullish(),Graph:K.nullish(),Milestones:K.nullish()}).passthrough(),Qy=zod.z.object({Identity:K.nullish(),Pricing:K.nullish(),Reward:K.nullish()}).passthrough(),Ky=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Hy=zod.z.object({TrackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),StartValue:zod.z.number().nullish(),MinValue:zod.z.number().nullish(),MaxValue:zod.z.number().nullish(),ClampToMin:zod.z.boolean().nullish(),ClampToMax:zod.z.boolean().nullish(),HiddenFromUI:zod.z.boolean().nullish()}).passthrough(),$y=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(_y).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),qu=zod.z.object({Options:ee.nullish()}).passthrough(),Eu=zod.z.object({Grants:G.nullish(),TrackChanges:zod.z.array(Ky).nullish(),MilestonePoints:zod.z.number().nullish()}).passthrough(),Zy=zod.z.object({NodeID:zod.z.string().nullish(),Type:zod.z.string().nullish(),Identity:as.nullish(),Pricing:qu.nullish(),Reward:Eu.nullish(),Action:Vy.nullish(),UnlockRules:$y.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ie.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),Presets:Qy.nullish()}).passthrough(),Gu=zod.z.object({RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(Zy).nullish(),Tracks:zod.z.array(Hy).nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish()}).passthrough(),Nu=zod.z.object({Milestones:zod.z.record(zod.z.string(),Te).nullish(),ClaimMode:zod.z.string().nullish(),Token:zt.nullish()}).passthrough(),ju=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),Identity:as.nullish(),Graph:Gu.nullish(),Milestones:Nu.nullish(),Presets:Wy.nullish()}).passthrough(),Jy=zod.z.object({Identity:zod.z.record(zod.z.string(),as).nullish(),Availability:zod.z.record(zod.z.string(),Bu).nullish(),Behaviour:zod.z.record(zod.z.string(),Lu).nullish(),Graph:zod.z.record(zod.z.string(),Gu).nullish(),Milestones:zod.z.record(zod.z.string(),Nu).nullish(),Pricing:zod.z.record(zod.z.string(),qu).nullish(),Reward:zod.z.record(zod.z.string(),Eu).nullish()}).passthrough(),Ln=zod.z.object({Slots:zod.z.record(zod.z.string(),jy).nullish(),Offers:zod.z.record(zod.z.string(),ju).nullish(),Presets:Jy.nullish()}).passthrough(),Fu=zod.z.object({DealOfferDefinitions:Ln.nullish()}),Vu=zod.z.object({DealOffers:Ly.nullish()}),Yy=zod.z.object({EntityID:zod.z.string().nullish(),TotalEarned:zod.z.number().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),ReachedUnclaimedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Xy=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:ju.nullish(),ActivationState:Uu.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:lt.nullish(),Milestone:Yy.nullish()}).passthrough(),_u=zod.z.object({Slots:zod.z.array(Xy).nullish()}),Wu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:v.nullish()}),Qu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:v.nullish()}),Ku=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:v.nullish()}),Hu=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:v.nullish()}),$u=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:v.nullish()}),ot={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var ls=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(ot.GetDefinition,e,Fu)}getUserState(e){return this.send(ot.GetUserState,e,Vu)}getActiveDeals(e){return this.send(ot.GetActiveDeals,e,_u)}dismissDeal(e){return this.send(ot.DismissDeal,e,Qu)}executeNode(e){return this.send(ot.ExecuteNode,e,Wu)}recordShow(e){return this.send(ot.RecordShow,e,Ku)}claimMilestone(e){return this.send(ot.ClaimMilestone,e,Hu)}claimMilestonesBatch(e){return this.send(ot.ClaimMilestonesBatch,e,$u)}};var eR=zod.z.object({}).passthrough().transform(o=>o),tR=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Rate:zod.z.number().nullish(),Basis:zod.z.string().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish(),MinSourceAmount:zod.z.number().nullish(),MaxRewardPerOperation:zod.z.number().nullish(),Limits:ie.nullish()}).passthrough(),qn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:zod.z.record(zod.z.string(),Te).nullish(),SpendRewards:zod.z.array(tR).nullish()}).passthrough(),Zu=zod.z.object({ReferralDefinitions:qn.nullish()}).passthrough(),Ju=zod.z.object({Referral:eR.nullish(),InviteUrl:zod.z.string().nullish()}).passthrough(),Yu=zod.z.object({ReferralCode:zod.z.string().nullish(),ReferrerUserID:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:v.nullish()}).passthrough(),En=zod.z.object({RewardID:zod.z.string().nullish(),Resources:v.nullish()}).passthrough(),Xu=rt(En),kt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var us=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(kt.GetDefinitions,e,Zu)}getUserState(e){return this.send(kt.GetUserState,e,Ju)}activateReferralCode(e){return this.send(kt.ActivateReferralCode,e,Yu)}claimInviteReward(e){return this.send(kt.ClaimInviteReward,e,En)}claimInviteRewardsBatch(e){return this.send(kt.ClaimInviteRewardsBatch,e,Xu)}};var iR={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},rR={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},ec=zod.z.object({UserID:zod.z.string(),PublicData:Se.nullish()}),sR=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Se.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:v.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),ri=zod.z.object({Friends:zod.z.array(ec).nullish()}),nR=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),si=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:ec.nullish(),Counters:nR.nullish()}),tc=zod.z.object({Events:zod.z.array(sR).nullish()}),Xe={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var cs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Xe.GetFriendsList,e,ri)}getIncomingRequests(e){return this.send(Xe.GetIncomingRequests,e,ri)}getOutgoingRequests(e){return this.send(Xe.GetOutgoingRequests,e,ri)}getRecommendedFriends(e){return this.send(Xe.GetRecommendedFriends,e,ri)}sendFriendRequest(e){return this.send(Xe.SendFriendRequest,e,si)}acceptFriendRequest(e){return this.send(Xe.AcceptFriendRequest,e,si)}declineFriendRequest(e){return this.send(Xe.DeclineFriendRequest,e,si)}removeFriend(e){return this.send(Xe.RemoveFriend,e,si)}getTimeline(e){return this.send(Xe.GetTimeline,e,tc)}};var oR={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var $t=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),aR=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:ee.nullish(),Effect:$t.nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),lR=zod.z.object({ScheduledBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Schedule:re.nullish(),Effects:zod.z.array($t).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),uR=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array($t).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cR=zod.z.object({ChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:re.nullish(),Phases:zod.z.array(uR).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),pR=zod.z.object({TriggeredBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Sources:zod.z.array(Ne).nullish(),Effects:zod.z.array($t).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),dR=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),hR=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),dR).nullish()}).passthrough(),ps=zod.z.object({Definitions:zod.z.record(zod.z.string(),aR).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),lR).nullish(),BoostChains:zod.z.record(zod.z.string(),cR).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),pR).nullish(),Settings:hR.nullish()}).passthrough(),ic=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:$t.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var rc=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),ic).nullish()}),sc=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:ic.nullish(),Resources:v.nullish()}),mR={Scheduled:"Scheduled",Chain:"Chain"},fR=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array($t).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nc=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(fR).nullish()}),wt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var ds=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(wt.GetDefinitions,e,ps)}getActive(e){return this.send(wt.GetActive,e,rc)}getActiveWindows(e){return this.send(wt.GetActiveWindows,e,nc)}activate(e){return this.send(wt.Activate,e,sc)}cleanupExpired(e){return this.send(wt.CleanupExpired,e,be)}};var hs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Je.GetUserCustomDataDefinitions,e,rr)}getMyUserCustomData(e){return this.send(Je.GetMyUserCustomData,e,Qo)}getPublicUserCustomDataOf(e){return this.send(Je.GetPublicUserCustomDataOf,e,Ws)}setPrivateData(e){return this.send(Je.SetPrivateData,e,Qs)}setPublicData(e){return this.send(Je.SetPublicData,e,Qs)}deleteKey(e){return this.send(Je.DeleteKey,e,be)}batchSet(e){return this.send(Je.BatchSet,e,Ko)}batchDelete(e){return this.send(Je.BatchDelete,e,Ho)}batchGetPublicUserCustomDataOf(e){return this.send(Je.BatchGetPublicUserCustomDataOf,e,$o)}};var gR={Static:"Static",Runtime:"Runtime"},yR={Public:"Public",Private:"Private"},RR=zod.z.enum(["Client","Server","System"]).catch("Client"),CR=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),SR=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:RR.nullish(),ExpiresAt:u.nullish()}).passthrough(),oc=zod.z.record(zod.z.string(),SR),Gn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:oc.nullish(),Runtime:oc.nullish(),NotModified:zod.z.boolean().nullish()}),xR=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:CR.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),ms=zod.z.object({Keys:zod.z.record(zod.z.string(),xR).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),ni={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(ni.GetTitleCustomDataDefinitions,e,ms)}getPublicTitleData(e){return this.send(ni.GetPublicTitleData,e,Gn)}getPublicTitleDataKeys(e){return this.send(ni.GetPublicTitleDataKeys,e,Gn)}};var bR={Fast:"Fast",Sequential:"Sequential"},DR={Instant:"Instant",Timed:"Timed"};var zR={Hit:"Hit",Blocked:"Blocked"},PR=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),vR=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:G.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:G.nullish()}).passthrough();var TR=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:G.nullish()}).passthrough(),IR=zod.z.object({Reward:G.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(TR).nullish(),Rate:IR.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var ac=zod.z.object({}).passthrough().transform(o=>o),lc=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),ke=zod.z.object({Operation:v.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),kR=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),wR=zod.z.object({ShieldChance:zod.z.number().nullish(),DamagedBuildingChance:zod.z.number().nullish(),RankMultiplierMin:zod.z.number().nullish(),RankMultiplierMax:zod.z.number().nullish(),RankOffsetMin:zod.z.number().nullish(),RankOffsetMax:zod.z.number().nullish()}).passthrough(),MR=zod.z.object({CostMatrixTemplatesByID:zod.z.record(zod.z.string(),zod.z.array(zod.z.array(zod.z.number()))).nullish(),PerBoardGrowth:zod.z.number().nullish(),VisualTemplateCycle:zod.z.array(zod.z.string()).nullish(),EconomyScaledResources:Re.nullish(),ScaleRaidStealWithEconomy:zod.z.boolean().nullish(),ScaleAttackRewardWithEconomy:zod.z.boolean().nullish(),AttackValueFromCostMatrix:zod.z.boolean().nullish(),AttackBlockedRewardFactor:zod.z.number().nullish(),ScaleVictimLossWithEconomy:zod.z.boolean().nullish(),ScaleVictimLossWithTier:zod.z.boolean().nullish(),SynthesizedBuildingSlots:zod.z.number().nullish(),SynthesizedBuildingMaxLevel:zod.z.number().nullish()}).passthrough(),AR=zod.z.object({CostMatrix:zod.z.array(zod.z.array(zod.z.number())).nullish(),PerBoardGrowth:zod.z.number().nullish(),EconomyScale:zod.z.number().nullish(),ScaledResources:Re.nullish()}).passthrough(),uc=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:G.nullish()}).passthrough(),OR=zod.z.object({Index:zod.z.number().nullish(),Type:zod.z.string().nullish(),CustomTypeID:zod.z.string().nullish(),RandomActionAttackWeight:zod.z.number().nullish(),RandomActionRaidWeight:zod.z.number().nullish(),ChanceTableID:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),UR=zod.z.object({Tiles:zod.z.record(zod.z.string(),OR).nullish()}).passthrough(),BR=zod.z.object({Weight:zod.z.number().nullish(),Bonus:ke.nullish(),Tag:zod.z.string().nullish()}).passthrough(),LR=zod.z.object({Weight:zod.z.number().nullish(),Tag:zod.z.string().nullish(),MinBonusCells:zod.z.number().nullish(),MaxBonusCells:zod.z.number().nullish(),BonusPool:zod.z.array(BR).nullish(),GuaranteedBonus:ke.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),qR=zod.z.object({Variants:zod.z.array(LR).nullish()}).passthrough(),ER=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:ke.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),GR=zod.z.object({Outcomes:zod.z.array(ER).nullish()}).passthrough(),cc=zod.z.object({PerAdMultiplierRange:lc.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),NR=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:ke.nullish()}).passthrough(),jR=zod.z.object({Tiers:zod.z.array(NR).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:ke.nullish()}).passthrough(),FR=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:ke.nullish()}).passthrough(),VR=zod.z.object({Reward:ke.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),_R=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(FR).nullish(),Rate:VR.nullish()}).passthrough(),pc=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),_R).nullish()}).passthrough(),WR=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ke.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:ee.nullish(),Multipliers:cc.nullish(),Gradation:jR.nullish(),RunStats:pc.nullish()}).passthrough(),QR=zod.z.object({Choices:zod.z.array(WR).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),KR=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:ke.nullish(),Tag:zod.z.string().nullish()}).passthrough(),HR=zod.z.object({OnPassStart:ke.nullish(),OnTileLanding:zod.z.record(zod.z.string(),ke).nullish(),OnAttack:zod.z.record(zod.z.string(),ke).nullish(),OnRaid:zod.z.record(zod.z.string(),ke).nullish(),OnBuild:ke.nullish(),OnStageComplete:ke.nullish(),OnAttackBonusDrops:zod.z.array(KR).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),GR).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),QR).nullish()}).passthrough(),dc=zod.z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(uc).nullish(),HeistGridBonusConfig:qR.nullish(),StageOperations:HR.nullish(),TileLandingMultiplier:lc.nullish(),EconomyOverride:AR.nullish()}).passthrough(),$R=zod.z.object({Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),BoardTemplateID:zod.z.string().nullish(),Buildings:zod.z.array(uc).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:dc.nullish()}).passthrough(),gs=zod.z.object({RollCurrencyID:zod.z.string().nullish(),ShieldCurrencyID:zod.z.string().nullish(),RaidMode:zod.z.string().nullish(),AllowedRollMultipliers:zod.z.array(zod.z.number()).nullish(),BoardTemplatesByID:zod.z.record(zod.z.string(),UR).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),dc).nullish(),StagesByLevel:zod.z.record(zod.z.string(),$R).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:MR.nullish(),Dice:kR.nullish(),Bots:wR.nullish()}).passthrough(),ZR=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),Te).nullish(),GrandPrize:G.nullish()}).passthrough(),ys=zod.z.object({Board:gs.nullish(),CommunityChest:ZR.nullish()}).passthrough(),JR=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Se.nullish(),TargetBuildingStates:zod.z.array(PR).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),YR=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:ke.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:ee.nullish(),Multipliers:cc.nullish(),RunStats:pc.nullish()}).passthrough(),XR=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(YR).nullish()}).passthrough(),eC=zod.z.object({GroupID:zod.z.string().nullish(),Delta:B.nullish(),NewProgress:B.nullish(),MaxProgress:B.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),hc=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:B.nullish(),LandedTileType:zod.z.string().nullish(),Operation:v.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:JR.nullish(),SpecialModeOffer:XR.nullish(),CommunityChestContribution:eC.nullish()}).passthrough(),mc=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:v.nullish(),DualResult:Dt.nullish()}).passthrough(),Nn=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:G.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(vR).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:v.nullish(),DualResult:Dt.nullish()}).passthrough(),fc=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:v.nullish()}).passthrough(),gc=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:v.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),yc=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),tC=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),Rc=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:v.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(tC).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:G.nullish()}).passthrough(),iC={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Cc=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),rC={Active:"Active",Left:"Left",Replaced:"Replaced"},sC=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),nC=zod.z.object({CurrentProgress:B.nullish(),MaxProgress:B.nullish()}).passthrough(),oC=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Se.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:B.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:sC.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Sc=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(oC).nullish(),SharedProgress:nC.nullish(),Status:Cc.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),aC=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:Cc.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),lC=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(aC).nullish()}).passthrough(),xc=zod.z.object({ServerTimeUtc:u.nullish(),UserState:lC.nullish(),ActiveGroup:Sc.nullish(),SecondsRemaining:B.nullish()}),bc=zod.z.object({ServerTimeUtc:u.nullish(),Group:Sc.nullish(),SecondsRemaining:B.nullish()}),jn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:v.nullish()}),Dc=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),ze={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var uC=zod.z.object({VariantID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Weight:zod.z.number().nullish(),IsControl:zod.z.boolean().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),cC=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:re.nullish(),Gate:_.nullish(),Variants:zod.z.array(uC).nullish(),Salt:zod.z.string().nullish(),LayerID:zod.z.string().nullish(),StickyAssignment:zod.z.boolean().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zc=zod.z.object({Experiments:zod.z.record(zod.z.string(),cC).nullish()}).passthrough();var pC={Mesh:"Mesh",Host:"Host"},Fn=zod.z.enum(["Mesh","Host"]).catch("Mesh"),dC={ServerRelay:"ServerRelay",P2P:"P2P"},Vn=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),hC={Public:"Public",Private:"Private"},mC=zod.z.enum(["Public","Private"]).catch("Public"),fC={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},gC=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),Pc=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),yC=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),vc=zod.z.object({SystemState:yC.nullish(),DefaultTopology:Fn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Vn.nullish(),AllowCreatorChatOverride:zod.z.boolean().nullish(),MaxPlayersPerRoom:zod.z.number().nullish(),RoomTtlSeconds:zod.z.number().nullish(),HeartbeatIntervalMs:zod.z.number().nullish(),MemberTimeoutMs:zod.z.number().nullish(),MaxSignalPayloadBytes:zod.z.number().nullish(),MaxChatTextLength:zod.z.number().nullish(),RoomLogCap:zod.z.number().nullish(),IceServers:zod.z.array(Pc).nullish()}).passthrough(),RC=zod.z.object({UserID:zod.z.string().nullish(),Username:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),Ready:zod.z.boolean().nullish(),State:zod.z.record(zod.z.string(),zod.z.string()).nullish(),JoinedAt:zod.z.number().nullish(),IsHost:zod.z.boolean().nullish(),LastSeenMs:zod.z.number().nullish()}).passthrough(),CC=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:Fn.nullish(),ChatMode:Vn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),SC=zod.z.object({Seq:zod.z.number().nullish(),Type:gC.nullish(),FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Kind:zod.z.string().nullish(),Payload:zod.z.string().nullish(),Ts:zod.z.number().nullish()}).passthrough(),Rs=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:Fn.nullish(),ChatMode:Vn.nullish(),Visibility:mC.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(RC).nullish(),IceServers:zod.z.array(Pc).nullish(),Seq:zod.z.number().nullish()}).passthrough(),_n=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Tc=zod.z.object({Rooms:zod.z.array(CC).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Ic=zod.z.object({Envelopes:zod.z.array(SC).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Cs=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ke={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Wn=zod.z.object({TitleCustomData:ms.nullish(),Character:pr.nullish(),Item:Pr.nullish(),Currency:cr.nullish(),Store:Tr.nullish(),Lootbox:Cn.nullish(),Quest:fi.nullish(),TimedEvent:jr.nullish(),Leaderboard:Kr.nullish(),Season:$r.nullish(),Reward:Sn.nullish(),Collection:rs.nullish(),Craft:wn.nullish(),DealOffer:Ln.nullish(),Premium:kn.nullish(),TimedBoost:ps.nullish(),CoopEvent:ns.nullish(),GameLoop:ys.nullish(),Match:ln.nullish(),Experiment:zc.nullish(),Blockchain:en.nullish(),Marketplace:dn.nullish(),Multiplayer:vc.nullish(),UserCustomData:rr.nullish(),Referral:qn.nullish(),Localization:el.nullish()}).passthrough();var Mt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Ss=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(Mt.GetTitlePublicConfiguration,e,Wn)}getTitlePublicConfigurationExcept(e){return this.send(Mt.GetTitlePublicConfigurationExcept,e,Wn)}getCurrencyDefinitions(e){return this.send(Mt.GetCurrencyDefinitions,e,cr)}getItemDefinitions(e){return this.send(Mt.GetItemDefinitions,e,Pr)}getServerTime(e){return this.send(Mt.GetServerTime,e,be)}};var xs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(ze.GetGameLoops,e,ys)}getBoardDefinition(e,t=false){return this.send(ze.GetBoardDefinition,e,gs,t)}getBoardDefinitionForLevel(e,t=false){return this.send(ze.GetBoardDefinitionForLevel,e,gs,t)}getUserBoardState(e){return this.send(ze.GetUserBoardState,e,ac)}boardLoopRoll(e){return this.send(ze.BoardLoopRoll,e,hc)}boardLoopAttack(e){return this.send(ze.BoardLoopAttack,e,mc)}boardLoopRaid(e){return this.send(ze.BoardLoopRaid,e,Nn)}boardLoopRaidFast(e){return this.send(ze.BoardLoopRaidFast,e,Nn)}boardLoopBuild(e){return this.send(ze.BoardLoopBuild,e,fc)}boardSpecialChoose(e){return this.send(ze.BoardSpecialChoose,e,gc)}boardSpecialApplyMultiplier(e){return this.send(ze.BoardSpecialApplyMultiplier,e,yc)}boardSpecialClaim(e){return this.send(ze.BoardSpecialClaim,e,Rc)}getCommunityChestState(e){return this.send(ze.GetCommunityChestState,e,xc)}joinOrCreateCommunityChest(e){return this.send(ze.JoinOrCreateCommunityChest,e,bc)}claimCommunityChestMilestone(e){return this.send(ze.ClaimCommunityChestMilestone,e,jn)}claimCommunityChestGrandPrize(e){return this.send(ze.ClaimCommunityChestGrandPrize,e,jn)}leaveCommunityChest(e){return this.send(ze.LeaveCommunityChest,e,Dc)}};var oi=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(oi),zod.z.record(zod.z.string(),oi)]));var bC={Live:"Live",Latest:"Latest",Specific:"Specific"},DC={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},zC=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),PC={None:"None",Disabled:"Disabled",NoActiveRevision:"NoActiveRevision",RevisionNotFound:"RevisionNotFound",InvalidFieldName:"InvalidFieldName",RateLimited:"RateLimited",HandlerNotFound:"HandlerNotFound",HandlerDisabled:"HandlerDisabled",Timeout:"Timeout",StatementCountExceeded:"StatementCountExceeded",StackOverflow:"StackOverflow",ApiCallLimitExceeded:"ApiCallLimitExceeded",JavaScriptException:"JavaScriptException",ExecutionError:"ExecutionError"},vC=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),TC=zod.z.object({Level:zC,Message:zod.z.string().nullish(),Data:oi.nullish()}),IC=zod.z.object({Error:vC,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),kc=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:oi.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(TC).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:IC.nullish()}),Qn={Execute:"Execute"};var bs=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",Qn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,kc,{ticket:e.ClientSessionTicket})}};var Ds=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ee.GetDefinitions,e,ba)}getUserState(e){return this.send(Ee.GetUserState,e,Da)}depositToken(e){return this.send(Ee.DepositToken,e,za)}depositNFT(e){return this.send(Ee.DepositNFT,e,Pa)}requestTokenWithdrawal(e){return this.send(Ee.RequestTokenWithdrawal,e,va)}requestNFTWithdrawal(e){return this.send(Ee.RequestNFTWithdrawal,e,Ta)}getTransactionHistory(e){return this.send(Ee.GetTransactionHistory,e,Ia)}retryWithdrawal(e){return this.send(Ee.RetryWithdrawal,e,ka)}confirmWithdrawal(e){return this.send(Ee.ConfirmWithdrawal,e,wa)}donateToDeveloper(e){return this.send(Ee.DonateToDeveloper,e,sn)}donateToUsersPool(e){return this.send(Ee.DonateToUsersPool,e,sn)}};var zs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(pe.GetDefinitions,e,_a)}getGroupedOffers(e){return this.send(pe.GetGroupedOffers,e,Wa)}getOffersByItem(e){return this.send(pe.GetOffersByItem,e,hn)}getOffer(e){return this.send(pe.GetOffer,e,Qa)}getBuyOrders(e){return this.send(pe.GetBuyOrders,e,hn)}getMyState(e){return this.send(pe.GetMyState,e,Ha)}getHistory(e){return this.send(pe.GetHistory,e,$a)}createListing(e){return this.send(pe.CreateListing,e,ti)}cancelListing(e){return this.send(pe.CancelListing,e,Ve)}buy(e){return this.send(pe.Buy,e,Ve)}marketBuy(e){return this.send(pe.MarketBuy,e,Ve)}marketSell(e){return this.send(pe.MarketSell,e,Ve)}createAuction(e){return this.send(pe.CreateAuction,e,ti)}placeBid(e){return this.send(pe.PlaceBid,e,Ka)}claimAuction(e){return this.send(pe.ClaimAuction,e,Ve)}createBuyOrder(e){return this.send(pe.CreateBuyOrder,e,ti)}cancelBuyOrder(e){return this.send(pe.CancelBuyOrder,e,Ve)}fillBuyOrder(e){return this.send(pe.FillBuyOrder,e,Ve)}createDirectTrade(e){return this.send(pe.CreateDirectTrade,e,ti)}respondDirectTrade(e){return this.send(pe.RespondDirectTrade,e,Ve)}cancelDirectTrade(e){return this.send(pe.CancelDirectTrade,e,Ve)}claimBack(e){return this.send(pe.ClaimBack,e,Ve)}};var Ps=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ke.CreateRoom,e,Rs)}joinRoom(e){return this.send(Ke.JoinRoom,e,Rs)}leaveRoom(e){return this.send(Ke.LeaveRoom,e,_n)}listRooms(e){return this.send(Ke.ListRooms,e,Tc)}getRoom(e){return this.send(Ke.GetRoom,e,Rs)}closeRoom(e){return this.send(Ke.CloseRoom,e,_n)}poll(e){return this.send(Ke.Poll,e,Ic)}sendSignal(e){return this.send(Ke.SendSignal,e,Cs)}sendChat(e){return this.send(Ke.SendChat,e,Cs)}setMemberState(e){return this.send(Ke.SetMemberState,e,Cs)}};var vs=class{settings;emitter;platform;acquisition;playtime;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;communityMarketing;chat;push;localization;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=Jn(e),this.emitter=new Jt,this.platform=e.platform??new Bt,this.clientPlatform=e.clientPlatform??co(),this.acquisition=new bt(this.platform),this.acquisition.capture(),this.playtime=new Yt(this),this.emitter.on("auth:loggedIn",()=>{this.playtime.start(),this.acquisition.clear();}),this.emitter.on("auth:loggedOut",()=>{this.playtime.stop();}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new Ri({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new bi(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new Di(this.platform.storage,this.settings.titleID),this.api={authentication:new Sr(this),user:new br(this),currency:new Dr(this),item:new vr(this),store:new Ir(this),purchase:new kr(this),lootbox:new Ar(this),reward:new Or(this),quest:new Nr(this),tutorial:new Ur(this),communityMarketing:new Br(this),chat:new qr(this),push:new Er(this),localization:new Gr(this),timedEvent:new Fr(this),leaderboard:new Hr(this),season:new Zr(this),premium:new Yr(this),character:new Xr(this),match:new es(this),craft:new is(this),collection:new ss(this),coopEvent:new os(this),dealOffer:new ls(this),referral:new us(this),social:new cs(this),timedBoost:new ds(this),userCustomData:new hs(this),titleCustomData:new fs(this),title:new Ss(this),gameLoop:new xs(this),cloudCode:new bs(this),blockchain:new Ds(this),marketplace:new zs(this),multiplayer:new Ps(this)},this.userService=new Ti(this),this.auth=new zi(this),this.currency=new ki(this),this.item=new wi(this),this.store=new Mi(this),this.purchase=new Ai(this),this.checkout=new Oi(this),this.lootbox=new Ui(this),this.reward=new Bi(this),this.quest=new Fi(this),this.tutorial=new Li(this),this.communityMarketing=new qi(this),this.chat=new Ei(this),this.push=new Gi(this),this.localization=new ji(this),this.timedEvent=new Vi(this),this.leaderboard=new _i(this),this.season=new Wi(this),this.premium=new Qi(this),this.character=new Ki(this),this.match=new Hi(this),this.craft=new $i(this),this.collection=new Zi(this),this.coopEvent=new Ji(this),this.dealOffer=new Yi(this),this.referral=new Xi(this),this.social=new er(this),this.timedBoost=new tr(this),this.userCustomData=new sr(this),this.titleCustomData=new nr(this),this.title=new or(this),this.gameLoop=new ar(this),this.cloudCode=new lr(this),this.blockchain=new mr(this),this.marketplace=new Rr(this),this.multiplayer=new Cr(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:M()}}};var Ts=class{ctx;constructor(e){this.ctx=new vs(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get purchase(){return this.ctx.purchase}get checkout(){return this.ctx.checkout}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get communityMarketing(){return this.ctx.communityMarketing}get chat(){return this.ctx.chat}get push(){return this.ctx.push}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function kC(o){return new Ts(o)}var wc="idos_sso",Mc="state",Kn="idos:sso:state",wC="https://idosgames.com/sso/";function MC(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get(wc);if(!t)return null;let i=e.get(Mc)??"",r=LC();return EC(e),qC(),r&&i!==r?null:{code:t,state:i}}function AC(o){if(typeof window>"u")return;let e=o.returnTo??OC(),t=UC();BC(t);let i=new URL(o.ssoUrl??wC);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function OC(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function UC(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function BC(o){try{window.sessionStorage.setItem(Kn,o);}catch{}}function LC(){try{return window.sessionStorage.getItem(Kn)}catch{return null}}function qC(){try{window.sessionStorage.removeItem(Kn);}catch{}}function EC(o){o.delete(wc),o.delete(Mc);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}function GC(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function NC(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function jC(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Oc(o,e,t,i=1){if(!o)return e;let r=o.Base??e,s=Math.max(0,t-i),a;switch(o.Shape??"Flat"){case "PerStep":a=r+(o.PerStep??0)*s;break;case "PerStepRate":a=r*(1+(o.PerStepRate??0)*s);break;case "Geometric":a=r*Math.pow(1+(o.GrowthRate??0),s);break;case "Table":a=r*Ac(o,t,1);break;case "TableAbsolute":a=Ac(o,t,r);break;default:a=r;break}return Number.isNaN(a)?r:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function FC(o,e,t=1){return Oc(o,1,e,t)}function VC(o){if(!o)return false;switch(o.Shape??"Flat"){case "PerStep":return (o.PerStep??0)!==0;case "PerStepRate":return (o.PerStepRate??0)!==0;case "Geometric":return (o.GrowthRate??0)!==0;case "Table":case "TableAbsolute":return Uc(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function _C(o){if(Number.isNaN(o)||o<=0)return 0;if(!Number.isFinite(o))return Number.MAX_SAFE_INTEGER;let e=Math.round(o);return Math.abs(o-e)<=1e-9*Math.max(1,Math.abs(o))?e:Math.ceil(o)}function Uc(o){if(!o)return [];let e=[];for(let t of o)t?.AtStep==null||t.Value==null||e.push({AtStep:t.AtStep,Value:t.Value});return e}function Ac(o,e,t){let i=Uc(o.Points);if(i.length===0)return t;let r=null,s=null,a=null;for(let p of i)(a===null||p.AtStep>a.AtStep)&&(a=p),p.AtStep<=e&&(r===null||p.AtStep>=r.AtStep)&&(r=p),p.AtStep>e&&(s===null||p.AtStep<s.AtStep)&&(s=p);if(r===null)return t;if(s===null){let p=o.TailGrowthRate??0;return p===0?a.Value:a.Value*Math.pow(1+p,e-a.AtStep)}switch(o.Interpolation??"Step"){case "Linear":{let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+p*(s.Value-r.Value)}case "Geometric":{if(r.Value<=0||s.Value<=0){let x=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+x*(s.Value-r.Value)}let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value*Math.pow(s.Value/r.Value,p)}default:return r.Value}}var WC={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Hn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),QC={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},KC=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),HC=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Hn.nullish(),Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),CreditsRewarded:zod.z.number().nullish(),AllowedProviderIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),$C=zod.z.object({DefaultCreditsPerView:zod.z.number().nullish(),MaxCreditsBalance:zod.z.number().nullish(),DailyCreditEarnCap:zod.z.number().nullish(),DailyViewCap:zod.z.number().nullish(),MinSecondsBetweenViews:zod.z.number().nullish()}).passthrough(),ZC=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),JC=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:KC.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),YC=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),XC=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),eS=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),DisableInterstitials:zod.z.boolean().nullish(),DisableBanners:zod.z.boolean().nullish(),DisableAppOpen:zod.z.boolean().nullish()}).passthrough(),tS=zod.z.object({RequirePersonalizedAdsConsent:zod.z.boolean().nullish(),RequireTrackingConsent:zod.z.boolean().nullish(),CurrentPolicyVersion:zod.z.string().nullish(),RegulatedRegions:zod.z.array(zod.z.string()).nullish()}).passthrough(),iS=zod.z.object({RequireServerSideVerification:zod.z.boolean().nullish(),PendingRequestTtlSeconds:zod.z.number().nullish(),MaxPendingRequestsPerUser:zod.z.number().nullish(),ProviderPublicKeys:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rS=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Hn.nullish()}).passthrough(),sS={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},nS=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),oS=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:nS.nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),rS).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),HC).nullish(),Providers:zod.z.record(zod.z.string(),oS).nullish(),RewardedVideo:$C.nullish(),Interstitial:ZC.nullish(),Banner:JC.nullish(),AppOpen:YC.nullish(),FrequencyCapping:XC.nullish(),PremiumAdReductions:zod.z.array(eS).nullish(),Consent:tS.nullish(),Verification:iS.nullish()}).passthrough();var aS=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),lS=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),uS=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),cS=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),pS=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),dS=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Hn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),hS=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:aS.nullish(),Placements:zod.z.record(zod.z.string(),lS).nullish(),Daily:uS.nullish(),Session:cS.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:pS.nullish(),PendingRequests:zod.z.record(zod.z.string(),dS).nullish(),FraudFlags:hS.nullish(),UpdatedAt:u.nullish()}).passthrough();var mS={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},fS=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),gS={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},yS=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]).catch("Admin"),RS={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},CS=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),SS=zod.z.object({MessageTypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),DisplayPriority:zod.z.number().nullish(),ExpirationHours:zod.z.number().nullish(),AutoClaim:zod.z.boolean().nullish(),AllowP2P:zod.z.boolean().nullish(),ShowBadge:zod.z.boolean().nullish()}).passthrough(),xS=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:_.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),SS).nullish(),Segments:zod.z.array(xS).nullish(),DailyP2PGiftLimit:zod.z.number().nullish(),MaxRewardsPerP2PMessage:zod.z.number().nullish()}).passthrough();zod.z.object({MessageID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RecipientUserID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Source:yS.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Se.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:fS.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:G.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:CS.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var Bc="idos_device_id",Is=class{storage;constructor(e=new Ot){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Bc);return e||(e="noop-device",this.storage.setString(Bc,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
-
exports.AcquisitionCapture=
|
|
1
|
+
'use strict';var zod=require('zod'),zi=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var zi__default=/*#__PURE__*/_interopDefault(zi);var ii=class{listeners=new Map;on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),()=>{this.off(e,t);}}once(e,t){let i=this.on(e,r=>{i(),t(r);});return i}off(e,t){let i=this.listeners.get(e);i&&(i.delete(t),i.size===0&&this.listeners.delete(e));}emit(e,t){let i=this.listeners.get(e);if(i)for(let r of [...i])r(t);}removeAllListeners(){this.listeners.clear();}};function rp(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function lo(){return np()??rp()}function np(){try{let o=globalThis.localStorage;if(!o)return null;let e="__idos_probe__";return o.setItem(e,"1"),o.removeItem(e),{get:t=>{try{return o.getItem(t)}catch{return null}},set:(t,i)=>{try{o.setItem(t,i);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var uo="https://api.idosgames.com";function co(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??uo).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??lo(),locale:o.locale??sp(),appVersion:o.appVersion??""}}function sp(){try{return globalThis.navigator?.language??""}catch{return ""}}var Bt=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},qt=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function Lt(){return globalThis.Telegram?.WebApp??null}function k(){return crypto.randomUUID()}var po="idos_device_id",Et=class{storage;constructor(e=new Bt){this.storage=e;}getPlatform(){return Lt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=Lt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=Lt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(po);return e||(e=k(),this.storage.setString(po,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=Lt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=Lt();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var Gn="idos_acq",ho=["gclid","fbclid","ttclid","msclkid","yclid"],op=["ref","r"],ap=["ref_","ref-","ref=","r_","r-"];var vt=class{constructor(e){this.platform=e;}platform;capture(){let e=this.readFromEnvironment();lp(e)&&this.store({signal:e,capturedAt:Date.now()});}buildForLogin(e){let t=this.read(),i=t?{...t.signal}:{},r=pp(this.platform.getDeviceModel());return r&&(i.OsVersion=r),e&&(i.AppVersion=e),Object.keys(i).length>0?i:void 0}clear(){this.platform.storage.remove(Gn);}static detectDevicePlatform(e){let t=(e||"").toLowerCase();return t.includes("android")?"Android":/iphone|ipad|ipod/.test(t)?"iOS":"Web"}static parseReferralCode(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.includes("://")||t.includes("?")){let i=go(fo(t));if(i)return i}return di(t)}readFromEnvironment(){let e={},t=fo(this.platform.getFullURL());zt(e,"UtmSource",t.get("utm_source")),zt(e,"UtmMedium",t.get("utm_medium")),zt(e,"UtmCampaign",t.get("utm_campaign")),zt(e,"UtmTerm",t.get("utm_term")),zt(e,"UtmContent",t.get("utm_content")),zt(e,"ClaimToken",t.get("idos_click"));for(let I of ho){let N=t.get(I);if(N){e.ClickID=N;break}}let i=this.platform.getStartParameter()??"",r=cp(i);if(r){for(let I of up)zt(e,I,r.get(yo[I])??null);for(let I of ho){let N=r.get(I);if(N){e.ClickID=N;break}}}let n=di(r?r.get("ref")??r.get("r")??"":i),a=go(t),c=n||a;c&&(e.ReferralCode=c,e.ChannelHint=n?"telegram":"query");let m=this.platform.getReferrer?.();return m&&(e.Referrer=m),e}read(){try{let e=this.platform.storage.getString(Gn);if(!e)return null;let t=JSON.parse(e);return !t?.signal||typeof t.capturedAt!="number"?null:Date.now()-t.capturedAt>2592e6?(this.clear(),null):t}catch{return null}}store(e){try{this.platform.storage.setString(Gn,JSON.stringify(e));}catch{}}};function lp(o){return !!(o.UtmSource||o.UtmMedium||o.UtmCampaign||o.ClickID||o.Referrer||o.ReferralCode||o.ClaimToken)}function zt(o,e,t){t&&(o[e]=t);}var mo="a1_",yo={UtmSource:"utm_source",UtmMedium:"utm_medium",UtmCampaign:"utm_campaign",UtmTerm:"utm_term",UtmContent:"utm_content"},up=Object.keys(yo);function cp(o){let e=(o||"").trim();if(!e.startsWith(mo))return null;let t=e.slice(mo.length);if(!t)return null;try{let i=t.replace(/-/g,"+").replace(/_/g,"/"),r=atob(i+"=".repeat((4-i.length%4)%4)),n=Uint8Array.from(r,m=>m.charCodeAt(0)),a=new TextDecoder().decode(n),c=new URLSearchParams(a);return [...c.keys()].length>0?c:null}catch{return null}}function fo(o){try{let e=o.indexOf("?");return new URLSearchParams(e>=0?o.slice(e):"")}catch{return new URLSearchParams}}function go(o){for(let e of op){let t=o.get(e);if(t)return di(t)}return null}function di(o){let e=(o||"").trim();if(!e)return null;for(let t of ap)if(e.toLowerCase().startsWith(t)){e=e.slice(t.length).trim();break}return e||null}function pp(o){let e=o||"",t=/android\s+(\d+)/i.exec(e);if(t)return t[1];let i=/(?:iphone )?os\s+(\d+)[._]/i.exec(e);if(i)return i[1]}var Ro="idos_usage_pending",Co="idos_usage_session",So="idos_usage_closed_session",xo="idos_usage_new_session",bo="idos_usage_last_activity",ri=class{constructor(e){this.ctx=e;}ctx;pendingSeconds=0;currentSessionSeconds=0;pendingClosedSessionSeconds=0;isNewSessionPending=false;lastTickAt=0;suspendedAt=null;countingPaused=false;timer=null;started=false;flushing=false;start(){this.started||typeof window>"u"||(this.started=true,this.restore(),this.lastTickAt=Date.now(),this.countingPaused=typeof document<"u"&&document.visibilityState==="hidden",this.timer=setInterval(()=>this.tick(),200*1e3),window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide));}async stop(){this.started&&(this.started=false,this.timer&&(clearInterval(this.timer),this.timer=null),typeof window<"u"&&(window.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide)),this.accumulate(),this.closeCurrentSession(false),await this.flush());}onVisibilityChange=()=>{if(!(typeof document>"u")){if(document.visibilityState==="hidden"){this.accumulate(),this.countingPaused=true,this.suspendedAt=Date.now(),this.flush();return}this.countingPaused=false,this.suspendedAt!==null&&((Date.now()-this.suspendedAt)/1e3>=1800&&this.closeCurrentSession(true),this.suspendedAt=null),this.lastTickAt=Date.now();}};onPageHide=()=>{this.accumulate(),this.persist(),this.flush();};tick(){this.accumulate(),this.flush();}accumulate(){let e=Date.now(),t=Math.floor((e-this.lastTickAt)/1e3);this.lastTickAt=e,!(t<=0)&&(this.countingPaused||(this.pendingSeconds+=t,this.currentSessionSeconds+=t,this.persist()));}closeCurrentSession(e){let t=Math.floor(this.currentSessionSeconds);t>0&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t)),this.currentSessionSeconds=0,e&&(this.isNewSessionPending=true),this.persist();}async flush(){if(this.flushing||this.pendingSeconds<=0&&this.pendingClosedSessionSeconds<=0&&!this.isNewSessionPending)return;let e=this.pendingSeconds,t=this.pendingClosedSessionSeconds,i=this.isNewSessionPending;this.flushing=true,this.pendingSeconds=0,this.pendingClosedSessionSeconds=0,this.isNewSessionPending=false,this.persist();try{(await this.ctx.userService.addUsageTime(e,i,t)).ok||(this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist());}catch{this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist();}finally{this.flushing=false;}}restore(){this.pendingSeconds=this.readNumber(Ro),this.currentSessionSeconds=this.readNumber(Co),this.pendingClosedSessionSeconds=this.readNumber(So),this.isNewSessionPending=this.readNumber(xo)!==0;let e=this.readNumber(bo);this.currentSessionSeconds>0&&e>0&&(Date.now()-e)/1e3>=1800&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,Math.floor(this.currentSessionSeconds)),this.currentSessionSeconds=0);}persist(){this.writeNumber(Ro,this.pendingSeconds),this.writeNumber(Co,this.currentSessionSeconds),this.writeNumber(So,this.pendingClosedSessionSeconds),this.writeNumber(xo,this.isNewSessionPending?1:0),this.writeNumber(bo,Date.now());}readNumber(e){let t=this.ctx.platform.storage.getString(e),i=t?Number(t):0;return Number.isFinite(i)&&i>0?i:0}writeNumber(e,t){try{this.ctx.platform.storage.setString(e,String(Math.floor(t)));}catch{}}};var Xe={Virtual:"Virtual",Crypto:"Crypto"},Nt=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),hi={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},mi=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),ot={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},fi=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),dp={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},gi=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),hp={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},yi=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),mp={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},ni=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),De={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function zo(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return Do(e);let t=o.cordova?.platformId;return t?Do(t):o.navigator?.userAgent??""?ot.Web:ot.Unknown}function Do(o){let e=o.toLowerCase();return e==="android"?ot.Android:e==="ios"?ot.Ios:e==="web"?ot.Web:ot.Unknown}function Rt(o){return {ok:true,data:o}}function s(o,e){return {ok:false,reason:o,error:e}}function fp(o){return o.ok}function gp(o){return !o.ok}var q=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="string"?Number(o):o;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(o)}`}),zod.z.NEVER)}),_=zod.z.union([zod.z.number(),zod.z.string()]).transform((o,e)=>{let t=typeof o=="number"?String(o):o.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:zod.z.ZodIssueCode.custom,message:`Invalid decimal: ${String(o)}`}),zod.z.NEVER):t}),u=zod.z.string();var Nn=zod.z.object({Type:mi.nullish(),CurrencyID:zod.z.string().nullish(),Amount:q.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),yp=zod.z.object({Type:yi.nullish(),EntityID:zod.z.string()}),Rp=zod.z.object({Address:yp.nullish(),Amount:q.nullish(),Source:zod.z.string().nullish()}),be=zod.z.object({Entries:zod.z.array(Nn).nullish(),EventTokens:zod.z.array(Rp).nullish()}),vo=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:be.nullish()}),j=zod.z.object({Standard:be.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(vo).nullish()}),dt=zod.z.object({Standard:be.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(vo).nullish()}),P=zod.z.object({Grant:j.nullish(),Consume:dt.nullish()}),It=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:P.nullish(),ToResult:P.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:be.nullish()});var Cp=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),Sp={Completed:"Completed",Started:"Started",StepReached:"StepReached"},xp=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),V=zod.z.object({Segments:zod.z.array(zod.z.string()).nullish(),MinPremiumTier:zod.z.number().nullish(),RequiredPremiumIDs:zod.z.array(zod.z.string()).nullish(),MinLevel:zod.z.number().nullish(),MaxLevel:zod.z.number().nullish(),Countries:zod.z.array(zod.z.string()).nullish(),RegisteredWithinDays:zod.z.number().nullish(),ActiveWithinDays:zod.z.number().nullish(),Experiment:Cp.nullish(),Tutorial:xp.nullish(),Platforms:zod.z.array(fi).nullish()}).passthrough();var ne=zod.z.object({TotalCap:zod.z.number().nullish(),DailyCap:zod.z.number().nullish(),DailyWeightCap:zod.z.number().nullish(),PerActivationCap:zod.z.number().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish()}).passthrough();var bp=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Dp=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),zp=zod.z.object({AnchorUtc:zod.z.string().nullish(),MaxCycles:zod.z.number().nullish(),PauseBetweenPhasesSec:zod.z.number().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish()}).passthrough();zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();var vp=zod.z.object({Reset:zod.z.string().nullish(),IntervalSeconds:zod.z.number().nullish(),AnchorUtc:zod.z.string().nullish(),PauseBetweenCyclesSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough();zod.z.object({SourceType:zod.z.string().nullish(),TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var We=zod.z.object({SourceType:zod.z.string().nullish(),BaseWeight:zod.z.number().nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish(),TileTypeFilter:zod.z.array(zod.z.string()).nullish(),TileIndexFilter:zod.z.array(zod.z.number()).nullish(),ChanceOutcomeFilter:zod.z.array(zod.z.string()).nullish(),OutcomeFilter:zod.z.array(zod.z.string()).nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Limits:ne.nullish()}).passthrough(),se=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Dp.nullish(),Chain:zp.nullish(),Cyclic:vp.nullish(),ActivationTriggers:zod.z.array(We).nullish(),Relative:bp.nullish()}).passthrough();var Ip={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},Pp=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),Tp={Step:"Step",Linear:"Linear",Geometric:"Geometric"},Ap=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),kp=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),Ae=zod.z.object({Base:zod.z.number().nullish(),Shape:Pp.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(kp).nullish(),Interpolation:Ap.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var wp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:j.nullish()}).passthrough(),Mp=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),jn=zod.z.object({Bundles:zod.z.array(wp).nullish(),Multipliers:zod.z.array(Mp).nullish()}).passthrough();var Op=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),Ri=zod.z.object({Source:Op.nullish(),SourceKey:zod.z.string().nullish(),Curve:Ae.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:be.nullish(),ExcludeRewards:be.nullish()}).passthrough(),Me=zod.z.object({MilestoneID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredProgress:zod.z.number().nullish(),Rewards:j.nullish(),BonusRewards:j.nullish(),SeasonTierRewards:jn.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),jt=zod.z.object({Milestones:zod.z.record(zod.z.string(),Me).nullish()}).passthrough();var $=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Up=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),Pt=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxBalance:zod.z.number().nullish(),MaxPerGrant:zod.z.number().nullish(),DailyEarnCap:zod.z.number().nullish(),BurnOnEventEnd:zod.z.boolean().nullish(),BurnConversion:Up.nullish()}).passthrough();var Bp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Io=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:Bp.nullish(),CustomData:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough().transform(o=>o),E=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Io).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()});var ue=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),at=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(ue(o)),Resources:P.nullish(),Inventory:E.nullish()});var qp={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Po=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),Lp=zod.z.object({}).passthrough().transform(o=>o),Ep=zod.z.object({CycleID:zod.z.string(),InstanceKey:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),CycleStartUtc:u.nullish(),CycleEndUtc:u.nullish(),PointsTotalEarned:q.nullish(),PointsCurrent:q.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),Fn=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:q.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:Po}),To=zod.z.object({State:Lp.nullish(),PointsTracks:zod.z.record(zod.z.string(),Ep).nullish()}),Vn=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Po.nullish(),Resources:P.nullish(),Inventory:E.nullish()}),_n=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:q.nullish(),Resources:P.nullish(),Inventory:E.nullish()}),Ao=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),GroupCompletionID:zod.z.string(),GroupID:zod.z.string().nullish(),CompletedGroupQuests:zod.z.number().nullish(),RequiredGroupQuests:zod.z.number().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),ko=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(Fn).nullish()}),wo=zod.z.array(ue(Vn)),Mo=zod.z.array(ue(_n)),Gp={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Np=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),jp={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Fp=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Oo=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Np.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(We).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),Wn=zod.z.object({Milestones:$.nullish(),Linking:$.nullish(),Availability:$.nullish(),Reward:$.nullish(),Objectives:$.nullish()}).passthrough(),Vp=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Uo=zod.z.object({CycleIDs:zod.z.array(zod.z.string()).nullish(),GroupID:zod.z.string().nullish(),PhaseIDs:zod.z.array(zod.z.string()).nullish(),RequiredQuestIDs:zod.z.array(zod.z.string()).nullish(),PrerequisiteMode:Fp.nullish()}).passthrough(),Bo=zod.z.object({Schedule:se.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:V.nullish(),Limits:ne.nullish()}).passthrough(),qo=zod.z.object({Grant:j.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),_p=zod.z.object({QuestID:zod.z.string().nullish(),Identity:Vp.nullish(),Linking:Uo.nullish(),Availability:Bo.nullish(),Objectives:zod.z.record(zod.z.string(),Oo).nullish(),Reward:qo.nullish(),Presets:Wn.nullish()}).passthrough(),Wp=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:V.nullish(),Reward:j.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Qp=zod.z.object({PhaseID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Gate:V.nullish(),Milestones:zod.z.record(zod.z.string(),Me).nullish(),Presets:Wn.nullish(),PointsToken:Pt.nullish()}).passthrough(),Kp=zod.z.object({Milestones:zod.z.record(zod.z.string(),jt).nullish(),Linking:zod.z.record(zod.z.string(),Uo).nullish(),Availability:zod.z.record(zod.z.string(),Bo).nullish(),Reward:zod.z.record(zod.z.string(),qo).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Oo)).nullish()}).passthrough(),Hp=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:se.nullish(),Milestones:zod.z.record(zod.z.string(),Me).nullish(),Gate:V.nullish(),PointsToken:Pt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Wp).nullish(),Phases:zod.z.record(zod.z.string(),Qp).nullish(),Presets:Wn.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Si=zod.z.object({Cycles:zod.z.record(zod.z.string(),Hp).nullish(),Quests:zod.z.record(zod.z.string(),_p).nullish(),Presets:Kp.nullish()}).passthrough(),tt={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var $p={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},Zp=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),Jp={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Yp=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),Xp={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},ed=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),td={GameLoop:"GameLoop"},id={Raid:"Raid",Attack:"Attack"},rd=zod.z.object({Title:zod.z.string().nullish(),TitleKey:zod.z.string().nullish(),Body:zod.z.string().nullish(),BodyKey:zod.z.string().nullish(),AnchorID:zod.z.string().nullish(),HighlightTarget:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),UiHint:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nd=zod.z.object({Mode:Zp.nullish(),Triggers:zod.z.array(We).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),sd=zod.z.object({Grant:j.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),od=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),ad=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:od.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),ld=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),Qn=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:rd.nullish(),Completion:nd.nullish(),Effects:sd.nullish(),Script:ad.nullish(),Policy:ld.nullish()}).passthrough(),ud=zod.z.object({DisplayName:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),Description:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Lo=zod.z.object({Schedule:se.nullish(),Gate:V.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:We.nullish()}).passthrough(),Eo=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Yp.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Go=zod.z.object({Grant:j.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),cd=zod.z.object({Availability:$.nullish(),Policy:$.nullish(),Reward:$.nullish(),Steps:$.nullish()}).passthrough(),pd=zod.z.object({FlowID:zod.z.string().nullish(),Identity:ud.nullish(),Availability:Lo.nullish(),Policy:Eo.nullish(),Steps:zod.z.record(zod.z.string(),Qn).nullish(),Reward:Go.nullish(),Presets:cd.nullish()}).passthrough(),dd=zod.z.object({BlockingFlowIDs:zod.z.array(zod.z.string()).nullish(),BlockedModules:zod.z.array(zod.z.string()).nullish(),BlockedActions:zod.z.record(zod.z.string(),zod.z.array(zod.z.string())).nullish(),BlockBeforeStart:zod.z.boolean().nullish(),SkipLiftsBlock:zod.z.boolean().nullish()}).passthrough(),hd=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:dd.nullish()}).passthrough(),md=zod.z.object({Availability:zod.z.record(zod.z.string(),Lo).nullish(),Policy:zod.z.record(zod.z.string(),Eo).nullish(),Reward:zod.z.record(zod.z.string(),Go).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Qn)).nullish()}).passthrough(),No=zod.z.object({Flows:zod.z.record(zod.z.string(),pd).nullish(),Settings:hd.nullish(),Presets:md.nullish()}).passthrough(),fd=zod.z.object({}).passthrough().transform(o=>o),jo=zod.z.object({FlowID:zod.z.string(),Status:ed,CurrentStepID:zod.z.string().nullish(),CurrentStep:Qn.nullish(),TotalSteps:zod.z.number(),CompletedSteps:zod.z.number(),CanSkip:zod.z.boolean(),RewardClaimed:zod.z.boolean(),RewardPending:zod.z.boolean(),VariantID:zod.z.string().nullish()}).passthrough(),Fo=zod.z.object({State:fd.nullish(),Flows:zod.z.array(jo).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),St=zod.z.object({Flow:jo.nullish()}).passthrough(),Vo=zod.z.object({FlowID:zod.z.string().nullish(),Granted:P.nullish()}).passthrough(),_o=zod.z.array(ue(St)),Wo=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),Qe={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var xi=class{constructor(e=600,t=()=>Date.now()){this.windowMs=e;this.now=t;}windowMs;now;last=new Map;tryAcquire(e){if(this.windowMs<=0)return true;let t=this.now(),i=this.last.get(e);return i!==void 0&&t-i<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var bi=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Qo(o){return o===429||o>=500&&o<=599}function Kn(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),i=t*.2*(e()*2-1);return Math.max(50,t+i)}function Hn(o){return new Promise(e=>setTimeout(e,o))}var gd=12e3,yd=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(Fn).nullish(),TutorialProgress:zod.z.array(Wo).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),Di=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new bi;inFlightRequests=0;sessionRefreshHandler=null;constructor(e){this.baseUrl=e.baseUrl,this.emitter=e.emitter,this.fetchImpl=e.fetchImpl??globalThis.fetch.bind(globalThis),this.debugLogging=e.debugLogging??false,this.throttler=new xi(e.throttleMs),this.clientPlatform=e.clientPlatform??ot.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let n=r.throttleKey??e;if(!this.throttler.tryAcquire(n))return s("throttled","Throttled");if(!this.inflight.add(n))return s("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,c=JSON.stringify(t),m=r.ticket??null,I=r.silent??!1,N=r.timeoutMs??gd,de=r.autoRetry??!0,he=!1,Ce=0;for(;;){let Ee;try{Ee=await this.doFetch(a,c,m,N);}catch{if(de&&Ce<3){Ce++,await Hn(Kn(Ce));continue}return this.connectionFailure("Internet Connection Error",I)}let st=Ee.status;if(st>=200&&st<300)return await this.parseSuccess(Ee,i,I,e);if(st===401){if(!he&&this.sessionRefreshHandler){he=!0;let pt=null;try{pt=await this.sessionRefreshHandler();}catch{pt=null;}if(pt){m=pt;continue}}return this.emitter.emit("auth:unauthorized",void 0),s("unauthorized","Unauthorized")}if(Qo(st)){if(de&&Ce<3){Ce++,await Hn(Kn(Ce));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${st})`,I)}return await this.handleWebError(Ee,st,I)}}finally{this.inflight.remove(n),this.lowerBusy();}}async doFetch(e,t,i,r){let n=new AbortController,a=setTimeout(()=>{n.abort();},r);try{let c={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return i&&(c.Authorization=`Bearer ${i}`),await this.fetchImpl(e,{method:"POST",body:t,headers:c,signal:n.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,i,r){let n;try{n=await e.text();}catch{return this.globalError("Failed to read response body",i)}let a;try{a=JSON.parse(n);}catch{return this.globalError("JSON Parse Error",i)}let c=yd.safeParse(a);if(!c.success)return this.globalError("Malformed response envelope",i);if(!c.data.Success){let he=c.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",he),s("server",he)}let m=c.data.QuestProgress;m&&m.length>0&&this.emitter.emit("quest:systemProgress",m);let I=c.data.TutorialProgress;I&&I.length>0&&this.emitter.emit("tutorial:systemProgress",I);let N=c.data.StateVersions;N&&Object.keys(N).length>0&&this.emitter.emit("user:stateVersions",{epoch:c.data.StateEpoch??null,versions:N});let de=t.safeParse(c.data.Data);if(!de.success){let he=`Validation error (${r}): ${de.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",he),i||this.emitter.emit("error:global",he),s("validation",he)}return Rt(de.data)}async handleWebError(e,t,i){let r=`HTTP ${t}`;try{let n=await e.text();if(n)try{let c=JSON.parse(n).Error;r=typeof c=="string"&&c.length>0?`HTTP ${t}: ${c}`:`HTTP ${t}: ${n}`;}catch{r=`HTTP ${t}: ${n}`;}}catch{}return i||this.emitter.emit("error:global",r),s("server",r)}connectionFailure(e,t){return t||this.emitter.emit("error:connection",e),s("connection",e)}globalError(e,t){return t||this.emitter.emit("error:global",e),s("server",e)}raiseBusy(){this.inFlightRequests++,this.inFlightRequests===1&&this.emitter.emit("transport:busy",true);}lowerBusy(){this.inFlightRequests>0&&(this.inFlightRequests--,this.inFlightRequests===0&&this.emitter.emit("transport:busy",false));}};function Vt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function si(o){return `${Vt(o)}T00:00:00.000Z`}function Ho(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function $o(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function $n(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let n=o.InventoryV2,a=i.toISOString(),c=new Map,m=new Map,I=new Map,N=new Map,de=new Map,he=new Map,Ce=new Map,Ee=new Map,st=e.Grant?.PremiumTiers??[],pt=st.length;for(let pe=0;;pe++){let xe,ie;if(pe===0)xe=e.Grant?.Standard?.Entries,ie=false;else if(pe-1<pt)xe=st[pe-1]?.Resources?.Entries,ie=false;else if(pe===1+pt)xe=e.Consume?.Standard?.Entries,ie=true;else break;if(xe)for(let Y of xe){if(Y.Type==null)continue;let ee=Math.max(0,Y.Amount??0);if(!(ee<=0))switch(Y.Type){case "VirtualCurrency":{if(!Y.CurrencyID)continue;let te=ie?m:c;te.set(Y.CurrencyID,(te.get(Y.CurrencyID)??0)+ee);break}case "CryptoCurrency":{if(!Y.CurrencyID)continue;let te=ie?N:I;te.set(Y.CurrencyID,(te.get(Y.CurrencyID)??new zi__default.default(0)).plus(ee));break}case "Item":{if(!Y.ItemID)continue;let te=Cd(t,Y.CatalogID,Y.ItemID),oe=(te?te.IsStackable??true:true)?ie?he:de:ie?Ee:Ce;oe.set(Y.ItemID,(oe.get(Y.ItemID)??0)+ee);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=c.size>0||m.size>0,r.vcChanged){n.VirtualCurrencies??={};for(let pe of new Set([...c.keys(),...m.keys()])){let xe=c.get(pe)??0,ie=m.get(pe)??0,Y=xe-ie,ee=n.VirtualCurrencies[pe];ee?(ee.Amount+=Y,ee.UpdatedAt=a,ee.Daily&&Vt(ee.Daily.PeriodStartUtc)===Vt(i)?(ee.Daily.Earned+=xe,ee.Daily.Spent+=ie):ee.Daily={PeriodStartUtc:si(i),Earned:xe,Spent:ie}):n.VirtualCurrencies[pe]={Amount:Y,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:si(i),Earned:xe,Spent:ie}};}}if(r.ccChanged=I.size>0||N.size>0,r.ccChanged){n.CryptoCurrencies??={};for(let pe of new Set([...I.keys(),...N.keys()])){let xe=I.get(pe)??new zi__default.default(0),ie=N.get(pe)??new zi__default.default(0),Y=xe.minus(ie),ee=n.CryptoCurrencies[pe];ee?(ee.Amount=new zi__default.default(ee.Amount).plus(Y).toString(),ee.UpdatedAt=a):n.CryptoCurrencies[pe]={Amount:Y.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=de.size>0||he.size>0||Ce.size>0||Ee.size>0,r.itemsChanged){n.Items??={},n.UnstackableItems??={};let pe=n.UnstackableItems,xe=new Set([...de.keys(),...he.keys(),...Ce.keys(),...Ee.keys()]);for(let ie of xe){let Y=(de.get(ie)??0)-(he.get(ie)??0),ee=(Ce.get(ie)??0)-(Ee.get(ie)??0),te=Y+ee,_e=n.Items[ie];_e?(Y!==0&&(_e.StackableAmount+=Y),ee!==0&&(_e.UnstackableAmount+=ee),te!==0&&(_e.TotalAmount+=te)):n.Items[ie]={StackableAmount:Math.max(0,Y),UnstackableAmount:Math.max(0,ee),TotalAmount:Math.max(0,te)};}for(let[ie,Y]of Ee){if(Y<=0)continue;let ee=Object.values(pe).filter(te=>te.ItemID===ie&&te.EquippedSlot==null&&(te.ExpiresAt==null||new Date(te.ExpiresAt)>i)).sort(Rd).slice(0,Y).map(te=>te.ItemInstanceID);for(let te of ee)delete pe[te];}for(let[ie,Y]of Ce){let ee=Sd(t,ie);for(let te=0;te<Y;te++){let _e=k();pe[_e]={ItemInstanceID:_e,ItemID:ie,CatalogID:ee,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let ip=o.EventToken;for(let pe=0;;pe++){let xe,ie;if(pe===0)xe=e.Grant?.Standard?.EventTokens,ie=false;else if(pe-1<pt)xe=st[pe-1]?.Resources?.EventTokens,ie=false;else if(pe===1+pt)xe=e.Consume?.Standard?.EventTokens,ie=true;else break;if(!(!xe||xe.length===0))for(let Y of xe){let ee=Y.Address;if(!ee||ee.Type==null)continue;let te=Y.Amount??0;if(te<=0)continue;let _e=xd(ip,ee.Type);if(!_e)continue;let oe=_e[ee.EntityID];oe||(oe={},_e[ee.EntityID]=oe),oe.Balance??={Current:0,TotalEarned:0,TotalSpent:0},oe.Daily??={Date:si(i),TotalEarned:0},oe.Meta??={};let ti=Y.Source&&Y.Source.length>0?Y.Source:"CustomAction";ie?(oe.Balance.Current-=te,oe.Balance.TotalSpent+=te):(oe.Balance.Current+=te,oe.Balance.TotalEarned+=te,Vt(oe.Daily.Date)!==Vt(i)&&(oe.Daily={Date:si(i),TotalEarned:0}),oe.Daily.TotalEarned+=te,oe.Daily.EarnedBySource??={},oe.Daily.EarnedBySource[ti]=(oe.Daily.EarnedBySource[ti]??0)+te,oe.Daily.TriggersBySource??={},oe.Daily.TriggersBySource[ti]=(oe.Daily.TriggersBySource[ti]??0)+1,oe.Daily.LastTriggerBySource??={},oe.Daily.LastTriggerBySource[ti]=a,oe.Meta.JoinedAtUtc||(oe.Meta.JoinedAtUtc=a),oe.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function Rd(o,e){return o.AcquiredAt!==e.AcquiredAt?o.AcquiredAt<e.AcquiredAt?-1:1:o.ItemInstanceID===e.ItemInstanceID?0:o.ItemInstanceID<e.ItemInstanceID?-1:1}function Cd(o,e,t){let i=o?.Catalogs;if(i){if(e){let r=i[e]?.Items?.[t];if(r)return r}for(let r of Object.values(i)){let n=r.Items?.[t];if(n)return n}}}function Sd(o,e){let t=o?.Catalogs;if(t){for(let[i,r]of Object.entries(t))if(r.Items&&e in r.Items)return i}}function xd(o,e){switch(e){case "TimedEvent":return o.TimedEvent??={};case "Quest":return o.Quest??={};case "Leaderboard":return o.Leaderboard??={};case "CoopEvent":return o.CoopEvent??={};case "Season":return o.Season??={};default:return null}}function Zo(o,e,t){let i={drop:[],restore:{}};if(!t)return i;let r=t.ChangedInstances??{},n=new Set(t.RemovedInstanceIDs??[]),a=new Set;for(let m of Object.values(r))m?.ItemID&&a.add(m.ItemID);for(let m of n){let I=o[m]?.ItemID;I&&a.add(I);}if(a.size===0)return i;let c=m=>n.has(m)||m in r;if(e){for(let[m,I]of Object.entries(e))m in o||c(m)||I&&a.has(I.ItemID)&&i.drop.push(m);for(let[m,I]of Object.entries(o))m in e||c(m)||I&&a.has(I.ItemID)&&(i.restore[m]=I);}return i}function Zn(o,e){return o===e||o.startsWith(`${e}:`)}var vi=class{constructor(e){this.emitter=e;}emitter;currentState={};activeEventsCache=null;get state(){return this.currentState}getCachedActiveEvents(){return this.activeEventsCache}clear(){this.currentState=null,this.emitter.emit("user:anyUpdated",void 0);}applyUserState(e){this.currentState=e,this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserStateContainers(e,t){if(t.length!==0){this.currentState??={};for(let i of t)this.currentState[i]=e[i];this.emitter.emit("user:stateUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}applyInventory(e){this.currentState??={},this.currentState.InventoryV2=e,this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyVirtualCurrency(e){this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.VirtualCurrencies=e,this.emitter.emit("user:virtualCurrencyUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyResourceOperation(e,t,i=new Date){if(!this.currentState)return;let r=$n(this.currentState,e,t,i);this.emitResourceChanges(r,false);}applyResourcesWithDelta(e,t,i,r=new Date){if(!this.currentState)return;let n=this.currentState,a={...n.InventoryV2?.UnstackableItems??{}},c=$n(n,e,i,r),m=Zo(a,n.InventoryV2?.UnstackableItems,t),I=Object.entries(t?.ChangedInstances??{}),N=t?.RemovedInstanceIDs??[],de=m.drop.length>0||Object.keys(m.restore).length>0||I.length>0||N.length>0;if(de){n.InventoryV2??={},n.InventoryV2.UnstackableItems??={};let he=n.InventoryV2.UnstackableItems;for(let Ce of m.drop)delete he[Ce];for(let[Ce,Ee]of Object.entries(m.restore))he[Ce]=Ee;for(let[Ce,Ee]of I)he[Ce]=Ee;for(let Ce of N)delete he[Ce];}this.emitResourceChanges(c,de);}emitResourceChanges(e,t){let i=e.vcChanged||e.ccChanged||e.itemsChanged||t;e.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),i&&this.emitter.emit("user:inventoryUpdated",void 0),e.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(i||e.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,i){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,n=t instanceof zi__default.default?t:new zi__default.default(t),a=i??new Date().toISOString(),c=r[e];c?(c.Amount=new zi__default.default(c.Amount).plus(n).toString(),c.UpdatedAt=a):r[e]={Amount:n.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,n=r[e];n||(n={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=n),n.TotalPurchases+=t,n.LastPurchasedAt=i,i>=n.DailyResetUtc?(n.DailyPurchases=t,n.DailyResetUtc=Ho(i)):n.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let n=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:n});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let n=r.Cycles[t];if(!n)return;n.Quests??={};let a=n.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let n=r.PermanentQuests[e]??={QuestID:e,Status:i};n.Status=i,i==="Claimed"&&(n.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},this.markMilestoneClaimed(i.Milestone,t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,n=t[r]??={};n.Balance??={Current:0,TotalEarned:0,TotalSpent:0},n.Balance.Current=i.PointsCurrent??0,n.Balance.TotalEarned=i.PointsTotalEarned??0,n.Milestone??={};for(let a of i.ClaimedPointMilestoneIDs??[])this.markMilestoneClaimed(n.Milestone,a);}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let n=r.Steps[i.StepID]??={StepID:i.StepID};n.Progress=i.Progress,i.Completed&&(n.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let n=t.Cycles[i.CycleID];if(!n)continue;n.Quests??={},r=n.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let n=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};n.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(n.Completed=true,n.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(Zn(i,e)&&r)return r;return null}applyActiveEvents(e){this.activeEventsCache=e??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserLteState(e){e&&(this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent=e.Tokens??{},this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchTimedEventMilestoneClaimed(e,t,i){if(!(!t||!i)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,n]of Object.entries(this.currentState.EventToken.TimedEvent))!Zn(r,t)||!n||this.markMilestoneClaimed(n.Milestone??(n.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let n of r)n.Type!==e||n.TimedEventID!==t||(n.Progress??={},this.markMilestoneClaimed(n.Progress.Milestone??(n.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){e.Claims??={};let i=e.Claims[t]??={};i.ClaimedAt??=new Date().toISOString(),i.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let n=this.ensureLeaderboardProgress(e);(n.ScoreCycleVersion??0)<r&&(n.ScoreEarnedThisCycle=0,n.ClaimedMilestoneIDs=[],n.BracketID=null),n.CurrentScore=t,n.ScoreEarnedThisCycle=(n.ScoreEarnedThisCycle??0)+i,n.ScoreCycleVersion=r,n.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,n]of Object.entries(e.ChangedInstances??{}))t[r]=n,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.PendingActivationReward=false,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let n=i[r];n&&n.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,n){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,c={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:n??null};if(e==="Private")a.Private??={},a.Private[t]=c;else if(e==="Public")a.Public??={},a.Public[t]=c;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(n=>n.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var Ii=class{config=null;sections=new Map;itemDefs;currencyDefs;get titlePublicConfiguration(){return this.config}patchSection(e,t){this.sections.set(e,t);}getSection(e){return this.sections.get(e)}applyTitlePublicConfiguration(e){this.config=e&&typeof e=="object"?e:null;}get itemDefinitions(){return this.itemDefs??this.config?.Item??void 0}applyItemDefinitions(e){this.itemDefs=e;}get currencyDefinitions(){return this.currencyDefs??this.config?.Currency??void 0}applyCurrencyDefinitions(e){this.currencyDefs=e;}};var Pi=class{user;config;constructor(e){this.user=new vi(e),this.config=new Ii;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Ti=class{constructor(e,t){this.storage=e;this.authTypeKey=`Saved_AuthType_${t}`,this.emailKey=`Saved_Auth_Email_${t}`,this.passwordKey=`Saved_Auth_Password_${t}`;}storage;authTypeKey;emailKey;passwordKey;get lastAuthType(){let e=this.storage.getString(this.authTypeKey);return bd(e)?e:De.None}saveAuthType(e){this.storage.setString(this.authTypeKey,e);}get savedEmail(){return this.storage.getString(this.emailKey)??""}get savedPassword(){return this.storage.getString(this.passwordKey)??""}saveEmailAndPassword(e,t){this.storage.setString(this.emailKey,e),this.storage.setString(this.passwordKey,t);}clear(){this.storage.remove(this.authTypeKey),this.storage.remove(this.emailKey),this.storage.remove(this.passwordKey);}};function bd(o){return o!==null&&Object.values(De).includes(o)}var Dd=8,zd=100,vd=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,Jo=["GameLoop"],Ai=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=De.None;sessionEmail="";sessionPassword="";pendingRegistration=null;get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),Attribution:this.ctx.acquisition.buildForLogin(this.ctx.settings.appVersion)}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(De.Device)):t}async loginWithTelegram(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.ctx.platform.getTelegramInitDataRaw();if(!e)return s("client","Telegram initData is not available.");let t=this.baseRequest();t.TelegramInitData=e;let i=await this.ctx.api.authentication.loginWithTelegram(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(De.Telegram)):i}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(i);if(!r.ok)return r;this.applyAuthContext(r.data);let n=await this.fetchAndApplyClientState(De.Email);return n.ok&&this.keepEmailCredentials(e,t),n}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);return r.ok?(this.pendingRegistration={email:e,password:t},Rt({codeTtlMinutes:r.data.CodeTtlMinutes??0,resendCooldownSeconds:r.data.ResendCooldownSeconds??0})):r}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.VerificationCode=t;let r=await this.ctx.api.authentication.confirmEmailRegistration(i);if(!r.ok)return r;this.applyAuthContext(r.data);let n=await this.fetchAndApplyClientState(De.Email);return n.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,n}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let i=await this.ctx.api.authentication.resendVerificationCode(t);return i.ok?Rt(void 0):i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(De.Google)):i}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.WalletAddress=e,i.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(i)}async loginWithWallet(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=i,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let n=await this.ctx.api.authentication.loginWithWallet(r);return n.ok?(this.applyAuthContext(n.data),this.fetchAndApplyClientState(De.Wallet)):n}async loginWithSsoCode(e){if(!e)return s("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(De.iDosGames)):i}async forgotPassword(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();return t.Email=e,this.ctx.api.authentication.forgotPassword(t)}async resetPassword(e,t,i){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=i,this.ctx.api.authentication.resetPassword(r)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,i){switch(e){case De.Email:return this.loginWithEmail(t,i);case De.Device:case De.None:return this.loginWithDeviceID();case De.Telegram:return this.loginWithTelegram();default:return Promise.resolve(s("client",`Cannot auto-login: last session used "${e}", which requires a fresh token from the platform SDK. Obtain a new token and call the matching login method (e.g. loginWithGoogle) instead of autoLogin().`))}}async refreshSession(){if(this.refreshing)return null;let e=this.sessionAuthType!==De.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===De.None)return null;this.refreshing=true;try{return (await this.replay(e,this.sessionEmail||this.ctx.authStore.savedEmail,this.sessionPassword||this.ctx.authStore.savedPassword)).ok&&this.authContext?this.authContext.clientSessionTicket:null}catch{return null}finally{this.refreshing=false;}}logout(){this.authContext=null,this.forgetSession(),this.ctx.authStore.clear(),this.ctx.data.reset(),this.ctx.emitter.emit("auth:loggedOut",void 0);}static isValidEmail(e){return e.length>0&&vd.test(e)}static isValidPasswordLength(e){return e.length>=Dd&&e.length<=zd}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=De.None,this.sessionEmail="",this.sessionPassword="";}applyAuthContext(e){this.authContext={userID:e.TitleUserID,clientSessionTicket:e.TitleClientSessionTicket,clientSessionTicketExpiration:e.TitleClientSessionTicketExpiration,platformUserID:e.PlatformUserID??void 0,platformAuthToken:e.PlatformAuthToken??void 0,platformAuthTokenExpiration:e.PlatformAuthTokenExpiration??void 0};}async fetchAndApplyClientState(e){let t=await this.ctx.userService.getClientStateExcept(Jo,Jo);return t.ok&&(this.sessionAuthType=e,this.rememberSession?this.ctx.authStore.saveAuthType(e):this.ctx.authStore.clear(),this.ctx.emitter.emit("auth:loggedIn",void 0)),t}};var Id="idos:cfg",_t=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Yo(t)}`:e&&e.length>0?`f:${Yo(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="string"||!i.c?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,c:i};await this.storage.set(this.keyOf(e),JSON.stringify(r));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${Id}:${this.titleId}:${e}`}};function Yo(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var Xo="idos:loc",Wt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.v!="number"||!i.t||typeof i.t!="object"?null:i}catch{return null}}async write(e,t,i){try{let r={v:t,t:i};await this.storage.set(this.keyOf(e),JSON.stringify(r)),await this.noteVersion(e,t);}catch{}}async readVersions(){try{let e=await this.storage.get(this.versionsKey());if(!e)return {};let t=JSON.parse(e);if(!t||typeof t!="object")return {};let i={};for(let[r,n]of Object.entries(t))typeof n=="number"&&n>0&&(i[r]=n);return i}catch{return {}}}async noteVersion(e,t){let i=await this.readVersions();i[e]!==t&&(i[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(i)));}keyOf(e){return `${Xo}:${this.titleId}:${e}`}versionsKey(){return `${Xo}:${this.titleId}:versions`}};var Pd="idos:state",ki=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;async read(e){if(!e)return null;try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let i=JSON.parse(t);return !i||typeof i!="object"||typeof i.e!="string"||!i.v||!i.s?null:i}catch{return null}}async write(e,t,i,r){if(!(!e||!t))try{let n={e:t,v:i,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(n));}catch{}}keyOf(e){return `${Pd}:${this.titleId}:${e}`}};function Td(o,e){if(!o)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return o;let i={};for(let[r,n]of Object.entries(o))t.has(r.toLowerCase())||(i[r]=n);return i}function Yn(o,e,t,i){let r={...o??{}};if(!e||!t||!i)return r;for(let[n,a]of Object.entries(t))i[n]===a&&n in e&&(r[n]=e[n]);return r}function Ad(o){return {...o??{}}}function Xn(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var wi=class{constructor(e){this.cache=e;}cache;loadedFor=null;epoch=null;versions={};state=null;dirty=false;async load(e){if(this.loadedFor===e)return;let t=await this.cache.read(e);this.loadedFor=e,this.epoch=t?.e??null,this.versions=t?{...t.v}:{},this.state=t?.s??null,this.dirty=false;}get cachedState(){return this.state}get currentEpoch(){return this.epoch}versionsFor(e){if(!this.epoch)return;let t=Td(this.versions,e);return t&&Object.keys(t).length>0?t:void 0}noteMutation(e,t){if(!e||e!==this.epoch){e&&e!==this.epoch&&this.reset(e);return}for(let[i,r]of Object.entries(t)){let n=this.versions[i];n!==void 0&&r===n+1?this.versions[i]=r:delete this.versions[i],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=Ad(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[i,r]of Object.entries(t??{}))this.versions[i]=r;this.dirty=true;}async flush(e,t){!this.dirty||!this.epoch||!e||(this.state=t??{},this.dirty=false,await this.cache.write(e,this.epoch,this.versions,this.state));}reset(e){this.epoch=e,this.versions={},this.state=null,this.dirty=true;}};var ea=s("server","Title configuration is unavailable (CDN and API both failed)."),Mi=class{constructor(e){this.ctx=e;}ctx;baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),RelatedEntityID:k()}:null}get configCache(){return this.cache??=new _t(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new Wt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new wi(new ki(this.ctx.settings.configStorage,this.ctx.settings.titleID))}versionStore;noteStateVersions(e,t){this.ctx.auth.context?.userID&&this.stateStore.currentEpoch&&this.stateStore.noteMutation(e,t);}async getClientState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=_t.scopeOf(e.TitleFields,null),i=await this.configCache.read(t);i&&(e.KnownTitleConfigVersion=i.v),await this.prepareLocalization(e);let r=await this.prepareStateHandshake(e,null),n=await this.ctx.api.user.getClientState(e);if(!n.ok)return n;let a=await this.resolveTitleConfig(n.data,t,i,{Fields:e.TitleFields});return a==null?ea:(this.finishStateHandshake(n.data,r),await this.applyClientState(n.data,a,void 0,void 0),await this.applyLocalization(n.data.Localization),await this.flushState(r),n)}async prepareStateHandshake(e,t){let i=this.ctx.auth.context?.userID;if(!i)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(i),await this.stateStore.flush(i,this.ctx.data.user.state);let r=this.stateStore.versionsFor(t);if(r){e.KnownStateVersions=r;let n=this.stateStore.currentEpoch;n&&(e.KnownStateEpoch=n);}return {userId:i,cached:this.stateStore.cachedState,sent:r}}finishStateHandshake(e,t){let i=Yn(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=Xn(e);!r||!t.userId||this.stateStore.afterFullRead(r,e.StateVersions);}async resolveTitleConfig(e,t,i,r){let n=e.TitleConfigVersion;if(i&&n&&i.v===n)return i.c;if(e.TitleConfigUrl){let c=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(c!=null)return n&&await this.configCache.write(t,n,c),c}let a=await this.fetchConfigFromApi(r);return a!=null?(n&&await this.configCache.write(t,n,a),a):i?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let i={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(i):await this.ctx.api.title.getTitlePublicConfiguration(i);return r.ok?r.data:null}async getClientStateExcept(e,t){let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.ExcludeFields=e,i.ExcludeTitleFields=t;let r=_t.scopeOf(null,t??[]),n=await this.configCache.read(r);n&&(i.KnownTitleConfigVersion=n.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),c=await this.ctx.api.user.getClientStateExcept(i);if(!c.ok)return c;let m=await this.resolveTitleConfig(c.data,r,n,{ExcludeFields:t??[]});return m==null?ea:(this.finishStateHandshake(c.data,a),await this.applyClientState(c.data,m,e,t),await this.applyLocalization(c.data.Localization),await this.flushState(a),c)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let n=await this.fetchLocalizationFromApi(t,r?.v??0);return n??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let n=r.data;if(n.NotModified)return null;let a=n.Entries??{},c=n.Version??0,m=n.Locale??e;return c>0&&await this.localizationCache.write(m,c,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):s("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let n=Yn(r.data.User,i.cached,i.sent,r.data.StateVersions);r.data.User=n;let a=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(n,a);let c=Xn(r.data);return c&&(this.stateStore.afterSliceRead(c,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let n=await this.ctx.api.user.addUsageTime(r);return n.ok&&this.ctx.emitter.emit("user:usageTimeAdded",n.data),n}async deleteUserAccount(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let n=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,c=n?this.ctx.data.user.state?.GameLoop:void 0,m=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let I=this.ctx.data.user.state;n&&I&&I.GameLoop==null&&(I.GameLoop=c);let N=this.ctx.data.config.titlePublicConfiguration;a&&N&&N.GameLoop==null&&(N.GameLoop=m),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Ui=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,i,r,n,a){if(!t)return s("client","SourceID is required.");if(!r)return s("client","TargetID is required.");if(n<=0)return s("client","Amount must be positive.");if(e===i&&t===r)return s("client","Source and target must differ.");if(e===Xe.Crypto||i===Xe.Crypto)return s("client","Convert supports VC\u2194VC only. Use cryptoConvert for crypto.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:String(Math.trunc(n)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${i}_${r}_${k()}`},m=await this.ctx.api.currency.convert(c);if(m.ok){let I=m.data,N={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:I.SourceID,Amount:I.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:I.TargetID,Amount:I.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(N,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",I);}return m}async cryptoConvert(e,t,i,r,n,a){let c=n instanceof zi__default.default?n:new zi__default.default(n);if(!t)return s("client","SourceID is required.");if(!r)return s("client","TargetID is required.");if(c.lte(0))return s("client","SourceAmount must be a positive decimal.");if(e===i&&t===r)return s("client","Source and target must differ.");if(e===Xe.Virtual&&i===Xe.Virtual)return s("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===Xe.Virtual&&!c.isInteger())return s("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:c.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${k()}`},I=await this.ctx.api.currency.cryptoConvert(m);if(I.ok){let N=I.data,de=[],he=[];if(N.SourceType===Xe.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:N.SourceID,Amount:Math.trunc(Number(N.SourceSpent))}),N.TargetType===Xe.Virtual&&he.push({Type:"VirtualCurrency",CurrencyID:N.TargetID,Amount:Math.trunc(Number(N.TargetCredited))}),de.length>0||he.length>0){let Ce={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:he.length>0?{Standard:{Entries:he}}:null};this.ctx.data.user.applyResourceOperation(Ce,this.ctx.data.config.itemDefinitions);}N.SourceType===Xe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.SourceID,new zi__default.default(N.SourceSpent).negated(),N.ServerTimeUtc),N.TargetType===Xe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(N.TargetID,new zi__default.default(N.TargetCredited),N.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",N);}return I}};var Bi=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,i){let r=e.trim();if(!r)return s("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:r,SelectedOptionID:i,RelatedEntityID:`upgrade_item_${r}_${k()}`};t&&t.length>0&&(n.FodderInstanceIDs=[...t]);let a=await this.ctx.api.item.upgradeLevel(n);return a.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",a.data)),a}async upgradeLevelsBatch(e){if(!e||e.length===0)return s("client","upgrades is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Upgrades:e},i=await this.ctx.api.item.upgradeLevelsBatch(t);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",i.data)),i}};var kd="Store",qi=class{constructor(e){this.ctx=e;}ctx;storefront=null;storefrontLoadedAt=0;async purchase(e,t=1,i){if(!e)return s("client","OfferID is required.");if(t<1)return s("client","Count must be at least 1.");let r=this.ctx.auth.context;if(!r)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,StoreID:i?.slot?.storeID,SectionID:i?.slot?.sectionID,SlotID:i?.slot?.slotID,RelatedEntityID:`store_buy_${e}_${r.userID}_${k()}`},a=await this.ctx.api.store.purchase(n);if(a.ok){let c=a.data;this.ctx.data.user.patchStorePurchase(e,t,c.ServerTimeUtc),this.ctx.data.user.applyResourcesWithDelta(c.Resources,c.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",c);}return a}async purchaseBatch(e){if(!e||e.length===0)return s("client","purchases is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Purchases:e},i=await this.ctx.api.store.purchaseBatch(t);if(i.ok){let r=false;for(let n of i.data)!n.Success||!n.Data||!n.Data.OfferID||(this.ctx.data.user.patchStorePurchase(n.Data.OfferID,n.Data.Count,n.Data.ServerTimeUtc),!r&&n.Data.Resources&&(this.ctx.data.user.applyResourcesWithDelta(n.Data.Resources,n.Data.Inventory,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",i.data);}return i}async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.store.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(kd,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}async getStorefront(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.store.getStorefront(e);return t.ok&&(this.storefront=t.data,this.storefrontLoadedAt=Date.now(),this.ctx.emitter.emit("store:storefrontLoaded",t.data)),t}get cachedStorefront(){return this.storefront}nextRefreshAtUtc(){let e=null;for(let t of this.storefront?.Stores??[])for(let i of t.Sections??[])for(let r of i.Slots??[]){let n=r.RefreshesAtUtc;n&&(e===null||Date.parse(n)<Date.parse(e))&&(e=n);}return e}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.store.getUserState(e);return t.ok&&(this.ctx.data.user.applyStore(t.data),this.ctx.emitter.emit("store:userStateLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Li=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return s("client","Receipt is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID,TransactionID:i?.transactionID},n=await this.ctx.api.purchase.validatePurchase(r);return n.ok&&this.applyValidation(n.data),n}async validatePurchasesBatch(e){if(!e||e.length===0)return s("client","receipts is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e},i=await this.ctx.api.purchase.validatePurchasesBatch(t);if(i.ok)for(let r of i.data.Items)r.Success&&r.Data&&this.applyValidation(r.Data);return i}applyValidation(e){e.Granted&&this.ctx.data.user.applyResourcesWithDelta(e.Resources,e.Inventory,this.ctx.data.config.itemDefinitions);}};var Ei=class{constructor(e){this.ctx=e;}ctx;get platform(){return this.ctx.clientPlatform}availableOptions(e){return e?Object.entries(e).filter(([,t])=>t!=null).map(([t,i])=>({...i,OptionID:i.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,i)=>(t.OptionID??"").localeCompare(i.OptionID??"")):[]}isAvailable(e){if(!e)return false;let t=e.AllowedPlatforms;return !t||t.length===0?true:t.includes(this.platform)}requirementOf(e){let t=this.storeProductOf(e.Cost);return t?{option:e,kind:"store",productID:t}:{option:e,kind:"resources",shortfall:this.cryptoShortfallOf(e.Cost)??void 0}}storeProductOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t)if(i?.Type===hi.Purchase&&i.ProductID)return i.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let i of t){if(i?.Type!==hi.CryptoCurrency||!i.CurrencyID)continue;let r=Number(i.Amount??0);if(!(r>0))continue;let n=this.cryptoBalance(i.CurrencyID);return n>=r?null:{currencyID:i.CurrencyID,required:r,available:n,missing:r-n}}return null}cryptoBalance(e){let i=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(i?.Amount??0)}};var wd="Lootbox",Gi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(wd,i),this.ctx.emitter.emit("lootbox:definitionsLoaded",i));}return t}async open(e,t,i,r){if(!e)return s("client","LootboxID is required.");if(t<1)return s("client","Count must be at least 1.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:i,Payment:r,RelatedEntityID:`lootbox_${e}_${i??"default"}_${k()}`},a=await this.ctx.api.lootbox.open(n);if(a.ok){let c=a.data;c.TriggeredPity&&c.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,c.TriggeredPity,t),this.ctx.data.user.applyResourcesWithDelta(c.Resources,c.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("lootbox:opened",c);}return a}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Md="Reward";function es(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ni=class{constructor(e){this.ctx=e;}ctx;multiplier=1;multiplierEnabled=false;get milestoneRewardMultiplier(){return this.multiplier}get milestoneRewardMultiplierEnabled(){return this.multiplierEnabled}async getRewardDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getRewardDefinitions(e);if(t.ok){let i=t.data.RewardDefinitions;i&&(this.ctx.data.config.patchSection(Md,i),this.ctx.emitter.emit("reward:definitionsLoaded",i));}return t}async getUserRewardsState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getUserRewardsState(e);return t.ok&&t.data.Rewards&&(this.ctx.data.user.applyReward(t.data.Rewards),this.ctx.emitter.emit("reward:userStateLoaded",t.data.Rewards)),t}async getMilestoneRewardMultiplier(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.reward.getMilestoneRewardMultiplier(e);if(t.ok){let i=t.data;this.multiplierEnabled=i.Enabled,this.multiplier=i.Enabled?i.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",i);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${k()}`},r=await this.ctx.api.reward.claimDailyReward(i);if(r.ok){let n=r.data;this.ctx.data.user.patchDailyCalendarState(n.CalendarID,n.DailyState),this.ctx.data.user.applyResourcesWithDelta(n.Resources,n.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",n);}return r}async collectIdleAccrual(e){if(!es(e))return s("client",'AccrualID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),AccrualID:e,RelatedEntityID:`idle_collect_${e}_${k()}`},i=await this.ctx.api.reward.collectIdleAccrual(t);if(i.ok){let r=i.data;this.ctx.data.user.patchIdleAccrualState(r.AccrualID,r.IdleState),this.ctx.data.user.applyResourcesWithDelta(r.Resources,r.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",r);}return i}async claimComebackReward(e){if(!es(e))return s("client",'ComebackID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ComebackID:e,RelatedEntityID:`comeback_claim_${e}_${k()}`},i=await this.ctx.api.reward.claimComebackReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchComebackState(r.ComebackID,r.ComebackState),this.ctx.data.user.applyResourcesWithDelta(r.Resources,r.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",r);}return i}async claimReward(e){if(!es(e))return s("client",'ClaimID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),ClaimID:e,RelatedEntityID:`reward_claim_${e}_${k()}`},i=await this.ctx.api.reward.claimReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchClaimRewardState(r.ClaimID,r.ClaimState),this.ctx.data.user.applyResourcesWithDelta(r.Resources,r.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",r);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Od="Tutorial",ji=class{constructor(e){this.ctx=e;}ctx;async getTutorialDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.tutorial.getTutorialDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Od,t.data),this.ctx.emitter.emit("tutorial:definitionsLoaded",t.data)),t}async getUserTutorialState(e=true){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.AutoStart=e;let i=await this.ctx.api.tutorial.getUserTutorialState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyTutorial(r),this.ctx.emitter.emit("tutorial:userStateLoaded",i.data);}return i}async startFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.startFlow(t),{event:"tutorial:flowStarted"})}async reportStepShown(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.reportStepShown(i))}async completeStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.completeStep(i),{relatedEntityID:`tutorial_step_${e}_${t}_${k()}`})}async completeStepsBatch(e,t){let i=e?.trim();if(!i)return s("client","FlowID is required.");if(!t||t.length===0)return s("client","stepIDs is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),FlowID:i,StepIDs:t,RelatedEntityID:`tutorial_batch_${i}_${k()}`},n=await this.ctx.api.tutorial.completeStepsBatch(r);return n.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",n.data)),n}async skipStep(e,t){return this.stepCall(e,t,i=>this.ctx.api.tutorial.skipStep(i))}async skipFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.skipFlow(t),{event:"tutorial:flowSkipped"})}async claimFlowReward(e){let t=e?.trim();if(!t)return s("client","FlowID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${k()}`},r=await this.ctx.api.tutorial.claimFlowReward(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",r.data)),r}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,i){let r=e?.trim();if(!r)return s("client","FlowID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),FlowID:r},a=await t(n);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(i.event,a.data)),a}async stepCall(e,t,i,r){let n=e?.trim(),a=t?.trim();if(!n)return s("client","FlowID is required.");if(!a)return s("client","StepID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),FlowID:n,StepID:a};r?.relatedEntityID&&(c.RelatedEntityID=r.relatedEntityID);let m=await i(c);return m.ok&&(this.applyFlowView(m.data),this.ctx.emitter.emit("tutorial:stepChanged",m.data)),m}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Fi=class{constructor(e){this.ctx=e;}ctx;async getState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.getCommunityMarketingState(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:stateLoaded",t.data),t}async getEarnings(e=0){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e>0&&(t.Limit=e);let i=await this.ctx.api.communityMarketing.getEarnings(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:earningsLoaded",i.data),i}async claim(e){if(!e)return s("client","campaignID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.CampaignID=e;let i=await this.ctx.api.communityMarketing.claim(t);return i.ok&&this.ctx.emitter.emit("communityMarketing:claimed",i.data),i}async withdrawCryptoReward(e,t,i){if(!e)return s("client","campaignID is required.");if(!t)return s("client","walletAddress is required.");let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.CampaignID=e,r.WalletAddress=t,i&&(r.Amount=i);let n=await this.ctx.api.communityMarketing.withdrawCryptoReward(r);return n.ok&&this.ctx.emitter.emit("communityMarketing:withdrawn",n.data),n}async checkJoinEligibility(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.communityMarketing.checkJoinEligibility(e);return t.ok&&this.ctx.emitter.emit("communityMarketing:eligibilityChecked",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ud="Chat",Vi=class{constructor(e){this.ctx=e;}ctx;cursors=new Map;async getChatDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.chat.getChatDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ud,t.data),this.ctx.emitter.emit("chat:definitionsLoaded",t.data)),t}async getChannels(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e&&(t.Locale=e);let i=await this.ctx.api.chat.getChannels(t);return i.ok&&this.ctx.emitter.emit("chat:channelsLoaded",i.data),i}async poll(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e&&(t.Locale=e),this.cursors.size>0&&(t.Cursors=[...this.cursors.values()]);let i=await this.ctx.api.chat.poll(t);if(!i.ok)return i;for(let r of i.data.Rooms??[])r.NextCursor&&r.RoomID&&this.cursors.set(r.RoomID,r.NextCursor),r.Messages&&r.Messages.length>0&&this.ctx.emitter.emit("chat:messages",r);return i}async getHistory(e,t,i){let r=this.baseRequest();return r?(r.RoomID=e,t&&(r.Before=t),i&&(r.Limit=i),this.ctx.api.chat.getHistory(r)):s("unauthorized","Not logged in.")}async sendMessage(e,t,i){let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.ChannelID=e,r.Text=t,i&&(r.Locale=i);let n=await this.ctx.api.chat.sendMessage(r);return n.ok&&this.ctx.emitter.emit("chat:sent",n.data),n}async sendDirect(e,t){let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomID=e,i.Text=t;let r=await this.ctx.api.chat.sendMessage(i);return r.ok&&this.ctx.emitter.emit("chat:sent",r.data),r}async openDirectChannel(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.openDirectChannel(t)):s("unauthorized","Not logged in.")}async getConversations(){let e=this.baseRequest();return e?this.ctx.api.chat.getConversations(e):s("unauthorized","Not logged in.")}async markRead(e,t){let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomID=e,i.Cursors=[t??this.cursors.get(e)??{RoomID:e}];let r=await this.ctx.api.chat.markRead(i);return r.ok&&this.ctx.emitter.emit("chat:read",{roomID:e}),r}async joinChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.joinChannel(t)):s("unauthorized","Not logged in.")}async leaveChannel(e){let t=this.baseRequest();return t?(t.ChannelID=e,this.ctx.api.chat.leaveChannel(t)):s("unauthorized","Not logged in.")}async reportMessage(e,t,i,r){let n=this.baseRequest();return n?(n.RoomID=e,n.MessageID=t,n.Reason=i,r&&(n.Comment=r),this.ctx.api.chat.reportMessage(n)):s("unauthorized","Not logged in.")}async ignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.ignoreUser(t)):s("unauthorized","Not logged in.")}async unignoreUser(e){let t=this.baseRequest();return t?(t.TargetUserID=e,this.ctx.api.chat.unignoreUser(t)):s("unauthorized","Not logged in.")}resetCursors(){this.cursors.clear();}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Bd={WebPush:"WebPush",Fcm:"Fcm",Apns:"Apns"},qd=zod.z.enum(["WebPush","Fcm","Apns"]).catch("WebPush"),Ld={Player:"player",Title:"title",Creator:"creator"},Qt={GetPushConfig:"GetPushConfig",SubscribePush:"SubscribePush",UnsubscribePush:"UnsubscribePush",GetPushSubscriptions:"GetPushSubscriptions"},ta=zod.z.object({Configured:zod.z.boolean().nullish(),PublicKey:zod.z.string().nullish()}).passthrough(),Ed=zod.z.object({TitleID:zod.z.string().nullish(),Topic:zod.z.string().nullish()}).passthrough(),ts=zod.z.object({EndpointHash:zod.z.string().nullish(),Transport:qd.nullish(),Locale:zod.z.string().nullish(),Topics:zod.z.array(Ed).nullish()}).passthrough(),ia=zod.z.object({Configured:zod.z.boolean().nullish(),Subscriptions:zod.z.array(ts).nullish()}).passthrough(),ht={Unsupported:"unsupported",Idle:"idle",Subscribed:"subscribed",Blocked:"blocked",Embedded:"embedded"};var Gd="IDOS_PLATFORM_PUSH_REQUEST",Nd="IDOS_PLATFORM_PUSH_RESPONSE",ra=["https://idosgames.com","https://www.idosgames.com"];function na(o){if(typeof window>"u"||window.self===window.top)return Promise.resolve(false);let e=window.parent;if(!e)return Promise.resolve(false);let t=`push-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;return new Promise(i=>{let r=false,n=m=>{r||(r=true,window.removeEventListener("message",a),clearTimeout(c),i(m));},a=m=>{let I=m?.data;!I||I.type!==Nd||I.requestId!==t||ra.includes(m.origin)&&n(I.ok===true);},c=setTimeout(()=>n(false),12e4);window.addEventListener("message",a);for(let m of ra)try{e.postMessage({type:Gd,requestId:t,titleID:o},m);}catch{}})}var _i=class{constructor(e){this.ctx=e;}ctx;cachedConfig=null;async getConfig(e=false){if(!e&&this.cachedConfig)return this.cachedConfig;let t=this.baseRequest();if(!t)return {Configured:false,PublicKey:null};let i=await this.ctx.api.push.getPushConfig(t),r=i.ok?i.data:{Configured:false,PublicKey:null};return this.cachedConfig=r,i.ok&&this.ctx.emitter.emit("push:configLoaded",r),r}async getState(){let e=await this.getConfig();if(!e.Configured||!e.PublicKey)return ht.Unsupported;if(this.isEmbedded())return ht.Embedded;if(!this.isSupported())return ht.Unsupported;let t=Notification.permission;return t==="denied"?ht.Blocked:t!=="granted"?ht.Idle:await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription()?ht.Subscribed:ht.Idle}async subscribe(e={}){let t=await this.getConfig();if(!t.Configured||!t.PublicKey)return s("client","Push notifications are not available for this title.");if(this.isEmbedded())return await na(this.ctx.settings.titleID)?Rt({Where:"portal",Subscription:null}):s("client","The portal did not complete the subscription.");if(!this.isSupported())return s("client","This browser has no Push API.");let i=await Notification.requestPermission();if(i!=="granted")return s("client",i==="denied"?"The player blocked notifications for this site.":"The player dismissed the permission prompt.");let r=await navigator.serviceWorker.register(e.swPath??"./sw.js");await navigator.serviceWorker.ready;let a=await r.pushManager.getSubscription()??await r.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:jd(t.PublicKey)}),c=this.baseRequest();if(!c)return s("unauthorized","Not logged in.");let m=a.toJSON();c.PushEndpoint=m.endpoint,c.PushP256dh=m.keys?.p256dh,c.PushAuth=m.keys?.auth,c.PushTransport="WebPush",c.PushLocale=e.locale??navigator.language,c.PushTimezoneOffsetMinutes=-new Date().getTimezoneOffset();let I=await this.ctx.api.push.subscribePush(c);return I.ok?(this.ctx.emitter.emit("push:subscribed",I.data),Rt({Where:"game",Subscription:I.data})):I}async unsubscribe(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");if(this.isSupported()){let r=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();r&&(e.PushEndpoint=r.endpoint,await r.unsubscribe());}if(!e.PushEndpoint)return s("client","This browser has no push subscription to remove.");let t=await this.ctx.api.push.unsubscribePush(e);return t.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),t}async getSubscriptions(){let e=this.baseRequest();return e?await this.ctx.api.push.getPushSubscriptions(e):s("unauthorized","Not logged in.")}async unsubscribeByHash(e){if(!e)return s("client","endpointHash is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.PushEndpointHash=e;let i=await this.ctx.api.push.unsubscribePush(t);return i.ok&&this.ctx.emitter.emit("push:unsubscribed",void 0),i}isSupported(){return typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}isEmbedded(){return typeof window<"u"&&window.self!==window.top}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};function jd(o){let e=o.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(o.length/4)*4,"="),t=atob(e),i=new ArrayBuffer(t.length),r=new Uint8Array(i);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return i}var Wi=Object.freeze({}),Qi=class{constructor(e){this.ctx=e;}ctx;table={...Wi};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new Wt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}tableCache;get locale(){return this.currentLocale}get fallbackLocale(){return this.currentFallbackLocale}get locales(){let e=this.ctx.data.config.titlePublicConfiguration?.Localization??null;return e?.Locales?Object.entries(e.Locales).filter(([,t])=>t?.IsEnabled!==false).map(([t,i])=>({Locale:i?.Locale??t,DisplayName:i?.DisplayName??null,Order:i?.Order??0})).sort((t,i)=>(t.Order??0)-(i.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let i=this.resolveKey(e,t),r=this.lookup(i)??this.lookup(e);return r===void 0?this.onMissing(e):t?Fd(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Wi},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return s("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:n,fallbackLocale:a}=i.data,c=null;if(a){let m=await this.loadTableFromApi(a);m.ok&&(c=m.data.table);}return this.table=n,this.fallbackTable=c,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(n).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):s("unauthorized","Not logged in.")}reset(){this.table={...Wi},this.fallbackTable=null,this.currentFallbackLocale=null,this.setLocaleInternal(null);}setLocaleInternal(e){this.currentLocale=e,this.pluralRules=null;}baseRequest(){let e=this.ctx.auth.context;return e?{UserID:e.userID,ClientSessionTicket:e.clientSessionTicket,BuildKey:this.ctx.settings.buildKey,RelatedEntityID:k()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.Locale=e;let i=await this.cache.read(sa(e));i&&(t.KnownVersion=i.v);let r=await this.ctx.api.localization.getLocalizationTable(t);if(!r.ok)return r;let n=r.data,a=n.Locale??sa(e),c=n.Version??0;if(n.NotModified){let I=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:I?.t??{...Wi},fallbackLocale:n.FallbackLocale??null}}}let m=n.Entries??{};return c>0&&await this.cache.write(a,c,m),{ok:true,data:{locale:a,table:m,fallbackLocale:n.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),n=`${e}.${r}`;if(this.lookup(n)!==void 0)return n;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function Fd(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function sa(o){return o.trim().replace(/_/g,"-").toLowerCase()}var Vd="Quest",Ki=class{constructor(e){this.ctx=e;}ctx;async getQuestDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.quest.getQuestDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Vd,t.data),this.ctx.emitter.emit("quest:definitionsLoaded",t.data)),t}async getUserQuestState(e=true){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.AutoRefreshCycles=e;let i=await this.ctx.api.quest.getUserQuestState(t);if(i.ok){let r=i.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(i.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return i}async refreshQuestCycles(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.quest.refreshQuestCycles(e);return t.ok&&this.ctx.emitter.emit("quest:cyclesRefreshed",void 0),t}async claimQuestReward(e,t){let i=e.trim();if(!i)return s("client","QuestID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r=t&&t.trim().length>0?t.trim():void 0,n={...this.ctx.buildAuthedBaseRequest(),QuestID:i,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${i}_${k()}`},a=await this.ctx.api.quest.claimQuestReward(n);if(a.ok){let c=a.data;this.ctx.data.user.patchQuestStatus(c.QuestID,c.CycleID,"Claimed"),this.ctx.data.user.applyResourcesWithDelta(c.Resources,c.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",c);}return a}async claimQuestRewardsBatch(e){if(!e||e.length===0)return s("client","quests is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Quests:e},i=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(i.ok){let r=false;for(let n of i.data)!n.Success||!n.Data||(this.ctx.data.user.patchQuestStatus(n.Data.QuestID,n.Data.CycleID,"Claimed"),!r&&n.Data.Resources&&(this.ctx.data.user.applyResourcesWithDelta(n.Data.Resources,n.Data.Inventory,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",i.data);}return i}async claimMilestoneReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return s("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),CycleID:i,MilestoneID:r,RelatedEntityID:`milestone_claim_${i}_${r}_${k()}`},a=await this.ctx.api.quest.claimMilestoneReward(n);if(a.ok){let c=a.data;this.ctx.data.user.patchMilestoneClaimed(c.CycleID,c.MilestoneID),this.ctx.data.user.applyResourcesWithDelta(c.Resources,c.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",c);}return a}async claimMilestoneRewardsBatch(e){if(!e||e.length===0)return s("client","milestones is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(i.ok){let r=false;for(let n of i.data)!n.Success||!n.Data||(this.ctx.data.user.patchMilestoneClaimed(n.Data.CycleID,n.Data.MilestoneID),!r&&n.Data.Resources&&(this.ctx.data.user.applyResourcesWithDelta(n.Data.Resources,n.Data.Inventory,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",i.data);}return i}async claimGroupCompletionReward(e,t){let i=e.trim(),r=t.trim();if(!i||!r)return s("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),CycleID:i,GroupCompletionID:r,RelatedEntityID:`group_completion_${i}_${r}_${k()}`},a=await this.ctx.api.quest.claimGroupCompletionReward(n);if(a.ok){let c=a.data;this.ctx.data.user.patchGroupCompletionClaimed(c.CycleID,c.GroupCompletionID),this.ctx.data.user.applyResourcesWithDelta(c.Resources,c.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",c);}return a}async addQuestProgress(e,t){let i=e.trim();if(!i)return s("client","MetricID is required.");if(t<0)return s("client","ProgressValue must be >= 0.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MetricID:i,ProgressValue:t},n=await this.ctx.api.quest.addQuestProgress(r);return n.ok&&(this.ctx.data.user.patchQuestProgressUpdates(n.data.Updates),this.ctx.emitter.emit("quest:progressAdded",n.data)),n}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var _d="TimedEvent",Hi=class{constructor(e){this.ctx=e;}ctx;async getActiveEvents(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getActiveEvents(e);return t.ok&&(this.ctx.data.user.applyActiveEvents(t.data),this.ctx.emitter.emit("timedEvent:activeEventsLoaded",t.data)),t}async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_d,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,n,a,c=1){if(!t)return s("client","LteID is required.");if(!i)return s("client","SourceType is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:n,SourceParams:a,RollMultiplier:c},I=await this.ctx.api.timedEvent.grantTokens(m);return I.ok&&(this.ctx.data.user.applyResourceOperation(I.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",I.data)),I}async spendTokens(e,t,i){if(!t)return s("client","LteID is required.");if(i<=0)return s("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:i},n=await this.ctx.api.timedEvent.spendTokens(r);return n.ok&&(this.ctx.data.user.applyResourceOperation(n.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",n.data)),n}async claimMilestone(e,t,i){if(!t||!i)return s("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:i},n=await this.ctx.api.timedEvent.claimMilestone(r);if(n.ok){let a=n.data;this.ctx.data.user.applyResourcesWithDelta(a.Rewards,a.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,i),this.ctx.emitter.emit("timedEvent:milestoneClaimed",a);}return n}async claimMilestonesBatch(e){if(!e||e.length===0)return s("client","milestones is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",i.data)),i}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let i=await this.ctx.api.timedEvent.claimAllMilestones(t);return i.ok&&(this.applyMilestoneClaimBatch(i.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",i.data)),i}async spendTokensBatch(e){if(!e||e.length===0)return s("client","spends is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Spends:e},i=await this.ctx.api.timedEvent.spendTokensBatch(t);if(i.ok){let r=false;for(let n of i.data)!r&&n.Success&&n.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(n.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",i.data);}return i}async grantTokensBatch(e){if(!e||e.length===0)return s("client","grants is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Grants:e},i=await this.ctx.api.timedEvent.grantTokensBatch(t);if(i.ok){let r=false;for(let n of i.data)!r&&n.Success&&n.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(n.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",i.data);}return i}applyMilestoneClaimBatch(e){let t=false;for(let i of e){if(!i.Success||!i.Data)continue;let r=i.Data;r.Type&&r.LteID&&r.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(r.Type,r.LteID,r.MilestoneID),!t&&r.Rewards&&(this.ctx.data.user.applyResourcesWithDelta(r.Rewards,r.Inventory,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Wd="Leaderboard",$i=class{constructor(e){this.ctx=e;}ctx;cycleDocID(e){return `${this.ctx.settings.titleID}_${e}`}async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.leaderboard.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Wd,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return s("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return s("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return s("client","LeaderboardID is required.");if(t<=0)return s("client","Score must be positive.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let n=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),n.NewScore,t,n.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",n);}return r}async submitScoreFromSource(e,t,i,r,n=1){if(!e)return s("client","LeaderboardID is required.");if(!t)return s("client","SourceType is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:n},c=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(c.ok){let m=c.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),m.NewScore,m.NewScore,m.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",m);}return c}async claimCycleReward(e){if(!e)return s("client","LeaderboardID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourcesWithDelta(r.Resources,r.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return s("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let n=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourcesWithDelta(n.Resources,n.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",n);}return r}async getFriendsLeaderboard(e){if(!e)return s("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return s("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return s("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return s("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourcesWithDelta(r.Data.Resources,r.Data.Inventory,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return s("client","milestones is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourcesWithDelta(r.Data.Resources,r.Data.Inventory,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return s("client","scores is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return s("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let n=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(n),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourcesWithDelta(r.CycleReward.Data.Resources,r.CycleReward.Data.Inventory,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(n,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourcesWithDelta(a.Data.Resources,a.Data.Inventory,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return s("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Qd="Season",Zi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Qd,t.data),this.ctx.emitter.emit("season:definitionsLoaded",t.data)),t}async getActiveSeason(e){if(!e)return s("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getActiveSeason(t);return i.ok&&(i.data.UserState&&this.ctx.data.user.patchSeasonState(e,i.data.UserState),this.ctx.emitter.emit("season:activeLoaded",i.data)),i}async getUserState(e){if(!e)return s("client","SeasonChainID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.SeasonChainID=e;let i=await this.ctx.api.season.getUserState(t);return i.ok&&(this.ctx.data.user.patchSeasonState(e,i.data),this.ctx.emitter.emit("season:userStateLoaded",i.data)),i}async grantStatusTokens(e,t){if(!e)return s("client","SeasonChainID is required.");if(t<=0)return s("client","Amount must be positive.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${k()}`},r=await this.ctx.api.season.grantStatusTokens(i);return r.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,r.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",r.data)),r}async claimTierReward(e,t){if(!e)return s("client","SeasonChainID is required.");if(t<=0)return s("client","TierNumber must be positive.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${k()}`},r=await this.ctx.api.season.claimTierReward(i);if(r.ok){let n=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourcesWithDelta(n.Resources,n.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",n);}return r}async claimTierRewardsBatch(e,t){if(!e)return s("client","SeasonChainID is required.");let i=(t??[]).filter(a=>a>0);if(i.length===0)return s("client","TierNumbers is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:i,RelatedEntityID:`season_tier_batch_${e}_${k()}`},n=await this.ctx.api.season.claimTierRewardsBatch(r);if(n.ok){let a=n.data;for(let c of a.Items??[]){let m=c.Data?.TierNumber;c.Success&&typeof m=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,m);}this.ctx.data.user.applyResourcesWithDelta(a.Resources,a.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return n}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Kd="Premium",Ji=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(Kd,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return s("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return s("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(n);if(a.ok){let c=a.data;c.Premium&&this.ctx.data.user.applyPremium(c.Premium),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",c);}return a}async purchaseRealMoney(e,t,i,r,n,a,c,m){if(!e||!t)return s("client","PremiumID and TransactionID are required.");if(!r||!n)return s("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let I={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:n,PurchaseToken:a,PackageName:c,AppStoreEnvironment:m,RelatedEntityID:`premium_iap_${e}_${t}`},N=await this.ctx.api.premium.purchaseRealMoney(I);if(N.ok){let de=N.data;de.Premium&&this.ctx.data.user.applyPremium(de.Premium),this.ctx.data.user.applyResourceOperation(de.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",de);}return N}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var oa=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:dt.nullish(),AllowedPlatforms:zod.z.array(fi).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),X=zod.z.record(zod.z.string(),oa),Hd=zod.z.object({Store:gi,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var Yi=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),is=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:q.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),Yi).nullish(),UpdatedAt:u.nullish()}).passthrough(),aa=zod.z.object({Characters:zod.z.record(zod.z.string(),is).nullish()}),rs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:P.nullish()}),ns=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:P.nullish()}),la=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),Yi).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:E.nullish()}),ua=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:E.nullish()}),$d=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),ca=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),$d).nullish(),Inventory:E.nullish()}),ss=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:P.nullish()}),pa=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),SkinID:zod.z.string(),Resources:P.nullish(),Inventory:E.nullish(),Equipped:zod.z.boolean().nullish(),EquipError:zod.z.string().nullish(),Equipment:Yi.nullish(),Power:zod.z.number().nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),da=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),SkinID:zod.z.string(),Equipped:Yi.nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:E.nullish()}),ha=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Cleared:zod.z.boolean().nullish(),Power:zod.z.number().nullish(),Inventory:E.nullish()}),Zd=zod.z.object({SkinID:zod.z.string(),IsDefault:zod.z.boolean().nullish(),Misconfigured:zod.z.string().nullish(),Owned:zod.z.boolean().nullish(),OwnedCopies:zod.z.number().nullish(),IsWorn:zod.z.boolean().nullish(),MeetsRequirements:zod.z.boolean().nullish(),SoldDirectly:zod.z.boolean().nullish(),OnSale:zod.z.boolean().nullish(),SaleEndsAtUtc:u.nullish(),GateOpen:zod.z.boolean().nullish(),Purchasable:zod.z.boolean().nullish(),PriceOptions:X.nullish()}),Jd=zod.z.object({CharacterID:zod.z.string(),CharacterOpen:zod.z.boolean().nullish(),DefaultSkinID:zod.z.string().nullish(),WornSkinID:zod.z.string().nullish(),Skins:zod.z.array(Zd).nullish()}),ma=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),Jd).nullish()}),fa=at(ss),ga=at(ns),ya=at(rs),os=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),Ra=zod.z.object({StatID:zod.z.string(),TypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),MaxLevel:zod.z.number().nullish(),Weight:zod.z.number().nullish(),PriceOptions:X.nullish(),CostCurve:Ae.nullish(),BaseStatValue:zod.z.number().nullish(),ValueCurve:Ae.nullish(),RankCurve:Ae.nullish(),Requirements:zod.z.array(os).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Yd=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(os).nullish(),AllowedRarityIDs:zod.z.array(zod.z.string()).nullish(),AllowedItemTags:zod.z.array(zod.z.string()).nullish(),MinItemLevel:zod.z.number().nullish(),MaxItemLevel:zod.z.number().nullish()}).passthrough(),Ca=zod.z.object({Slots:zod.z.record(zod.z.string(),Yd).nullish()}).passthrough(),Sa=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Lore:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xd=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),eh=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:X.nullish()}).passthrough(),th=zod.z.object({Stats:$.nullish(),Levels:$.nullish(),Equipment:$.nullish()}).passthrough(),xa=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:X.nullish(),CostCurve:Ae.nullish()}).passthrough(),as="@skin";function ih(o){return !!o&&o.startsWith("@")}var rh=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string()}).passthrough(),nh=zod.z.object({PriceOptions:X.nullish(),Schedule:se.nullish(),Gate:V.nullish()}).passthrough(),sh=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(os).nullish()}).passthrough(),oh=zod.z.object({SkinID:zod.z.string().nullish(),Identity:Sa.nullish(),Item:rh.nullish(),Sale:nh.nullish(),Requirements:sh.nullish()}).passthrough(),ah=zod.z.object({DefaultSkinID:zod.z.string().nullish(),Definitions:zod.z.record(zod.z.string(),oh).nullish()}).passthrough(),lh=zod.z.object({CharacterID:zod.z.string(),Identity:Sa.nullish(),Classification:Xd.nullish(),Unlock:eh.nullish(),Presets:th.nullish(),Equipment:Ca.nullish(),Stats:zod.z.record(zod.z.string(),Ra).nullish(),RankLadder:xa.nullish(),RankStatCurve:Ae.nullish(),StatMaxLevelCurve:Ae.nullish(),Skins:ah.nullish()}).passthrough(),uh=zod.z.object({Stats:zod.z.record(zod.z.string(),Ra).nullish()}).passthrough(),ch=zod.z.object({RankLadder:xa.nullish()}).passthrough(),ph=zod.z.object({Equipment:Ca.nullish()}).passthrough(),dh=zod.z.object({Stats:zod.z.record(zod.z.string(),uh).nullish(),Levels:zod.z.record(zod.z.string(),ch).nullish(),Equipment:zod.z.record(zod.z.string(),ph).nullish()}).passthrough(),Xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),lh).nullish(),Presets:dh.nullish()}).passthrough(),ke={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch",UnlockSkin:"UnlockSkin",EquipSkin:"EquipSkin",UnequipSkin:"UnequipSkin",GetCharacterSkins:"GetCharacterSkins"},hh="SKIN_ALREADY_OWNED";var mh="Character",er=class{constructor(e){this.ctx=e;}ctx;async getCharacterDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.character.getCharacterDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(mh,t.data),this.ctx.emitter.emit("character:definitionsLoaded",t.data)),t}async getUserCharacters(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.character.getUserCharacters(e);if(t.ok){let i=t.data.Characters??{};this.ctx.data.user.applyCharacter(i),this.ctx.emitter.emit("character:userCharactersLoaded",i);}return t}async unlockCharacter(e,t){if(!e)return s("client","CharacterID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${k()}`},r=await this.ctx.api.character.unlockCharacter(i);if(r.ok){let n=r.data;this.ctx.data.user.patchCharacter(n.CharacterID,a=>{a.StatLevels??={},a.Equipment??={},n.Power!=null&&(a.Power=n.Power),a.UpdatedAt=n.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(n.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",n);}return r}async upgradeStatLevel(e,t,i){if(!e||!t)return s("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${k()}`,...i?.levels!=null?{Levels:i.levels}:{},...i?.targetLevel!=null?{TargetLevel:i.targetLevel}:{}},n=await this.ctx.api.character.upgradeStatLevel(r);if(n.ok){let a=n.data;this.ctx.data.user.patchCharacter(a.CharacterID,c=>{c.StatLevels??={},c.StatLevels[a.StatID]=a.StatLevel,a.Power!=null&&(c.Power=a.Power),c.UpdatedAt=a.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",a);}return n}async upgradeCharacterLevel(e,t){if(!e)return s("client","CharacterID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${k()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(i);if(r.ok){let n=r.data;this.ctx.data.user.patchCharacter(n.CharacterID,a=>{a.Level=n.NewLevel,n.Power!=null&&(a.Power=n.Power),a.UpdatedAt=n.ServerTimeUtc,n.NewLevel===1&&(a.StatLevels??={},a.Equipment??={});}),this.ctx.data.user.applyResourceOperation(n.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",n);}return r}async equipItems(e,t){if(!e)return s("client","CharacterID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(i);return r.ok&&(this.applyEquipChangesLocally(e,r.data),this.ctx.emitter.emit("character:itemsEquipped",r.data)),r}async unequipItems(e,t){if(!e)return s("client","CharacterID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(i);if(r.ok){let n=r.data;this.applyUnequipChangesLocally(e,n),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:n.ClearedSlotIDs??[],power:n.Power??null});}return r}async unequipAllCharacters(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.character.unequipAllCharacters(e);return t.ok&&(this.applyUnequipAllLocally(t.data),this.ctx.emitter.emit("character:allUnequipped",t.data)),t}async unlockSkin(e,t,i){if(!e||!t)return s("client","CharacterID and SkinID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SkinID:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,AutoEquip:i?.autoEquip??false,RelatedEntityID:`unlock_skin_${e}_${t}_${k()}`},n=await this.ctx.api.character.unlockSkin(r);if(n.ok){let a=n.data;this.ctx.data.user.applyResourcesWithDelta(a.Resources,a.Inventory,this.ctx.data.config.itemDefinitions),a.Equipped&&a.Equipment&&this.applySkinLocally(a.CharacterID,a.Equipment,a.Power,a.ServerTimeUtc),this.ctx.emitter.emit("character:skinUnlocked",a);}return n}async equipSkin(e,t,i){if(!e||!t)return s("client","CharacterID and SkinID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SkinID:t,ItemInstanceID:i},n=await this.ctx.api.character.equipSkin(r);if(n.ok){let a=n.data;this.applyInventoryDelta(a.Inventory),this.applySkinLocally(a.CharacterID,a.Equipped??null,a.Power,a.ServerTimeUtc),this.ctx.emitter.emit("character:skinEquipped",a);}return n}async unequipSkin(e){if(!e)return s("client","CharacterID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e},i=await this.ctx.api.character.unequipSkin(t);if(i.ok){let r=i.data;r.Cleared&&(this.applyInventoryDelta(r.Inventory),this.applySkinLocally(r.CharacterID,null,r.Power,r.ServerTimeUtc)),this.ctx.emitter.emit("character:skinUnequipped",r);}return i}async getCharacterSkins(e){let t=this.baseRequest();return t?(e&&(t.CharacterID=e),this.ctx.api.character.getCharacterSkins(t)):s("unauthorized","Not logged in.")}applySkinLocally(e,t,i,r){let n=this.ctx.data.user;n.patchCharacterEquipment(e,as,t??null),n.patchCharacter(e,a=>{i!=null&&(a.Power=i),a.UpdatedAt=r;});}async unlockCharactersBatch(e){if(!e||e.length===0)return s("client","characterIDs is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),UnlockCharacterIDs:e},i=await this.ctx.api.character.unlockCharactersBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,n=>{n.StatLevels??={},n.Equipment??={},r.Power!=null&&(n.Power=r.Power),n.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",i.data)),i}async upgradeCharacterLevelsBatch(e){if(!e||e.length===0)return s("client","upgrades is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LevelUpgrades:e},i=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,n=>{n.Level=r.NewLevel,r.Power!=null&&(n.Power=r.Power),n.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(n.StatLevels??={},n.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",i.data)),i}async upgradeStatLevelsBatch(e){if(!e||e.length===0)return s("client","upgrades is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),StatUpgrades:e},i=await this.ctx.api.character.upgradeStatLevelsBatch(t);return i.ok&&(this.applyBatchResults(i.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,n=>{n.StatLevels??={},n.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(n.Power=r.Power),n.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",i.data)),i}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourcesWithDelta(e.Resources,e.Inventory,this.ctx.data.config.itemDefinitions);for(let i of e.Items??[])!i.Success||!i.Data||t(i.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,n]of Object.entries(t.Equipment??{}))i.patchCharacterEquipment(e,r,n);i.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let i=t.ClearedSlotIDs??[];if(i.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let n of i)r.patchCharacterEquipment(e,n,null);r.patchCharacter(e,n=>{t.Power!=null&&(n.Power=t.Power),n.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[i,r]of Object.entries(e.Characters??{})){for(let n of r.ClearedSlotIDs??[])t.patchCharacterEquipment(i,n,null);t.patchCharacter(i,n=>{r.Power!=null&&(n.Power=r.Power),n.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fh="Match",tr=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,n,a){let c=this.ctx.auth.context;if(!c)return s("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:n,SelectedOptionID:a,RelatedEntityID:`pvp_create_${c.userID}_${k()}`},I=await this.ctx.api.match.createMatch(m);return I.ok&&(this.ctx.data.user.applyResourceOperation(I.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",I.data)),I}async updateMatch(e,t={}){if(!e)return s("client","MatchID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},r=await this.ctx.api.match.updateMatch(i);return r.ok&&this.ctx.emitter.emit("match:updated",r.data),r}async cancelMatch(e){if(!e)return s("client","MatchID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),MatchID:e},i=await this.ctx.api.match.cancelMatch(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",i.data)),i}async instantBattle(e,t,i,r){let n=this.ctx.auth.context;if(!n)return s("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:i,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${k()}`},c=await this.ctx.api.match.instantBattle(a);if(c.ok){let m=c.data,I=this.ctx.data.config.itemDefinitions;if(m.Resources)this.ctx.data.user.applyResourceOperation(m.Resources,I);else if(m.ResourcesDual){let N=m.ResourcesDual;N.FromUserID===n.userID&&N.FromResult?this.ctx.data.user.applyResourceOperation(N.FromResult,I):N.ToUserID===n.userID&&N.ToResult&&this.ctx.data.user.applyResourceOperation(N.ToResult,I);}this.ctx.emitter.emit("match:instantBattleCompleted",m);}return c}async saveStrategy(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let n=await this.ctx.api.match.getMyMatches(r);return n.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",n.data),n}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let n=await this.ctx.api.match.getAvailableMatches(r);return n.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",n.data),n}async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(fh,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gh="Craft",ir=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(gh,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,i=1,r,n){if(!e)return s("client","CraftID is required.");let a=this.ctx.auth.context;if(!a)return s("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:i,SelectedOptionID:r,InputInstanceIDs:n,RelatedEntityID:`craft_${e}_${a.userID}_${k()}`},m=await this.ctx.api.craft.craft(c);return m.ok&&(this.ctx.data.user.applyResourcesWithDelta(m.data.Resources,m.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",m.data)),m}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yh={Text:"Text",Image:"Image",Video:"Video",Audio:"Audio",Music:"Music",ThreeD:"ThreeD"},ba=zod.z.enum(["Text","Image","Video","Audio","Music","ThreeD"]).catch("Text"),Kt={Pending:"pending",Running:"running",Completed:"completed",Failed:"failed"};function ls(o){return o!==Kt.Pending&&o!==Kt.Running}var Rh={Disabled:"AI_DISABLED",FeatureNotFound:"AI_FEATURE_NOT_FOUND",FeatureDisabled:"AI_FEATURE_DISABLED",WrongAction:"AI_WRONG_ACTION",NotAvailableForPlayer:"AI_NOT_AVAILABLE_FOR_PLAYER",FeatureClosed:"AI_FEATURE_CLOSED",LimitReached:"AI_LIMIT_REACHED",Cooldown:"AI_COOLDOWN",BadInput:"AI_BAD_INPUT",PromptRejected:"AI_PROMPT_REJECTED",Unavailable:"AI_UNAVAILABLE",GenerationFailed:"AI_GENERATION_FAILED",GenerationNotFound:"AI_GENERATION_NOT_FOUND"};function Ch(o){return o?/\b(AI_[A-Z_]+)\s*:/.exec(o)?.[1]??null:null}var Sh=zod.z.object({Url:zod.z.string().nullish(),ContentType:zod.z.string().nullish(),Variant:zod.z.string().nullish()}),xh=zod.z.object({Code:zod.z.string().nullish(),Message:zod.z.string().nullish()}),rr=zod.z.object({GenerationID:zod.z.string(),FeatureKey:zod.z.string().nullish(),Modality:ba.nullish(),Status:zod.z.string(),Progress:zod.z.number().nullish(),OutputText:zod.z.string().nullish(),Assets:zod.z.array(Sh).nullish(),Error:xh.nullish(),Charge:P.nullish(),PlayerRefunded:zod.z.boolean().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish()}),Da=zod.z.object({Data:zod.z.array(rr).nullish(),Skip:zod.z.number().nullish(),Limit:zod.z.number().nullish()}),bh=zod.z.object({Modality:ba.nullish(),Async:zod.z.boolean().nullish(),Limits:ne.nullish(),PriceOptions:X.nullish(),Tags:zod.z.array(zod.z.string()).nullish(),HistoryMessages:zod.z.number().nullish(),MaxTokens:zod.z.number().nullish(),AllowImages:zod.z.boolean().nullish(),MaxInputImages:zod.z.number().nullish(),MaxInputImageBytes:zod.z.number().nullish(),AllowedImageTypes:zod.z.array(zod.z.string()).nullish(),MaxImages:zod.z.number().nullish(),AllowEdit:zod.z.boolean().nullish(),AllowReferenceImage:zod.z.boolean().nullish(),MaxPromptChars:zod.z.number().nullish(),LockBehavior:zod.z.boolean().nullish(),ImageSize:zod.z.string().nullish(),VideoSize:zod.z.string().nullish(),VideoSeconds:zod.z.number().nullish(),Voice:zod.z.string().nullish(),AudioFormat:zod.z.string().nullish(),MusicFormat:zod.z.string().nullish(),ThreeDOperation:zod.z.string().nullish(),ArtStyle:zod.z.string().nullish(),ThreeDFormat:zod.z.string().nullish()}).passthrough(),za=zod.z.object({Enabled:zod.z.boolean().nullish(),Features:zod.z.record(zod.z.string(),bh).nullish()}).passthrough(),Be={GetDefinitions:"GetDefinitions",GenerateText:"GenerateText",GetText:"GetText",GenerateImage:"GenerateImage",EditImage:"EditImage",GenerateVideo:"GenerateVideo",GetVideo:"GetVideo",GenerateAudio:"GenerateAudio",GenerateMusic:"GenerateMusic",GenerateThreeD:"GenerateThreeD",GetThreeD:"GetThreeD",ListGenerations:"ListGenerations",GetGeneration:"GetGeneration"};var Dh="AI",zh=/^[A-Za-z0-9_-]{1,128}$/,nr=class{constructor(e){this.ctx=e;}ctx;charged=new Set;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.ai.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dh,t.data),this.ctx.emitter.emit("ai:definitionsLoaded",t.data)),t}generateText(e,t,i){return this.generate(e,{Text:t},i,r=>this.ctx.api.ai.generateText(r))}getText(e){return this.poll(e,t=>this.ctx.api.ai.getText(t))}generateImage(e,t,i){return this.generate(e,{Image:t},i,r=>this.ctx.api.ai.generateImage(r))}editImage(e,t,i){return this.generate(e,{ImageEdit:t},i,r=>this.ctx.api.ai.editImage(r))}generateVideo(e,t,i){return this.generate(e,{Video:t},i,r=>this.ctx.api.ai.generateVideo(r))}getVideo(e){return this.poll(e,t=>this.ctx.api.ai.getVideo(t))}generateAudio(e,t,i){return this.generate(e,{Audio:t},i,r=>this.ctx.api.ai.generateAudio(r))}generateMusic(e,t,i){return this.generate(e,{Music:t},i,r=>this.ctx.api.ai.generateMusic(r))}generateThreeD(e,t,i){return this.generate(e,{ThreeD:t},i,r=>this.ctx.api.ai.generateThreeD(r))}getThreeD(e){return this.poll(e,t=>this.ctx.api.ai.getThreeD(t))}async listGenerations(e){let t=this.baseRequest();return t?(e&&(t.Query=e),this.ctx.api.ai.listGenerations(t)):s("unauthorized","Not logged in.")}async getGeneration(e){if(!e)return s("client","GenerationID is required.");let t=this.baseRequest();return t?(t.GenerationID=e,this.ctx.api.ai.getGeneration(t)):s("unauthorized","Not logged in.")}isTerminal(e){return ls(e)}async generate(e,t,i,r){if(!e)return s("client","FeatureKey is required.");let n=i?.relatedEntityID;if(n!==void 0&&!zh.test(n))return s("client","relatedEntityID must be 1-128 characters of A-Z, a-z, 0-9, '_' or '-'.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),...t,FeatureKey:e,SelectedOptionID:i?.selectedOptionID,RelatedEntityID:n??k()},c=await r(a);return c.ok&&(await this.reconcileCharge(c.data,true),this.emitView(c.data)),c}async poll(e,t){if(!e)return s("client","GenerationID is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.GenerationID=e;let r=await t(i);return r.ok&&(await this.reconcileCharge(r.data,false),this.emitView(r.data)),r}async reconcileCharge(e,t){if(e.PlayerRefunded){this.charged.delete(e.GenerationID)&&await this.ctx.userService.getUserInventory();return}!t||!e.Charge||this.charged.has(e.GenerationID)||(this.charged.add(e.GenerationID),this.ctx.data.user.applyResourceOperation(e.Charge,this.ctx.data.config.itemDefinitions));}emitView(e){this.ctx.emitter.emit("ai:generationUpdated",e),e.Status===Kt.Completed?this.ctx.emitter.emit("ai:generationCompleted",e):e.Status===Kt.Failed&&this.ctx.emitter.emit("ai:generationFailed",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var vh="Collection",sr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(vh,t.data),this.ctx.emitter.emit("collection:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getUserState(e);return t.ok&&(this.ctx.data.user.applyCollection(t.data),this.ctx.emitter.emit("collection:userStateLoaded",t.data)),t}async openPack(e,t,i=1,r){let n=this.ctx.auth.context;if(!n)return s("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:i,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`open_pack_${e}_${t}_${n.userID}_${k()}`},c=await this.ctx.api.collection.openPack(a);return c.ok&&(this.ctx.data.user.applyResourcesWithDelta(c.data.Resources,c.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",c.data)),c}async openCollectionChest(e,t,i=1){let r=this.ctx.auth.context;if(!r)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:i,RelatedEntityID:`open_chest_${e}_${t}_${r.userID}_${k()}`},a=await this.ctx.api.collection.openCollectionChest(n);return a.ok&&(this.ctx.data.user.applyResourcesWithDelta(a.data.Resources,a.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",a.data)),a}async useCollectibleJoker(e,t){let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${i.userID}_${k()}`},n=await this.ctx.api.collection.useCollectibleJoker(r);return n.ok&&(this.ctx.data.user.applyResourcesWithDelta(n.data.Resources,n.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",n.data)),n}async claimSetReward(e,t){let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${i.userID}_${k()}`},n=await this.ctx.api.collection.claimSetReward(r);return n.ok&&(this.ctx.data.user.applyResourcesWithDelta(n.data.Resources,n.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",n.data)),n}async claimSetRewardsBatch(e){if(!e||e.length===0)return s("client","sets is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Sets:e},i=await this.ctx.api.collection.claimSetRewardsBatch(t);if(i.ok){let r=false;for(let n of i.data)!r&&n.Success&&n.Data?.Resources&&(this.ctx.data.user.applyResourcesWithDelta(n.Data.Resources,n.Data.Inventory,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",i.data);}return i}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${k()}`},r=await this.ctx.api.collection.claimGrandPrize(i);return r.ok&&(this.ctx.data.user.applyResourcesWithDelta(r.data.Resources,r.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",r.data)),r}async sendTradeOffer(e,t,i,r,n,a=false){let c=this.ctx.auth.context;if(!c)return s("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:n,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${c.userID}_${r}_${k()}`},I=await this.ctx.api.collection.sendTradeOffer(m);return I.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",I.data),I}async cancelTradeOffer(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_cancel_${e}_${k()}`},i=await this.ctx.api.collection.cancelTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",i.data),i}async acceptTradeOffer(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_accept_${e}_${k()}`},i=await this.ctx.api.collection.acceptTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",i.data),i}async declineTradeOffer(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),OfferID:e,RelatedEntityID:`trade_decline_${e}_${k()}`},i=await this.ctx.api.collection.declineTradeOffer(t);return i.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",i.data),i}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getMyTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",i.data),i}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.CollectionID=e;let i=await this.ctx.api.collection.getIncomingTradeOffers(t);return i.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ih="CoopEvent",or=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ih,t.data),this.ctx.emitter.emit("coopEvent:definitionsLoaded",t.data)),t}async getActiveEvent(e){if(!e)return s("client","CoopChainID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.CoopChainID=e;let i=await this.ctx.api.coopEvent.getActiveEvent(t);return i.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",i.data),i}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.coopEvent.getUserState(e);return t.ok&&(this.ctx.data.user.applyCoopEvent(t.data.UserState??null),this.ctx.emitter.emit("coopEvent:userStateLoaded",t.data)),t}async getGroupState(e){if(!e)return s("client","GroupID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.GroupID=e;let i=await this.ctx.api.coopEvent.getGroupState(t);return i.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",i.data),i}async joinOrCreateGroup(e){if(!e)return s("client","CoopChainID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e},i=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(i.ok){let r=i.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",i.data);}return i}async spin(e,t,i=1,r){if(!e||!t)return s("client","CoopChainID and GroupID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),CoopChainID:e,GroupID:t,Count:i,SelectedOptionID:r,RelatedEntityID:k()},a=await this.ctx.api.coopEvent.spin(n);return a.ok&&(this.ctx.data.user.applyResourceOperation(a.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",a.data)),a}async claimObjectReward(e){if(!e)return s("client","GroupID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimObjectReward(t);return i.ok&&(this.ctx.data.user.applyResourcesWithDelta(i.data.Resources,i.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",i.data)),i}async claimGrandPrize(e){if(!e)return s("client","GroupID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.claimGrandPrize(t);return i.ok&&(this.ctx.data.user.applyResourcesWithDelta(i.data.Resources,i.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",i.data)),i}async leaveGroup(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.coopEvent.leaveGroup(t);return i.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ph="DealOffer",ar=class{constructor(e){this.ctx=e;}ctx;async getDefinition(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getDefinition(e);return t.ok&&t.data.DealOfferDefinitions&&(this.ctx.data.config.patchSection(Ph,t.data.DealOfferDefinitions),this.ctx.emitter.emit("dealOffer:definitionLoaded",t.data.DealOfferDefinitions)),t}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getUserState(e);return t.ok&&t.data.DealOffers&&(this.ctx.data.user.applyDealOffer(t.data.DealOffers),this.ctx.emitter.emit("dealOffer:userStateLoaded",t.data.DealOffers)),t}async getActiveDeals(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.dealOffer.getActiveDeals(e);return t.ok&&this.ctx.emitter.emit("dealOffer:activeDealsLoaded",t.data),t}async dismissDeal(e){if(!e)return s("client","SlotID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_dismiss_${e}_${k()}`},i=await this.ctx.api.dealOffer.dismissDeal(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",i.data)),i}async executeNode(e,t,i,r){if(!e||!t)return s("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n=i&&i.trim().length>0?i.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:n??`deal_exec_${e}_${t}_${k()}`},c=await this.ctx.api.dealOffer.executeNode(a);return c.ok&&(c.data.Idempotent||this.ctx.data.user.applyResourcesWithDelta(c.data.Resources,c.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",c.data)),c}async recordShow(e){if(!e)return s("client","SlotID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),SlotID:e,RelatedEntityID:`deal_show_${e}_${k()}`},i=await this.ctx.api.dealOffer.recordShow(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",i.data)),i}async claimMilestone(e,t){if(!e||!t)return s("client","SlotID and MilestoneID are required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${k()}`},r=await this.ctx.api.dealOffer.claimMilestone(i);return r.ok&&(this.ctx.data.user.applyResourcesWithDelta(r.data.Resources,r.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",r.data)),r}async claimMilestonesBatch(e,t){if(!e)return s("client","SlotID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:i,RelatedEntityID:`deal_milestone_batch_${e}_${k()}`},n=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return n.ok&&(this.ctx.data.user.applyResourcesWithDelta(n.data.Resources,n.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",n.data)),n}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Th="Referral",lr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(Th,t.data.ReferralDefinitions),this.ctx.emitter.emit("referral:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.referral.getUserState(e);return t.ok&&t.data.Referral&&(this.ctx.data.user.applyReferral(t.data.Referral),this.ctx.emitter.emit("referral:userStateLoaded",t.data)),t}async activateReferralCode(e){let t=vt.parseReferralCode(e)?.toUpperCase();if(!t)return s("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},n=await this.ctx.api.referral.activateReferralCode(r);if(n.ok){let a=n.data;a.ReferrerUserID&&this.ctx.data.user.patchReferralSubscription(a.ReferrerUserID),this.ctx.data.user.applyResourcesWithDelta(a.Resources,a.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return n}async claimInviteReward(e){let t=e.trim();if(!t)return s("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},n=await this.ctx.api.referral.claimInviteReward(r);if(n.ok){let a=n.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourcesWithDelta(a.Resources,a.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return n}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return s("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},n=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(n.ok){let a=n.data;for(let c of a.Items??[])c.Success&&c.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(c.Id);this.ctx.data.user.applyResourcesWithDelta(a.Resources,a.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return n}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ur=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getOutgoingRequests(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return s("client","TargetUserID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return s("client","RequesterUserID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return s("client","RequesterUserID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return s("client","FriendUserID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ah="TimedBoost";function kh(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var cr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Ah,t.data),this.ctx.emitter.emit("timedBoost:definitionsLoaded",t.data)),t}async getActive(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActive(e);return t.ok&&(this.ctx.data.user.applyTimedBoost({Active:t.data.Active??{}}),this.ctx.emitter.emit("timedBoost:activeLoaded",t.data)),t}async getActiveWindows(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.getActiveWindows(e);return t.ok&&this.ctx.emitter.emit("timedBoost:activeWindowsLoaded",t.data),t}async activate(e,t){let i=e.trim();if(!kh(i))return s("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BoostID:i,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${i}_${k()}`},n=await this.ctx.api.timedBoost.activate(r);if(n.ok){let a=n.data;if(a.ActivatedBoost){let c=a.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(a.ActivatedBoost,c);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",a);}return n}async cleanupExpired(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.timedBoost.cleanupExpired(e);return t.ok&&(await this.getActive(),this.ctx.emitter.emit("timedBoost:expiredCleaned",void 0)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var mt={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},wh={Client:"Client",Server:"Server",System:"System"},Mh=zod.z.enum(["Client","Server","System"]).catch("Client"),Oh=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Mh.nullish(),ExpiresAt:u.nullish()}).passthrough(),pr=zod.z.record(zod.z.string(),Oh),va=zod.z.object({Version:zod.z.number().nullish(),Private:pr.nullish(),Public:pr.nullish(),ReadOnly:pr.nullish()}),us=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:pr.nullish()}),cs=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Uh=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Ia=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Uh).nullish()}),Pa=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),Ta=zod.z.object({Results:zod.z.array(us).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),Bh={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},qh=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),Lh=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:qh.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),dr=zod.z.object({Keys:zod.z.record(zod.z.string(),Lh).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),it={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Eh="UserCustomData";function Aa(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var hr=class{constructor(e){this.ctx=e;}ctx;async getUserCustomDataDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getUserCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Eh,t.data),this.ctx.emitter.emit("userCustomData:definitionsLoaded",t.data)),t}async getMyUserCustomData(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.userCustomData.getMyUserCustomData(e);return t.ok&&(this.ctx.data.user.applyUserCustomData(t.data),this.ctx.emitter.emit("userCustomData:myDataLoaded",t.data)),t}async getPublicUserCustomDataOf(e){let t=e.trim();if(!t)return s("client","TargetUserID is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(i);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,mt.Private)}async setPublicData(e,t){return this.setData(e,t,mt.Public)}async setData(e,t,i){let r=e.trim();if(!Aa(r))return s("client",'KeyID is required and must not contain "." or "$".');if(t==null)return s("client","Value is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let n={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},c=await(i===mt.Private?this.ctx.api.userCustomData.setPrivateData(n):this.ctx.api.userCustomData.setPublicData(n));if(c.ok){let m=c.data;this.ctx.data.user.patchUserCustomDataKey(i,m.KeyID,t,m.Version??0,m.ExpiresAt),this.ctx.emitter.emit(i===mt.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",m);}return c}async deleteKey(e,t){let i=e.trim();if(!Aa(i))return s("client",'KeyID is required and must not contain "." or "$".');if(t!==mt.Private&&t!==mt.Public)return s("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),KeyID:i,Bucket:t},n=await this.ctx.api.userCustomData.deleteKey(r);return n.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,i),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),n}async batchSet(e){if(!e.length)return s("client","At least one item is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchSetItems:e},i=await this.ctx.api.userCustomData.batchSet(t);if(i.ok){for(let r of i.data.Results??[]){let n=r.Bucket??mt.Private,a=e.find(c=>c.Bucket===n&&c.KeyID===r.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(n,r.KeyID,a.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",i.data);}return i}async batchDelete(e){if(!e.length)return s("client","At least one item is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BatchDeleteItems:e},i=await this.ctx.api.userCustomData.batchDelete(t);if(i.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",i.data);}return i}async batchGetPublicUserCustomDataOf(e){if(!e.length)return s("client","At least one target user id is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.TargetUserIDs=e;let i=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return i.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Gh="TitleCustomDataDefinitions",ka=50;function Nh(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function ps(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function jh(o){let e={};for(let[t,i]of Object.entries(o))ps(i)||(e[t]=i);return e}var mr=class{constructor(e){this.ctx=e;}ctx;lastRuntimeVersion=null;runtimeCache={};async getTitleCustomDataDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.titleCustomData.getTitleCustomDataDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Gh,t.data),this.ctx.emitter.emit("titleCustomData:definitionsLoaded",t.data)),t}async getPublicTitleData(e=true){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");e&&this.lastRuntimeVersion!=null&&(t.KnownRuntimeVersion=this.lastRuntimeVersion);let i=await this.ctx.api.titleCustomData.getPublicTitleData(t);return i.ok&&this.absorb(i.data),i}async getPublicTitleDataKeys(e){let t=e.map(n=>n.trim()).filter(n=>n.length>0);if(!t.length)return s("client","At least one KeyID is required.");if(t.some(n=>!Nh(n)))return s("client",'KeyID must not contain "." or "$".');if(t.length>ka)return s("client",`At most ${ka} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!ps(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!ps(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=jh(this.runtimeCache),e.Runtime=this.runtimeCache):e.Runtime&&(this.runtimeCache=e.Runtime),e.RuntimeVersion!=null&&(this.lastRuntimeVersion=e.RuntimeVersion),this.ctx.emitter.emit("titleCustomData:publicDataLoaded",e);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fr=class{constructor(e){this.ctx=e;}ctx;async getTitlePublicConfiguration(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.title.getTitlePublicConfiguration(e);return t.ok&&(this.ctx.data.config.applyTitlePublicConfiguration(t.data),this.ctx.emitter.emit("title:publicConfigurationReceived",t.data)),t}async getCurrencyDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.title.getCurrencyDefinitions(e);return t.ok&&(this.ctx.data.config.applyCurrencyDefinitions(t.data),this.ctx.emitter.emit("title:currencyDefinitionsReceived",t.data)),t}async getItemDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.title.getItemDefinitions(e);return t.ok&&(this.ctx.data.config.applyItemDefinitions(t.data),this.ctx.emitter.emit("title:itemDefinitionsReceived",t.data)),t}async getServerTime(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.title.getServerTime(e);return t.ok&&this.ctx.emitter.emit("title:serverTimeReceived",t.data),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Fh=15,Vh="GameLoop",_h="BoardDefinition",gr=class{constructor(e){this.ctx=e;}ctx;get itemDefs(){return this.ctx.data.config.itemDefinitions}async getGameLoops(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getGameLoops(e);return t.ok&&(this.ctx.data.config.patchSection(Vh,t.data),this.ctx.emitter.emit("gameLoop:gameLoopsLoaded",t.data)),t}async getBoardDefinition(e=false){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");let i=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return i.ok&&(this.ctx.data.config.patchSection(_h,i.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",i.data)),i}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return s("client","stageLevel must be > 0.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(i,t);return r.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",r.data),r}async getUserBoardState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getUserBoardState(e);return t.ok&&(this.ctx.data.user.applyBoardState(t.data),this.ctx.emitter.emit("gameLoop:boardStateLoaded",t.data)),t}async boardLoopRoll(e=1){if(e<1)return s("client","rollMultiplier must be >= 1.");let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let n=r.data,a=$o(new Date,Fh);this.ctx.data.user.patchBoardState(c=>{c.Position=n.NewPosition,c.CyclesCompleted=(c.CyclesCompleted??0)+(n.CyclesCompletedDelta??0),c.LastRollAtUtc=new Date().toISOString(),n.ActionRequired&&n.ActionData?c.Pending={Type:n.ActionRequired,TargetUserID:n.ActionData.TargetUserID,TargetPublicData:n.ActionData.PublicData,TargetBuildingStates:n.ActionData.TargetBuildingStates??void 0,TargetHasShield:n.ActionData.TargetHasShield??void 0,RollMultiplier:n.UsedMultiplier??1,ExpiresAtUtc:a}:n.SpecialModeOffer&&(c.Pending={Type:"SPECIAL",RollMultiplier:n.UsedMultiplier??1,ExpiresAtUtc:a,Special:{ModeID:n.SpecialModeOffer.ModeID??void 0,Choices:n.SpecialModeOffer.Choices??void 0}});}),n.Operation&&this.ctx.data.user.applyResourcesWithDelta(n.Operation,n.Inventory,this.itemDefs),n.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",n);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(i);if(r.ok){let n=r.data;this.ctx.data.user.clearBoardPending(),n.IsBotTarget&&n.Operation?this.ctx.data.user.applyResourcesWithDelta(n.Operation,n.Inventory,this.itemDefs):!n.IsBotTarget&&n.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(n.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",n);}else await this.getUserBoardState();return r}async boardLoopRaid(e,t){if(e<0||e>11)return s("client","digIndex must be between 0 and 11.");let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${i.userID}_${k()}`},n=await this.ctx.api.gameLoop.boardLoopRaid(r);if(n.ok){let a=n.data;a.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(a.RaidLayout,a.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(a)),this.ctx.emitter.emit("gameLoop:boardRaided",a);}else await this.getUserBoardState();return n}async boardLoopRaidFast(e){if(!e.length)return s("client","digIndices must not be empty.");let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(i);if(r.ok){let n=r.data;n.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(n)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",n);}else await this.getUserBoardState();return r}async boardLoopBuild(e){if(e<0)return s("client","buildingIndex must be >= 0.");let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${k()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(i);if(r.ok){let n=r.data;n.StageComplete?this.ctx.data.user.patchBoardState(a=>{a.StageLevel=(a.StageLevel??1)+1,a.Position=0,a.Pending=null,a.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(n.BuiltIndex,a=>{n.NewLevel!=null&&(a.Level=n.NewLevel),a.IsDamaged=false,n.MaxLevelRewardClaimed&&(a.MaxLevelRewardClaimed=true);}),n.Operation&&this.ctx.data.user.applyResourcesWithDelta(n.Operation,n.Inventory,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",n);}return r}async boardSpecialChoose(e,t){if(!e)return s("client","choiceID must not be empty.");let i=this.ctx.auth.context;if(!i)return s("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${i.userID}_${k()}`},n=await this.ctx.api.gameLoop.boardSpecialChoose(r);if(n.ok){let a=n.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(m=>{m.ChoiceID=e,m.ChosenMode=a.Mode??"Timed",m.StartedAtUtc=a.StartedAtUtc??null,m.DurationSeconds=a.DurationSeconds??null,m.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourcesWithDelta(a.Operation,a.Inventory,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return n}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${k()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(i);if(r.ok){let n=r.data;this.ctx.data.user.patchBoardSpecialPending(a=>{a.AdViewsUsed=n.AdViewsUsed??0,a.AccumulatedMultiplier=n.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",n);}return r}async boardSpecialClaim(e){let t=this.ctx.auth.context;if(!t)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${k()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},r=await this.ctx.api.gameLoop.boardSpecialClaim(i);if(r.ok){let n=r.data;this.ctx.data.user.clearBoardPending(),n.Operation&&this.ctx.data.user.applyResourcesWithDelta(n.Operation,n.Inventory,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",n);}return r}async getCommunityChestState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return s("client","milestoneID is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourcesWithDelta(r.data.Resources,r.data.Inventory,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourcesWithDelta(i.data.Resources,i.data.Inventory,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourcesWithDelta(e.Operation,e.Inventory,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yr=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,i,r){let n=e.trim();if(!n)return s("client","FunctionName is required.");if(!this.ctx.auth.context)return s("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),FunctionName:n,FunctionParameter:t,RevisionSelection:i,SpecificRevision:r},c=await this.ctx.api.cloudCode.execute(a);return c.ok&&this.ctx.emitter.emit("cloudCode:executed",c.data),c}};var wa=zod.z.object({ServerTimeUtc:u,SourceType:Nt,SourceID:zod.z.string(),TargetType:Nt,TargetID:zod.z.string(),SourceSpent:q,FeeAmount:q,RateApplied:_,TargetCredited:q}),Ma=zod.z.object({ServerTimeUtc:u,SourceType:Nt,SourceID:zod.z.string(),TargetType:Nt,TargetID:zod.z.string(),SourceSpent:_,FeeAmount:_,RateApplied:_,TargetCredited:_}),Rr={Convert:"Convert",CryptoConvert:"CryptoConvert"},Wh={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},Oa=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Qh={Automatic:"Automatic",Manual:"Manual"},Kh=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),Hh=zod.z.object({ValueInUSD:_.nullish(),ValueInUSDUpdatedAt:u.nullish(),InitialDeposit:zod.z.number().nullish(),MinBalance:zod.z.number().nullish(),MaxBalance:zod.z.number().nullish(),DailyEarnLimit:zod.z.number().nullish(),DailySpendLimit:zod.z.number().nullish()}).passthrough(),$h=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Zh=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Jh=zod.z.object({TargetCurrencyType:Nt.nullish(),TargetCurrencyID:zod.z.string(),Rate:_.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Ua=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Kh.nullish(),Fee:zod.z.number().nullish(),Targets:zod.z.array(Jh).nullish()}).passthrough(),Ba=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),Yh=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Hh.nullish(),Recharge:$h.nullish(),Conversion:Ua.nullish(),Permissions:Zh.nullish(),Audit:Ba.nullish(),Status:Oa.nullish()}).passthrough(),Xh=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinWithdraw:_.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),em=zod.z.object({DailyWithdrawUsd:_.nullish(),MonthlyWithdrawUsd:_.nullish(),KycRequiredAboveUsd:_.nullish()}).passthrough(),tm=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),ds=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),DisplayDecimals:zod.z.number().nullish(),ValueInUSD:_.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:_.nullish(),CommunityMarketingDepositSharePercent:_.nullish(),WithdrawalBurnPercent:_.nullish(),Networks:zod.z.array(Xh).nullish(),Limits:em.nullish(),Permissions:tm.nullish(),Conversion:Ua.nullish(),Audit:Ba.nullish(),Status:Oa.nullish()}).passthrough(),Cr=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Yh).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),ds).nullish()}).passthrough();var im={EVM:"EVM",Solana:"Solana"},rm=zod.z.enum(["EVM","Solana"]).catch("EVM"),nm={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},sm=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),om={Token:"Token",Nft:"Nft"},qa=zod.z.enum(["Token","Nft"]).catch("Token"),am={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},lm=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),um={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},cm=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),pm={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},hs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),La={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Sr(o){let e=o?.trim();return e||La.GameTopUp}var dm={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ea=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),hm=zod.z.object({ContractAddress:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),Ga=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),mm=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:rm.nullish(),ChainID:zod.z.number().nullish(),ChainTicker:zod.z.string().nullish(),RewardPoolAddress:zod.z.string().nullish(),VaultDepositAddress:zod.z.string().nullish(),ChainConfigVersion:zod.z.number().nullish(),RequiredConfirmations:zod.z.number().nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ga.nullish(),NftCollections:zod.z.array(hm).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),fm=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Ga.nullish()}).passthrough(),gm=zod.z.object({MinAccountAgeDays:zod.z.number().nullish(),MultiAccountCheckEnabled:zod.z.boolean().nullish(),BanOnSharedWithdrawalAddress:zod.z.boolean().nullish(),PendingWithdrawalTtlHours:zod.z.number().nullish()}).passthrough();var ym=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),Rm=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:_.nullish(),BalanceSource:ym.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),Cm=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Rm).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),ms=zod.z.object({SystemState:fm.nullish(),Networks:zod.z.record(zod.z.string(),mm).nullish(),AccountSafety:gm.nullish(),WalletLogin:Cm.nullish()}).passthrough(),Sm=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:sm.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Na=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:qa.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:_.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),xm=zod.z.object({Status:lm.nullish(),Tier:cm.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),bm=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:_.nullish(),DepositsVolumeUsd:_.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:_.nullish(),WithdrawalsVolumeUsd:_.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),Dm=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:_.nullish(),TotalWithdrawalsVolumeUsd:_.nullish(),PerCurrency:zod.z.record(zod.z.string(),bm).nullish()}).passthrough(),zm=zod.z.object({NetworkID:zod.z.string().nullish(),ItemCatalogID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),Withdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),vm=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),PerCollection:zod.z.record(zod.z.string(),zm).nullish()}).passthrough(),Im=zod.z.object({Tokens:Dm.nullish(),Nfts:vm.nullish()}).passthrough(),Pm=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:_.nullish(),MinBalance:_.nullish()}).passthrough(),Tm=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),CheckedAt:u.nullish(),LoggedInAt:u.nullish(),GatePassed:zod.z.boolean().nullish(),GatedBalances:zod.z.array(Pm).nullish()}).passthrough(),Am=zod.z.object({Version:zod.z.number().nullish(),Stats:Im.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Sm).nullish(),LastWalletLogin:Tm.nullish(),PendingWithdrawals:zod.z.array(Na).nullish(),Kyc:xm.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),km=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:_,FrozenDelta:_,UpdatedAt:u}).passthrough(),xr=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),km).nullish(),PendingAdded:Na.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),wm=zod.z.object({Amount:_,Frozen:_,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Mm=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ea.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:_.nullish(),Status:hs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountUsd:_.nullish(),NetPayoutAmount:_.nullish()}).passthrough(),Om=zod.z.object({ID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CreatedAt:u.nullish(),UpdatedAt:u.nullish(),UserID:zod.z.string().nullish(),TransactionHash:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainType:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),Direction:Ea.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:_.nullish(),Status:hs.nullish(),SignatureData:zod.z.string().nullish(),CompletedAt:u.nullish(),ExpiresAt:u.nullish(),FailReason:zod.z.string().nullish(),Reason:zod.z.string().nullish(),Category:zod.z.string().nullish(),NFTID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),SkinID:zod.z.string().nullish()}).passthrough(),ja=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),fs=zod.z.object({TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ContractAddress:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(ja).nullish(),Signature:zod.z.string().nullish()}).passthrough(),gs=zod.z.object({Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),ProgramID:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(ja).nullish(),SignatureHex:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Fa=zod.z.object({Blockchain:ms.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),ds).nullish()}).passthrough(),Va=zod.z.object({State:Am.nullish(),CryptoBalances:zod.z.record(zod.z.string(),wm).nullish()}).passthrough(),_a=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:_.nullish(),AmountUsd:_.nullish(),StateDelta:xr.nullish()}).passthrough(),Wa=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),Resources:P.nullish(),Inventory:E.nullish()}).passthrough(),Qa=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:_.nullish(),NetAmountNative:_.nullish(),BurnAmountNative:_.nullish(),AmountUsd:_.nullish(),ExpiresAt:u.nullish(),EvmSignature:fs.nullish(),SolanaSignature:gs.nullish(),StateDelta:xr.nullish()}).passthrough(),Ka=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),NftTokenID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:P.nullish(),EvmSignature:fs.nullish(),SolanaSignature:gs.nullish(),StateDelta:xr.nullish(),Inventory:E.nullish()}).passthrough(),Ha=zod.z.object({TokenTransactions:zod.z.array(Mm).nullish(),NFTTransactions:zod.z.array(Om).nullish()}).passthrough(),ys=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:_.nullish(),AmountUsd:_.nullish(),Target:zod.z.string().nullish()}).passthrough(),$a=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:qa.nullish(),EvmSignature:fs.nullish(),SolanaSignature:gs.nullish()}).passthrough(),Za=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:hs.nullish(),StateDelta:xr.nullish()}).passthrough(),Ve={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Um="Blockchain",br=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Um,t.data.Blockchain),this.ctx.emitter.emit("blockchain:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getUserState(e);return t.ok&&(this.ctx.data.user.applyBlockchainState(t.data.State??null,t.data.CryptoBalances),this.ctx.emitter.emit("blockchain:userStateLoaded",t.data)),t}async depositToken(e,t){if(!e)return s("client","NetworkID is required.");if(!t)return s("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(i);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new zi__default.default(r.data.AmountNative??0),r.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",r.data)),r}async depositNFT(e,t){if(!e)return s("client","NetworkID is required.");if(!t)return s("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(i);return r.ok&&(this.ctx.data.user.applyResourcesWithDelta(r.data.Resources,r.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",r.data)),r}async requestTokenWithdrawal(e,t,i,r,n){if(!e)return s("client","CurrencyID is required.");if(!t)return s("client","NetworkID is required.");if(!i)return s("client","WalletAddress is required.");if(!r)return s("client","Amount is required.");let a=this.baseRequest();if(!a)return s("unauthorized","Not logged in.");a.CurrencyID=e,a.NetworkID=t,a.WalletAddress=i,a.Amount=r,a.Category=Sr(n);let c=await this.ctx.api.blockchain.requestTokenWithdrawal(a);return c.ok&&c.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(c.data.CurrencyID,new zi__default.default(c.data.AmountNative??0).negated(),c.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",c.data)),c}async requestNFTWithdrawal(e,t,i,r,n,a,c){if(!e)return s("client","ItemID is required.");if(!t)return s("client","NetworkID is required.");if(!i)return s("client","WalletAddress is required.");if(!r)return s("client","Amount is required.");let m=this.baseRequest();if(!m)return s("unauthorized","Not logged in.");m.ItemID=e,m.NetworkID=t,m.WalletAddress=i,m.Amount=r,m.Category=Sr(n),a!==void 0&&(m.Level=a),c&&(m.ItemInstanceID=c);let I=await this.ctx.api.blockchain.requestNFTWithdrawal(m);return I.ok&&(this.ctx.data.user.applyResourcesWithDelta(I.data.Resources,I.data.Inventory,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",I.data)),I}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.Amount=String(e);let i=await this.ctx.api.blockchain.getTransactionHistory(t);return i.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",i.data),i}async retryWithdrawal(e){if(!e)return s("client","TitleTransactionID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.TitleTransactionID=e;let i=await this.ctx.api.blockchain.retryWithdrawal(t);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",i.data),i}async confirmWithdrawal(e,t){if(!e)return s("client","TitleTransactionID is required.");if(!t)return s("client","On-chain TransactionHash is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.TitleTransactionID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(i);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",r.data),r}async donateToDeveloper(e,t){if(!e)return s("client","NetworkID is required.");if(!t)return s("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",r.data),r}async donateToUsersPool(e,t){if(!e)return s("client","NetworkID is required.");if(!t)return s("client","TransactionHash is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.NetworkID=e,i.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(i);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ze=zod.z.object({Username:zod.z.string().nullish(),Country:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Premium:zod.z.boolean().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),BoardRank:zod.z.number().nullish()}).passthrough();var Bm={Head:"Head",Torso:"Torso",Legs:"Legs"},Dr=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),qm={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Rs=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),Xa=zod.z.object({AttackTarget:Dr,DefenseTarget:Dr});var Lm=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),Em=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Dr.nullish(),DefenseZone:Dr.nullish(),HitType:Lm.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Gm=zod.z.object({MaxHp:zod.z.number().nullish(),CurrentHp:zod.z.number().nullish(),Damage:zod.z.number().nullish(),AttackSpeed:zod.z.number().nullish(),CritChance:zod.z.number().nullish(),CritMultiplier:zod.z.number().nullish(),Armor:zod.z.number().nullish(),DodgeChance:zod.z.number().nullish()}).passthrough(),Nm=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),CustomData:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough().transform(o=>o),Ya=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:is.nullish(),BattleStrategy:zod.z.array(Xa).nullish(),UnstackableItems:zod.z.record(zod.z.string(),Nm).nullish(),Stats:Gm.nullish()}).passthrough(),jm=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:be.nullish(),NetReward:be.nullish(),BattleLog:zod.z.array(Em).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:Ya.nullish(),P2BattleProfile:Ya.nullish()}).passthrough(),el=zod.z.object({MatchID:zod.z.string(),TitleID:zod.z.string().nullish(),RuleID:zod.z.string().nullish(),CreatedAt:u.nullish(),CreatorID:zod.z.string().nullish(),CreatorCharacterID:zod.z.string().nullish(),CreatorStrategy:zod.z.array(Xa).nullish(),TargetUserID:zod.z.string().nullish(),Entry:be.nullish(),CreationCostPaid:be.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Rs.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),tl=zod.z.object({Status:Rs,MatchID:zod.z.string(),Entry:be.nullish(),Resources:P.nullish()}),il=zod.z.object({Match:el.nullish()}),rl=zod.z.object({MatchID:zod.z.string(),Status:Rs,Resources:P.nullish()}),nl=zod.z.object({Battle:jm.nullish(),Resources:P.nullish(),ResourcesDual:It.nullish()}),Cs=zod.z.object({Matches:zod.z.array(el).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),ut={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Fm=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var Vm=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),_m=zod.z.object({HealthStatID:zod.z.string().nullish(),DamageStatID:zod.z.string().nullish(),ArmorStatID:zod.z.string().nullish(),AttackSpeedStatID:zod.z.string().nullish(),CritChanceStatID:zod.z.string().nullish(),CritDamageStatID:zod.z.string().nullish(),DodgeStatID:zod.z.string().nullish(),AllMightStatID:zod.z.string().nullish()}).passthrough(),Wm=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),Qm=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish(),ArmorMode:Wm.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),Km=zod.z.object({Kind:Vm.nullish(),Constant:zod.z.number().nullish(),VariableID:zod.z.string().nullish(),Argument:zod.z.string().nullish(),Curve:Ae.nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),Hm=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(Km).nullish()}).passthrough(),Tt=zod.z.object({Terms:zod.z.array(Hm).nullish()}).passthrough(),$m=zod.z.object({Health:Tt.nullish(),Damage:Tt.nullish(),Armor:Tt.nullish(),AttackSpeed:Tt.nullish(),CritChance:Tt.nullish(),CritDamage:Tt.nullish(),Dodge:Tt.nullish()}).passthrough(),sl=zod.z.object({StatMapping:_m.nullish(),Combat:Qm.nullish(),Formula:$m.nullish()}).passthrough(),Zm=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Ss=zod.z.object({Kind:Fm.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:yi.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),ol=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Ss).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),al=zod.z.object({PriceOptions:X.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ne.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),Jm=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Zm.nullish(),Entry:ol.nullish(),Creation:al.nullish(),Settings:sl.nullish()}).passthrough(),Ym=zod.z.object({Rules:zod.z.record(zod.z.string(),Jm).nullish(),Defaults:sl.nullish(),EntryDefaults:ol.nullish(),CreationDefaults:al.nullish()}).passthrough(),xs=zod.z.object({InstantBattle:Ym.nullish()}).passthrough(),ll=xs;var Xm={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},bs=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),ef={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Ds=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),tf={Burn:"Burn",Ledger:"Ledger"},rf=zod.z.enum(["Burn","Ledger"]).catch("Burn"),vr={Item:"Item",VirtualCurrency:"VirtualCurrency"},zs=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),nf=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:q.nullish()}).passthrough(),sf=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Ss).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),of=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:q.nullish(),Sink:rf.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),nf).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),af=zod.z.object({AllowedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedCatalogIDs:zod.z.array(zod.z.string()).nullish(),DeniedItemIDs:zod.z.array(zod.z.string()).nullish(),AllowUnstackableWithState:zod.z.boolean().nullish()}).passthrough(),lf=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ne.nullish(),BuyLimits:ne.nullish(),ListingFeeOptions:X.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),uf=zod.z.object({Enabled:zod.z.boolean().nullish(),MinDurationHours:zod.z.number().nullish(),MaxDurationHours:zod.z.number().nullish(),AntiSnipeWindowSeconds:zod.z.number().nullish(),AntiSnipeExtensionSeconds:zod.z.number().nullish(),MaxAntiSnipeExtensions:zod.z.number().nullish(),MinBidStepPercent:zod.z.number().nullish(),MinBidStepAbsolute:q.nullish(),BidLimits:ne.nullish()}).passthrough(),cf=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ne.nullish(),FillLimits:ne.nullish()}).passthrough(),pf=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ne.nullish()}).passthrough(),df=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),vs=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:V.nullish(),Schedule:se.nullish(),PricePolicy:sf.nullish(),Commission:of.nullish(),Tradability:af.nullish(),Listings:lf.nullish(),Auctions:uf.nullish(),BuyOrders:cf.nullish(),DirectTrades:pf.nullish(),Matching:df.nullish()}).passthrough(),ul=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:q.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),hf=zod.z.object({BidAxisType:mi.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:q.nullish(),CurrentBid:q.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(ul).nullish()}).passthrough(),zr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),mf=zod.z.object({Create:zr.nullish(),Buy:zr.nullish(),Sell:zr.nullish(),Bid:zr.nullish()}).passthrough(),ff=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),gf=zod.z.object({ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Quantity:zod.z.number().nullish(),RemainingUses:zod.z.number().nullish(),Level:zod.z.number().nullish(),AcquiredAt:u,ExpiresAt:u.nullish(),EquippedSlot:ff.nullish(),CustomData:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough().transform(o=>o),ft=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:bs.nullish(),Status:Ds.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:ze.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:zs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:q.nullish(),GoodsInstances:zod.z.array(gf).nullish(),Price:be.nullish(),Auction:hf.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),yf=zod.z.object({GoodsType:zs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(bs,q).nullish(),ListingCount:q.nullish(),AuctionCount:q.nullish(),BuyOrderCount:q.nullish()}).passthrough(),cl=zod.z.object({Definitions:vs.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Is=zod.z.object({Offers:zod.z.array(ft).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),pl=zod.z.object({Groups:zod.z.array(yf).nullish()}).passthrough(),dl=zod.z.object({Offer:ft.nullish()}).passthrough(),He=zod.z.object({OfferID:zod.z.string().nullish(),Status:Ds.nullish(),Settlement:It.nullish(),Resources:P.nullish(),CommissionTaken:be.nullish()}).passthrough(),oi=zod.z.object({OfferID:zod.z.string().nullish(),Offer:ft.nullish(),Resources:P.nullish(),Matched:zod.z.boolean().nullish(),Settlement:He.nullish()}).passthrough(),hl=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:q.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:P.nullish()}).passthrough(),ml=zod.z.object({MyOffers:zod.z.array(ft).nullish(),MyLeadingBids:zod.z.array(ft).nullish(),MyBuyOrders:zod.z.array(ft).nullish(),IncomingTrades:zod.z.array(ft).nullish(),OutgoingTrades:zod.z.array(ft).nullish(),Claimables:zod.z.array(ft).nullish(),DrainedRefunds:zod.z.array(ul).nullish(),Limits:mf.nullish()}).passthrough(),Rf=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:bs.nullish(),FinalStatus:Ds.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:zs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:q.nullish(),PricePaid:be.nullish(),CommissionTaken:be.nullish(),CompletedAt:u.nullish()}).passthrough(),fl=zod.z.object({Entries:zod.z.array(Rf).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),fe={GetDefinitions:"GetDefinitions",GetGroupedOffers:"GetGroupedOffers",GetOffersByItem:"GetOffersByItem",GetOffer:"GetOffer",GetBuyOrders:"GetBuyOrders",GetMyState:"GetMyState",GetHistory:"GetHistory",CreateListing:"CreateListing",CancelListing:"CancelListing",Buy:"Buy",MarketBuy:"MarketBuy",MarketSell:"MarketSell",CreateAuction:"CreateAuction",PlaceBid:"PlaceBid",ClaimAuction:"ClaimAuction",CreateBuyOrder:"CreateBuyOrder",CancelBuyOrder:"CancelBuyOrder",FillBuyOrder:"FillBuyOrder",CreateDirectTrade:"CreateDirectTrade",RespondDirectTrade:"RespondDirectTrade",CancelDirectTrade:"CancelDirectTrade",ClaimBack:"ClaimBack"};var Cf="Marketplace",Ir=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Cf,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return s("client","ItemID is required.");let n=this.baseRequest();if(!n)return s("unauthorized","Not logged in.");n.ItemID=e,n.OfferTypeFilter=t,n.ContinuationToken=i,n.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(n);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return s("client","OfferID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let n=await this.ctx.api.marketplace.getBuyOrders(r);return n.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",n.data),n}async getMyState(){let e=this.baseRequest();if(!e)return s("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,n,a,c){if(!e)return s("client","ItemID is required.");if(!t)return s("client","CatalogID is required.");if(!r)return s("client","PriceBundle is required.");let m=this.baseRequest();if(!m)return s("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=i,m.PriceBundle=r,m.DurationHours=n,m.ItemInstanceIDs=a,m.SelectedOptionID=c;let I=await this.ctx.api.marketplace.createListing(m);return this.applyCreateOfferResult(I,"marketplace:listingCreated"),I}async cancelListing(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelListing(t),"marketplace:listingCancelled")}async buy(e){if(!e)return s("client","OfferID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.buy(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:bought",i.data)),i}async marketBuy(e,t,i){if(!e||e<=0)return s("client","GoodsAmount must be positive.");if(!t)return s("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");let n=this.applyGoodsSelector(r,i);if(n)return n;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,i){if(!e||e<=0)return s("client","GoodsAmount must be positive.");if(!t)return s("client","PriceBundle is required.");let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");let n=this.applyGoodsSelector(r,i);if(n)return n;r.GoodsAmount=e,r.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(r);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,i,r,n,a,c={}){if(!e)return s("client","ItemID is required.");if(!t)return s("client","CatalogID is required.");let m=this.baseRequest();if(!m)return s("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=i,m.BidAxisType=r,m.BidCurrencyID=c.bidCurrencyID,m.BidCatalogID=c.bidCatalogID,m.BidItemID=c.bidItemID,m.StartingBid=n,m.DurationHours=a,m.ItemInstanceIDs=c.itemInstanceIDs,m.SelectedOptionID=c.selectedOptionID;let I=await this.ctx.api.marketplace.createAuction(m);return this.applyCreateOfferResult(I,"marketplace:auctionCreated"),I}async placeBid(e,t){if(!e)return s("client","OfferID is required.");if(!t||t<=0)return s("client","BidAmount must be positive.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.OfferID=e,i.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(i);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",r.data)),r}async claimAuction(e){if(!e)return s("client","OfferID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimAuction(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",i.data)),i}async createBuyOrder(e,t,i,r,n){if(!e)return s("client","ItemID is required.");if(!t)return s("client","CatalogID is required.");if(!r)return s("client","PriceBundle is required.");let a=this.baseRequest();if(!a)return s("unauthorized","Not logged in.");a.ItemID=e,a.CatalogID=t,a.GoodsAmount=i,a.PriceBundle=r,a.DurationHours=n;let c=await this.ctx.api.marketplace.createBuyOrder(a);return this.applyCreateOfferResult(c,"marketplace:buyOrderCreated"),c}async cancelBuyOrder(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelBuyOrder(t),"marketplace:buyOrderCancelled")}async fillBuyOrder(e){if(!e)return s("client","OfferID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.fillBuyOrder(t);return i.ok&&(this.applyDualPartySettlement(i.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",i.data)),i}async createDirectTrade(e,t,i,r,n){if(!e)return s("client","TargetUserID is required.");if(!t)return s("client","CatalogID is required.");if(!i)return s("client","ItemID is required.");let a=this.baseRequest();if(!a)return s("unauthorized","Not logged in.");a.TargetUserID=e,a.CatalogID=t,a.ItemID=i,a.ItemInstanceIDs=r,a.RequestedBundle=n;let c=await this.ctx.api.marketplace.createDirectTrade(a);return this.applyCreateOfferResult(c,"marketplace:directTradeCreated"),c}async respondDirectTrade(e,t){if(!e)return s("client","OfferID is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.OfferID=e,i.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(i);return r.ok&&(t&&(r.data.Settlement?this.applyDualPartySettlement(r.data.Settlement):r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",r.data)),r}async cancelDirectTrade(e){return this.cancelOffer(e,t=>this.ctx.api.marketplace.cancelDirectTrade(t),"marketplace:directTradeCancelled")}async claimBack(e){let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.claimBack(t);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",i.data)),i}async cancelOffer(e,t,i){if(!e)return s("client","OfferID is required.");let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.OfferID=e;let n=await t(r);return n.ok&&(this.ctx.data.user.applyResourceOperation(n.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(i,n.data)),n}applyCreateOfferResult(e,t){e.ok&&(e.data.Matched&&e.data.Settlement?this.applyDualPartySettlement(e.data.Settlement.Settlement):this.ctx.data.user.applyResourceOperation(e.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(t,e.data));}applyGoodsSelector(e,t){return "goodsCurrencyID"in t&&t.goodsCurrencyID?(e.GoodsType=vr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=vr.Item,e.ItemID=t.itemID,e.CatalogID=t.catalogID,null):s("client","Either itemID+catalogID or goodsCurrencyID is required.")}applyDualPartySettlement(e){let t=this.ctx.auth.context?.userID;if(!e||!t)return;let i=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,i):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,i);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pr=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return s("client","RoomName is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomName=e,i.Topology=t.topology,i.ChatMode=t.chatMode,i.MaxPlayers=t.maxPlayers,i.Visibility=t.visibility,i.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",r.data),r}async joinRoom(e,t){if(!e)return s("client","RoomID is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomID=e,i.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",r.data),r}async leaveRoom(e){if(!e)return s("client","RoomID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.leaveRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",i.data),i}async listRooms(e=0,t=20){let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.Page=e,i.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(i);return r.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",r.data),r}async getRoom(e){if(!e)return s("client","RoomID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.getRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",i.data),i}async closeRoom(e){if(!e)return s("client","RoomID is required.");let t=this.baseRequest();if(!t)return s("unauthorized","Not logged in.");t.RoomID=e;let i=await this.ctx.api.multiplayer.closeRoom(t);return i.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",i.data),i}async poll(e,t){if(!e)return s("client","RoomID is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomID=e,i.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(i);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,i,r){if(!e)return s("client","RoomID is required.");if(!t)return s("client","TargetUserID is required.");if(!i)return s("client","SignalKind is required.");let n=this.baseRequest();if(!n)return s("unauthorized","Not logged in.");n.RoomID=e,n.TargetUserID=t,n.SignalKind=i,n.Payload=r;let a=await this.ctx.api.multiplayer.sendSignal(n);return a.ok&&this.ctx.emitter.emit("multiplayer:signalSent",a.data),a}async sendChat(e,t){if(!e)return s("client","RoomID is required.");if(!t)return s("client","ChatText is required.");let i=this.baseRequest();if(!i)return s("unauthorized","Not logged in.");i.RoomID=e,i.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(i);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,i){if(!e)return s("client","RoomID is required.");let r=this.baseRequest();if(!r)return s("unauthorized","Not logged in.");r.RoomID=e,r.Ready=t,r.MemberState=i;let n=await this.ctx.api.multiplayer.setMemberState(r);return n.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",n.data),n}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gl=zod.z.object({PlatformUserID:zod.z.string().nullish(),PlatformAuthToken:zod.z.string().nullish(),PlatformAuthTokenExpiration:u.nullish(),TitleUserID:zod.z.string(),TitleClientSessionTicket:zod.z.string(),TitleClientSessionTicketExpiration:u}),yl=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),ve=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),Rl=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),je={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function M(o,e,t,i){let n=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?n:`${n}/${i}`}var Tr=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return M(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,gl,{ticket:null})}loginWithDeviceID(e){return this.login(je.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(je.LoginWithTelegram,e)}loginWithEmail(e){return this.login(je.LoginWithEmail,e)}loginWithGoogle(e){return this.login(je.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(je.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(je.RegisterWithEmail),e,yl,{ticket:null})}confirmEmailRegistration(e){return this.login(je.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(je.ResendVerificationCode),e,ve,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(je.RequestWalletChallenge),e,Rl,{ticket:null})}loginWithWallet(e){return this.login(je.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(je.ForgotPassword),e,ve,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(je.ResetPassword),e,ve,{ticket:null})}};var Sf={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},Cl=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),xf=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),Sl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),xf).nullish(),MissingKeyMode:Cl.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),bf=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),xl=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:bf.nullish()}).passthrough(),Ar={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},Df=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),bl=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:Cl.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(Df).nullish()}).passthrough(),Dl=zod.z.object({RequestedLocale:zod.z.string().nullish(),Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),NotModified:zod.z.boolean().nullish(),Entries:zod.z.record(zod.z.string(),zod.z.string()).nullish(),FallbackLocale:zod.z.string().nullish(),FallbackVersion:zod.z.number().nullish()}).passthrough();var Ps=zod.z.object({TitleConfigVersion:zod.z.string().nullish(),TitleConfigUrl:zod.z.string().nullish(),User:zod.z.unknown().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish(),Localization:xl.nullish()}).passthrough().transform(o=>o),zl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),vl=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),User:zod.z.unknown().nullish()}).passthrough().transform(o=>o),Il=zod.z.object({}).passthrough().transform(o=>o),Pl=zod.z.object({}).passthrough().transform(o=>o),Tl=zod.z.object({Today:zod.z.number(),Yesterday:zod.z.number(),CurrentWeek:zod.z.number(),CurrentMonth:zod.z.number(),Total:zod.z.number(),TotalSessions:zod.z.number(),FirstActiveAt:u.nullish(),LastActiveAt:u.nullish(),LongestSessionEverSeconds:zod.z.number().nullish(),CurrentWeekActiveHoursMask:zod.z.number().nullish(),CurrentMonthActiveHoursMask:zod.z.number().nullish(),ReactivationCount:zod.z.number().nullish(),History:zod.z.record(zod.z.string(),zod.z.unknown()).nullish()}).passthrough(),Al=zod.z.object({Username:zod.z.string()}),Ze={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var kr=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return M(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Ze.GetClientState,e.UserID),e,Ps,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Ze.GetClientStateExcept,e.UserID),e,Ps,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Ze.GetStateVersions,e.UserID),e,zl,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Ze.GetUserState,e.UserID),e,vl,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Ze.GetInventory,e.UserID),e,Il,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Ze.GetEventTokens,e.UserID),e,Pl,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Ze.GetUsageTime,e.UserID),e,Tl,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Ze.AddUsageTime,e.UserID),e,ve,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Ze.DeleteUserAccount,e.UserID),e,ve,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Ze.ChangeUsername,e.UserID),e,Al,{ticket:e.ClientSessionTicket})}};var wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Rr.Convert,e,wa)}cryptoConvert(e){return this.send(Rr.CryptoConvert,e,Ma)}};var zf=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Ts=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:P.nullish(),FodderConsumed:zod.z.array(zf).nullish()}),kl=zod.z.array(ue(Ts)),Mr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},vf={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},If=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Pf={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},Tf=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),Af=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),kf=zod.z.object({Networks:zod.z.record(zod.z.string(),Af).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),wf=zod.z.object({FlatBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),PercentBonuses:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Power:zod.z.number().nullish()}).passthrough(),Mf=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),UseRequirements:zod.z.record(zod.z.string(),zod.z.number()).nullish(),AllowedCharacterIDs:zod.z.array(zod.z.string()).nullish(),AllowedSlotIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Of=zod.z.object({ValuationMode:If.nullish(),WeightCurve:Ae.nullish(),Selection:Tf.nullish()}).passthrough(),Uf=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:X.nullish(),CostCurve:Ae.nullish(),FlatBonusCurve:Ae.nullish(),PercentBonusCurve:Ae.nullish(),PowerCurve:Ae.nullish(),Fodder:Of.nullish()}).passthrough(),Bf=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),qf=zod.z.object({ItemID:zod.z.string(),CatalogID:zod.z.string(),ItemClass:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),CustomData:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsStackable:zod.z.boolean().nullish(),IsTradable:zod.z.boolean().nullish(),Weight:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),NFT:kf.nullish(),Stats:wf.nullish(),Equipment:Mf.nullish(),Upgrade:Uf.nullish(),Metadata:Bf.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Lf=zod.z.object({Items:zod.z.record(zod.z.string(),qf).nullish()}).passthrough(),Or=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Lf).nullish()}).passthrough();var Ur=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=M(this.ctx.settings.titleID,"Item",Mr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Ts,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=M(this.ctx.settings.titleID,"Item",Mr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,kl,{ticket:e.ClientSessionTicket})}};var As=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:P.nullish(),Inventory:E.nullish()}),wl=zod.z.array(ue(As)),Ef=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),Gf=zod.z.object({SlotKey:zod.z.string(),InstanceKey:zod.z.string(),OfferID:zod.z.string().nullish(),Purchases:zod.z.number(),LastPurchasedAt:u}),Ml=zod.z.object({Purchases:zod.z.record(zod.z.string(),Ef).nullish(),Rotations:zod.z.record(zod.z.string(),Gf).nullish()}).passthrough().transform(o=>o),bt=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ks=zod.z.object({Schedule:se.nullish(),Gate:V.nullish()}).passthrough(),Nf={Fixed:"Fixed",Title:"Title",Player:"Player"},jf=zod.z.object({OfferID:zod.z.string().nullish(),Weight:zod.z.number().nullish(),Gate:V.nullish()}).passthrough(),Ff=zod.z.object({Mode:zod.z.string().nullish(),OfferID:zod.z.string().nullish(),Pool:zod.z.array(jf).nullish(),Salt:zod.z.string().nullish(),PerInstanceCap:zod.z.number().nullish()}).passthrough(),Vf=zod.z.object({SlotID:zod.z.string().nullish(),Identity:bt.nullish(),Availability:ks.nullish(),Rotation:Ff.nullish()}).passthrough(),_f=zod.z.object({SectionID:zod.z.string().nullish(),Identity:bt.nullish(),Availability:ks.nullish(),Slots:zod.z.record(zod.z.string(),Vf).nullish(),UniqueOffersInSection:zod.z.boolean().nullish()}).passthrough(),Wf=zod.z.object({Sections:zod.z.record(zod.z.string(),_f).nullish()}).passthrough(),Qf=zod.z.object({StoreID:zod.z.string().nullish(),Identity:bt.nullish(),Availability:ks.nullish(),Layout:Wf.nullish()}).passthrough(),Kf=zod.z.object({Options:X.nullish(),CompareAt:zod.z.record(zod.z.string(),dt).nullish()}).passthrough(),Hf=zod.z.object({Grant:j.nullish()}).passthrough(),$f=zod.z.object({Schedule:se.nullish(),Gate:V.nullish(),Limits:ne.nullish()}).passthrough(),Zf=zod.z.object({OfferID:zod.z.string().nullish(),Identity:bt.nullish(),Pricing:Kf.nullish(),Reward:Hf.nullish(),Availability:$f.nullish()}).passthrough(),Br=zod.z.object({Stores:zod.z.record(zod.z.string(),Qf).nullish(),StoreOffers:zod.z.record(zod.z.string(),Zf).nullish()}).passthrough(),Jf=zod.z.object({PurchasedTotal:zod.z.number(),PurchasedToday:zod.z.number(),PurchasedThisRotation:zod.z.number(),RemainingTotal:zod.z.number().nullish(),RemainingToday:zod.z.number().nullish(),IsFirstPurchaseAvailable:zod.z.boolean(),SoldOut:zod.z.boolean(),AvailableAtUtc:u.nullish()}).passthrough(),Yf=zod.z.object({OptionID:zod.z.string(),Name:zod.z.string().nullish(),Cost:dt.nullish(),CompareAtCost:dt.nullish(),DiscountPercent:zod.z.number().nullish(),IsFree:zod.z.boolean(),IsAdPaid:zod.z.boolean(),IsStorePaid:zod.z.boolean(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xf=zod.z.object({OfferID:zod.z.string(),Identity:bt.nullish(),PriceOptions:zod.z.array(Yf).nullish(),Rewards:j.nullish(),State:Jf.nullish()}).passthrough(),eg=zod.z.object({SlotID:zod.z.string(),Identity:bt.nullish(),SortOrder:zod.z.number(),RotationMode:zod.z.string().nullish(),RotationInstanceKey:zod.z.string().nullish(),RefreshesAtUtc:u.nullish(),RemainingThisRotation:zod.z.number().nullish(),Offer:Xf.nullish()}).passthrough(),tg=zod.z.object({SectionID:zod.z.string(),Identity:bt.nullish(),SortOrder:zod.z.number(),Slots:zod.z.array(eg).nullish()}).passthrough(),ig=zod.z.object({StoreID:zod.z.string(),Identity:bt.nullish(),SortOrder:zod.z.number(),ScheduleInstanceKey:zod.z.string().nullish(),ExpiresAtUtc:u.nullish(),Sections:zod.z.array(tg).nullish()}).passthrough(),Ol=zod.z.object({ServerTimeUtc:u,Stores:zod.z.array(ig).nullish(),AdCreditBalance:zod.z.number()}).passthrough(),At={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch",GetStorefront:"GetStorefront"},rg="OFFER_NOT_IN_ROTATION";var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(At.Purchase,e,As)}purchaseBatch(e){return this.send(At.PurchaseBatch,e,wl)}getDefinitions(e){return this.send(At.GetDefinitions,e,Br)}getUserState(e){return this.send(At.GetUserState,e,Ml)}getStorefront(e){return this.send(At.GetStorefront,e,Ol)}};var ng={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},sg=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),og=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:V.nullish(),Limits:ne.nullish()}).passthrough(),ag=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),lg=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:sg.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:j.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:og.nullish(),Refund:ag.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ul=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),lg).nullish()}).passthrough(),Bl=zod.z.object({ProductID:zod.z.string().nullish(),TotalPurchases:zod.z.number().nullish(),DailyPurchases:zod.z.number().nullish(),DailyResetUtc:u.nullish(),LastPurchasedAt:u.nullish(),Owned:zod.z.boolean().nullish(),Refunded:zod.z.boolean().nullish(),PurchaseBlocked:zod.z.boolean().nullish()}).passthrough(),ql=zod.z.object({Products:zod.z.record(zod.z.string(),Bl).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),ug={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},cg=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),ws=zod.z.object({ServerTimeUtc:u,Store:gi.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:cg.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:P.nullish(),Inventory:E.nullish(),ProductState:Bl.nullish()}).passthrough(),Ll=at(ws),Ht={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var Lr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ht.GetDefinitions,e,Ul)}getUserState(e){return this.send(Ht.GetUserState,e,ql)}validatePurchase(e){return this.send(Ht.ValidatePurchase,e,ws)}validatePurchasesBatch(e){return this.send(Ht.ValidatePurchasesBatch,e,Ll)}};var pg=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),El=zod.z.object({Reward:j.nullish(),Weight:zod.z.number().nullish(),AmountRange:pg.nullish()}).passthrough(),$t=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(El).nullish()}).passthrough(),Zt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(El).nullish()}).passthrough(),dg=zod.z.object({RewardSlots:zod.z.array($t).nullish()}).passthrough(),hg=zod.z.object({PityRules:zod.z.array(Zt).nullish()}).passthrough(),Er=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),dg).nullish(),PityPresets:zod.z.record(zod.z.string(),hg).nullish()}).passthrough();var mg=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Gl=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish(),Results:zod.z.array(P).nullish(),TriggeredPity:zod.z.array(mg).nullish()}),fg=zod.z.object({RewardSlots:$.nullish(),PityRules:$.nullish()}).passthrough(),gg=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:q.nullish()}).passthrough(),yg=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:X.nullish(),RewardSlots:zod.z.array($t).nullish(),PityRules:zod.z.array(Zt).nullish(),Presets:fg.nullish(),RewardMultiplier:Ri.nullish(),SupplyLimits:zod.z.array(gg).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Ms=zod.z.object({Definitions:zod.z.record(zod.z.string(),yg).nullish(),RewardPools:Er.nullish()}).passthrough(),Nl=zod.z.object({LootboxDefinitions:Ms.nullish()}),Gr={GetDefinitions:"GetDefinitions",Open:"Open"};var Nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Gr.GetDefinitions,e,Nl)}open(e){return this.send(Gr.Open,e,Gl)}};var Rg=zod.z.object({}).passthrough().transform(o=>o),Cg=zod.z.object({}).passthrough().transform(o=>o),Sg=zod.z.object({}).passthrough().transform(o=>o),xg=zod.z.object({}).passthrough().transform(o=>o),bg=zod.z.object({}).passthrough().transform(o=>o),jl=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:Rg,Resources:P.nullish(),Inventory:E.nullish()}),Fl=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:q.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Cg,Resources:P.nullish(),Inventory:E.nullish()}),Vl=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Sg,Resources:P.nullish(),Inventory:E.nullish()}),_l=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:xg,Resources:P.nullish(),Inventory:E.nullish()}),Wl=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:q.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Dg=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),zg=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:j.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vg=zod.z.object({CalendarID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Days:zod.z.array(zg).nullish(),IsLooping:zod.z.boolean().nullish(),MissBehavior:zod.z.string().nullish(),ResetByDays:zod.z.number().nullish(),MissThresholdMultiplier:zod.z.number().nullish(),ClaimMode:zod.z.string().nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Ig=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Pg=zod.z.object({BaseRatePerSecond:zod.z.number().nullish(),PowerCoefficient:zod.z.number().nullish(),BoardRankCoefficient:zod.z.number().nullish(),EquipmentBonusEnabled:zod.z.boolean().nullish(),EquipmentCharacterID:zod.z.string().nullish(),PremiumMultipliers:zod.z.array(Ig).nullish()}).passthrough(),Tg=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:V.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ag=zod.z.object({AccrualID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rate:Pg.nullish(),Rewards:j.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Tg.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),kg=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:j.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),wg=zod.z.object({ComebackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(kg).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Mg=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),CooldownSeconds:zod.z.number().nullish(),MaxClaimsPerWindow:zod.z.number().nullish(),WindowSeconds:zod.z.number().nullish(),TotalClaimLimit:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({ClaimID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Mode:zod.z.string().nullish(),Rewards:j.nullish(),Limits:ne.nullish(),PremiumLimitOverrides:zod.z.array(Mg).nullish(),Gate:V.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Os=zod.z.object({TierRewards:Dg.nullish(),MilestoneRewardMultiplier:Ri.nullish(),DailyCalendars:zod.z.record(zod.z.string(),vg).nullish(),IdleAccruals:zod.z.record(zod.z.string(),Ag).nullish(),Comebacks:zod.z.record(zod.z.string(),wg).nullish(),Claims:zod.z.record(zod.z.string(),Og).nullish()}).passthrough(),Ql=zod.z.object({RewardDefinitions:Os.nullish()}),Kl=zod.z.object({Rewards:bg.nullish()}),gt={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var jr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(gt.GetRewardDefinitions,e,Ql)}getUserRewardsState(e){return this.send(gt.GetUserRewardsState,e,Kl)}getMilestoneRewardMultiplier(e){return this.send(gt.GetMilestoneRewardMultiplier,e,Wl)}claimDailyReward(e){return this.send(gt.ClaimDailyReward,e,jl)}collectIdleAccrual(e){return this.send(gt.CollectIdleAccrual,e,Fl)}claimComebackReward(e){return this.send(gt.ClaimComebackReward,e,Vl)}claimReward(e){return this.send(gt.ClaimReward,e,_l)}};var Fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(Qe.GetTutorialDefinitions,e,No)}getUserTutorialState(e){return this.send(Qe.GetUserTutorialState,e,Fo)}startFlow(e){return this.send(Qe.StartFlow,e,St)}reportStepShown(e){return this.send(Qe.ReportStepShown,e,St)}completeStep(e){return this.send(Qe.CompleteStep,e,St)}completeStepsBatch(e){return this.send(Qe.CompleteStepsBatch,e,_o)}skipStep(e){return this.send(Qe.SkipStep,e,St)}skipFlow(e){return this.send(Qe.SkipFlow,e,St)}claimFlowReward(e){return this.send(Qe.ClaimFlowReward,e,Vo)}resetFlow(e){return this.send(Qe.ResetFlow,e,St)}};var Ug={Open:"Open",Application:"Application"},Bg=zod.z.enum(["Open","Application"]).catch("Open"),qg={Pending:"Pending",Approved:"Approved",Rejected:"Rejected",Suspended:"Suspended",Left:"Left"},Hl=zod.z.enum(["Pending","Approved","Rejected","Suspended","Left"]).catch("Pending"),Lg={VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency"},Us=zod.z.enum(["VirtualCurrency","CryptoCurrency"]).catch("VirtualCurrency"),Eg={Views:"Views",Likes:"Likes",Comments:"Comments",Shares:"Shares"};zod.z.enum(["Views","Likes","Comments","Shares"]).catch("Views");var kt={GetCommunityMarketingState:"GetCommunityMarketingState",GetEarnings:"GetEarnings",Claim:"Claim",WithdrawCryptoReward:"WithdrawCryptoReward",CheckJoinEligibility:"CheckJoinEligibility"},Gg=zod.z.object({CampaignID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),DescriptionKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IsRunning:zod.z.boolean().nullish()}).passthrough(),$l=zod.z.object({IsEnabled:zod.z.boolean().nullish(),CreatorPortalUrl:zod.z.string().nullish(),ParticipationMode:Bg.nullish(),IsCreator:zod.z.boolean().nullish(),CreatorStatus:Hl.nullish(),VerificationCode:zod.z.string().nullish(),TeamID:zod.z.string().nullish(),Campaigns:zod.z.array(Gg).nullish()}).passthrough(),Ng=zod.z.object({Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),CountedMetrics:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ReachedMilestones:zod.z.array(zod.z.string()).nullish(),CappedBySubmissionLimit:zod.z.boolean().nullish(),CappedByCreatorLimit:zod.z.boolean().nullish()}).passthrough(),jg=zod.z.object({CampaignID:zod.z.string().nullish(),CurrencyKind:Us.nullish(),CurrencyID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),Earned:zod.z.number().nullish(),Mature:zod.z.number().nullish(),Granted:zod.z.number().nullish(),Paid:zod.z.number().nullish(),Overpaid:zod.z.number().nullish(),Claimable:zod.z.number().nullish(),BySubmission:zod.z.record(zod.z.string(),Ng).nullish(),ComputedAt:zod.z.string().nullish()}).passthrough(),Fg=zod.z.object({PayoutID:zod.z.string().nullish(),CampaignID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:Us.nullish(),NetworkID:zod.z.string().nullish(),PaidAt:zod.z.string().nullish()}).passthrough(),Zl=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),HoldDays:zod.z.number().nullish(),Campaigns:zod.z.array(jg).nullish(),Payouts:zod.z.array(Fg).nullish()}).passthrough(),Jl=zod.z.object({CampaignID:zod.z.string().nullish(),PayoutID:zod.z.string().nullish(),Claimed:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),CurrencyKind:Us.nullish(),NetworkID:zod.z.string().nullish(),RemainingFraction:zod.z.number().nullish(),IdempotentReplay:zod.z.boolean().nullish(),Message:zod.z.string().nullish()}).passthrough(),Vg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.string().nullish()}).passthrough(),_g=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenAddress:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),TokenId:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),Signature:zod.z.string().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish(),Deadline:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Splits:zod.z.array(Vg).nullish()}).passthrough(),Wg=zod.z.object({Kind:zod.z.string().nullish(),Target:zod.z.string().nullish(),Required:zod.z.number().nullish(),Actual:zod.z.number().nullish(),Passed:zod.z.boolean().nullish()}).passthrough(),Yl=zod.z.object({Passed:zod.z.boolean().nullish(),Approved:zod.z.boolean().nullish(),Status:Hl.nullish(),WalletMissing:zod.z.boolean().nullish(),WalletConnectAllowed:zod.z.boolean().nullish(),Conditions:zod.z.array(Wg).nullish()}).passthrough(),Qg=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),Kg=zod.z.object({ProgramID:zod.z.string().nullish(),Mint:zod.z.string().nullish(),WalletAddress:zod.z.string().nullish(),Amount:zod.z.string().nullish(),BurnAmount:zod.z.string().nullish(),Nonce:zod.z.string().nullish(),ExpiresAt:zod.z.string().nullish(),SignatureEpoch:zod.z.string().nullish(),Domain:zod.z.string().nullish(),Splits:zod.z.array(Qg).nullish(),SignatureHex:zod.z.string().nullish(),Ed25519PublicKey:zod.z.string().nullish(),Ed25519Message:zod.z.string().nullish(),SigIxIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),Category:zod.z.string().nullish()}).passthrough(),Xl=zod.z.object({ServerTimeUtc:zod.z.string().nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),ChainID:zod.z.number().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:zod.z.number().nullish(),NetAmountNative:zod.z.number().nullish(),BurnAmountNative:zod.z.number().nullish(),AmountUsd:zod.z.number().nullish(),ExpiresAt:zod.z.string().nullish(),EvmSignature:_g.nullish(),SolanaSignature:Kg.nullish()}).passthrough();var Vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"CommunityMarketing",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCommunityMarketingState(e){return this.send(kt.GetCommunityMarketingState,e,$l)}getEarnings(e){return this.send(kt.GetEarnings,e,Zl)}claim(e){return this.send(kt.Claim,e,Jl)}checkJoinEligibility(e){return this.send(kt.CheckJoinEligibility,e,Yl)}withdrawCryptoReward(e){return this.send(kt.WithdrawCryptoReward,e,Xl)}};var Hg={Global:"Global",Announcement:"Announcement",Group:"Group"},tu=zod.z.enum(["Global","Announcement","Group"]).catch("Global"),$g={None:"None",Language:"Language",Region:"Region"},Zg=zod.z.enum(["None","Language","Region"]).catch("None"),Jg={Anyone:"Anyone",Friends:"Friends"},Yg=zod.z.enum(["Anyone","Friends"]).catch("Anyone"),Xg={Reject:"Reject",Mask:"Mask"},ey=zod.z.enum(["Reject","Mask"]).catch("Reject"),ty={Player:"Player",Publisher:"Publisher",System:"System"},iy=zod.z.enum(["Player","Publisher","System"]).catch("Player"),ry={Spam:"Spam",Abuse:"Abuse",Scam:"Scam",Inappropriate:"Inappropriate",Other:"Other"};zod.z.enum(["Spam","Abuse","Scam","Inappropriate","Other"]).catch("Other");var ny=zod.z.object({DisplayNameKey:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),IconPath:zod.z.string().nullish(),JoinedByDefault:zod.z.boolean().nullish()}).passthrough(),iu=zod.z.object({Gate:V.nullish(),Schedule:se.nullish()}).passthrough(),ru=zod.z.object({Gate:V.nullish(),Limits:ne.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),nu=zod.z.object({HotTailSize:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish()}).passthrough(),sy=zod.z.object({Availability:$.nullish(),Write:$.nullish(),Retention:$.nullish()}).passthrough(),oy=zod.z.object({ChannelID:zod.z.string().nullish(),Identity:ny.nullish(),Type:tu.nullish(),GroupSource:zod.z.string().nullish(),Partitioning:Zg.nullish(),Capacity:zod.z.number().nullish(),Availability:iu.nullish(),Write:ru.nullish(),Retention:nu.nullish(),Presets:sy.nullish()}).passthrough(),ay=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Gate:V.nullish(),WhoCanMessage:Yg.nullish(),Limits:ne.nullish(),MaxLength:zod.z.number().nullish(),HistoryHours:zod.z.number().nullish(),MaxConversations:zod.z.number().nullish()}).passthrough(),ly=zod.z.object({BlockedTerms:zod.z.array(zod.z.string()).nullish(),BlockedTermAction:ey.nullish(),MaxIgnoreListSize:zod.z.number().nullish(),ReportsEnabled:zod.z.boolean().nullish(),ReportLimits:ne.nullish()}).passthrough(),uy=zod.z.object({MinIntervalSeconds:zod.z.number().nullish(),MaxMessagesPerPoll:zod.z.number().nullish(),MaxHistoryPageSize:zod.z.number().nullish()}).passthrough(),cy=zod.z.object({Availability:zod.z.record(zod.z.string(),iu).nullish(),Write:zod.z.record(zod.z.string(),ru).nullish(),Retention:zod.z.record(zod.z.string(),nu).nullish()}).passthrough(),su=zod.z.object({IsEnabled:zod.z.boolean().nullish(),Channels:zod.z.record(zod.z.string(),oy).nullish(),Direct:ay.nullish(),Moderation:ly.nullish(),Polling:uy.nullish(),Presets:cy.nullish()}).passthrough(),py=zod.z.object({LastReadAt:zod.z.string().nullish(),LastReadMessageID:zod.z.string().nullish(),Left:zod.z.boolean().nullish()}).passthrough(),eu=zod.z.object({LastAt:zod.z.string().nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:zod.z.string().nullish(),TotalCount:zod.z.number().nullish(),LastTextHash:zod.z.string().nullish()}).passthrough();zod.z.object({MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish(),Ignored:zod.z.array(zod.z.string()).nullish(),Channels:zod.z.record(zod.z.string(),py).nullish(),Limits:zod.z.record(zod.z.string(),eu).nullish(),ReportLimits:eu.nullish()}).passthrough();var Bs=zod.z.object({RoomID:zod.z.string().nullish(),SentAt:zod.z.string().nullish(),MessageID:zod.z.string().nullish()}).passthrough(),_r=zod.z.object({RoomID:zod.z.string().nullish(),ChannelID:zod.z.string().nullish(),MessageID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderProfile:ze.nullish(),AuthorType:iy.nullish(),Text:zod.z.string().nullish(),SentAt:zod.z.string().nullish()}).passthrough(),dy=zod.z.object({ChannelID:zod.z.string().nullish(),RoomID:zod.z.string().nullish(),DisplayNameKey:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:tu.nullish(),CanWrite:zod.z.boolean().nullish(),WriteBlockedReason:zod.z.string().nullish(),SlowModeSeconds:zod.z.number().nullish(),MaxLength:zod.z.number().nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),ou=zod.z.object({Channels:zod.z.array(dy).nullish(),PollIntervalSeconds:zod.z.number().nullish(),MutedUntil:zod.z.string().nullish(),MuteReason:zod.z.string().nullish()}).passthrough(),hy=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(_r).nullish(),NextCursor:Bs.nullish(),UnreadCount:zod.z.number().nullish(),ServedFromDatabase:zod.z.boolean().nullish()}).passthrough(),au=zod.z.object({Rooms:zod.z.array(hy).nullish(),PollIntervalSeconds:zod.z.number().nullish()}).passthrough(),lu=zod.z.object({RoomID:zod.z.string().nullish(),Messages:zod.z.array(_r).nullish(),NextBefore:Bs.nullish()}).passthrough(),uu=zod.z.object({Message:_r.nullish(),Moderated:zod.z.boolean().nullish()}).passthrough(),cu=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:ze.nullish(),MaxLength:zod.z.number().nullish()}).passthrough(),my=zod.z.object({RoomID:zod.z.string().nullish(),PeerUserID:zod.z.string().nullish(),PeerProfile:ze.nullish(),LastMessage:_r.nullish(),UnreadCount:zod.z.number().nullish(),LastReadAt:zod.z.string().nullish()}).passthrough(),pu=zod.z.object({Conversations:zod.z.array(my).nullish()}).passthrough(),Jt=zod.z.object({Ignored:zod.z.array(zod.z.string()).nullish(),Cursor:Bs.nullish(),Joined:zod.z.boolean().nullish()}).passthrough(),du=zod.z.object({ReportID:zod.z.string().nullish(),AlreadyReported:zod.z.boolean().nullish()}).passthrough(),qe={GetChatDefinitions:"GetChatDefinitions",GetChannels:"GetChannels",Poll:"Poll",GetHistory:"GetHistory",GetConversations:"GetConversations",SendMessage:"SendMessage",OpenDirectChannel:"OpenDirectChannel",MarkRead:"MarkRead",JoinChannel:"JoinChannel",LeaveChannel:"LeaveChannel",ReportMessage:"ReportMessage",IgnoreUser:"IgnoreUser",UnignoreUser:"UnignoreUser"};var Wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Chat",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getChatDefinitions(e){return this.send(qe.GetChatDefinitions,e,su)}getChannels(e){return this.send(qe.GetChannels,e,ou)}poll(e){return this.send(qe.Poll,e,au)}getHistory(e){return this.send(qe.GetHistory,e,lu)}getConversations(e){return this.send(qe.GetConversations,e,pu)}sendMessage(e){return this.send(qe.SendMessage,e,uu)}openDirectChannel(e){return this.send(qe.OpenDirectChannel,e,cu)}markRead(e){return this.send(qe.MarkRead,e,Jt)}joinChannel(e){return this.send(qe.JoinChannel,e,Jt)}leaveChannel(e){return this.send(qe.LeaveChannel,e,Jt)}reportMessage(e){return this.send(qe.ReportMessage,e,du)}ignoreUser(e){return this.send(qe.IgnoreUser,e,Jt)}unignoreUser(e){return this.send(qe.UnignoreUser,e,Jt)}};var Qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Push",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getPushConfig(e){return this.send(Qt.GetPushConfig,e,ta)}subscribePush(e){return this.send(Qt.SubscribePush,e,ts)}unsubscribePush(e){return this.send(Qt.UnsubscribePush,e,ve)}getPushSubscriptions(e){return this.send(Qt.GetPushSubscriptions,e,ia)}};var Kr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${r}:${t.Locale}`:r})}getLocalizationManifest(e){return this.send(Ar.GetLocalizationManifest,e,bl)}getLocalizationTable(e){return this.send(Ar.GetLocalizationTable,e,Dl)}};var Hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(tt.GetQuestDefinitions,e,Si)}getUserQuestState(e){return this.send(tt.GetUserQuestState,e,To)}refreshQuestCycles(e){return this.send(tt.RefreshQuestCycles,e,ve)}claimQuestReward(e){return this.send(tt.ClaimQuestReward,e,Vn)}claimQuestRewardsBatch(e){return this.send(tt.ClaimQuestRewardsBatch,e,wo)}claimMilestoneReward(e){return this.send(tt.ClaimMilestoneReward,e,_n)}claimMilestoneRewardsBatch(e){return this.send(tt.ClaimMilestoneRewardsBatch,e,Mo)}claimGroupCompletionReward(e){return this.send(tt.ClaimGroupCompletionReward,e,Ao)}addQuestProgress(e){return this.send(tt.AddQuestProgress,e,ko)}};var hu=zod.z.object({}).passthrough().transform(o=>o);var fy=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),gy=zod.z.object({Schedule:zod.z.array(fy).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),yy=zod.z.object({IsActive:zod.z.boolean().nullish(),CurrentPhaseEndUtc:u.nullish(),NextBonusStartUtc:u.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentPhaseIndex:zod.z.number().nullish(),ActiveBonusMultiplier:zod.z.number().nullish()}).passthrough(),Ry=zod.z.object({Milestones:$.nullish()}).passthrough(),qs=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Category:zod.z.string().nullish(),Token:Pt.nullish(),TokenSources:zod.z.array(We).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),Me).nullish(),Presets:Ry.nullish(),BonusWindow:gy.nullish()}).passthrough(),Cy=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:qs.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Sy=zod.z.object({TimedEventID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:se.nullish(),Content:qs.nullish(),Events:zod.z.array(Cy).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),xy=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),by=zod.z.object({Milestones:zod.z.record(zod.z.string(),jt).nullish()}).passthrough(),$r=zod.z.object({Definitions:zod.z.record(zod.z.string(),Sy).nullish(),Settings:xy.nullish(),Presets:by.nullish()}).passthrough(),Dy=zod.z.object({Type:ni,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:qs.nullish(),Progress:hu.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:Me.nullish(),BonusWindow:yy.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),mu=zod.z.object({ActiveEvents:zod.z.array(Dy).nullish()}).passthrough(),fu=zod.z.object({Tokens:zod.z.record(zod.z.string(),hu).nullish()}),Ls=zod.z.object({Type:ni.nullish(),LteID:zod.z.string().nullish(),Resources:P.nullish()}),Es=zod.z.object({Type:ni.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:P.nullish(),Inventory:E.nullish()}),zy=zod.z.object({Type:ni.nullish(),LteID:zod.z.string().nullish(),Resources:P.nullish()}),Gs=zod.z.array(ue(Es)),gu=zod.z.array(ue(Ls)),yu=zod.z.array(ue(zy)),Je={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Je.GetActiveEvents,e,mu)}getDefinitions(e){return this.send(Je.GetDefinitions,e,$r)}getUserLteState(e){return this.send(Je.GetUserLteState,e,fu)}grantTokens(e){return this.send(Je.GrantTokens,e,P)}spendTokens(e){return this.send(Je.SpendTokens,e,Ls)}claimMilestone(e){return this.send(Je.ClaimMilestone,e,Es)}claimMilestonesBatch(e){return this.send(Je.ClaimMilestonesBatch,e,Gs)}claimAllMilestones(e){return this.send(Je.ClaimAllMilestones,e,Gs)}spendTokensBatch(e){return this.send(Je.SpendTokensBatch,e,gu)}grantTokensBatch(e){return this.send(Je.GrantTokensBatch,e,yu)}};var vy=zod.z.object({UserID:zod.z.string(),Score:q.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:ze.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),ai=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:q.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(vy).nullish(),BracketID:zod.z.string().nullish()}),Iy=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:q.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Jr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:q.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:q.nullish(),MilestoneTokensEarned:q.nullish(),NextMilestone:Me.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Iy).nullish()}),Yr=zod.z.object({LeaderboardID:zod.z.string(),NewScore:q,CycleVersion:zod.z.number()}),Xr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),en=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:P.nullish(),Inventory:E.nullish()}),Ru=zod.z.array(ue(ai)),Cu=zod.z.array(ue(Jr)),Su=zod.z.array(ue(Xr)),xu=zod.z.array(ue(en)),bu=zod.z.array(ue(Yr)),Py=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ue(Xr).nullish(),Milestones:zod.z.array(ue(en)).nullish()}),Du=zod.z.array(Py),Ty=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ue(ai).nullish(),Progress:ue(Jr).nullish()}),zu=zod.z.array(Ty),Ay=zod.z.string(),vu=zod.z.object({Rank:zod.z.string().nullish(),Rewards:j.nullish(),SeasonTierRewards:jn.nullish()}).passthrough(),ky=zod.z.object({RankRewards:zod.z.array(vu).nullish()}).passthrough(),wy=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),My=zod.z.object({Milestones:$.nullish(),RankRewards:$.nullish()}).passthrough(),Oy=zod.z.object({LeaderboardID:zod.z.string(),DisplayName:zod.z.string().nullish(),ScoreDisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),IsEnabled:zod.z.boolean().nullish(),ScoreAggregation:Ay.nullish(),Schedule:se.nullish(),ChainEvents:zod.z.array(wy).nullish(),Gate:V.nullish(),TopUsersLimit:zod.z.number().nullish(),MinScoreToEnterTop:zod.z.number().nullish(),BracketSize:zod.z.number().nullish(),LinkedSeasonChainID:zod.z.string().nullish(),RankRewards:zod.z.array(vu).nullish(),Milestones:zod.z.record(zod.z.string(),Me).nullish(),Presets:My.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(We).nullish()}).passthrough(),Uy=zod.z.object({Milestones:zod.z.record(zod.z.string(),jt).nullish(),RankRewards:zod.z.record(zod.z.string(),ky).nullish()}).passthrough(),tn=zod.z.object({Definitions:zod.z.record(zod.z.string(),Oy).nullish(),Presets:Uy.nullish()}).passthrough(),we={GetDefinitions:"GetDefinitions",GetLeaderboard:"GetLeaderboard",GetMyProgress:"GetMyProgress",SubmitScore:"SubmitScore",SubmitScoreFromSource:"SubmitScoreFromSource",ClaimCycleReward:"ClaimCycleReward",ClaimMilestone:"ClaimMilestone",GetFriendsLeaderboard:"GetFriendsLeaderboard",GetLeaderboardsBatch:"GetLeaderboardsBatch",GetProgressBatch:"GetProgressBatch",ClaimCycleRewardsBatch:"ClaimCycleRewardsBatch",ClaimMilestonesBatch:"ClaimMilestonesBatch",SubmitScoresBatch:"SubmitScoresBatch",ClaimAllRewardsBatch:"ClaimAllRewardsBatch",GetOverviewBatch:"GetOverviewBatch"};var rn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(we.GetDefinitions,e,tn)}getLeaderboard(e){return this.send(we.GetLeaderboard,e,ai)}getMyProgress(e){return this.send(we.GetMyProgress,e,Jr)}submitScore(e){return this.send(we.SubmitScore,e,Yr)}submitScoreFromSource(e){return this.send(we.SubmitScoreFromSource,e,Yr)}claimCycleReward(e){return this.send(we.ClaimCycleReward,e,Xr)}claimMilestone(e){return this.send(we.ClaimMilestone,e,en)}getFriendsLeaderboard(e){return this.send(we.GetFriendsLeaderboard,e,ai)}getLeaderboardsBatch(e){return this.send(we.GetLeaderboardsBatch,e,Ru)}getProgressBatch(e){return this.send(we.GetProgressBatch,e,Cu)}claimCycleRewardsBatch(e){return this.send(we.ClaimCycleRewardsBatch,e,Su)}claimMilestonesBatch(e){return this.send(we.ClaimMilestonesBatch,e,xu)}submitScoresBatch(e){return this.send(we.SubmitScoresBatch,e,bu)}claimAllRewardsBatch(e){return this.send(we.ClaimAllRewardsBatch,e,Du)}getOverviewBatch(e){return this.send(we.GetOverviewBatch,e,zu)}};var Ns=zod.z.object({}).passthrough().transform(o=>o),Iu=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>ku).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:q.nullish(),UserState:Ns.nullish(),NextTier:zod.z.lazy(()=>Au).nullish()}).passthrough(),Pu=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:q.nullish(),NewStatusTokens:q.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),js=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:P.nullish(),Inventory:E.nullish()}),Tu=at(js);var Au=zod.z.object({Tier:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),RequiredTokens:q.nullish(),TierReachedReward:j.nullish()}).passthrough(),ku=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:q.nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tiers:zod.z.array(Au).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var By=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:se.nullish(),Seasons:zod.z.array(ku).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:V.nullish()}).passthrough(),nn=zod.z.object({Chains:zod.z.record(zod.z.string(),By).nullish()}).passthrough(),Dt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var sn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Dt.GetDefinitions,e,nn)}getActiveSeason(e){return this.send(Dt.GetActiveSeason,e,Iu)}getUserState(e){return this.send(Dt.GetUserState,e,Ns)}grantStatusTokens(e){return this.send(Dt.GrantStatusTokens,e,Pu)}claimTierReward(e){return this.send(Dt.ClaimTierReward,e,js)}claimTierRewardsBatch(e){return this.send(Dt.ClaimTierRewardsBatch,e,Tu)}};var qy={Apple:"Apple",Google:"Google"},wu=zod.z.object({}).passthrough().transform(o=>o),Ly=zod.z.object({PremiumID:zod.z.string().nullish(),PurchaseDate:zod.z.string().nullish(),ExpirationDate:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),IsAutoRenewEnabled:zod.z.boolean().nullish()}).passthrough(),Ey=zod.z.object({PremiumID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Tier:zod.z.number().nullish(),DurationDays:zod.z.number().nullish(),TrialDurationDays:zod.z.number().nullish(),PriceOptions:X.nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Fs=zod.z.object({Definitions:zod.z.record(zod.z.string(),Ey).nullish()}).passthrough(),Mu=zod.z.object({Premium:Fs.nullish()}),Ou=zod.z.object({ServerTimeUtc:u.nullish(),Premium:wu.nullish()}),on=zod.z.object({ServerTimeUtc:u.nullish(),Premium:wu.nullish(),Subscription:Ly.nullish(),Resources:P.nullish()}),wt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var an=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(wt.GetDefinitions,e,Mu)}getUserState(e){return this.send(wt.GetUserState,e,Ou)}activateTrial(e){return this.send(wt.ActivateTrial,e,on)}purchaseItemOrCurrency(e){return this.send(wt.PurchaseWithResources,e,on)}purchaseRealMoney(e){return this.send(wt.PurchaseRealMoney,e,on)}};var ln=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(ke.GetCharacterDefinitions,e,Xi)}getUserCharacters(e){return this.send(ke.GetUserCharacters,e,aa)}unlockCharacter(e){return this.send(ke.UnlockCharacter,e,ss)}upgradeStatLevel(e){return this.send(ke.UpgradeStatLevel,e,rs)}upgradeCharacterLevel(e){return this.send(ke.UpgradeCharacterLevel,e,ns)}equipItems(e){return this.send(ke.EquipItems,e,la)}unequipItems(e){return this.send(ke.UnequipItems,e,ua)}unequipAllCharacters(e){return this.send(ke.UnequipAllCharacters,e,ca)}unlockCharactersBatch(e){return this.send(ke.UnlockCharactersBatch,e,fa)}upgradeCharacterLevelsBatch(e){return this.send(ke.UpgradeCharacterLevelsBatch,e,ga)}upgradeStatLevelsBatch(e){return this.send(ke.UpgradeStatLevelsBatch,e,ya)}unlockSkin(e){return this.send(ke.UnlockSkin,e,pa)}equipSkin(e){return this.send(ke.EquipSkin,e,da)}unequipSkin(e){return this.send(ke.UnequipSkin,e,ha)}getCharacterSkins(e){return this.send(ke.GetCharacterSkins,e,ma)}};var un=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(ut.CreateMatch,e,tl)}updateMatch(e){return this.send(ut.UpdateMatch,e,il)}cancelMatch(e){return this.send(ut.CancelMatch,e,rl)}instantBattle(e){return this.send(ut.InstantBattle,e,nl)}saveStrategy(e){return this.send(ut.SaveStrategy,e,ve)}getMyMatches(e){return this.send(ut.GetMyMatches,e,Cs)}getAvailableMatches(e){return this.send(ut.GetAvailableMatches,e,Cs)}getDefinitions(e){return this.send(ut.GetDefinitions,e,ll)}};var Gy={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Uu=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),Ny={None:"None",Min:"Min",Average:"Average",Max:"Max"},jy=zod.z.enum(["None","Min","Average","Max"]).catch("None"),Fy={ProtectLeveled:"ProtectLeveled",ClientSelected:"ClientSelected",LowestLevelFirst:"LowestLevelFirst",HighestLevelFirst:"HighestLevelFirst"},Vy=zod.z.enum(["ProtectLeveled","ClientSelected","LowestLevelFirst","HighestLevelFirst"]).catch("ProtectLeveled"),_y={Clamp:"Clamp",Reject:"Reject"},Wy=zod.z.enum(["Clamp","Reject"]).catch("Clamp"),Qy=zod.z.object({ItemInstanceID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),Level:zod.z.number().nullish(),Units:zod.z.number().nullish()}),Ky=zod.z.object({Index:zod.z.number().nullish(),BurnedItemIDs:zod.z.array(zod.z.string()).nullish(),RolledCollectionID:zod.z.string().nullish(),UsedCollections:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Output:Nn.nullish(),OutputLevel:zod.z.number().nullish(),BurnedInstances:zod.z.array(Qy).nullish()}),Bu=zod.z.object({ServerTimeUtc:u,Type:Uu.nullish(),CraftID:zod.z.string(),CraftedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),InputRarity:zod.z.string().nullish(),OutputRarity:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish(),Results:zod.z.array(Ky).nullish()}),Hy=zod.z.object({CraftID:zod.z.string().nullish(),Type:Uu.nullish(),CatalogID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),InputRarityID:zod.z.string().nullish(),OutputRarityID:zod.z.string().nullish(),RequiredItemCount:zod.z.number().nullish(),PriceOptions:X.nullish(),OutputLevelMode:jy.nullish(),InputSelection:Vy.nullish(),OutputLevelOverflow:Wy.nullish()}).passthrough(),Vs=zod.z.object({Definitions:zod.z.record(zod.z.string(),Hy).nullish()}).passthrough(),qu=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:Vs.nullish()}),cn={GetDefinitions:"GetDefinitions",Craft:"Craft"};var pn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(cn.GetDefinitions,e,qu)}craft(e){return this.send(cn.Craft,e,Bu)}};var $y=2e5,Yt=2e5,dn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r={}){let n=M(this.ctx.settings.titleID,"AI",e,t.UserID??"");return this.ctx.transport.post(n,t,i,{...r,ticket:t.ClientSessionTicket})}generate(e,t,i){return this.send(e,t,rr,{timeoutMs:i,autoRetry:false})}readGeneration(e,t){return this.send(e,t,rr,{throttleKey:`AI:${e}:${t.GenerationID??""}`})}getDefinitions(e){return this.send(Be.GetDefinitions,e,za)}generateText(e){return this.generate(Be.GenerateText,e,$y)}getText(e){return this.readGeneration(Be.GetText,e)}generateImage(e){return this.generate(Be.GenerateImage,e,Yt)}editImage(e){return this.generate(Be.EditImage,e,Yt)}generateVideo(e){return this.generate(Be.GenerateVideo,e,Yt)}getVideo(e){return this.readGeneration(Be.GetVideo,e)}generateAudio(e){return this.generate(Be.GenerateAudio,e,Yt)}generateMusic(e){return this.generate(Be.GenerateMusic,e,Yt)}generateThreeD(e){return this.generate(Be.GenerateThreeD,e,Yt)}getThreeD(e){return this.readGeneration(Be.GetThreeD,e)}listGenerations(e){return this.send(Be.ListGenerations,e,Da)}getGeneration(e){return this.readGeneration(Be.GetGeneration,e)}};var Zy={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Jy=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),Lu=zod.z.object({}).passthrough().transform(o=>o),Xt=zod.z.object({CollectibleID:zod.z.string(),Rarity:zod.z.number().nullish(),IsSpecial:zod.z.boolean().nullish(),IsDuplicate:zod.z.boolean().nullish(),CollectionCurrencyConverted:zod.z.number().nullish()}),Eu=zod.z.object({GrantedCollectibles:zod.z.array(Xt).nullish(),DuplicateCollectibles:zod.z.array(Xt).nullish(),CollectionCurrencyEarned:q.nullish()}),Gu=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(Eu).nullish(),GrantedCollectibles:zod.z.array(Xt).nullish(),DuplicateCollectibles:zod.z.array(Xt).nullish(),CollectionCurrencyEarned:q.nullish(),NewCollectionCurrencyBalance:q.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:P.nullish(),Inventory:E.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Nu=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(Eu).nullish(),GrantedCollectibles:zod.z.array(Xt).nullish(),DuplicateCollectibles:zod.z.array(Xt).nullish(),CollectionCurrencyEarned:q.nullish(),NewCollectionCurrencyBalance:q.nullish(),Resources:P.nullish(),Inventory:E.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),ju=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),_s=zod.z.object({SetID:zod.z.string(),Resources:P.nullish(),Inventory:E.nullish()}),Fu=zod.z.array(ue(_s)),Vu=zod.z.object({Resources:P.nullish(),Inventory:E.nullish()}),Yy=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ze.nullish(),OfferedCollectibleID:zod.z.string().nullish(),OfferedCollectibleIsSpecial:zod.z.boolean().nullish(),ReceiverUserID:zod.z.string().nullish(),RequestedCollectibleID:zod.z.string().nullish(),RequestedCollectibleIsSpecial:zod.z.boolean().nullish(),Status:Jy.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RespondedAtUtc:u.nullish(),DeclineReason:zod.z.string().nullish(),IsSpecialTradeEvent:zod.z.boolean().nullish(),SpecialTradeEventID:zod.z.string().nullish()}).passthrough(),_u=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:P.nullish()}),Wu=zod.z.object({OfferID:zod.z.string(),Resources:P.nullish()}),Qu=zod.z.object({OfferID:zod.z.string(),ReceivedCollectibleID:zod.z.string().nullish(),ReceivedIsSpecial:zod.z.boolean().nullish(),SentCollectibleID:zod.z.string().nullish(),SentCollectibleIsSpecial:zod.z.boolean().nullish(),Transfer:zod.z.unknown().nullish()}),Ku=zod.z.object({OfferID:zod.z.string(),Resources:P.nullish()}),Ws=zod.z.object({Offers:zod.z.array(Yy).nullish()}),Xy=zod.z.object({CollectibleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rarity:zod.z.number().nullish(),HasSpecialVersion:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish()}).passthrough(),eR=zod.z.object({SetID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SortOrder:zod.z.number().nullish(),Collectibles:zod.z.array(Xy).nullish(),SetCompletionReward:j.nullish()}).passthrough(),tR=zod.z.object({CollectionID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),SeasonChainID:zod.z.string().nullish(),Sets:zod.z.array(eR).nullish(),GrandPrize:j.nullish()}).passthrough(),Hu=zod.z.object({BonusRewardSlots:$.nullish(),PityRules:$.nullish()}).passthrough(),iR=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:X.nullish(),BonusRewardSlots:zod.z.array($t).nullish(),PityRules:zod.z.array(Zt).nullish(),Presets:Hu.nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectibleCount:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),GuaranteeMaxRarity:zod.z.boolean().nullish(),RarityWeights:zod.z.record(zod.z.string(),zod.z.number()).nullish(),ColorTier:zod.z.number().nullish()}).passthrough(),rR=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),nR=zod.z.object({CollectionChestID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CollectionCurrencyCost:zod.z.number().nullish(),MaxOpenCount:zod.z.number().nullish(),MinCollectibleCount:zod.z.number().nullish(),MaxCollectibleCount:zod.z.number().nullish(),GuaranteedMinRarity:zod.z.number().nullish(),BonusRewardSlots:zod.z.array($t).nullish(),PityRules:zod.z.array(Zt).nullish(),Presets:Hu.nullish(),Tier:zod.z.number().nullish()}).passthrough(),sR=zod.z.object({SpecialTradeEventID:zod.z.string().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),AllowedSpecialCollectibleIDs:zod.z.array(zod.z.string()).nullish(),SpecialTradeEventDailyTradeLimit:zod.z.number().nullish()}).passthrough(),hn=zod.z.object({Collections:zod.z.record(zod.z.string(),tR).nullish(),PackTypes:zod.z.record(zod.z.string(),iR).nullish(),CollectionChests:zod.z.array(nR).nullish(),DuplicateConversions:zod.z.array(rR).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(sR).nullish(),RewardPools:Er.nullish()}).passthrough(),Oe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",OpenPack:"OpenPack",OpenCollectionChest:"OpenCollectionChest",UseCollectibleJoker:"UseCollectibleJoker",ClaimSetReward:"ClaimSetReward",ClaimSetRewardsBatch:"ClaimSetRewardsBatch",ClaimGrandPrize:"ClaimGrandPrize",SendTradeOffer:"SendTradeOffer",CancelTradeOffer:"CancelTradeOffer",AcceptTradeOffer:"AcceptTradeOffer",DeclineTradeOffer:"DeclineTradeOffer",GetMyTradeOffers:"GetMyTradeOffers",GetIncomingTradeOffers:"GetIncomingTradeOffers"};var mn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Oe.GetDefinitions,e,hn)}getUserState(e){return this.send(Oe.GetUserState,e,Lu)}openPack(e){return this.send(Oe.OpenPack,e,Gu)}openCollectionChest(e){return this.send(Oe.OpenCollectionChest,e,Nu)}useCollectibleJoker(e){return this.send(Oe.UseCollectibleJoker,e,ju)}claimSetReward(e){return this.send(Oe.ClaimSetReward,e,_s)}claimSetRewardsBatch(e){return this.send(Oe.ClaimSetRewardsBatch,e,Fu)}claimGrandPrize(e){return this.send(Oe.ClaimGrandPrize,e,Vu)}sendTradeOffer(e){return this.send(Oe.SendTradeOffer,e,_u)}cancelTradeOffer(e){return this.send(Oe.CancelTradeOffer,e,Wu)}acceptTradeOffer(e){return this.send(Oe.AcceptTradeOffer,e,Qu)}declineTradeOffer(e){return this.send(Oe.DeclineTradeOffer,e,Ku)}getMyTradeOffers(e){return this.send(Oe.GetMyTradeOffers,e,Ws)}getIncomingTradeOffers(e){return this.send(Oe.GetIncomingTradeOffers,e,Ws)}};var oR=zod.z.object({}).passthrough().transform(o=>o),aR={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},lR={Active:"Active",Left:"Left",Replaced:"Replaced"},uR=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),cR=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),BuildObjectsProgress:uR.nullish(),IsBot:zod.z.boolean().nullish(),SpinsCount:zod.z.number().nullish(),TokensSpent:zod.z.number().nullish(),MemberStatus:zod.z.string().nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),pR=zod.z.object({Index:zod.z.number().nullish(),OwnerUserID:zod.z.string().nullish(),CurrentProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish(),IsCompleted:zod.z.boolean().nullish()}).passthrough(),dR=zod.z.object({Objects:zod.z.array(pR).nullish()}).passthrough(),$u=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),CoopChainID:zod.z.string().nullish(),CoopEventID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),Members:zod.z.array(cR).nullish(),BuildObjectsState:dR.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Zu=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),hR=zod.z.string(),Qs=zod.z.object({DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Weight:zod.z.number().nullish(),MinProgress:zod.z.number().nullish(),MaxProgress:zod.z.number().nullish()}).passthrough(),mR=zod.z.object({Index:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxProgress:zod.z.number().nullish(),CompletionReward:j.nullish()}).passthrough(),fR=zod.z.object({Objects:zod.z.array(mR).nullish(),PriceOptions:X.nullish(),SpinnerTable:zod.z.array(Qs).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),gR=zod.z.object({CoopEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),EventType:hR.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:fR.nullish(),GrandPrize:j.nullish()}).passthrough(),yR=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:se.nullish(),Events:zod.z.array(gR).nullish(),Gate:V.nullish()}).passthrough(),Ju=zod.z.object({ServerTimeUtc:u.nullish(),UserState:oR.nullish(),ActiveGroup:$u.nullish()}),Ks=zod.z.object({ServerTimeUtc:u.nullish(),Group:$u.nullish(),SecondsRemaining:q.nullish()}),Yu=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:P.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:Qs.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(Qs).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:q.nullish(),MaxProgress:q.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),Hs=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),Xu=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),fn=zod.z.object({Chains:zod.z.record(zod.z.string(),yR).nullish()}).passthrough(),rt={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var gn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(rt.GetDefinitions,e,fn)}getActiveEvent(e){return this.send(rt.GetActiveEvent,e,Zu)}getUserState(e){return this.send(rt.GetUserState,e,Ju)}getGroupState(e){return this.send(rt.GetGroupState,e,Ks)}joinOrCreateGroup(e){return this.send(rt.JoinOrCreateGroup,e,Ks)}spin(e){return this.send(rt.Spin,e,Yu)}claimObjectReward(e){return this.send(rt.ClaimObjectReward,e,Hs)}claimGrandPrize(e){return this.send(rt.ClaimGrandPrize,e,Hs)}leaveGroup(e){return this.send(rt.LeaveGroup,e,Xu)}};var RR={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},CR={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},SR=zod.z.object({NodeID:zod.z.string().nullish(),Status:zod.z.string().nullish(),ExecutionCount:zod.z.number().nullish(),UnlockedAtUtc:u.nullish(),CompletedAtUtc:u.nullish(),LastExecutedAtUtc:u.nullish(),NextAvailableAtUtc:u.nullish(),LastExecutionRefID:zod.z.string().nullish()}).passthrough(),xR=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),ec=zod.z.object({OfferID:zod.z.string().nullish(),InstanceKey:zod.z.string().nullish(),SourceOfferVersion:zod.z.number().nullish(),Status:zod.z.string().nullish(),ActivatedAtUtc:u.nullish(),ExhaustedAtUtc:u.nullish(),ExpiredAtUtc:u.nullish(),DismissedAtUtc:u.nullish(),ShowCount:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),Nodes:zod.z.record(zod.z.string(),SR).nullish(),Tracks:zod.z.record(zod.z.string(),xR).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),bR=zod.z.object({SlotID:zod.z.string().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),ActiveOfferID:zod.z.string().nullish(),ActiveOfferStartedAtUtc:u.nullish(),ActiveOfferExpiresAtUtc:u.nullish(),ActiveOffer:ec.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),DR=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),zR=zod.z.object({TotalActivations:zod.z.number().nullish(),TotalExhausted:zod.z.number().nullish(),TotalExpired:zod.z.number().nullish(),TotalDismissed:zod.z.number().nullish(),TotalShows:zod.z.number().nullish(),LastShownAtUtc:u.nullish(),LastActivatedAtUtc:u.nullish(),LastExhaustedAtUtc:u.nullish(),NodeCounts:zod.z.record(zod.z.string(),DR).nullish()}).passthrough(),vR=zod.z.object({Slots:zod.z.record(zod.z.string(),bR).nullish(),OfferHistory:zod.z.record(zod.z.string(),zR).nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),IR={Purchase:"Purchase",FreeClaim:"FreeClaim",RewardedVideo:"RewardedVideo",Info:"Info"},PR={Eq:"Eq",Gte:"Gte",Lte:"Lte"},TR=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),yn=zod.z.object({DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),tc=zod.z.object({Schedule:se.nullish(),Gate:V.nullish()}).passthrough(),ic=zod.z.object({AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),AR=zod.z.object({Identity:$.nullish(),Availability:$.nullish(),Behaviour:$.nullish()}).passthrough(),kR=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),Identity:yn.nullish(),Availability:tc.nullish(),Behaviour:ic.nullish(),Queue:zod.z.array(TR).nullish(),Presets:AR.nullish()}).passthrough(),wR=zod.z.object({ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),MR=zod.z.object({RewardedVideo:wR.nullish()}).passthrough(),OR=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),UR=zod.z.object({Identity:$.nullish(),Graph:$.nullish(),Milestones:$.nullish()}).passthrough(),BR=zod.z.object({Identity:$.nullish(),Pricing:$.nullish(),Reward:$.nullish()}).passthrough(),qR=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),LR=zod.z.object({TrackID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),StartValue:zod.z.number().nullish(),MinValue:zod.z.number().nullish(),MaxValue:zod.z.number().nullish(),ClampToMin:zod.z.boolean().nullish(),ClampToMax:zod.z.boolean().nullish(),HiddenFromUI:zod.z.boolean().nullish()}).passthrough(),ER=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(OR).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),rc=zod.z.object({Options:X.nullish()}).passthrough(),nc=zod.z.object({Grants:j.nullish(),TrackChanges:zod.z.array(qR).nullish(),MilestonePoints:zod.z.number().nullish()}).passthrough(),GR=zod.z.object({NodeID:zod.z.string().nullish(),Type:zod.z.string().nullish(),Identity:yn.nullish(),Pricing:rc.nullish(),Reward:nc.nullish(),Action:MR.nullish(),UnlockRules:ER.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ne.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),Presets:BR.nullish()}).passthrough(),sc=zod.z.object({RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(GR).nullish(),Tracks:zod.z.array(LR).nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish()}).passthrough(),oc=zod.z.object({Milestones:zod.z.record(zod.z.string(),Me).nullish(),ClaimMode:zod.z.string().nullish(),Token:Pt.nullish()}).passthrough(),ac=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),Identity:yn.nullish(),Graph:sc.nullish(),Milestones:oc.nullish(),Presets:UR.nullish()}).passthrough(),NR=zod.z.object({Identity:zod.z.record(zod.z.string(),yn).nullish(),Availability:zod.z.record(zod.z.string(),tc).nullish(),Behaviour:zod.z.record(zod.z.string(),ic).nullish(),Graph:zod.z.record(zod.z.string(),sc).nullish(),Milestones:zod.z.record(zod.z.string(),oc).nullish(),Pricing:zod.z.record(zod.z.string(),rc).nullish(),Reward:zod.z.record(zod.z.string(),nc).nullish()}).passthrough(),$s=zod.z.object({Slots:zod.z.record(zod.z.string(),kR).nullish(),Offers:zod.z.record(zod.z.string(),ac).nullish(),Presets:NR.nullish()}).passthrough(),lc=zod.z.object({DealOfferDefinitions:$s.nullish()}),uc=zod.z.object({DealOffers:vR.nullish()}),jR=zod.z.object({EntityID:zod.z.string().nullish(),TotalEarned:zod.z.number().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),ReachedUnclaimedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),FR=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:ac.nullish(),ActivationState:ec.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:dt.nullish(),Milestone:jR.nullish()}).passthrough(),cc=zod.z.object({Slots:zod.z.array(FR).nullish()}),pc=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),NodeID:zod.z.string().nullish(),NodeCompleted:zod.z.boolean().nullish(),OfferExhausted:zod.z.boolean().nullish(),Idempotent:zod.z.boolean().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),dc=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:P.nullish()}),hc=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:P.nullish()}),mc=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),fc=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),ClaimedIDs:zod.z.array(zod.z.string()).nullish(),Rejected:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Resources:P.nullish(),Inventory:E.nullish()}),ct={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var Rn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(ct.GetDefinition,e,lc)}getUserState(e){return this.send(ct.GetUserState,e,uc)}getActiveDeals(e){return this.send(ct.GetActiveDeals,e,cc)}dismissDeal(e){return this.send(ct.DismissDeal,e,dc)}executeNode(e){return this.send(ct.ExecuteNode,e,pc)}recordShow(e){return this.send(ct.RecordShow,e,hc)}claimMilestone(e){return this.send(ct.ClaimMilestone,e,mc)}claimMilestonesBatch(e){return this.send(ct.ClaimMilestonesBatch,e,fc)}};var VR=zod.z.object({}).passthrough().transform(o=>o),_R=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Rate:zod.z.number().nullish(),Basis:zod.z.string().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish(),MinSourceAmount:zod.z.number().nullish(),MaxRewardPerOperation:zod.z.number().nullish(),Limits:ne.nullish()}).passthrough(),Zs=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:j.nullish(),InviteRewards:zod.z.record(zod.z.string(),Me).nullish(),SpendRewards:zod.z.array(_R).nullish()}).passthrough(),gc=zod.z.object({ReferralDefinitions:Zs.nullish()}).passthrough(),yc=zod.z.object({Referral:VR.nullish(),InviteUrl:zod.z.string().nullish()}).passthrough(),Rc=zod.z.object({ReferralCode:zod.z.string().nullish(),ReferrerUserID:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:P.nullish(),Inventory:E.nullish()}).passthrough(),Js=zod.z.object({RewardID:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish()}).passthrough(),Cc=at(Js),Mt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Cn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Mt.GetDefinitions,e,gc)}getUserState(e){return this.send(Mt.GetUserState,e,yc)}activateReferralCode(e){return this.send(Mt.ActivateReferralCode,e,Rc)}claimInviteReward(e){return this.send(Mt.ClaimInviteReward,e,Js)}claimInviteRewardsBatch(e){return this.send(Mt.ClaimInviteRewardsBatch,e,Cc)}};var WR={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},QR={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Sc=zod.z.object({UserID:zod.z.string(),PublicData:ze.nullish()}),KR=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:ze.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:P.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),li=zod.z.object({Friends:zod.z.array(Sc).nullish()}),HR=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),ui=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:Sc.nullish(),Counters:HR.nullish()}),xc=zod.z.object({Events:zod.z.array(KR).nullish()}),nt={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Sn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(nt.GetFriendsList,e,li)}getIncomingRequests(e){return this.send(nt.GetIncomingRequests,e,li)}getOutgoingRequests(e){return this.send(nt.GetOutgoingRequests,e,li)}getRecommendedFriends(e){return this.send(nt.GetRecommendedFriends,e,li)}sendFriendRequest(e){return this.send(nt.SendFriendRequest,e,ui)}acceptFriendRequest(e){return this.send(nt.AcceptFriendRequest,e,ui)}declineFriendRequest(e){return this.send(nt.DeclineFriendRequest,e,ui)}removeFriend(e){return this.send(nt.RemoveFriend,e,ui)}getTimeline(e){return this.send(nt.GetTimeline,e,xc)}};var $R={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var ei=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),ZR=zod.z.object({BoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:X.nullish(),Effect:ei.nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),JR=zod.z.object({ScheduledBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Schedule:se.nullish(),Effects:zod.z.array(ei).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),YR=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(ei).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),XR=zod.z.object({ChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Schedule:se.nullish(),Phases:zod.z.array(YR).nullish(),Gate:V.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),eC=zod.z.object({TriggeredBoostID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Tags:zod.z.array(zod.z.string()).nullish(),Sources:zod.z.array(We).nullish(),Effects:zod.z.array(ei).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:V.nullish()}).passthrough(),tC=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),iC=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),tC).nullish()}).passthrough(),xn=zod.z.object({Definitions:zod.z.record(zod.z.string(),ZR).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),JR).nullish(),BoostChains:zod.z.record(zod.z.string(),XR).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),eC).nullish(),Settings:iC.nullish()}).passthrough(),bc=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:ei.nullish(),SourceType:zod.z.string().nullish(),SourceRef:zod.z.string().nullish()}).passthrough();zod.z.object({Date:u.nullish(),DailyCount:zod.z.number().nullish(),LastFiredUtc:u.nullish()}).passthrough();var Dc=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),bc).nullish()}),zc=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:bc.nullish(),Resources:P.nullish()}),rC={Scheduled:"Scheduled",Chain:"Chain"},nC=zod.z.object({Kind:zod.z.string().nullish(),SourceID:zod.z.string().nullish(),PhaseID:zod.z.string().nullish(),CycleIndex:zod.z.number().nullish(),PhaseOrder:zod.z.number().nullish(),StartUtc:u.nullish(),EndUtc:u.nullish(),Effects:zod.z.array(ei).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vc=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(nC).nullish()}),Ot={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var bn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ot.GetDefinitions,e,xn)}getActive(e){return this.send(Ot.GetActive,e,Dc)}getActiveWindows(e){return this.send(Ot.GetActiveWindows,e,vc)}activate(e){return this.send(Ot.Activate,e,zc)}cleanupExpired(e){return this.send(Ot.CleanupExpired,e,ve)}};var Dn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(it.GetUserCustomDataDefinitions,e,dr)}getMyUserCustomData(e){return this.send(it.GetMyUserCustomData,e,va)}getPublicUserCustomDataOf(e){return this.send(it.GetPublicUserCustomDataOf,e,us)}setPrivateData(e){return this.send(it.SetPrivateData,e,cs)}setPublicData(e){return this.send(it.SetPublicData,e,cs)}deleteKey(e){return this.send(it.DeleteKey,e,ve)}batchSet(e){return this.send(it.BatchSet,e,Ia)}batchDelete(e){return this.send(it.BatchDelete,e,Pa)}batchGetPublicUserCustomDataOf(e){return this.send(it.BatchGetPublicUserCustomDataOf,e,Ta)}};var sC={Static:"Static",Runtime:"Runtime"},oC={Public:"Public",Private:"Private"},aC=zod.z.enum(["Client","Server","System"]).catch("Client"),lC=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),uC=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:aC.nullish(),ExpiresAt:u.nullish()}).passthrough(),Ic=zod.z.record(zod.z.string(),uC),Ys=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Ic.nullish(),Runtime:Ic.nullish(),NotModified:zod.z.boolean().nullish()}),cC=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:lC.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),zn=zod.z.object({Keys:zod.z.record(zod.z.string(),cC).nullish(),DefaultMaxValueLengthBytes:zod.z.number().nullish(),DefaultTtlSeconds:zod.z.number().nullish(),MaxKeysPerBucket:zod.z.number().nullish(),MaxTotalSizeBytes:zod.z.number().nullish(),RejectUnregisteredKeys:zod.z.boolean().nullish()}).passthrough(),ci={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var vn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(ci.GetTitleCustomDataDefinitions,e,zn)}getPublicTitleData(e){return this.send(ci.GetPublicTitleData,e,Ys)}getPublicTitleDataKeys(e){return this.send(ci.GetPublicTitleDataKeys,e,Ys)}};var pC={Fast:"Fast",Sequential:"Sequential"},dC={Instant:"Instant",Timed:"Timed"};var hC={Hit:"Hit",Blocked:"Blocked"},mC=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),fC=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:j.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:j.nullish()}).passthrough();var gC=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:j.nullish()}).passthrough(),yC=zod.z.object({Reward:j.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(gC).nullish(),Rate:yC.nullish()}).passthrough();zod.z.object({PlayedCount:zod.z.number().nullish(),RewardsClaimedCount:zod.z.number().nullish(),InstantClaimsCount:zod.z.number().nullish(),EarlyClaimsCount:zod.z.number().nullish(),LateClaimsCount:zod.z.number().nullish(),AdViewsTotal:zod.z.number().nullish()}).passthrough();var Pc=zod.z.object({}).passthrough().transform(o=>o),Tc=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ue=zod.z.object({Operation:P.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),RC=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),CC=zod.z.object({ShieldChance:zod.z.number().nullish(),DamagedBuildingChance:zod.z.number().nullish(),RankMultiplierMin:zod.z.number().nullish(),RankMultiplierMax:zod.z.number().nullish(),RankOffsetMin:zod.z.number().nullish(),RankOffsetMax:zod.z.number().nullish()}).passthrough(),SC=zod.z.object({CostMatrixTemplatesByID:zod.z.record(zod.z.string(),zod.z.array(zod.z.array(zod.z.number()))).nullish(),PerBoardGrowth:zod.z.number().nullish(),VisualTemplateCycle:zod.z.array(zod.z.string()).nullish(),EconomyScaledResources:be.nullish(),ScaleRaidStealWithEconomy:zod.z.boolean().nullish(),ScaleAttackRewardWithEconomy:zod.z.boolean().nullish(),AttackValueFromCostMatrix:zod.z.boolean().nullish(),AttackBlockedRewardFactor:zod.z.number().nullish(),ScaleVictimLossWithEconomy:zod.z.boolean().nullish(),ScaleVictimLossWithTier:zod.z.boolean().nullish(),SynthesizedBuildingSlots:zod.z.number().nullish(),SynthesizedBuildingMaxLevel:zod.z.number().nullish()}).passthrough(),xC=zod.z.object({CostMatrix:zod.z.array(zod.z.array(zod.z.number())).nullish(),PerBoardGrowth:zod.z.number().nullish(),EconomyScale:zod.z.number().nullish(),ScaledResources:be.nullish()}).passthrough(),Ac=zod.z.object({SlotIndex:zod.z.number().nullish(),Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),MaxLevel:zod.z.number().nullish(),MaxLevelReward:j.nullish()}).passthrough(),bC=zod.z.object({Index:zod.z.number().nullish(),Type:zod.z.string().nullish(),CustomTypeID:zod.z.string().nullish(),RandomActionAttackWeight:zod.z.number().nullish(),RandomActionRaidWeight:zod.z.number().nullish(),ChanceTableID:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),DC=zod.z.object({Tiles:zod.z.record(zod.z.string(),bC).nullish()}).passthrough(),zC=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Ue.nullish(),Tag:zod.z.string().nullish()}).passthrough(),vC=zod.z.object({Weight:zod.z.number().nullish(),Tag:zod.z.string().nullish(),MinBonusCells:zod.z.number().nullish(),MaxBonusCells:zod.z.number().nullish(),BonusPool:zod.z.array(zC).nullish(),GuaranteedBonus:Ue.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),IC=zod.z.object({Variants:zod.z.array(vC).nullish()}).passthrough(),PC=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Ue.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),TC=zod.z.object({Outcomes:zod.z.array(PC).nullish()}).passthrough(),kc=zod.z.object({PerAdMultiplierRange:Tc.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),AC=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Ue.nullish()}).passthrough(),kC=zod.z.object({Tiers:zod.z.array(AC).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:Ue.nullish()}).passthrough(),wC=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:Ue.nullish()}).passthrough(),MC=zod.z.object({Reward:Ue.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),OC=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(wC).nullish(),Rate:MC.nullish()}).passthrough(),wc=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),OC).nullish()}).passthrough(),UC=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ue.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:X.nullish(),Multipliers:kc.nullish(),Gradation:kC.nullish(),RunStats:wc.nullish()}).passthrough(),BC=zod.z.object({Choices:zod.z.array(UC).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),qC=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Ue.nullish(),Tag:zod.z.string().nullish()}).passthrough(),LC=zod.z.object({OnPassStart:Ue.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Ue).nullish(),OnAttack:zod.z.record(zod.z.string(),Ue).nullish(),OnRaid:zod.z.record(zod.z.string(),Ue).nullish(),OnBuild:Ue.nullish(),OnStageComplete:Ue.nullish(),OnAttackBonusDrops:zod.z.array(qC).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),TC).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),BC).nullish()}).passthrough(),Mc=zod.z.object({BaseAttackReward:j.nullish(),BaseRaidReward:j.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Ac).nullish(),HeistGridBonusConfig:IC.nullish(),StageOperations:LC.nullish(),TileLandingMultiplier:Tc.nullish(),EconomyOverride:xC.nullish()}).passthrough(),EC=zod.z.object({Name:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),BoardTemplateID:zod.z.string().nullish(),Buildings:zod.z.array(Ac).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Mc.nullish()}).passthrough(),In=zod.z.object({RollCurrencyID:zod.z.string().nullish(),ShieldCurrencyID:zod.z.string().nullish(),RaidMode:zod.z.string().nullish(),AllowedRollMultipliers:zod.z.array(zod.z.number()).nullish(),BoardTemplatesByID:zod.z.record(zod.z.string(),DC).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Mc).nullish(),StagesByLevel:zod.z.record(zod.z.string(),EC).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:SC.nullish(),Dice:RC.nullish(),Bots:CC.nullish()}).passthrough(),GC=zod.z.object({IsActive:zod.z.boolean().nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AnchorUtc:u.nullish(),RoundDurationSec:zod.z.number().nullish(),PauseBetweenRoundsSec:zod.z.number().nullish(),MaxRounds:zod.z.number().nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),ContributionMin:zod.z.number().nullish(),ContributionMax:zod.z.number().nullish(),ScaleContributionWithRollMultiplier:zod.z.boolean().nullish(),MaxProgress:zod.z.number().nullish(),Milestones:zod.z.record(zod.z.string(),Me).nullish(),GrandPrize:j.nullish()}).passthrough(),Pn=zod.z.object({Board:In.nullish(),CommunityChest:GC.nullish()}).passthrough(),NC=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:ze.nullish(),TargetBuildingStates:zod.z.array(mC).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),jC=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ue.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:X.nullish(),Multipliers:kc.nullish(),RunStats:wc.nullish()}).passthrough(),FC=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(jC).nullish()}).passthrough(),VC=zod.z.object({GroupID:zod.z.string().nullish(),Delta:q.nullish(),NewProgress:q.nullish(),MaxProgress:q.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Oc=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:q.nullish(),LandedTileType:zod.z.string().nullish(),Operation:P.nullish(),Inventory:E.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:NC.nullish(),SpecialModeOffer:FC.nullish(),CommunityChestContribution:VC.nullish()}).passthrough(),Uc=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:P.nullish(),Inventory:E.nullish(),DualResult:It.nullish()}).passthrough(),Xs=zod.z.object({Status:zod.z.string().nullish(),Outcome:zod.z.string().nullish(),FoundSymbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),FoundBonus:j.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(fC).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:P.nullish(),Inventory:E.nullish(),DualResult:It.nullish()}).passthrough(),Bc=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:P.nullish(),Inventory:E.nullish()}).passthrough(),qc=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:P.nullish(),Inventory:E.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),Lc=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),_C=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),Ec=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:P.nullish(),Inventory:E.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(_C).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:j.nullish()}).passthrough(),WC={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Gc=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),QC={Active:"Active",Left:"Left",Replaced:"Replaced"},KC=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),HC=zod.z.object({CurrentProgress:q.nullish(),MaxProgress:q.nullish()}).passthrough(),$C=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:q.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:KC.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),Nc=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array($C).nullish(),SharedProgress:HC.nullish(),Status:Gc.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),ZC=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:Gc.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),JC=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(ZC).nullish()}).passthrough(),jc=zod.z.object({ServerTimeUtc:u.nullish(),UserState:JC.nullish(),ActiveGroup:Nc.nullish(),SecondsRemaining:q.nullish()}),Fc=zod.z.object({ServerTimeUtc:u.nullish(),Group:Nc.nullish(),SecondsRemaining:q.nullish()}),eo=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:P.nullish(),Inventory:E.nullish()}),Vc=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Pe={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var YC=zod.z.object({VariantID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Weight:zod.z.number().nullish(),IsControl:zod.z.boolean().nullish(),Params:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),XC=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:se.nullish(),Gate:V.nullish(),Variants:zod.z.array(YC).nullish(),Salt:zod.z.string().nullish(),LayerID:zod.z.string().nullish(),StickyAssignment:zod.z.boolean().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),_c=zod.z.object({Experiments:zod.z.record(zod.z.string(),XC).nullish()}).passthrough();var eS={Mesh:"Mesh",Host:"Host"},to=zod.z.enum(["Mesh","Host"]).catch("Mesh"),tS={ServerRelay:"ServerRelay",P2P:"P2P"},io=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),iS={Public:"Public",Private:"Private"},rS=zod.z.enum(["Public","Private"]).catch("Public"),nS={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},sS=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),Wc=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),oS=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Qc=zod.z.object({SystemState:oS.nullish(),DefaultTopology:to.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:io.nullish(),AllowCreatorChatOverride:zod.z.boolean().nullish(),MaxPlayersPerRoom:zod.z.number().nullish(),RoomTtlSeconds:zod.z.number().nullish(),HeartbeatIntervalMs:zod.z.number().nullish(),MemberTimeoutMs:zod.z.number().nullish(),MaxSignalPayloadBytes:zod.z.number().nullish(),MaxChatTextLength:zod.z.number().nullish(),RoomLogCap:zod.z.number().nullish(),IceServers:zod.z.array(Wc).nullish()}).passthrough(),aS=zod.z.object({UserID:zod.z.string().nullish(),Username:zod.z.string().nullish(),AvatarUrl:zod.z.string().nullish(),Level:zod.z.number().nullish(),Power:zod.z.number().nullish(),Ready:zod.z.boolean().nullish(),State:zod.z.record(zod.z.string(),zod.z.string()).nullish(),JoinedAt:zod.z.number().nullish(),IsHost:zod.z.boolean().nullish(),LastSeenMs:zod.z.number().nullish()}).passthrough(),lS=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:to.nullish(),ChatMode:io.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),uS=zod.z.object({Seq:zod.z.number().nullish(),Type:sS.nullish(),FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Kind:zod.z.string().nullish(),Payload:zod.z.string().nullish(),Ts:zod.z.number().nullish()}).passthrough(),Tn=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:to.nullish(),ChatMode:io.nullish(),Visibility:rS.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(aS).nullish(),IceServers:zod.z.array(Wc).nullish(),Seq:zod.z.number().nullish()}).passthrough(),ro=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Kc=zod.z.object({Rooms:zod.z.array(lS).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Hc=zod.z.object({Envelopes:zod.z.array(uS).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),An=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ye={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var no=zod.z.object({TitleCustomData:zn.nullish(),Character:Xi.nullish(),Item:Or.nullish(),Currency:Cr.nullish(),Store:Br.nullish(),Lootbox:Ms.nullish(),Quest:Si.nullish(),TimedEvent:$r.nullish(),Leaderboard:tn.nullish(),Season:nn.nullish(),Reward:Os.nullish(),Collection:hn.nullish(),Craft:Vs.nullish(),DealOffer:$s.nullish(),Premium:Fs.nullish(),TimedBoost:xn.nullish(),CoopEvent:fn.nullish(),GameLoop:Pn.nullish(),Match:xs.nullish(),Experiment:_c.nullish(),Blockchain:ms.nullish(),Marketplace:vs.nullish(),Multiplayer:Qc.nullish(),UserCustomData:dr.nullish(),Referral:Zs.nullish(),Localization:Sl.nullish()}).passthrough();var Ut={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var kn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(Ut.GetTitlePublicConfiguration,e,no)}getTitlePublicConfigurationExcept(e){return this.send(Ut.GetTitlePublicConfigurationExcept,e,no)}getCurrencyDefinitions(e){return this.send(Ut.GetCurrencyDefinitions,e,Cr)}getItemDefinitions(e){return this.send(Ut.GetItemDefinitions,e,Or)}getServerTime(e){return this.send(Ut.GetServerTime,e,ve)}};var wn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let n=M(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(n,t,i,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(Pe.GetGameLoops,e,Pn)}getBoardDefinition(e,t=false){return this.send(Pe.GetBoardDefinition,e,In,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Pe.GetBoardDefinitionForLevel,e,In,t)}getUserBoardState(e){return this.send(Pe.GetUserBoardState,e,Pc)}boardLoopRoll(e){return this.send(Pe.BoardLoopRoll,e,Oc)}boardLoopAttack(e){return this.send(Pe.BoardLoopAttack,e,Uc)}boardLoopRaid(e){return this.send(Pe.BoardLoopRaid,e,Xs)}boardLoopRaidFast(e){return this.send(Pe.BoardLoopRaidFast,e,Xs)}boardLoopBuild(e){return this.send(Pe.BoardLoopBuild,e,Bc)}boardSpecialChoose(e){return this.send(Pe.BoardSpecialChoose,e,qc)}boardSpecialApplyMultiplier(e){return this.send(Pe.BoardSpecialApplyMultiplier,e,Lc)}boardSpecialClaim(e){return this.send(Pe.BoardSpecialClaim,e,Ec)}getCommunityChestState(e){return this.send(Pe.GetCommunityChestState,e,jc)}joinOrCreateCommunityChest(e){return this.send(Pe.JoinOrCreateCommunityChest,e,Fc)}claimCommunityChestMilestone(e){return this.send(Pe.ClaimCommunityChestMilestone,e,eo)}claimCommunityChestGrandPrize(e){return this.send(Pe.ClaimCommunityChestGrandPrize,e,eo)}leaveCommunityChest(e){return this.send(Pe.LeaveCommunityChest,e,Vc)}};var pi=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(pi),zod.z.record(zod.z.string(),pi)]));var pS={Live:"Live",Latest:"Latest",Specific:"Specific"},dS={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},hS=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),mS={None:"None",Disabled:"Disabled",NoActiveRevision:"NoActiveRevision",RevisionNotFound:"RevisionNotFound",InvalidFieldName:"InvalidFieldName",RateLimited:"RateLimited",HandlerNotFound:"HandlerNotFound",HandlerDisabled:"HandlerDisabled",Timeout:"Timeout",StatementCountExceeded:"StatementCountExceeded",StackOverflow:"StackOverflow",ApiCallLimitExceeded:"ApiCallLimitExceeded",JavaScriptException:"JavaScriptException",ExecutionError:"ExecutionError"},fS=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),gS=zod.z.object({Level:hS,Message:zod.z.string().nullish(),Data:pi.nullish()}),yS=zod.z.object({Error:fS,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),$c=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:pi.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(gS).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:yS.nullish()}),so={Execute:"Execute"};var Mn=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=M(this.ctx.settings.titleID,"CloudCode",so.Execute,e.UserID??"");return this.ctx.transport.post(t,e,$c,{ticket:e.ClientSessionTicket})}};var On=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ve.GetDefinitions,e,Fa)}getUserState(e){return this.send(Ve.GetUserState,e,Va)}depositToken(e){return this.send(Ve.DepositToken,e,_a)}depositNFT(e){return this.send(Ve.DepositNFT,e,Wa)}requestTokenWithdrawal(e){return this.send(Ve.RequestTokenWithdrawal,e,Qa)}requestNFTWithdrawal(e){return this.send(Ve.RequestNFTWithdrawal,e,Ka)}getTransactionHistory(e){return this.send(Ve.GetTransactionHistory,e,Ha)}retryWithdrawal(e){return this.send(Ve.RetryWithdrawal,e,$a)}confirmWithdrawal(e){return this.send(Ve.ConfirmWithdrawal,e,Za)}donateToDeveloper(e){return this.send(Ve.DonateToDeveloper,e,ys)}donateToUsersPool(e){return this.send(Ve.DonateToUsersPool,e,ys)}};var Un=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(fe.GetDefinitions,e,cl)}getGroupedOffers(e){return this.send(fe.GetGroupedOffers,e,pl)}getOffersByItem(e){return this.send(fe.GetOffersByItem,e,Is)}getOffer(e){return this.send(fe.GetOffer,e,dl)}getBuyOrders(e){return this.send(fe.GetBuyOrders,e,Is)}getMyState(e){return this.send(fe.GetMyState,e,ml)}getHistory(e){return this.send(fe.GetHistory,e,fl)}createListing(e){return this.send(fe.CreateListing,e,oi)}cancelListing(e){return this.send(fe.CancelListing,e,He)}buy(e){return this.send(fe.Buy,e,He)}marketBuy(e){return this.send(fe.MarketBuy,e,He)}marketSell(e){return this.send(fe.MarketSell,e,He)}createAuction(e){return this.send(fe.CreateAuction,e,oi)}placeBid(e){return this.send(fe.PlaceBid,e,hl)}claimAuction(e){return this.send(fe.ClaimAuction,e,He)}createBuyOrder(e){return this.send(fe.CreateBuyOrder,e,oi)}cancelBuyOrder(e){return this.send(fe.CancelBuyOrder,e,He)}fillBuyOrder(e){return this.send(fe.FillBuyOrder,e,He)}createDirectTrade(e){return this.send(fe.CreateDirectTrade,e,oi)}respondDirectTrade(e){return this.send(fe.RespondDirectTrade,e,He)}cancelDirectTrade(e){return this.send(fe.CancelDirectTrade,e,He)}claimBack(e){return this.send(fe.ClaimBack,e,He)}};var Bn=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=M(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ye.CreateRoom,e,Tn)}joinRoom(e){return this.send(Ye.JoinRoom,e,Tn)}leaveRoom(e){return this.send(Ye.LeaveRoom,e,ro)}listRooms(e){return this.send(Ye.ListRooms,e,Kc)}getRoom(e){return this.send(Ye.GetRoom,e,Tn)}closeRoom(e){return this.send(Ye.CloseRoom,e,ro)}poll(e){return this.send(Ye.Poll,e,Hc)}sendSignal(e){return this.send(Ye.SendSignal,e,An)}sendChat(e){return this.send(Ye.SendChat,e,An)}setMemberState(e){return this.send(Ye.SetMemberState,e,An)}};var qn=class{settings;emitter;platform;acquisition;playtime;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;communityMarketing;chat;push;localization;timedEvent;leaderboard;season;premium;character;match;craft;ai;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e){this.settings=co(e),this.emitter=new ii,this.platform=e.platform??new Et,this.clientPlatform=e.clientPlatform??zo(),this.acquisition=new vt(this.platform),this.acquisition.capture(),this.playtime=new ri(this),this.emitter.on("auth:loggedIn",()=>{this.playtime.start(),this.acquisition.clear();}),this.emitter.on("auth:loggedOut",()=>{this.playtime.stop();}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new Di({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new Pi(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.emitter.on("tutorial:systemProgress",t=>{this.data.user.patchTutorialProgress(t);}),this.emitter.on("user:stateVersions",({epoch:t,versions:i})=>{this.userService.noteStateVersions(t,i);}),this.authStore=new Ti(this.platform.storage,this.settings.titleID),this.api={authentication:new Tr(this),user:new kr(this),currency:new wr(this),item:new Ur(this),store:new qr(this),purchase:new Lr(this),lootbox:new Nr(this),reward:new jr(this),quest:new Hr(this),tutorial:new Fr(this),communityMarketing:new Vr(this),chat:new Wr(this),push:new Qr(this),localization:new Kr(this),timedEvent:new Zr(this),leaderboard:new rn(this),season:new sn(this),premium:new an(this),character:new ln(this),match:new un(this),craft:new pn(this),ai:new dn(this),collection:new mn(this),coopEvent:new gn(this),dealOffer:new Rn(this),referral:new Cn(this),social:new Sn(this),timedBoost:new bn(this),userCustomData:new Dn(this),titleCustomData:new vn(this),title:new kn(this),gameLoop:new wn(this),cloudCode:new Mn(this),blockchain:new On(this),marketplace:new Un(this),multiplayer:new Bn(this)},this.userService=new Mi(this),this.auth=new Ai(this),this.currency=new Ui(this),this.item=new Bi(this),this.store=new qi(this),this.purchase=new Li(this),this.checkout=new Ei(this),this.lootbox=new Gi(this),this.reward=new Ni(this),this.quest=new Ki(this),this.tutorial=new ji(this),this.communityMarketing=new Fi(this),this.chat=new Vi(this),this.push=new _i(this),this.localization=new Qi(this),this.timedEvent=new Hi(this),this.leaderboard=new $i(this),this.season=new Zi(this),this.premium=new Ji(this),this.character=new er(this),this.match=new tr(this),this.craft=new ir(this),this.ai=new nr(this),this.collection=new sr(this),this.coopEvent=new or(this),this.dealOffer=new ar(this),this.referral=new lr(this),this.social=new ur(this),this.timedBoost=new cr(this),this.userCustomData=new hr(this),this.titleCustomData=new mr(this),this.title=new fr(this),this.gameLoop=new gr(this),this.cloudCode=new yr(this),this.blockchain=new br(this),this.marketplace=new Ir(this),this.multiplayer=new Pr(this),this.transport.setSessionRefreshHandler(()=>this.auth.refreshSession());}buildAuthedBaseRequest(){let e=this.auth.context;return {UserID:e?.userID,ClientSessionTicket:e?.clientSessionTicket,BuildKey:this.settings.buildKey,WebAppLink:this.platform.getFullURL(),RelatedEntityID:k()}}};var Ln=class{ctx;constructor(e){this.ctx=new qn(e);}get titleID(){return this.ctx.settings.titleID}get auth(){return this.ctx.auth}get user(){return this.ctx.userService}get currency(){return this.ctx.currency}get item(){return this.ctx.item}get store(){return this.ctx.store}get purchase(){return this.ctx.purchase}get checkout(){return this.ctx.checkout}get lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}get tutorial(){return this.ctx.tutorial}get communityMarketing(){return this.ctx.communityMarketing}get chat(){return this.ctx.chat}get push(){return this.ctx.push}get localization(){return this.ctx.localization}get timedEvent(){return this.ctx.timedEvent}get leaderboard(){return this.ctx.leaderboard}get season(){return this.ctx.season}get premium(){return this.ctx.premium}get character(){return this.ctx.character}get match(){return this.ctx.match}get craft(){return this.ctx.craft}get ai(){return this.ctx.ai}get collection(){return this.ctx.collection}get coopEvent(){return this.ctx.coopEvent}get dealOffer(){return this.ctx.dealOffer}get referral(){return this.ctx.referral}get social(){return this.ctx.social}get timedBoost(){return this.ctx.timedBoost}get userCustomData(){return this.ctx.userCustomData}get titleCustomData(){return this.ctx.titleCustomData}get title(){return this.ctx.title}get gameLoop(){return this.ctx.gameLoop}get cloudCode(){return this.ctx.cloudCode}get blockchain(){return this.ctx.blockchain}get marketplace(){return this.ctx.marketplace}get multiplayer(){return this.ctx.multiplayer}get data(){return this.ctx.data}get platform(){return this.ctx.platform}on(e,t){return this.ctx.emitter.on(e,t)}once(e,t){return this.ctx.emitter.once(e,t)}off(e,t){this.ctx.emitter.off(e,t);}};function RS(o){return new Ln(o)}var Zc="idos_sso",Jc="state",oo="idos:sso:state",CS="https://idosgames.com/sso/";function SS(){if(typeof window>"u")return null;let o=window.location.hash?.startsWith("#")?window.location.hash.slice(1):window.location.hash;if(!o)return null;let e=new URLSearchParams(o),t=e.get(Zc);if(!t)return null;let i=e.get(Jc)??"",r=vS();return PS(e),IS(),r&&i!==r?null:{code:t,state:i}}function xS(o){if(typeof window>"u")return;let e=o.returnTo??bS(),t=DS();zS(t);let i=new URL(o.ssoUrl??CS);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function bS(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function DS(){let o=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(o);else for(let e=0;e<o.length;e++)o[e]=Math.floor(Math.random()*256);return Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}function zS(o){try{window.sessionStorage.setItem(oo,o);}catch{}}function vS(){try{return window.sessionStorage.getItem(oo)}catch{return null}}function IS(){try{window.sessionStorage.removeItem(oo);}catch{}}function PS(o){o.delete(Zc),o.delete(Jc);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}function TS(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function AS(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function kS(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Xc(o,e,t,i=1){if(!o)return e;let r=o.Base??e,n=Math.max(0,t-i),a;switch(o.Shape??"Flat"){case "PerStep":a=r+(o.PerStep??0)*n;break;case "PerStepRate":a=r*(1+(o.PerStepRate??0)*n);break;case "Geometric":a=r*Math.pow(1+(o.GrowthRate??0),n);break;case "Table":a=r*Yc(o,t,1);break;case "TableAbsolute":a=Yc(o,t,r);break;default:a=r;break}return Number.isNaN(a)?r:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function wS(o,e,t=1){return Xc(o,1,e,t)}function MS(o){if(!o)return false;switch(o.Shape??"Flat"){case "PerStep":return (o.PerStep??0)!==0;case "PerStepRate":return (o.PerStepRate??0)!==0;case "Geometric":return (o.GrowthRate??0)!==0;case "Table":case "TableAbsolute":return ep(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function OS(o){if(Number.isNaN(o)||o<=0)return 0;if(!Number.isFinite(o))return Number.MAX_SAFE_INTEGER;let e=Math.round(o);return Math.abs(o-e)<=1e-9*Math.max(1,Math.abs(o))?e:Math.ceil(o)}function ep(o){if(!o)return [];let e=[];for(let t of o)t?.AtStep==null||t.Value==null||e.push({AtStep:t.AtStep,Value:t.Value});return e}function Yc(o,e,t){let i=ep(o.Points);if(i.length===0)return t;let r=null,n=null,a=null;for(let c of i)(a===null||c.AtStep>a.AtStep)&&(a=c),c.AtStep<=e&&(r===null||c.AtStep>=r.AtStep)&&(r=c),c.AtStep>e&&(n===null||c.AtStep<n.AtStep)&&(n=c);if(r===null)return t;if(n===null){let c=o.TailGrowthRate??0;return c===0?a.Value:a.Value*Math.pow(1+c,e-a.AtStep)}switch(o.Interpolation??"Step"){case "Linear":{let c=(e-r.AtStep)/(n.AtStep-r.AtStep);return r.Value+c*(n.Value-r.Value)}case "Geometric":{if(r.Value<=0||n.Value<=0){let m=(e-r.AtStep)/(n.AtStep-r.AtStep);return r.Value+m*(n.Value-r.Value)}let c=(e-r.AtStep)/(n.AtStep-r.AtStep);return r.Value*Math.pow(n.Value/r.Value,c)}default:return r.Value}}var US={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},ao=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),BS={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},qS=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),LS=zod.z.object({PlacementID:zod.z.string().nullish(),Type:ao.nullish(),Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),CreditsRewarded:zod.z.number().nullish(),AllowedProviderIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),ES=zod.z.object({DefaultCreditsPerView:zod.z.number().nullish(),MaxCreditsBalance:zod.z.number().nullish(),DailyCreditEarnCap:zod.z.number().nullish(),DailyViewCap:zod.z.number().nullish(),MinSecondsBetweenViews:zod.z.number().nullish()}).passthrough(),GS=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),NS=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:qS.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),jS=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),FS=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),VS=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),DisableInterstitials:zod.z.boolean().nullish(),DisableBanners:zod.z.boolean().nullish(),DisableAppOpen:zod.z.boolean().nullish()}).passthrough(),_S=zod.z.object({RequirePersonalizedAdsConsent:zod.z.boolean().nullish(),RequireTrackingConsent:zod.z.boolean().nullish(),CurrentPolicyVersion:zod.z.string().nullish(),RegulatedRegions:zod.z.array(zod.z.string()).nullish()}).passthrough(),WS=zod.z.object({RequireServerSideVerification:zod.z.boolean().nullish(),PendingRequestTtlSeconds:zod.z.number().nullish(),MaxPendingRequestsPerUser:zod.z.number().nullish(),ProviderPublicKeys:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),QS=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:ao.nullish()}).passthrough(),KS={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},HS=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),$S=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:HS.nullish(),Enabled:zod.z.boolean().nullish(),Priority:zod.z.number().nullish(),AndroidAppID:zod.z.string().nullish(),IosAppID:zod.z.string().nullish(),WebAppID:zod.z.string().nullish(),Units:zod.z.record(zod.z.string(),QS).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),LS).nullish(),Providers:zod.z.record(zod.z.string(),$S).nullish(),RewardedVideo:ES.nullish(),Interstitial:GS.nullish(),Banner:NS.nullish(),AppOpen:jS.nullish(),FrequencyCapping:FS.nullish(),PremiumAdReductions:zod.z.array(VS).nullish(),Consent:_S.nullish(),Verification:WS.nullish()}).passthrough();var ZS=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),JS=zod.z.object({PlacementID:zod.z.string().nullish(),LastShownAt:u.nullish(),LastCompletedAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalCompletions:zod.z.number().nullish(),ConsecutiveFailures:zod.z.number().nullish()}).passthrough(),YS=zod.z.object({Date:u.nullish(),ImpressionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),CompletionsByPlacement:zod.z.record(zod.z.string(),zod.z.number()).nullish(),TotalImpressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish(),AppOpenImpressions:zod.z.number().nullish(),CreditsEarnedToday:zod.z.number().nullish()}).passthrough(),XS=zod.z.object({SessionID:zod.z.string().nullish(),SessionStartAt:u.nullish(),Impressions:zod.z.number().nullish(),InterstitialImpressions:zod.z.number().nullish(),RewardedCompletions:zod.z.number().nullish()}).passthrough(),ex=zod.z.object({PersonalizedAdsConsent:zod.z.boolean().nullish(),TrackingConsent:zod.z.boolean().nullish(),PolicyVersion:zod.z.string().nullish(),Region:zod.z.string().nullish(),ConsentGivenAt:u.nullish(),ConsentRevokedAt:u.nullish()}).passthrough(),tx=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:ao.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),ix=zod.z.object({InvalidSsvCount:zod.z.number().nullish(),OrphanCompletions:zod.z.number().nullish(),FastCompletions:zod.z.number().nullish(),LastFlaggedAt:u.nullish()}).passthrough();zod.z.object({Credits:ZS.nullish(),Placements:zod.z.record(zod.z.string(),JS).nullish(),Daily:YS.nullish(),Session:XS.nullish(),LastImpressionAt:u.nullish(),LastInterstitialAt:u.nullish(),LastRewardedAt:u.nullish(),LastAppOpenAt:u.nullish(),TotalImpressions:zod.z.number().nullish(),TotalRewardedCompletions:zod.z.number().nullish(),AdsDisabledUntil:u.nullish(),Consent:ex.nullish(),PendingRequests:zod.z.record(zod.z.string(),tx).nullish(),FraudFlags:ix.nullish(),UpdatedAt:u.nullish()}).passthrough();var rx={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},nx=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),sx={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},ox=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]).catch("Admin"),ax={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},lx=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),ux=zod.z.object({MessageTypeID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IconPath:zod.z.string().nullish(),DisplayPriority:zod.z.number().nullish(),ExpirationHours:zod.z.number().nullish(),AutoClaim:zod.z.boolean().nullish(),AllowP2P:zod.z.boolean().nullish(),ShowBadge:zod.z.boolean().nullish()}).passthrough(),cx=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:V.nullish()}).passthrough();zod.z.object({MaxMessagesPerUser:zod.z.number().nullish(),ReadNoRewardRetentionHours:zod.z.number().nullish(),ClaimedRetentionHours:zod.z.number().nullish(),DefaultPageSize:zod.z.number().nullish(),EnableAutoClaim:zod.z.boolean().nullish(),MessageTypes:zod.z.record(zod.z.string(),ux).nullish(),Segments:zod.z.array(cx).nullish(),DailyP2PGiftLimit:zod.z.number().nullish(),MaxRewardsPerP2PMessage:zod.z.number().nullish()}).passthrough();zod.z.object({MessageID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RecipientUserID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Source:ox.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:ze.nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:j.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:nx.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),ReadAtUtc:u.nullish(),BroadcastID:zod.z.string().nullish(),Version:zod.z.number().nullish()}).passthrough();zod.z.object({BroadcastID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),MessageTypeID:zod.z.string().nullish(),Subject:zod.z.string().nullish(),Body:zod.z.string().nullish(),TemplateParams:zod.z.record(zod.z.string(),zod.z.string()).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:j.nullish(),TargetSegmentID:zod.z.string().nullish(),TargetUserIDs:zod.z.array(zod.z.string()).nullish(),StartsAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),CreatedAtUtc:u.nullish(),CreatedByAdminID:zod.z.string().nullish(),AdminComment:zod.z.string().nullish(),Status:lx.nullish(),DeliveredCount:zod.z.number().nullish(),ClaimedCount:zod.z.number().nullish()}).passthrough();zod.z.object({UnreadCount:zod.z.number().nullish(),UnclaimedRewardCount:zod.z.number().nullish(),LastFetchCursor:u.nullish(),ReceivedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),ClaimedBroadcastIDs:zod.z.array(zod.z.string()).nullish(),DailyP2PGiftsSent:zod.z.number().nullish(),DailyGiftsResetDate:u.nullish(),LastOpenedAtUtc:u.nullish(),TotalMessagesReceived:zod.z.number().nullish(),TotalRewardsClaimed:zod.z.number().nullish()}).passthrough();var tp="idos_device_id",En=class{storage;constructor(e=new qt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(tp);return e||(e="noop-device",this.storage.setString(tp,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
+
exports.AIAction=Be;exports.AIErrorCode=Rh;exports.AIGenerationStatus=Kt;exports.AIModality=yh;exports.AcquisitionCapture=vt;exports.AdProviderKind=KS;exports.AdType=US;exports.AttackOutcome=hC;exports.AuthType=De;exports.AuthenticationAction=je;exports.BannerPosition=BS;exports.BlockchainAction=Ve;exports.BlockchainNetworkType=im;exports.BlockchainOperationCategory=La;exports.BlockchainTransactionStatus=pm;exports.BlockchainTransactionType=om;exports.BodyPart=Bm;exports.BoostWindowKind=rC;exports.BroadcastStatus=ax;exports.BrowserPlatformAdapter=Et;exports.BrowserStorage=Bt;exports.CharacterAction=ke;exports.ChatAction=qe;exports.ChatAuthorType=ty;exports.ChatBlockedTermAction=Xg;exports.ChatChannelType=Hg;exports.ChatDirectAudience=Jg;exports.ChatPartitioning=$g;exports.ChatReportReason=ry;exports.ClientPlatform=ot;exports.CloudCodeAction=so;exports.CloudCodeErrorCode=mS;exports.CloudCodeLogLevel=dS;exports.CloudCodeRevisionSelection=pS;exports.CollectionAction=Oe;exports.CommissionSink=tf;exports.CommunityChestMemberStatus=QC;exports.CommunityChestStatus=WC;exports.CommunityCreatorStatus=qg;exports.CommunityMarketingAction=kt;exports.CommunityMetricKind=Eg;exports.CommunityParticipationMode=Ug;exports.CommunityPayoutCurrencyKind=Lg;exports.ConversionRateMode=Qh;exports.CoopEventAction=rt;exports.CoopGroupStatus=aR;exports.CoopMemberStatus=lR;exports.CraftAction=cn;exports.CraftInputSelectionMode=Fy;exports.CraftOutputLevelMode=Ny;exports.CraftOutputLevelOverflow=_y;exports.CraftType=Gy;exports.CurrencyAction=Rr;exports.CurrencyStatus=Wh;exports.CurrencyType=Xe;exports.CurveInterpolation=Tp;exports.CurveShape=Ip;exports.CustomDataBucket=mt;exports.CustomDataValueType=Bh;exports.CustomDataWriter=wh;exports.DEFAULT_BASE_URL=uo;exports.DealComparisonOperator=PR;exports.DealNodeRuntimeStatus=CR;exports.DealNodeType=IR;exports.DealOfferAction=ct;exports.DealOfferActivationStatus=RR;exports.EnvelopeType=nS;exports.EventTokenType=hp;exports.FodderSelectionMode=Pf;exports.FodderValuationMode=vf;exports.FriendActionStatus=WR;exports.GameLoopAction=Pe;exports.IDosGamesClient=Ln;exports.IapProductType=ng;exports.IapPurchaseStatus=ug;exports.IapStoreValues=dp;exports.ItemAction=Mr;exports.KycStatus=am;exports.KycTier=um;exports.LeaderboardAction=we;exports.LocalizationAction=Ar;exports.LocalizationMissingKeyMode=Sf;exports.LootboxAction=Gr;exports.MailboxMessageSource=sx;exports.MailboxMessageStatus=rx;exports.MarketGoodsType=vr;exports.MarketOfferStatus=ef;exports.MarketOfferType=Xm;exports.MarketplaceAction=fe;exports.MatchAction=ut;exports.MatchStatus=qm;exports.MemoryStorage=qt;exports.MultiplayerAction=Ye;exports.MultiplayerChatMode=tS;exports.MultiplayerTopology=eS;exports.NoopPlatformAdapter=En;exports.OFFER_NOT_IN_ROTATION=rg;exports.PlaytimeTracker=ri;exports.PremiumAction=wt;exports.PurchaseAction=Ht;exports.PushAction=Qt;exports.PushPermissionState=ht;exports.PushTopic=Ld;exports.PushTransport=Bd;exports.QuestAction=tt;exports.QuestObjectiveSource=Gp;exports.QuestPrerequisiteMode=jp;exports.QuestStatus=qp;exports.RaidMode=pC;exports.ReferralAction=Mt;exports.ResourceEntryType=hi;exports.RewardAction=gt;exports.RoomVisibility=iS;exports.SKIN_ALREADY_OWNED=hh;exports.SKIN_SLOT=as;exports.ScheduleMode=mp;exports.SeasonAction=Dt;exports.SocialAction=nt;exports.SpecialChoiceMode=dC;exports.StoreAction=At;exports.StoreRotationMode=Nf;exports.StoreType=qy;exports.TimedBoostAction=Ot;exports.TimedBoostStackingPolicy=$R;exports.TimedEventAction=Je;exports.TimelineEventType=QR;exports.TitleAction=Ut;exports.TitleCustomDataAction=ci;exports.TitleDataBucket=oC;exports.TitleDataScope=sC;exports.TradeOfferStatus=Zy;exports.TransactionDirection=dm;exports.TutorialAction=Qe;exports.TutorialBoardAction=id;exports.TutorialFlowStatus=Xp;exports.TutorialGateMode=Sp;exports.TutorialRestartPolicy=Jp;exports.TutorialScriptModule=td;exports.TutorialStepCompletionMode=$p;exports.TypedEmitter=ii;exports.UserAction=Ze;exports.UserCustomDataAction=it;exports.WalletLinkType=nm;exports.beginSsoRedirect=xS;exports.claimedMilestoneIDs=AS;exports.createIDosGamesClient=RS;exports.curveMultiplier=wS;exports.evaluateCurve=Xc;exports.grantedPremiumTiers=kS;exports.isAIGenerationTerminal=ls;exports.isCurveConfigured=MS;exports.isFail=gp;exports.isMilestoneClaimed=TS;exports.isOk=fp;exports.isReservedSlot=ih;exports.normalizeBlockchainCategory=Sr;exports.parseAIErrorCode=Ch;exports.readSsoCodeFromUrl=SS;exports.roundAmount=OS;exports.zPaymentProof=Hd;exports.zPriceOption=oa;exports.zPriceOptions=X;
|