@idosgames/core 0.7.0 → 0.8.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/dist/index.cjs +2 -2
- package/dist/index.d.cts +134 -20
- package/dist/index.d.ts +134 -20
- 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'),ii=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ii__default=/*#__PURE__*/_interopDefault(ii);var Lt=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 yu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function Sn(){return Cu()??yu()}function Cu(){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 xn="https://api.idosgames.com";function Dn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??xn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??Sn(),locale:o.locale??Su()}}function Su(){try{return globalThis.navigator?.language??""}catch{return ""}}var Ct=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{}}},St=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 xt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var bn="idos_device_id",Dt=class{storage;constructor(e=new Ct){this.storage=e;}getPlatform(){return xt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=xt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=xt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(bn);return e||(e=P(),this.storage.setString(bn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=xt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=xt();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 je={Virtual:"Virtual",Crypto:"Crypto"},zt=zod.z.enum(["Virtual","Crypto"]),Wt={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},Qt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]),He={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},Kt=zod.z.enum(["Unknown","Web","Android","Ios"]),xu={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},Ht=zod.z.enum(["GooglePlay","AppleAppStore"]),Du={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},$t=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),bu={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},qt=zod.z.enum(["Cyclic","Scheduled","Chained"]),me={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function Tn(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return zn(e);let t=o.cordova?.platformId;return t?zn(t):o.navigator?.userAgent??""?He.Web:He.Unknown}function zn(o){let e=o.toLowerCase();return e==="android"?He.Android:e==="ios"?He.Ios:e==="web"?He.Web:He.Unknown}function vn(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function zu(o){return o.ok}function Tu(o){return !o.ok}var w=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)}),q=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 ns=zod.z.object({Type:Qt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:w.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),vu=zod.z.object({Type:$t.nullish(),EntityID:zod.z.string()}),Pu=zod.z.object({Address:vu.nullish(),Amount:w.nullish(),Source:zod.z.string().nullish()}),fe=zod.z.object({Entries:zod.z.array(ns).nullish(),EventTokens:zod.z.array(Pu).nullish()}),Pn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:fe.nullish()}),L=zod.z.object({Standard:fe.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Pn).nullish()}),Et=zod.z.object({Standard:fe.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(Pn).nullish()}),b=zod.z.object({Grant:L.nullish(),Consume:Et.nullish()}),dt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:b.nullish(),ToResult:b.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:fe.nullish()});var Iu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),ku={Completed:"Completed",Started:"Started",StepReached:"StepReached"},Mu=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).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:Iu.nullish(),Tutorial:Mu.nullish(),Platforms:zod.z.array(Kt).nullish()}).passthrough();var ge=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 wu=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Ou=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Au=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 Uu=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 Ue=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:ge.nullish()}).passthrough(),pe=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Ou.nullish(),Chain:Au.nullish(),Cyclic:Uu.nullish(),ActivationTriggers:zod.z.array(Ue).nullish(),Relative:wu.nullish()}).passthrough();var Bu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),Lu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),os=zod.z.object({Bundles:zod.z.array(Bu).nullish(),Multipliers:zod.z.array(Lu).nullish()}).passthrough();var qu=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Eu=zod.z.enum(["Tiered","Linear"]);var Gu=zod.z.enum(["Step","Linear"]),Nu=zod.z.object({AtProgress:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Zt=zod.z.object({Source:qu.nullish(),SourceKey:zod.z.string().nullish(),CurveType:Eu.nullish(),Tiers:zod.z.array(Nu).nullish(),TierMode:Gu.nullish(),BaseMultiplier:zod.z.number().nullish(),PerUnit:zod.z.number().nullish(),Anchor:zod.z.number().nullish(),MinMultiplier:zod.z.number().nullish(),MaxMultiplier:zod.z.number().nullish(),IncludeRewards:fe.nullish(),ExcludeRewards:fe.nullish()}).passthrough(),De=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:L.nullish(),BonusRewards:L.nullish(),SeasonTierRewards:os.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),at=zod.z.object({Milestones:zod.z.record(zod.z.string(),De).nullish()}).passthrough();var X=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var ju=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),ht=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:ju.nullish()}).passthrough();var re=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),$e=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(re(o)),Resources:b.nullish()});var Fu={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},In=zod.z.enum(["Active","Completed","Claimed","Expired"]),Vu=zod.z.object({}).passthrough().transform(o=>o),_u=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:w.nullish(),PointsCurrent:w.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:w.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:In}),kn=zod.z.object({State:Vu.nullish(),PointsTracks:zod.z.record(zod.z.string(),_u).nullish()}),ls=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:In.nullish(),Resources:b.nullish()}),us=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:w.nullish(),Resources:b.nullish()}),Mn=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:b.nullish()}),wn=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(as).nullish()}),On=zod.z.array(re(ls)),An=zod.z.array(re(us)),Wu={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Qu=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),Ku={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Hu=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Un=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Qu.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),cs=zod.z.object({Milestones:X.nullish(),Linking:X.nullish(),Availability:X.nullish(),Reward:X.nullish(),Objectives:X.nullish()}).passthrough(),$u=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(),Bn=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:Hu.nullish()}).passthrough(),Ln=zod.z.object({Schedule:pe.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),qn=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Zu=zod.z.object({QuestID:zod.z.string().nullish(),Identity:$u.nullish(),Linking:Bn.nullish(),Availability:Ln.nullish(),Objectives:zod.z.record(zod.z.string(),Un).nullish(),Reward:qn.nullish(),Presets:cs.nullish()}).passthrough(),Ju=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:_.nullish(),Reward:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Yu=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(),De).nullish(),Presets:cs.nullish(),PointsToken:ht.nullish()}).passthrough(),Xu=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish(),Linking:zod.z.record(zod.z.string(),Bn).nullish(),Availability:zod.z.record(zod.z.string(),Ln).nullish(),Reward:zod.z.record(zod.z.string(),qn).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Un)).nullish()}).passthrough(),ec=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Gate:_.nullish(),PointsToken:ht.nullish(),GroupCompletions:zod.z.record(zod.z.string(),Ju).nullish(),Phases:zod.z.record(zod.z.string(),Yu).nullish(),Presets:cs.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Yt=zod.z.object({Cycles:zod.z.record(zod.z.string(),ec).nullish(),Quests:zod.z.record(zod.z.string(),Zu).nullish(),Presets:Xu.nullish()}).passthrough(),Ve={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var tc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},ic=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]),rc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},sc=zod.z.enum(["Never","OnRequest","Always"]),nc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},oc=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]),ac={GameLoop:"GameLoop"},lc={Raid:"Raid",Attack:"Attack"},uc=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(),cc=zod.z.object({Mode:ic.nullish(),Triggers:zod.z.array(Ue).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),pc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),dc=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).nullish()}).passthrough(),hc=zod.z.object({Module:zod.z.enum(["GameLoop"]).nullish(),Board:dc.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),mc=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),ps=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:uc.nullish(),Completion:cc.nullish(),Effects:pc.nullish(),Script:hc.nullish(),Policy:mc.nullish()}).passthrough(),fc=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(),En=zod.z.object({Schedule:pe.nullish(),Gate:_.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Ue.nullish()}).passthrough(),Gn=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:sc.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Nn=zod.z.object({Grant:L.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),gc=zod.z.object({Availability:X.nullish(),Policy:X.nullish(),Reward:X.nullish(),Steps:X.nullish()}).passthrough(),Rc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:fc.nullish(),Availability:En.nullish(),Policy:Gn.nullish(),Steps:zod.z.record(zod.z.string(),ps).nullish(),Reward:Nn.nullish(),Presets:gc.nullish()}).passthrough(),yc=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(),Cc=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:yc.nullish()}).passthrough(),Sc=zod.z.object({Availability:zod.z.record(zod.z.string(),En).nullish(),Policy:zod.z.record(zod.z.string(),Gn).nullish(),Reward:zod.z.record(zod.z.string(),Nn).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),ps)).nullish()}).passthrough(),jn=zod.z.object({Flows:zod.z.record(zod.z.string(),Rc).nullish(),Settings:Cc.nullish(),Presets:Sc.nullish()}).passthrough(),xc=zod.z.object({}).passthrough().transform(o=>o),Fn=zod.z.object({FlowID:zod.z.string(),Status:oc,CurrentStepID:zod.z.string().nullish(),CurrentStep:ps.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(),Vn=zod.z.object({State:xc.nullish(),Flows:zod.z.array(Fn).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),lt=zod.z.object({Flow:Fn.nullish()}).passthrough(),_n=zod.z.object({FlowID:zod.z.string().nullish(),Granted:b.nullish()}).passthrough(),Wn=zod.z.array(re(lt)),Qn=zod.z.object({FlowID:zod.z.string(),StepID:zod.z.string(),Progress:zod.z.number(),Target:zod.z.number(),Completed:zod.z.boolean()}).passthrough(),Be={GetTutorialDefinitions:"GetTutorialDefinitions",GetUserTutorialState:"GetUserTutorialState",StartFlow:"StartFlow",ReportStepShown:"ReportStepShown",CompleteStep:"CompleteStep",CompleteStepsBatch:"CompleteStepsBatch",SkipStep:"SkipStep",SkipFlow:"SkipFlow",ClaimFlowReward:"ClaimFlowReward",ResetFlow:"ResetFlow"};var Xt=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 ei=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Kn(o){return o===429||o>=500&&o<=599}function ds(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 hs(o){return new Promise(e=>setTimeout(e,o))}var Dc=12e3,bc=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(Qn).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),ti=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new ei;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 Xt(e.throttleMs),this.clientPlatform=e.clientPlatform??He.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),D=r.ticket??null,U=r.silent??!1,E=r.timeoutMs??Dc,de=r.autoRetry??!0,Re=!1,Pe=0;for(;;){let Qe;try{Qe=await this.doFetch(a,p,D,E);}catch{if(de&&Pe<3){Pe++,await hs(ds(Pe));continue}return this.connectionFailure("Internet Connection Error",U)}let Ke=Qe.status;if(Ke>=200&&Ke<300)return await this.parseSuccess(Qe,i,U,e);if(Ke===401){if(!Re&&this.sessionRefreshHandler){Re=!0;let et=null;try{et=await this.sessionRefreshHandler();}catch{et=null;}if(et){D=et;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Kn(Ke)){if(de&&Pe<3){Pe++,await hs(ds(Pe));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Ke})`,U)}return await this.handleWebError(Qe,Ke,U)}}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=bc.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let Re=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",Re),n("server",Re)}let D=p.data.QuestProgress;D&&D.length>0&&this.emitter.emit("quest:systemProgress",D);let U=p.data.TutorialProgress;U&&U.length>0&&this.emitter.emit("tutorial:systemProgress",U);let E=p.data.StateVersions;E&&Object.keys(E).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:E});let de=t.safeParse(p.data.Data);if(!de.success){let Re=`Validation error (${r}): ${de.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",Re),i||this.emitter.emit("error:global",Re),n("validation",Re)}return vn(de.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 vt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function Gt(o){return `${vt(o)}T00:00:00.000Z`}function $n(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Zn(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function Jn(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,D=new Map,U=new Map,E=new Map,de=new Map,Re=new Map,Pe=new Map,Qe=new Map,Ke=e.Grant?.PremiumTiers??[],et=Ke.length;for(let ne=0;;ne++){let he,Z;if(ne===0)he=e.Grant?.Standard?.Entries,Z=false;else if(ne-1<et)he=Ke[ne-1]?.Resources?.Entries,Z=false;else if(ne===1+et)he=e.Consume?.Standard?.Entries,Z=true;else break;if(he)for(let V of he){if(V.Type==null)continue;let H=Math.max(0,V.Amount??0);if(!(H<=0))switch(V.Type){case "VirtualCurrency":{if(!V.CurrencyID)continue;let $=Z?D:p;$.set(V.CurrencyID,($.get(V.CurrencyID)??0)+H);break}case "CryptoCurrency":{if(!V.CurrencyID)continue;let $=Z?E:U;$.set(V.CurrencyID,($.get(V.CurrencyID)??new ii__default.default(0)).plus(H));break}case "Item":{if(!V.ItemID)continue;let $=Tc(t,V.CatalogID,V.ItemID),ee=($?$.IsStackable??true:true)?Z?Re:de:Z?Qe:Pe;ee.set(V.ItemID,(ee.get(V.ItemID)??0)+H);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||D.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...D.keys()])){let he=p.get(ne)??0,Z=D.get(ne)??0,V=he-Z,H=s.VirtualCurrencies[ne];H?(H.Amount+=V,H.UpdatedAt=a,H.Daily&&vt(H.Daily.PeriodStartUtc)===vt(i)?(H.Daily.Earned+=he,H.Daily.Spent+=Z):H.Daily={PeriodStartUtc:Gt(i),Earned:he,Spent:Z}):s.VirtualCurrencies[ne]={Amount:V,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Gt(i),Earned:he,Spent:Z}};}}if(r.ccChanged=U.size>0||E.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...U.keys(),...E.keys()])){let he=U.get(ne)??new ii__default.default(0),Z=E.get(ne)??new ii__default.default(0),V=he.minus(Z),H=s.CryptoCurrencies[ne];H?(H.Amount=new ii__default.default(H.Amount).plus(V).toString(),H.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:V.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=de.size>0||Re.size>0||Pe.size>0||Qe.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,he=new Set([...de.keys(),...Re.keys(),...Pe.keys(),...Qe.keys()]);for(let Z of he){let V=(de.get(Z)??0)-(Re.get(Z)??0),H=(Pe.get(Z)??0)-(Qe.get(Z)??0),$=V+H,Ae=s.Items[Z];Ae?(V!==0&&(Ae.StackableAmount+=V),H!==0&&(Ae.UnstackableAmount+=H),$!==0&&(Ae.TotalAmount+=$)):s.Items[Z]={StackableAmount:Math.max(0,V),UnstackableAmount:Math.max(0,H),TotalAmount:Math.max(0,$)};}for(let[Z,V]of Qe){if(V<=0)continue;let H=Object.values(ne).filter($=>$.ItemID===Z&&$.EquippedSlot==null&&($.ExpiresAt==null||new Date($.ExpiresAt)>i)).sort(zc).slice(0,V).map($=>$.ItemInstanceID);for(let $ of H)delete ne[$];}for(let[Z,V]of Pe){let H=vc(t,Z);for(let $=0;$<V;$++){let Ae=P();ne[Ae]={ItemInstanceID:Ae,ItemID:Z,CatalogID:H,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Ru=o.EventToken;for(let ne=0;;ne++){let he,Z;if(ne===0)he=e.Grant?.Standard?.EventTokens,Z=false;else if(ne-1<et)he=Ke[ne-1]?.Resources?.EventTokens,Z=false;else if(ne===1+et)he=e.Consume?.Standard?.EventTokens,Z=true;else break;if(!(!he||he.length===0))for(let V of he){let H=V.Address;if(!H||H.Type==null)continue;let $=V.Amount??0;if($<=0)continue;let Ae=Pc(Ru,H.Type);if(!Ae)continue;let ee=Ae[H.EntityID];ee||(ee={},Ae[H.EntityID]=ee),ee.Balance??={Current:0,TotalEarned:0,TotalSpent:0},ee.Daily??={Date:Gt(i),TotalEarned:0},ee.Meta??={};let Bt=V.Source&&V.Source.length>0?V.Source:"CustomAction";Z?(ee.Balance.Current-=$,ee.Balance.TotalSpent+=$):(ee.Balance.Current+=$,ee.Balance.TotalEarned+=$,vt(ee.Daily.Date)!==vt(i)&&(ee.Daily={Date:Gt(i),TotalEarned:0}),ee.Daily.TotalEarned+=$,ee.Daily.EarnedBySource??={},ee.Daily.EarnedBySource[Bt]=(ee.Daily.EarnedBySource[Bt]??0)+$,ee.Daily.TriggersBySource??={},ee.Daily.TriggersBySource[Bt]=(ee.Daily.TriggersBySource[Bt]??0)+1,ee.Daily.LastTriggerBySource??={},ee.Daily.LastTriggerBySource[Bt]=a,ee.Meta.JoinedAtUtc||(ee.Meta.JoinedAtUtc=a),ee.Meta.LastEarnedAtUtc=a),r.tokensChanged=true;}}return r}function zc(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 Tc(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 vc(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 Pc(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 ms(o,e){return o===e||o.startsWith(`${e}:`)}var ri=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=Jn(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 ii__default.default?t:new ii__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new ii__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=$n(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??={},i.Milestone.ClaimedIDs??=[],i.Milestone.ClaimedIDs.includes(t)||i.Milestone.ClaimedIDs.push(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??={},s.Milestone.ClaimedIDs=i.ClaimedPointMilestoneIDs??[];}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(ms(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))!ms(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){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let i=e.UnlockedIDs.indexOf(t);i>=0&&e.UnlockedIDs.splice(i,1);}}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.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);}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 si=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 ni=class{user;config;constructor(e){this.user=new ri(e),this.config=new si;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var oi=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 Ic(e)?e:me.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 Ic(o){return o!==null&&Object.values(me).includes(o)}var kc=8,Mc=100,wc=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,Yn=["GameLoop"],ai=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=me.None;sessionEmail="";sessionPassword="";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()}}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(me.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(me.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(me.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);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(me.Email);return s.ok&&this.keepEmailCredentials(e,t),s}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(me.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(me.Wallet)):s}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=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.loginWithPlatformToken(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(me.iDosGames)):i}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(me.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 me.Email:return this.loginWithEmail(t,i);case me.Device:case me.None:return this.loginWithDeviceID();case me.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!==me.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===me.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&&wc.test(e)}static isValidPasswordLength(e){return e.length>=kc&&e.length<=Mc}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=me.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(Yn,Yn);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 Oc="idos:cfg",Pt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${Xn(t)}`:e&&e.length>0?`f:${Xn(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 `${Oc}:${this.titleId}:${e}`}};function Xn(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var eo="idos:loc",It=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 `${eo}:${this.titleId}:${e}`}versionsKey(){return `${eo}:${this.titleId}:versions`}};var Ac="idos:state",li=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 `${Ac}:${this.titleId}:${e}`}};function Uc(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 gs(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 Bc(o){return {...o??{}}}function Rs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var ui=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=Uc(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=Bc(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 to=n("server","Title configuration is unavailable (CDN and API both failed)."),ci=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:P()}:null}get configCache(){return this.cache??=new Pt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new It(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new ui(new li(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=Pt.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?to:(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=gs(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=Rs(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=Pt.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 D=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return D==null?to:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,D,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,D=s.Locale??e;return p>0&&await this.localizationCache.write(D,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=gs(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=Rs(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,D=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let U=this.ctx.data.user.state;s&&U&&U.GameLoop==null&&(U.GameLoop=p);let E=this.ctx.data.config.titlePublicConfiguration;a&&E&&E.GameLoop==null&&(E.GameLoop=D),this.ctx.emitter.emit("user:clientStateReceived",e);}};var di=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===je.Crypto||i===je.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}_${P()}`},D=await this.ctx.api.currency.convert(p);if(D.ok){let U=D.data,E={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.SourceID,Amount:U.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.TargetID,Amount:U.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(E,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",U);}return D}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof ii__default.default?s:new ii__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===je.Virtual&&i===je.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===je.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 D={...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}_${P()}`},U=await this.ctx.api.currency.cryptoConvert(D);if(U.ok){let E=U.data,de=[],Re=[];if(E.SourceType===je.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===je.Virtual&&Re.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),de.length>0||Re.length>0){let Pe={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:Re.length>0?{Standard:{Entries:Re}}:null};this.ctx.data.user.applyResourceOperation(Pe,this.ctx.data.config.itemDefinitions);}E.SourceType===je.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new ii__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===je.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new ii__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return U}};var hi=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}_${P()}`};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 Lc="Store",mi=class{constructor(e){this.ctx=e;}ctx;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,RelatedEntityID:`store_buy_${e}_${r.userID}_${P()}`},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(Lc,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}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 fi=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},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 gi=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===Wt.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!==Wt.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 qc="Lootbox",Ri=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(qc,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"}_${P()}`},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 Ec="Reward";function ys(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var yi=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(Ec,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"}_${P()}`},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(!ys(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}_${P()}`},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(!ys(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}_${P()}`},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(!ys(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}_${P()}`},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 Gc="Tutorial",Ci=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(Gc,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}_${P()}`})}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}_${P()}`},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}_${P()}`},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 D=await i(p);return D.ok&&(this.applyFlowView(D.data),this.ctx.emitter.emit("tutorial:stepChanged",D.data)),D}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 Si=Object.freeze({}),xi=class{constructor(e){this.ctx=e;}ctx;table={...Si};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new It(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?Nc(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Si},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 D=await this.loadTableFromApi(a);D.ok&&(p=D.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={...Si},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:P()}: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(io(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??io(e),p=s.Version??0;if(s.NotModified){let U=i??await this.cache.read(a);return {ok:true,data:{locale:a,table:U?.t??{...Si},fallbackLocale:s.FallbackLocale??null}}}let D=s.Entries??{};return p>0&&await this.cache.write(a,p,D),{ok:true,data:{locale:a,table:D,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 Nc(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function io(o){return o.trim().replace(/_/g,"-").toLowerCase()}var jc="Quest",Di=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(jc,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}_${P()}`},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}_${P()}`},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}_${P()}`},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 Fc="TimedEvent",bi=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(Fc,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 D={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},U=await this.ctx.api.timedEvent.grantTokens(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",U.data)),U}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 Vc="Leaderboard",zi=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(Vc,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 D=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),D.NewScore,D.NewScore,D.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",D);}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 _c="Season",Ti=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(_c,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}_${P()}`},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}_${P()}`},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}_${P()}`},s=await this.ctx.api.season.claimTierRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[]){let D=p.Data?.TierNumber;p.Success&&typeof D=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,D);}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 Wc="Premium",vi=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(Wc,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,D){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 U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:D,RelatedEntityID:`premium_iap_${e}_${t}`},E=await this.ctx.api.premium.purchaseRealMoney(U);if(E.ok){let de=E.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 E}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Qc="Character",Pi=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(Qc,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}_${P()}`},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}_${P()}`,...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}_${P()}`,...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 Kc="Match",Ii=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 D={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${P()}`},U=await this.ctx.api.match.createMatch(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",U.data)),U}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}_${P()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let D=p.data,U=this.ctx.data.config.itemDefinitions;if(D.Resources)this.ctx.data.user.applyResourceOperation(D.Resources,U);else if(D.ResourcesDual){let E=D.ResourcesDual;E.FromUserID===s.userID&&E.FromResult?this.ctx.data.user.applyResourceOperation(E.FromResult,U):E.ToUserID===s.userID&&E.ToResult&&this.ctx.data.user.applyResourceOperation(E.ToResult,U);}this.ctx.emitter.emit("match:instantBattleCompleted",D);}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(Kc,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Hc="Craft",ki=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(Hc,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}_${P()}`},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 $c="Collection",Mi=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($c,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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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 D={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:i,ReceiverUserID:r,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${r}_${P()}`},U=await this.ctx.api.collection.sendTradeOffer(D);return U.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",U.data),U}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}_${P()}`},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}_${P()}`},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}_${P()}`},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 Zc="CoopEvent",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.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Zc,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:P()},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 Jc="DealOffer",Oi=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(Jc,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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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 Yc="Referral",Ai=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(Yc,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=e.trim().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.ReferralCode&&this.ctx.data.user.patchReferralSubscription(a.ReferralCode),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 Ui=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 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 Xc="TimedBoost";function ep(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Bi=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(Xc,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(!ep(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}_${P()}`},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 tt={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},tp={Client:"Client",Server:"Server",System:"System"},ip=zod.z.enum(["Client","Server","System"]),rp=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:ip.nullish(),ExpiresAt:u.nullish()}).passthrough(),Li=zod.z.record(zod.z.string(),rp),ro=zod.z.object({Version:zod.z.number().nullish(),Private:Li.nullish(),Public:Li.nullish(),ReadOnly:Li.nullish()}),Cs=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Li.nullish()}),Ss=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),sp=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),so=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(sp).nullish()}),no=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),oo=zod.z.object({Results:zod.z.array(Cs).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),np={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},op=zod.z.enum(["String","Int","Bool","Json"]),ap=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:op.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),qi=zod.z.object({Keys:zod.z.record(zod.z.string(),ap).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(),_e={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var lp="UserCustomData";function ao(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Ei=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(lp,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,tt.Private)}async setPublicData(e,t){return this.setData(e,t,tt.Public)}async setData(e,t,i){let r=e.trim();if(!ao(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===tt.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let D=p.data;this.ctx.data.user.patchUserCustomDataKey(i,D.KeyID,t,D.Version??0,D.ExpiresAt),this.ctx.emitter.emit(i===tt.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",D);}return p}async deleteKey(e,t){let i=e.trim();if(!ao(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==tt.Private&&t!==tt.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??tt.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 up="TitleCustomDataDefinitions",lo=50;function cp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function xs(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function pp(o){let e={};for(let[t,i]of Object.entries(o))xs(i)||(e[t]=i);return e}var Gi=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(up,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=>!cp(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>lo)return n("client",`At most ${lo} 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&&!xs(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!xs(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=pp(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 Ni=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 dp=15,hp="GameLoop",mp="BoardDefinition",ji=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(hp,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(mp,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}_${P()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(i);if(r.ok){let s=r.data,a=Zn(new Date,dp);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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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}_${P()}`},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(D=>{D.ChoiceID=e,D.ChosenMode=a.Mode??"Timed",D.StartedAtUtc=a.StartedAtUtc??null,D.DurationSeconds=a.DurationSeconds??null,D.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}_${P()}`},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(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(i.ok){let r=i.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return i}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 Fi=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 uo=zod.z.object({ServerTimeUtc:u,SourceType:zt,SourceID:zod.z.string(),TargetType:zt,TargetID:zod.z.string(),SourceSpent:w,FeeAmount:w,RateApplied:q,TargetCredited:w}),co=zod.z.object({ServerTimeUtc:u,SourceType:zt,SourceID:zod.z.string(),TargetType:zt,TargetID:zod.z.string(),SourceSpent:q,FeeAmount:q,RateApplied:q,TargetCredited:q}),Vi={Convert:"Convert",CryptoConvert:"CryptoConvert"},fp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},po=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),gp={Automatic:"Automatic",Manual:"Manual"},Rp=zod.z.enum(["Automatic","Manual"]),yp=zod.z.object({ValueInUSD:q.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(),Cp=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Sp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),xp=zod.z.object({TargetCurrencyType:zt.nullish(),TargetCurrencyID:zod.z.string(),Rate:q.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),ho=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Rp.nullish(),FeePercent:q.nullish(),Targets:zod.z.array(xp).nullish()}).passthrough(),mo=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),Dp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:yp.nullish(),Recharge:Cp.nullish(),Conversion:ho.nullish(),Permissions:Sp.nullish(),Audit:mo.nullish(),Status:po.nullish()}).passthrough(),bp=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:q.nullish(),MinWithdraw:q.nullish(),WithdrawFee:q.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),zp=zod.z.object({DailyWithdrawUsd:q.nullish(),MonthlyWithdrawUsd:q.nullish(),KycRequiredAboveUsd:q.nullish()}).passthrough(),Tp=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:q.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:q.nullish(),CommunityMarketingDepositSharePercent:q.nullish(),WithdrawalBurnPercent:q.nullish(),Networks:zod.z.array(bp).nullish(),Limits:zp.nullish(),Permissions:Tp.nullish(),Conversion:ho.nullish(),Audit:mo.nullish(),Status:po.nullish()}).passthrough(),_i=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Dp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ds).nullish()}).passthrough();var fo=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:Et.nullish(),AllowedPlatforms:zod.z.array(Kt).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Y=zod.z.record(zod.z.string(),fo),vp=zod.z.object({Store:Ht,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var go=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),bs=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:w.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),go).nullish(),UpdatedAt:u.nullish()}).passthrough(),Pp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Ip=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:Pp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),ut=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Ip).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),Ro=zod.z.object({Characters:zod.z.record(zod.z.string(),bs).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:b.nullish()}),Ts=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),yo=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),go).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ut.nullish()}),Co=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:ut.nullish()}),kp=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),So=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),kp).nullish(),Inventory:ut.nullish()}),vs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),xo=$e(vs),Do=$e(Ts),bo=$e(zs),zo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),To=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:Y.nullish(),CostScalingFactor:zod.z.number().nullish(),BaseStatValue:zod.z.number().nullish(),StatScalingFactor:zod.z.number().nullish(),CharacterLevelScalingFactor:zod.z.number().nullish(),Requirements:zod.z.array(zo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vo=zod.z.object({Level:zod.z.number().nullish(),PriceOptions:Y.nullish(),GlobalStatMultiplier:zod.z.number().nullish(),StatMaxLevelMultiplier:zod.z.number().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Mp=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(zo).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(),Po=zod.z.object({Slots:zod.z.record(zod.z.string(),Mp).nullish()}).passthrough(),wp=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(),Op=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ap=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:Y.nullish()}).passthrough(),Up=zod.z.object({Stats:X.nullish(),Levels:X.nullish(),Equipment:X.nullish()}).passthrough(),Bp=zod.z.object({CharacterID:zod.z.string(),Identity:wp.nullish(),Classification:Op.nullish(),Unlock:Ap.nullish(),Presets:Up.nullish(),Equipment:Po.nullish(),Stats:zod.z.record(zod.z.string(),To).nullish(),Levels:zod.z.record(zod.z.string(),vo).nullish()}).passthrough(),Lp=zod.z.object({Stats:zod.z.record(zod.z.string(),To).nullish()}).passthrough(),qp=zod.z.object({Levels:zod.z.record(zod.z.string(),vo).nullish()}).passthrough(),Ep=zod.z.object({Equipment:Po.nullish()}).passthrough(),Gp=zod.z.object({Stats:zod.z.record(zod.z.string(),Lp).nullish(),Levels:zod.z.record(zod.z.string(),qp).nullish(),Equipment:zod.z.record(zod.z.string(),Ep).nullish()}).passthrough(),Wi=zod.z.object({Definitions:zod.z.record(zod.z.string(),Bp).nullish(),Presets:Gp.nullish()}).passthrough(),Me={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var Np={EVM:"EVM",Solana:"Solana"},jp=zod.z.enum(["EVM","Solana"]),Fp={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Vp=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),_p={Token:"Token",Nft:"Nft"},Io=zod.z.enum(["Token","Nft"]),Wp={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Qp=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Kp={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Hp=zod.z.enum(["None","Tier1","Tier2","Tier3"]),$p={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Ps=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),ko={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Qi(o){let e=o?.trim();return e||ko.GameTopUp}var Zp={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Mo=zod.z.enum(["UsersCryptoWallet","Game"]),Jp=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(),wo=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),Yp=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:jp.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:wo.nullish(),NftCollections:zod.z.array(Jp).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xp=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:wo.nullish()}).passthrough(),ed=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 td=zod.z.enum(["OnChain","Combined"]),id=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:q.nullish(),BalanceSource:td.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),rd=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(id).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Is=zod.z.object({SystemState:Xp.nullish(),Networks:zod.z.record(zod.z.string(),Yp).nullish(),AccountSafety:ed.nullish(),WalletLogin:rd.nullish()}).passthrough(),sd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:Vp.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Oo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Io.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:q.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),nd=zod.z.object({Status:Qp.nullish(),Tier:Hp.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),od=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:q.nullish(),DepositsVolumeUsd:q.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:q.nullish(),WithdrawalsVolumeUsd:q.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),ad=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:q.nullish(),TotalWithdrawalsVolumeUsd:q.nullish(),PerCurrency:zod.z.record(zod.z.string(),od).nullish()}).passthrough(),ld=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(),ud=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(),ld).nullish()}).passthrough(),cd=zod.z.object({Tokens:ad.nullish(),Nfts:ud.nullish()}).passthrough(),pd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),dd=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(pd).nullish()}).passthrough(),hd=zod.z.object({Version:zod.z.number().nullish(),Stats:cd.nullish(),LinkedWallets:zod.z.record(zod.z.string(),sd).nullish(),LastWalletLogin:dd.nullish(),PendingWithdrawals:zod.z.array(Oo).nullish(),Kyc:nd.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),md=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:u}).passthrough(),Ki=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),md).nullish(),PendingAdded:Oo.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),fd=zod.z.object({Amount:q,Frozen:q,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),gd=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:Mo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Ps.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:q.nullish(),NetPayoutAmount:q.nullish()}).passthrough(),Rd=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:Mo.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Ps.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(),Ao=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),ks=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(Ao).nullish(),Signature:zod.z.string().nullish()}).passthrough(),Ms=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(Ao).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(),Uo=zod.z.object({Blockchain:Is.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ds).nullish()}).passthrough(),Bo=zod.z.object({State:hd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),fd).nullish()}).passthrough(),Lo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),StateDelta:Ki.nullish()}).passthrough(),qo=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:b.nullish(),Inventory:ut.nullish()}).passthrough(),Eo=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),NetAmountNative:q.nullish(),BurnAmountNative:q.nullish(),AmountUsd:q.nullish(),ExpiresAt:u.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish(),StateDelta:Ki.nullish()}).passthrough(),Go=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:b.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish(),StateDelta:Ki.nullish(),Inventory:ut.nullish()}).passthrough(),No=zod.z.object({TokenTransactions:zod.z.array(gd).nullish(),NFTTransactions:zod.z.array(Rd).nullish()}).passthrough(),ws=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),Target:zod.z.string().nullish()}).passthrough(),jo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Io.nullish(),EvmSignature:ks.nullish(),SolanaSignature:Ms.nullish()}).passthrough(),Fo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Ps.nullish(),StateDelta:Ki.nullish()}).passthrough(),we={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var yd="Blockchain",Hi=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(yd,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 ii__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=Qi(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 ii__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 D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.NetworkID=t,D.WalletAddress=i,D.Amount=r,D.Category=Qi(s),a!==void 0&&(D.Level=a),p&&(D.ItemInstanceID=p);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",U.data)),U}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 be=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 Cd={Head:"Head",Torso:"Torso",Legs:"Legs"},$i=zod.z.enum(["Head","Torso","Legs"]),Sd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Os=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Wo=zod.z.object({AttackTarget:$i,DefenseTarget:$i});var xd=zod.z.enum(["Hit","Critical","Block","Dodge"]),Dd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:$i.nullish(),DefenseZone:$i.nullish(),HitType:xd.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),bd=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(),zd=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),_o=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:bs.nullish(),BattleStrategy:zod.z.array(Wo).nullish(),UnstackableItems:zod.z.record(zod.z.string(),zd).nullish(),Stats:bd.nullish()}).passthrough(),Td=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:fe.nullish(),NetReward:fe.nullish(),BattleLog:zod.z.array(Dd).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:_o.nullish(),P2BattleProfile:_o.nullish()}).passthrough(),Qo=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(Wo).nullish(),TargetUserID:zod.z.string().nullish(),Entry:fe.nullish(),CreationCostPaid:fe.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Os.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),Ko=zod.z.object({Status:Os,MatchID:zod.z.string(),Entry:fe.nullish(),Resources:b.nullish()}),Ho=zod.z.object({Match:Qo.nullish()}),$o=zod.z.object({MatchID:zod.z.string(),Status:Os,Resources:b.nullish()}),Zo=zod.z.object({Battle:Td.nullish(),Resources:b.nullish(),ResourcesDual:dt.nullish()}),As=zod.z.object({Matches:zod.z.array(Qo).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Je={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var vd=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var Pd=zod.z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),Id=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(),kd=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()}).passthrough(),Md=zod.z.object({Source:Pd.nullish(),StatID:zod.z.string().nullish(),Value:zod.z.number().nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),wd=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(Md).nullish()}).passthrough(),mt=zod.z.object({Terms:zod.z.array(wd).nullish()}).passthrough(),Od=zod.z.object({Health:mt.nullish(),Damage:mt.nullish(),Armor:mt.nullish(),AttackSpeed:mt.nullish(),CritChance:mt.nullish(),CritDamage:mt.nullish(),Dodge:mt.nullish()}).passthrough(),Jo=zod.z.object({StatMapping:Id.nullish(),Combat:kd.nullish(),Formula:Od.nullish()}).passthrough(),Ad=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Us=zod.z.object({Kind:vd.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:$t.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),Yo=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Us).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Xo=zod.z.object({PriceOptions:Y.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ge.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),Ud=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Ad.nullish(),Entry:Yo.nullish(),Creation:Xo.nullish(),Settings:Jo.nullish()}).passthrough(),Bd=zod.z.object({Rules:zod.z.record(zod.z.string(),Ud).nullish(),Defaults:Jo.nullish(),EntryDefaults:Yo.nullish(),CreationDefaults:Xo.nullish()}).passthrough(),Bs=zod.z.object({InstantBattle:Bd.nullish()}).passthrough(),ea=Bs;var Ld={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Ls=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),qd={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},qs=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),Ed={Burn:"Burn",Ledger:"Ledger"},Gd=zod.z.enum(["Burn","Ledger"]),Ji={Item:"Item",VirtualCurrency:"VirtualCurrency"},Es=zod.z.enum(["Item","VirtualCurrency"]),Nd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish()}).passthrough(),jd=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Us).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Fd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:w.nullish(),Sink:Gd.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Nd).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Vd=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(),_d=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ge.nullish(),BuyLimits:ge.nullish(),ListingFeeOptions:Y.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Wd=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:w.nullish(),BidLimits:ge.nullish()}).passthrough(),Qd=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ge.nullish(),FillLimits:ge.nullish()}).passthrough(),Kd=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ge.nullish()}).passthrough(),Hd=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Gs=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:_.nullish(),Schedule:pe.nullish(),PricePolicy:jd.nullish(),Commission:Fd.nullish(),Tradability:Vd.nullish(),Listings:_d.nullish(),Auctions:Wd.nullish(),BuyOrders:Qd.nullish(),DirectTrades:Kd.nullish(),Matching:Hd.nullish()}).passthrough(),ta=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:w.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),$d=zod.z.object({BidAxisType:Qt.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:w.nullish(),CurrentBid:w.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(ta).nullish()}).passthrough(),Zi=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Zd=zod.z.object({Create:Zi.nullish(),Buy:Zi.nullish(),Sell:Zi.nullish(),Bid:Zi.nullish()}).passthrough(),Jd=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Yd=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:Jd.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),it=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ls.nullish(),Status:qs.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:be.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),GoodsInstances:zod.z.array(Yd).nullish(),Price:fe.nullish(),Auction:$d.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Xd=zod.z.object({GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Ls,w).nullish(),ListingCount:w.nullish(),AuctionCount:w.nullish(),BuyOrderCount:w.nullish()}).passthrough(),ia=zod.z.object({Definitions:Gs.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Ns=zod.z.object({Offers:zod.z.array(it).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ra=zod.z.object({Groups:zod.z.array(Xd).nullish()}).passthrough(),sa=zod.z.object({Offer:it.nullish()}).passthrough(),qe=zod.z.object({OfferID:zod.z.string().nullish(),Status:qs.nullish(),Settlement:dt.nullish(),Resources:b.nullish(),CommissionTaken:fe.nullish()}).passthrough(),Nt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:it.nullish(),Resources:b.nullish(),Matched:zod.z.boolean().nullish(),Settlement:qe.nullish()}).passthrough(),na=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:w.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish()}).passthrough(),oa=zod.z.object({MyOffers:zod.z.array(it).nullish(),MyLeadingBids:zod.z.array(it).nullish(),MyBuyOrders:zod.z.array(it).nullish(),IncomingTrades:zod.z.array(it).nullish(),OutgoingTrades:zod.z.array(it).nullish(),Claimables:zod.z.array(it).nullish(),DrainedRefunds:zod.z.array(ta).nullish(),Limits:Zd.nullish()}).passthrough(),eh=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Ls.nullish(),FinalStatus:qs.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Es.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:w.nullish(),PricePaid:fe.nullish(),CommissionTaken:fe.nullish(),CompletedAt:u.nullish()}).passthrough(),aa=zod.z.object({Entries:zod.z.array(eh).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ae={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 th="Marketplace",Yi=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(th,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 D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=i,D.PriceBundle=r,D.DurationHours=s,D.ItemInstanceIDs=a,D.SelectedOptionID=p;let U=await this.ctx.api.marketplace.createListing(D);return this.applyCreateOfferResult(U,"marketplace:listingCreated"),U}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 D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=i,D.BidAxisType=r,D.BidCurrencyID=p.bidCurrencyID,D.BidCatalogID=p.bidCatalogID,D.BidItemID=p.bidItemID,D.StartingBid=s,D.DurationHours=a,D.ItemInstanceIDs=p.itemInstanceIDs,D.SelectedOptionID=p.selectedOptionID;let U=await this.ctx.api.marketplace.createAuction(D);return this.applyCreateOfferResult(U,"marketplace:auctionCreated"),U}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=Ji.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Ji.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 Xi=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 la=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}),ze=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),ua=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),Oe={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",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 er=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,la,{ticket:null})}loginWithDeviceID(e){return this.login(Oe.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Oe.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Oe.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Oe.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Oe.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(Oe.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(Oe.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Oe.RequestWalletChallenge),e,ua,{ticket:null})}loginWithWallet(e){return this.login(Oe.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ForgotPassword),e,ze,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Oe.ResetPassword),e,ze,{ticket:null})}};var ih={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},ca=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]),rh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),pa=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),rh).nullish(),MissingKeyMode:ca.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),sh=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),da=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:sh.nullish()}).passthrough(),tr={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},nh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),ha=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:ca.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(nh).nullish()}).passthrough(),ma=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 js=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:da.nullish()}).passthrough().transform(o=>o),fa=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),ga=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),Ra=zod.z.object({}).passthrough().transform(o=>o),ya=zod.z.object({}).passthrough().transform(o=>o),Ca=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(),Sa=zod.z.object({Username:zod.z.string()}),Ee={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var ir=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(Ee.GetClientState,e.UserID),e,js,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Ee.GetClientStateExcept,e.UserID),e,js,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Ee.GetStateVersions,e.UserID),e,fa,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Ee.GetUserState,e.UserID),e,ga,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Ee.GetInventory,e.UserID),e,Ra,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Ee.GetEventTokens,e.UserID),e,ya,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Ee.GetUsageTime,e.UserID),e,Ca,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Ee.AddUsageTime,e.UserID),e,ze,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Ee.DeleteUserAccount,e.UserID),e,ze,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Ee.ChangeUsername,e.UserID),e,Sa,{ticket:e.ClientSessionTicket})}};var rr=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(Vi.Convert,e,uo)}cryptoConvert(e){return this.send(Vi.CryptoConvert,e,co)}};var oh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Fs=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:b.nullish(),FodderConsumed:zod.z.array(oh).nullish()}),xa=zod.z.array(re(Fs)),sr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},ah={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},lh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),uh={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},ch=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),ph=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),dh=zod.z.object({Networks:zod.z.record(zod.z.string(),ph).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),hh=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(),mh=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(),fh=zod.z.object({ValuationMode:lh.nullish(),MergeRatio:zod.z.number().nullish(),Selection:ch.nullish()}).passthrough(),gh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:Y.nullish(),CostScalingFactor:zod.z.number().nullish(),FlatScalingFactor:zod.z.number().nullish(),PercentScalingFactor:zod.z.number().nullish(),PowerScalingFactor:zod.z.number().nullish(),Fodder:fh.nullish()}).passthrough(),Rh=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),yh=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:dh.nullish(),Stats:hh.nullish(),Equipment:mh.nullish(),Upgrade:gh.nullish(),Metadata:Rh.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Ch=zod.z.object({Items:zod.z.record(zod.z.string(),yh).nullish()}).passthrough(),nr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Ch).nullish()}).passthrough();var or=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",sr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Fs,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",sr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,xa,{ticket:e.ClientSessionTicket})}};var Vs=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),Da=zod.z.array(re(Vs)),Sh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),ba=zod.z.object({Purchases:zod.z.record(zod.z.string(),Sh).nullish()}).passthrough().transform(o=>o),xh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Dh=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:xh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),bh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),zh=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),PriceOptions:Y.nullish(),Rewards:L.nullish(),Rules:bh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ar=zod.z.object({Stores:zod.z.record(zod.z.string(),Dh).nullish(),StoreOffers:zod.z.record(zod.z.string(),zh).nullish()}).passthrough(),kt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var lr=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(kt.Purchase,e,Vs)}purchaseBatch(e){return this.send(kt.PurchaseBatch,e,Da)}getDefinitions(e){return this.send(kt.GetDefinitions,e,ar)}getUserState(e){return this.send(kt.GetUserState,e,ba)}};var Th={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},vh=zod.z.enum(["Consumable","NonConsumable","Subscription"]),Ph=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:_.nullish(),Limits:ge.nullish()}).passthrough(),Ih=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:vh.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:Ph.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),za=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Ih).nullish()}).passthrough(),Ta=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()}).passthrough(),va=zod.z.object({Products:zod.z.record(zod.z.string(),Ta).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),kh={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},Mh=zod.z.enum(["Granted","Restored","AlreadyProcessed"]),_s=zod.z.object({ServerTimeUtc:u,Store:Ht.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:Mh.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:b.nullish(),ProductState:Ta.nullish()}).passthrough(),Pa=$e(_s),Mt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var ur=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(Mt.GetDefinitions,e,za)}getUserState(e){return this.send(Mt.GetUserState,e,va)}validatePurchase(e){return this.send(Mt.ValidatePurchase,e,_s)}validatePurchasesBatch(e){return this.send(Mt.ValidatePurchasesBatch,e,Pa)}};var wh=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ia=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:wh.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(Ia).nullish()}).passthrough(),Ot=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Ia).nullish()}).passthrough(),Oh=zod.z.object({RewardSlots:zod.z.array(wt).nullish()}).passthrough(),Ah=zod.z.object({PityRules:zod.z.array(Ot).nullish()}).passthrough(),cr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Oh).nullish(),PityPresets:zod.z.record(zod.z.string(),Ah).nullish()}).passthrough();var Uh=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),ka=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:b.nullish(),Inventory:ut.nullish(),Results:zod.z.array(b).nullish(),TriggeredPity:zod.z.array(Uh).nullish()}),Bh=zod.z.object({RewardSlots:X.nullish(),PityRules:X.nullish()}).passthrough(),Lh=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:w.nullish()}).passthrough(),qh=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:Y.nullish(),RewardSlots:zod.z.array(wt).nullish(),PityRules:zod.z.array(Ot).nullish(),Presets:Bh.nullish(),RewardMultiplier:Zt.nullish(),SupplyLimits:zod.z.array(Lh).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Ws=zod.z.object({Definitions:zod.z.record(zod.z.string(),qh).nullish(),RewardPools:cr.nullish()}).passthrough(),Ma=zod.z.object({LootboxDefinitions:Ws.nullish()}),pr={GetDefinitions:"GetDefinitions",Open:"Open"};var dr=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(pr.GetDefinitions,e,Ma)}open(e){return this.send(pr.Open,e,ka)}};var Eh=zod.z.object({}).passthrough().transform(o=>o),Gh=zod.z.object({}).passthrough().transform(o=>o),Nh=zod.z.object({}).passthrough().transform(o=>o),jh=zod.z.object({}).passthrough().transform(o=>o),Fh=zod.z.object({}).passthrough().transform(o=>o),wa=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:Eh,Resources:b.nullish()}),Oa=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:w.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Gh,Resources:b.nullish()}),Aa=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Nh,Resources:b.nullish()}),Ua=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:jh,Resources:b.nullish()}),Ba=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:w.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Vh=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),_h=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:L.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Wh=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(_h).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(),Qh=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),Kh=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(Qh).nullish()}).passthrough(),Hh=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(),$h=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:Kh.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Hh.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Zh=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Jh=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(Zh).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(),Yh=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(),Xh=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:L.nullish(),Limits:ge.nullish(),PremiumLimitOverrides:zod.z.array(Yh).nullish(),Gate:_.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Qs=zod.z.object({TierRewards:Vh.nullish(),MilestoneRewardMultiplier:Zt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Wh).nullish(),IdleAccruals:zod.z.record(zod.z.string(),$h).nullish(),Comebacks:zod.z.record(zod.z.string(),Jh).nullish(),Claims:zod.z.record(zod.z.string(),Xh).nullish()}).passthrough(),La=zod.z.object({RewardDefinitions:Qs.nullish()}),qa=zod.z.object({Rewards:Fh.nullish()}),st={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var hr=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(st.GetRewardDefinitions,e,La)}getUserRewardsState(e){return this.send(st.GetUserRewardsState,e,qa)}getMilestoneRewardMultiplier(e){return this.send(st.GetMilestoneRewardMultiplier,e,Ba)}claimDailyReward(e){return this.send(st.ClaimDailyReward,e,wa)}collectIdleAccrual(e){return this.send(st.CollectIdleAccrual,e,Oa)}claimComebackReward(e){return this.send(st.ClaimComebackReward,e,Aa)}claimReward(e){return this.send(st.ClaimReward,e,Ua)}};var mr=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(Be.GetTutorialDefinitions,e,jn)}getUserTutorialState(e){return this.send(Be.GetUserTutorialState,e,Vn)}startFlow(e){return this.send(Be.StartFlow,e,lt)}reportStepShown(e){return this.send(Be.ReportStepShown,e,lt)}completeStep(e){return this.send(Be.CompleteStep,e,lt)}completeStepsBatch(e){return this.send(Be.CompleteStepsBatch,e,Wn)}skipStep(e){return this.send(Be.SkipStep,e,lt)}skipFlow(e){return this.send(Be.SkipFlow,e,lt)}claimFlowReward(e){return this.send(Be.ClaimFlowReward,e,_n)}resetFlow(e){return this.send(Be.ResetFlow,e,lt)}};var fr=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(tr.GetLocalizationManifest,e,ha)}getLocalizationTable(e){return this.send(tr.GetLocalizationTable,e,ma)}};var gr=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(Ve.GetQuestDefinitions,e,Yt)}getUserQuestState(e){return this.send(Ve.GetUserQuestState,e,kn)}refreshQuestCycles(e){return this.send(Ve.RefreshQuestCycles,e,ze)}claimQuestReward(e){return this.send(Ve.ClaimQuestReward,e,ls)}claimQuestRewardsBatch(e){return this.send(Ve.ClaimQuestRewardsBatch,e,On)}claimMilestoneReward(e){return this.send(Ve.ClaimMilestoneReward,e,us)}claimMilestoneRewardsBatch(e){return this.send(Ve.ClaimMilestoneRewardsBatch,e,An)}claimGroupCompletionReward(e){return this.send(Ve.ClaimGroupCompletionReward,e,Mn)}addQuestProgress(e){return this.send(Ve.AddQuestProgress,e,wn)}};var Ea=zod.z.object({}).passthrough().transform(o=>o);var em=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),tm=zod.z.object({Schedule:zod.z.array(em).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),im=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(),rm=zod.z.object({Milestones:X.nullish()}).passthrough(),Ks=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:ht.nullish(),TokenSources:zod.z.array(Ue).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:rm.nullish(),BonusWindow:tm.nullish()}).passthrough(),sm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Ks.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nm=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:pe.nullish(),Content:Ks.nullish(),Events:zod.z.array(sm).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),om=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),am=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish()}).passthrough(),Rr=zod.z.object({Definitions:zod.z.record(zod.z.string(),nm).nullish(),Settings:om.nullish(),Presets:am.nullish()}).passthrough(),lm=zod.z.object({Type:qt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Ks.nullish(),Progress:Ea.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:De.nullish(),BonusWindow:im.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Ga=zod.z.object({ActiveEvents:zod.z.array(lm).nullish()}).passthrough(),Na=zod.z.object({Tokens:zod.z.record(zod.z.string(),Ea).nullish()}),Hs=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),$s=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),um=zod.z.object({Type:qt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Zs=zod.z.array(re($s)),ja=zod.z.array(re(Hs)),Fa=zod.z.array(re(um)),Ge={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var yr=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(Ge.GetActiveEvents,e,Ga)}getDefinitions(e){return this.send(Ge.GetDefinitions,e,Rr)}getUserLteState(e){return this.send(Ge.GetUserLteState,e,Na)}grantTokens(e){return this.send(Ge.GrantTokens,e,b)}spendTokens(e){return this.send(Ge.SpendTokens,e,Hs)}claimMilestone(e){return this.send(Ge.ClaimMilestone,e,$s)}claimMilestonesBatch(e){return this.send(Ge.ClaimMilestonesBatch,e,Zs)}claimAllMilestones(e){return this.send(Ge.ClaimAllMilestones,e,Zs)}spendTokensBatch(e){return this.send(Ge.SpendTokensBatch,e,ja)}grantTokensBatch(e){return this.send(Ge.GrantTokensBatch,e,Fa)}};var cm=zod.z.object({UserID:zod.z.string(),Score:w.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:be.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),jt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:w.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(cm).nullish(),BracketID:zod.z.string().nullish()}),pm=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:w.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),Cr=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:w.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:w.nullish(),MilestoneTokensEarned:w.nullish(),NextMilestone:De.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(pm).nullish()}),Sr=zod.z.object({LeaderboardID:zod.z.string(),NewScore:w,CycleVersion:zod.z.number()}),xr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),Dr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),Va=zod.z.array(re(jt)),_a=zod.z.array(re(Cr)),Wa=zod.z.array(re(xr)),Qa=zod.z.array(re(Dr)),Ka=zod.z.array(re(Sr)),dm=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(xr).nullish(),Milestones:zod.z.array(re(Dr)).nullish()}),Ha=zod.z.array(dm),hm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(jt).nullish(),Progress:re(Cr).nullish()}),$a=zod.z.array(hm),mm=zod.z.string(),Za=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:os.nullish()}).passthrough(),fm=zod.z.object({RankRewards:zod.z.array(Za).nullish()}).passthrough(),gm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Rm=zod.z.object({Milestones:X.nullish(),RankRewards:X.nullish()}).passthrough(),ym=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:mm.nullish(),Schedule:pe.nullish(),ChainEvents:zod.z.array(gm).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(Za).nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:Rm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Ue).nullish()}).passthrough(),Cm=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish(),RankRewards:zod.z.record(zod.z.string(),fm).nullish()}).passthrough(),br=zod.z.object({Definitions:zod.z.record(zod.z.string(),ym).nullish(),Presets:Cm.nullish()}).passthrough(),xe={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 zr=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(xe.GetDefinitions,e,br)}getLeaderboard(e){return this.send(xe.GetLeaderboard,e,jt)}getMyProgress(e){return this.send(xe.GetMyProgress,e,Cr)}submitScore(e){return this.send(xe.SubmitScore,e,Sr)}submitScoreFromSource(e){return this.send(xe.SubmitScoreFromSource,e,Sr)}claimCycleReward(e){return this.send(xe.ClaimCycleReward,e,xr)}claimMilestone(e){return this.send(xe.ClaimMilestone,e,Dr)}getFriendsLeaderboard(e){return this.send(xe.GetFriendsLeaderboard,e,jt)}getLeaderboardsBatch(e){return this.send(xe.GetLeaderboardsBatch,e,Va)}getProgressBatch(e){return this.send(xe.GetProgressBatch,e,_a)}claimCycleRewardsBatch(e){return this.send(xe.ClaimCycleRewardsBatch,e,Wa)}claimMilestonesBatch(e){return this.send(xe.ClaimMilestonesBatch,e,Qa)}submitScoresBatch(e){return this.send(xe.SubmitScoresBatch,e,Ka)}claimAllRewardsBatch(e){return this.send(xe.ClaimAllRewardsBatch,e,Ha)}getOverviewBatch(e){return this.send(xe.GetOverviewBatch,e,$a)}};var Js=zod.z.object({}).passthrough().transform(o=>o),Ja=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>tl).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:w.nullish(),UserState:Js.nullish(),NextTier:zod.z.lazy(()=>el).nullish()}).passthrough(),Ya=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:w.nullish(),NewStatusTokens:w.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),Ys=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),Xa=$e(Ys);var el=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:w.nullish(),TierReachedReward:L.nullish()}).passthrough(),tl=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:w.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(el).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Sm=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Seasons:zod.z.array(tl).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:_.nullish()}).passthrough(),Tr=zod.z.object({Chains:zod.z.record(zod.z.string(),Sm).nullish()}).passthrough(),pt={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var vr=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(pt.GetDefinitions,e,Tr)}getActiveSeason(e){return this.send(pt.GetActiveSeason,e,Ja)}getUserState(e){return this.send(pt.GetUserState,e,Js)}grantStatusTokens(e){return this.send(pt.GrantStatusTokens,e,Ya)}claimTierReward(e){return this.send(pt.ClaimTierReward,e,Ys)}claimTierRewardsBatch(e){return this.send(pt.ClaimTierRewardsBatch,e,Xa)}};var xm={Apple:"Apple",Google:"Google"},il=zod.z.object({}).passthrough().transform(o=>o),Dm=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(),bm=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:Y.nullish(),AppleProductID:zod.z.string().nullish(),GoogleProductID:zod.z.string().nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xs=zod.z.object({Definitions:zod.z.record(zod.z.string(),bm).nullish()}).passthrough(),rl=zod.z.object({Premium:Xs.nullish()}),sl=zod.z.object({ServerTimeUtc:u.nullish(),Premium:il.nullish()}),Pr=zod.z.object({ServerTimeUtc:u.nullish(),Premium:il.nullish(),Subscription:Dm.nullish(),Resources:b.nullish()}),ft={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Ir=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(ft.GetDefinitions,e,rl)}getUserState(e){return this.send(ft.GetUserState,e,sl)}activateTrial(e){return this.send(ft.ActivateTrial,e,Pr)}purchaseItemOrCurrency(e){return this.send(ft.PurchaseWithResources,e,Pr)}purchaseRealMoney(e){return this.send(ft.PurchaseRealMoney,e,Pr)}};var kr=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(Me.GetCharacterDefinitions,e,Wi)}getUserCharacters(e){return this.send(Me.GetUserCharacters,e,Ro)}unlockCharacter(e){return this.send(Me.UnlockCharacter,e,vs)}upgradeStatLevel(e){return this.send(Me.UpgradeStatLevel,e,zs)}upgradeCharacterLevel(e){return this.send(Me.UpgradeCharacterLevel,e,Ts)}equipItems(e){return this.send(Me.EquipItems,e,yo)}unequipItems(e){return this.send(Me.UnequipItems,e,Co)}unequipAllCharacters(e){return this.send(Me.UnequipAllCharacters,e,So)}unlockCharactersBatch(e){return this.send(Me.UnlockCharactersBatch,e,xo)}upgradeCharacterLevelsBatch(e){return this.send(Me.UpgradeCharacterLevelsBatch,e,Do)}upgradeStatLevelsBatch(e){return this.send(Me.UpgradeStatLevelsBatch,e,bo)}};var Mr=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(Je.CreateMatch,e,Ko)}updateMatch(e){return this.send(Je.UpdateMatch,e,Ho)}cancelMatch(e){return this.send(Je.CancelMatch,e,$o)}instantBattle(e){return this.send(Je.InstantBattle,e,Zo)}saveStrategy(e){return this.send(Je.SaveStrategy,e,ze)}getMyMatches(e){return this.send(Je.GetMyMatches,e,As)}getAvailableMatches(e){return this.send(Je.GetAvailableMatches,e,As)}getDefinitions(e){return this.send(Je.GetDefinitions,e,ea)}};var zm={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},nl=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),Tm=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:ns.nullish()}),ol=zod.z.object({ServerTimeUtc:u,Type:nl.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:b.nullish(),Results:zod.z.array(Tm).nullish()}),vm=zod.z.object({CraftID:zod.z.string().nullish(),Type:nl.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:Y.nullish()}).passthrough(),en=zod.z.object({Definitions:zod.z.record(zod.z.string(),vm).nullish()}).passthrough(),al=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:en.nullish()}),wr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Or=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(wr.GetDefinitions,e,al)}craft(e){return this.send(wr.Craft,e,ol)}};var Pm={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Im=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),ll=zod.z.object({}).passthrough().transform(o=>o),At=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()}),ul=zod.z.object({GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish()}),cl=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(ul).nullish(),GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),pl=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(ul).nullish(),GrantedCollectibles:zod.z.array(At).nullish(),DuplicateCollectibles:zod.z.array(At).nullish(),CollectionCurrencyEarned:w.nullish(),NewCollectionCurrencyBalance:w.nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),dl=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),tn=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),hl=zod.z.array(re(tn)),ml=zod.z.object({Resources:b.nullish()}),km=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:be.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:Im.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(),fl=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),gl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Rl=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()}),yl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),rn=zod.z.object({Offers:zod.z.array(km).nullish()}),Mm=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(),wm=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(Mm).nullish(),SetCompletionReward:L.nullish()}).passthrough(),Om=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(wm).nullish(),GrandPrize:L.nullish()}).passthrough(),Cl=zod.z.object({BonusRewardSlots:X.nullish(),PityRules:X.nullish()}).passthrough(),Am=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:Y.nullish(),BonusRewardSlots:zod.z.array(wt).nullish(),PityRules:zod.z.array(Ot).nullish(),Presets:Cl.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(),Um=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Bm=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(Ot).nullish(),Presets:Cl.nullish(),Tier:zod.z.number().nullish()}).passthrough(),Lm=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(),Ar=zod.z.object({Collections:zod.z.record(zod.z.string(),Om).nullish(),PackTypes:zod.z.record(zod.z.string(),Am).nullish(),CollectionChests:zod.z.array(Bm).nullish(),DuplicateConversions:zod.z.array(Um).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(Lm).nullish(),RewardPools:cr.nullish()}).passthrough(),Te={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 Ur=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(Te.GetDefinitions,e,Ar)}getUserState(e){return this.send(Te.GetUserState,e,ll)}openPack(e){return this.send(Te.OpenPack,e,cl)}openCollectionChest(e){return this.send(Te.OpenCollectionChest,e,pl)}useCollectibleJoker(e){return this.send(Te.UseCollectibleJoker,e,dl)}claimSetReward(e){return this.send(Te.ClaimSetReward,e,tn)}claimSetRewardsBatch(e){return this.send(Te.ClaimSetRewardsBatch,e,hl)}claimGrandPrize(e){return this.send(Te.ClaimGrandPrize,e,ml)}sendTradeOffer(e){return this.send(Te.SendTradeOffer,e,fl)}cancelTradeOffer(e){return this.send(Te.CancelTradeOffer,e,gl)}acceptTradeOffer(e){return this.send(Te.AcceptTradeOffer,e,Rl)}declineTradeOffer(e){return this.send(Te.DeclineTradeOffer,e,yl)}getMyTradeOffers(e){return this.send(Te.GetMyTradeOffers,e,rn)}getIncomingTradeOffers(e){return this.send(Te.GetIncomingTradeOffers,e,rn)}};var qm=zod.z.object({}).passthrough().transform(o=>o),Em={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Gm={Active:"Active",Left:"Left",Replaced:"Replaced"},Nm=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),jm=zod.z.object({UserID:zod.z.string().nullish(),PublicData:be.nullish(),BuildObjectsProgress:Nm.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(),Fm=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(),Vm=zod.z.object({Objects:zod.z.array(Fm).nullish()}).passthrough(),Sl=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(jm).nullish(),BuildObjectsState:Vm.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),xl=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),_m=zod.z.string(),sn=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(),Wm=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:L.nullish()}).passthrough(),Qm=zod.z.object({Objects:zod.z.array(Wm).nullish(),PriceOptions:Y.nullish(),SpinnerTable:zod.z.array(sn).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Km=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:_m.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:Qm.nullish(),GrandPrize:L.nullish()}).passthrough(),Hm=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:pe.nullish(),Events:zod.z.array(Km).nullish(),Gate:_.nullish()}).passthrough(),Dl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:qm.nullish(),ActiveGroup:Sl.nullish()}),nn=zod.z.object({ServerTimeUtc:u.nullish(),Group:Sl.nullish(),SecondsRemaining:w.nullish()}),bl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:sn.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(sn).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),on=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),zl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Br=zod.z.object({Chains:zod.z.record(zod.z.string(),Hm).nullish()}).passthrough(),We={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Lr=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(We.GetDefinitions,e,Br)}getActiveEvent(e){return this.send(We.GetActiveEvent,e,xl)}getUserState(e){return this.send(We.GetUserState,e,Dl)}getGroupState(e){return this.send(We.GetGroupState,e,nn)}joinOrCreateGroup(e){return this.send(We.JoinOrCreateGroup,e,nn)}spin(e){return this.send(We.Spin,e,bl)}claimObjectReward(e){return this.send(We.ClaimObjectReward,e,on)}claimGrandPrize(e){return this.send(We.ClaimGrandPrize,e,on)}leaveGroup(e){return this.send(We.LeaveGroup,e,zl)}};var $m={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},Zm={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Jm=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(),Ym=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Tl=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(),Jm).nullish(),Tracks:zod.z.record(zod.z.string(),Ym).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),Xm=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:Tl.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),ef=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),tf=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(),ef).nullish()}).passthrough(),rf=zod.z.object({Slots:zod.z.record(zod.z.string(),Xm).nullish(),OfferHistory:zod.z.record(zod.z.string(),tf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var sf=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),nf=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(sf).nullish(),Schedule:pe.nullish(),Gate:_.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),of=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:Y.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),af=zod.z.object({AdPlacementID:zod.z.string().nullish(),ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),CooldownSecondsBetweenViews:zod.z.number().nullish(),RequireServerVerification:zod.z.boolean().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),lf=zod.z.object({Purchase:of.nullish(),RewardedVideo:af.nullish()}).passthrough(),uf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),cf=zod.z.object({Milestones:X.nullish()}).passthrough(),pf=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),df=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(),hf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(uf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),mf=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:lf.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(pf).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:hf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ge.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),vl=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),GraphMode:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(mf).nullish(),Tracks:zod.z.array(df).nullish(),Milestones:zod.z.record(zod.z.string(),De).nullish(),Presets:cf.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:ht.nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ff=zod.z.object({Milestones:zod.z.record(zod.z.string(),at).nullish()}).passthrough(),an=zod.z.object({Slots:zod.z.record(zod.z.string(),nf).nullish(),Offers:zod.z.record(zod.z.string(),vl).nullish(),Presets:ff.nullish()}).passthrough(),Pl=zod.z.object({DealOfferDefinitions:an.nullish()}),Il=zod.z.object({DealOffers:rf.nullish()}),gf=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(),Rf=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:vl.nullish(),ActivationState:Tl.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:Et.nullish(),Milestone:gf.nullish()}).passthrough(),kl=zod.z.object({Slots:zod.z.array(Rf).nullish()}),Ml=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:b.nullish()}),wl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Ol=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Al=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),Ul=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:b.nullish()}),Ye={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var qr=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(Ye.GetDefinition,e,Pl)}getUserState(e){return this.send(Ye.GetUserState,e,Il)}getActiveDeals(e){return this.send(Ye.GetActiveDeals,e,kl)}dismissDeal(e){return this.send(Ye.DismissDeal,e,wl)}executeNode(e){return this.send(Ye.ExecuteNode,e,Ml)}recordShow(e){return this.send(Ye.RecordShow,e,Ol)}claimMilestone(e){return this.send(Ye.ClaimMilestone,e,Al)}claimMilestonesBatch(e){return this.send(Ye.ClaimMilestonesBatch,e,Ul)}};var yf=zod.z.object({}).passthrough().transform(o=>o),Cf=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),ln=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),De).nullish(),SpendRewards:zod.z.array(Cf).nullish()}).passthrough(),Bl=zod.z.object({ReferralDefinitions:ln.nullish()}),Ll=zod.z.object({Referral:yf.nullish()}),ql=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}),un=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}),El=$e(un),gt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Er=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(gt.GetDefinitions,e,Bl)}getUserState(e){return this.send(gt.GetUserState,e,Ll)}activateReferralCode(e){return this.send(gt.ActivateReferralCode,e,ql)}claimInviteReward(e){return this.send(gt.ClaimInviteReward,e,un)}claimInviteRewardsBatch(e){return this.send(gt.ClaimInviteRewardsBatch,e,El)}};var Sf={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},xf={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Gl=zod.z.object({UserID:zod.z.string(),PublicData:be.nullish()}),Df=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:be.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:b.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Gr=zod.z.object({Friends:zod.z.array(Gl).nullish()}),bf=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),Ft=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:Gl.nullish(),Counters:bf.nullish()}),Nl=zod.z.object({Events:zod.z.array(Df).nullish()}),Xe={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Nr=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,Gr)}getIncomingRequests(e){return this.send(Xe.GetIncomingRequests,e,Gr)}getRecommendedFriends(e){return this.send(Xe.GetRecommendedFriends,e,Gr)}sendFriendRequest(e){return this.send(Xe.SendFriendRequest,e,Ft)}acceptFriendRequest(e){return this.send(Xe.AcceptFriendRequest,e,Ft)}declineFriendRequest(e){return this.send(Xe.DeclineFriendRequest,e,Ft)}removeFriend(e){return this.send(Xe.RemoveFriend,e,Ft)}getTimeline(e){return this.send(Xe.GetTimeline,e,Nl)}};var zf={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Ut=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Tf=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:Y.nullish(),Effect:Ut.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(),vf=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:pe.nullish(),Effects:zod.z.array(Ut).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pf=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Ut).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),If=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:pe.nullish(),Phases:zod.z.array(Pf).nullish(),Gate:_.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),kf=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(Ue).nullish(),Effects:zod.z.array(Ut).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:_.nullish()}).passthrough(),Mf=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),wf=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Mf).nullish()}).passthrough(),jr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Tf).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),vf).nullish(),BoostChains:zod.z.record(zod.z.string(),If).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),kf).nullish(),Settings:wf.nullish()}).passthrough(),jl=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Ut.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 Fl=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),jl).nullish()}),Vl=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:jl.nullish(),Resources:b.nullish()}),Of={Scheduled:"Scheduled",Chain:"Chain"},Af=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(Ut).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),_l=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(Af).nullish()}),Rt={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Fr=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(Rt.GetDefinitions,e,jr)}getActive(e){return this.send(Rt.GetActive,e,Fl)}getActiveWindows(e){return this.send(Rt.GetActiveWindows,e,_l)}activate(e){return this.send(Rt.Activate,e,Vl)}cleanupExpired(e){return this.send(Rt.CleanupExpired,e,ze)}};var Vr=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(_e.GetUserCustomDataDefinitions,e,qi)}getMyUserCustomData(e){return this.send(_e.GetMyUserCustomData,e,ro)}getPublicUserCustomDataOf(e){return this.send(_e.GetPublicUserCustomDataOf,e,Cs)}setPrivateData(e){return this.send(_e.SetPrivateData,e,Ss)}setPublicData(e){return this.send(_e.SetPublicData,e,Ss)}deleteKey(e){return this.send(_e.DeleteKey,e,ze)}batchSet(e){return this.send(_e.BatchSet,e,so)}batchDelete(e){return this.send(_e.BatchDelete,e,no)}batchGetPublicUserCustomDataOf(e){return this.send(_e.BatchGetPublicUserCustomDataOf,e,oo)}};var Uf={Static:"Static",Runtime:"Runtime"},Bf={Public:"Public",Private:"Private"},Lf=zod.z.enum(["Client","Server","System"]),qf=zod.z.enum(["String","Int","Bool","Json"]),Ef=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Lf.nullish(),ExpiresAt:u.nullish()}).passthrough(),Wl=zod.z.record(zod.z.string(),Ef),cn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Wl.nullish(),Runtime:Wl.nullish(),NotModified:zod.z.boolean().nullish()}),Gf=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:qf.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),_r=zod.z.object({Keys:zod.z.record(zod.z.string(),Gf).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(),Vt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Wr=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(Vt.GetTitleCustomDataDefinitions,e,_r)}getPublicTitleData(e){return this.send(Vt.GetPublicTitleData,e,cn)}getPublicTitleDataKeys(e){return this.send(Vt.GetPublicTitleDataKeys,e,cn)}};var Nf={Fast:"Fast",Sequential:"Sequential"},jf={Instant:"Instant",Timed:"Timed"},Ff={Hit:"Hit",Blocked:"Blocked"},Vf=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),_f=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:L.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 Ql=zod.z.object({}).passthrough().transform(o=>o),Kl=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ie=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),Wf=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Qf=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(),Kf=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:fe.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(),Hf=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:fe.nullish()}).passthrough(),Hl=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:L.nullish()}).passthrough(),$f=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(),Zf=zod.z.object({Tiles:zod.z.record(zod.z.string(),$f).nullish()}).passthrough(),Jf=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Ie.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Yf=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(Jf).nullish(),GuaranteedBonus:Ie.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),Xf=zod.z.object({Variants:zod.z.array(Yf).nullish()}).passthrough(),eg=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Ie.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),tg=zod.z.object({Outcomes:zod.z.array(eg).nullish()}).passthrough(),$l=zod.z.object({PerAdMultiplierRange:Kl.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),ig=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Ie.nullish()}).passthrough(),rg=zod.z.object({Tiers:zod.z.array(ig).nullish(),BelowFirstTierReward:Ie.nullish()}).passthrough(),sg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ie.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:Y.nullish(),Multipliers:$l.nullish(),Gradation:rg.nullish()}).passthrough(),ng=zod.z.object({Choices:zod.z.array(sg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),og=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Ie.nullish(),Tag:zod.z.string().nullish()}).passthrough(),ag=zod.z.object({OnPassStart:Ie.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Ie).nullish(),OnAttack:zod.z.record(zod.z.string(),Ie).nullish(),OnRaid:zod.z.record(zod.z.string(),Ie).nullish(),OnBuild:Ie.nullish(),OnStageComplete:Ie.nullish(),OnAttackBonusDrops:zod.z.array(og).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),tg).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),ng).nullish()}).passthrough(),Zl=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Hl).nullish(),HeistGridBonusConfig:Xf.nullish(),StageOperations:ag.nullish(),TileLandingMultiplier:Kl.nullish(),EconomyOverride:Hf.nullish()}).passthrough(),lg=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(Hl).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Zl.nullish()}).passthrough(),Qr=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(),Zf).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Zl).nullish(),StagesByLevel:zod.z.record(zod.z.string(),lg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:Kf.nullish(),Dice:Wf.nullish(),Bots:Qf.nullish()}).passthrough(),ug=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(),De).nullish(),GrandPrize:L.nullish()}).passthrough(),Kr=zod.z.object({Board:Qr.nullish(),CommunityChest:ug.nullish()}).passthrough(),cg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:be.nullish(),TargetBuildingStates:zod.z.array(Vf).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),pg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Ie.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:Y.nullish(),Multipliers:$l.nullish()}).passthrough(),dg=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(pg).nullish()}).passthrough(),hg=zod.z.object({GroupID:zod.z.string().nullish(),Delta:w.nullish(),NewProgress:w.nullish(),MaxProgress:w.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Jl=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:w.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:cg.nullish(),SpecialModeOffer:dg.nullish(),CommunityChestContribution:hg.nullish()}).passthrough(),Yl=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:b.nullish(),DualResult:dt.nullish()}).passthrough(),pn=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:L.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(_f).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:dt.nullish()}).passthrough(),Xl=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),eu=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:b.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),tu=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),iu=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),mg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},ru=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),fg={Active:"Active",Left:"Left",Replaced:"Replaced"},gg=zod.z.enum(["Active","Left","Replaced"]),Rg=zod.z.object({CurrentProgress:w.nullish(),MaxProgress:w.nullish()}).passthrough(),yg=zod.z.object({UserID:zod.z.string().nullish(),PublicData:be.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:w.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:gg.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),su=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(yg).nullish(),SharedProgress:Rg.nullish(),Status:ru.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Cg=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:ru.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),Sg=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Cg).nullish()}).passthrough(),nu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Sg.nullish(),ActiveGroup:su.nullish(),SecondsRemaining:w.nullish()}),ou=zod.z.object({ServerTimeUtc:u.nullish(),Group:su.nullish(),SecondsRemaining:w.nullish()}),dn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),au=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Se={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 xg=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(),Dg=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:pe.nullish(),Gate:_.nullish(),Variants:zod.z.array(xg).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(),lu=zod.z.object({Experiments:zod.z.record(zod.z.string(),Dg).nullish()}).passthrough();var bg={Mesh:"Mesh",Host:"Host"},hn=zod.z.enum(["Mesh","Host"]),zg={ServerRelay:"ServerRelay",P2P:"P2P"},mn=zod.z.enum(["ServerRelay","P2P"]),Tg={Public:"Public",Private:"Private"},vg=zod.z.enum(["Public","Private"]),Pg={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Ig=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),uu=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),kg=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),cu=zod.z.object({SystemState:kg.nullish(),DefaultTopology:hn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:mn.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(uu).nullish()}).passthrough(),Mg=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(),wg=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:hn.nullish(),ChatMode:mn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),Og=zod.z.object({Seq:zod.z.number().nullish(),Type:Ig.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(),Hr=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:hn.nullish(),ChatMode:mn.nullish(),Visibility:vg.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Mg).nullish(),IceServers:zod.z.array(uu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),fn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),pu=zod.z.object({Rooms:zod.z.array(wg).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),du=zod.z.object({Envelopes:zod.z.array(Og).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),$r=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ne={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var gn=zod.z.object({TitleCustomData:_r.nullish(),Character:Wi.nullish(),Item:nr.nullish(),Currency:_i.nullish(),Store:ar.nullish(),Lootbox:Ws.nullish(),Quest:Yt.nullish(),TimedEvent:Rr.nullish(),Leaderboard:br.nullish(),Season:Tr.nullish(),Reward:Qs.nullish(),Collection:Ar.nullish(),Craft:en.nullish(),DealOffer:an.nullish(),Premium:Xs.nullish(),TimedBoost:jr.nullish(),CoopEvent:Br.nullish(),GameLoop:Kr.nullish(),Match:Bs.nullish(),Experiment:lu.nullish(),Blockchain:Is.nullish(),Marketplace:Gs.nullish(),Multiplayer:cu.nullish(),UserCustomData:qi.nullish(),Referral:ln.nullish(),Localization:pa.nullish()}).passthrough();var yt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Zr=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(yt.GetTitlePublicConfiguration,e,gn)}getTitlePublicConfigurationExcept(e){return this.send(yt.GetTitlePublicConfigurationExcept,e,gn)}getCurrencyDefinitions(e){return this.send(yt.GetCurrencyDefinitions,e,_i)}getItemDefinitions(e){return this.send(yt.GetItemDefinitions,e,nr)}getServerTime(e){return this.send(yt.GetServerTime,e,ze)}};var Jr=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(Se.GetGameLoops,e,Kr)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,Qr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,Qr,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,Ql)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,Jl)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,Yl)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,pn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,pn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,Xl)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,eu)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,tu)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,iu)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,nu)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,ou)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,dn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,dn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,au)}};var _t=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(_t),zod.z.record(zod.z.string(),_t)]));var Ug={Live:"Live",Latest:"Latest",Specific:"Specific"},Bg={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Lg=zod.z.enum(["Debug","Info","Warning","Error"]),qg={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"},Eg=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Gg=zod.z.object({Level:Lg,Message:zod.z.string().nullish(),Data:_t.nullish()}),Ng=zod.z.object({Error:Eg,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),hu=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:_t.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(Gg).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Ng.nullish()}),Rn={Execute:"Execute"};var Yr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",Rn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,hu,{ticket:e.ClientSessionTicket})}};var Xr=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(we.GetDefinitions,e,Uo)}getUserState(e){return this.send(we.GetUserState,e,Bo)}depositToken(e){return this.send(we.DepositToken,e,Lo)}depositNFT(e){return this.send(we.DepositNFT,e,qo)}requestTokenWithdrawal(e){return this.send(we.RequestTokenWithdrawal,e,Eo)}requestNFTWithdrawal(e){return this.send(we.RequestNFTWithdrawal,e,Go)}getTransactionHistory(e){return this.send(we.GetTransactionHistory,e,No)}retryWithdrawal(e){return this.send(we.RetryWithdrawal,e,jo)}confirmWithdrawal(e){return this.send(we.ConfirmWithdrawal,e,Fo)}donateToDeveloper(e){return this.send(we.DonateToDeveloper,e,ws)}donateToUsersPool(e){return this.send(we.DonateToUsersPool,e,ws)}};var es=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(ae.GetDefinitions,e,ia)}getGroupedOffers(e){return this.send(ae.GetGroupedOffers,e,ra)}getOffersByItem(e){return this.send(ae.GetOffersByItem,e,Ns)}getOffer(e){return this.send(ae.GetOffer,e,sa)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Ns)}getMyState(e){return this.send(ae.GetMyState,e,oa)}getHistory(e){return this.send(ae.GetHistory,e,aa)}createListing(e){return this.send(ae.CreateListing,e,Nt)}cancelListing(e){return this.send(ae.CancelListing,e,qe)}buy(e){return this.send(ae.Buy,e,qe)}marketBuy(e){return this.send(ae.MarketBuy,e,qe)}marketSell(e){return this.send(ae.MarketSell,e,qe)}createAuction(e){return this.send(ae.CreateAuction,e,Nt)}placeBid(e){return this.send(ae.PlaceBid,e,na)}claimAuction(e){return this.send(ae.ClaimAuction,e,qe)}createBuyOrder(e){return this.send(ae.CreateBuyOrder,e,Nt)}cancelBuyOrder(e){return this.send(ae.CancelBuyOrder,e,qe)}fillBuyOrder(e){return this.send(ae.FillBuyOrder,e,qe)}createDirectTrade(e){return this.send(ae.CreateDirectTrade,e,Nt)}respondDirectTrade(e){return this.send(ae.RespondDirectTrade,e,qe)}cancelDirectTrade(e){return this.send(ae.CancelDirectTrade,e,qe)}claimBack(e){return this.send(ae.ClaimBack,e,qe)}};var ts=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(Ne.CreateRoom,e,Hr)}joinRoom(e){return this.send(Ne.JoinRoom,e,Hr)}leaveRoom(e){return this.send(Ne.LeaveRoom,e,fn)}listRooms(e){return this.send(Ne.ListRooms,e,pu)}getRoom(e){return this.send(Ne.GetRoom,e,Hr)}closeRoom(e){return this.send(Ne.CloseRoom,e,fn)}poll(e){return this.send(Ne.Poll,e,du)}sendSignal(e){return this.send(Ne.SendSignal,e,$r)}sendChat(e){return this.send(Ne.SendChat,e,$r)}setMemberState(e){return this.send(Ne.SetMemberState,e,$r)}};var is=class{settings;emitter;platform;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;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=Dn(e),this.emitter=new Lt,this.platform=e.platform??new Dt,this.clientPlatform=e.clientPlatform??Tn(),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new ti({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new ni(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 oi(this.platform.storage,this.settings.titleID),this.api={authentication:new er(this),user:new ir(this),currency:new rr(this),item:new or(this),store:new lr(this),purchase:new ur(this),lootbox:new dr(this),reward:new hr(this),quest:new gr(this),tutorial:new mr(this),localization:new fr(this),timedEvent:new yr(this),leaderboard:new zr(this),season:new vr(this),premium:new Ir(this),character:new kr(this),match:new Mr(this),craft:new Or(this),collection:new Ur(this),coopEvent:new Lr(this),dealOffer:new qr(this),referral:new Er(this),social:new Nr(this),timedBoost:new Fr(this),userCustomData:new Vr(this),titleCustomData:new Wr(this),title:new Zr(this),gameLoop:new Jr(this),cloudCode:new Yr(this),blockchain:new Xr(this),marketplace:new es(this),multiplayer:new ts(this)},this.userService=new ci(this),this.auth=new ai(this),this.currency=new di(this),this.item=new hi(this),this.store=new mi(this),this.purchase=new fi(this),this.checkout=new gi(this),this.lootbox=new Ri(this),this.reward=new yi(this),this.quest=new Di(this),this.tutorial=new Ci(this),this.localization=new xi(this),this.timedEvent=new bi(this),this.leaderboard=new zi(this),this.season=new Ti(this),this.premium=new vi(this),this.character=new Pi(this),this.match=new Ii(this),this.craft=new ki(this),this.collection=new Mi(this),this.coopEvent=new wi(this),this.dealOffer=new Oi(this),this.referral=new Ai(this),this.social=new Ui(this),this.timedBoost=new Bi(this),this.userCustomData=new Ei(this),this.titleCustomData=new Gi(this),this.title=new Ni(this),this.gameLoop=new ji(this),this.cloudCode=new Fi(this),this.blockchain=new Hi(this),this.marketplace=new Yi(this),this.multiplayer=new Xi(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:P()}}};var rs=class{ctx;constructor(e){this.ctx=new is(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 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 jg(o){return new rs(o)}var mu="idos_sso",fu="state",yn="idos:sso:state",Fg="https://idosgames.com/sso/";function Vg(){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(mu);if(!t)return null;let i=e.get(fu)??"",r=Hg();return Zg(e),$g(),r&&i!==r?null:{code:t,state:i}}function _g(o){if(typeof window>"u")return;let e=o.returnTo??Wg(),t=Qg();Kg(t);let i=new URL(o.ssoUrl??Fg);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function Wg(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function Qg(){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 Kg(o){try{window.sessionStorage.setItem(yn,o);}catch{}}function Hg(){try{return window.sessionStorage.getItem(yn)}catch{return null}}function $g(){try{window.sessionStorage.removeItem(yn);}catch{}}function Zg(o){o.delete(mu),o.delete(fu);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}var Jg={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Cn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),Yg={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Xg=zod.z.enum(["Top","Bottom","Left","Right"]),eR=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Cn.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(),tR=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(),iR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),rR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:Xg.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),sR=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),nR=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),oR=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(),aR=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(),lR=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(),uR=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Cn.nullish()}).passthrough(),cR=zod.z.object({ProviderID:zod.z.string().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(),uR).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),eR).nullish(),Providers:zod.z.record(zod.z.string(),cR).nullish(),RewardedVideo:tR.nullish(),Interstitial:iR.nullish(),Banner:rR.nullish(),AppOpen:sR.nullish(),FrequencyCapping:nR.nullish(),PremiumAdReductions:zod.z.array(oR).nullish(),Consent:aR.nullish(),Verification:lR.nullish()}).passthrough();var pR=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),dR=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(),hR=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(),mR=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(),fR=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(),gR=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Cn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),RR=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:pR.nullish(),Placements:zod.z.record(zod.z.string(),dR).nullish(),Daily:hR.nullish(),Session:mR.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:fR.nullish(),PendingRequests:zod.z.record(zod.z.string(),gR).nullish(),FraudFlags:RR.nullish(),UpdatedAt:u.nullish()}).passthrough();var yR={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},CR=zod.z.enum(["Unread","Read","Deleted","Expired"]),SR={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},xR=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),DR={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},bR=zod.z.enum(["Active","Paused","Cancelled","Completed"]),zR=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(),TR=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(),zR).nullish(),Segments:zod.z.array(TR).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:xR.nullish(),RelatedEntityID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:be.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:L.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:CR.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:L.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:bR.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 gu="idos_device_id",ss=class{storage;constructor(e=new St){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(gu);return e||(e="noop-device",this.storage.setString(gu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
-
exports.AdType=
|
|
1
|
+
'use strict';var zod=require('zod'),sr=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var sr__default=/*#__PURE__*/_interopDefault(sr);var Et=class{listeners=new Map;on(e,t){let r=this.listeners.get(e);return r||(r=new Set,this.listeners.set(e,r)),r.add(t),()=>{this.off(e,t);}}once(e,t){let r=this.on(e,i=>{r(),t(i);});return r}off(e,t){let r=this.listeners.get(e);r&&(r.delete(t),r.size===0&&this.listeners.delete(e));}emit(e,t){let r=this.listeners.get(e);if(r)for(let i of [...r])i(t);}removeAllListeners(){this.listeners.clear();}};function bu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function Dn(){return zu()??bu()}function zu(){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,r)=>{try{o.setItem(t,r);}catch{try{o.removeItem(t);}catch{}}},remove:t=>{try{o.removeItem(t);}catch{}}}}catch{return null}}var bn="https://api.idosgames.com";function zn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??bn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??Dn(),locale:o.locale??Tu()}}function Tu(){try{return globalThis.navigator?.language??""}catch{return ""}}var xt=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{}}},Dt=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 bt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var Tn="idos_device_id",zt=class{storage;constructor(e=new xt){this.storage=e;}getPlatform(){return bt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=bt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=bt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(Tn);return e||(e=P(),this.storage.setString(Tn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=bt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=bt();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 Ve={Virtual:"Virtual",Crypto:"Crypto"},vt=zod.z.enum(["Virtual","Crypto"]),Kt={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},Ht=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]),Ze={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},$t=zod.z.enum(["Unknown","Web","Android","Ios"]),vu={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},Zt=zod.z.enum(["GooglePlay","AppleAppStore"]),Pu={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},Jt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),Iu={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Gt=zod.z.enum(["Cyclic","Scheduled","Chained"]),me={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function Pn(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return vn(e);let t=o.cordova?.platformId;return t?vn(t):o.navigator?.userAgent??""?Ze.Web:Ze.Unknown}function vn(o){let e=o.toLowerCase();return e==="android"?Ze.Android:e==="ios"?Ze.Ios:e==="web"?Ze.Web:Ze.Unknown}function In(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function ku(o){return o.ok}function Mu(o){return !o.ok}var M=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)}),q=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 as=zod.z.object({Type:Ht.nullish(),CurrencyID:zod.z.string().nullish(),Amount:M.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),wu=zod.z.object({Type:Jt.nullish(),EntityID:zod.z.string()}),Au=zod.z.object({Address:wu.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),fe=zod.z.object({Entries:zod.z.array(as).nullish(),EventTokens:zod.z.array(Au).nullish()}),kn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:fe.nullish()}),L=zod.z.object({Standard:fe.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(kn).nullish()}),Nt=zod.z.object({Standard:fe.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(kn).nullish()}),b=zod.z.object({Grant:L.nullish(),Consume:Nt.nullish()}),mt=zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),FromResult:b.nullish(),ToResult:b.nullish()});zod.z.object({FromUserID:zod.z.string().nullish(),ToUserID:zod.z.string().nullish(),Transferred:fe.nullish()});var Ou=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),Uu={Completed:"Completed",Started:"Started",StepReached:"StepReached"},Bu=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),W=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:Ou.nullish(),Tutorial:Bu.nullish(),Platforms:zod.z.array($t).nullish()}).passthrough();var ge=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 Lu=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),qu=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Eu=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 Gu=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 Le=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:ge.nullish()}).passthrough(),ce=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:qu.nullish(),Chain:Eu.nullish(),Cyclic:Gu.nullish(),ActivationTriggers:zod.z.array(Le).nullish(),Relative:Lu.nullish()}).passthrough();var Nu={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},ju=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]),Fu={Step:"Step",Linear:"Linear",Geometric:"Geometric"},Vu=zod.z.enum(["Step","Linear","Geometric"]),_u=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),xe=zod.z.object({Base:zod.z.number().nullish(),Shape:ju.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(_u).nullish(),Interpolation:Vu.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var Wu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),Qu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),ls=zod.z.object({Bundles:zod.z.array(Wu).nullish(),Multipliers:zod.z.array(Qu).nullish()}).passthrough();var Ku=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]),Yt=zod.z.object({Source:Ku.nullish(),SourceKey:zod.z.string().nullish(),Curve:xe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:fe.nullish(),ExcludeRewards:fe.nullish()}).passthrough(),be=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:L.nullish(),BonusRewards:L.nullish(),SeasonTierRewards:ls.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),ut=zod.z.object({Milestones:zod.z.record(zod.z.string(),be).nullish()}).passthrough();var Y=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Hu=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),ft=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:Hu.nullish()}).passthrough();var ie=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),Je=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(ie(o)),Resources:b.nullish()});var $u={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Mn=zod.z.enum(["Active","Completed","Claimed","Expired"]),Zu=zod.z.object({}).passthrough().transform(o=>o),Ju=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:M.nullish(),PointsCurrent:M.nullish(),ClaimedPointMilestoneIDs:zod.z.array(zod.z.string()).nullish()}),us=zod.z.object({QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),ObjectiveID:zod.z.string().nullish(),NewValue:M.nullish(),ObjectiveCompleted:zod.z.boolean().nullish(),Status:Mn}),wn=zod.z.object({State:Zu.nullish(),PointsTracks:zod.z.record(zod.z.string(),Ju).nullish()}),cs=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Mn.nullish(),Resources:b.nullish()}),ps=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:M.nullish(),Resources:b.nullish()}),An=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:b.nullish()}),On=zod.z.object({MetricID:zod.z.string(),Updates:zod.z.array(us).nullish()}),Un=zod.z.array(ie(cs)),Bn=zod.z.array(ie(ps)),Yu={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Xu=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]),ec={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},tc=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Ln=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:Xu.nullish(),MaxProgressPerCall:zod.z.number().nullish(),MetricID:zod.z.string().nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),AggregationMethod:zod.z.string().nullish()}).passthrough(),ds=zod.z.object({Milestones:Y.nullish(),Linking:Y.nullish(),Availability:Y.nullish(),Reward:Y.nullish(),Objectives:Y.nullish()}).passthrough(),rc=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(),qn=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:tc.nullish()}).passthrough(),En=zod.z.object({Schedule:ce.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:W.nullish(),Limits:ge.nullish()}).passthrough(),Gn=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),ic=zod.z.object({QuestID:zod.z.string().nullish(),Identity:rc.nullish(),Linking:qn.nullish(),Availability:En.nullish(),Objectives:zod.z.record(zod.z.string(),Ln).nullish(),Reward:Gn.nullish(),Presets:ds.nullish()}).passthrough(),sc=zod.z.object({CompletionID:zod.z.string().nullish(),GroupID:zod.z.string().nullish(),RequiredCompletedQuests:zod.z.number().nullish(),Gate:W.nullish(),Reward:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),nc=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:W.nullish(),Milestones:zod.z.record(zod.z.string(),be).nullish(),Presets:ds.nullish(),PointsToken:ft.nullish()}).passthrough(),oc=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),Linking:zod.z.record(zod.z.string(),qn).nullish(),Availability:zod.z.record(zod.z.string(),En).nullish(),Reward:zod.z.record(zod.z.string(),Gn).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Ln)).nullish()}).passthrough(),ac=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Milestones:zod.z.record(zod.z.string(),be).nullish(),Gate:W.nullish(),PointsToken:ft.nullish(),GroupCompletions:zod.z.record(zod.z.string(),sc).nullish(),Phases:zod.z.record(zod.z.string(),nc).nullish(),Presets:ds.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),er=zod.z.object({Cycles:zod.z.record(zod.z.string(),ac).nullish(),Quests:zod.z.record(zod.z.string(),ic).nullish(),Presets:oc.nullish()}).passthrough(),We={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var lc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},uc=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]),cc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},pc=zod.z.enum(["Never","OnRequest","Always"]),dc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},hc=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]),mc={GameLoop:"GameLoop"},fc={Raid:"Raid",Attack:"Attack"},gc=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(),Rc=zod.z.object({Mode:uc.nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),yc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Cc=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).nullish()}).passthrough(),Sc=zod.z.object({Module:zod.z.enum(["GameLoop"]).nullish(),Board:Cc.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),xc=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),hs=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:gc.nullish(),Completion:Rc.nullish(),Effects:yc.nullish(),Script:Sc.nullish(),Policy:xc.nullish()}).passthrough(),Dc=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(),Nn=zod.z.object({Schedule:ce.nullish(),Gate:W.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Le.nullish()}).passthrough(),jn=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:pc.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Fn=zod.z.object({Grant:L.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),bc=zod.z.object({Availability:Y.nullish(),Policy:Y.nullish(),Reward:Y.nullish(),Steps:Y.nullish()}).passthrough(),zc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:Dc.nullish(),Availability:Nn.nullish(),Policy:jn.nullish(),Steps:zod.z.record(zod.z.string(),hs).nullish(),Reward:Fn.nullish(),Presets:bc.nullish()}).passthrough(),Tc=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(),vc=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Tc.nullish()}).passthrough(),Pc=zod.z.object({Availability:zod.z.record(zod.z.string(),Nn).nullish(),Policy:zod.z.record(zod.z.string(),jn).nullish(),Reward:zod.z.record(zod.z.string(),Fn).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),hs)).nullish()}).passthrough(),Vn=zod.z.object({Flows:zod.z.record(zod.z.string(),zc).nullish(),Settings:vc.nullish(),Presets:Pc.nullish()}).passthrough(),Ic=zod.z.object({}).passthrough().transform(o=>o),_n=zod.z.object({FlowID:zod.z.string(),Status:hc,CurrentStepID:zod.z.string().nullish(),CurrentStep:hs.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(),Wn=zod.z.object({State:Ic.nullish(),Flows:zod.z.array(_n).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),ct=zod.z.object({Flow:_n.nullish()}).passthrough(),Qn=zod.z.object({FlowID:zod.z.string().nullish(),Granted:b.nullish()}).passthrough(),Kn=zod.z.array(ie(ct)),Hn=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 tr=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(),r=this.last.get(e);return r!==void 0&&t-r<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var rr=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function $n(o){return o===429||o>=500&&o<=599}function ms(o,e=Math.random){let t=Math.min(500*Math.pow(2,o-1),4e3),r=t*.2*(e()*2-1);return Math.max(50,t+r)}function fs(o){return new Promise(e=>setTimeout(e,o))}var kc=12e3,Mc=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(us).nullish(),TutorialProgress:zod.z.array(Hn).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),ir=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new rr;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 tr(e.throttleMs),this.clientPlatform=e.clientPlatform??Ze.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,r,i={}){let s=i.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),D=i.ticket??null,U=i.silent??!1,E=i.timeoutMs??kc,de=i.autoRetry??!0,Re=!1,Ie=0;for(;;){let He;try{He=await this.doFetch(a,p,D,E);}catch{if(de&&Ie<3){Ie++,await fs(ms(Ie));continue}return this.connectionFailure("Internet Connection Error",U)}let $e=He.status;if($e>=200&&$e<300)return await this.parseSuccess(He,r,U,e);if($e===401){if(!Re&&this.sessionRefreshHandler){Re=!0;let rt=null;try{rt=await this.sessionRefreshHandler();}catch{rt=null;}if(rt){D=rt;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if($n($e)){if(de&&Ie<3){Ie++,await fs(ms(Ie));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${$e})`,U)}return await this.handleWebError(He,$e,U)}}finally{this.inflight.remove(s),this.lowerBusy();}}async doFetch(e,t,r,i){let s=new AbortController,a=setTimeout(()=>{s.abort();},i);try{let p={"Content-Type":"application/json","X-IG-Platform":this.clientPlatform};return r&&(p.Authorization=`Bearer ${r}`),await this.fetchImpl(e,{method:"POST",body:t,headers:p,signal:s.signal})}finally{clearTimeout(a);}}async parseSuccess(e,t,r,i){let s;try{s=await e.text();}catch{return this.globalError("Failed to read response body",r)}let a;try{a=JSON.parse(s);}catch{return this.globalError("JSON Parse Error",r)}let p=Mc.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",r);if(!p.data.Success){let Re=p.data.Error??"Server returned Success=false";return r||this.emitter.emit("error:global",Re),n("server",Re)}let D=p.data.QuestProgress;D&&D.length>0&&this.emitter.emit("quest:systemProgress",D);let U=p.data.TutorialProgress;U&&U.length>0&&this.emitter.emit("tutorial:systemProgress",U);let E=p.data.StateVersions;E&&Object.keys(E).length>0&&this.emitter.emit("user:stateVersions",{epoch:p.data.StateEpoch??null,versions:E});let de=t.safeParse(p.data.Data);if(!de.success){let Re=`Validation error (${i}): ${de.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",Re),r||this.emitter.emit("error:global",Re),n("validation",Re)}return In(de.data)}async handleWebError(e,t,r){let i=`HTTP ${t}`;try{let s=await e.text();if(s)try{let p=JSON.parse(s).Error;i=typeof p=="string"&&p.length>0?`HTTP ${t}: ${p}`:`HTTP ${t}: ${s}`;}catch{i=`HTTP ${t}: ${s}`;}}catch{}return r||this.emitter.emit("error:global",i),n("server",i)}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 It(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function jt(o){return `${It(o)}T00:00:00.000Z`}function Jn(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Yn(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function Xn(o,e,t,r){let i={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return i;o.InventoryV2??={};let s=o.InventoryV2,a=r.toISOString(),p=new Map,D=new Map,U=new Map,E=new Map,de=new Map,Re=new Map,Ie=new Map,He=new Map,$e=e.Grant?.PremiumTiers??[],rt=$e.length;for(let ne=0;;ne++){let he,$;if(ne===0)he=e.Grant?.Standard?.Entries,$=false;else if(ne-1<rt)he=$e[ne-1]?.Resources?.Entries,$=false;else if(ne===1+rt)he=e.Consume?.Standard?.Entries,$=true;else break;if(he)for(let _ of he){if(_.Type==null)continue;let K=Math.max(0,_.Amount??0);if(!(K<=0))switch(_.Type){case "VirtualCurrency":{if(!_.CurrencyID)continue;let H=$?D:p;H.set(_.CurrencyID,(H.get(_.CurrencyID)??0)+K);break}case "CryptoCurrency":{if(!_.CurrencyID)continue;let H=$?E:U;H.set(_.CurrencyID,(H.get(_.CurrencyID)??new sr__default.default(0)).plus(K));break}case "Item":{if(!_.ItemID)continue;let H=Ac(t,_.CatalogID,_.ItemID),X=(H?H.IsStackable??true:true)?$?Re:de:$?He:Ie;X.set(_.ItemID,(X.get(_.ItemID)??0)+K);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(i.vcChanged=p.size>0||D.size>0,i.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...D.keys()])){let he=p.get(ne)??0,$=D.get(ne)??0,_=he-$,K=s.VirtualCurrencies[ne];K?(K.Amount+=_,K.UpdatedAt=a,K.Daily&&It(K.Daily.PeriodStartUtc)===It(r)?(K.Daily.Earned+=he,K.Daily.Spent+=$):K.Daily={PeriodStartUtc:jt(r),Earned:he,Spent:$}):s.VirtualCurrencies[ne]={Amount:_,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:jt(r),Earned:he,Spent:$}};}}if(i.ccChanged=U.size>0||E.size>0,i.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...U.keys(),...E.keys()])){let he=U.get(ne)??new sr__default.default(0),$=E.get(ne)??new sr__default.default(0),_=he.minus($),K=s.CryptoCurrencies[ne];K?(K.Amount=new sr__default.default(K.Amount).plus(_).toString(),K.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:_.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(i.itemsChanged=de.size>0||Re.size>0||Ie.size>0||He.size>0,i.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,he=new Set([...de.keys(),...Re.keys(),...Ie.keys(),...He.keys()]);for(let $ of he){let _=(de.get($)??0)-(Re.get($)??0),K=(Ie.get($)??0)-(He.get($)??0),H=_+K,Be=s.Items[$];Be?(_!==0&&(Be.StackableAmount+=_),K!==0&&(Be.UnstackableAmount+=K),H!==0&&(Be.TotalAmount+=H)):s.Items[$]={StackableAmount:Math.max(0,_),UnstackableAmount:Math.max(0,K),TotalAmount:Math.max(0,H)};}for(let[$,_]of He){if(_<=0)continue;let K=Object.values(ne).filter(H=>H.ItemID===$&&H.EquippedSlot==null&&(H.ExpiresAt==null||new Date(H.ExpiresAt)>r)).sort(wc).slice(0,_).map(H=>H.ItemInstanceID);for(let H of K)delete ne[H];}for(let[$,_]of Ie){let K=Oc(t,$);for(let H=0;H<_;H++){let Be=P();ne[Be]={ItemInstanceID:Be,ItemID:$,CatalogID:K,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Du=o.EventToken;for(let ne=0;;ne++){let he,$;if(ne===0)he=e.Grant?.Standard?.EventTokens,$=false;else if(ne-1<rt)he=$e[ne-1]?.Resources?.EventTokens,$=false;else if(ne===1+rt)he=e.Consume?.Standard?.EventTokens,$=true;else break;if(!(!he||he.length===0))for(let _ of he){let K=_.Address;if(!K||K.Type==null)continue;let H=_.Amount??0;if(H<=0)continue;let Be=Uc(Du,K.Type);if(!Be)continue;let X=Be[K.EntityID];X||(X={},Be[K.EntityID]=X),X.Balance??={Current:0,TotalEarned:0,TotalSpent:0},X.Daily??={Date:jt(r),TotalEarned:0},X.Meta??={};let qt=_.Source&&_.Source.length>0?_.Source:"CustomAction";$?(X.Balance.Current-=H,X.Balance.TotalSpent+=H):(X.Balance.Current+=H,X.Balance.TotalEarned+=H,It(X.Daily.Date)!==It(r)&&(X.Daily={Date:jt(r),TotalEarned:0}),X.Daily.TotalEarned+=H,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[qt]=(X.Daily.EarnedBySource[qt]??0)+H,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[qt]=(X.Daily.TriggersBySource[qt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[qt]=a,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=a),X.Meta.LastEarnedAtUtc=a),i.tokensChanged=true;}}return i}function wc(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 Ac(o,e,t){let r=o?.Catalogs;if(r){if(e){let i=r[e]?.Items?.[t];if(i)return i}for(let i of Object.values(r)){let s=i.Items?.[t];if(s)return s}}}function Oc(o,e){let t=o?.Catalogs;if(t){for(let[r,i]of Object.entries(t))if(i.Items&&e in i.Items)return r}}function Uc(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 nr=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 r of t)this.currentState[r]=e[r];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,r=new Date){if(!this.currentState)return;let i=Xn(this.currentState,e,t,r);i.vcChanged&&this.emitter.emit("user:virtualCurrencyUpdated",void 0),(i.vcChanged||i.ccChanged||i.itemsChanged)&&this.emitter.emit("user:inventoryUpdated",void 0),i.tokensChanged&&this.emitter.emit("user:eventTokenUpdated",void 0),(i.vcChanged||i.ccChanged||i.itemsChanged||i.tokensChanged)&&this.emitter.emit("user:anyUpdated",void 0);}patchCryptoCurrencyDelta(e,t,r){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let i=this.currentState.InventoryV2.CryptoCurrencies,s=t instanceof sr__default.default?t:new sr__default.default(t),a=r??new Date().toISOString(),p=i[e];p?(p.Amount=new sr__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):i[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,r){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let i=this.currentState.Store.Purchases,s=i[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},i[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=r,r>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=Jn(r)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,r){if(!e||r<=0)return;this.currentState??={};let i=this.currentState.Lootbox??={};if(i.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(i.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,r){if(!e)return;this.currentState??={},this.currentState.Quest??={};let i=this.currentState.Quest;if(t){i.Cycles??={};let s=i.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:r};a.Status=r,r==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {i.PermanentQuests??={};let s=i.PermanentQuests[e]??={QuestID:e,Status:r};s.Status=r,r==="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 r=this.getQuestPointsProgress(e);r&&(r.Milestone??={},this.markMilestoneClaimed(r.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 r of Object.values(e)){if(!r.CycleID)continue;let i=r.InstanceKey?`${r.CycleID}:${r.InstanceKey}`:r.CycleID,s=t[i]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=r.PointsCurrent??0,s.Balance.TotalEarned=r.PointsTotalEarned??0,s.Milestone??={};for(let a of r.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 r=this.currentState.Quest.Cycles[e];r&&(r.ClaimedGroupCompletionIDs??=[],r.ClaimedGroupCompletionIDs.includes(t)||r.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 r=t.Flows[e.FlowID]??={FlowID:e.FlowID};r.Status=e.Status,r.CurrentStepID=e.CurrentStepID??null,r.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(r.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 r of e){if(!r.FlowID||!r.StepID)continue;let i=t.Flows[r.FlowID]??={FlowID:r.FlowID,Status:"InProgress"};i.Steps??={};let s=i.Steps[r.StepID]??={StepID:r.StepID};s.Progress=r.Progress,r.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),i.CurrentStepID===r.StepID&&(i.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 r of e){if(!r.QuestID)continue;let i;if(!r.CycleID)t.PermanentQuests??={},i=t.PermanentQuests[r.QuestID]??={QuestID:r.QuestID,Status:r.Status};else {t.Cycles??={};let s=t.Cycles[r.CycleID];if(!s)continue;s.Quests??={},i=s.Quests[r.QuestID]??={QuestID:r.QuestID,Status:r.Status};}if(i.Status=r.Status,r.ObjectiveID){i.Objectives??={};let s=i.Objectives[r.ObjectiveID]??={ObjectiveID:r.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=r.NewValue??0,r.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}r.Status==="Completed"&&(i.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[r,i]of Object.entries(t))if(gs(r,e)&&i)return i;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,r){if(!(!t||!r)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[i,s]of Object.entries(this.currentState.EventToken.TimedEvent))!gs(i,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),r);this.patchActiveEventMilestoneClaimed(e,t,r),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,r){let i=this.activeEventsCache?.ActiveEvents;if(i)for(let s of i)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),r));}markMilestoneClaimed(e,t){e.Claims??={};let r=e.Claims[t]??={};r.ClaimedAt??=new Date().toISOString(),r.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let r=this.ensureLeaderboardProgress(e);r.CurrentScore=t.CurrentScore??0,r.LastKnownRank=t.LastKnownRank??0,r.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,r.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,r.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,r,i){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<i&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+r,s.ScoreCycleVersion=i,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 r=this.ensureLeaderboardProgress(e);r.ClaimedMilestoneIDs??=[],r.ClaimedMilestoneIDs.includes(t)||r.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,r=t[e];return r||(r={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=r),r}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 r=this.ensureSeasonState(e);r.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let r=this.ensureSeasonState(e);r.ClaimedTierRewards??=[],r.ClaimedTierRewards.includes(t)||r.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,r=t[e];return r||(r={SeasonChainID:e},t[e]=r),r}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 r=this.currentState.Character.Characters,i=r[e];i||(i={CharacterID:e},r[e]=i),t(i),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,r){if(!e||!t)return;let i=this.currentState?.Character?.Characters?.[e];i&&(i.Equipment??={},r===null?delete i.Equipment[t]:i.Equipment[t]=r,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,r=false;for(let[i,s]of Object.entries(e.ChangedInstances??{}))t[i]=s,r=true;for(let i of e.RemovedInstanceIDs??[])i in t&&(delete t[i],r=true);r&&(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,r){this.currentState??={};let i=this.currentState.CoopEvent??={MyObjectIndex:-1};i.ActiveGroupID=e,i.ActiveCoopEventID=t,i.MyObjectIndex=r,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.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);}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(r=>r!==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(r=>r!==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(r=>r!==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 r=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let i of Object.keys(r)){let s=r[i];s&&s.BoostID===e.BoostID&&i!==e.InstanceID&&delete r[i];}r[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,r,i,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:r,UpdatedAt:new Date().toISOString(),Version:i,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 r=this.currentState.CustomData;if(e==="Private")r.Private&&delete r.Private[t];else if(e==="Public")r.Public&&delete r.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 r=this.ensureBoard();r.BuildingStates??=[];let i=r.BuildingStates.find(s=>s.SlotIndex===e);i||(i={SlotIndex:e},r.BuildingStates.push(i)),t(i),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let i=this.ensureBoard().Pending;i&&(e&&(i.RaidLayout=e),t>=0&&(i.OpenedIndices??=[],i.OpenedIndices.includes(t)||i.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let r=this.ensureBoard().Pending;!r||r.Type.toUpperCase()!=="SPECIAL"||(r.Special??={},e(r.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 or=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 ar=class{user;config;constructor(e){this.user=new nr(e),this.config=new or;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var lr=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 Bc(e)?e:me.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 Bc(o){return o!==null&&Object.values(me).includes(o)}var Lc=8,qc=100,Ec=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,eo=["GameLoop"],ur=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=me.None;sessionEmail="";sessionPassword="";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()}}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(me.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 r=await this.ctx.api.authentication.loginWithTelegram(t);return r.ok?(this.applyAuthContext(r.data),this.fetchAndApplyClientState(me.Telegram)):r}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.Email=e,r.Password=t;let i=await this.ctx.api.authentication.loginWithEmail(r);if(!i.ok)return i;this.applyAuthContext(i.data);let s=await this.fetchAndApplyClientState(me.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.Email=e,r.Password=t,r.DeviceID=this.ctx.platform.getDeviceID(),r.Device=this.ctx.platform.getDeviceModel(),r.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.registerWithEmail(r);if(!i.ok)return i;this.applyAuthContext(i.data);let s=await this.fetchAndApplyClientState(me.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let r=await this.ctx.api.authentication.loginWithGoogle(t);return r.ok?(this.applyAuthContext(r.data),this.fetchAndApplyClientState(me.Google)):r}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.WalletAddress=e,r.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(r)}async loginWithWallet(e,t,r){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.WalletAddress=e,i.NetworkID=t,i.WalletSignature=r,i.Platform=this.ctx.platform.getPlatform(),i.Device=this.ctx.platform.getDeviceModel(),i.DeviceID=this.ctx.platform.getDeviceID();let s=await this.ctx.api.authentication.loginWithWallet(i);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(me.Wallet)):s}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.loginWithPlatformToken(t);return r.ok?(this.applyAuthContext(r.data),this.fetchAndApplyClientState(me.iDosGames)):r}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 r=await this.ctx.api.authentication.loginWithSsoCode(t);return r.ok?(this.applyAuthContext(r.data),this.fetchAndApplyClientState(me.iDosGames)):r}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,r){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();return i.Email=e,i.ResetToken=t,i.Password=r,this.ctx.api.authentication.resetPassword(i)}autoLogin(){return this.replay(this.ctx.authStore.lastAuthType,this.ctx.authStore.savedEmail,this.ctx.authStore.savedPassword)}replay(e,t,r){switch(e){case me.Email:return this.loginWithEmail(t,r);case me.Device:case me.None:return this.loginWithDeviceID();case me.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!==me.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===me.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&&Ec.test(e)}static isValidPasswordLength(e){return e.length>=Lc&&e.length<=qc}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=me.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(eo,eo);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 Gc="idos:cfg",kt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${to(t)}`:e&&e.length>0?`f:${to(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let r=JSON.parse(t);return !r||typeof r!="object"||typeof r.v!="string"||!r.c?null:r}catch{return null}}async write(e,t,r){try{let i={v:t,c:r};await this.storage.set(this.keyOf(e),JSON.stringify(i));}catch{}}async clear(e){try{await this.storage.remove(this.keyOf(e));}catch{}}keyOf(e){return `${Gc}:${this.titleId}:${e}`}};function to(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var ro="idos:loc",Mt=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 r=JSON.parse(t);return !r||typeof r!="object"||typeof r.v!="number"||!r.t||typeof r.t!="object"?null:r}catch{return null}}async write(e,t,r){try{let i={v:t,t:r};await this.storage.set(this.keyOf(e),JSON.stringify(i)),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 r={};for(let[i,s]of Object.entries(t))typeof s=="number"&&s>0&&(r[i]=s);return r}catch{return {}}}async noteVersion(e,t){let r=await this.readVersions();r[e]!==t&&(r[e]=t,await this.storage.set(this.versionsKey(),JSON.stringify(r)));}keyOf(e){return `${ro}:${this.titleId}:${e}`}versionsKey(){return `${ro}:${this.titleId}:versions`}};var Nc="idos:state",cr=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 r=JSON.parse(t);return !r||typeof r!="object"||typeof r.e!="string"||!r.v||!r.s?null:r}catch{return null}}async write(e,t,r,i){if(!(!e||!t))try{let s={e:t,v:r,s:i};await this.storage.set(this.keyOf(e),JSON.stringify(s));}catch{}}keyOf(e){return `${Nc}:${this.titleId}:${e}`}};function jc(o,e){if(!o)return;let t=new Set((e??[]).map(i=>i.trim().toLowerCase()));if(t.size===0)return o;let r={};for(let[i,s]of Object.entries(o))t.has(i.toLowerCase())||(r[i]=s);return r}function ys(o,e,t,r){let i={...o??{}};if(!e||!t||!r)return i;for(let[s,a]of Object.entries(t))r[s]===a&&s in e&&(i[s]=e[s]);return i}function Fc(o){return {...o??{}}}function Cs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var pr=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=jc(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[r,i]of Object.entries(t)){let s=this.versions[r];s!==void 0&&i===s+1?this.versions[r]=i:delete this.versions[r],this.dirty=true;}}afterFullRead(e,t){e!==this.epoch&&this.reset(e),this.versions=Fc(t),this.dirty=true;}afterSliceRead(e,t){e!==this.epoch&&this.reset(e);for(let[r,i]of Object.entries(t??{}))this.versions[r]=i;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 io=n("server","Title configuration is unavailable (CDN and API both failed)."),dr=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:P()}:null}get configCache(){return this.cache??=new kt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new Mt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new pr(new cr(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=kt.scopeOf(e.TitleFields,null),r=await this.configCache.read(t);r&&(e.KnownTitleConfigVersion=r.v),await this.prepareLocalization(e);let i=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,r,{Fields:e.TitleFields});return a==null?io:(this.finishStateHandshake(s.data,i),await this.applyClientState(s.data,a,void 0,void 0),await this.applyLocalization(s.data.Localization),await this.flushState(i),s)}async prepareStateHandshake(e,t){let r=this.ctx.auth.context?.userID;if(!r)return {userId:null,cached:null,sent:void 0};await this.stateStore.load(r),await this.stateStore.flush(r,this.ctx.data.user.state);let i=this.stateStore.versionsFor(t);if(i){e.KnownStateVersions=i;let s=this.stateStore.currentEpoch;s&&(e.KnownStateEpoch=s);}return {userId:r,cached:this.stateStore.cachedState,sent:i}}finishStateHandshake(e,t){let r=ys(e.User,t.cached,t.sent,e.StateVersions);e.User=r;let i=Cs(e);!i||!t.userId||this.stateStore.afterFullRead(i,e.StateVersions);}async resolveTitleConfig(e,t,r,i){let s=e.TitleConfigVersion;if(r&&s&&r.v===s)return r.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(i);return a!=null?(s&&await this.configCache.write(t,s,a),a):r?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let r=await t.json();return r&&typeof r=="object"?r:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let r={...t,...e},i=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(r):await this.ctx.api.title.getTitlePublicConfiguration(r);return i.ok?i.data:null}async getClientStateExcept(e,t){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ExcludeFields=e,r.ExcludeTitleFields=t;let i=kt.scopeOf(null,t??[]),s=await this.configCache.read(i);s&&(r.KnownTitleConfigVersion=s.v),await this.prepareLocalization(r);let a=await this.prepareStateHandshake(r,e??null),p=await this.ctx.api.user.getClientStateExcept(r);if(!p.ok)return p;let D=await this.resolveTitleConfig(p.data,i,s,{ExcludeFields:t??[]});return D==null?io:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,D,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 r=await this.localizationCache.readVersions();Object.keys(r).length>0&&(e.KnownLocalizationVersions=r);}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}),r=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:r});}async resolveLocalizationTable(e){let t=e.Locale??null,r=e.Version??0;if(!t)return null;let i=await this.localizationCache.read(t);if(r<=0)return i?.t??null;if(i&&i.v===r)return i.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,r,a),a}let s=await this.fetchLocalizationFromApi(t,i?.v??0);return s??i?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let r=await t.json();return r&&typeof r=="object"?r:null}catch{return null}}async fetchLocalizationFromApi(e,t){let r=this.baseRequest();if(!r)return null;let i=await this.ctx.api.localization.getLocalizationTable({...r,Locale:e,KnownVersion:t});if(!i.ok)return null;let s=i.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,D=s.Locale??e;return p>0&&await this.localizationCache.write(D,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 r=await this.prepareStateHandshake(t,null),i=await this.ctx.api.user.getUserState(t);if(!i.ok)return i;let s=ys(i.data.User,r.cached,r.sent,i.data.StateVersions);i.data.User=s;let a=Object.keys(i.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(s,a);let p=Cs(i.data);return p&&(this.stateStore.afterSliceRead(p,i.data.StateVersions),await this.flushState(r)),i}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,r){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.UsageTime=e,i.IsNewSession=t,i.SessionDurationSeconds=r;let s=await this.ctx.api.user.addUsageTime(i);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 r=await this.ctx.api.user.changeUsername(t);return r.ok&&this.ctx.emitter.emit("user:usernameChanged",r.data),r}async applyClientState(e,t,r,i){let s=r?.includes("GameLoop")===true,a=i?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,D=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let U=this.ctx.data.user.state;s&&U&&U.GameLoop==null&&(U.GameLoop=p);let E=this.ctx.data.config.titlePublicConfiguration;a&&E&&E.GameLoop==null&&(E.GameLoop=D),this.ctx.emitter.emit("user:clientStateReceived",e);}};var mr=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,r,i,s,a){if(!t)return n("client","SourceID is required.");if(!i)return n("client","TargetID is required.");if(s<=0)return n("client","Amount must be positive.");if(e===r&&t===i)return n("client","Source and target must differ.");if(e===Ve.Crypto||r===Ve.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:r,TargetID:i,SourceAmount:String(Math.trunc(s)),TransactionID:a&&a.length>0?a:`convert_${e}_${t}_to_${r}_${i}_${P()}`},D=await this.ctx.api.currency.convert(p);if(D.ok){let U=D.data,E={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.SourceID,Amount:U.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:U.TargetID,Amount:U.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(E,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",U);}return D}async cryptoConvert(e,t,r,i,s,a){let p=s instanceof sr__default.default?s:new sr__default.default(s);if(!t)return n("client","SourceID is required.");if(!i)return n("client","TargetID is required.");if(p.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===r&&t===i)return n("client","Source and target must differ.");if(e===Ve.Virtual&&r===Ve.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===Ve.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 D={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:r,TargetID:i,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${r}_${i}_${P()}`},U=await this.ctx.api.currency.cryptoConvert(D);if(U.ok){let E=U.data,de=[],Re=[];if(E.SourceType===Ve.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===Ve.Virtual&&Re.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),de.length>0||Re.length>0){let Ie={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:Re.length>0?{Standard:{Entries:Re}}:null};this.ctx.data.user.applyResourceOperation(Ie,this.ctx.data.config.itemDefinitions);}E.SourceType===Ve.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new sr__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===Ve.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new sr__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return U}};var fr=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t,r){let i=e.trim();if(!i)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:i,SelectedOptionID:r,RelatedEntityID:`upgrade_item_${i}_${P()}`};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},r=await this.ctx.api.item.upgradeLevelsBatch(t);return r.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",r.data)),r}};var Vc="Store",gr=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1,r){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,SelectedOptionID:r?.selectedOptionID,Payment:r?.payment,RelatedEntityID:`store_buy_${e}_${i.userID}_${P()}`},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},r=await this.ctx.api.store.purchaseBatch(t);if(r.ok){let i=false;for(let s of r.data)!s.Success||!s.Data||!s.Data.OfferID||(this.ctx.data.user.patchStorePurchase(s.Data.OfferID,s.Data.Count,s.Data.ServerTimeUtc),!i&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true));this.ctx.emitter.emit("store:offersPurchasedBatch",r.data);}return r}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(Vc,t.data),this.ctx.emitter.emit("store:definitionsLoaded",t.data)),t}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 Rr=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,r){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:r?.signature,ProductID:r?.productID,TransactionID:r?.transactionID},s=await this.ctx.api.purchase.validatePurchase(i);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 yr=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,r])=>({...r,OptionID:r.OptionID||t})).filter(t=>this.isAvailable(t)).sort((t,r)=>(t.OptionID??"").localeCompare(r.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 r of t)if(r?.Type===Kt.Purchase&&r.ProductID)return r.ProductID;return null}cryptoShortfallOf(e){let t=e?.Standard?.Entries;if(!t)return null;for(let r of t){if(r?.Type!==Kt.CryptoCurrency||!r.CurrencyID)continue;let i=Number(r.Amount??0);if(!(i>0))continue;let s=this.cryptoBalance(r.CurrencyID);return s>=i?null:{currencyID:r.CurrencyID,required:i,available:s,missing:i-s}}return null}cryptoBalance(e){let r=this.ctx.data.user.state?.InventoryV2?.CryptoCurrencies?.[e];return Number(r?.Amount??0)}};var _c="Lootbox",Cr=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 r=t.data.LootboxDefinitions;r&&(this.ctx.data.config.patchSection(_c,r),this.ctx.emitter.emit("lootbox:definitionsLoaded",r));}return t}async open(e,t,r,i){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:r,Payment:i,RelatedEntityID:`lootbox_${e}_${r??"default"}_${P()}`},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 Wc="Reward";function Ss(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Sr=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 r=t.data.RewardDefinitions;r&&(this.ctx.data.config.patchSection(Wc,r),this.ctx.emitter.emit("reward:definitionsLoaded",r));}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 r=t.data;this.multiplierEnabled=r.Enabled,this.multiplier=r.Enabled?r.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",r);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${P()}`},i=await this.ctx.api.reward.claimDailyReward(r);if(i.ok){let s=i.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 i}async collectIdleAccrual(e){if(!Ss(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}_${P()}`},r=await this.ctx.api.reward.collectIdleAccrual(t);if(r.ok){let i=r.data;this.ctx.data.user.patchIdleAccrualState(i.AccrualID,i.IdleState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:idleCollected",i);}return r}async claimComebackReward(e){if(!Ss(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}_${P()}`},r=await this.ctx.api.reward.claimComebackReward(t);if(r.ok){let i=r.data;this.ctx.data.user.patchComebackState(i.ComebackID,i.ComebackState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:comebackClaimed",i);}return r}async claimReward(e){if(!Ss(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}_${P()}`},r=await this.ctx.api.reward.claimReward(t);if(r.ok){let i=r.data;this.ctx.data.user.patchClaimRewardState(i.ClaimID,i.ClaimState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:claimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Qc="Tutorial",xr=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(Qc,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 r=await this.ctx.api.tutorial.getUserTutorialState(t);if(r.ok){let i=r.data.State??{};this.ctx.data.user.applyTutorial(i),this.ctx.emitter.emit("tutorial:userStateLoaded",r.data);}return r}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,r=>this.ctx.api.tutorial.reportStepShown(r))}async completeStep(e,t){return this.stepCall(e,t,r=>this.ctx.api.tutorial.completeStep(r),{relatedEntityID:`tutorial_step_${e}_${t}_${P()}`})}async completeStepsBatch(e,t){let r=e?.trim();if(!r)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 i={...this.ctx.buildAuthedBaseRequest(),FlowID:r,StepIDs:t,RelatedEntityID:`tutorial_batch_${r}_${P()}`},s=await this.ctx.api.tutorial.completeStepsBatch(i);return s.ok&&(await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:stepsCompletedBatch",s.data)),s}async skipStep(e,t){return this.stepCall(e,t,r=>this.ctx.api.tutorial.skipStep(r))}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 r={...this.ctx.buildAuthedBaseRequest(),FlowID:t,RelatedEntityID:`tutorial_claim_${t}_${P()}`},i=await this.ctx.api.tutorial.claimFlowReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Granted,this.ctx.data.config.itemDefinitions),await this.refreshAfterMutation(),this.ctx.emitter.emit("tutorial:rewardClaimed",i.data)),i}async resetFlow(e){return this.flowCall(e,t=>this.ctx.api.tutorial.resetFlow(t),{event:"tutorial:flowReset"})}async flowCall(e,t,r){let i=e?.trim();if(!i)return n("client","FlowID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),FlowID:i},a=await t(s);return a.ok&&(this.applyFlowView(a.data),this.ctx.emitter.emit(r.event,a.data)),a}async stepCall(e,t,r,i){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};i?.relatedEntityID&&(p.RelatedEntityID=i.relatedEntityID);let D=await r(p);return D.ok&&(this.applyFlowView(D.data),this.ctx.emitter.emit("tutorial:stepChanged",D.data)),D}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 Dr=Object.freeze({}),br=class{constructor(e){this.ctx=e;}ctx;table={...Dr};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new Mt(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,r])=>({Locale:r?.Locale??t,DisplayName:r?.DisplayName??null,Order:r?.Order??0})).sort((t,r)=>(t.Order??0)-(r.Order??0)):[]}has(e){return this.lookup(e)!==void 0}t(e,t){if(!e)return "";let r=this.resolveKey(e,t),i=this.lookup(r)??this.lookup(e);return i===void 0?this.onMissing(e):t?Kc(i,t):i}applyState(e,t){if(!e){this.reset();return}let r=e.Locale??null;this.table=t.table??{...Dr},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let r=await this.loadTableFromApi(e);if(!r.ok)return r;let{locale:i,table:s,fallbackLocale:a}=r.data,p=null;if(a){let D=await this.loadTableFromApi(a);D.ok&&(p=D.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:i}}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={...Dr},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:P()}:null}async loadTableFromApi(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Locale=e;let r=await this.cache.read(so(e));r&&(t.KnownVersion=r.v);let i=await this.ctx.api.localization.getLocalizationTable(t);if(!i.ok)return i;let s=i.data,a=s.Locale??so(e),p=s.Version??0;if(s.NotModified){let U=r??await this.cache.read(a);return {ok:true,data:{locale:a,table:U?.t??{...Dr},fallbackLocale:s.FallbackLocale??null}}}let D=s.Entries??{};return p>0&&await this.cache.write(a,p,D),{ok:true,data:{locale:a,table:D,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let r=t?.count;if(typeof r!="number")return e;let i=this.pluralCategory(r),s=`${e}.${i}`;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 Kc(o,e){return o.replace(/\{(\w+)\}/g,(t,r)=>{let i=e[r];return i===void 0?t:String(i)})}function so(o){return o.trim().replace(/_/g,"-").toLowerCase()}var Hc="Quest",zr=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(Hc,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 r=await this.ctx.api.quest.getUserQuestState(t);if(r.ok){let i=r.data.State??{};this.ctx.data.user.applyQuest(i),this.ctx.data.user.patchQuestPointsTracks(r.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",i);}return r}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 r=e.trim();if(!r)return n("client","QuestID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i=t&&t.trim().length>0?t.trim():void 0,s={...this.ctx.buildAuthedBaseRequest(),QuestID:r,CycleID:i,RelatedEntityID:`quest_claim_${i??""}_${r}_${P()}`},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},r=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(r.ok){let i=false;for(let s of r.data)!s.Success||!s.Data||(this.ctx.data.user.patchQuestStatus(s.Data.QuestID,s.Data.CycleID,"Claimed"),!i&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",r.data);}return r}async claimMilestoneReward(e,t){let r=e.trim(),i=t.trim();if(!r||!i)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:r,MilestoneID:i,RelatedEntityID:`milestone_claim_${r}_${i}_${P()}`},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},r=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(r.ok){let i=false;for(let s of r.data)!s.Success||!s.Data||(this.ctx.data.user.patchMilestoneClaimed(s.Data.CycleID,s.Data.MilestoneID),!i&&s.Data.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",r.data);}return r}async claimGroupCompletionReward(e,t){let r=e.trim(),i=t.trim();if(!r||!i)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:r,GroupCompletionID:i,RelatedEntityID:`group_completion_${r}_${i}_${P()}`},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 r=e.trim();if(!r)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 i={...this.ctx.buildAuthedBaseRequest(),MetricID:r,ProgressValue:t},s=await this.ctx.api.quest.addQuestProgress(i);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 $c="TimedEvent",Tr=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($c,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,r,i,s,a,p=1){if(!t)return n("client","LteID is required.");if(!r)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:r,Outcome:i,AmountOverride:s,SourceParams:a,RollMultiplier:p},U=await this.ctx.api.timedEvent.grantTokens(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",U.data)),U}async spendTokens(e,t,r){if(!t)return n("client","LteID is required.");if(r<=0)return n("client","SpendAmount must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SpendAmount:r},s=await this.ctx.api.timedEvent.spendTokens(i);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,r){if(!t||!r)return n("client","LteID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,MilestoneID:r},s=await this.ctx.api.timedEvent.claimMilestone(i);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,r),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},r=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return r.ok&&(this.applyMilestoneClaimBatch(r.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",r.data)),r}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let r=await this.ctx.api.timedEvent.claimAllMilestones(t);return r.ok&&(this.applyMilestoneClaimBatch(r.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",r.data)),r}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},r=await this.ctx.api.timedEvent.spendTokensBatch(t);if(r.ok){let i=false;for(let s of r.data)!i&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",r.data);}return r}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},r=await this.ctx.api.timedEvent.grantTokensBatch(t);if(r.ok){let i=false;for(let s of r.data)!i&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",r.data);}return r}applyMilestoneClaimBatch(e){let t=false;for(let r of e){if(!r.Success||!r.Data)continue;let i=r.Data;i.Type&&i.LteID&&i.MilestoneID&&this.ctx.data.user.patchTimedEventMilestoneClaimed(i.Type,i.LteID,i.MilestoneID),!t&&i.Rewards&&(this.ctx.data.user.applyResourceOperation(i.Rewards,this.ctx.data.config.itemDefinitions),t=true);}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Zc="Leaderboard",vr=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(Zc,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 r=await this.ctx.api.leaderboard.getLeaderboard(t);return r.ok&&this.ctx.emitter.emit("leaderboard:loaded",r.data),r}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 r=await this.ctx.api.leaderboard.getMyProgress(t);return r.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),r.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",r.data)),r}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 r={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},i=await this.ctx.api.leaderboard.submitScore(r);if(i.ok){let s=i.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return i}async submitScoreFromSource(e,t,r,i,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:r,Params:i,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let D=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),D.NewScore,D.NewScore,D.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",D);}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},r=await this.ctx.api.leaderboard.claimCycleReward(t);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",i);}return r}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 r={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},i=await this.ctx.api.leaderboard.claimMilestone(r);if(i.ok){let s=i.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 i}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 r=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return r.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",r.data),r}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 r=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return r.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",r.data),r}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 r=await this.ctx.api.leaderboard.getProgressBatch(t);if(r.ok){for(let i of r.data)!i.Success||!i.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(i.Data.LeaderboardID),i.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",r.data);}return r}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},r=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(r.ok){for(let i of r.data)!i.Success||!i.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(i.Data.LeaderboardID)),i.Data.Resources&&this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",r.data);}return r}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},r=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(r.ok){for(let i of r.data)!i.Success||!i.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(i.Data.LeaderboardID),i.Data.MilestoneID),i.Data.Resources&&this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",r.data);}return r}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},r=await this.ctx.api.leaderboard.submitScoresBatch(t);if(r.ok){for(let i of r.data)!i.Success||!i.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(i.Data.LeaderboardID),i.Data.NewScore,i.Data.NewScore,i.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",r.data);}return r}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},r=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(r.ok){for(let i of r.data){let s=this.cycleDocID(i.LeaderboardID);i.CycleReward?.Success&&i.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),i.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(i.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of i.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",r.data);}return r}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 r=await this.ctx.api.leaderboard.getOverviewBatch(t);if(r.ok){for(let i of r.data)i.Progress?.Success&&i.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(i.LeaderboardID),i.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",r.data);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Jc="Season",Pr=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(Jc,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 r=await this.ctx.api.season.getActiveSeason(t);return r.ok&&(r.data.UserState&&this.ctx.data.user.patchSeasonState(e,r.data.UserState),this.ctx.emitter.emit("season:activeLoaded",r.data)),r}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 r=await this.ctx.api.season.getUserState(t);return r.ok&&(this.ctx.data.user.patchSeasonState(e,r.data),this.ctx.emitter.emit("season:userStateLoaded",r.data)),r}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 r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${P()}`},i=await this.ctx.api.season.grantStatusTokens(r);return i.ok&&(this.ctx.data.user.patchSeasonCurrentTier(e,i.data.NewTier),this.ctx.emitter.emit("season:statusTokensGranted",i.data)),i}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 r={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${P()}`},i=await this.ctx.api.season.claimTierReward(r);if(i.ok){let s=i.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 i}async claimTierRewardsBatch(e,t){if(!e)return n("client","SeasonChainID is required.");let r=(t??[]).filter(a=>a>0);if(r.length===0)return n("client","TierNumbers is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumbers:r,RelatedEntityID:`season_tier_batch_${e}_${P()}`},s=await this.ctx.api.season.claimTierRewardsBatch(i);if(s.ok){let a=s.data;for(let p of a.Items??[]){let D=p.Data?.TierNumber;p.Success&&typeof D=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,D);}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 Yc="Premium",Ir=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(Yc,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 r={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},i=await this.ctx.api.premium.activateTrial(r);return i.ok&&(i.data.Premium&&this.ctx.data.user.applyPremium(i.data.Premium),this.ctx.emitter.emit("premium:trialActivated",i.data)),i}async purchaseItemOrCurrency(e,t,r="Default",i=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:r,Count:i,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,r,i,s,a,p,D){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!i||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:r,ProductID:i,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:D,RelatedEntityID:`premium_iap_${e}_${t}`},E=await this.ctx.api.premium.purchaseRealMoney(U);if(E.ok){let de=E.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 E}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Xc="Character",kr=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(Xc,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 r=t.data.Characters??{};this.ctx.data.user.applyCharacter(r),this.ctx.emitter.emit("character:userCharactersLoaded",r);}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 r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`unlock_char_${e}_${P()}`},i=await this.ctx.api.character.unlockCharacter(r);if(i.ok){let s=i.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 i}async upgradeStatLevel(e,t,r){if(!e||!t)return n("client","CharacterID and StatID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,StatID:t,RelatedEntityID:`upgrade_stat_${e}_${t}_${P()}`,...r?.levels!=null?{Levels:r.levels}:{},...r?.targetLevel!=null?{TargetLevel:r.targetLevel}:{}},s=await this.ctx.api.character.upgradeStatLevel(i);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 r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${P()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},i=await this.ctx.api.character.upgradeCharacterLevel(r);if(i.ok){let s=i.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 i}async equipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},i=await this.ctx.api.character.equipItems(r);return i.ok&&(this.applyEquipChangesLocally(e,i.data),this.ctx.emitter.emit("character:itemsEquipped",i.data)),i}async unequipItems(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},i=await this.ctx.api.character.unequipItems(r);if(i.ok){let s=i.data;this.applyUnequipChangesLocally(e,s),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:s.ClearedSlotIDs??[],power:s.Power??null});}return i}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},r=await this.ctx.api.character.unlockCharactersBatch(t);return r.ok&&(this.applyBatchResults(r.data,i=>{this.ctx.data.user.patchCharacter(i.CharacterID,s=>{s.StatLevels??={},s.Equipment??={},i.Power!=null&&(s.Power=i.Power),s.UpdatedAt=i.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",r.data)),r}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},r=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return r.ok&&(this.applyBatchResults(r.data,i=>{this.ctx.data.user.patchCharacter(i.CharacterID,s=>{s.Level=i.NewLevel,i.Power!=null&&(s.Power=i.Power),s.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(s.StatLevels??={},s.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",r.data)),r}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},r=await this.ctx.api.character.upgradeStatLevelsBatch(t);return r.ok&&(this.applyBatchResults(r.data,i=>{this.ctx.data.user.patchCharacter(i.CharacterID,s=>{s.StatLevels??={},s.StatLevels[i.StatID]=i.StatLevel,i.Power!=null&&(s.Power=i.Power),s.UpdatedAt=i.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",r.data)),r}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let r of e.Items??[])!r.Success||!r.Data||t(r.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[i,s]of Object.entries(t.Equipment??{}))r.patchCharacterEquipment(e,i,s);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let r=t.ClearedSlotIDs??[];if(r.length===0&&t.Power==null)return;let i=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let s of r)i.patchCharacterEquipment(e,s,null);i.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[r,i]of Object.entries(e.Characters??{})){for(let s of i.ClearedSlotIDs??[])t.patchCharacterEquipment(r,s,null);t.patchCharacter(r,s=>{i.Power!=null&&(s.Power=i.Power),s.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ep="Match",Mr=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,r,i,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:r,BattleStrategy:i,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${P()}`},U=await this.ctx.api.match.createMatch(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",U.data)),U}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),MatchID:e,TargetUserID:t.targetUserID,ClearTargetUser:t.clearTargetUser,RuleID:t.ruleID,CharacterID:t.characterID,BattleStrategy:t.battleStrategy},i=await this.ctx.api.match.updateMatch(r);return i.ok&&this.ctx.emitter.emit("match:updated",i.data),i}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},r=await this.ctx.api.match.cancelMatch(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",r.data)),r}async instantBattle(e,t,r,i){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:r,BattleStrategy:i,RelatedEntityID:`pvp_battle_${e}_${P()}`},p=await this.ctx.api.match.instantBattle(a);if(p.ok){let D=p.data,U=this.ctx.data.config.itemDefinitions;if(D.Resources)this.ctx.data.user.applyResourceOperation(D.Resources,U);else if(D.ResourcesDual){let E=D.ResourcesDual;E.FromUserID===s.userID&&E.FromResult?this.ctx.data.user.applyResourceOperation(E.FromResult,U):E.ToUserID===s.userID&&E.ToResult&&this.ctx.data.user.applyResourceOperation(E.ToResult,U);}this.ctx.emitter.emit("match:instantBattleCompleted",D);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},r=await this.ctx.api.match.saveStrategy(t);return r.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),r}async getMyMatches(e=0,t=20,r){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t,i.Statuses=r;let s=await this.ctx.api.match.getMyMatches(i);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,r=false){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.Page=e,i.PageSize=t,i.OnlyPublic=r;let s=await this.ctx.api.match.getAvailableMatches(i);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(ep,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var tp="Craft",wr=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(tp,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,r=1,i){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:r,SelectedOptionID:i,RelatedEntityID:`craft_${e}_${s.userID}_${P()}`},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 rp="Collection",Ar=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(rp,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,r=1,i){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,Count:r,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${P()}`},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,r=1){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,Count:r,RelatedEntityID:`open_chest_${e}_${t}_${i.userID}_${P()}`},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 r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${r.userID}_${P()}`},s=await this.ctx.api.collection.useCollectibleJoker(i);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 r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${r.userID}_${P()}`},s=await this.ctx.api.collection.claimSetReward(i);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},r=await this.ctx.api.collection.claimSetRewardsBatch(t);if(r.ok){let i=false;for(let s of r.data)!i&&s.Success&&s.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(s.Data.Resources,this.ctx.data.config.itemDefinitions),i=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",r.data);}return r}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${P()}`},i=await this.ctx.api.collection.claimGrandPrize(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:grandPrizeClaimed",i.data)),i}async sendTradeOffer(e,t,r,i,s,a=false){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let D={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:r,ReceiverUserID:i,RequestedCollectibleID:s,RequestedCollectibleIsSpecial:a,RelatedEntityID:`trade_send_${p.userID}_${i}_${P()}`},U=await this.ctx.api.collection.sendTradeOffer(D);return U.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",U.data),U}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}_${P()}`},r=await this.ctx.api.collection.cancelTradeOffer(t);return r.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",r.data),r}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}_${P()}`},r=await this.ctx.api.collection.acceptTradeOffer(t);return r.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",r.data),r}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}_${P()}`},r=await this.ctx.api.collection.declineTradeOffer(t);return r.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",r.data),r}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let r=await this.ctx.api.collection.getMyTradeOffers(t);return r.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",r.data),r}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let r=await this.ctx.api.collection.getIncomingTradeOffers(t);return r.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ip="CoopEvent",Or=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(ip,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 r=await this.ctx.api.coopEvent.getActiveEvent(t);return r.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",r.data),r}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 r=await this.ctx.api.coopEvent.getGroupState(t);return r.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",r.data),r}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},r=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(r.ok){let i=r.data.Group;i&&this.ctx.data.user.patchCoopEventActiveGroup(i.GroupID??null,i.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",r.data);}return r}async spin(e,t,r=1,i){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:r,SelectedOptionID:i,RelatedEntityID:P()},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},r=await this.ctx.api.coopEvent.claimObjectReward(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",r.data)),r}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},r=await this.ctx.api.coopEvent.claimGrandPrize(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",r.data)),r}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},r=await this.ctx.api.coopEvent.leaveGroup(t);return r.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",r.data)),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var sp="DealOffer",Ur=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(sp,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}_${P()}`},r=await this.ctx.api.dealOffer.dismissDeal(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",r.data)),r}async executeNode(e,t,r,i){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s=r&&r.trim().length>0?r.trim():void 0,a={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,SelectedOptionID:i?.selectedOptionID,Payment:i?.payment,RelatedEntityID:s??`deal_exec_${e}_${t}_${P()}`},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}_${P()}`},r=await this.ctx.api.dealOffer.recordShow(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",r.data)),r}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 r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${P()}`},i=await this.ctx.api.dealOffer.claimMilestone(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestoneClaimed",i.data)),i}async claimMilestonesBatch(e,t){if(!e)return n("client","SlotID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))],i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:r,RelatedEntityID:`deal_milestone_batch_${e}_${P()}`},s=await this.ctx.api.dealOffer.claimMilestonesBatch(i);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 np="Referral",Br=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(np,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=e.trim().toUpperCase();if(!t)return n("client","ReferralCode is required.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${r.userID}`},s=await this.ctx.api.referral.activateReferralCode(i);if(s.ok){let a=s.data;a.ReferralCode&&this.ctx.data.user.patchReferralSubscription(a.ReferralCode),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 r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${r.userID}`},s=await this.ctx.api.referral.claimInviteReward(i);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 r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${r.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(i);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 Lr=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 getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let r=await this.ctx.api.social.getRecommendedFriends(t);return r.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",r.data),r}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},r=await this.ctx.api.social.sendFriendRequest(t);return r.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",r.data)),r}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},r=await this.ctx.api.social.acceptFriendRequest(t);return r.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",r.data)),r}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},r=await this.ctx.api.social.declineFriendRequest(t);return r.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",r.data)),r}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},r=await this.ctx.api.social.removeFriend(t);return r.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",r.data)),r}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 op="TimedBoost";function ap(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var qr=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(op,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 r=e.trim();if(!ap(r))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),BoostID:r,SelectedOptionID:t?.selectedOptionID,Payment:t?.payment,RelatedEntityID:`timed_boost_activate_${r}_${P()}`},s=await this.ctx.api.timedBoost.activate(i);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 it={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},lp={Client:"Client",Server:"Server",System:"System"},up=zod.z.enum(["Client","Server","System"]),cp=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:up.nullish(),ExpiresAt:u.nullish()}).passthrough(),Er=zod.z.record(zod.z.string(),cp),no=zod.z.object({Version:zod.z.number().nullish(),Private:Er.nullish(),Public:Er.nullish(),ReadOnly:Er.nullish()}),xs=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Er.nullish()}),Ds=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),pp=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),oo=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(pp).nullish()}),ao=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),lo=zod.z.object({Results:zod.z.array(xs).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),dp={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},hp=zod.z.enum(["String","Int","Bool","Json"]),mp=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:hp.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Gr=zod.z.object({Keys:zod.z.record(zod.z.string(),mp).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(),Qe={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var fp="UserCustomData";function uo(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Nr=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(fp,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 r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.TargetUserID=t;let i=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(r);return i.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",i.data),i}async setPrivateData(e,t){return this.setData(e,t,it.Private)}async setPublicData(e,t){return this.setData(e,t,it.Public)}async setData(e,t,r){let i=e.trim();if(!uo(i))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:i,Value:t},p=await(r===it.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let D=p.data;this.ctx.data.user.patchUserCustomDataKey(r,D.KeyID,t,D.Version??0,D.ExpiresAt),this.ctx.emitter.emit(r===it.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",D);}return p}async deleteKey(e,t){let r=e.trim();if(!uo(r))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==it.Private&&t!==it.Public)return n("client","Only Private or Public keys can be deleted.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Bucket:t},s=await this.ctx.api.userCustomData.deleteKey(i);return s.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,r),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},r=await this.ctx.api.userCustomData.batchSet(t);if(r.ok){for(let i of r.data.Results??[]){let s=i.Bucket??it.Private,a=e.find(p=>p.Bucket===s&&p.KeyID===i.KeyID);a&&this.ctx.data.user.patchUserCustomDataKey(s,i.KeyID,a.Value,i.Version??0,i.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",r.data);}return r}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},r=await this.ctx.api.userCustomData.batchDelete(t);if(r.ok){for(let i of e)this.ctx.data.user.removeUserCustomDataKey(i.Bucket,i.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",r.data);}return r}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 r=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return r.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gp="TitleCustomDataDefinitions",co=50;function Rp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function bs(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function yp(o){let e={};for(let[t,r]of Object.entries(o))bs(r)||(e[t]=r);return e}var jr=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(gp,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 r=await this.ctx.api.titleCustomData.getPublicTitleData(t);return r.ok&&this.absorb(r.data),r}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=>!Rp(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>co)return n("client",`At most ${co} keys per call \u2014 request them in chunks.`);let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.KeyIDs=t;let i=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(r);return i.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",i.data),i}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!bs(t))return t.Value;let r=this.staticCache[e];if(r?.Value!=null&&!bs(r))return r.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=yp(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 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 Cp=15,Sp="GameLoop",xp="BoardDefinition",Vr=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(Sp,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 r=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return r.ok&&(this.ctx.data.config.patchSection(xp,r.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",r.data)),r}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.StageLevel=e;let i=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(r,t);return i.ok&&this.ctx.emitter.emit("gameLoop:boardDefinitionForLevelLoaded",i.data),i}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 r={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardLoopRoll(r);if(i.ok){let s=i.data,a=Yn(new Date,Cp);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 i}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardLoopAttack(r);if(i.ok){let s=i.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 i}async boardLoopRaid(e,t){if(e<0||e>11)return n("client","digIndex must be between 0 and 11.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${r.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardLoopRaid(i);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 r={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardLoopRaidFast(r);if(i.ok){let s=i.data;s.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(s)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",s);}else await this.getUserBoardState();return i}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 r={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${P()}`},i=await this.ctx.api.gameLoop.boardLoopBuild(r);if(i.ok){let s=i.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 i}async boardSpecialChoose(e,t){if(!e)return n("client","choiceID must not be empty.");let r=this.ctx.auth.context;if(!r)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,SelectedOptionID:t,RelatedEntityID:`special_choose_${r.userID}_${P()}`},s=await this.ctx.api.gameLoop.boardSpecialChoose(i);if(s.ok){let a=s.data;a.Mode==="Instant"||a.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(D=>{D.ChoiceID=e,D.ChosenMode=a.Mode??"Timed",D.StartedAtUtc=a.StartedAtUtc??null,D.DurationSeconds=a.DurationSeconds??null,D.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 r={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${P()}`},i=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(r);if(i.ok){let s=i.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 i}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${P()}`},r=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",i);}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 r=t.data.Group;r?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:r.GroupID,ActiveRoundIndex:r.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 r={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},i=await this.ctx.api.gameLoop.claimCommunityChestMilestone(r);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",i.data)),i}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},r=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",r.data)),r}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},r=await this.ctx.api.gameLoop.leaveCommunityChest(t);return r.ok&&(r.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",r.data)),r}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 _r=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,r,i){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:r,SpecificRevision:i},p=await this.ctx.api.cloudCode.execute(a);return p.ok&&this.ctx.emitter.emit("cloudCode:executed",p.data),p}};var po=zod.z.object({ServerTimeUtc:u,SourceType:vt,SourceID:zod.z.string(),TargetType:vt,TargetID:zod.z.string(),SourceSpent:M,FeeAmount:M,RateApplied:q,TargetCredited:M}),ho=zod.z.object({ServerTimeUtc:u,SourceType:vt,SourceID:zod.z.string(),TargetType:vt,TargetID:zod.z.string(),SourceSpent:q,FeeAmount:q,RateApplied:q,TargetCredited:q}),Wr={Convert:"Convert",CryptoConvert:"CryptoConvert"},Dp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},mo=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]),bp={Automatic:"Automatic",Manual:"Manual"},zp=zod.z.enum(["Automatic","Manual"]),Tp=zod.z.object({ValueInUSD:q.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(),vp=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Pp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Ip=zod.z.object({TargetCurrencyType:vt.nullish(),TargetCurrencyID:zod.z.string(),Rate:q.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),fo=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:zp.nullish(),FeePercent:q.nullish(),Targets:zod.z.array(Ip).nullish()}).passthrough(),go=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),kp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Tp.nullish(),Recharge:vp.nullish(),Conversion:fo.nullish(),Permissions:Pp.nullish(),Audit:go.nullish(),Status:mo.nullish()}).passthrough(),Mp=zod.z.object({NetworkID:zod.z.string(),ContractAddress:zod.z.string().nullish(),Decimals:zod.z.number().nullish(),MinDeposit:q.nullish(),MinWithdraw:q.nullish(),WithdrawFee:q.nullish(),DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish()}).passthrough(),wp=zod.z.object({DailyWithdrawUsd:q.nullish(),MonthlyWithdrawUsd:q.nullish(),KycRequiredAboveUsd:q.nullish()}).passthrough(),Ap=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),zs=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:q.nullish(),ValueInUSDUpdatedAt:u.nullish(),DeveloperDepositSharePercent:q.nullish(),CommunityMarketingDepositSharePercent:q.nullish(),WithdrawalBurnPercent:q.nullish(),Networks:zod.z.array(Mp).nullish(),Limits:wp.nullish(),Permissions:Ap.nullish(),Conversion:fo.nullish(),Audit:go.nullish(),Status:mo.nullish()}).passthrough(),Qr=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),kp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),zs).nullish()}).passthrough();var Ro=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:Nt.nullish(),AllowedPlatforms:zod.z.array($t).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),J=zod.z.record(zod.z.string(),Ro),Op=zod.z.object({Store:Zt,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var yo=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),Ts=zod.z.object({CharacterID:zod.z.string(),Level:zod.z.number().nullish(),Experience:M.nullish(),Power:zod.z.number().nullish(),StatLevels:zod.z.record(zod.z.string(),zod.z.number()).nullish(),Equipment:zod.z.record(zod.z.string(),yo).nullish(),UpdatedAt:u.nullish()}).passthrough(),Up=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),Bp=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:Up.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),Bp).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),Co=zod.z.object({Characters:zod.z.record(zod.z.string(),Ts).nullish()}),vs=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),StatID:zod.z.string(),StatLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),Ps=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),So=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),yo).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:pt.nullish()}),xo=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:pt.nullish()}),Lp=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),Do=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),Lp).nullish(),Inventory:pt.nullish()}),Is=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),bo=Je(Is),zo=Je(Ps),To=Je(vs),vo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),Po=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:J.nullish(),CostCurve:xe.nullish(),BaseStatValue:zod.z.number().nullish(),ValueCurve:xe.nullish(),RankCurve:xe.nullish(),Requirements:zod.z.array(vo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qp=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(vo).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(),Io=zod.z.object({Slots:zod.z.record(zod.z.string(),qp).nullish()}).passthrough(),Ep=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(),Gp=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Np=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:J.nullish()}).passthrough(),jp=zod.z.object({Stats:Y.nullish(),Levels:Y.nullish(),Equipment:Y.nullish()}).passthrough(),ko=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish()}).passthrough(),Fp=zod.z.object({CharacterID:zod.z.string(),Identity:Ep.nullish(),Classification:Gp.nullish(),Unlock:Np.nullish(),Presets:jp.nullish(),Equipment:Io.nullish(),Stats:zod.z.record(zod.z.string(),Po).nullish(),RankLadder:ko.nullish(),RankStatCurve:xe.nullish(),StatMaxLevelCurve:xe.nullish()}).passthrough(),Vp=zod.z.object({Stats:zod.z.record(zod.z.string(),Po).nullish()}).passthrough(),_p=zod.z.object({RankLadder:ko.nullish()}).passthrough(),Wp=zod.z.object({Equipment:Io.nullish()}).passthrough(),Qp=zod.z.object({Stats:zod.z.record(zod.z.string(),Vp).nullish(),Levels:zod.z.record(zod.z.string(),_p).nullish(),Equipment:zod.z.record(zod.z.string(),Wp).nullish()}).passthrough(),Kr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Fp).nullish(),Presets:Qp.nullish()}).passthrough(),Ae={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var Kp={EVM:"EVM",Solana:"Solana"},Hp=zod.z.enum(["EVM","Solana"]),$p={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Zp=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),Jp={Token:"Token",Nft:"Nft"},Mo=zod.z.enum(["Token","Nft"]),Yp={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},Xp=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),ed={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},td=zod.z.enum(["None","Tier1","Tier2","Tier3"]),rd={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},ks=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),wo={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Hr(o){let e=o?.trim();return e||wo.GameTopUp}var id={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ao=zod.z.enum(["UsersCryptoWallet","Game"]),sd=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(),Oo=zod.z.object({Ios:zod.z.boolean().nullish(),Android:zod.z.boolean().nullish(),Web:zod.z.boolean().nullish()}).passthrough(),nd=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Hp.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:Oo.nullish(),NftCollections:zod.z.array(sd).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),od=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),NftDepositsEnabled:zod.z.boolean().nullish(),NftWithdrawalsEnabled:zod.z.boolean().nullish(),PlatformOverrides:Oo.nullish()}).passthrough(),ad=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 ld=zod.z.enum(["OnChain","Combined"]),ud=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:q.nullish(),BalanceSource:ld.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),cd=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(ud).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Ms=zod.z.object({SystemState:od.nullish(),Networks:zod.z.record(zod.z.string(),nd).nullish(),AccountSafety:ad.nullish(),WalletLogin:cd.nullish()}).passthrough(),pd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:Zp.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Uo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Mo.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:q.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),dd=zod.z.object({Status:Xp.nullish(),Tier:td.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),hd=zod.z.object({CurrencyID:zod.z.string().nullish(),Deposits:zod.z.number().nullish(),DepositsVolumeNative:q.nullish(),DepositsVolumeUsd:q.nullish(),Withdrawals:zod.z.number().nullish(),WithdrawalsVolumeNative:q.nullish(),WithdrawalsVolumeUsd:q.nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),FirstDepositAt:u.nullish(),LastDepositAt:u.nullish(),FirstWithdrawalAt:u.nullish(),LastWithdrawalAt:u.nullish()}).passthrough(),md=zod.z.object({TotalDeposits:zod.z.number().nullish(),TotalWithdrawals:zod.z.number().nullish(),FailedWithdrawals:zod.z.number().nullish(),RejectedDeposits:zod.z.number().nullish(),TotalDepositsVolumeUsd:q.nullish(),TotalWithdrawalsVolumeUsd:q.nullish(),PerCurrency:zod.z.record(zod.z.string(),hd).nullish()}).passthrough(),fd=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(),gd=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(),fd).nullish()}).passthrough(),Rd=zod.z.object({Tokens:md.nullish(),Nfts:gd.nullish()}).passthrough(),yd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),Cd=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(yd).nullish()}).passthrough(),Sd=zod.z.object({Version:zod.z.number().nullish(),Stats:Rd.nullish(),LinkedWallets:zod.z.record(zod.z.string(),pd).nullish(),LastWalletLogin:Cd.nullish(),PendingWithdrawals:zod.z.array(Uo).nullish(),Kyc:dd.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),xd=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:u}).passthrough(),$r=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),xd).nullish(),PendingAdded:Uo.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),Dd=zod.z.object({Amount:q,Frozen:q,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),bd=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:Ao.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:ks.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:q.nullish(),NetPayoutAmount:q.nullish()}).passthrough(),zd=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:Ao.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:ks.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(),Bo=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),ws=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(Bo).nullish(),Signature:zod.z.string().nullish()}).passthrough(),As=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(Bo).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(),Lo=zod.z.object({Blockchain:Ms.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),zs).nullish()}).passthrough(),qo=zod.z.object({State:Sd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),Dd).nullish()}).passthrough(),Eo=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),StateDelta:$r.nullish()}).passthrough(),Go=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:b.nullish(),Inventory:pt.nullish()}).passthrough(),No=zod.z.object({ServerTimeUtc:u.nullish(),TitleTransactionID:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),NetAmountNative:q.nullish(),BurnAmountNative:q.nullish(),AmountUsd:q.nullish(),ExpiresAt:u.nullish(),EvmSignature:ws.nullish(),SolanaSignature:As.nullish(),StateDelta:$r.nullish()}).passthrough(),jo=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:b.nullish(),EvmSignature:ws.nullish(),SolanaSignature:As.nullish(),StateDelta:$r.nullish(),Inventory:pt.nullish()}).passthrough(),Fo=zod.z.object({TokenTransactions:zod.z.array(bd).nullish(),NFTTransactions:zod.z.array(zd).nullish()}).passthrough(),Os=zod.z.object({ServerTimeUtc:u.nullish(),TransactionHash:zod.z.string().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),Target:zod.z.string().nullish()}).passthrough(),Vo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Mo.nullish(),EvmSignature:ws.nullish(),SolanaSignature:As.nullish()}).passthrough(),_o=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:ks.nullish(),StateDelta:$r.nullish()}).passthrough(),Oe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Td="Blockchain",Zr=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(Td,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 r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.NetworkID=e,r.TransactionHash=t;let i=await this.ctx.api.blockchain.depositToken(r);return i.ok&&i.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(i.data.CurrencyID,new sr__default.default(i.data.AmountNative??0),i.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenDeposited",i.data)),i}async depositNFT(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.NetworkID=e,r.TransactionHash=t;let i=await this.ctx.api.blockchain.depositNFT(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftDeposited",i.data)),i}async requestTokenWithdrawal(e,t,r,i,s){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!r)return n("client","WalletAddress is required.");if(!i)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=r,a.Amount=i,a.Category=Hr(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 sr__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,r,i,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!r)return n("client","WalletAddress is required.");if(!i)return n("client","Amount is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.NetworkID=t,D.WalletAddress=r,D.Amount=i,D.Category=Hr(s),a!==void 0&&(D.Level=a),p&&(D.ItemInstanceID=p);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(D);return U.ok&&(this.ctx.data.user.applyResourceOperation(U.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",U.data)),U}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let r=await this.ctx.api.blockchain.getTransactionHistory(t);return r.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",r.data),r}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 r=await this.ctx.api.blockchain.retryWithdrawal(t);return r.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",r.data),r}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.TitleTransactionID=e,r.TransactionHash=t;let i=await this.ctx.api.blockchain.confirmWithdrawal(r);return i.ok&&this.ctx.emitter.emit("blockchain:withdrawalConfirmed",i.data),i}async donateToDeveloper(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.NetworkID=e,r.TransactionHash=t;let i=await this.ctx.api.blockchain.donateToDeveloper(r);return i.ok&&this.ctx.emitter.emit("blockchain:donatedToDeveloper",i.data),i}async donateToUsersPool(e,t){if(!e)return n("client","NetworkID is required.");if(!t)return n("client","TransactionHash is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.NetworkID=e,r.TransactionHash=t;let i=await this.ctx.api.blockchain.donateToUsersPool(r);return i.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",i.data),i}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 vd={Head:"Head",Torso:"Torso",Legs:"Legs"},Jr=zod.z.enum(["Head","Torso","Legs"]),Pd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Us=zod.z.enum(["Open","InProgress","Cancelled","Completed"]),Ko=zod.z.object({AttackTarget:Jr,DefenseTarget:Jr});var Id=zod.z.enum(["Hit","Critical","Block","Dodge"]),kd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Jr.nullish(),DefenseZone:Jr.nullish(),HitType:Id.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Md=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(),wd=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),Qo=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:Ts.nullish(),BattleStrategy:zod.z.array(Ko).nullish(),UnstackableItems:zod.z.record(zod.z.string(),wd).nullish(),Stats:Md.nullish()}).passthrough(),Ad=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:fe.nullish(),NetReward:fe.nullish(),BattleLog:zod.z.array(kd).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:Qo.nullish(),P2BattleProfile:Qo.nullish()}).passthrough(),Ho=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(Ko).nullish(),TargetUserID:zod.z.string().nullish(),Entry:fe.nullish(),CreationCostPaid:fe.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Us.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),$o=zod.z.object({Status:Us,MatchID:zod.z.string(),Entry:fe.nullish(),Resources:b.nullish()}),Zo=zod.z.object({Match:Ho.nullish()}),Jo=zod.z.object({MatchID:zod.z.string(),Status:Us,Resources:b.nullish()}),Yo=zod.z.object({Battle:Ad.nullish(),Resources:b.nullish(),ResourcesDual:mt.nullish()}),Bs=zod.z.object({Matches:zod.z.array(Ho).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),Xe={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Od=zod.z.enum(["VirtualCurrency","Item","EventToken"]);var Ud=zod.z.enum(["Constant","Variable","Curve"]),Bd=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(),Ld=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()}).passthrough(),qd=zod.z.object({Kind:Ud.nullish(),Constant:zod.z.number().nullish(),VariableID:zod.z.string().nullish(),Argument:zod.z.string().nullish(),Curve:xe.nullish(),OnePlus:zod.z.boolean().nullish()}).passthrough(),Ed=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(qd).nullish()}).passthrough(),gt=zod.z.object({Terms:zod.z.array(Ed).nullish()}).passthrough(),Gd=zod.z.object({Health:gt.nullish(),Damage:gt.nullish(),Armor:gt.nullish(),AttackSpeed:gt.nullish(),CritChance:gt.nullish(),CritDamage:gt.nullish(),Dodge:gt.nullish()}).passthrough(),Xo=zod.z.object({StatMapping:Bd.nullish(),Combat:Ld.nullish(),Formula:Gd.nullish()}).passthrough(),Nd=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Ls=zod.z.object({Kind:Od.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:Jt.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),ea=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Ls).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),ta=zod.z.object({PriceOptions:J.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ge.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),jd=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Nd.nullish(),Entry:ea.nullish(),Creation:ta.nullish(),Settings:Xo.nullish()}).passthrough(),Fd=zod.z.object({Rules:zod.z.record(zod.z.string(),jd).nullish(),Defaults:Xo.nullish(),EntryDefaults:ea.nullish(),CreationDefaults:ta.nullish()}).passthrough(),qs=zod.z.object({InstantBattle:Fd.nullish()}).passthrough(),ra=qs;var Vd={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Es=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),_d={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Gs=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]),Wd={Burn:"Burn",Ledger:"Ledger"},Qd=zod.z.enum(["Burn","Ledger"]),Xr={Item:"Item",VirtualCurrency:"VirtualCurrency"},Ns=zod.z.enum(["Item","VirtualCurrency"]),Kd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),Hd=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Ls).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),$d=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:Qd.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Kd).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Zd=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(),Jd=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ge.nullish(),BuyLimits:ge.nullish(),ListingFeeOptions:J.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),Yd=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:M.nullish(),BidLimits:ge.nullish()}).passthrough(),Xd=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ge.nullish(),FillLimits:ge.nullish()}).passthrough(),eh=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ge.nullish()}).passthrough(),th=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),js=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:W.nullish(),Schedule:ce.nullish(),PricePolicy:Hd.nullish(),Commission:$d.nullish(),Tradability:Zd.nullish(),Listings:Jd.nullish(),Auctions:Yd.nullish(),BuyOrders:Xd.nullish(),DirectTrades:eh.nullish(),Matching:th.nullish()}).passthrough(),ia=zod.z.object({BidIndex:zod.z.number().nullish(),UserID:zod.z.string().nullish(),Amount:M.nullish(),Settled:zod.z.boolean().nullish(),SettledAt:u.nullish()}).passthrough(),rh=zod.z.object({BidAxisType:Ht.nullish(),BidCurrencyID:zod.z.string().nullish(),BidCatalogID:zod.z.string().nullish(),BidItemID:zod.z.string().nullish(),StartingBid:M.nullish(),CurrentBid:M.nullish(),CurrentBidderID:zod.z.string().nullish(),BidCount:zod.z.number().nullish(),ExtensionCount:zod.z.number().nullish(),PendingRefunds:zod.z.array(ia).nullish()}).passthrough(),Yr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),ih=zod.z.object({Create:Yr.nullish(),Buy:Yr.nullish(),Sell:Yr.nullish(),Bid:Yr.nullish()}).passthrough(),sh=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),nh=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:sh.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),st=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Es.nullish(),Status:Gs.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:ze.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Ns.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:zod.z.array(nh).nullish(),Price:fe.nullish(),Auction:rh.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),oh=zod.z.object({GoodsType:Ns.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Es,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),sa=zod.z.object({Definitions:js.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Fs=zod.z.object({Offers:zod.z.array(st).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),na=zod.z.object({Groups:zod.z.array(oh).nullish()}).passthrough(),oa=zod.z.object({Offer:st.nullish()}).passthrough(),Ge=zod.z.object({OfferID:zod.z.string().nullish(),Status:Gs.nullish(),Settlement:mt.nullish(),Resources:b.nullish(),CommissionTaken:fe.nullish()}).passthrough(),Ft=zod.z.object({OfferID:zod.z.string().nullish(),Offer:st.nullish(),Resources:b.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ge.nullish()}).passthrough(),aa=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:M.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish()}).passthrough(),la=zod.z.object({MyOffers:zod.z.array(st).nullish(),MyLeadingBids:zod.z.array(st).nullish(),MyBuyOrders:zod.z.array(st).nullish(),IncomingTrades:zod.z.array(st).nullish(),OutgoingTrades:zod.z.array(st).nullish(),Claimables:zod.z.array(st).nullish(),DrainedRefunds:zod.z.array(ia).nullish(),Limits:ih.nullish()}).passthrough(),ah=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Es.nullish(),FinalStatus:Gs.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Ns.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:fe.nullish(),CommissionTaken:fe.nullish(),CompletedAt:u.nullish()}).passthrough(),ua=zod.z.object({Entries:zod.z.array(ah).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),ae={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 lh="Marketplace",ei=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(lh,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,r,i=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=r,s.PageSize=i;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 r=await this.ctx.api.marketplace.getOffer(t);return r.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",r.data),r}async getBuyOrders(e,t,r=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.ContinuationToken=t,i.PageSize=r;let s=await this.ctx.api.marketplace.getBuyOrders(i);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 r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ContinuationToken=e,r.PageSize=t;let i=await this.ctx.api.marketplace.getHistory(r);return i.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",i.data),i}async createListing(e,t,r,i,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!i)return n("client","PriceBundle is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=r,D.PriceBundle=i,D.DurationHours=s,D.ItemInstanceIDs=a,D.SelectedOptionID=p;let U=await this.ctx.api.marketplace.createListing(D);return this.applyCreateOfferResult(U,"marketplace:listingCreated"),U}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 r=await this.ctx.api.marketplace.buy(t);return r.ok&&(this.applyDualPartySettlement(r.data.Settlement),this.ctx.emitter.emit("marketplace:bought",r.data)),r}async marketBuy(e,t,r){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(i,r);if(s)return s;i.GoodsAmount=e,i.PriceBundle=t;let a=await this.ctx.api.marketplace.marketBuy(i);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",a.data)),a}async marketSell(e,t,r){if(!e||e<=0)return n("client","GoodsAmount must be positive.");if(!t)return n("client","PriceBundle is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");let s=this.applyGoodsSelector(i,r);if(s)return s;i.GoodsAmount=e,i.PriceBundle=t;let a=await this.ctx.api.marketplace.marketSell(i);return a.ok&&(this.applyDualPartySettlement(a.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",a.data)),a}async createAuction(e,t,r,i,s,a,p={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let D=this.baseRequest();if(!D)return n("unauthorized","Not logged in.");D.ItemID=e,D.CatalogID=t,D.GoodsAmount=r,D.BidAxisType=i,D.BidCurrencyID=p.bidCurrencyID,D.BidCatalogID=p.bidCatalogID,D.BidItemID=p.bidItemID,D.StartingBid=s,D.DurationHours=a,D.ItemInstanceIDs=p.itemInstanceIDs,D.SelectedOptionID=p.selectedOptionID;let U=await this.ctx.api.marketplace.createAuction(D);return this.applyCreateOfferResult(U,"marketplace:auctionCreated"),U}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e,r.BidAmount=t;let i=await this.ctx.api.marketplace.placeBid(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:bidPlaced",i.data)),i}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 r=await this.ctx.api.marketplace.claimAuction(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",r.data)),r}async createBuyOrder(e,t,r,i,s){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!i)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=r,a.PriceBundle=i,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 r=await this.ctx.api.marketplace.fillBuyOrder(t);return r.ok&&(this.applyDualPartySettlement(r.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",r.data)),r}async createDirectTrade(e,t,r,i,s){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!r)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=r,a.ItemInstanceIDs=i,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 r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e,r.Accept=t;let i=await this.ctx.api.marketplace.respondDirectTrade(r);return i.ok&&(t&&(i.data.Settlement?this.applyDualPartySettlement(i.data.Settlement):i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions)),this.ctx.emitter.emit("marketplace:directTradeResponded",i.data)),i}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 r=await this.ctx.api.marketplace.claimBack(t);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",r.data)),r}async cancelOffer(e,t,r){if(!e)return n("client","OfferID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.OfferID=e;let s=await t(i);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(r,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=Xr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Xr.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 r=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,r):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,r);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ti=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomName=e,r.Topology=t.topology,r.ChatMode=t.chatMode,r.MaxPlayers=t.maxPlayers,r.Visibility=t.visibility,r.JoinCode=t.joinCode;let i=await this.ctx.api.multiplayer.createRoom(r);return i.ok&&this.ctx.emitter.emit("multiplayer:roomCreated",i.data),i}async joinRoom(e,t){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.JoinCode=t;let i=await this.ctx.api.multiplayer.joinRoom(r);return i.ok&&this.ctx.emitter.emit("multiplayer:roomJoined",i.data),i}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 r=await this.ctx.api.multiplayer.leaveRoom(t);return r.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",r.data),r}async listRooms(e=0,t=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t;let i=await this.ctx.api.multiplayer.listRooms(r);return i.ok&&this.ctx.emitter.emit("multiplayer:roomsListed",i.data),i}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 r=await this.ctx.api.multiplayer.getRoom(t);return r.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",r.data),r}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 r=await this.ctx.api.multiplayer.closeRoom(t);return r.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",r.data),r}async poll(e,t){if(!e)return n("client","RoomID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.LastSeq=t;let i=await this.ctx.api.multiplayer.poll(r);return i.ok&&this.ctx.emitter.emit("multiplayer:polled",i.data),i}async sendSignal(e,t,r,i){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!r)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=r,s.Payload=i;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 r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.RoomID=e,r.ChatText=t;let i=await this.ctx.api.multiplayer.sendChat(r);return i.ok&&this.ctx.emitter.emit("multiplayer:chatSent",i.data),i}async setMemberState(e,t,r){if(!e)return n("client","RoomID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.Ready=t,i.MemberState=r;let s=await this.ctx.api.multiplayer.setMemberState(i);return s.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ca=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}),Te=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),pa=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),Ue={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function A(o,e,t,r){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return r==null?s:`${s}/${r}`}var ri=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return A(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,ca,{ticket:null})}loginWithDeviceID(e){return this.login(Ue.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ue.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ue.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ue.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ue.LoginWithPlatformToken,e)}loginWithSsoCode(e){return this.login(Ue.LoginWithSsoCode,e)}registerWithEmail(e){return this.login(Ue.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ue.RequestWalletChallenge),e,pa,{ticket:null})}loginWithWallet(e){return this.login(Ue.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ue.ForgotPassword),e,Te,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ue.ResetPassword),e,Te,{ticket:null})}};var uh={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},da=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]),ch=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),ha=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),ch).nullish(),MissingKeyMode:da.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),ph=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),ma=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:ph.nullish()}).passthrough(),ii={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},dh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),fa=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:da.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(dh).nullish()}).passthrough(),ga=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 Vs=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:ma.nullish()}).passthrough().transform(o=>o),Ra=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),ya=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),Ca=zod.z.object({}).passthrough().transform(o=>o),Sa=zod.z.object({}).passthrough().transform(o=>o),xa=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(),Da=zod.z.object({Username:zod.z.string()}),Ne={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var si=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return A(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Ne.GetClientState,e.UserID),e,Vs,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Ne.GetClientStateExcept,e.UserID),e,Vs,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Ne.GetStateVersions,e.UserID),e,Ra,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Ne.GetUserState,e.UserID),e,ya,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Ne.GetInventory,e.UserID),e,Ca,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Ne.GetEventTokens,e.UserID),e,Sa,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Ne.GetUsageTime,e.UserID),e,xa,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Ne.AddUsageTime,e.UserID),e,Te,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Ne.DeleteUserAccount,e.UserID),e,Te,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Ne.ChangeUsername,e.UserID),e,Da,{ticket:e.ClientSessionTicket})}};var ni=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Wr.Convert,e,po)}cryptoConvert(e){return this.send(Wr.CryptoConvert,e,ho)}};var hh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),_s=zod.z.object({ServerTimeUtc:u,ItemInstanceID:zod.z.string(),ItemID:zod.z.string(),CatalogID:zod.z.string().nullish(),Level:zod.z.number(),Resources:b.nullish(),FodderConsumed:zod.z.array(hh).nullish()}),ba=zod.z.array(ie(_s)),oi={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},mh={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},fh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]),gh={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},Rh=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),yh=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Ch=zod.z.object({Networks:zod.z.record(zod.z.string(),yh).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Sh=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(),xh=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(),Dh=zod.z.object({ValuationMode:fh.nullish(),WeightCurve:xe.nullish(),Selection:Rh.nullish()}).passthrough(),bh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish(),FlatBonusCurve:xe.nullish(),PercentBonusCurve:xe.nullish(),PowerCurve:xe.nullish(),Fodder:Dh.nullish()}).passthrough(),zh=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Th=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:Ch.nullish(),Stats:Sh.nullish(),Equipment:xh.nullish(),Upgrade:bh.nullish(),Metadata:zh.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),vh=zod.z.object({Items:zod.z.record(zod.z.string(),Th).nullish()}).passthrough(),ai=zod.z.object({Catalogs:zod.z.record(zod.z.string(),vh).nullish()}).passthrough();var li=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=A(this.ctx.settings.titleID,"Item",oi.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,_s,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=A(this.ctx.settings.titleID,"Item",oi.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,ba,{ticket:e.ClientSessionTicket})}};var Ws=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),za=zod.z.array(ie(Ws)),Ph=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),Ta=zod.z.object({Purchases:zod.z.record(zod.z.string(),Ph).nullish()}).passthrough().transform(o=>o),Ih=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),kh=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Ih.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Mh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ge.nullish()}).passthrough(),wh=zod.z.object({OfferID:zod.z.string(),StoreIDs:zod.z.array(zod.z.string()).nullish(),Name:zod.z.string().nullish(),PriceOptions:J.nullish(),Rewards:L.nullish(),Rules:Mh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ui=zod.z.object({Stores:zod.z.record(zod.z.string(),kh).nullish(),StoreOffers:zod.z.record(zod.z.string(),wh).nullish()}).passthrough(),wt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var ci=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(wt.Purchase,e,Ws)}purchaseBatch(e){return this.send(wt.PurchaseBatch,e,za)}getDefinitions(e){return this.send(wt.GetDefinitions,e,ui)}getUserState(e){return this.send(wt.GetUserState,e,Ta)}};var Ah={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},Oh=zod.z.enum(["Consumable","NonConsumable","Subscription"]),Uh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ge.nullish()}).passthrough(),Bh=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),Lh=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:Oh.nullish(),Enabled:zod.z.boolean().nullish(),StoreProductIDs:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Rewards:L.nullish(),PriceUsdCents:zod.z.number().nullish(),Rules:Uh.nullish(),Refund:Bh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),va=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Lh).nullish()}).passthrough(),Pa=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(),Ia=zod.z.object({Products:zod.z.record(zod.z.string(),Pa).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),qh={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},Eh=zod.z.enum(["Granted","Restored","AlreadyProcessed"]),Qs=zod.z.object({ServerTimeUtc:u,Store:Zt.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:Eh.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:b.nullish(),ProductState:Pa.nullish()}).passthrough(),ka=Je(Qs),At={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var pi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(At.GetDefinitions,e,va)}getUserState(e){return this.send(At.GetUserState,e,Ia)}validatePurchase(e){return this.send(At.ValidatePurchase,e,Qs)}validatePurchasesBatch(e){return this.send(At.ValidatePurchasesBatch,e,ka)}};var Gh=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Ma=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:Gh.nullish()}).passthrough(),Ot=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Ma).nullish()}).passthrough(),Ut=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Ma).nullish()}).passthrough(),Nh=zod.z.object({RewardSlots:zod.z.array(Ot).nullish()}).passthrough(),jh=zod.z.object({PityRules:zod.z.array(Ut).nullish()}).passthrough(),di=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Nh).nullish(),PityPresets:zod.z.record(zod.z.string(),jh).nullish()}).passthrough();var Fh=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),wa=zod.z.object({ServerTimeUtc:u,LootboxID:zod.z.string(),OpenedCount:zod.z.number().nullish(),SelectedOptionID:zod.z.string().nullish(),Resources:b.nullish(),Inventory:pt.nullish(),Results:zod.z.array(b).nullish(),TriggeredPity:zod.z.array(Fh).nullish()}),Vh=zod.z.object({RewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),_h=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),Wh=zod.z.object({LootboxID:zod.z.string(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),PriceOptions:J.nullish(),RewardSlots:zod.z.array(Ot).nullish(),PityRules:zod.z.array(Ut).nullish(),Presets:Vh.nullish(),RewardMultiplier:Yt.nullish(),SupplyLimits:zod.z.array(_h).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Ks=zod.z.object({Definitions:zod.z.record(zod.z.string(),Wh).nullish(),RewardPools:di.nullish()}).passthrough(),Aa=zod.z.object({LootboxDefinitions:Ks.nullish()}),hi={GetDefinitions:"GetDefinitions",Open:"Open"};var mi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(hi.GetDefinitions,e,Aa)}open(e){return this.send(hi.Open,e,wa)}};var Qh=zod.z.object({}).passthrough().transform(o=>o),Kh=zod.z.object({}).passthrough().transform(o=>o),Hh=zod.z.object({}).passthrough().transform(o=>o),$h=zod.z.object({}).passthrough().transform(o=>o),Zh=zod.z.object({}).passthrough().transform(o=>o),Oa=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:Qh,Resources:b.nullish()}),Ua=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Kh,Resources:b.nullish()}),Ba=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Hh,Resources:b.nullish()}),La=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:$h,Resources:b.nullish()}),qa=zod.z.object({Enabled:zod.z.boolean(),Multiplier:zod.z.number().nullish(),Progress:M.nullish(),Source:zod.z.string().nullish(),SourceKey:zod.z.string().nullish()}),Jh=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),Yh=zod.z.object({DayNumber:zod.z.number().nullish(),Rewards:L.nullish(),IsMilestone:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Xh=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(Yh).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:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),em=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),tm=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(em).nullish()}).passthrough(),rm=zod.z.object({MinCharacterLevel:zod.z.number().nullish(),RequirementsCharacterID:zod.z.string().nullish(),Gate:W.nullish(),RequiredItemIDs:zod.z.array(zod.z.string()).nullish(),RequiredEquippedItemIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),im=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:tm.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:rm.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),sm=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nm=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(sm).nullish(),ClaimCooldownSeconds:zod.z.number().nullish(),ClaimWindowSeconds:zod.z.number().nullish(),TrackPresenceOnRead:zod.z.boolean().nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),om=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(),am=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:L.nullish(),Limits:ge.nullish(),PremiumLimitOverrides:zod.z.array(om).nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),Hs=zod.z.object({TierRewards:Jh.nullish(),MilestoneRewardMultiplier:Yt.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Xh).nullish(),IdleAccruals:zod.z.record(zod.z.string(),im).nullish(),Comebacks:zod.z.record(zod.z.string(),nm).nullish(),Claims:zod.z.record(zod.z.string(),am).nullish()}).passthrough(),Ea=zod.z.object({RewardDefinitions:Hs.nullish()}),Ga=zod.z.object({Rewards:Zh.nullish()}),ot={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var fi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(ot.GetRewardDefinitions,e,Ea)}getUserRewardsState(e){return this.send(ot.GetUserRewardsState,e,Ga)}getMilestoneRewardMultiplier(e){return this.send(ot.GetMilestoneRewardMultiplier,e,qa)}claimDailyReward(e){return this.send(ot.ClaimDailyReward,e,Oa)}collectIdleAccrual(e){return this.send(ot.CollectIdleAccrual,e,Ua)}claimComebackReward(e){return this.send(ot.ClaimComebackReward,e,Ba)}claimReward(e){return this.send(ot.ClaimReward,e,La)}};var gi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(qe.GetTutorialDefinitions,e,Vn)}getUserTutorialState(e){return this.send(qe.GetUserTutorialState,e,Wn)}startFlow(e){return this.send(qe.StartFlow,e,ct)}reportStepShown(e){return this.send(qe.ReportStepShown,e,ct)}completeStep(e){return this.send(qe.CompleteStep,e,ct)}completeStepsBatch(e){return this.send(qe.CompleteStepsBatch,e,Kn)}skipStep(e){return this.send(qe.SkipStep,e,ct)}skipFlow(e){return this.send(qe.SkipFlow,e,ct)}claimFlowReward(e){return this.send(qe.ClaimFlowReward,e,Qn)}resetFlow(e){return this.send(qe.ResetFlow,e,ct)}};var Ri=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Localization",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket,throttleKey:t.Locale?`${i}:${t.Locale}`:i})}getLocalizationManifest(e){return this.send(ii.GetLocalizationManifest,e,fa)}getLocalizationTable(e){return this.send(ii.GetLocalizationTable,e,ga)}};var yi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(We.GetQuestDefinitions,e,er)}getUserQuestState(e){return this.send(We.GetUserQuestState,e,wn)}refreshQuestCycles(e){return this.send(We.RefreshQuestCycles,e,Te)}claimQuestReward(e){return this.send(We.ClaimQuestReward,e,cs)}claimQuestRewardsBatch(e){return this.send(We.ClaimQuestRewardsBatch,e,Un)}claimMilestoneReward(e){return this.send(We.ClaimMilestoneReward,e,ps)}claimMilestoneRewardsBatch(e){return this.send(We.ClaimMilestoneRewardsBatch,e,Bn)}claimGroupCompletionReward(e){return this.send(We.ClaimGroupCompletionReward,e,An)}addQuestProgress(e){return this.send(We.AddQuestProgress,e,On)}};var Na=zod.z.object({}).passthrough().transform(o=>o);var lm=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),um=zod.z.object({Schedule:zod.z.array(lm).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),cm=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(),pm=zod.z.object({Milestones:Y.nullish()}).passthrough(),$s=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:ft.nullish(),TokenSources:zod.z.array(Le).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),be).nullish(),Presets:pm.nullish(),BonusWindow:um.nullish()}).passthrough(),dm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:$s.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),hm=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:ce.nullish(),Content:$s.nullish(),Events:zod.z.array(dm).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),mm=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),fm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),Ci=zod.z.object({Definitions:zod.z.record(zod.z.string(),hm).nullish(),Settings:mm.nullish(),Presets:fm.nullish()}).passthrough(),gm=zod.z.object({Type:Gt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:$s.nullish(),Progress:Na.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:be.nullish(),BonusWindow:cm.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),ja=zod.z.object({ActiveEvents:zod.z.array(gm).nullish()}).passthrough(),Fa=zod.z.object({Tokens:zod.z.record(zod.z.string(),Na).nullish()}),Zs=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Js=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),Rm=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Ys=zod.z.array(ie(Js)),Va=zod.z.array(ie(Zs)),_a=zod.z.array(ie(Rm)),je={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Si=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(je.GetActiveEvents,e,ja)}getDefinitions(e){return this.send(je.GetDefinitions,e,Ci)}getUserLteState(e){return this.send(je.GetUserLteState,e,Fa)}grantTokens(e){return this.send(je.GrantTokens,e,b)}spendTokens(e){return this.send(je.SpendTokens,e,Zs)}claimMilestone(e){return this.send(je.ClaimMilestone,e,Js)}claimMilestonesBatch(e){return this.send(je.ClaimMilestonesBatch,e,Ys)}claimAllMilestones(e){return this.send(je.ClaimAllMilestones,e,Ys)}spendTokensBatch(e){return this.send(je.SpendTokensBatch,e,Va)}grantTokensBatch(e){return this.send(je.GrantTokensBatch,e,_a)}};var ym=zod.z.object({UserID:zod.z.string(),Score:M.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:ze.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),Vt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(ym).nullish(),BracketID:zod.z.string().nullish()}),Cm=zod.z.object({CycleKey:zod.z.string().nullish(),CycleEndUtc:u.nullish(),ClaimDeadlineUtc:u.nullish(),MilestoneTokensEarned:M.nullish(),ClaimableMilestoneIDs:zod.z.array(zod.z.string()).nullish(),CycleIndex:zod.z.number().nullish(),ChainedEventID:zod.z.string().nullish()}).passthrough(),xi=zod.z.object({LeaderboardID:zod.z.string(),CurrentScore:M.nullish(),LastKnownRank:zod.z.number().nullish(),HasUnclaimedReward:zod.z.boolean().nullish(),ScoreEarnedThisCycle:M.nullish(),MilestoneTokensEarned:M.nullish(),NextMilestone:be.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Cm).nullish()}),Di=zod.z.object({LeaderboardID:zod.z.string(),NewScore:M,CycleVersion:zod.z.number()}),bi=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),zi=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),Wa=zod.z.array(ie(Vt)),Qa=zod.z.array(ie(xi)),Ka=zod.z.array(ie(bi)),Ha=zod.z.array(ie(zi)),$a=zod.z.array(ie(Di)),Sm=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ie(bi).nullish(),Milestones:zod.z.array(ie(zi)).nullish()}),Za=zod.z.array(Sm),xm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ie(Vt).nullish(),Progress:ie(xi).nullish()}),Ja=zod.z.array(xm),Dm=zod.z.string(),Ya=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:ls.nullish()}).passthrough(),bm=zod.z.object({RankRewards:zod.z.array(Ya).nullish()}).passthrough(),zm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Tm=zod.z.object({Milestones:Y.nullish(),RankRewards:Y.nullish()}).passthrough(),vm=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:Dm.nullish(),Schedule:ce.nullish(),ChainEvents:zod.z.array(zm).nullish(),Gate:W.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(Ya).nullish(),Milestones:zod.z.record(zod.z.string(),be).nullish(),Presets:Tm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Le).nullish()}).passthrough(),Pm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),RankRewards:zod.z.record(zod.z.string(),bm).nullish()}).passthrough(),Ti=zod.z.object({Definitions:zod.z.record(zod.z.string(),vm).nullish(),Presets:Pm.nullish()}).passthrough(),De={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 vi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(De.GetDefinitions,e,Ti)}getLeaderboard(e){return this.send(De.GetLeaderboard,e,Vt)}getMyProgress(e){return this.send(De.GetMyProgress,e,xi)}submitScore(e){return this.send(De.SubmitScore,e,Di)}submitScoreFromSource(e){return this.send(De.SubmitScoreFromSource,e,Di)}claimCycleReward(e){return this.send(De.ClaimCycleReward,e,bi)}claimMilestone(e){return this.send(De.ClaimMilestone,e,zi)}getFriendsLeaderboard(e){return this.send(De.GetFriendsLeaderboard,e,Vt)}getLeaderboardsBatch(e){return this.send(De.GetLeaderboardsBatch,e,Wa)}getProgressBatch(e){return this.send(De.GetProgressBatch,e,Qa)}claimCycleRewardsBatch(e){return this.send(De.ClaimCycleRewardsBatch,e,Ka)}claimMilestonesBatch(e){return this.send(De.ClaimMilestonesBatch,e,Ha)}submitScoresBatch(e){return this.send(De.SubmitScoresBatch,e,$a)}claimAllRewardsBatch(e){return this.send(De.ClaimAllRewardsBatch,e,Za)}getOverviewBatch(e){return this.send(De.GetOverviewBatch,e,Ja)}};var Xs=zod.z.object({}).passthrough().transform(o=>o),Xa=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>il).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:M.nullish(),UserState:Xs.nullish(),NextTier:zod.z.lazy(()=>rl).nullish()}).passthrough(),el=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),AmountGranted:M.nullish(),NewStatusTokens:M.nullish(),OldTier:zod.z.number().nullish(),NewTier:zod.z.number(),TierUp:zod.z.boolean().nullish()}),en=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),tl=Je(en);var rl=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:M.nullish(),TierReachedReward:L.nullish()}).passthrough(),il=zod.z.object({SeasonID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:M.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(rl).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Im=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Seasons:zod.z.array(il).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:W.nullish()}).passthrough(),Pi=zod.z.object({Chains:zod.z.record(zod.z.string(),Im).nullish()}).passthrough(),ht={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Ii=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ht.GetDefinitions,e,Pi)}getActiveSeason(e){return this.send(ht.GetActiveSeason,e,Xa)}getUserState(e){return this.send(ht.GetUserState,e,Xs)}grantStatusTokens(e){return this.send(ht.GrantStatusTokens,e,el)}claimTierReward(e){return this.send(ht.ClaimTierReward,e,en)}claimTierRewardsBatch(e){return this.send(ht.ClaimTierRewardsBatch,e,tl)}};var km={Apple:"Apple",Google:"Google"},sl=zod.z.object({}).passthrough().transform(o=>o),Mm=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(),wm=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:J.nullish(),Benefits:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),tn=zod.z.object({Definitions:zod.z.record(zod.z.string(),wm).nullish()}).passthrough(),nl=zod.z.object({Premium:tn.nullish()}),ol=zod.z.object({ServerTimeUtc:u.nullish(),Premium:sl.nullish()}),ki=zod.z.object({ServerTimeUtc:u.nullish(),Premium:sl.nullish(),Subscription:Mm.nullish(),Resources:b.nullish()}),Rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Mi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Rt.GetDefinitions,e,nl)}getUserState(e){return this.send(Rt.GetUserState,e,ol)}activateTrial(e){return this.send(Rt.ActivateTrial,e,ki)}purchaseItemOrCurrency(e){return this.send(Rt.PurchaseWithResources,e,ki)}purchaseRealMoney(e){return this.send(Rt.PurchaseRealMoney,e,ki)}};var wi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Ae.GetCharacterDefinitions,e,Kr)}getUserCharacters(e){return this.send(Ae.GetUserCharacters,e,Co)}unlockCharacter(e){return this.send(Ae.UnlockCharacter,e,Is)}upgradeStatLevel(e){return this.send(Ae.UpgradeStatLevel,e,vs)}upgradeCharacterLevel(e){return this.send(Ae.UpgradeCharacterLevel,e,Ps)}equipItems(e){return this.send(Ae.EquipItems,e,So)}unequipItems(e){return this.send(Ae.UnequipItems,e,xo)}unequipAllCharacters(e){return this.send(Ae.UnequipAllCharacters,e,Do)}unlockCharactersBatch(e){return this.send(Ae.UnlockCharactersBatch,e,bo)}upgradeCharacterLevelsBatch(e){return this.send(Ae.UpgradeCharacterLevelsBatch,e,zo)}upgradeStatLevelsBatch(e){return this.send(Ae.UpgradeStatLevelsBatch,e,To)}};var Ai=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Xe.CreateMatch,e,$o)}updateMatch(e){return this.send(Xe.UpdateMatch,e,Zo)}cancelMatch(e){return this.send(Xe.CancelMatch,e,Jo)}instantBattle(e){return this.send(Xe.InstantBattle,e,Yo)}saveStrategy(e){return this.send(Xe.SaveStrategy,e,Te)}getMyMatches(e){return this.send(Xe.GetMyMatches,e,Bs)}getAvailableMatches(e){return this.send(Xe.GetAvailableMatches,e,Bs)}getDefinitions(e){return this.send(Xe.GetDefinitions,e,ra)}};var Am={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},al=zod.z.enum(["TradeUpRarity","TradeUpCollection"]),Om=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:as.nullish()}),ll=zod.z.object({ServerTimeUtc:u,Type:al.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:b.nullish(),Results:zod.z.array(Om).nullish()}),Um=zod.z.object({CraftID:zod.z.string().nullish(),Type:al.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:J.nullish()}).passthrough(),rn=zod.z.object({Definitions:zod.z.record(zod.z.string(),Um).nullish()}).passthrough(),ul=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:rn.nullish()}),Oi={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Ui=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Oi.GetDefinitions,e,ul)}craft(e){return this.send(Oi.Craft,e,ll)}};var Bm={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Lm=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),cl=zod.z.object({}).passthrough().transform(o=>o),Bt=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()}),pl=zod.z.object({GrantedCollectibles:zod.z.array(Bt).nullish(),DuplicateCollectibles:zod.z.array(Bt).nullish(),CollectionCurrencyEarned:M.nullish()}),dl=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(pl).nullish(),GrantedCollectibles:zod.z.array(Bt).nullish(),DuplicateCollectibles:zod.z.array(Bt).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),NewlyCompletedSetIDs:zod.z.array(zod.z.string()).nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),hl=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(pl).nullish(),GrantedCollectibles:zod.z.array(Bt).nullish(),DuplicateCollectibles:zod.z.array(Bt).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),ml=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),sn=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),fl=zod.z.array(ie(sn)),gl=zod.z.object({Resources:b.nullish()}),qm=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:Lm.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(),Rl=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),yl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Cl=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()}),Sl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),nn=zod.z.object({Offers:zod.z.array(qm).nullish()}),Em=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(),Gm=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(Em).nullish(),SetCompletionReward:L.nullish()}).passthrough(),Nm=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(Gm).nullish(),GrandPrize:L.nullish()}).passthrough(),xl=zod.z.object({BonusRewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),jm=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:J.nullish(),BonusRewardSlots:zod.z.array(Ot).nullish(),PityRules:zod.z.array(Ut).nullish(),Presets:xl.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(),Fm=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Vm=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(Ot).nullish(),PityRules:zod.z.array(Ut).nullish(),Presets:xl.nullish(),Tier:zod.z.number().nullish()}).passthrough(),_m=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(),Bi=zod.z.object({Collections:zod.z.record(zod.z.string(),Nm).nullish(),PackTypes:zod.z.record(zod.z.string(),jm).nullish(),CollectionChests:zod.z.array(Vm).nullish(),DuplicateConversions:zod.z.array(Fm).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(_m).nullish(),RewardPools:di.nullish()}).passthrough(),ve={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 Li=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ve.GetDefinitions,e,Bi)}getUserState(e){return this.send(ve.GetUserState,e,cl)}openPack(e){return this.send(ve.OpenPack,e,dl)}openCollectionChest(e){return this.send(ve.OpenCollectionChest,e,hl)}useCollectibleJoker(e){return this.send(ve.UseCollectibleJoker,e,ml)}claimSetReward(e){return this.send(ve.ClaimSetReward,e,sn)}claimSetRewardsBatch(e){return this.send(ve.ClaimSetRewardsBatch,e,fl)}claimGrandPrize(e){return this.send(ve.ClaimGrandPrize,e,gl)}sendTradeOffer(e){return this.send(ve.SendTradeOffer,e,Rl)}cancelTradeOffer(e){return this.send(ve.CancelTradeOffer,e,yl)}acceptTradeOffer(e){return this.send(ve.AcceptTradeOffer,e,Cl)}declineTradeOffer(e){return this.send(ve.DeclineTradeOffer,e,Sl)}getMyTradeOffers(e){return this.send(ve.GetMyTradeOffers,e,nn)}getIncomingTradeOffers(e){return this.send(ve.GetIncomingTradeOffers,e,nn)}};var Wm=zod.z.object({}).passthrough().transform(o=>o),Qm={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Km={Active:"Active",Left:"Left",Replaced:"Replaced"},Hm=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),$m=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),BuildObjectsProgress:Hm.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(),Zm=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(),Jm=zod.z.object({Objects:zod.z.array(Zm).nullish()}).passthrough(),Dl=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($m).nullish(),BuildObjectsState:Jm.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),bl=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),Ym=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(),Xm=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:L.nullish()}).passthrough(),ef=zod.z.object({Objects:zod.z.array(Xm).nullish(),PriceOptions:J.nullish(),SpinnerTable:zod.z.array(on).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),tf=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:Ym.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:ef.nullish(),GrandPrize:L.nullish()}).passthrough(),rf=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Events:zod.z.array(tf).nullish(),Gate:W.nullish()}).passthrough(),zl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Wm.nullish(),ActiveGroup:Dl.nullish()}),an=zod.z.object({ServerTimeUtc:u.nullish(),Group:Dl.nullish(),SecondsRemaining:M.nullish()}),Tl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.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:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),ln=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),vl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),qi=zod.z.object({Chains:zod.z.record(zod.z.string(),rf).nullish()}).passthrough(),Ke={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Ei=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ke.GetDefinitions,e,qi)}getActiveEvent(e){return this.send(Ke.GetActiveEvent,e,bl)}getUserState(e){return this.send(Ke.GetUserState,e,zl)}getGroupState(e){return this.send(Ke.GetGroupState,e,an)}joinOrCreateGroup(e){return this.send(Ke.JoinOrCreateGroup,e,an)}spin(e){return this.send(Ke.Spin,e,Tl)}claimObjectReward(e){return this.send(Ke.ClaimObjectReward,e,ln)}claimGrandPrize(e){return this.send(Ke.ClaimGrandPrize,e,ln)}leaveGroup(e){return this.send(Ke.LeaveGroup,e,vl)}};var sf={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},nf={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},of=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(),af=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Pl=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(),of).nullish(),Tracks:zod.z.record(zod.z.string(),af).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),lf=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:Pl.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),uf=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),cf=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(),uf).nullish()}).passthrough(),pf=zod.z.object({Slots:zod.z.record(zod.z.string(),lf).nullish(),OfferHistory:zod.z.record(zod.z.string(),cf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var df=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),hf=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(df).nullish(),Schedule:ce.nullish(),Gate:W.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),mf=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:J.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),ff=zod.z.object({AdPlacementID:zod.z.string().nullish(),ViewsRequiredToComplete:zod.z.number().nullish(),MaxViewsPerActivation:zod.z.number().nullish(),CooldownSecondsBetweenViews:zod.z.number().nullish(),RequireServerVerification:zod.z.boolean().nullish(),GrantRewardsPerView:zod.z.boolean().nullish()}).passthrough(),gf=zod.z.object({Purchase:mf.nullish(),RewardedVideo:ff.nullish()}).passthrough(),Rf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),yf=zod.z.object({Milestones:Y.nullish()}).passthrough(),Cf=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Sf=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(),xf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Rf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),Df=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:gf.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(Cf).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:xf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ge.nullish(),HideWhenCompleted:zod.z.boolean().nullish(),ExhaustOfferOnComplete:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Il=zod.z.object({OfferID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Enabled:zod.z.boolean().nullish(),GraphMode:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),RootNodeIDs:zod.z.array(zod.z.string()).nullish(),Nodes:zod.z.array(Df).nullish(),Tracks:zod.z.array(Sf).nullish(),Milestones:zod.z.record(zod.z.string(),be).nullish(),Presets:yf.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:ft.nullish(),ExhaustedWhenAllTerminalNodesCompleted:zod.z.boolean().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Metadata:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),bf=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),un=zod.z.object({Slots:zod.z.record(zod.z.string(),hf).nullish(),Offers:zod.z.record(zod.z.string(),Il).nullish(),Presets:bf.nullish()}).passthrough(),kl=zod.z.object({DealOfferDefinitions:un.nullish()}),Ml=zod.z.object({DealOffers:pf.nullish()}),zf=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(),Tf=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:Il.nullish(),ActivationState:Pl.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:Nt.nullish(),Milestone:zf.nullish()}).passthrough(),wl=zod.z.object({Slots:zod.z.array(Tf).nullish()}),Al=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:b.nullish()}),Ol=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Ul=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Bl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),Ll=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:b.nullish()}),et={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var Gi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(et.GetDefinition,e,kl)}getUserState(e){return this.send(et.GetUserState,e,Ml)}getActiveDeals(e){return this.send(et.GetActiveDeals,e,wl)}dismissDeal(e){return this.send(et.DismissDeal,e,Ol)}executeNode(e){return this.send(et.ExecuteNode,e,Al)}recordShow(e){return this.send(et.RecordShow,e,Ul)}claimMilestone(e){return this.send(et.ClaimMilestone,e,Bl)}claimMilestonesBatch(e){return this.send(et.ClaimMilestonesBatch,e,Ll)}};var vf=zod.z.object({}).passthrough().transform(o=>o),Pf=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Percent:zod.z.number().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish()}).passthrough(),cn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),be).nullish(),SpendRewards:zod.z.array(Pf).nullish()}).passthrough(),ql=zod.z.object({ReferralDefinitions:cn.nullish()}),El=zod.z.object({Referral:vf.nullish()}),Gl=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}),pn=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}),Nl=Je(pn),yt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Ni=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(yt.GetDefinitions,e,ql)}getUserState(e){return this.send(yt.GetUserState,e,El)}activateReferralCode(e){return this.send(yt.ActivateReferralCode,e,Gl)}claimInviteReward(e){return this.send(yt.ClaimInviteReward,e,pn)}claimInviteRewardsBatch(e){return this.send(yt.ClaimInviteRewardsBatch,e,Nl)}};var If={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},kf={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},jl=zod.z.object({UserID:zod.z.string(),PublicData:ze.nullish()}),Mf=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:b.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),ji=zod.z.object({Friends:zod.z.array(jl).nullish()}),wf=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),_t=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:jl.nullish(),Counters:wf.nullish()}),Fl=zod.z.object({Events:zod.z.array(Mf).nullish()}),tt={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Fi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(tt.GetFriendsList,e,ji)}getIncomingRequests(e){return this.send(tt.GetIncomingRequests,e,ji)}getRecommendedFriends(e){return this.send(tt.GetRecommendedFriends,e,ji)}sendFriendRequest(e){return this.send(tt.SendFriendRequest,e,_t)}acceptFriendRequest(e){return this.send(tt.AcceptFriendRequest,e,_t)}declineFriendRequest(e){return this.send(tt.DeclineFriendRequest,e,_t)}removeFriend(e){return this.send(tt.RemoveFriend,e,_t)}getTimeline(e){return this.send(tt.GetTimeline,e,Fl)}};var Af={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Lt=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Of=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:J.nullish(),Effect:Lt.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(),Uf=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:ce.nullish(),Effects:zod.z.array(Lt).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Bf=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Lt).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Lf=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:ce.nullish(),Phases:zod.z.array(Bf).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),qf=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(Le).nullish(),Effects:zod.z.array(Lt).nullish(),DurationSeconds:zod.z.number().nullish(),Charges:zod.z.number().nullish(),StackingPolicy:zod.z.string().nullish(),MaxActiveInstances:zod.z.number().nullish(),Gate:W.nullish()}).passthrough(),Ef=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Gf=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),Ef).nullish()}).passthrough(),Vi=zod.z.object({Definitions:zod.z.record(zod.z.string(),Of).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),Uf).nullish(),BoostChains:zod.z.record(zod.z.string(),Lf).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),qf).nullish(),Settings:Gf.nullish()}).passthrough(),Vl=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Lt.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 _l=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),Vl).nullish()}),Wl=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:Vl.nullish(),Resources:b.nullish()}),Nf={Scheduled:"Scheduled",Chain:"Chain"},jf=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(Lt).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ql=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(jf).nullish()}),Ct={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var _i=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ct.GetDefinitions,e,Vi)}getActive(e){return this.send(Ct.GetActive,e,_l)}getActiveWindows(e){return this.send(Ct.GetActiveWindows,e,Ql)}activate(e){return this.send(Ct.Activate,e,Wl)}cleanupExpired(e){return this.send(Ct.CleanupExpired,e,Te)}};var Wi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Qe.GetUserCustomDataDefinitions,e,Gr)}getMyUserCustomData(e){return this.send(Qe.GetMyUserCustomData,e,no)}getPublicUserCustomDataOf(e){return this.send(Qe.GetPublicUserCustomDataOf,e,xs)}setPrivateData(e){return this.send(Qe.SetPrivateData,e,Ds)}setPublicData(e){return this.send(Qe.SetPublicData,e,Ds)}deleteKey(e){return this.send(Qe.DeleteKey,e,Te)}batchSet(e){return this.send(Qe.BatchSet,e,oo)}batchDelete(e){return this.send(Qe.BatchDelete,e,ao)}batchGetPublicUserCustomDataOf(e){return this.send(Qe.BatchGetPublicUserCustomDataOf,e,lo)}};var Ff={Static:"Static",Runtime:"Runtime"},Vf={Public:"Public",Private:"Private"},_f=zod.z.enum(["Client","Server","System"]),Wf=zod.z.enum(["String","Int","Bool","Json"]),Qf=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:_f.nullish(),ExpiresAt:u.nullish()}).passthrough(),Kl=zod.z.record(zod.z.string(),Qf),dn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Kl.nullish(),Runtime:Kl.nullish(),NotModified:zod.z.boolean().nullish()}),Kf=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).nullish(),Bucket:zod.z.enum(["Public","Private"]).nullish(),ValueType:Wf.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Qi=zod.z.object({Keys:zod.z.record(zod.z.string(),Kf).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(),Wt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Ki=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(Wt.GetTitleCustomDataDefinitions,e,Qi)}getPublicTitleData(e){return this.send(Wt.GetPublicTitleData,e,dn)}getPublicTitleDataKeys(e){return this.send(Wt.GetPublicTitleDataKeys,e,dn)}};var Hf={Fast:"Fast",Sequential:"Sequential"},$f={Instant:"Instant",Timed:"Timed"},Zf={Hit:"Hit",Blocked:"Blocked"},Jf=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Yf=zod.z.object({Symbol:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:zod.z.string().nullish()}).passthrough();zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:L.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 Hl=zod.z.object({}).passthrough().transform(o=>o),$l=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Me=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),Xf=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),eg=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(),tg=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:fe.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(),rg=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:fe.nullish()}).passthrough(),Zl=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:L.nullish()}).passthrough(),ig=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(),sg=zod.z.object({Tiles:zod.z.record(zod.z.string(),ig).nullish()}).passthrough(),ng=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Me.nullish(),Tag:zod.z.string().nullish()}).passthrough(),og=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(ng).nullish(),GuaranteedBonus:Me.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),ag=zod.z.object({Variants:zod.z.array(og).nullish()}).passthrough(),lg=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Me.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),ug=zod.z.object({Outcomes:zod.z.array(lg).nullish()}).passthrough(),Jl=zod.z.object({PerAdMultiplierRange:$l.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),cg=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Me.nullish()}).passthrough(),pg=zod.z.object({Tiers:zod.z.array(cg).nullish(),BelowFirstTierReward:Me.nullish()}).passthrough(),dg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Me.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:Jl.nullish(),Gradation:pg.nullish()}).passthrough(),hg=zod.z.object({Choices:zod.z.array(dg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),mg=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Me.nullish(),Tag:zod.z.string().nullish()}).passthrough(),fg=zod.z.object({OnPassStart:Me.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Me).nullish(),OnAttack:zod.z.record(zod.z.string(),Me).nullish(),OnRaid:zod.z.record(zod.z.string(),Me).nullish(),OnBuild:Me.nullish(),OnStageComplete:Me.nullish(),OnAttackBonusDrops:zod.z.array(mg).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),ug).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),hg).nullish()}).passthrough(),Yl=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Zl).nullish(),HeistGridBonusConfig:ag.nullish(),StageOperations:fg.nullish(),TileLandingMultiplier:$l.nullish(),EconomyOverride:rg.nullish()}).passthrough(),gg=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(Zl).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:Yl.nullish()}).passthrough(),Hi=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(),sg).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),Yl).nullish(),StagesByLevel:zod.z.record(zod.z.string(),gg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:tg.nullish(),Dice:Xf.nullish(),Bots:eg.nullish()}).passthrough(),Rg=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(),be).nullish(),GrandPrize:L.nullish()}).passthrough(),$i=zod.z.object({Board:Hi.nullish(),CommunityChest:Rg.nullish()}).passthrough(),yg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:ze.nullish(),TargetBuildingStates:zod.z.array(Jf).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Cg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Me.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:Jl.nullish()}).passthrough(),Sg=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Cg).nullish()}).passthrough(),xg=zod.z.object({GroupID:zod.z.string().nullish(),Delta:M.nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),UnlockedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),Completed:zod.z.boolean().nullish()}).passthrough(),Xl=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:yg.nullish(),SpecialModeOffer:Sg.nullish(),CommunityChestContribution:xg.nullish()}).passthrough(),eu=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:b.nullish(),DualResult:mt.nullish()}).passthrough(),hn=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:L.nullish(),OpenedIndex:zod.z.number().nullish(),AttemptsLeft:zod.z.number().nullish(),RaidLayout:zod.z.array(Yf).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:mt.nullish()}).passthrough(),tu=zod.z.object({BuiltIndex:zod.z.number(),NewLevel:zod.z.number().nullish(),StageComplete:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),ru=zod.z.object({Mode:zod.z.union([zod.z.string(),zod.z.number()]).nullish(),Operation:b.nullish(),DurationSeconds:zod.z.number().nullish(),StartedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish()}).passthrough(),iu=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),su=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),Operation:b.nullish()}).passthrough(),Dg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},nu=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]),bg={Active:"Active",Left:"Left",Replaced:"Replaced"},zg=zod.z.enum(["Active","Left","Replaced"]),Tg=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),vg=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:zg.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),ou=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(vg).nullish(),SharedProgress:Tg.nullish(),Status:nu.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Pg=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:nu.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),Ig=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Pg).nullish()}).passthrough(),au=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Ig.nullish(),ActiveGroup:ou.nullish(),SecondsRemaining:M.nullish()}),lu=zod.z.object({ServerTimeUtc:u.nullish(),Group:ou.nullish(),SecondsRemaining:M.nullish()}),mn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),uu=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Se={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 kg=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(),Mg=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:ce.nullish(),Gate:W.nullish(),Variants:zod.z.array(kg).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(),cu=zod.z.object({Experiments:zod.z.record(zod.z.string(),Mg).nullish()}).passthrough();var wg={Mesh:"Mesh",Host:"Host"},fn=zod.z.enum(["Mesh","Host"]),Ag={ServerRelay:"ServerRelay",P2P:"P2P"},gn=zod.z.enum(["ServerRelay","P2P"]),Og={Public:"Public",Private:"Private"},Ug=zod.z.enum(["Public","Private"]),Bg={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Lg=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),pu=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),qg=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),du=zod.z.object({SystemState:qg.nullish(),DefaultTopology:fn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:gn.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(pu).nullish()}).passthrough(),Eg=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(),Gg=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:fn.nullish(),ChatMode:gn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),Ng=zod.z.object({Seq:zod.z.number().nullish(),Type:Lg.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(),Zi=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:gn.nullish(),Visibility:Ug.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Eg).nullish(),IceServers:zod.z.array(pu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),Rn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),hu=zod.z.object({Rooms:zod.z.array(Gg).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),mu=zod.z.object({Envelopes:zod.z.array(Ng).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Ji=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Fe={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var yn=zod.z.object({TitleCustomData:Qi.nullish(),Character:Kr.nullish(),Item:ai.nullish(),Currency:Qr.nullish(),Store:ui.nullish(),Lootbox:Ks.nullish(),Quest:er.nullish(),TimedEvent:Ci.nullish(),Leaderboard:Ti.nullish(),Season:Pi.nullish(),Reward:Hs.nullish(),Collection:Bi.nullish(),Craft:rn.nullish(),DealOffer:un.nullish(),Premium:tn.nullish(),TimedBoost:Vi.nullish(),CoopEvent:qi.nullish(),GameLoop:$i.nullish(),Match:qs.nullish(),Experiment:cu.nullish(),Blockchain:Ms.nullish(),Marketplace:js.nullish(),Multiplayer:du.nullish(),UserCustomData:Gr.nullish(),Referral:cn.nullish(),Localization:ha.nullish()}).passthrough();var St={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Yi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(St.GetTitlePublicConfiguration,e,yn)}getTitlePublicConfigurationExcept(e){return this.send(St.GetTitlePublicConfigurationExcept,e,yn)}getCurrencyDefinitions(e){return this.send(St.GetCurrencyDefinitions,e,Qr)}getItemDefinitions(e){return this.send(St.GetItemDefinitions,e,ai)}getServerTime(e){return this.send(St.GetServerTime,e,Te)}};var Xi=class{constructor(e){this.ctx=e;}ctx;send(e,t,r,i=false){let s=A(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(s,t,r,{ticket:t.ClientSessionTicket,silent:i})}getGameLoops(e){return this.send(Se.GetGameLoops,e,$i)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,Hi,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,Hi,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,Hl)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,Xl)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,eu)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,hn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,hn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,tu)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,ru)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,iu)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,su)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,au)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,lu)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,mn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,mn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,uu)}};var Qt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Qt),zod.z.record(zod.z.string(),Qt)]));var Fg={Live:"Live",Latest:"Latest",Specific:"Specific"},Vg={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},_g=zod.z.enum(["Debug","Info","Warning","Error"]),Wg={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"},Qg=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),Kg=zod.z.object({Level:_g,Message:zod.z.string().nullish(),Data:Qt.nullish()}),Hg=zod.z.object({Error:Qg,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),fu=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Qt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(Kg).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:Hg.nullish()}),Cn={Execute:"Execute"};var es=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=A(this.ctx.settings.titleID,"CloudCode",Cn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,fu,{ticket:e.ClientSessionTicket})}};var ts=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Oe.GetDefinitions,e,Lo)}getUserState(e){return this.send(Oe.GetUserState,e,qo)}depositToken(e){return this.send(Oe.DepositToken,e,Eo)}depositNFT(e){return this.send(Oe.DepositNFT,e,Go)}requestTokenWithdrawal(e){return this.send(Oe.RequestTokenWithdrawal,e,No)}requestNFTWithdrawal(e){return this.send(Oe.RequestNFTWithdrawal,e,jo)}getTransactionHistory(e){return this.send(Oe.GetTransactionHistory,e,Fo)}retryWithdrawal(e){return this.send(Oe.RetryWithdrawal,e,Vo)}confirmWithdrawal(e){return this.send(Oe.ConfirmWithdrawal,e,_o)}donateToDeveloper(e){return this.send(Oe.DonateToDeveloper,e,Os)}donateToUsersPool(e){return this.send(Oe.DonateToUsersPool,e,Os)}};var rs=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ae.GetDefinitions,e,sa)}getGroupedOffers(e){return this.send(ae.GetGroupedOffers,e,na)}getOffersByItem(e){return this.send(ae.GetOffersByItem,e,Fs)}getOffer(e){return this.send(ae.GetOffer,e,oa)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Fs)}getMyState(e){return this.send(ae.GetMyState,e,la)}getHistory(e){return this.send(ae.GetHistory,e,ua)}createListing(e){return this.send(ae.CreateListing,e,Ft)}cancelListing(e){return this.send(ae.CancelListing,e,Ge)}buy(e){return this.send(ae.Buy,e,Ge)}marketBuy(e){return this.send(ae.MarketBuy,e,Ge)}marketSell(e){return this.send(ae.MarketSell,e,Ge)}createAuction(e){return this.send(ae.CreateAuction,e,Ft)}placeBid(e){return this.send(ae.PlaceBid,e,aa)}claimAuction(e){return this.send(ae.ClaimAuction,e,Ge)}createBuyOrder(e){return this.send(ae.CreateBuyOrder,e,Ft)}cancelBuyOrder(e){return this.send(ae.CancelBuyOrder,e,Ge)}fillBuyOrder(e){return this.send(ae.FillBuyOrder,e,Ge)}createDirectTrade(e){return this.send(ae.CreateDirectTrade,e,Ft)}respondDirectTrade(e){return this.send(ae.RespondDirectTrade,e,Ge)}cancelDirectTrade(e){return this.send(ae.CancelDirectTrade,e,Ge)}claimBack(e){return this.send(ae.ClaimBack,e,Ge)}};var is=class{constructor(e){this.ctx=e;}ctx;send(e,t,r){let i=A(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(i,t,r,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Fe.CreateRoom,e,Zi)}joinRoom(e){return this.send(Fe.JoinRoom,e,Zi)}leaveRoom(e){return this.send(Fe.LeaveRoom,e,Rn)}listRooms(e){return this.send(Fe.ListRooms,e,hu)}getRoom(e){return this.send(Fe.GetRoom,e,Zi)}closeRoom(e){return this.send(Fe.CloseRoom,e,Rn)}poll(e){return this.send(Fe.Poll,e,mu)}sendSignal(e){return this.send(Fe.SendSignal,e,Ji)}sendChat(e){return this.send(Fe.SendChat,e,Ji)}setMemberState(e){return this.send(Fe.SetMemberState,e,Ji)}};var ss=class{settings;emitter;platform;clientPlatform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;purchase;checkout;lootbox;reward;quest;tutorial;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=zn(e),this.emitter=new Et,this.platform=e.platform??new zt,this.clientPlatform=e.clientPlatform??Pn(),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new ir({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new ar(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:r})=>{this.userService.noteStateVersions(t,r);}),this.authStore=new lr(this.platform.storage,this.settings.titleID),this.api={authentication:new ri(this),user:new si(this),currency:new ni(this),item:new li(this),store:new ci(this),purchase:new pi(this),lootbox:new mi(this),reward:new fi(this),quest:new yi(this),tutorial:new gi(this),localization:new Ri(this),timedEvent:new Si(this),leaderboard:new vi(this),season:new Ii(this),premium:new Mi(this),character:new wi(this),match:new Ai(this),craft:new Ui(this),collection:new Li(this),coopEvent:new Ei(this),dealOffer:new Gi(this),referral:new Ni(this),social:new Fi(this),timedBoost:new _i(this),userCustomData:new Wi(this),titleCustomData:new Ki(this),title:new Yi(this),gameLoop:new Xi(this),cloudCode:new es(this),blockchain:new ts(this),marketplace:new rs(this),multiplayer:new is(this)},this.userService=new dr(this),this.auth=new ur(this),this.currency=new mr(this),this.item=new fr(this),this.store=new gr(this),this.purchase=new Rr(this),this.checkout=new yr(this),this.lootbox=new Cr(this),this.reward=new Sr(this),this.quest=new zr(this),this.tutorial=new xr(this),this.localization=new br(this),this.timedEvent=new Tr(this),this.leaderboard=new vr(this),this.season=new Pr(this),this.premium=new Ir(this),this.character=new kr(this),this.match=new Mr(this),this.craft=new wr(this),this.collection=new Ar(this),this.coopEvent=new Or(this),this.dealOffer=new Ur(this),this.referral=new Br(this),this.social=new Lr(this),this.timedBoost=new qr(this),this.userCustomData=new Nr(this),this.titleCustomData=new jr(this),this.title=new Fr(this),this.gameLoop=new Vr(this),this.cloudCode=new _r(this),this.blockchain=new Zr(this),this.marketplace=new ei(this),this.multiplayer=new ti(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:P()}}};var ns=class{ctx;constructor(e){this.ctx=new ss(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 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 $g(o){return new ns(o)}var gu="idos_sso",Ru="state",Sn="idos:sso:state",Zg="https://idosgames.com/sso/";function Jg(){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(gu);if(!t)return null;let r=e.get(Ru)??"",i=rR();return sR(e),iR(),i&&r!==i?null:{code:t,state:r}}function Yg(o){if(typeof window>"u")return;let e=o.returnTo??Xg(),t=eR();tR(t);let r=new URL(o.ssoUrl??Zg);r.searchParams.set("title",o.titleID),r.searchParams.set("return_to",e),r.searchParams.set("state",t),window.location.assign(r.toString());}function Xg(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function eR(){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 tR(o){try{window.sessionStorage.setItem(Sn,o);}catch{}}function rR(){try{return window.sessionStorage.getItem(Sn)}catch{return null}}function iR(){try{window.sessionStorage.removeItem(Sn);}catch{}}function sR(o){o.delete(gu),o.delete(Ru);let e=o.toString(),{pathname:t,search:r}=window.location;window.history.replaceState(null,"",`${t}${r}${e?`#${e}`:""}`);}function nR(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function oR(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function aR(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Cu(o,e,t,r=1){if(!o)return e;let i=o.Base??e,s=Math.max(0,t-r),a;switch(o.Shape??"Flat"){case "PerStep":a=i+(o.PerStep??0)*s;break;case "PerStepRate":a=i*(1+(o.PerStepRate??0)*s);break;case "Geometric":a=i*Math.pow(1+(o.GrowthRate??0),s);break;case "Table":a=i*yu(o,t,1);break;case "TableAbsolute":a=yu(o,t,i);break;default:a=i;break}return Number.isNaN(a)?i:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function lR(o,e,t=1){return Cu(o,1,e,t)}function uR(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 Su(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function cR(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 Su(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 yu(o,e,t){let r=Su(o.Points);if(r.length===0)return t;let i=null,s=null,a=null;for(let p of r)(a===null||p.AtStep>a.AtStep)&&(a=p),p.AtStep<=e&&(i===null||p.AtStep>=i.AtStep)&&(i=p),p.AtStep>e&&(s===null||p.AtStep<s.AtStep)&&(s=p);if(i===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-i.AtStep)/(s.AtStep-i.AtStep);return i.Value+p*(s.Value-i.Value)}case "Geometric":{if(i.Value<=0||s.Value<=0){let D=(e-i.AtStep)/(s.AtStep-i.AtStep);return i.Value+D*(s.Value-i.Value)}let p=(e-i.AtStep)/(s.AtStep-i.AtStep);return i.Value*Math.pow(s.Value/i.Value,p)}default:return i.Value}}var pR={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},xn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),dR={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},hR=zod.z.enum(["Top","Bottom","Left","Right"]),mR=zod.z.object({PlacementID:zod.z.string().nullish(),Type:xn.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(),fR=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(),gR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),RR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:hR.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),yR=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),CR=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),SR=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(),xR=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(),DR=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(),bR=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:xn.nullish()}).passthrough(),zR={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},TR=zod.z.enum(["AppLovinMax","LevelPlay"]),vR=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:TR.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(),bR).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),mR).nullish(),Providers:zod.z.record(zod.z.string(),vR).nullish(),RewardedVideo:fR.nullish(),Interstitial:gR.nullish(),Banner:RR.nullish(),AppOpen:yR.nullish(),FrequencyCapping:CR.nullish(),PremiumAdReductions:zod.z.array(SR).nullish(),Consent:xR.nullish(),Verification:DR.nullish()}).passthrough();var PR=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),IR=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(),kR=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(),MR=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(),wR=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(),AR=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:xn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),OR=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:PR.nullish(),Placements:zod.z.record(zod.z.string(),IR).nullish(),Daily:kR.nullish(),Session:MR.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:wR.nullish(),PendingRequests:zod.z.record(zod.z.string(),AR).nullish(),FraudFlags:OR.nullish(),UpdatedAt:u.nullish()}).passthrough();var UR={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},BR=zod.z.enum(["Unread","Read","Deleted","Expired"]),LR={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},qR=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),ER={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},GR=zod.z.enum(["Active","Paused","Cancelled","Completed"]),NR=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(),jR=zod.z.object({SegmentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Gate:W.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(),NR).nullish(),Segments:zod.z.array(jR).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:qR.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:L.nullish(),Claimed:zod.z.boolean().nullish(),ClaimedAtUtc:u.nullish(),Status:BR.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:L.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:GR.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 xu="idos_device_id",os=class{storage;constructor(e=new Dt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(xu);return e||(e="noop-device",this.storage.setString(xu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
|
|
2
|
+
exports.AdProviderKind=zR;exports.AdType=pR;exports.AttackOutcome=Zf;exports.AuthType=me;exports.AuthenticationAction=Ue;exports.BannerPosition=dR;exports.BlockchainAction=Oe;exports.BlockchainNetworkType=Kp;exports.BlockchainOperationCategory=wo;exports.BlockchainTransactionStatus=rd;exports.BlockchainTransactionType=Jp;exports.BodyPart=vd;exports.BoostWindowKind=Nf;exports.BroadcastStatus=ER;exports.BrowserPlatformAdapter=zt;exports.BrowserStorage=xt;exports.CharacterAction=Ae;exports.ClientPlatform=Ze;exports.CloudCodeAction=Cn;exports.CloudCodeErrorCode=Wg;exports.CloudCodeLogLevel=Vg;exports.CloudCodeRevisionSelection=Fg;exports.CollectionAction=ve;exports.CommissionSink=Wd;exports.CommunityChestMemberStatus=bg;exports.CommunityChestStatus=Dg;exports.ConversionRateMode=bp;exports.CoopEventAction=Ke;exports.CoopGroupStatus=Qm;exports.CoopMemberStatus=Km;exports.CraftAction=Oi;exports.CraftType=Am;exports.CurrencyAction=Wr;exports.CurrencyStatus=Dp;exports.CurrencyType=Ve;exports.CurveInterpolation=Fu;exports.CurveShape=Nu;exports.CustomDataBucket=it;exports.CustomDataValueType=dp;exports.CustomDataWriter=lp;exports.DEFAULT_BASE_URL=bn;exports.DealNodeRuntimeStatus=nf;exports.DealOfferAction=et;exports.DealOfferActivationStatus=sf;exports.EnvelopeType=Bg;exports.EventTokenType=Pu;exports.FodderSelectionMode=gh;exports.FodderValuationMode=mh;exports.FriendActionStatus=If;exports.GameLoopAction=Se;exports.IDosGamesClient=ns;exports.IapProductType=Ah;exports.IapPurchaseStatus=qh;exports.IapStoreValues=vu;exports.ItemAction=oi;exports.KycStatus=Yp;exports.KycTier=ed;exports.LeaderboardAction=De;exports.LocalizationAction=ii;exports.LocalizationMissingKeyMode=uh;exports.LootboxAction=hi;exports.MailboxMessageSource=LR;exports.MailboxMessageStatus=UR;exports.MarketGoodsType=Xr;exports.MarketOfferStatus=_d;exports.MarketOfferType=Vd;exports.MarketplaceAction=ae;exports.MatchAction=Xe;exports.MatchStatus=Pd;exports.MemoryStorage=Dt;exports.MultiplayerAction=Fe;exports.MultiplayerChatMode=Ag;exports.MultiplayerTopology=wg;exports.NoopPlatformAdapter=os;exports.PremiumAction=Rt;exports.PurchaseAction=At;exports.QuestAction=We;exports.QuestObjectiveSource=Yu;exports.QuestPrerequisiteMode=ec;exports.QuestStatus=$u;exports.RaidMode=Hf;exports.ReferralAction=yt;exports.ResourceEntryType=Kt;exports.RewardAction=ot;exports.RoomVisibility=Og;exports.ScheduleMode=Iu;exports.SeasonAction=ht;exports.SocialAction=tt;exports.SpecialChoiceMode=$f;exports.StoreAction=wt;exports.StoreType=km;exports.TimedBoostAction=Ct;exports.TimedBoostStackingPolicy=Af;exports.TimedEventAction=je;exports.TimelineEventType=kf;exports.TitleAction=St;exports.TitleCustomDataAction=Wt;exports.TitleDataBucket=Vf;exports.TitleDataScope=Ff;exports.TradeOfferStatus=Bm;exports.TransactionDirection=id;exports.TutorialAction=qe;exports.TutorialBoardAction=fc;exports.TutorialFlowStatus=dc;exports.TutorialGateMode=Uu;exports.TutorialRestartPolicy=cc;exports.TutorialScriptModule=mc;exports.TutorialStepCompletionMode=lc;exports.TypedEmitter=Et;exports.UserAction=Ne;exports.UserCustomDataAction=Qe;exports.WalletLinkType=$p;exports.beginSsoRedirect=Yg;exports.claimedMilestoneIDs=oR;exports.createIDosGamesClient=$g;exports.curveMultiplier=lR;exports.evaluateCurve=Cu;exports.grantedPremiumTiers=aR;exports.isCurveConfigured=uR;exports.isFail=Mu;exports.isMilestoneClaimed=nR;exports.isOk=ku;exports.normalizeBlockchainCategory=Hr;exports.readSsoCodeFromUrl=Jg;exports.roundAmount=cR;exports.zPaymentProof=Op;exports.zPriceOption=Ro;exports.zPriceOptions=J;
|