@idosgames/core 0.9.0 → 0.10.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 CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var zod=require('zod'),or=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var or__default=/*#__PURE__*/_interopDefault(or);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 Tu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function bn(){return vu()??Tu()}function vu(){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 zn="https://api.idosgames.com";function Tn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??zn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??bn(),locale:o.locale??Pu()}}function Pu(){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 vn="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(vn);return e||(e=P(),this.storage.setString(vn,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 _e={Virtual:"Virtual",Crypto:"Crypto"},vt=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),$t={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},Zt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),Ye={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},Jt=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),Iu={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},Yt=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),ku={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},Xt=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),Mu={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Gt=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),ge={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function In(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return Pn(e);let t=o.cordova?.platformId;return t?Pn(t):o.navigator?.userAgent??""?Ye.Web:Ye.Unknown}function Pn(o){let e=o.toLowerCase();return e==="android"?Ye.Android:e==="ios"?Ye.Ios:e==="web"?Ye.Web:Ye.Unknown}function Nt(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function wu(o){return o.ok}function Au(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 ls=zod.z.object({Type:Zt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:M.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),Ou=zod.z.object({Type:Xt.nullish(),EntityID:zod.z.string()}),Uu=zod.z.object({Address:Ou.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),me=zod.z.object({Entries:zod.z.array(ls).nullish(),EventTokens:zod.z.array(Uu).nullish()}),kn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:me.nullish()}),L=zod.z.object({Standard:me.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(kn).nullish()}),jt=zod.z.object({Standard:me.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(kn).nullish()}),b=zod.z.object({Grant:L.nullish(),Consume:jt.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:me.nullish()});var Bu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),Lu={Completed:"Completed",Started:"Started",StepReached:"StepReached"},qu=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),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:Bu.nullish(),Tutorial:qu.nullish(),Platforms:zod.z.array(Jt).nullish()}).passthrough();var fe=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 Eu=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Gu=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Nu=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 ju=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:fe.nullish()}).passthrough(),ce=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:Gu.nullish(),Chain:Nu.nullish(),Cyclic:ju.nullish(),ActivationTriggers:zod.z.array(Le).nullish(),Relative:Eu.nullish()}).passthrough();var Fu={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},Vu=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),_u={Step:"Step",Linear:"Linear",Geometric:"Geometric"},Wu=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),Qu=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),xe=zod.z.object({Base:zod.z.number().nullish(),Shape:Vu.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(Qu).nullish(),Interpolation:Wu.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var Ku=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),Hu=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),us=zod.z.object({Bundles:zod.z.array(Ku).nullish(),Multipliers:zod.z.array(Hu).nullish()}).passthrough();var $u=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),er=zod.z.object({Source:$u.nullish(),SourceKey:zod.z.string().nullish(),Curve:xe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:me.nullish(),ExcludeRewards:me.nullish()}).passthrough(),ze=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:us.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),ut=zod.z.object({Milestones:zod.z.record(zod.z.string(),ze).nullish()}).passthrough();var Y=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var Zu=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:Zu.nullish()}).passthrough();var ie=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),Xe=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(ie(o)),Resources:b.nullish()});var Ju={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Mn=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),Yu=zod.z.object({}).passthrough().transform(o=>o),Xu=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()}),cs=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:Yu.nullish(),PointsTracks:zod.z.record(zod.z.string(),Xu).nullish()}),ps=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Mn.nullish(),Resources:b.nullish()}),ds=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(cs).nullish()}),Un=zod.z.array(ie(ps)),Bn=zod.z.array(ie(ds)),ec={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},tc=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),rc={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},ic=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Ln=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:tc.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(),hs=zod.z.object({Milestones:Y.nullish(),Linking:Y.nullish(),Availability:Y.nullish(),Reward:Y.nullish(),Objectives:Y.nullish()}).passthrough(),sc=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:ic.nullish()}).passthrough(),En=zod.z.object({Schedule:ce.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:W.nullish(),Limits:fe.nullish()}).passthrough(),Gn=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),nc=zod.z.object({QuestID:zod.z.string().nullish(),Identity:sc.nullish(),Linking:qn.nullish(),Availability:En.nullish(),Objectives:zod.z.record(zod.z.string(),Ln).nullish(),Reward:Gn.nullish(),Presets:hs.nullish()}).passthrough(),oc=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(),ac=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(),ze).nullish(),Presets:hs.nullish(),PointsToken:ft.nullish()}).passthrough(),lc=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(),uc=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Milestones:zod.z.record(zod.z.string(),ze).nullish(),Gate:W.nullish(),PointsToken:ft.nullish(),GroupCompletions:zod.z.record(zod.z.string(),oc).nullish(),Phases:zod.z.record(zod.z.string(),ac).nullish(),Presets:hs.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rr=zod.z.object({Cycles:zod.z.record(zod.z.string(),uc).nullish(),Quests:zod.z.record(zod.z.string(),nc).nullish(),Presets:lc.nullish()}).passthrough(),Qe={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var cc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},pc=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),dc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},hc=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),mc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},fc=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),gc={GameLoop:"GameLoop"},Rc={Raid:"Raid",Attack:"Attack"},yc=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:pc.nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),Sc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),xc=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),Dc=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:xc.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),bc=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),ms=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:yc.nullish(),Completion:Cc.nullish(),Effects:Sc.nullish(),Script:Dc.nullish(),Policy:bc.nullish()}).passthrough(),zc=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:hc.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(),Tc=zod.z.object({Availability:Y.nullish(),Policy:Y.nullish(),Reward:Y.nullish(),Steps:Y.nullish()}).passthrough(),vc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:zc.nullish(),Availability:Nn.nullish(),Policy:jn.nullish(),Steps:zod.z.record(zod.z.string(),ms).nullish(),Reward:Fn.nullish(),Presets:Tc.nullish()}).passthrough(),Pc=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(),Ic=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:Pc.nullish()}).passthrough(),kc=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(),ms)).nullish()}).passthrough(),Vn=zod.z.object({Flows:zod.z.record(zod.z.string(),vc).nullish(),Settings:Ic.nullish(),Presets:kc.nullish()}).passthrough(),Mc=zod.z.object({}).passthrough().transform(o=>o),_n=zod.z.object({FlowID:zod.z.string(),Status:fc,CurrentStepID:zod.z.string().nullish(),CurrentStep:ms.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:Mc.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 ir=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 sr=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 fs(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 gs(o){return new Promise(e=>setTimeout(e,o))}var wc=12e3,Ac=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(cs).nullish(),TutorialProgress:zod.z.array(Hn).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),nr=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new sr;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 ir(e.throttleMs),this.clientPlatform=e.clientPlatform??Ye.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??wc,de=i.autoRetry??!0,Re=!1,ke=0;for(;;){let Ze;try{Ze=await this.doFetch(a,p,D,E);}catch{if(de&&ke<3){ke++,await gs(fs(ke));continue}return this.connectionFailure("Internet Connection Error",U)}let Je=Ze.status;if(Je>=200&&Je<300)return await this.parseSuccess(Ze,r,U,e);if(Je===401){if(!Re&&this.sessionRefreshHandler){Re=!0;let it=null;try{it=await this.sessionRefreshHandler();}catch{it=null;}if(it){D=it;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if($n(Je)){if(de&&ke<3){ke++,await gs(fs(ke));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Je})`,U)}return await this.handleWebError(Ze,Je,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=Ac.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 Nt(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 Ft(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,ke=new Map,Ze=new Map,Je=e.Grant?.PremiumTiers??[],it=Je.length;for(let ne=0;;ne++){let he,$;if(ne===0)he=e.Grant?.Standard?.Entries,$=false;else if(ne-1<it)he=Je[ne-1]?.Resources?.Entries,$=false;else if(ne===1+it)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 or__default.default(0)).plus(K));break}case "Item":{if(!_.ItemID)continue;let H=Uc(t,_.CatalogID,_.ItemID),X=(H?H.IsStackable??true:true)?$?Re:de:$?Ze:ke;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:Ft(r),Earned:he,Spent:$}):s.VirtualCurrencies[ne]={Amount:_,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Ft(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 or__default.default(0),$=E.get(ne)??new or__default.default(0),_=he.minus($),K=s.CryptoCurrencies[ne];K?(K.Amount=new or__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||ke.size>0||Ze.size>0,i.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,he=new Set([...de.keys(),...Re.keys(),...ke.keys(),...Ze.keys()]);for(let $ of he){let _=(de.get($)??0)-(Re.get($)??0),K=(ke.get($)??0)-(Ze.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 Ze){if(_<=0)continue;let K=Object.values(ne).filter(H=>H.ItemID===$&&H.EquippedSlot==null&&(H.ExpiresAt==null||new Date(H.ExpiresAt)>r)).sort(Oc).slice(0,_).map(H=>H.ItemInstanceID);for(let H of K)delete ne[H];}for(let[$,_]of ke){let K=Bc(t,$);for(let H=0;H<_;H++){let Be=P();ne[Be]={ItemInstanceID:Be,ItemID:$,CatalogID:K,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let zu=o.EventToken;for(let ne=0;;ne++){let he,$;if(ne===0)he=e.Grant?.Standard?.EventTokens,$=false;else if(ne-1<it)he=Je[ne-1]?.Resources?.EventTokens,$=false;else if(ne===1+it)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=Lc(zu,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:Ft(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:Ft(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 Oc(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 Uc(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 Bc(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 Lc(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 Rs(o,e){return o===e||o.startsWith(`${e}:`)}var ar=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 or__default.default?t:new or__default.default(t),a=r??new Date().toISOString(),p=i[e];p?(p.Amount=new or__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(Rs(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))!Rs(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);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(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 lr=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 ur=class{user;config;constructor(e){this.user=new ar(e),this.config=new lr;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var cr=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 qc(e)?e:ge.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 qc(o){return o!==null&&Object.values(ge).includes(o)}var Ec=8,Gc=100,Nc=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,eo=["GameLoop"],pr=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ge.None;sessionEmail="";sessionPassword="";pendingRegistration=null;get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}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(ge.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(ge.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(ge.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);return i.ok?(this.pendingRegistration={email:e,password:t},Nt({codeTtlMinutes:i.data.CodeTtlMinutes??0,resendCooldownSeconds:i.data.ResendCooldownSeconds??0})):i}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.Email=e,r.VerificationCode=t;let i=await this.ctx.api.authentication.confirmEmailRegistration(r);if(!i.ok)return i;this.applyAuthContext(i.data);let s=await this.fetchAndApplyClientState(ge.Email);return s.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,s}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let r=await this.ctx.api.authentication.resendVerificationCode(t);return r.ok?Nt(void 0):r}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(ge.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(ge.Wallet)):s}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.loginWithSsoCode(t);return r.ok?(this.applyAuthContext(r.data),this.fetchAndApplyClientState(ge.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 ge.Email:return this.loginWithEmail(t,r);case ge.Device:case ge.None:return this.loginWithDeviceID();case ge.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!==ge.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ge.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&&Nc.test(e)}static isValidPasswordLength(e){return e.length>=Ec&&e.length<=Gc}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ge.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 jc="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 `${jc}:${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 Fc="idos:state",dr=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 `${Fc}:${this.titleId}:${e}`}};function Vc(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 Cs(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 _c(o){return {...o??{}}}function Ss(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var hr=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=Vc(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=_c(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)."),mr=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 hr(new dr(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=Cs(e.User,t.cached,t.sent,e.StateVersions);e.User=r;let i=Ss(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=Cs(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=Ss(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 gr=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===_e.Crypto||r===_e.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 or__default.default?s:new or__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===_e.Virtual&&r===_e.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===_e.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===_e.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===_e.Virtual&&Re.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),de.length>0||Re.length>0){let ke={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:Re.length>0?{Standard:{Entries:Re}}:null};this.ctx.data.user.applyResourceOperation(ke,this.ctx.data.config.itemDefinitions);}E.SourceType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new or__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new or__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return U}};var Rr=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 Wc="Store",yr=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(Wc,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 Cr=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 Sr=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===$t.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!==$t.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 Qc="Lootbox",xr=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(Qc,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 Kc="Reward";function xs(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Dr=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(Kc,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(!xs(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(!xs(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(!xs(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 Hc="Tutorial",br=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(Hc,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 zr=Object.freeze({}),Tr=class{constructor(e){this.ctx=e;}ctx;table={...zr};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?$c(i,t):i}applyState(e,t){if(!e){this.reset();return}let r=e.Locale??null;this.table=t.table??{...zr},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={...zr},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??{...zr},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 $c(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 Zc="Quest",vr=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(Zc,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 Jc="TimedEvent",Pr=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(Jc,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 Yc="Leaderboard",Ir=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(Yc,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 Xc="Season",kr=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(Xc,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 ep="Premium",Mr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getDefinitions(e);return t.ok&&t.data.Premium&&(this.ctx.data.config.patchSection(ep,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 tp="Character",wr=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(tp,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 rp="Match",Ar=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(rp,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ip="Craft",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.craft.getDefinitions(e);return t.ok&&t.data.CraftDefinitions&&(this.ctx.data.config.patchSection(ip,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 sp="Collection",Ur=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(sp,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 np="CoopEvent",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.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(np,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 op="DealOffer",Lr=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(op,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 ap="Referral",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.referral.getDefinitions(e);return t.ok&&t.data.ReferralDefinitions&&(this.ctx.data.config.patchSection(ap,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 Er=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getOutgoingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let 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 lp="TimedBoost";function up(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Gr=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(lp,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(!up(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 st={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},cp={Client:"Client",Server:"Server",System:"System"},pp=zod.z.enum(["Client","Server","System"]).catch("Client"),dp=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:pp.nullish(),ExpiresAt:u.nullish()}).passthrough(),Nr=zod.z.record(zod.z.string(),dp),no=zod.z.object({Version:zod.z.number().nullish(),Private:Nr.nullish(),Public:Nr.nullish(),ReadOnly:Nr.nullish()}),Ds=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Nr.nullish()}),bs=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),hp=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(hp).nullish()}),ao=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),lo=zod.z.object({Results:zod.z.array(Ds).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),mp={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},fp=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),gp=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:fp.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),jr=zod.z.object({Keys:zod.z.record(zod.z.string(),gp).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(),Ke={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Rp="UserCustomData";function uo(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Fr=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(Rp,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,st.Private)}async setPublicData(e,t){return this.setData(e,t,st.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===st.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===st.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!==st.Private&&t!==st.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??st.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 yp="TitleCustomDataDefinitions",co=50;function Cp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function zs(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function Sp(o){let e={};for(let[t,r]of Object.entries(o))zs(r)||(e[t]=r);return e}var Vr=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(yp,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=>!Cp(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&&!zs(t))return t.Value;let r=this.staticCache[e];if(r?.Value!=null&&!zs(r))return r.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=Sp(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 _r=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 xp=15,Dp="GameLoop",bp="BoardDefinition",Wr=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(Dp,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(bp,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,xp);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(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${P()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},i=await this.ctx.api.gameLoop.boardSpecialClaim(r);if(i.ok){let s=i.data;this.ctx.data.user.clearBoardPending(),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",s);}return 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 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 Qr=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}),Kr={Convert:"Convert",CryptoConvert:"CryptoConvert"},zp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},mo=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Tp={Automatic:"Automatic",Manual:"Manual"},vp=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),Pp=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(),Ip=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),kp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Mp=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:vp.nullish(),FeePercent:q.nullish(),Targets:zod.z.array(Mp).nullish()}).passthrough(),go=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),wp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:Pp.nullish(),Recharge:Ip.nullish(),Conversion:fo.nullish(),Permissions:kp.nullish(),Audit:go.nullish(),Status:mo.nullish()}).passthrough(),Ap=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(),Op=zod.z.object({DailyWithdrawUsd:q.nullish(),MonthlyWithdrawUsd:q.nullish(),KycRequiredAboveUsd:q.nullish()}).passthrough(),Up=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Ts=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(Ap).nullish(),Limits:Op.nullish(),Permissions:Up.nullish(),Conversion:fo.nullish(),Audit:go.nullish(),Status:mo.nullish()}).passthrough(),Hr=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),wp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ts).nullish()}).passthrough();var Ro=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:jt.nullish(),AllowedPlatforms:zod.z.array(Jt).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),J=zod.z.record(zod.z.string(),Ro),Bp=zod.z.object({Store:Yt,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()}),vs=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(),Lp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),qp=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:Lp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),qp).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),Co=zod.z.object({Characters:zod.z.record(zod.z.string(),vs).nullish()}),Ps=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()}),Is=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()}),Ep=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(),Ep).nullish(),Inventory:pt.nullish()}),ks=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),bo=Xe(ks),zo=Xe(Is),To=Xe(Ps),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(),Gp=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(),Gp).nullish()}).passthrough(),Np=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(),jp=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Fp=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:J.nullish()}).passthrough(),Vp=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(),_p=zod.z.object({CharacterID:zod.z.string(),Identity:Np.nullish(),Classification:jp.nullish(),Unlock:Fp.nullish(),Presets:Vp.nullish(),Equipment:Io.nullish(),Stats:zod.z.record(zod.z.string(),Po).nullish(),RankLadder:ko.nullish(),RankStatCurve:xe.nullish(),StatMaxLevelCurve:xe.nullish()}).passthrough(),Wp=zod.z.object({Stats:zod.z.record(zod.z.string(),Po).nullish()}).passthrough(),Qp=zod.z.object({RankLadder:ko.nullish()}).passthrough(),Kp=zod.z.object({Equipment:Io.nullish()}).passthrough(),Hp=zod.z.object({Stats:zod.z.record(zod.z.string(),Wp).nullish(),Levels:zod.z.record(zod.z.string(),Qp).nullish(),Equipment:zod.z.record(zod.z.string(),Kp).nullish()}).passthrough(),$r=zod.z.object({Definitions:zod.z.record(zod.z.string(),_p).nullish(),Presets:Hp.nullish()}).passthrough(),Oe={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var $p={EVM:"EVM",Solana:"Solana"},Zp=zod.z.enum(["EVM","Solana"]).catch("EVM"),Jp={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},Yp=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),Xp={Token:"Token",Nft:"Nft"},Mo=zod.z.enum(["Token","Nft"]).catch("Token"),ed={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},td=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),rd={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},id=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),sd={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Ms=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),wo={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Zr(o){let e=o?.trim();return e||wo.GameTopUp}var nd={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ao=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),od=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(),ad=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:Zp.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(od).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ld=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(),ud=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 cd=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),pd=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:q.nullish(),BalanceSource:cd.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),dd=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(pd).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),ws=zod.z.object({SystemState:ld.nullish(),Networks:zod.z.record(zod.z.string(),ad).nullish(),AccountSafety:ud.nullish(),WalletLogin:dd.nullish()}).passthrough(),hd=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:Yp.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(),md=zod.z.object({Status:td.nullish(),Tier:id.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),fd=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(),gd=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(),fd).nullish()}).passthrough(),Rd=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(),yd=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(),Rd).nullish()}).passthrough(),Cd=zod.z.object({Tokens:gd.nullish(),Nfts:yd.nullish()}).passthrough(),Sd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),xd=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(Sd).nullish()}).passthrough(),Dd=zod.z.object({Version:zod.z.number().nullish(),Stats:Cd.nullish(),LinkedWallets:zod.z.record(zod.z.string(),hd).nullish(),LastWalletLogin:xd.nullish(),PendingWithdrawals:zod.z.array(Uo).nullish(),Kyc:md.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),bd=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:u}).passthrough(),Jr=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),bd).nullish(),PendingAdded:Uo.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),zd=zod.z.object({Amount:q,Frozen:q,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Td=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:Ms.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(),vd=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:Ms.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(),As=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(),Os=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:ws.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ts).nullish()}).passthrough(),qo=zod.z.object({State:Dd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),zd).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:Jr.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:As.nullish(),SolanaSignature:Os.nullish(),StateDelta:Jr.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:As.nullish(),SolanaSignature:Os.nullish(),StateDelta:Jr.nullish(),Inventory:pt.nullish()}).passthrough(),Fo=zod.z.object({TokenTransactions:zod.z.array(Td).nullish(),NFTTransactions:zod.z.array(vd).nullish()}).passthrough(),Us=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:As.nullish(),SolanaSignature:Os.nullish()}).passthrough(),_o=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Ms.nullish(),StateDelta:Jr.nullish()}).passthrough(),Ue={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Pd="Blockchain",Yr=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(Pd,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 or__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=Zr(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 or__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=Zr(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 Te=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 Id={Head:"Head",Torso:"Torso",Legs:"Legs"},Xr=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),kd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Bs=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),Ko=zod.z.object({AttackTarget:Xr,DefenseTarget:Xr});var Md=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),wd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:Xr.nullish(),DefenseZone:Xr.nullish(),HitType:Md.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),Ad=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(),Od=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:vs.nullish(),BattleStrategy:zod.z.array(Ko).nullish(),UnstackableItems:zod.z.record(zod.z.string(),Od).nullish(),Stats:Ad.nullish()}).passthrough(),Ud=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:me.nullish(),NetReward:me.nullish(),BattleLog:zod.z.array(wd).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:me.nullish(),CreationCostPaid:me.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Bs.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),$o=zod.z.object({Status:Bs,MatchID:zod.z.string(),Entry:me.nullish(),Resources:b.nullish()}),Zo=zod.z.object({Match:Ho.nullish()}),Jo=zod.z.object({MatchID:zod.z.string(),Status:Bs,Resources:b.nullish()}),Yo=zod.z.object({Battle:Ud.nullish(),Resources:b.nullish(),ResourcesDual:mt.nullish()}),Ls=zod.z.object({Matches:zod.z.array(Ho).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),tt={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Bd=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var Ld=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),qd=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(),Ed=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),Gd=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish(),ArmorMode:Ed.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),Nd=zod.z.object({Kind:Ld.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(),jd=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(Nd).nullish()}).passthrough(),gt=zod.z.object({Terms:zod.z.array(jd).nullish()}).passthrough(),Fd=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:qd.nullish(),Combat:Gd.nullish(),Formula:Fd.nullish()}).passthrough(),Vd=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),qs=zod.z.object({Kind:Bd.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:Xt.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(qs).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:fe.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),_d=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:Vd.nullish(),Entry:ea.nullish(),Creation:ta.nullish(),Settings:Xo.nullish()}).passthrough(),Wd=zod.z.object({Rules:zod.z.record(zod.z.string(),_d).nullish(),Defaults:Xo.nullish(),EntryDefaults:ea.nullish(),CreationDefaults:ta.nullish()}).passthrough(),Es=zod.z.object({InstantBattle:Wd.nullish()}).passthrough(),ra=Es;var Qd={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},Gs=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),Kd={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Ns=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),Hd={Burn:"Burn",Ledger:"Ledger"},$d=zod.z.enum(["Burn","Ledger"]).catch("Burn"),ti={Item:"Item",VirtualCurrency:"VirtualCurrency"},js=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),Zd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.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(qs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),Yd=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:$d.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),Zd).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),Xd=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(),eh=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:fe.nullish(),BuyLimits:fe.nullish(),ListingFeeOptions:J.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),th=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:fe.nullish()}).passthrough(),rh=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:fe.nullish(),FillLimits:fe.nullish()}).passthrough(),ih=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:fe.nullish()}).passthrough(),sh=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Fs=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:W.nullish(),Schedule:ce.nullish(),PricePolicy:Jd.nullish(),Commission:Yd.nullish(),Tradability:Xd.nullish(),Listings:eh.nullish(),Auctions:th.nullish(),BuyOrders:rh.nullish(),DirectTrades:ih.nullish(),Matching:sh.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(),nh=zod.z.object({BidAxisType:Zt.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(),ei=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),oh=zod.z.object({Create:ei.nullish(),Buy:ei.nullish(),Sell:ei.nullish(),Bid:ei.nullish()}).passthrough(),ah=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),lh=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:ah.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),nt=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Gs.nullish(),Status:Ns.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:Te.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:js.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:zod.z.array(lh).nullish(),Price:me.nullish(),Auction:nh.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),uh=zod.z.object({GoodsType:js.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(Gs,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),sa=zod.z.object({Definitions:Fs.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Vs=zod.z.object({Offers:zod.z.array(nt).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),na=zod.z.object({Groups:zod.z.array(uh).nullish()}).passthrough(),oa=zod.z.object({Offer:nt.nullish()}).passthrough(),Ge=zod.z.object({OfferID:zod.z.string().nullish(),Status:Ns.nullish(),Settlement:mt.nullish(),Resources:b.nullish(),CommissionTaken:me.nullish()}).passthrough(),Vt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:nt.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(nt).nullish(),MyLeadingBids:zod.z.array(nt).nullish(),MyBuyOrders:zod.z.array(nt).nullish(),IncomingTrades:zod.z.array(nt).nullish(),OutgoingTrades:zod.z.array(nt).nullish(),Claimables:zod.z.array(nt).nullish(),DrainedRefunds:zod.z.array(ia).nullish(),Limits:oh.nullish()}).passthrough(),ch=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:Gs.nullish(),FinalStatus:Ns.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:js.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:me.nullish(),CommissionTaken:me.nullish(),CompletedAt:u.nullish()}).passthrough(),ua=zod.z.object({Entries:zod.z.array(ch).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 ph="Marketplace",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.marketplace.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(ph,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=ti.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=ti.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 ii=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}),pa=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),De=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),da=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),we={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function 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 si=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(we.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(we.LoginWithTelegram,e)}loginWithEmail(e){return this.login(we.LoginWithEmail,e)}loginWithGoogle(e){return this.login(we.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(we.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(we.RegisterWithEmail),e,pa,{ticket:null})}confirmEmailRegistration(e){return this.login(we.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(we.ResendVerificationCode),e,De,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(we.RequestWalletChallenge),e,da,{ticket:null})}loginWithWallet(e){return this.login(we.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(we.ForgotPassword),e,De,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(we.ResetPassword),e,De,{ticket:null})}};var dh={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},ha=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),hh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),ma=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),hh).nullish(),MissingKeyMode:ha.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),mh=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),fa=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:mh.nullish()}).passthrough(),ni={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},fh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),ga=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:ha.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(fh).nullish()}).passthrough(),Ra=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 _s=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:fa.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()}).passthrough().transform(o=>o),Ca=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),Sa=zod.z.object({}).passthrough().transform(o=>o),xa=zod.z.object({}).passthrough().transform(o=>o),Da=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(),ba=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var oi=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(je.GetClientState,e.UserID),e,_s,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,_s,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(je.GetStateVersions,e.UserID),e,ya,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(je.GetUserState,e.UserID),e,Ca,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,Sa,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,xa,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,Da,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,De,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,De,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,ba,{ticket:e.ClientSessionTicket})}};var ai=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(Kr.Convert,e,po)}cryptoConvert(e){return this.send(Kr.CryptoConvert,e,ho)}};var gh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Ws=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(gh).nullish()}),za=zod.z.array(ie(Ws)),li={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Rh={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},yh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Ch={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},Sh=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),xh=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(),xh).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),bh=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(),zh=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(),Th=zod.z.object({ValuationMode:yh.nullish(),WeightCurve:xe.nullish(),Selection:Sh.nullish()}).passthrough(),vh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish(),FlatBonusCurve:xe.nullish(),PercentBonusCurve:xe.nullish(),PowerCurve:xe.nullish(),Fodder:Th.nullish()}).passthrough(),Ph=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Ih=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:bh.nullish(),Equipment:zh.nullish(),Upgrade:vh.nullish(),Metadata:Ph.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),kh=zod.z.object({Items:zod.z.record(zod.z.string(),Ih).nullish()}).passthrough(),ui=zod.z.object({Catalogs:zod.z.record(zod.z.string(),kh).nullish()}).passthrough();var ci=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=A(this.ctx.settings.titleID,"Item",li.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Ws,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=A(this.ctx.settings.titleID,"Item",li.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,za,{ticket:e.ClientSessionTicket})}};var Qs=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),Ta=zod.z.array(ie(Qs)),Mh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),va=zod.z.object({Purchases:zod.z.record(zod.z.string(),Mh).nullish()}).passthrough().transform(o=>o),wh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ah=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:wh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Oh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:fe.nullish()}).passthrough(),Uh=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:Oh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),pi=zod.z.object({Stores:zod.z.record(zod.z.string(),Ah).nullish(),StoreOffers:zod.z.record(zod.z.string(),Uh).nullish()}).passthrough(),wt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var di=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,Qs)}purchaseBatch(e){return this.send(wt.PurchaseBatch,e,Ta)}getDefinitions(e){return this.send(wt.GetDefinitions,e,pi)}getUserState(e){return this.send(wt.GetUserState,e,va)}};var Bh={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},Lh=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),qh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:fe.nullish()}).passthrough(),Eh=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),Gh=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:Lh.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:qh.nullish(),Refund:Eh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Pa=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),Gh).nullish()}).passthrough(),Ia=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(),ka=zod.z.object({Products:zod.z.record(zod.z.string(),Ia).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),Nh={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},jh=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),Ks=zod.z.object({ServerTimeUtc:u,Store:Yt.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:jh.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:b.nullish(),ProductState:Ia.nullish()}).passthrough(),Ma=Xe(Ks),At={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var hi=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,Pa)}getUserState(e){return this.send(At.GetUserState,e,ka)}validatePurchase(e){return this.send(At.ValidatePurchase,e,Ks)}validatePurchasesBatch(e){return this.send(At.ValidatePurchasesBatch,e,Ma)}};var Fh=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),wa=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:Fh.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(wa).nullish()}).passthrough(),Ut=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(wa).nullish()}).passthrough(),Vh=zod.z.object({RewardSlots:zod.z.array(Ot).nullish()}).passthrough(),_h=zod.z.object({PityRules:zod.z.array(Ut).nullish()}).passthrough(),mi=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),Vh).nullish(),PityPresets:zod.z.record(zod.z.string(),_h).nullish()}).passthrough();var Wh=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),Aa=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(Wh).nullish()}),Qh=zod.z.object({RewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),Kh=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),Hh=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:Qh.nullish(),RewardMultiplier:er.nullish(),SupplyLimits:zod.z.array(Kh).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Hs=zod.z.object({Definitions:zod.z.record(zod.z.string(),Hh).nullish(),RewardPools:mi.nullish()}).passthrough(),Oa=zod.z.object({LootboxDefinitions:Hs.nullish()}),fi={GetDefinitions:"GetDefinitions",Open:"Open"};var gi=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(fi.GetDefinitions,e,Oa)}open(e){return this.send(fi.Open,e,Aa)}};var $h=zod.z.object({}).passthrough().transform(o=>o),Zh=zod.z.object({}).passthrough().transform(o=>o),Jh=zod.z.object({}).passthrough().transform(o=>o),Yh=zod.z.object({}).passthrough().transform(o=>o),Xh=zod.z.object({}).passthrough().transform(o=>o),Ua=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:$h,Resources:b.nullish()}),Ba=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:Zh,Resources:b.nullish()}),La=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:Jh,Resources:b.nullish()}),qa=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:Yh,Resources:b.nullish()}),Ea=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()}),em=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),tm=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(),rm=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(tm).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(),im=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),sm=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(im).nullish()}).passthrough(),nm=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(),om=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:sm.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:nm.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),am=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),lm=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(am).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(),um=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(),cm=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:fe.nullish(),PremiumLimitOverrides:zod.z.array(um).nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),$s=zod.z.object({TierRewards:em.nullish(),MilestoneRewardMultiplier:er.nullish(),DailyCalendars:zod.z.record(zod.z.string(),rm).nullish(),IdleAccruals:zod.z.record(zod.z.string(),om).nullish(),Comebacks:zod.z.record(zod.z.string(),lm).nullish(),Claims:zod.z.record(zod.z.string(),cm).nullish()}).passthrough(),Ga=zod.z.object({RewardDefinitions:$s.nullish()}),Na=zod.z.object({Rewards:Xh.nullish()}),ot={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Ri=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,Ga)}getUserRewardsState(e){return this.send(ot.GetUserRewardsState,e,Na)}getMilestoneRewardMultiplier(e){return this.send(ot.GetMilestoneRewardMultiplier,e,Ea)}claimDailyReward(e){return this.send(ot.ClaimDailyReward,e,Ua)}collectIdleAccrual(e){return this.send(ot.CollectIdleAccrual,e,Ba)}claimComebackReward(e){return this.send(ot.ClaimComebackReward,e,La)}claimReward(e){return this.send(ot.ClaimReward,e,qa)}};var yi=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 Ci=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(ni.GetLocalizationManifest,e,ga)}getLocalizationTable(e){return this.send(ni.GetLocalizationTable,e,Ra)}};var Si=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(Qe.GetQuestDefinitions,e,rr)}getUserQuestState(e){return this.send(Qe.GetUserQuestState,e,wn)}refreshQuestCycles(e){return this.send(Qe.RefreshQuestCycles,e,De)}claimQuestReward(e){return this.send(Qe.ClaimQuestReward,e,ps)}claimQuestRewardsBatch(e){return this.send(Qe.ClaimQuestRewardsBatch,e,Un)}claimMilestoneReward(e){return this.send(Qe.ClaimMilestoneReward,e,ds)}claimMilestoneRewardsBatch(e){return this.send(Qe.ClaimMilestoneRewardsBatch,e,Bn)}claimGroupCompletionReward(e){return this.send(Qe.ClaimGroupCompletionReward,e,An)}addQuestProgress(e){return this.send(Qe.AddQuestProgress,e,On)}};var ja=zod.z.object({}).passthrough().transform(o=>o);var pm=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),dm=zod.z.object({Schedule:zod.z.array(pm).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),hm=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(),mm=zod.z.object({Milestones:Y.nullish()}).passthrough(),Zs=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(),ze).nullish(),Presets:mm.nullish(),BonusWindow:dm.nullish()}).passthrough(),fm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:Zs.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),gm=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:Zs.nullish(),Events:zod.z.array(fm).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Rm=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),ym=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),xi=zod.z.object({Definitions:zod.z.record(zod.z.string(),gm).nullish(),Settings:Rm.nullish(),Presets:ym.nullish()}).passthrough(),Cm=zod.z.object({Type:Gt,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:Zs.nullish(),Progress:ja.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ze.nullish(),BonusWindow:hm.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),Fa=zod.z.object({ActiveEvents:zod.z.array(Cm).nullish()}).passthrough(),Va=zod.z.object({Tokens:zod.z.record(zod.z.string(),ja).nullish()}),Js=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Ys=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),Sm=zod.z.object({Type:Gt.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),Xs=zod.z.array(ie(Ys)),_a=zod.z.array(ie(Js)),Wa=zod.z.array(ie(Sm)),Fe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Di=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(Fe.GetActiveEvents,e,Fa)}getDefinitions(e){return this.send(Fe.GetDefinitions,e,xi)}getUserLteState(e){return this.send(Fe.GetUserLteState,e,Va)}grantTokens(e){return this.send(Fe.GrantTokens,e,b)}spendTokens(e){return this.send(Fe.SpendTokens,e,Js)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Ys)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,Xs)}claimAllMilestones(e){return this.send(Fe.ClaimAllMilestones,e,Xs)}spendTokensBatch(e){return this.send(Fe.SpendTokensBatch,e,_a)}grantTokensBatch(e){return this.send(Fe.GrantTokensBatch,e,Wa)}};var xm=zod.z.object({UserID:zod.z.string(),Score:M.nullish(),Rank:zod.z.number().nullish(),LastScoreUpdateUtc:u.nullish(),IpHash:zod.z.string().nullish(),PublicProfile:Te.nullish(),SeasonTierAtCycleEnd:zod.z.number().nullish()}).passthrough(),_t=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(xm).nullish(),BracketID:zod.z.string().nullish()}),Dm=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(),bi=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:ze.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Dm).nullish()}),zi=zod.z.object({LeaderboardID:zod.z.string(),NewScore:M,CycleVersion:zod.z.number()}),Ti=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),vi=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),Qa=zod.z.array(ie(_t)),Ka=zod.z.array(ie(bi)),Ha=zod.z.array(ie(Ti)),$a=zod.z.array(ie(vi)),Za=zod.z.array(ie(zi)),bm=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:ie(Ti).nullish(),Milestones:zod.z.array(ie(vi)).nullish()}),Ja=zod.z.array(bm),zm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:ie(_t).nullish(),Progress:ie(bi).nullish()}),Ya=zod.z.array(zm),Tm=zod.z.string(),Xa=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:us.nullish()}).passthrough(),vm=zod.z.object({RankRewards:zod.z.array(Xa).nullish()}).passthrough(),Pm=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Im=zod.z.object({Milestones:Y.nullish(),RankRewards:Y.nullish()}).passthrough(),km=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:Tm.nullish(),Schedule:ce.nullish(),ChainEvents:zod.z.array(Pm).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(Xa).nullish(),Milestones:zod.z.record(zod.z.string(),ze).nullish(),Presets:Im.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Le).nullish()}).passthrough(),Mm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),RankRewards:zod.z.record(zod.z.string(),vm).nullish()}).passthrough(),Pi=zod.z.object({Definitions:zod.z.record(zod.z.string(),km).nullish(),Presets:Mm.nullish()}).passthrough(),be={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 Ii=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(be.GetDefinitions,e,Pi)}getLeaderboard(e){return this.send(be.GetLeaderboard,e,_t)}getMyProgress(e){return this.send(be.GetMyProgress,e,bi)}submitScore(e){return this.send(be.SubmitScore,e,zi)}submitScoreFromSource(e){return this.send(be.SubmitScoreFromSource,e,zi)}claimCycleReward(e){return this.send(be.ClaimCycleReward,e,Ti)}claimMilestone(e){return this.send(be.ClaimMilestone,e,vi)}getFriendsLeaderboard(e){return this.send(be.GetFriendsLeaderboard,e,_t)}getLeaderboardsBatch(e){return this.send(be.GetLeaderboardsBatch,e,Qa)}getProgressBatch(e){return this.send(be.GetProgressBatch,e,Ka)}claimCycleRewardsBatch(e){return this.send(be.ClaimCycleRewardsBatch,e,Ha)}claimMilestonesBatch(e){return this.send(be.ClaimMilestonesBatch,e,$a)}submitScoresBatch(e){return this.send(be.SubmitScoresBatch,e,Za)}claimAllRewardsBatch(e){return this.send(be.ClaimAllRewardsBatch,e,Ja)}getOverviewBatch(e){return this.send(be.GetOverviewBatch,e,Ya)}};var en=zod.z.object({}).passthrough().transform(o=>o),el=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>sl).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:M.nullish(),UserState:en.nullish(),NextTier:zod.z.lazy(()=>il).nullish()}).passthrough(),tl=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()}),tn=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),rl=Xe(tn);var il=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(),sl=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(il).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var wm=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Seasons:zod.z.array(sl).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:W.nullish()}).passthrough(),ki=zod.z.object({Chains:zod.z.record(zod.z.string(),wm).nullish()}).passthrough(),ht={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Mi=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,ki)}getActiveSeason(e){return this.send(ht.GetActiveSeason,e,el)}getUserState(e){return this.send(ht.GetUserState,e,en)}grantStatusTokens(e){return this.send(ht.GrantStatusTokens,e,tl)}claimTierReward(e){return this.send(ht.ClaimTierReward,e,tn)}claimTierRewardsBatch(e){return this.send(ht.ClaimTierRewardsBatch,e,rl)}};var Am={Apple:"Apple",Google:"Google"},nl=zod.z.object({}).passthrough().transform(o=>o),Om=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(),Um=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(),rn=zod.z.object({Definitions:zod.z.record(zod.z.string(),Um).nullish()}).passthrough(),ol=zod.z.object({Premium:rn.nullish()}),al=zod.z.object({ServerTimeUtc:u.nullish(),Premium:nl.nullish()}),wi=zod.z.object({ServerTimeUtc:u.nullish(),Premium:nl.nullish(),Subscription:Om.nullish(),Resources:b.nullish()}),Rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Ai=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,ol)}getUserState(e){return this.send(Rt.GetUserState,e,al)}activateTrial(e){return this.send(Rt.ActivateTrial,e,wi)}purchaseItemOrCurrency(e){return this.send(Rt.PurchaseWithResources,e,wi)}purchaseRealMoney(e){return this.send(Rt.PurchaseRealMoney,e,wi)}};var Oi=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(Oe.GetCharacterDefinitions,e,$r)}getUserCharacters(e){return this.send(Oe.GetUserCharacters,e,Co)}unlockCharacter(e){return this.send(Oe.UnlockCharacter,e,ks)}upgradeStatLevel(e){return this.send(Oe.UpgradeStatLevel,e,Ps)}upgradeCharacterLevel(e){return this.send(Oe.UpgradeCharacterLevel,e,Is)}equipItems(e){return this.send(Oe.EquipItems,e,So)}unequipItems(e){return this.send(Oe.UnequipItems,e,xo)}unequipAllCharacters(e){return this.send(Oe.UnequipAllCharacters,e,Do)}unlockCharactersBatch(e){return this.send(Oe.UnlockCharactersBatch,e,bo)}upgradeCharacterLevelsBatch(e){return this.send(Oe.UpgradeCharacterLevelsBatch,e,zo)}upgradeStatLevelsBatch(e){return this.send(Oe.UpgradeStatLevelsBatch,e,To)}};var Ui=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(tt.CreateMatch,e,$o)}updateMatch(e){return this.send(tt.UpdateMatch,e,Zo)}cancelMatch(e){return this.send(tt.CancelMatch,e,Jo)}instantBattle(e){return this.send(tt.InstantBattle,e,Yo)}saveStrategy(e){return this.send(tt.SaveStrategy,e,De)}getMyMatches(e){return this.send(tt.GetMyMatches,e,Ls)}getAvailableMatches(e){return this.send(tt.GetAvailableMatches,e,Ls)}getDefinitions(e){return this.send(tt.GetDefinitions,e,ra)}};var Bm={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},ll=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),Lm=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:ls.nullish()}),ul=zod.z.object({ServerTimeUtc:u,Type:ll.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(Lm).nullish()}),qm=zod.z.object({CraftID:zod.z.string().nullish(),Type:ll.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(),sn=zod.z.object({Definitions:zod.z.record(zod.z.string(),qm).nullish()}).passthrough(),cl=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:sn.nullish()}),Bi={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Li=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(Bi.GetDefinitions,e,cl)}craft(e){return this.send(Bi.Craft,e,ul)}};var Em={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Gm=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),pl=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()}),dl=zod.z.object({GrantedCollectibles:zod.z.array(Bt).nullish(),DuplicateCollectibles:zod.z.array(Bt).nullish(),CollectionCurrencyEarned:M.nullish()}),hl=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(dl).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()}),ml=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(dl).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()}),fl=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),nn=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),gl=zod.z.array(ie(nn)),Rl=zod.z.object({Resources:b.nullish()}),Nm=zod.z.object({OfferID:zod.z.string(),TitleID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),SenderUserID:zod.z.string().nullish(),SenderPublicData:Te.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:Gm.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(),yl=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),Cl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Sl=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()}),xl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),on=zod.z.object({Offers:zod.z.array(Nm).nullish()}),jm=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(),Fm=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(jm).nullish(),SetCompletionReward:L.nullish()}).passthrough(),Vm=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(Fm).nullish(),GrandPrize:L.nullish()}).passthrough(),Dl=zod.z.object({BonusRewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),_m=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:J.nullish(),BonusRewardSlots:zod.z.array(Ot).nullish(),PityRules:zod.z.array(Ut).nullish(),Presets:Dl.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(),Wm=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),Qm=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:Dl.nullish(),Tier:zod.z.number().nullish()}).passthrough(),Km=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(),qi=zod.z.object({Collections:zod.z.record(zod.z.string(),Vm).nullish(),PackTypes:zod.z.record(zod.z.string(),_m).nullish(),CollectionChests:zod.z.array(Qm).nullish(),DuplicateConversions:zod.z.array(Wm).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(Km).nullish(),RewardPools:mi.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 Ei=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,qi)}getUserState(e){return this.send(ve.GetUserState,e,pl)}openPack(e){return this.send(ve.OpenPack,e,hl)}openCollectionChest(e){return this.send(ve.OpenCollectionChest,e,ml)}useCollectibleJoker(e){return this.send(ve.UseCollectibleJoker,e,fl)}claimSetReward(e){return this.send(ve.ClaimSetReward,e,nn)}claimSetRewardsBatch(e){return this.send(ve.ClaimSetRewardsBatch,e,gl)}claimGrandPrize(e){return this.send(ve.ClaimGrandPrize,e,Rl)}sendTradeOffer(e){return this.send(ve.SendTradeOffer,e,yl)}cancelTradeOffer(e){return this.send(ve.CancelTradeOffer,e,Cl)}acceptTradeOffer(e){return this.send(ve.AcceptTradeOffer,e,Sl)}declineTradeOffer(e){return this.send(ve.DeclineTradeOffer,e,xl)}getMyTradeOffers(e){return this.send(ve.GetMyTradeOffers,e,on)}getIncomingTradeOffers(e){return this.send(ve.GetIncomingTradeOffers,e,on)}};var Hm=zod.z.object({}).passthrough().transform(o=>o),$m={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Zm={Active:"Active",Left:"Left",Replaced:"Replaced"},Jm=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),Ym=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Te.nullish(),BuildObjectsProgress:Jm.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(),Xm=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(),ef=zod.z.object({Objects:zod.z.array(Xm).nullish()}).passthrough(),bl=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(Ym).nullish(),BuildObjectsState:ef.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),zl=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),tf=zod.z.string(),an=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(),rf=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(),sf=zod.z.object({Objects:zod.z.array(rf).nullish(),PriceOptions:J.nullish(),SpinnerTable:zod.z.array(an).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),nf=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:tf.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:sf.nullish(),GrandPrize:L.nullish()}).passthrough(),of=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:ce.nullish(),Events:zod.z.array(nf).nullish(),Gate:W.nullish()}).passthrough(),Tl=zod.z.object({ServerTimeUtc:u.nullish(),UserState:Hm.nullish(),ActiveGroup:bl.nullish()}),ln=zod.z.object({ServerTimeUtc:u.nullish(),Group:bl.nullish(),SecondsRemaining:M.nullish()}),vl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:an.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(an).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),un=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),Pl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Gi=zod.z.object({Chains:zod.z.record(zod.z.string(),of).nullish()}).passthrough(),He={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Ni=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(He.GetDefinitions,e,Gi)}getActiveEvent(e){return this.send(He.GetActiveEvent,e,zl)}getUserState(e){return this.send(He.GetUserState,e,Tl)}getGroupState(e){return this.send(He.GetGroupState,e,ln)}joinOrCreateGroup(e){return this.send(He.JoinOrCreateGroup,e,ln)}spin(e){return this.send(He.Spin,e,vl)}claimObjectReward(e){return this.send(He.ClaimObjectReward,e,un)}claimGrandPrize(e){return this.send(He.ClaimGrandPrize,e,un)}leaveGroup(e){return this.send(He.LeaveGroup,e,Pl)}};var af={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},lf={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},uf=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(),cf=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Il=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(),uf).nullish(),Tracks:zod.z.record(zod.z.string(),cf).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),pf=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:Il.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),df=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),hf=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(),df).nullish()}).passthrough(),mf=zod.z.object({Slots:zod.z.record(zod.z.string(),pf).nullish(),OfferHistory:zod.z.record(zod.z.string(),hf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var ff=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),gf=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(ff).nullish(),Schedule:ce.nullish(),Gate:W.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Rf=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:J.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),yf=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(),Cf=zod.z.object({Purchase:Rf.nullish(),RewardedVideo:yf.nullish()}).passthrough(),Sf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),xf=zod.z.object({Milestones:Y.nullish()}).passthrough(),Df=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),bf=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(),zf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(Sf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),Tf=zod.z.object({NodeID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),Type:zod.z.string().nullish(),Action:Cf.nullish(),Grants:L.nullish(),TrackChanges:zod.z.array(Df).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:zf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:fe.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(),kl=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(Tf).nullish(),Tracks:zod.z.array(bf).nullish(),Milestones:zod.z.record(zod.z.string(),ze).nullish(),Presets:xf.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(),vf=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),cn=zod.z.object({Slots:zod.z.record(zod.z.string(),gf).nullish(),Offers:zod.z.record(zod.z.string(),kl).nullish(),Presets:vf.nullish()}).passthrough(),Ml=zod.z.object({DealOfferDefinitions:cn.nullish()}),wl=zod.z.object({DealOffers:mf.nullish()}),Pf=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(),If=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:kl.nullish(),ActivationState:Il.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:jt.nullish(),Milestone:Pf.nullish()}).passthrough(),Al=zod.z.object({Slots:zod.z.array(If).nullish()}),Ol=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()}),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(),Resources:b.nullish()}),Ll=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),ql=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()}),rt={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var ji=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(rt.GetDefinition,e,Ml)}getUserState(e){return this.send(rt.GetUserState,e,wl)}getActiveDeals(e){return this.send(rt.GetActiveDeals,e,Al)}dismissDeal(e){return this.send(rt.DismissDeal,e,Ul)}executeNode(e){return this.send(rt.ExecuteNode,e,Ol)}recordShow(e){return this.send(rt.RecordShow,e,Bl)}claimMilestone(e){return this.send(rt.ClaimMilestone,e,Ll)}claimMilestonesBatch(e){return this.send(rt.ClaimMilestonesBatch,e,ql)}};var kf=zod.z.object({}).passthrough().transform(o=>o),Mf=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(),pn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),ze).nullish(),SpendRewards:zod.z.array(Mf).nullish()}).passthrough(),El=zod.z.object({ReferralDefinitions:pn.nullish()}),Gl=zod.z.object({Referral:kf.nullish()}),Nl=zod.z.object({ReferralCode:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}),dn=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}),jl=Xe(dn),yt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Fi=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,El)}getUserState(e){return this.send(yt.GetUserState,e,Gl)}activateReferralCode(e){return this.send(yt.ActivateReferralCode,e,Nl)}claimInviteReward(e){return this.send(yt.ClaimInviteReward,e,dn)}claimInviteRewardsBatch(e){return this.send(yt.ClaimInviteRewardsBatch,e,jl)}};var wf={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Af={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Fl=zod.z.object({UserID:zod.z.string(),PublicData:Te.nullish()}),Of=zod.z.object({OwnerUserID:zod.z.string().nullish(),ActorUserID:zod.z.string().nullish(),ActorProfile:Te.nullish(),Type:zod.z.string().nullish(),CreatedAt:u.nullish(),OwnerImpact:b.nullish(),IsBlocked:zod.z.boolean().nullish(),TargetObjectName:zod.z.string().nullish()}).passthrough(),Wt=zod.z.object({Friends:zod.z.array(Fl).nullish()}),Uf=zod.z.object({FriendsCount:zod.z.number().nullish(),IncomingRequestsCount:zod.z.number().nullish(),OutgoingRequestsCount:zod.z.number().nullish()}),Qt=zod.z.object({TargetUserID:zod.z.string().nullish(),Status:zod.z.string().nullish(),Target:Fl.nullish(),Counters:Uf.nullish()}),Vl=zod.z.object({Events:zod.z.array(Of).nullish()}),$e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Vi=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($e.GetFriendsList,e,Wt)}getIncomingRequests(e){return this.send($e.GetIncomingRequests,e,Wt)}getOutgoingRequests(e){return this.send($e.GetOutgoingRequests,e,Wt)}getRecommendedFriends(e){return this.send($e.GetRecommendedFriends,e,Wt)}sendFriendRequest(e){return this.send($e.SendFriendRequest,e,Qt)}acceptFriendRequest(e){return this.send($e.AcceptFriendRequest,e,Qt)}declineFriendRequest(e){return this.send($e.DeclineFriendRequest,e,Qt)}removeFriend(e){return this.send($e.RemoveFriend,e,Qt)}getTimeline(e){return this.send($e.GetTimeline,e,Vl)}};var Bf={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(),Lf=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(),qf=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(),Ef=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(),Gf=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(Ef).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Nf=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(),jf=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),Ff=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),jf).nullish()}).passthrough(),_i=zod.z.object({Definitions:zod.z.record(zod.z.string(),Lf).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),qf).nullish(),BoostChains:zod.z.record(zod.z.string(),Gf).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),Nf).nullish(),Settings:Ff.nullish()}).passthrough(),_l=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 Wl=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),_l).nullish()}),Ql=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:_l.nullish(),Resources:b.nullish()}),Vf={Scheduled:"Scheduled",Chain:"Chain"},_f=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(),Kl=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(_f).nullish()}),Ct={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Wi=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,_i)}getActive(e){return this.send(Ct.GetActive,e,Wl)}getActiveWindows(e){return this.send(Ct.GetActiveWindows,e,Kl)}activate(e){return this.send(Ct.Activate,e,Ql)}cleanupExpired(e){return this.send(Ct.CleanupExpired,e,De)}};var Qi=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(Ke.GetUserCustomDataDefinitions,e,jr)}getMyUserCustomData(e){return this.send(Ke.GetMyUserCustomData,e,no)}getPublicUserCustomDataOf(e){return this.send(Ke.GetPublicUserCustomDataOf,e,Ds)}setPrivateData(e){return this.send(Ke.SetPrivateData,e,bs)}setPublicData(e){return this.send(Ke.SetPublicData,e,bs)}deleteKey(e){return this.send(Ke.DeleteKey,e,De)}batchSet(e){return this.send(Ke.BatchSet,e,oo)}batchDelete(e){return this.send(Ke.BatchDelete,e,ao)}batchGetPublicUserCustomDataOf(e){return this.send(Ke.BatchGetPublicUserCustomDataOf,e,lo)}};var Wf={Static:"Static",Runtime:"Runtime"},Qf={Public:"Public",Private:"Private"},Kf=zod.z.enum(["Client","Server","System"]).catch("Client"),Hf=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),$f=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Kf.nullish(),ExpiresAt:u.nullish()}).passthrough(),Hl=zod.z.record(zod.z.string(),$f),hn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:Hl.nullish(),Runtime:Hl.nullish(),NotModified:zod.z.boolean().nullish()}),Zf=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:Hf.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Ki=zod.z.object({Keys:zod.z.record(zod.z.string(),Zf).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(),Kt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Hi=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(Kt.GetTitleCustomDataDefinitions,e,Ki)}getPublicTitleData(e){return this.send(Kt.GetPublicTitleData,e,hn)}getPublicTitleDataKeys(e){return this.send(Kt.GetPublicTitleDataKeys,e,hn)}};var Jf={Fast:"Fast",Sequential:"Sequential"},Yf={Instant:"Instant",Timed:"Timed"};var Xf={Hit:"Hit",Blocked:"Blocked"},eg=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),tg=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();var rg=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:L.nullish()}).passthrough(),ig=zod.z.object({Reward:L.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(rg).nullish(),Rate:ig.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 $l=zod.z.object({}).passthrough().transform(o=>o),Zl=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),sg=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),ng=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(),og=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:me.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(),ag=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:me.nullish()}).passthrough(),Jl=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(),lg=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(),ug=zod.z.object({Tiles:zod.z.record(zod.z.string(),lg).nullish()}).passthrough(),cg=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),pg=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(cg).nullish(),GuaranteedBonus:Pe.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),dg=zod.z.object({Variants:zod.z.array(pg).nullish()}).passthrough(),hg=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Pe.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),mg=zod.z.object({Outcomes:zod.z.array(hg).nullish()}).passthrough(),Yl=zod.z.object({PerAdMultiplierRange:Zl.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),fg=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),gg=zod.z.object({Tiers:zod.z.array(fg).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:Pe.nullish()}).passthrough(),Rg=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),yg=zod.z.object({Reward:Pe.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),Cg=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(Rg).nullish(),Rate:yg.nullish()}).passthrough(),Xl=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),Cg).nullish()}).passthrough(),Sg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:Yl.nullish(),Gradation:gg.nullish(),RunStats:Xl.nullish()}).passthrough(),xg=zod.z.object({Choices:zod.z.array(Sg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),Dg=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),bg=zod.z.object({OnPassStart:Pe.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Pe).nullish(),OnAttack:zod.z.record(zod.z.string(),Pe).nullish(),OnRaid:zod.z.record(zod.z.string(),Pe).nullish(),OnBuild:Pe.nullish(),OnStageComplete:Pe.nullish(),OnAttackBonusDrops:zod.z.array(Dg).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),mg).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),xg).nullish()}).passthrough(),eu=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(Jl).nullish(),HeistGridBonusConfig:dg.nullish(),StageOperations:bg.nullish(),TileLandingMultiplier:Zl.nullish(),EconomyOverride:ag.nullish()}).passthrough(),zg=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(Jl).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:eu.nullish()}).passthrough(),$i=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(),ug).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),eu).nullish(),StagesByLevel:zod.z.record(zod.z.string(),zg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:og.nullish(),Dice:sg.nullish(),Bots:ng.nullish()}).passthrough(),Tg=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(),ze).nullish(),GrandPrize:L.nullish()}).passthrough(),Zi=zod.z.object({Board:$i.nullish(),CommunityChest:Tg.nullish()}).passthrough(),vg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:Te.nullish(),TargetBuildingStates:zod.z.array(eg).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),Pg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:Yl.nullish(),RunStats:Xl.nullish()}).passthrough(),Ig=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(Pg).nullish()}).passthrough(),kg=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(),tu=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:vg.nullish(),SpecialModeOffer:Ig.nullish(),CommunityChestContribution:kg.nullish()}).passthrough(),ru=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(),mn=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(tg).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:mt.nullish()}).passthrough(),iu=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(),su=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(),nu=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Mg=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),ou=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:b.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(Mg).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:L.nullish()}).passthrough(),wg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},au=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),Ag={Active:"Active",Left:"Left",Replaced:"Replaced"},Og=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),Ug=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Bg=zod.z.object({UserID:zod.z.string().nullish(),PublicData:Te.nullish(),IsBot:zod.z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:zod.z.array(zod.z.string()).nullish(),GrandPrizeClaimed:zod.z.boolean().nullish(),MemberStatus:Og.nullish(),JoinedAtUtc:u.nullish(),LeftAtUtc:u.nullish()}).passthrough(),lu=zod.z.object({GroupID:zod.z.string().nullish(),TitleID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),Members:zod.z.array(Bg).nullish(),SharedProgress:Ug.nullish(),Status:au.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Lg=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:au.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),qg=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Lg).nullish()}).passthrough(),uu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:qg.nullish(),ActiveGroup:lu.nullish(),SecondsRemaining:M.nullish()}),cu=zod.z.object({ServerTimeUtc:u.nullish(),Group:lu.nullish(),SecondsRemaining:M.nullish()}),fn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),pu=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 Eg=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(),Gg=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(Eg).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(),du=zod.z.object({Experiments:zod.z.record(zod.z.string(),Gg).nullish()}).passthrough();var Ng={Mesh:"Mesh",Host:"Host"},gn=zod.z.enum(["Mesh","Host"]).catch("Mesh"),jg={ServerRelay:"ServerRelay",P2P:"P2P"},Rn=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),Fg={Public:"Public",Private:"Private"},Vg=zod.z.enum(["Public","Private"]).catch("Public"),_g={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},Wg=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),hu=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(),mu=zod.z.object({SystemState:Qg.nullish(),DefaultTopology:gn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Rn.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(hu).nullish()}).passthrough(),Kg=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(),Hg=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:gn.nullish(),ChatMode:Rn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),$g=zod.z.object({Seq:zod.z.number().nullish(),Type:Wg.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(),Ji=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:gn.nullish(),ChatMode:Rn.nullish(),Visibility:Vg.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(Kg).nullish(),IceServers:zod.z.array(hu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),yn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),fu=zod.z.object({Rooms:zod.z.array(Hg).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),gu=zod.z.object({Envelopes:zod.z.array($g).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),Yi=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ve={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Cn=zod.z.object({TitleCustomData:Ki.nullish(),Character:$r.nullish(),Item:ui.nullish(),Currency:Hr.nullish(),Store:pi.nullish(),Lootbox:Hs.nullish(),Quest:rr.nullish(),TimedEvent:xi.nullish(),Leaderboard:Pi.nullish(),Season:ki.nullish(),Reward:$s.nullish(),Collection:qi.nullish(),Craft:sn.nullish(),DealOffer:cn.nullish(),Premium:rn.nullish(),TimedBoost:_i.nullish(),CoopEvent:Gi.nullish(),GameLoop:Zi.nullish(),Match:Es.nullish(),Experiment:du.nullish(),Blockchain:ws.nullish(),Marketplace:Fs.nullish(),Multiplayer:mu.nullish(),UserCustomData:jr.nullish(),Referral:pn.nullish(),Localization:ma.nullish()}).passthrough();var St={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var Xi=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,Cn)}getTitlePublicConfigurationExcept(e){return this.send(St.GetTitlePublicConfigurationExcept,e,Cn)}getCurrencyDefinitions(e){return this.send(St.GetCurrencyDefinitions,e,Hr)}getItemDefinitions(e){return this.send(St.GetItemDefinitions,e,ui)}getServerTime(e){return this.send(St.GetServerTime,e,De)}};var es=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,Zi)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,$i,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,$i,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,$l)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,tu)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,ru)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,mn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,mn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,iu)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,su)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,nu)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,ou)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,uu)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,cu)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,fn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,fn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,pu)}};var Ht=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Ht),zod.z.record(zod.z.string(),Ht)]));var Jg={Live:"Live",Latest:"Latest",Specific:"Specific"},Yg={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Xg=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),eR={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"},tR=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),rR=zod.z.object({Level:Xg,Message:zod.z.string().nullish(),Data:Ht.nullish()}),iR=zod.z.object({Error:tR,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),Ru=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Ht.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(rR).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:iR.nullish()}),Sn={Execute:"Execute"};var ts=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=A(this.ctx.settings.titleID,"CloudCode",Sn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,Ru,{ticket:e.ClientSessionTicket})}};var rs=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(Ue.GetDefinitions,e,Lo)}getUserState(e){return this.send(Ue.GetUserState,e,qo)}depositToken(e){return this.send(Ue.DepositToken,e,Eo)}depositNFT(e){return this.send(Ue.DepositNFT,e,Go)}requestTokenWithdrawal(e){return this.send(Ue.RequestTokenWithdrawal,e,No)}requestNFTWithdrawal(e){return this.send(Ue.RequestNFTWithdrawal,e,jo)}getTransactionHistory(e){return this.send(Ue.GetTransactionHistory,e,Fo)}retryWithdrawal(e){return this.send(Ue.RetryWithdrawal,e,Vo)}confirmWithdrawal(e){return this.send(Ue.ConfirmWithdrawal,e,_o)}donateToDeveloper(e){return this.send(Ue.DonateToDeveloper,e,Us)}donateToUsersPool(e){return this.send(Ue.DonateToUsersPool,e,Us)}};var is=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,Vs)}getOffer(e){return this.send(ae.GetOffer,e,oa)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Vs)}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,Vt)}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,Vt)}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,Vt)}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,Vt)}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 ss=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(Ve.CreateRoom,e,Ji)}joinRoom(e){return this.send(Ve.JoinRoom,e,Ji)}leaveRoom(e){return this.send(Ve.LeaveRoom,e,yn)}listRooms(e){return this.send(Ve.ListRooms,e,fu)}getRoom(e){return this.send(Ve.GetRoom,e,Ji)}closeRoom(e){return this.send(Ve.CloseRoom,e,yn)}poll(e){return this.send(Ve.Poll,e,gu)}sendSignal(e){return this.send(Ve.SendSignal,e,Yi)}sendChat(e){return this.send(Ve.SendChat,e,Yi)}setMemberState(e){return this.send(Ve.SetMemberState,e,Yi)}};var ns=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=Tn(e),this.emitter=new Et,this.platform=e.platform??new zt,this.clientPlatform=e.clientPlatform??In(),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new nr({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new ur(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 cr(this.platform.storage,this.settings.titleID),this.api={authentication:new si(this),user:new oi(this),currency:new ai(this),item:new ci(this),store:new di(this),purchase:new hi(this),lootbox:new gi(this),reward:new Ri(this),quest:new Si(this),tutorial:new yi(this),localization:new Ci(this),timedEvent:new Di(this),leaderboard:new Ii(this),season:new Mi(this),premium:new Ai(this),character:new Oi(this),match:new Ui(this),craft:new Li(this),collection:new Ei(this),coopEvent:new Ni(this),dealOffer:new ji(this),referral:new Fi(this),social:new Vi(this),timedBoost:new Wi(this),userCustomData:new Qi(this),titleCustomData:new Hi(this),title:new Xi(this),gameLoop:new es(this),cloudCode:new ts(this),blockchain:new rs(this),marketplace:new is(this),multiplayer:new ss(this)},this.userService=new mr(this),this.auth=new pr(this),this.currency=new gr(this),this.item=new Rr(this),this.store=new yr(this),this.purchase=new Cr(this),this.checkout=new Sr(this),this.lootbox=new xr(this),this.reward=new Dr(this),this.quest=new vr(this),this.tutorial=new br(this),this.localization=new Tr(this),this.timedEvent=new Pr(this),this.leaderboard=new Ir(this),this.season=new kr(this),this.premium=new Mr(this),this.character=new wr(this),this.match=new Ar(this),this.craft=new Or(this),this.collection=new Ur(this),this.coopEvent=new Br(this),this.dealOffer=new Lr(this),this.referral=new qr(this),this.social=new Er(this),this.timedBoost=new Gr(this),this.userCustomData=new Fr(this),this.titleCustomData=new Vr(this),this.title=new _r(this),this.gameLoop=new Wr(this),this.cloudCode=new Qr(this),this.blockchain=new Yr(this),this.marketplace=new ri(this),this.multiplayer=new ii(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 os=class{ctx;constructor(e){this.ctx=new ns(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 sR(o){return new os(o)}var yu="idos_sso",Cu="state",xn="idos:sso:state",nR="https://idosgames.com/sso/";function oR(){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(yu);if(!t)return null;let r=e.get(Cu)??"",i=pR();return hR(e),dR(),i&&r!==i?null:{code:t,state:r}}function aR(o){if(typeof window>"u")return;let e=o.returnTo??lR(),t=uR();cR(t);let r=new URL(o.ssoUrl??nR);r.searchParams.set("title",o.titleID),r.searchParams.set("return_to",e),r.searchParams.set("state",t),window.location.assign(r.toString());}function lR(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function uR(){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 cR(o){try{window.sessionStorage.setItem(xn,o);}catch{}}function pR(){try{return window.sessionStorage.getItem(xn)}catch{return null}}function dR(){try{window.sessionStorage.removeItem(xn);}catch{}}function hR(o){o.delete(yu),o.delete(Cu);let e=o.toString(),{pathname:t,search:r}=window.location;window.history.replaceState(null,"",`${t}${r}${e?`#${e}`:""}`);}function mR(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function fR(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function gR(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function xu(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*Su(o,t,1);break;case "TableAbsolute":a=Su(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 RR(o,e,t=1){return xu(o,1,e,t)}function yR(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 Du(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 Du(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 Su(o,e,t){let r=Du(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 SR={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Dn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),xR={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},DR=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),bR=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Dn.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(),zR=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(),TR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),vR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:DR.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),PR=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),IR=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),kR=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(),MR=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(),wR=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(),AR=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Dn.nullish()}).passthrough(),OR={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},UR=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),BR=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:UR.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(),AR).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),bR).nullish(),Providers:zod.z.record(zod.z.string(),BR).nullish(),RewardedVideo:zR.nullish(),Interstitial:TR.nullish(),Banner:vR.nullish(),AppOpen:PR.nullish(),FrequencyCapping:IR.nullish(),PremiumAdReductions:zod.z.array(kR).nullish(),Consent:MR.nullish(),Verification:wR.nullish()}).passthrough();var LR=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),qR=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(),ER=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(),GR=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(),NR=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(),jR=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Dn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),FR=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:LR.nullish(),Placements:zod.z.record(zod.z.string(),qR).nullish(),Daily:ER.nullish(),Session:GR.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:NR.nullish(),PendingRequests:zod.z.record(zod.z.string(),jR).nullish(),FraudFlags:FR.nullish(),UpdatedAt:u.nullish()}).passthrough();var VR={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},_R=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),WR={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"]).catch("Admin"),KR={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},HR=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),$R=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(),ZR=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(),$R).nullish(),Segments:zod.z.array(ZR).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:Te.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:_R.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:HR.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 bu="idos_device_id",as=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(bu);return e||(e="noop-device",this.storage.setString(bu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
- exports.AdProviderKind=OR;exports.AdType=SR;exports.AttackOutcome=Xf;exports.AuthType=ge;exports.AuthenticationAction=we;exports.BannerPosition=xR;exports.BlockchainAction=Ue;exports.BlockchainNetworkType=$p;exports.BlockchainOperationCategory=wo;exports.BlockchainTransactionStatus=sd;exports.BlockchainTransactionType=Xp;exports.BodyPart=Id;exports.BoostWindowKind=Vf;exports.BroadcastStatus=KR;exports.BrowserPlatformAdapter=zt;exports.BrowserStorage=xt;exports.CharacterAction=Oe;exports.ClientPlatform=Ye;exports.CloudCodeAction=Sn;exports.CloudCodeErrorCode=eR;exports.CloudCodeLogLevel=Yg;exports.CloudCodeRevisionSelection=Jg;exports.CollectionAction=ve;exports.CommissionSink=Hd;exports.CommunityChestMemberStatus=Ag;exports.CommunityChestStatus=wg;exports.ConversionRateMode=Tp;exports.CoopEventAction=He;exports.CoopGroupStatus=$m;exports.CoopMemberStatus=Zm;exports.CraftAction=Bi;exports.CraftType=Bm;exports.CurrencyAction=Kr;exports.CurrencyStatus=zp;exports.CurrencyType=_e;exports.CurveInterpolation=_u;exports.CurveShape=Fu;exports.CustomDataBucket=st;exports.CustomDataValueType=mp;exports.CustomDataWriter=cp;exports.DEFAULT_BASE_URL=zn;exports.DealNodeRuntimeStatus=lf;exports.DealOfferAction=rt;exports.DealOfferActivationStatus=af;exports.EnvelopeType=_g;exports.EventTokenType=ku;exports.FodderSelectionMode=Ch;exports.FodderValuationMode=Rh;exports.FriendActionStatus=wf;exports.GameLoopAction=Se;exports.IDosGamesClient=os;exports.IapProductType=Bh;exports.IapPurchaseStatus=Nh;exports.IapStoreValues=Iu;exports.ItemAction=li;exports.KycStatus=ed;exports.KycTier=rd;exports.LeaderboardAction=be;exports.LocalizationAction=ni;exports.LocalizationMissingKeyMode=dh;exports.LootboxAction=fi;exports.MailboxMessageSource=WR;exports.MailboxMessageStatus=VR;exports.MarketGoodsType=ti;exports.MarketOfferStatus=Kd;exports.MarketOfferType=Qd;exports.MarketplaceAction=ae;exports.MatchAction=tt;exports.MatchStatus=kd;exports.MemoryStorage=Dt;exports.MultiplayerAction=Ve;exports.MultiplayerChatMode=jg;exports.MultiplayerTopology=Ng;exports.NoopPlatformAdapter=as;exports.PremiumAction=Rt;exports.PurchaseAction=At;exports.QuestAction=Qe;exports.QuestObjectiveSource=ec;exports.QuestPrerequisiteMode=rc;exports.QuestStatus=Ju;exports.RaidMode=Jf;exports.ReferralAction=yt;exports.ResourceEntryType=$t;exports.RewardAction=ot;exports.RoomVisibility=Fg;exports.ScheduleMode=Mu;exports.SeasonAction=ht;exports.SocialAction=$e;exports.SpecialChoiceMode=Yf;exports.StoreAction=wt;exports.StoreType=Am;exports.TimedBoostAction=Ct;exports.TimedBoostStackingPolicy=Bf;exports.TimedEventAction=Fe;exports.TimelineEventType=Af;exports.TitleAction=St;exports.TitleCustomDataAction=Kt;exports.TitleDataBucket=Qf;exports.TitleDataScope=Wf;exports.TradeOfferStatus=Em;exports.TransactionDirection=nd;exports.TutorialAction=qe;exports.TutorialBoardAction=Rc;exports.TutorialFlowStatus=mc;exports.TutorialGateMode=Lu;exports.TutorialRestartPolicy=dc;exports.TutorialScriptModule=gc;exports.TutorialStepCompletionMode=cc;exports.TypedEmitter=Et;exports.UserAction=je;exports.UserCustomDataAction=Ke;exports.WalletLinkType=Jp;exports.beginSsoRedirect=aR;exports.claimedMilestoneIDs=fR;exports.createIDosGamesClient=sR;exports.curveMultiplier=RR;exports.evaluateCurve=xu;exports.grantedPremiumTiers=gR;exports.isCurveConfigured=yR;exports.isFail=Au;exports.isMilestoneClaimed=mR;exports.isOk=wu;exports.normalizeBlockchainCategory=Zr;exports.readSsoCodeFromUrl=oR;exports.roundAmount=CR;exports.zPaymentProof=Bp;exports.zPriceOption=Ro;exports.zPriceOptions=J;
1
+ 'use strict';var zod=require('zod'),ui=require('decimal.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ui__default=/*#__PURE__*/_interopDefault(ui);var Nt=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 qu(){let o=new Map;return {get:e=>o.get(e)??null,set:(e,t)=>{o.set(e,t);},remove:e=>{o.delete(e);}}}function In(){return Eu()??qu()}function Eu(){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 kn="https://api.idosgames.com";function Mn(o){return {titleID:o.titleID,titleTemplateID:o.titleTemplateID??"default",buildKey:o.buildKey??"",baseUrl:(o.baseUrl??kn).replace(/\/+$/,""),devBuild:o.devBuild??false,debugLogging:o.debugLogging??false,configStorage:o.configStorage??In(),locale:o.locale??Gu(),appVersion:o.appVersion??""}}function Gu(){try{return globalThis.navigator?.language??""}catch{return ""}}var Dt=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{}}},bt=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 vt(){return globalThis.Telegram?.WebApp??null}function P(){return crypto.randomUUID()}var wn="idos_device_id",zt=class{storage;constructor(e=new Dt){this.storage=e;}getPlatform(){return vt()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=vt()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=vt()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(wn);return e||(e=P(),this.storage.setString(wn,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=vt();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=vt();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 ps="idos_acq",Nu=["gclid","fbclid","ttclid","msclkid","yclid"],ju=["ref","r"],Fu=["ref_","ref-","ref=","r_","r-"];var mt=class{constructor(e){this.platform=e;}platform;capture(){let e=this.readFromEnvironment();Vu(e)&&this.store({signal:e,capturedAt:Date.now()});}buildForLogin(e){let t=this.read(),i=t?{...t.signal}:{},r=_u(this.platform.getDeviceModel());return r&&(i.OsVersion=r),e&&(i.AppVersion=e),Object.keys(i).length>0?i:void 0}clear(){this.platform.storage.remove(ps);}static detectDevicePlatform(e){let t=(e||"").toLowerCase();return t.includes("android")?"Android":/iphone|ipad|ipod/.test(t)?"iOS":"Web"}static parseReferralCode(e){if(!e)return null;let t=e.trim();if(!t)return null;if(t.includes("://")||t.includes("?")){let i=On(An(t));if(i)return i}return ds(t)}readFromEnvironment(){let e={},t=An(this.platform.getFullURL());Tt(e,"UtmSource",t.get("utm_source")),Tt(e,"UtmMedium",t.get("utm_medium")),Tt(e,"UtmCampaign",t.get("utm_campaign")),Tt(e,"UtmTerm",t.get("utm_term")),Tt(e,"UtmContent",t.get("utm_content")),Tt(e,"ClaimToken",t.get("idos_click"));for(let p of Nu){let x=t.get(p);if(x){e.ClickID=x;break}}let i=ds(this.platform.getStartParameter()??""),r=On(t),s=i||r;s&&(e.ReferralCode=s,e.ChannelHint=i?"telegram":"query");let a=this.platform.getReferrer?.();return a&&(e.Referrer=a),e}read(){try{let e=this.platform.storage.getString(ps);if(!e)return null;let t=JSON.parse(e);return !t?.signal||typeof t.capturedAt!="number"?null:Date.now()-t.capturedAt>2592e6?(this.clear(),null):t}catch{return null}}store(e){try{this.platform.storage.setString(ps,JSON.stringify(e));}catch{}}};function Vu(o){return !!(o.UtmSource||o.UtmMedium||o.UtmCampaign||o.ClickID||o.Referrer||o.ReferralCode||o.ClaimToken)}function Tt(o,e,t){t&&(o[e]=t);}function An(o){try{let e=o.indexOf("?");return new URLSearchParams(e>=0?o.slice(e):"")}catch{return new URLSearchParams}}function On(o){for(let e of ju){let t=o.get(e);if(t)return ds(t)}return null}function ds(o){let e=(o||"").trim();if(!e)return null;for(let t of Fu)if(e.toLowerCase().startsWith(t)){e=e.slice(t.length).trim();break}return e||null}function _u(o){let e=o||"",t=/android\s+(\d+)/i.exec(e);if(t)return t[1];let i=/(?:iphone )?os\s+(\d+)[._]/i.exec(e);if(i)return i[1]}var Un="idos_usage_pending",Bn="idos_usage_session",Ln="idos_usage_closed_session",qn="idos_usage_new_session",En="idos_usage_last_activity",jt=class{constructor(e){this.ctx=e;}ctx;pendingSeconds=0;currentSessionSeconds=0;pendingClosedSessionSeconds=0;isNewSessionPending=false;lastTickAt=0;suspendedAt=null;countingPaused=false;timer=null;started=false;flushing=false;start(){this.started||typeof window>"u"||(this.started=true,this.restore(),this.lastTickAt=Date.now(),this.countingPaused=typeof document<"u"&&document.visibilityState==="hidden",this.timer=setInterval(()=>this.tick(),200*1e3),window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide));}async stop(){this.started&&(this.started=false,this.timer&&(clearInterval(this.timer),this.timer=null),typeof window<"u"&&(window.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide)),this.accumulate(),this.closeCurrentSession(false),await this.flush());}onVisibilityChange=()=>{if(!(typeof document>"u")){if(document.visibilityState==="hidden"){this.accumulate(),this.countingPaused=true,this.suspendedAt=Date.now(),this.flush();return}this.countingPaused=false,this.suspendedAt!==null&&((Date.now()-this.suspendedAt)/1e3>=300&&this.closeCurrentSession(true),this.suspendedAt=null),this.lastTickAt=Date.now();}};onPageHide=()=>{this.accumulate(),this.persist(),this.flush();};tick(){this.accumulate(),this.flush();}accumulate(){let e=Date.now(),t=Math.floor((e-this.lastTickAt)/1e3);this.lastTickAt=e,!(t<=0)&&(this.countingPaused||(this.pendingSeconds+=t,this.currentSessionSeconds+=t,this.persist()));}closeCurrentSession(e){let t=Math.floor(this.currentSessionSeconds);t>0&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t)),this.currentSessionSeconds=0,e&&(this.isNewSessionPending=true),this.persist();}async flush(){if(this.flushing||this.pendingSeconds<=0&&this.pendingClosedSessionSeconds<=0&&!this.isNewSessionPending)return;let e=this.pendingSeconds,t=this.pendingClosedSessionSeconds,i=this.isNewSessionPending;this.flushing=true,this.pendingSeconds=0,this.pendingClosedSessionSeconds=0,this.isNewSessionPending=false,this.persist();try{(await this.ctx.userService.addUsageTime(e,i,t)).ok||(this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist());}catch{this.pendingSeconds+=e,this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,t),this.isNewSessionPending||=i,this.persist();}finally{this.flushing=false;}}restore(){this.pendingSeconds=this.readNumber(Un),this.currentSessionSeconds=this.readNumber(Bn),this.pendingClosedSessionSeconds=this.readNumber(Ln),this.isNewSessionPending=this.readNumber(qn)!==0;let e=this.readNumber(En);this.currentSessionSeconds>0&&e>0&&(Date.now()-e)/1e3>=300&&(this.pendingClosedSessionSeconds=Math.max(this.pendingClosedSessionSeconds,Math.floor(this.currentSessionSeconds)),this.currentSessionSeconds=0);}persist(){this.writeNumber(Un,this.pendingSeconds),this.writeNumber(Bn,this.currentSessionSeconds),this.writeNumber(Ln,this.pendingClosedSessionSeconds),this.writeNumber(qn,this.isNewSessionPending?1:0),this.writeNumber(En,Date.now());}readNumber(e){let t=this.ctx.platform.storage.getString(e),i=t?Number(t):0;return Number.isFinite(i)&&i>0?i:0}writeNumber(e,t){try{this.ctx.platform.storage.setString(e,String(Math.floor(t)));}catch{}}};var _e={Virtual:"Virtual",Crypto:"Crypto"},It=zod.z.enum(["Virtual","Crypto"]).catch("Virtual"),Yt={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",RewardedVideoCredit:"RewardedVideoCredit",Purchase:"Purchase"},Xt=zod.z.enum(["Item","VirtualCurrency","CryptoCurrency","RewardedVideoCredit","Purchase"]).catch("Item"),Ye={Unknown:"Unknown",Web:"Web",Android:"Android",Ios:"Ios"},ei=zod.z.enum(["Unknown","Web","Android","Ios"]).catch("Unknown"),Wu={GooglePlay:"GooglePlay",AppleAppStore:"AppleAppStore"},ti=zod.z.enum(["GooglePlay","AppleAppStore"]).catch("GooglePlay"),Qu={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},ii=zod.z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]).catch("TimedEvent"),Ku={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Ft=zod.z.enum(["Cyclic","Scheduled","Chained"]).catch("Cyclic"),Re={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};function Nn(){let o=globalThis,e=o.Capacitor?.getPlatform?.();if(e)return Gn(e);let t=o.cordova?.platformId;return t?Gn(t):o.navigator?.userAgent??""?Ye.Web:Ye.Unknown}function Gn(o){let e=o.toLowerCase();return e==="android"?Ye.Android:e==="ios"?Ye.Ios:e==="web"?Ye.Web:Ye.Unknown}function Vt(o){return {ok:true,data:o}}function n(o,e){return {ok:false,reason:o,error:e}}function Hu(o){return o.ok}function $u(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 hs=zod.z.object({Type:Xt.nullish(),CurrencyID:zod.z.string().nullish(),Amount:M.nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ProductID:zod.z.string().nullish()}),Zu=zod.z.object({Type:ii.nullish(),EntityID:zod.z.string()}),Ju=zod.z.object({Address:Zu.nullish(),Amount:M.nullish(),Source:zod.z.string().nullish()}),ge=zod.z.object({Entries:zod.z.array(hs).nullish(),EventTokens:zod.z.array(Ju).nullish()}),jn=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Resources:ge.nullish()}),L=zod.z.object({Standard:ge.nullish(),PremiumBonuses:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(jn).nullish()}),_t=zod.z.object({Standard:ge.nullish(),PremiumDiscounts:zod.z.array(zod.z.unknown()).nullish(),PremiumTiers:zod.z.array(jn).nullish()}),b=zod.z.object({Grant:L.nullish(),Consume:_t.nullish()}),ft=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:ge.nullish()});var Yu=zod.z.object({ExperimentID:zod.z.string().nullish(),Variants:zod.z.array(zod.z.string()).nullish()}).passthrough(),Xu={Completed:"Completed",Started:"Started",StepReached:"StepReached"},ec=zod.z.object({FlowIDs:zod.z.array(zod.z.string()).nullish(),Mode:zod.z.enum(["Completed","Started","StepReached"]).catch("Completed").nullish(),StepID:zod.z.string().nullish(),Negate:zod.z.boolean().nullish(),SkippedCountsAsCompleted:zod.z.boolean().nullish()}).passthrough(),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:Yu.nullish(),Tutorial:ec.nullish(),Platforms:zod.z.array(ei).nullish()}).passthrough();var ue=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 tc=zod.z.object({OffsetSecondsFromParentStart:zod.z.number().nullish(),DurationSeconds:zod.z.number().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),ic=zod.z.object({StartUtc:zod.z.string().nullish(),EndUtc:zod.z.string().nullish(),AllowEarningAfterEnd:zod.z.boolean().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),rc=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 sc=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:ue.nullish()}).passthrough(),de=zod.z.object({Mode:zod.z.string().nullish(),IsActive:zod.z.boolean().nullish(),Scheduled:ic.nullish(),Chain:rc.nullish(),Cyclic:sc.nullish(),ActivationTriggers:zod.z.array(Le).nullish(),Relative:tc.nullish()}).passthrough();var nc={Flat:"Flat",PerStep:"PerStep",PerStepRate:"PerStepRate",Geometric:"Geometric",Table:"Table",TableAbsolute:"TableAbsolute"},oc=zod.z.enum(["Flat","PerStep","PerStepRate","Geometric","Table","TableAbsolute"]).catch("Flat"),ac={Step:"Step",Linear:"Linear",Geometric:"Geometric"},lc=zod.z.enum(["Step","Linear","Geometric"]).catch("Step"),uc=zod.z.object({AtStep:zod.z.number().nullish(),Value:zod.z.number().nullish()}).passthrough(),xe=zod.z.object({Base:zod.z.number().nullish(),Shape:oc.nullish(),PerStep:zod.z.number().nullish(),PerStepRate:zod.z.number().nullish(),GrowthRate:zod.z.number().nullish(),Points:zod.z.array(uc).nullish(),Interpolation:lc.nullish(),TailGrowthRate:zod.z.number().nullish(),MinResult:zod.z.number().nullish(),MaxResult:zod.z.number().nullish()}).passthrough();var cc=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Rewards:L.nullish()}).passthrough(),pc=zod.z.object({SeasonChainID:zod.z.string().nullish(),MinSeasonTier:zod.z.number().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),ms=zod.z.object({Bundles:zod.z.array(cc).nullish(),Multipliers:zod.z.array(pc).nullish()}).passthrough();var dc=zod.z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]).catch("BoardStageLevel"),ri=zod.z.object({Source:dc.nullish(),SourceKey:zod.z.string().nullish(),Curve:xe.nullish(),Anchor:zod.z.number().nullish(),IncludeRewards:ge.nullish(),ExcludeRewards:ge.nullish()}).passthrough(),ve=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:ms.nullish(),SortOrder:zod.z.number().nullish(),IsFeatured:zod.z.boolean().nullish()}).passthrough(),ut=zod.z.object({Milestones:zod.z.record(zod.z.string(),ve).nullish()}).passthrough();var Y=zod.z.object({PresetID:zod.z.string().nullish(),Remove:zod.z.array(zod.z.string()).nullish()}).passthrough();var hc=zod.z.object({TargetCurrencyID:zod.z.string().nullish(),Rate:zod.z.number().nullish(),MaxConvertAmount:zod.z.number().nullish()}).passthrough(),gt=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:hc.nullish()}).passthrough();var re=o=>zod.z.object({Id:zod.z.string(),Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:o.nullish()}),Xe=o=>zod.z.object({ServerTimeUtc:u,Items:zod.z.array(re(o)),Resources:b.nullish()});var mc={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Fn=zod.z.enum(["Active","Completed","Claimed","Expired"]).catch("Active"),fc=zod.z.object({}).passthrough().transform(o=>o),gc=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()}),fs=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:Fn}),Vn=zod.z.object({State:fc.nullish(),PointsTracks:zod.z.record(zod.z.string(),gc).nullish()}),gs=zod.z.object({ServerTimeUtc:u,QuestID:zod.z.string(),CycleID:zod.z.string().nullish(),NewStatus:Fn.nullish(),Resources:b.nullish()}),Rs=zod.z.object({ServerTimeUtc:u,CycleID:zod.z.string(),MilestoneID:zod.z.string(),PointsTotalEarned:M.nullish(),Resources:b.nullish()}),_n=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(fs).nullish()}),Qn=zod.z.array(re(gs)),Kn=zod.z.array(re(Rs)),Rc={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},yc=zod.z.enum(["ClientApi","ServerApi","SystemEvent"]).catch("ClientApi"),Cc={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Sc=zod.z.enum(["BlockProgressAndClaim","BlockClaimOnly"]).catch("BlockProgressAndClaim"),Hn=zod.z.object({ObjectiveID:zod.z.string().nullish(),Source:yc.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(),ys=zod.z.object({Milestones:Y.nullish(),Linking:Y.nullish(),Availability:Y.nullish(),Reward:Y.nullish(),Objectives:Y.nullish()}).passthrough(),xc=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(),$n=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:Sc.nullish()}).passthrough(),Zn=zod.z.object({Schedule:de.nullish(),AccrueProgressWhenLocked:zod.z.boolean().nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),Jn=zod.z.object({Grant:L.nullish(),PointsReward:zod.z.number().nullish()}).passthrough(),Dc=zod.z.object({QuestID:zod.z.string().nullish(),Identity:xc.nullish(),Linking:$n.nullish(),Availability:Zn.nullish(),Objectives:zod.z.record(zod.z.string(),Hn).nullish(),Reward:Jn.nullish(),Presets:ys.nullish()}).passthrough(),bc=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(),vc=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(),ve).nullish(),Presets:ys.nullish(),PointsToken:gt.nullish()}).passthrough(),zc=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),Linking:zod.z.record(zod.z.string(),$n).nullish(),Availability:zod.z.record(zod.z.string(),Zn).nullish(),Reward:zod.z.record(zod.z.string(),Jn).nullish(),Objectives:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Hn)).nullish()}).passthrough(),Tc=zod.z.object({CycleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Gate:W.nullish(),PointsToken:gt.nullish(),GroupCompletions:zod.z.record(zod.z.string(),bc).nullish(),Phases:zod.z.record(zod.z.string(),vc).nullish(),Presets:ys.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ni=zod.z.object({Cycles:zod.z.record(zod.z.string(),Tc).nullish(),Quests:zod.z.record(zod.z.string(),Dc).nullish(),Presets:zc.nullish()}).passthrough(),Qe={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Pc={ClientAck:"ClientAck",SystemEvent:"SystemEvent",Auto:"Auto",Composite:"Composite"},Ic=zod.z.enum(["ClientAck","SystemEvent","Auto","Composite"]).catch("ClientAck"),kc={Never:"Never",OnRequest:"OnRequest",Always:"Always"},Mc=zod.z.enum(["Never","OnRequest","Always"]).catch("Never"),wc={NotStarted:"NotStarted",InProgress:"InProgress",Completed:"Completed",Skipped:"Skipped",Expired:"Expired"},Ac=zod.z.enum(["NotStarted","InProgress","Completed","Skipped","Expired"]).catch("NotStarted"),Oc={GameLoop:"GameLoop"},Uc={Raid:"Raid",Attack:"Attack"},Bc=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(),Lc=zod.z.object({Mode:Ic.nullish(),Triggers:zod.z.array(Le).nullish(),TargetValue:zod.z.number().nullish(),RequireAllTriggers:zod.z.boolean().nullish()}).passthrough(),qc=zod.z.object({Grant:L.nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),Ec=zod.z.object({TileType:zod.z.string().nullish(),TileIndex:zod.z.number().nullish(),ChanceOutcomeID:zod.z.string().nullish(),RandomActionType:zod.z.enum(["Raid","Attack"]).catch("Raid").nullish()}).passthrough(),Gc=zod.z.object({Module:zod.z.enum(["GameLoop"]).catch("GameLoop").nullish(),Board:Ec.nullish(),MaxUses:zod.z.number().nullish()}).passthrough(),Nc=zod.z.object({Skippable:zod.z.boolean().nullish(),TimeoutSeconds:zod.z.number().nullish()}).passthrough(),Cs=zod.z.object({StepID:zod.z.string().nullish(),Order:zod.z.number().nullish(),Identity:Bc.nullish(),Completion:Lc.nullish(),Effects:qc.nullish(),Script:Gc.nullish(),Policy:Nc.nullish()}).passthrough(),jc=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(),Yn=zod.z.object({Schedule:de.nullish(),Gate:W.nullish(),RequiredFlowIDs:zod.z.array(zod.z.string()).nullish(),AutoStart:zod.z.boolean().nullish(),StartTrigger:Le.nullish()}).passthrough(),Xn=zod.z.object({Skippable:zod.z.boolean().nullish(),SkippableFromOrder:zod.z.number().nullish(),RestartPolicy:Mc.nullish(),ExpireAfterSeconds:zod.z.number().nullish(),IsBlocking:zod.z.boolean().nullish(),UnlockFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),eo=zod.z.object({Grant:L.nullish(),AutoClaim:zod.z.boolean().nullish()}).passthrough(),Fc=zod.z.object({Availability:Y.nullish(),Policy:Y.nullish(),Reward:Y.nullish(),Steps:Y.nullish()}).passthrough(),Vc=zod.z.object({FlowID:zod.z.string().nullish(),Identity:jc.nullish(),Availability:Yn.nullish(),Policy:Xn.nullish(),Steps:zod.z.record(zod.z.string(),Cs).nullish(),Reward:eo.nullish(),Presets:Fc.nullish()}).passthrough(),_c=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(),Wc=zod.z.object({IsEnabled:zod.z.boolean().nullish(),MaxActiveFlows:zod.z.number().nullish(),Blocking:_c.nullish()}).passthrough(),Qc=zod.z.object({Availability:zod.z.record(zod.z.string(),Yn).nullish(),Policy:zod.z.record(zod.z.string(),Xn).nullish(),Reward:zod.z.record(zod.z.string(),eo).nullish(),Steps:zod.z.record(zod.z.string(),zod.z.record(zod.z.string(),Cs)).nullish()}).passthrough(),to=zod.z.object({Flows:zod.z.record(zod.z.string(),Vc).nullish(),Settings:Wc.nullish(),Presets:Qc.nullish()}).passthrough(),Kc=zod.z.object({}).passthrough().transform(o=>o),io=zod.z.object({FlowID:zod.z.string(),Status:Ac,CurrentStepID:zod.z.string().nullish(),CurrentStep:Cs.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(),ro=zod.z.object({State:Kc.nullish(),Flows:zod.z.array(io).nullish(),UnlockedFeatures:zod.z.array(zod.z.string()).nullish()}).passthrough(),ct=zod.z.object({Flow:io.nullish()}).passthrough(),so=zod.z.object({FlowID:zod.z.string().nullish(),Granted:b.nullish()}).passthrough(),no=zod.z.array(re(ct)),oo=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 oi=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 ai=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function ao(o){return o===429||o>=500&&o<=599}function Ss(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 xs(o){return new Promise(e=>setTimeout(e,o))}var Hc=12e3,$c=zod.z.object({Success:zod.z.boolean(),Error:zod.z.string().nullish(),Data:zod.z.unknown().optional(),QuestProgress:zod.z.array(fs).nullish(),TutorialProgress:zod.z.array(oo).nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish(),StateEpoch:zod.z.string().nullish()}).passthrough(),li=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;clientPlatform;inflight=new ai;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 oi(e.throttleMs),this.clientPlatform=e.clientPlatform??Ye.Unknown;}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,i,r={}){let s=r.throttleKey??e;if(!this.throttler.tryAcquire(s))return n("throttled","Throttled");if(!this.inflight.add(s))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let a=`${this.baseUrl}/${e}`,p=JSON.stringify(t),x=r.ticket??null,U=r.silent??!1,E=r.timeoutMs??Hc,me=r.autoRetry??!0,ye=!1,ke=0;for(;;){let Ze;try{Ze=await this.doFetch(a,p,x,E);}catch{if(me&&ke<3){ke++,await xs(Ss(ke));continue}return this.connectionFailure("Internet Connection Error",U)}let Je=Ze.status;if(Je>=200&&Je<300)return await this.parseSuccess(Ze,i,U,e);if(Je===401){if(!ye&&this.sessionRefreshHandler){ye=!0;let rt=null;try{rt=await this.sessionRefreshHandler();}catch{rt=null;}if(rt){x=rt;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(ao(Je)){if(me&&ke<3){ke++,await xs(Ss(ke));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Je})`,U)}return await this.handleWebError(Ze,Je,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=$c.safeParse(a);if(!p.success)return this.globalError("Malformed response envelope",i);if(!p.data.Success){let ye=p.data.Error??"Server returned Success=false";return i||this.emitter.emit("error:global",ye),n("server",ye)}let x=p.data.QuestProgress;x&&x.length>0&&this.emitter.emit("quest:systemProgress",x);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 me=t.safeParse(p.data.Data);if(!me.success){let ye=`Validation error (${r}): ${me.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",ye),i||this.emitter.emit("error:global",ye),n("validation",ye)}return Vt(me.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 Mt(o){return (typeof o=="string"?o:o.toISOString()).slice(0,10)}function Wt(o){return `${Mt(o)}T00:00:00.000Z`}function uo(o){let e=new Date(o);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function co(o,e){return new Date(o.getTime()+e*6e4).toISOString()}function po(o,e,t,i){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;o.InventoryV2??={};let s=o.InventoryV2,a=i.toISOString(),p=new Map,x=new Map,U=new Map,E=new Map,me=new Map,ye=new Map,ke=new Map,Ze=new Map,Je=e.Grant?.PremiumTiers??[],rt=Je.length;for(let ne=0;;ne++){let fe,$;if(ne===0)fe=e.Grant?.Standard?.Entries,$=false;else if(ne-1<rt)fe=Je[ne-1]?.Resources?.Entries,$=false;else if(ne===1+rt)fe=e.Consume?.Standard?.Entries,$=true;else break;if(fe)for(let _ of fe){if(_.Type==null)continue;let K=Math.max(0,_.Amount??0);if(!(K<=0))switch(_.Type){case "VirtualCurrency":{if(!_.CurrencyID)continue;let H=$?x: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 ui__default.default(0)).plus(K));break}case "Item":{if(!_.ItemID)continue;let H=Jc(t,_.CatalogID,_.ItemID),X=(H?H.IsStackable??true:true)?$?ye:me:$?Ze:ke;X.set(_.ItemID,(X.get(_.ItemID)??0)+K);break}case "Purchase":case "RewardedVideoCredit":continue}}}if(r.vcChanged=p.size>0||x.size>0,r.vcChanged){s.VirtualCurrencies??={};for(let ne of new Set([...p.keys(),...x.keys()])){let fe=p.get(ne)??0,$=x.get(ne)??0,_=fe-$,K=s.VirtualCurrencies[ne];K?(K.Amount+=_,K.UpdatedAt=a,K.Daily&&Mt(K.Daily.PeriodStartUtc)===Mt(i)?(K.Daily.Earned+=fe,K.Daily.Spent+=$):K.Daily={PeriodStartUtc:Wt(i),Earned:fe,Spent:$}):s.VirtualCurrencies[ne]={Amount:_,CreatedAt:a,UpdatedAt:a,Daily:{PeriodStartUtc:Wt(i),Earned:fe,Spent:$}};}}if(r.ccChanged=U.size>0||E.size>0,r.ccChanged){s.CryptoCurrencies??={};for(let ne of new Set([...U.keys(),...E.keys()])){let fe=U.get(ne)??new ui__default.default(0),$=E.get(ne)??new ui__default.default(0),_=fe.minus($),K=s.CryptoCurrencies[ne];K?(K.Amount=new ui__default.default(K.Amount).plus(_).toString(),K.UpdatedAt=a):s.CryptoCurrencies[ne]={Amount:_.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a};}}if(r.itemsChanged=me.size>0||ye.size>0||ke.size>0||Ze.size>0,r.itemsChanged){s.Items??={},s.UnstackableItems??={};let ne=s.UnstackableItems,fe=new Set([...me.keys(),...ye.keys(),...ke.keys(),...Ze.keys()]);for(let $ of fe){let _=(me.get($)??0)-(ye.get($)??0),K=(ke.get($)??0)-(Ze.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 Ze){if(_<=0)continue;let K=Object.values(ne).filter(H=>H.ItemID===$&&H.EquippedSlot==null&&(H.ExpiresAt==null||new Date(H.ExpiresAt)>i)).sort(Zc).slice(0,_).map(H=>H.ItemInstanceID);for(let H of K)delete ne[H];}for(let[$,_]of ke){let K=Yc(t,$);for(let H=0;H<_;H++){let Be=P();ne[Be]={ItemInstanceID:Be,ItemID:$,CatalogID:K,RemainingUses:1,AcquiredAt:a};}}}o.EventToken??={};let Lu=o.EventToken;for(let ne=0;;ne++){let fe,$;if(ne===0)fe=e.Grant?.Standard?.EventTokens,$=false;else if(ne-1<rt)fe=Je[ne-1]?.Resources?.EventTokens,$=false;else if(ne===1+rt)fe=e.Consume?.Standard?.EventTokens,$=true;else break;if(!(!fe||fe.length===0))for(let _ of fe){let K=_.Address;if(!K||K.Type==null)continue;let H=_.Amount??0;if(H<=0)continue;let Be=Xc(Lu,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:Wt(i),TotalEarned:0},X.Meta??={};let Gt=_.Source&&_.Source.length>0?_.Source:"CustomAction";$?(X.Balance.Current-=H,X.Balance.TotalSpent+=H):(X.Balance.Current+=H,X.Balance.TotalEarned+=H,Mt(X.Daily.Date)!==Mt(i)&&(X.Daily={Date:Wt(i),TotalEarned:0}),X.Daily.TotalEarned+=H,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[Gt]=(X.Daily.EarnedBySource[Gt]??0)+H,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[Gt]=(X.Daily.TriggersBySource[Gt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[Gt]=a,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=a),X.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 Jc(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 Yc(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 Xc(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 Ds(o,e){return o===e||o.startsWith(`${e}:`)}var ci=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=po(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 ui__default.default?t:new ui__default.default(t),a=i??new Date().toISOString(),p=r[e];p?(p.Amount=new ui__default.default(p.Amount).plus(s).toString(),p.UpdatedAt=a):r[e]={Amount:s.toString(),Frozen:"0",CreatedAt:a,UpdatedAt:a},this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyStore(e){this.currentState??={},this.currentState.Store=e??{},this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchStorePurchase(e,t,i){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,s=r[e];s||(s={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=s),s.TotalPurchases+=t,s.LastPurchasedAt=i,i>=s.DailyResetUtc?(s.DailyPurchases=t,s.DailyResetUtc=uo(i)):s.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,i){if(!e||i<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let s=new Date().toISOString();for(let a of t)a.RuleID&&(r.Pity[`${e}:${a.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:s});}this.emitter.emit("user:lootboxUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReward(e){this.currentState??={},this.currentState.Reward=e??{},this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchDailyCalendarState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.DailyCalendars??={},this.currentState.Reward.DailyCalendars[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchIdleAccrualState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.IdleAccruals??={},this.currentState.Reward.IdleAccruals[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchComebackState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Comebacks??={},this.currentState.Reward.Comebacks[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchClaimRewardState(e,t){!e||!t||(this.currentState??={},this.currentState.Reward??={},this.currentState.Reward.Claims??={},this.currentState.Reward.Claims[e]=t,this.emitter.emit("user:rewardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyQuest(e){this.currentState??={},this.currentState.Quest=e??{},this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestStatus(e,t,i){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let s=r.Cycles[t];if(!s)return;s.Quests??={};let a=s.Quests[e]??={QuestID:e,Status:i};a.Status=i,i==="Claimed"&&(a.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let s=r.PermanentQuests[e]??={QuestID:e,Status:i};s.Status=i,i==="Claimed"&&(s.ClaimedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMilestoneClaimed(e,t){if(!e||!t)return;let i=this.getQuestPointsProgress(e);i&&(i.Milestone??={},this.markMilestoneClaimed(i.Milestone,t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let i of Object.values(e)){if(!i.CycleID)continue;let r=i.InstanceKey?`${i.CycleID}:${i.InstanceKey}`:i.CycleID,s=t[r]??={};s.Balance??={Current:0,TotalEarned:0,TotalSpent:0},s.Balance.Current=i.PointsCurrent??0,s.Balance.TotalEarned=i.PointsTotalEarned??0,s.Milestone??={};for(let a of i.ClaimedPointMilestoneIDs??[])this.markMilestoneClaimed(s.Milestone,a);}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let i=this.currentState.Quest.Cycles[e];i&&(i.ClaimedGroupCompletionIDs??=[],i.ClaimedGroupCompletionIDs.includes(t)||i.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyTutorial(e){this.currentState??={},this.currentState.Tutorial=e??{},this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialFlow(e){if(!e?.FlowID)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};let i=t.Flows[e.FlowID]??={FlowID:e.FlowID};i.Status=e.Status,i.CurrentStepID=e.CurrentStepID??null,i.RewardClaimed=e.RewardClaimed,e.VariantID!==void 0&&(i.VariantID=e.VariantID),this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchTutorialProgress(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Tutorial??={};let t=this.currentState.Tutorial;t.Flows??={};for(let i of e){if(!i.FlowID||!i.StepID)continue;let r=t.Flows[i.FlowID]??={FlowID:i.FlowID,Status:"InProgress"};r.Steps??={};let s=r.Steps[i.StepID]??={StepID:i.StepID};s.Progress=i.Progress,i.Completed&&(s.CompletedAtUtc??=new Date().toISOString(),r.CurrentStepID===i.StepID&&(r.CurrentStepID=null));}this.emitter.emit("user:tutorialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchQuestProgressUpdates(e){if(!e||e.length===0)return;this.currentState??={},this.currentState.Quest??={};let t=this.currentState.Quest;for(let i of e){if(!i.QuestID)continue;let r;if(!i.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};else {t.Cycles??={};let s=t.Cycles[i.CycleID];if(!s)continue;s.Quests??={},r=s.Quests[i.QuestID]??={QuestID:i.QuestID,Status:i.Status};}if(r.Status=i.Status,i.ObjectiveID){r.Objectives??={};let s=r.Objectives[i.ObjectiveID]??={ObjectiveID:i.ObjectiveID,CurrentValue:0,Completed:false};s.CurrentValue=i.NewValue??0,i.ObjectiveCompleted&&(s.Completed=true,s.CompletedAtUtc??=new Date().toISOString());}i.Status==="Completed"&&(r.CompletedAtUtc??=new Date().toISOString());}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getQuestPointsProgress(e){if(!e)return null;let t=this.currentState?.EventToken?.Quest;if(!t)return null;for(let[i,r]of Object.entries(t))if(Ds(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))!Ds(r,t)||!s||this.markMilestoneClaimed(s.Milestone??(s.Milestone={}),i);this.patchActiveEventMilestoneClaimed(e,t,i),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,i){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let s of r)s.Type!==e||s.TimedEventID!==t||(s.Progress??={},this.markMilestoneClaimed(s.Progress.Milestone??(s.Progress.Milestone={}),i));}markMilestoneClaimed(e,t){e.Claims??={};let i=e.Claims[t]??={};i.ClaimedAt??=new Date().toISOString(),i.Unlocked=false;}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.CurrentScore=t.CurrentScore??0,i.LastKnownRank=t.LastKnownRank??0,i.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,i.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,i.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,i,r){if(!e)return;let s=this.ensureLeaderboardProgress(e);(s.ScoreCycleVersion??0)<r&&(s.ScoreEarnedThisCycle=0,s.ClaimedMilestoneIDs=[],s.BracketID=null),s.CurrentScore=t,s.ScoreEarnedThisCycle=(s.ScoreEarnedThisCycle??0)+i,s.ScoreCycleVersion=r,s.LastScoreSubmitUtc=new Date().toISOString(),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardCycleRewardClaimed(e){if(!e)return;let t=this.currentState?.Leaderboard?.ProgressByCycle?.[e];t&&(t.UnclaimedRewardCycleVersion=0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchLeaderboardMilestoneClaimed(e,t){if(!e||!t)return;let i=this.ensureLeaderboardProgress(e);i.ClaimedMilestoneIDs??=[],i.ClaimedMilestoneIDs.includes(t)||i.ClaimedMilestoneIDs.push(t),this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureLeaderboardProgress(e){this.currentState??={},this.currentState.Leaderboard??={},this.currentState.Leaderboard.ProgressByCycle??={};let t=this.currentState.Leaderboard.ProgressByCycle,i=t[e];return i||(i={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=i),i}applySeasonsState(e){this.currentState??={},this.currentState.Season=e??{},this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonState(e,t){!e||!t||(this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={},this.currentState.Season.States[e]=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchSeasonCurrentTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let i=this.ensureSeasonState(e);i.ClaimedTierRewards??=[],i.ClaimedTierRewards.includes(t)||i.ClaimedTierRewards.push(t),this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSeasonState(e){this.currentState??={},this.currentState.Season??={},this.currentState.Season.States??={};let t=this.currentState.Season.States,i=t[e];return i||(i={SeasonChainID:e},t[e]=i),i}applyPremium(e){this.currentState??={},this.currentState.Premium=e??{},this.emitter.emit("user:premiumUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCharacter(e){this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters=e??{},this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacter(e,t){if(!e)return;this.currentState??={},this.currentState.Character??={},this.currentState.Character.Characters??={};let i=this.currentState.Character.Characters,r=i[e];r||(r={CharacterID:e},i[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,i){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},i===null?delete r.Equipment[t]:r.Equipment[t]=i,this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyInventoryDelta(e){if(!e)return;this.currentState??={},this.currentState.InventoryV2??={},this.currentState.InventoryV2.UnstackableItems??={};let t=this.currentState.InventoryV2.UnstackableItems,i=false;for(let[r,s]of Object.entries(e.ChangedInstances??{}))t[r]=s,i=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],i=true);i&&(this.emitter.emit("user:inventoryUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyMatch(e){this.currentState??={},this.currentState.Match=e??{},this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchMatchStrategy(e){e&&(this.currentState??={},this.currentState.Match??={},this.currentState.Match.PvPBattleStrategy=e,this.emitter.emit("user:matchUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applyCollection(e){this.currentState??={},this.currentState.Collection=e??{},this.emitter.emit("user:collectionUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCoopEvent(e){this.currentState??={},this.currentState.CoopEvent=e??{MyObjectIndex:-1},this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCoopEventActiveGroup(e,t,i){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=i,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.PendingActivationReward=false,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialOutgoingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.OutgoingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),t.Accepted??=[],t.Accepted.includes(e)||t.Accepted.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveIncomingRequest(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialRemoveFriend(e){if(!e)return;let t=this.ensureSocial();t.Accepted=(t.Accepted??[]).filter(i=>i!==e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}ensureSocial(){return this.currentState??={},this.currentState.Social??={},this.currentState.Social}applyTimedBoost(e){this.currentState??={},this.currentState.TimedBoost=e??{},this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchActiveTimedBoost(e,t){this.currentState??={},this.currentState.TimedBoost??={},this.currentState.TimedBoost.Active??={};let i=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(i)){let s=i[r];s&&s.BoostID===e.BoostID&&r!==e.InstanceID&&delete i[r];}i[e.InstanceID]=e,this.emitter.emit("user:timedBoostUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyUserCustomData(e){this.currentState??={},this.currentState.CustomData??={};let t=this.currentState.CustomData;t.Version=e.Version??0,t.Private=e.Private??{},t.Public=e.Public??{},t.ReadOnly=e.ReadOnly??{},this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchUserCustomDataKey(e,t,i,r,s){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let a=this.currentState.CustomData,p={Value:i,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:s??null};if(e==="Private")a.Private??={},a.Private[t]=p;else if(e==="Public")a.Public??={},a.Public[t]=p;else return;a.Version=(a.Version??0)+1,this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}removeUserCustomDataKey(e,t){if(!t||!this.currentState?.CustomData)return;let i=this.currentState.CustomData;if(e==="Private")i.Private&&delete i.Private[t];else if(e==="Public")i.Public&&delete i.Public[t];else return;this.emitter.emit("user:customDataUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyBoardState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyCommunityChestUserState(e){this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.CommunityChest=e??{},this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardState(e){let t=this.ensureBoard();e(t),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardBuilding(e,t){if(e<0)return;let i=this.ensureBoard();i.BuildingStates??=[];let r=i.BuildingStates.find(s=>s.SlotIndex===e);r||(r={SlotIndex:e},i.BuildingStates.push(r)),t(r),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchBoardPendingRaidLayout(e,t){let r=this.ensureBoard().Pending;r&&(e&&(r.RaidLayout=e),t>=0&&(r.OpenedIndices??=[],r.OpenedIndices.includes(t)||r.OpenedIndices.push(t)),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchBoardSpecialPending(e){let i=this.ensureBoard().Pending;!i||i.Type.toUpperCase()!=="SPECIAL"||(i.Special??={},e(i.Special),this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}clearBoardPending(){let e=this.currentState?.GameLoop?.Board;!e||!e.Pending||(e.Pending=null,this.emitter.emit("user:gameLoopUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}ensureBoard(){return this.currentState??={},this.currentState.GameLoop??={},this.currentState.GameLoop.Board??={},this.currentState.GameLoop.Board}applyBlockchainState(e,t){this.currentState??={},this.currentState.Blockchain=e??{},t&&(this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies=t),this.emitter.emit("user:blockchainUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyMarketplaceState(e){this.currentState??={},this.currentState.Marketplace=e??{},this.emitter.emit("user:marketplaceUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}getVirtualCurrencyAmount(e){return this.currentState?.InventoryV2?.VirtualCurrencies?.[e]?.Amount??0}getCryptoCurrencyAmount(e){return this.currentState?.InventoryV2?.CryptoCurrencies?.[e]?.Amount??"0"}};var pi=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 di=class{user;config;constructor(e){this.user=new ci(e),this.config=new pi;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var hi=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 ep(e)?e:Re.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 ep(o){return o!==null&&Object.values(Re).includes(o)}var tp=8,ip=100,rp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,ho=["GameLoop"],mi=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=Re.None;sessionEmail="";sessionPassword="";pendingRegistration=null;get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL(),Attribution:this.ctx.acquisition.buildForLogin(this.ctx.settings.appVersion)}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(Re.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(Re.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(Re.Email);return s.ok&&this.keepEmailCredentials(e,t),s}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.Password=t,i.DeviceID=this.ctx.platform.getDeviceID(),i.Device=this.ctx.platform.getDeviceModel(),i.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(i);return r.ok?(this.pendingRegistration={email:e,password:t},Vt({codeTtlMinutes:r.data.CodeTtlMinutes??0,resendCooldownSeconds:r.data.ResendCooldownSeconds??0})):r}async confirmEmailRegistration(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let i=this.baseRequest();i.Email=e,i.VerificationCode=t;let r=await this.ctx.api.authentication.confirmEmailRegistration(i);if(!r.ok)return r;this.applyAuthContext(r.data);let s=await this.fetchAndApplyClientState(Re.Email);return s.ok&&this.pendingRegistration?.email===e&&this.keepEmailCredentials(e,this.pendingRegistration.password),this.pendingRegistration=null,s}async resendVerificationCode(e){let t=this.baseRequest();t.Email=e;let i=await this.ctx.api.authentication.resendVerificationCode(t);return i.ok?Vt(void 0):i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let i=await this.ctx.api.authentication.loginWithGoogle(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Re.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(Re.Wallet)):s}async loginWithSsoCode(e){if(!e)return n("client","SSO code is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.SsoCode=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let i=await this.ctx.api.authentication.loginWithSsoCode(t);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(Re.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 Re.Email:return this.loginWithEmail(t,i);case Re.Device:case Re.None:return this.loginWithDeviceID();case Re.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!==Re.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===Re.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&&rp.test(e)}static isValidPasswordLength(e){return e.length>=tp&&e.length<=ip}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=Re.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(ho,ho);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 sp="idos:cfg",wt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${mo(t)}`:e&&e.length>0?`f:${mo(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 `${sp}:${this.titleId}:${e}`}};function mo(o){return [...o].map(e=>e.toLowerCase()).sort().join(",")}var fo="idos:loc",At=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 `${fo}:${this.titleId}:${e}`}versionsKey(){return `${fo}:${this.titleId}:versions`}};var np="idos:state",fi=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 `${np}:${this.titleId}:${e}`}};function op(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 vs(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 ap(o){return {...o??{}}}function zs(o){return typeof o.StateEpoch=="string"&&o.StateEpoch.length>0?o.StateEpoch:null}var gi=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=op(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=ap(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 go=n("server","Title configuration is unavailable (CDN and API both failed)."),Ri=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 wt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get localizationCache(){return this.locCache??=new At(this.ctx.settings.configStorage,this.ctx.settings.titleID)}locCache;get stateStore(){return this.versionStore??=new gi(new fi(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=wt.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?go:(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=vs(e.User,t.cached,t.sent,e.StateVersions);e.User=i;let r=zs(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=wt.scopeOf(null,t??[]),s=await this.configCache.read(r);s&&(i.KnownTitleConfigVersion=s.v),await this.prepareLocalization(i);let a=await this.prepareStateHandshake(i,e??null),p=await this.ctx.api.user.getClientStateExcept(i);if(!p.ok)return p;let x=await this.resolveTitleConfig(p.data,r,s,{ExcludeFields:t??[]});return x==null?go:(this.finishStateHandshake(p.data,a),await this.applyClientState(p.data,x,e,t),await this.applyLocalization(p.data.Localization),await this.flushState(a),p)}async prepareLocalization(e){let t=this.ctx.localization.locale??this.ctx.settings.locale;t&&(e.Locale=t);let i=await this.localizationCache.readVersions();Object.keys(i).length>0&&(e.KnownLocalizationVersions=i);}async applyLocalization(e){if(!e){this.ctx.localization.applyState(null,{table:null,fallbackTable:null});return}let t=await this.resolveLocalizationTable({Locale:e.Locale,Version:e.Version,Url:e.Url}),i=e.Fallback?await this.resolveLocalizationTable(e.Fallback):null;this.ctx.localization.applyState(e,{table:t,fallbackTable:i});}async resolveLocalizationTable(e){let t=e.Locale??null,i=e.Version??0;if(!t)return null;let r=await this.localizationCache.read(t);if(i<=0)return r?.t??null;if(r&&r.v===i)return r.t;if(e.Url){let a=await this.fetchLocalizationFromCdn(e.Url);if(a!=null)return await this.localizationCache.write(t,i,a),a}let s=await this.fetchLocalizationFromApi(t,r?.v??0);return s??r?.t??null}async fetchLocalizationFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let i=await t.json();return i&&typeof i=="object"?i:null}catch{return null}}async fetchLocalizationFromApi(e,t){let i=this.baseRequest();if(!i)return null;let r=await this.ctx.api.localization.getLocalizationTable({...i,Locale:e,KnownVersion:t});if(!r.ok)return null;let s=r.data;if(s.NotModified)return null;let a=s.Entries??{},p=s.Version??0,x=s.Locale??e;return p>0&&await this.localizationCache.write(x,p,a),a}async getStateVersions(e){let t=this.baseRequest();return t?(e&&e.length>0&&(t.Fields=e),this.ctx.api.user.getStateVersions(t)):n("unauthorized","Not logged in.")}async getUserState(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Fields=e);let i=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let s=vs(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=zs(r.data);return p&&(this.stateStore.afterSliceRead(p,r.data.StateVersions),await this.flushState(i)),r}async flushState(e){e.userId&&await this.stateStore.flush(e.userId,this.ctx.data.user.state);}async getUserInventory(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getInventory(e);return t.ok&&(this.ctx.data.user.applyInventory(t.data),this.ctx.emitter.emit("user:inventoryReceived",t.data)),t}async getEventTokens(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getEventTokens(e);return t.ok&&this.ctx.emitter.emit("user:eventTokensReceived",t.data),t}async getUsageTime(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getUsageTime(e);return t.ok&&this.ctx.emitter.emit("user:usageTimeReceived",t.data),t}async addUsageTime(e,t,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=i;let s=await this.ctx.api.user.addUsageTime(r);return s.ok&&this.ctx.emitter.emit("user:usageTimeAdded",s.data),s}async deleteUserAccount(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.deleteUserAccount(e);return t.ok&&this.ctx.emitter.emit("user:accountDeleted",t.data),t}async changeUsername(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Username=e;let i=await this.ctx.api.user.changeUsername(t);return i.ok&&this.ctx.emitter.emit("user:usernameChanged",i.data),i}async applyClientState(e,t,i,r){let s=i?.includes("GameLoop")===true,a=r?.includes("GameLoop")===true,p=s?this.ctx.data.user.state?.GameLoop:void 0,x=a?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let 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=x),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Ci=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===_e.Crypto||i===_e.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()}`},x=await this.ctx.api.currency.convert(p);if(x.ok){let U=x.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 x}async cryptoConvert(e,t,i,r,s,a){let p=s instanceof ui__default.default?s:new ui__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===_e.Virtual&&i===_e.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===_e.Virtual&&!p.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:i,TargetID:r,SourceAmount:p.toString(),TransactionID:a&&a.length>0?a:`crypto_convert_${e}_${t}_to_${i}_${r}_${P()}`},U=await this.ctx.api.currency.cryptoConvert(x);if(U.ok){let E=U.data,me=[],ye=[];if(E.SourceType===_e.Virtual&&me.push({Type:"VirtualCurrency",CurrencyID:E.SourceID,Amount:Math.trunc(Number(E.SourceSpent))}),E.TargetType===_e.Virtual&&ye.push({Type:"VirtualCurrency",CurrencyID:E.TargetID,Amount:Math.trunc(Number(E.TargetCredited))}),me.length>0||ye.length>0){let ke={Consume:me.length>0?{Standard:{Entries:me}}:null,Grant:ye.length>0?{Standard:{Entries:ye}}:null};this.ctx.data.user.applyResourceOperation(ke,this.ctx.data.config.itemDefinitions);}E.SourceType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.SourceID,new ui__default.default(E.SourceSpent).negated(),E.ServerTimeUtc),E.TargetType===_e.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(E.TargetID,new ui__default.default(E.TargetCredited),E.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",E);}return U}};var Si=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 lp="Store",xi=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(lp,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 Di=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getDefinitions(e)}async getUserState(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()};return this.ctx.api.purchase.getUserState(e)}async validatePurchase(e,t,i){if(!t)return n("client","Receipt is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),Store:e,Receipt:t,Signature:i?.signature,ProductID:i?.productID,TransactionID:i?.transactionID},s=await this.ctx.api.purchase.validatePurchase(r);return s.ok&&s.data.Granted&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),s}async validatePurchasesBatch(e){if(!e||e.length===0)return n("client","receipts is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Receipts:e};return this.ctx.api.purchase.validatePurchasesBatch(t)}};var bi=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===Yt.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!==Yt.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 up="Lootbox",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.lootbox.getDefinitions(e);if(t.ok){let i=t.data.LootboxDefinitions;i&&(this.ctx.data.config.patchSection(up,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 cp="Reward";function Ts(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var zi=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(cp,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(!Ts(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(!Ts(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(!Ts(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 pp="Tutorial",Ti=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(pp,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 x=await i(p);return x.ok&&(this.applyFlowView(x.data),this.ctx.emitter.emit("tutorial:stepChanged",x.data)),x}applyFlowView(e){e?.Flow&&this.ctx.data.user.patchTutorialFlow(e.Flow);}async refreshAfterMutation(){await this.getUserTutorialState(false).catch(()=>{});}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Pi=Object.freeze({}),Ii=class{constructor(e){this.ctx=e;}ctx;table={...Pi};fallbackTable=null;currentLocale=null;currentFallbackLocale=null;pluralRules=null;get cache(){return this.tableCache??=new At(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?dp(r,t):r}applyState(e,t){if(!e){this.reset();return}let i=e.Locale??null;this.table=t.table??{...Pi},this.fallbackTable=t.fallbackTable,this.currentFallbackLocale=e.Fallback?.Locale??null,this.setLocaleInternal(i),this.ctx.emitter.emit("localization:changed",{locale:i,fallbackLocale:this.currentFallbackLocale,entryCount:Object.keys(this.table).length});}async setLocale(e){if(!this.baseRequest())return n("unauthorized","Not logged in.");let i=await this.loadTableFromApi(e);if(!i.ok)return i;let{locale:r,table:s,fallbackLocale:a}=i.data,p=null;if(a){let x=await this.loadTableFromApi(a);x.ok&&(p=x.data.table);}return this.table=s,this.fallbackTable=p,this.currentFallbackLocale=a,this.setLocaleInternal(r),this.ctx.emitter.emit("localization:changed",{locale:r,fallbackLocale:a,entryCount:Object.keys(s).length}),{ok:true,data:r}}async getManifest(){let e=this.baseRequest();return e?(e.Locale=this.currentLocale??this.ctx.settings.locale,this.ctx.api.localization.getLocalizationManifest(e)):n("unauthorized","Not logged in.")}reset(){this.table={...Pi},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(Ro(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??Ro(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??{...Pi},fallbackLocale:s.FallbackLocale??null}}}let x=s.Entries??{};return p>0&&await this.cache.write(a,p,x),{ok:true,data:{locale:a,table:x,fallbackLocale:s.FallbackLocale??null}}}lookup(e){let t=this.table[e];return t!==void 0?t:this.fallbackTable?.[e]}resolveKey(e,t){let i=t?.count;if(typeof i!="number")return e;let r=this.pluralCategory(i),s=`${e}.${r}`;if(this.lookup(s)!==void 0)return s;let a=`${e}.other`;return this.lookup(a)!==void 0?a:e}pluralCategory(e){try{return this.pluralRules??=new Intl.PluralRules(this.currentLocale??void 0),this.pluralRules.select(e)}catch{return "other"}}onMissing(e){let t=this.ctx.data.config.titlePublicConfiguration?.Localization?.MissingKeyMode??"ReturnKey";return t==="ReturnEmpty"?"":t==="ReturnMarkedKey"?`\u27E6${e}\u27E7`:e}};function dp(o,e){return o.replace(/\{(\w+)\}/g,(t,i)=>{let r=e[i];return r===void 0?t:String(r)})}function Ro(o){return o.trim().replace(/_/g,"-").toLowerCase()}var hp="Quest",ki=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(hp,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 mp="TimedEvent",Mi=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(mp,t.data),this.ctx.emitter.emit("timedEvent:definitionsLoaded",t.data)),t}async getUserLteState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.timedEvent.getUserLteState(e);return t.ok&&(this.ctx.data.user.applyUserLteState(t.data),this.ctx.emitter.emit("timedEvent:userStateLoaded",t.data)),t}async grantTokens(e,t,i,r,s,a,p=1){if(!t)return n("client","LteID is required.");if(!i)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:i,Outcome:r,AmountOverride:s,SourceParams:a,RollMultiplier:p},U=await this.ctx.api.timedEvent.grantTokens(x);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 fp="Leaderboard",wi=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(fp,t.data),this.ctx.emitter.emit("leaderboard:definitionsLoaded",t.data)),t}async getLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loaded",i.data),i}async getMyProgress(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getMyProgress(t);return i.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),i.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",i.data)),i}async submitScore(e,t){if(!e)return n("client","LeaderboardID is required.");if(t<=0)return n("client","Score must be positive.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),s.NewScore,t,s.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",s);}return r}async submitScoreFromSource(e,t,i,r,s=1){if(!e)return n("client","LeaderboardID is required.");if(!t)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let a={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:i,Params:r,RollMultiplier:s},p=await this.ctx.api.leaderboard.submitScoreFromSource(a);if(p.ok){let x=p.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),x.NewScore,x.NewScore,x.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",x);}return p}async claimCycleReward(e){if(!e)return n("client","LeaderboardID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e},i=await this.ctx.api.leaderboard.claimCycleReward(t);if(i.ok){let r=i.data;this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(e)),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:cycleRewardClaimed",r);}return i}async claimMilestone(e,t){if(!e||!t)return n("client","LeaderboardID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(i);if(r.ok){let s=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(s.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",s);}return r}async getFriendsLeaderboard(e){if(!e)return n("client","LeaderboardID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardID=e;let i=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return i.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",i.data),i}async getLeaderboardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return i.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",i.data),i}async getProgressBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getProgressBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",i.data);}return i}async claimCycleRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(this.cycleDocID(r.Data.LeaderboardID)),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:cycleRewardsClaimedBatch",i.data);}return i}async claimMilestonesBatch(e){if(!e||e.length===0)return n("client","milestones is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Milestones:e},i=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(r.Data.LeaderboardID),r.Data.MilestoneID),r.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.Data.Resources,this.ctx.data.config.itemDefinitions));this.ctx.emitter.emit("leaderboard:milestonesClaimedBatch",i.data);}return i}async submitScoresBatch(e){if(!e||e.length===0)return n("client","scores is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),Scores:e},i=await this.ctx.api.leaderboard.submitScoresBatch(t);if(i.ok){for(let r of i.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(r.Data.LeaderboardID),r.Data.NewScore,r.Data.NewScore,r.Data.CycleVersion);this.ctx.emitter.emit("leaderboard:scoresSubmittedBatch",i.data);}return i}async claimAllRewardsBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),LeaderboardIDs:e},i=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(i.ok){for(let r of i.data){let s=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(s),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let a of r.Milestones??[])!a.Success||!a.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(s,a.Data.MilestoneID),a.Data.Resources&&this.ctx.data.user.applyResourceOperation(a.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",i.data);}return i}async getOverviewBatch(e){if(!e||e.length===0)return n("client","leaderboardIDs is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.LeaderboardIDs=e;let i=await this.ctx.api.leaderboard.getOverviewBatch(t);if(i.ok){for(let r of i.data)r.Progress?.Success&&r.Progress.Data&&this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.LeaderboardID),r.Progress.Data);this.ctx.emitter.emit("leaderboard:overviewLoadedBatch",i.data);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gp="Season",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.season.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(gp,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 x=p.Data?.TierNumber;p.Success&&typeof x=="number"&&this.ctx.data.user.patchSeasonClaimedTier(e,x);}this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Rp="Premium",Oi=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(Rp,t.data.Premium),this.ctx.emitter.emit("premium:definitionsLoaded",t.data)),t}async getUserState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.premium.getUserState(e);return t.ok&&t.data.Premium&&(this.ctx.data.user.applyPremium(t.data.Premium),this.ctx.emitter.emit("premium:stateLoaded",t.data)),t}async activateTrial(e,t){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(i);return r.ok&&(r.data.Premium&&this.ctx.data.user.applyPremium(r.data.Premium),this.ctx.emitter.emit("premium:trialActivated",r.data)),r}async purchaseItemOrCurrency(e,t,i="Default",r=1){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:i,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},a=await this.ctx.api.premium.purchaseItemOrCurrency(s);if(a.ok){let p=a.data;p.Premium&&this.ctx.data.user.applyPremium(p.Premium),this.ctx.data.user.applyResourceOperation(p.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",p);}return a}async purchaseRealMoney(e,t,i,r,s,a,p,x){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!s)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let U={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:i,ProductID:r,ReceiptData:s,PurchaseToken:a,PackageName:p,AppStoreEnvironment:x,RelatedEntityID:`premium_iap_${e}_${t}`},E=await this.ctx.api.premium.purchaseRealMoney(U);if(E.ok){let me=E.data;me.Premium&&this.ctx.data.user.applyPremium(me.Premium),this.ctx.data.user.applyResourceOperation(me.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:realMoneyPurchaseCompleted",me);}return E}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yp="Character",Ui=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(yp,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 Cp="Match",Bi=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,i,r,s,a){let p=this.ctx.auth.context;if(!p)return n("unauthorized","Not logged in.");let x={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:i,BattleStrategy:r,TargetUserID:s,SelectedOptionID:a,RelatedEntityID:`pvp_create_${p.userID}_${P()}`},U=await this.ctx.api.match.createMatch(x);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 x=p.data,U=this.ctx.data.config.itemDefinitions;if(x.Resources)this.ctx.data.user.applyResourceOperation(x.Resources,U);else if(x.ResourcesDual){let E=x.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",x);}return p}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},i=await this.ctx.api.match.saveStrategy(t);return i.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),i}async getMyMatches(e=0,t=20,i){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=i;let s=await this.ctx.api.match.getMyMatches(r);return s.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",s.data),s}async getAvailableMatches(e=0,t=20,i=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=i;let s=await this.ctx.api.match.getAvailableMatches(r);return s.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",s.data),s}async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.match.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Cp,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Sp="Craft",Li=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(Sp,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 xp="Collection",qi=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.collection.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(xp,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 x={...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(x);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 Dp="CoopEvent",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.coopEvent.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(Dp,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 bp="DealOffer",Gi=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(bp,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 vp="Referral",Ni=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(vp,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=mt.parseReferralCode(e)?.toUpperCase();if(!t)return n("client","ReferralCode is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${i.userID}`},s=await this.ctx.api.referral.activateReferralCode(r);if(s.ok){let a=s.data;a.ReferrerUserID&&this.ctx.data.user.patchReferralSubscription(a.ReferrerUserID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",a);}return s}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${i.userID}`},s=await this.ctx.api.referral.claimInviteReward(r);if(s.ok){let a=s.data;a.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(a.RewardID),this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",a);}return s}async claimInviteRewardsBatch(e){let t=(e??[]).map(a=>a?.trim()).filter(Boolean);if(t.length===0)return n("client","InviteRewardIDs is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardIDs:t,RelatedEntityID:`referral_invite_batch_${t.join("_")}_${i.userID}`},s=await this.ctx.api.referral.claimInviteRewardsBatch(r);if(s.ok){let a=s.data;for(let p of a.Items??[])p.Success&&p.Id&&this.ctx.data.user.patchReferralInviteRewardClaimed(p.Id);this.ctx.data.user.applyResourceOperation(a.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardsBatchClaimed",a);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ji=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getOutgoingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getOutgoingRequests(e);return t.ok&&(this.ctx.data.user.applySocialOutgoingRequests(t.data.Friends),this.ctx.emitter.emit("social:outgoingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let i=await this.ctx.api.social.getRecommendedFriends(t);return i.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",i.data),i}async sendFriendRequest(e){if(!e)return n("client","TargetUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.sendFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",i.data)),i}async acceptFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.acceptFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",i.data)),i}async declineFriendRequest(e){if(!e)return n("client","RequesterUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.declineFriendRequest(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",i.data)),i}async removeFriend(e){if(!e)return n("client","FriendUserID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),TargetUserID:e},i=await this.ctx.api.social.removeFriend(t);return i.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",i.data)),i}async getTimeline(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getTimeline(e);return t.ok&&(this.ctx.data.user.applySocialTimeline(t.data.Events),this.ctx.emitter.emit("social:timelineLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var zp="TimedBoost";function Tp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Fi=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(zp,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(!Tp(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 st={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Pp={Client:"Client",Server:"Server",System:"System"},Ip=zod.z.enum(["Client","Server","System"]).catch("Client"),kp=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:Ip.nullish(),ExpiresAt:u.nullish()}).passthrough(),Vi=zod.z.record(zod.z.string(),kp),yo=zod.z.object({Version:zod.z.number().nullish(),Private:Vi.nullish(),Public:Vi.nullish(),ReadOnly:Vi.nullish()}),Ps=zod.z.object({UserID:zod.z.string().nullish(),Version:zod.z.number().nullish(),Public:Vi.nullish()}),Is=zod.z.object({ServerTimeUtc:u.nullish(),Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Mp=zod.z.object({Bucket:zod.z.string().nullish(),KeyID:zod.z.string(),Version:zod.z.number().nullish(),ExpiresAt:u.nullish()}),Co=zod.z.object({ServerTimeUtc:u.nullish(),Results:zod.z.array(Mp).nullish()}),So=zod.z.object({ServerTimeUtc:u.nullish(),DeletedCount:zod.z.number().nullish()}),xo=zod.z.object({Results:zod.z.array(Ps).nullish(),NotFoundUserIDs:zod.z.array(zod.z.string()).nullish()}),wp={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Ap=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),Op=zod.z.object({KeyID:zod.z.string(),Bucket:zod.z.string().nullish(),ValueType:Ap.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),_i=zod.z.object({Keys:zod.z.record(zod.z.string(),Op).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(),Ke={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Up="UserCustomData";function Do(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}var Wi=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(Up,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,st.Private)}async setPublicData(e,t){return this.setData(e,t,st.Public)}async setData(e,t,i){let r=e.trim();if(!Do(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===st.Private?this.ctx.api.userCustomData.setPrivateData(s):this.ctx.api.userCustomData.setPublicData(s));if(p.ok){let x=p.data;this.ctx.data.user.patchUserCustomDataKey(i,x.KeyID,t,x.Version??0,x.ExpiresAt),this.ctx.emitter.emit(i===st.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",x);}return p}async deleteKey(e,t){let i=e.trim();if(!Do(i))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==st.Private&&t!==st.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??st.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 Bp="TitleCustomDataDefinitions",bo=50;function Lp(o){return o.length>0&&!o.includes(".")&&!o.includes("$")}function ks(o){if(o.ExpiresAt==null)return false;let e=Date.parse(o.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function qp(o){let e={};for(let[t,i]of Object.entries(o))ks(i)||(e[t]=i);return e}var Qi=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(Bp,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=>!Lp(s)))return n("client",'KeyID must not contain "." or "$".');if(t.length>bo)return n("client",`At most ${bo} keys per call \u2014 request them in chunks.`);let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(i);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!ks(t))return t.Value;let i=this.staticCache[e];if(i?.Value!=null&&!ks(i))return i.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=qp(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 Ki=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 Ep=15,Gp="GameLoop",Np="BoardDefinition",Hi=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(Gp,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(Np,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=co(new Date,Ep);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(x=>{x.ChoiceID=e,x.ChosenMode=a.Mode??"Timed",x.StartedAtUtc=a.StartedAtUtc??null,x.DurationSeconds=a.DurationSeconds??null,x.AdViewsUsed=0;}),a.Operation&&this.ctx.data.user.applyResourceOperation(a.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",a);}return s}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${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(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${t.userID}_${P()}`,...e&&Object.keys(e).length>0?{RunStats:e}:{}},r=await this.ctx.api.gameLoop.boardSpecialClaim(i);if(r.ok){let s=r.data;this.ctx.data.user.clearBoardPending(),s.Operation&&this.ctx.data.user.applyResourceOperation(s.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",s);}return r}async getCommunityChestState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.gameLoop.getCommunityChestState(e);return t.ok&&(this.ctx.data.user.applyCommunityChestUserState(t.data.UserState??null),this.ctx.emitter.emit("gameLoop:communityChestStateLoaded",t.data)),t}async joinOrCreateCommunityChest(){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let e={...this.ctx.buildAuthedBaseRequest()},t=await this.ctx.api.gameLoop.joinOrCreateCommunityChest(e);if(t.ok){let i=t.data.Group;i?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:i.GroupID,ActiveRoundIndex:i.RoundIndex??void 0}),this.ctx.emitter.emit("gameLoop:communityChestJoined",t.data);}return t}async claimCommunityChestMilestone(e,t){if(!e)return n("client","milestoneID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(i);return r.ok&&(r.data.Resources&&this.ctx.data.user.applyResourceOperation(r.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestMilestoneClaimed",r.data)),r}async claimCommunityChestGrandPrize(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return i.ok&&(i.data.Resources&&this.ctx.data.user.applyResourceOperation(i.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",i.data)),i}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},i=await this.ctx.api.gameLoop.leaveCommunityChest(t);return i.ok&&(i.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",i.data)),i}applyRaidResources(e){e.Operation?this.ctx.data.user.applyResourceOperation(e.Operation,this.itemDefs):e.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(e.DualResult.FromResult,this.itemDefs);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var $i=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 vo=zod.z.object({ServerTimeUtc:u,SourceType:It,SourceID:zod.z.string(),TargetType:It,TargetID:zod.z.string(),SourceSpent:M,FeeAmount:M,RateApplied:q,TargetCredited:M}),zo=zod.z.object({ServerTimeUtc:u,SourceType:It,SourceID:zod.z.string(),TargetType:It,TargetID:zod.z.string(),SourceSpent:q,FeeAmount:q,RateApplied:q,TargetCredited:q}),Zi={Convert:"Convert",CryptoConvert:"CryptoConvert"},jp={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},To=zod.z.enum(["Active","Hidden","Deprecated","Maintenance"]).catch("Active"),Fp={Automatic:"Automatic",Manual:"Manual"},Vp=zod.z.enum(["Automatic","Manual"]).catch("Automatic"),_p=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(),Wp=zod.z.object({Rate:zod.z.number().nullish(),Max:zod.z.number().nullish(),Period:zod.z.number().nullish()}).passthrough(),Qp=zod.z.object({IsTradable:zod.z.boolean().nullish(),IsPurchasable:zod.z.boolean().nullish(),IsRefundable:zod.z.boolean().nullish()}).passthrough(),Kp=zod.z.object({TargetCurrencyType:It.nullish(),TargetCurrencyID:zod.z.string(),Rate:q.nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish(),DailyLimit:zod.z.number().nullish()}).passthrough(),Po=zod.z.object({Enabled:zod.z.boolean().nullish(),RateMode:Vp.nullish(),FeePercent:q.nullish(),Targets:zod.z.array(Kp).nullish()}).passthrough(),Io=zod.z.object({CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough(),Hp=zod.z.object({CurrencyID:zod.z.string(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),Economy:_p.nullish(),Recharge:Wp.nullish(),Conversion:Po.nullish(),Permissions:Qp.nullish(),Audit:Io.nullish(),Status:To.nullish()}).passthrough(),$p=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(),Jp=zod.z.object({DepositsEnabled:zod.z.boolean().nullish(),WithdrawalsEnabled:zod.z.boolean().nullish(),SpendableInGame:zod.z.boolean().nullish(),ConvertibleToVirtual:zod.z.boolean().nullish()}).passthrough(),Ms=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($p).nullish(),Limits:Zp.nullish(),Permissions:Jp.nullish(),Conversion:Po.nullish(),Audit:Io.nullish(),Status:To.nullish()}).passthrough(),Ji=zod.z.object({VirtualCurrencies:zod.z.record(zod.z.string(),Hp).nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ms).nullish()}).passthrough();var ko=zod.z.object({OptionID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Cost:_t.nullish(),AllowedPlatforms:zod.z.array(ei).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),J=zod.z.record(zod.z.string(),ko),Yp=zod.z.object({Store:ti,Receipt:zod.z.string(),Signature:zod.z.string().nullish()}).passthrough();var Mo=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),ItemInstanceID:zod.z.string().nullish(),EquippedAt:u.nullish()}),ws=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(),Mo).nullish(),UpdatedAt:u.nullish()}).passthrough(),Xp=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),ed=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:Xp.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),pt=zod.z.object({ChangedInstances:zod.z.record(zod.z.string(),ed).nullish(),RemovedInstanceIDs:zod.z.array(zod.z.string()).nullish()}),wo=zod.z.object({Characters:zod.z.record(zod.z.string(),ws).nullish()}),As=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()}),Os=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),NewLevel:zod.z.number(),Power:zod.z.number().nullish(),Resources:b.nullish()}),Ao=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Equipment:zod.z.record(zod.z.string(),Mo).nullish(),ReplacedInstanceIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish(),Inventory:pt.nullish()}),Oo=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()}),td=zod.z.object({ClearedSlotIDs:zod.z.array(zod.z.string()).nullish(),Power:zod.z.number().nullish()}),Uo=zod.z.object({ServerTimeUtc:u,Characters:zod.z.record(zod.z.string(),td).nullish(),Inventory:pt.nullish()}),Us=zod.z.object({ServerTimeUtc:u,CharacterID:zod.z.string(),Power:zod.z.number().nullish(),Resources:b.nullish()}),Bo=Xe(Us),Lo=Xe(Os),qo=Xe(As),Eo=zod.z.object({RequiredStatID:zod.z.string(),RequiredLevel:zod.z.number()}).passthrough(),Go=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(Eo).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),id=zod.z.object({SlotID:zod.z.string(),MinCharacterLevel:zod.z.number().nullish(),StatRequirements:zod.z.array(Eo).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(),No=zod.z.object({Slots:zod.z.record(zod.z.string(),id).nullish()}).passthrough(),rd=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(),sd=zod.z.object({ClassID:zod.z.string().nullish(),RarityID:zod.z.string().nullish(),Tags:zod.z.array(zod.z.string()).nullish()}).passthrough(),nd=zod.z.object({UnlockedByDefault:zod.z.boolean().nullish(),PriceOptions:J.nullish()}).passthrough(),od=zod.z.object({Stats:Y.nullish(),Levels:Y.nullish(),Equipment:Y.nullish()}).passthrough(),jo=zod.z.object({MaxRank:zod.z.number().nullish(),FirstPaidRank:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish()}).passthrough(),ad=zod.z.object({CharacterID:zod.z.string(),Identity:rd.nullish(),Classification:sd.nullish(),Unlock:nd.nullish(),Presets:od.nullish(),Equipment:No.nullish(),Stats:zod.z.record(zod.z.string(),Go).nullish(),RankLadder:jo.nullish(),RankStatCurve:xe.nullish(),StatMaxLevelCurve:xe.nullish()}).passthrough(),ld=zod.z.object({Stats:zod.z.record(zod.z.string(),Go).nullish()}).passthrough(),ud=zod.z.object({RankLadder:jo.nullish()}).passthrough(),cd=zod.z.object({Equipment:No.nullish()}).passthrough(),pd=zod.z.object({Stats:zod.z.record(zod.z.string(),ld).nullish(),Levels:zod.z.record(zod.z.string(),ud).nullish(),Equipment:zod.z.record(zod.z.string(),cd).nullish()}).passthrough(),Yi=zod.z.object({Definitions:zod.z.record(zod.z.string(),ad).nullish(),Presets:pd.nullish()}).passthrough(),Oe={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var dd={EVM:"EVM",Solana:"Solana"},hd=zod.z.enum(["EVM","Solana"]).catch("EVM"),md={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},fd=zod.z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]).catch("AutoLinkedFromTransaction"),gd={Token:"Token",Nft:"Nft"},Fo=zod.z.enum(["Token","Nft"]).catch("Token"),Rd={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},yd=zod.z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]).catch("NotRequested"),Cd={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Sd=zod.z.enum(["None","Tier1","Tier2","Tier3"]).catch("None"),xd={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Bs=zod.z.enum(["Pending","Completed","Failed","Expired","Abandoned"]).catch("Pending"),Vo={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Xi(o){let e=o?.trim();return e||Vo.GameTopUp}var Dd={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},_o=zod.z.enum(["UsersCryptoWallet","Game"]).catch("UsersCryptoWallet"),bd=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(),vd=zod.z.object({NetworkID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Type:hd.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(bd).nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zd=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(),Td=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 Pd=zod.z.enum(["OnChain","Combined"]).catch("OnChain"),Id=zod.z.object({Enabled:zod.z.boolean().nullish(),NetworkID:zod.z.string().nullish(),CurrencyID:zod.z.string().nullish(),MinBalance:q.nullish(),BalanceSource:Pd.nullish(),DenyMessage:zod.z.string().nullish()}).passthrough(),kd=zod.z.object({Enabled:zod.z.boolean().nullish(),TokenGates:zod.z.array(Id).nullish(),WalletConnectProjectId:zod.z.string().nullish()}).passthrough(),Ls=zod.z.object({SystemState:zd.nullish(),Networks:zod.z.record(zod.z.string(),vd).nullish(),AccountSafety:Td.nullish(),WalletLogin:kd.nullish()}).passthrough(),Md=zod.z.object({NetworkID:zod.z.string().nullish(),Address:zod.z.string().nullish(),LinkedAt:u.nullish(),LastUsedAt:u.nullish(),LinkType:fd.nullish(),IsSignatureVerified:zod.z.boolean().nullish()}).passthrough(),Qo=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Type:Fo.nullish(),NetworkID:zod.z.string().nullish(),AssetID:zod.z.string().nullish(),Amount:q.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),wd=zod.z.object({Status:yd.nullish(),Tier:Sd.nullish(),VerifiedAt:u.nullish(),ExpiresAt:u.nullish(),RejectedAt:u.nullish(),ProviderReference:zod.z.string().nullish(),RejectionReason:zod.z.string().nullish()}).passthrough(),Ad=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(),Od=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(),Ad).nullish()}).passthrough(),Ud=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(),Bd=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(),Ud).nullish()}).passthrough(),Ld=zod.z.object({Tokens:Od.nullish(),Nfts:Bd.nullish()}).passthrough(),qd=zod.z.object({CurrencyID:zod.z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),Ed=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(qd).nullish()}).passthrough(),Gd=zod.z.object({Version:zod.z.number().nullish(),Stats:Ld.nullish(),LinkedWallets:zod.z.record(zod.z.string(),Md).nullish(),LastWalletLogin:Ed.nullish(),PendingWithdrawals:zod.z.array(Qo).nullish(),Kyc:wd.nullish(),FirstActivityAt:u.nullish(),LastActivityAt:u.nullish(),IsFlagged:zod.z.boolean().nullish(),FlagReason:zod.z.string().nullish()}).passthrough(),Nd=zod.z.object({CurrencyID:zod.z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:u}).passthrough(),er=zod.z.object({CryptoBalances:zod.z.record(zod.z.string(),Nd).nullish(),PendingAdded:Qo.nullish(),PendingRemovedIDs:zod.z.array(zod.z.string()).nullish()}).passthrough(),jd=zod.z.object({Amount:q,Frozen:q,CreatedAt:u.nullish(),UpdatedAt:u.nullish()}).passthrough().transform(o=>o),Fd=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:_o.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Bs.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(),Vd=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:_o.nullish(),From:zod.z.string().nullish(),To:zod.z.string().nullish(),Amount:q.nullish(),Status:Bs.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(),Ko=zod.z.object({To:zod.z.string().nullish(),Amount:zod.z.union([zod.z.string(),zod.z.number()]).nullish()}).passthrough(),qs=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(Ko).nullish(),Signature:zod.z.string().nullish()}).passthrough(),Es=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(Ko).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(),Ho=zod.z.object({Blockchain:Ls.nullish(),CryptoCurrencies:zod.z.record(zod.z.string(),Ms).nullish()}).passthrough(),$o=zod.z.object({State:Gd.nullish(),CryptoBalances:zod.z.record(zod.z.string(),jd).nullish()}).passthrough(),Zo=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:er.nullish()}).passthrough(),Jo=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(),Yo=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:qs.nullish(),SolanaSignature:Es.nullish(),StateDelta:er.nullish()}).passthrough(),Xo=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:qs.nullish(),SolanaSignature:Es.nullish(),StateDelta:er.nullish(),Inventory:pt.nullish()}).passthrough(),ea=zod.z.object({TokenTransactions:zod.z.array(Fd).nullish(),NFTTransactions:zod.z.array(Vd).nullish()}).passthrough(),Gs=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(),ta=zod.z.object({TitleTransactionID:zod.z.string().nullish(),Kind:Fo.nullish(),EvmSignature:qs.nullish(),SolanaSignature:Es.nullish()}).passthrough(),ia=zod.z.object({TitleTransactionID:zod.z.string().nullish(),OnChainTxHash:zod.z.string().nullish(),Status:Bs.nullish(),StateDelta:er.nullish()}).passthrough(),Ue={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var _d="Blockchain",tr=class{constructor(e){this.ctx=e;}ctx;async getDefinitions(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.blockchain.getDefinitions(e);return t.ok&&(this.ctx.data.config.patchSection(_d,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 ui__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=Xi(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 ui__default.default(p.data.AmountNative??0).negated(),p.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",p.data)),p}async requestNFTWithdrawal(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!i)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.NetworkID=t,x.WalletAddress=i,x.Amount=r,x.Category=Xi(s),a!==void 0&&(x.Level=a),p&&(x.ItemInstanceID=p);let U=await this.ctx.api.blockchain.requestNFTWithdrawal(x);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 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 Wd={Head:"Head",Torso:"Torso",Legs:"Legs"},ir=zod.z.enum(["Head","Torso","Legs"]).catch("Head"),Qd={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Ns=zod.z.enum(["Open","InProgress","Cancelled","Completed"]).catch("Open"),na=zod.z.object({AttackTarget:ir,DefenseTarget:ir});var Kd=zod.z.enum(["Hit","Critical","Block","Dodge"]).catch("Hit"),Hd=zod.z.object({RoundIndex:zod.z.number().nullish(),AttackerID:zod.z.string().nullish(),DefenderID:zod.z.string().nullish(),AttackZone:ir.nullish(),DefenseZone:ir.nullish(),HitType:Kd.nullish(),DamageDealt:zod.z.number().nullish(),DefenderHpRemaining:zod.z.number().nullish()}).passthrough(),$d=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),sa=zod.z.object({UserID:zod.z.string().nullish(),SelectedCharacterID:zod.z.string().nullish(),SelectedCharacter:ws.nullish(),BattleStrategy:zod.z.array(na).nullish(),UnstackableItems:zod.z.record(zod.z.string(),Zd).nullish(),Stats:$d.nullish()}).passthrough(),Jd=zod.z.object({WinnerUserID:zod.z.string().nullish(),LoserUserID:zod.z.string().nullish(),Entry:ge.nullish(),NetReward:ge.nullish(),BattleLog:zod.z.array(Hd).nullish(),IsDraw:zod.z.boolean().nullish(),P1BattleProfile:sa.nullish(),P2BattleProfile:sa.nullish()}).passthrough(),oa=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(na).nullish(),TargetUserID:zod.z.string().nullish(),Entry:ge.nullish(),CreationCostPaid:ge.nullish(),RefundCreationCostOnCancel:zod.z.boolean().nullish(),JoinedByUserID:zod.z.string().nullish(),JoinedByCharacterID:zod.z.string().nullish(),JoinedAt:u.nullish(),Status:Ns.nullish(),WinnerUserID:zod.z.string().nullish(),CompletedAt:u.nullish(),IsRewardDistributed:zod.z.boolean().nullish(),RewardDistributedAt:u.nullish()}).passthrough(),aa=zod.z.object({Status:Ns,MatchID:zod.z.string(),Entry:ge.nullish(),Resources:b.nullish()}),la=zod.z.object({Match:oa.nullish()}),ua=zod.z.object({MatchID:zod.z.string(),Status:Ns,Resources:b.nullish()}),ca=zod.z.object({Battle:Jd.nullish(),Resources:b.nullish(),ResourcesDual:ft.nullish()}),js=zod.z.object({Matches:zod.z.array(oa).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}),tt={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Yd=zod.z.enum(["VirtualCurrency","Item","EventToken"]).catch("VirtualCurrency");var Xd=zod.z.enum(["Constant","Variable","Curve"]).catch("Constant"),eh=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(),th=zod.z.enum(["Flat","PercentReduction"]).catch("Flat"),ih=zod.z.object({MaxRounds:zod.z.number().nullish(),BlockDamageMultiplier:zod.z.number().nullish(),MinHitDamage:zod.z.number().nullish(),DefaultCritMultiplier:zod.z.number().nullish(),MaxCritChance:zod.z.number().nullish(),MaxDodgeChance:zod.z.number().nullish(),ArmorMode:th.nullish(),MaxArmorReduction:zod.z.number().nullish()}).passthrough(),rh=zod.z.object({Kind:Xd.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(),sh=zod.z.object({Coefficient:zod.z.number().nullish(),Factors:zod.z.array(rh).nullish()}).passthrough(),Rt=zod.z.object({Terms:zod.z.array(sh).nullish()}).passthrough(),nh=zod.z.object({Health:Rt.nullish(),Damage:Rt.nullish(),Armor:Rt.nullish(),AttackSpeed:Rt.nullish(),CritChance:Rt.nullish(),CritDamage:Rt.nullish(),Dodge:Rt.nullish()}).passthrough(),pa=zod.z.object({StatMapping:eh.nullish(),Combat:ih.nullish(),Formula:nh.nullish()}).passthrough(),oh=zod.z.object({BurnRate:zod.z.number().nullish()}).passthrough(),Fs=zod.z.object({Kind:Yd.nullish(),CurrencyID:zod.z.string().nullish(),CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),TokenType:ii.nullish(),EntityID:zod.z.string().nullish(),MinAmount:zod.z.number().nullish(),MaxAmount:zod.z.number().nullish()}).passthrough(),da=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Fs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),ha=zod.z.object({PriceOptions:J.nullish(),RefundCostOnCancel:zod.z.boolean().nullish(),MaxOpenMatches:zod.z.number().nullish(),Limits:ue.nullish(),AllowPrivateMatches:zod.z.boolean().nullish(),MaxMatchesPerOpponentPerDay:zod.z.number().nullish()}).passthrough(),ah=zod.z.object({RuleID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),Economy:oh.nullish(),Entry:da.nullish(),Creation:ha.nullish(),Settings:pa.nullish()}).passthrough(),lh=zod.z.object({Rules:zod.z.record(zod.z.string(),ah).nullish(),Defaults:pa.nullish(),EntryDefaults:da.nullish(),CreationDefaults:ha.nullish()}).passthrough(),Vs=zod.z.object({InstantBattle:lh.nullish()}).passthrough(),ma=Vs;var uh={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},_s=zod.z.enum(["Listing","Auction","BuyOrder","DirectTrade"]).catch("Listing"),ch={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Ws=zod.z.enum(["Active","Completed","Cancelled","Declined","Expired"]).catch("Active"),ph={Burn:"Burn",Ledger:"Ledger"},dh=zod.z.enum(["Burn","Ledger"]).catch("Burn"),sr={Item:"Item",VirtualCurrency:"VirtualCurrency"},Qs=zod.z.enum(["Item","VirtualCurrency"]).catch("Item"),hh=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),mh=zod.z.object({AllowVirtualCurrency:zod.z.boolean().nullish(),AllowItems:zod.z.boolean().nullish(),AllowEventTokens:zod.z.boolean().nullish(),Allowed:zod.z.array(Fs).nullish(),MaxPositions:zod.z.number().nullish()}).passthrough(),fh=zod.z.object({Percent:zod.z.number().nullish(),MinPerPosition:M.nullish(),Sink:dh.nullish(),LedgerAccountID:zod.z.string().nullish(),PerCatalogOverrides:zod.z.record(zod.z.string(),hh).nullish(),ApplyToDirectTrades:zod.z.boolean().nullish()}).passthrough(),gh=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(),Rh=zod.z.object({Enabled:zod.z.boolean().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),MaxActiveListings:zod.z.number().nullish(),CreateLimits:ue.nullish(),BuyLimits:ue.nullish(),ListingFeeOptions:J.nullish(),RefundListingFeeOnCancel:zod.z.boolean().nullish()}).passthrough(),yh=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:ue.nullish()}).passthrough(),Ch=zod.z.object({Enabled:zod.z.boolean().nullish(),MaxActiveOrders:zod.z.number().nullish(),AllowedDurationsHours:zod.z.array(zod.z.number()).nullish(),CreateLimits:ue.nullish(),FillLimits:ue.nullish()}).passthrough(),Sh=zod.z.object({Enabled:zod.z.boolean().nullish(),OfferExpirationHours:zod.z.number().nullish(),MaxPendingOutgoing:zod.z.number().nullish(),AllowGifts:zod.z.boolean().nullish(),CreateLimits:ue.nullish()}).passthrough(),xh=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Ks=zod.z.object({Enabled:zod.z.boolean().nullish(),Gate:W.nullish(),Schedule:de.nullish(),PricePolicy:mh.nullish(),Commission:fh.nullish(),Tradability:gh.nullish(),Listings:Rh.nullish(),Auctions:yh.nullish(),BuyOrders:Ch.nullish(),DirectTrades:Sh.nullish(),Matching:xh.nullish()}).passthrough(),fa=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(),Dh=zod.z.object({BidAxisType:Xt.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(fa).nullish()}).passthrough(),rr=zod.z.object({LastAt:u.nullish(),DailyCount:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),bh=zod.z.object({Create:rr.nullish(),Buy:rr.nullish(),Sell:rr.nullish(),Bid:rr.nullish()}).passthrough(),vh=zod.z.object({CharacterID:zod.z.string().nullish(),SlotID:zod.z.string().nullish()}).passthrough(),zh=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:vh.nullish(),CustomData:zod.z.string().nullish()}).passthrough().transform(o=>o),nt=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:_s.nullish(),Status:Ws.nullish(),CreatorUserID:zod.z.string().nullish(),CreatorPublicData:ze.nullish(),TargetUserID:zod.z.string().nullish(),GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:zod.z.array(zh).nullish(),Price:ge.nullish(),Auction:Dh.nullish(),CreatedAt:u.nullish(),ExpiresAt:u.nullish()}).passthrough(),Th=zod.z.object({GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),CountsByType:zod.z.record(_s,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),ga=zod.z.object({Definitions:Ks.nullish(),IsOpenNow:zod.z.boolean().nullish(),GatePassed:zod.z.boolean().nullish()}).passthrough(),Hs=zod.z.object({Offers:zod.z.array(nt).nullish(),ContinuationToken:zod.z.string().nullish()}).passthrough(),Ra=zod.z.object({Groups:zod.z.array(Th).nullish()}).passthrough(),ya=zod.z.object({Offer:nt.nullish()}).passthrough(),Ge=zod.z.object({OfferID:zod.z.string().nullish(),Status:Ws.nullish(),Settlement:ft.nullish(),Resources:b.nullish(),CommissionTaken:ge.nullish()}).passthrough(),Qt=zod.z.object({OfferID:zod.z.string().nullish(),Offer:nt.nullish(),Resources:b.nullish(),Matched:zod.z.boolean().nullish(),Settlement:Ge.nullish()}).passthrough(),Ca=zod.z.object({OfferID:zod.z.string().nullish(),CurrentBid:M.nullish(),BidCount:zod.z.number().nullish(),ExpiresAt:u.nullish(),Resources:b.nullish()}).passthrough(),Sa=zod.z.object({MyOffers:zod.z.array(nt).nullish(),MyLeadingBids:zod.z.array(nt).nullish(),MyBuyOrders:zod.z.array(nt).nullish(),IncomingTrades:zod.z.array(nt).nullish(),OutgoingTrades:zod.z.array(nt).nullish(),Claimables:zod.z.array(nt).nullish(),DrainedRefunds:zod.z.array(fa).nullish(),Limits:bh.nullish()}).passthrough(),Ph=zod.z.object({OfferID:zod.z.string().nullish(),OfferType:_s.nullish(),FinalStatus:Ws.nullish(),SellerUserID:zod.z.string().nullish(),BuyerUserID:zod.z.string().nullish(),GoodsType:Qs.nullish(),GoodsCatalogID:zod.z.string().nullish(),GoodsItemID:zod.z.string().nullish(),GoodsCurrencyID:zod.z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:ge.nullish(),CommissionTaken:ge.nullish(),CompletedAt:u.nullish()}).passthrough(),xa=zod.z.object({Entries:zod.z.array(Ph).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 Ih="Marketplace",nr=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(Ih,t.data.Definitions),this.ctx.emitter.emit("marketplace:definitionsLoaded",t.data)),t}async getGroupedOffers(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getGroupedOffers(e);return t.ok&&this.ctx.emitter.emit("marketplace:groupedOffersLoaded",t.data),t}async getOffersByItem(e,t,i,r=20){if(!e)return n("client","ItemID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ItemID=e,s.OfferTypeFilter=t,s.ContinuationToken=i,s.PageSize=r;let a=await this.ctx.api.marketplace.getOffersByItem(s);return a.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",a.data),a}async getOffer(e){if(!e)return n("client","OfferID is required.");let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.OfferID=e;let i=await this.ctx.api.marketplace.getOffer(t);return i.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",i.data),i}async getBuyOrders(e,t,i=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=i;let s=await this.ctx.api.marketplace.getBuyOrders(r);return s.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",s.data),s}async getMyState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.marketplace.getMyState(e);return t.ok&&(this.ctx.data.user.applyMarketplaceState(t.data.Limits??null),this.ctx.emitter.emit("marketplace:myStateLoaded",t.data)),t}async getHistory(e,t=20){let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ContinuationToken=e,i.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(i);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,i,r,s,a,p){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.PriceBundle=r,x.DurationHours=s,x.ItemInstanceIDs=a,x.SelectedOptionID=p;let U=await this.ctx.api.marketplace.createListing(x);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 x=this.baseRequest();if(!x)return n("unauthorized","Not logged in.");x.ItemID=e,x.CatalogID=t,x.GoodsAmount=i,x.BidAxisType=r,x.BidCurrencyID=p.bidCurrencyID,x.BidCatalogID=p.bidCatalogID,x.BidItemID=p.bidItemID,x.StartingBid=s,x.DurationHours=a,x.ItemInstanceIDs=p.itemInstanceIDs,x.SelectedOptionID=p.selectedOptionID;let U=await this.ctx.api.marketplace.createAuction(x);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=sr.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=sr.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 or=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 Da=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}),ba=zod.z.object({CodeTtlMinutes:zod.z.number().nullish(),ResendCooldownSeconds:zod.z.number().nullish()}),De=zod.z.object({IsCompleted:zod.z.boolean().nullish(),ServerTime:u.nullish()}),va=zod.z.object({Message:zod.z.string(),ExpiresAt:u}),we={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithSsoCode:"LoginWithSsoCode",RegisterWithEmail:"RegisterWithEmail",ConfirmEmailRegistration:"ConfirmEmailRegistration",ResendVerificationCode:"ResendVerificationCode",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function A(o,e,t,i){let s=`api/v2/${o&&o.length>0?o:"0"}/Client/${e}/${t}`;return i==null?s:`${s}/${i}`}var ar=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,Da,{ticket:null})}loginWithDeviceID(e){return this.login(we.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(we.LoginWithTelegram,e)}loginWithEmail(e){return this.login(we.LoginWithEmail,e)}loginWithGoogle(e){return this.login(we.LoginWithGoogle,e)}loginWithSsoCode(e){return this.login(we.LoginWithSsoCode,e)}registerWithEmail(e){return this.ctx.transport.post(this.endpoint(we.RegisterWithEmail),e,ba,{ticket:null})}confirmEmailRegistration(e){return this.login(we.ConfirmEmailRegistration,e)}resendVerificationCode(e){return this.ctx.transport.post(this.endpoint(we.ResendVerificationCode),e,De,{ticket:null})}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(we.RequestWalletChallenge),e,va,{ticket:null})}loginWithWallet(e){return this.login(we.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(we.ForgotPassword),e,De,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(we.ResetPassword),e,De,{ticket:null})}};var kh={ReturnKey:"ReturnKey",ReturnMarkedKey:"ReturnMarkedKey",ReturnEmpty:"ReturnEmpty"},za=zod.z.enum(["ReturnKey","ReturnMarkedKey","ReturnEmpty"]).catch("ReturnKey"),Mh=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Order:zod.z.number().nullish()}).passthrough(),Ta=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),Locales:zod.z.record(zod.z.string(),Mh).nullish(),MissingKeyMode:za.nullish(),MaxEntriesPerLocale:zod.z.number().nullish(),MaxValueLengthBytes:zod.z.number().nullish()}).passthrough(),wh=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish()}).passthrough(),Pa=zod.z.object({Locale:zod.z.string().nullish(),Version:zod.z.number().nullish(),Url:zod.z.string().nullish(),Fallback:wh.nullish()}).passthrough(),lr={GetLocalizationManifest:"GetLocalizationManifest",GetLocalizationTable:"GetLocalizationTable"},Ah=zod.z.object({Locale:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Order:zod.z.number().nullish(),Version:zod.z.number().nullish()}).passthrough(),Ia=zod.z.object({IsEnabled:zod.z.boolean().nullish(),DefaultLocale:zod.z.string().nullish(),MissingKeyMode:za.nullish(),ResolvedLocale:zod.z.string().nullish(),Locales:zod.z.array(Ah).nullish()}).passthrough(),ka=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 $s=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:Pa.nullish()}).passthrough().transform(o=>o),Ma=zod.z.object({StateEpoch:zod.z.string().nullish(),StateVersions:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough().transform(o=>o),wa=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),Aa=zod.z.object({}).passthrough().transform(o=>o),Oa=zod.z.object({}).passthrough().transform(o=>o),Ua=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(),Ba=zod.z.object({Username:zod.z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var ur=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(je.GetClientState,e.UserID),e,$s,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,$s,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(je.GetStateVersions,e.UserID),e,Ma,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(je.GetUserState,e.UserID),e,wa,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,Aa,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,Oa,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,Ua,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,De,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,De,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,Ba,{ticket:e.ClientSessionTicket})}};var cr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Zi.Convert,e,vo)}cryptoConvert(e){return this.send(Zi.CryptoConvert,e,zo)}};var Oh=zod.z.object({ItemInstanceID:zod.z.string(),Units:zod.z.number(),Level:zod.z.number()}),Zs=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()}),La=zod.z.array(re(Zs)),pr={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Uh={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Bh=zod.z.enum(["FlatCount","Merge","InvestmentRefund"]).catch("FlatCount"),Lh={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected",SameLevelOnly:"SameLevelOnly"},qh=zod.z.enum(["ProtectLeveled","CheapestFirst","ClientSelected","SameLevelOnly"]).catch("ProtectLeveled"),Eh=zod.z.object({ContractAddress:zod.z.string().nullish(),TokenID:zod.z.string().nullish(),TokenStandard:zod.z.string().nullish()}).passthrough(),Gh=zod.z.object({Networks:zod.z.record(zod.z.string(),Eh).nullish(),MetadataUrl:zod.z.string().nullish()}).passthrough(),Nh=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(),jh=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:Bh.nullish(),WeightCurve:xe.nullish(),Selection:qh.nullish()}).passthrough(),Vh=zod.z.object({MaxLevel:zod.z.number().nullish(),PriceOptions:J.nullish(),CostCurve:xe.nullish(),FlatBonusCurve:xe.nullish(),PercentBonusCurve:xe.nullish(),PowerCurve:xe.nullish(),Fodder:Fh.nullish()}).passthrough(),_h=zod.z.object({RarityID:zod.z.string().nullish(),CollectionID:zod.z.string().nullish(),AuthorID:zod.z.string().nullish()}).passthrough(),Wh=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:Gh.nullish(),Stats:Nh.nullish(),Equipment:jh.nullish(),Upgrade:Vh.nullish(),Metadata:_h.nullish(),ExpirationDurationSeconds:zod.z.number().nullish()}).passthrough(),Qh=zod.z.object({Items:zod.z.record(zod.z.string(),Wh).nullish()}).passthrough(),dr=zod.z.object({Catalogs:zod.z.record(zod.z.string(),Qh).nullish()}).passthrough();var hr=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=A(this.ctx.settings.titleID,"Item",pr.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,Zs,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=A(this.ctx.settings.titleID,"Item",pr.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,La,{ticket:e.ClientSessionTicket})}};var Js=zod.z.object({ServerTimeUtc:u,OfferID:zod.z.string(),Count:zod.z.number(),Resources:b.nullish()}),qa=zod.z.array(re(Js)),Kh=zod.z.object({OfferID:zod.z.string(),TotalPurchases:zod.z.number(),DailyPurchases:zod.z.number(),DailyResetUtc:u,LastPurchasedAt:u}),Ea=zod.z.object({Purchases:zod.z.record(zod.z.string(),Kh).nullish()}).passthrough().transform(o=>o),Hh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),RequiredFlags:zod.z.array(zod.z.string()).nullish()}).passthrough(),$h=zod.z.object({StoreID:zod.z.string(),Type:zod.z.string().nullish(),Name:zod.z.string().nullish(),Description:zod.z.string().nullish(),Rules:Hh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Zh=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),Jh=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:Zh.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),mr=zod.z.object({Stores:zod.z.record(zod.z.string(),$h).nullish(),StoreOffers:zod.z.record(zod.z.string(),Jh).nullish()}).passthrough(),Ot={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(Ot.Purchase,e,Js)}purchaseBatch(e){return this.send(Ot.PurchaseBatch,e,qa)}getDefinitions(e){return this.send(Ot.GetDefinitions,e,mr)}getUserState(e){return this.send(Ot.GetUserState,e,Ea)}};var Yh={Consumable:"Consumable",NonConsumable:"NonConsumable",Subscription:"Subscription"},Xh=zod.z.enum(["Consumable","NonConsumable","Subscription"]).catch("Consumable"),em=zod.z.object({StartUtc:u.nullish(),EndUtc:u.nullish(),Gate:W.nullish(),Limits:ue.nullish()}).passthrough(),tm=zod.z.object({ResourceAction:zod.z.string().nullish(),RevokeEntitlement:zod.z.boolean().nullish(),BlockFuturePurchases:zod.z.boolean().nullish()}).passthrough(),im=zod.z.object({ProductID:zod.z.string().nullish(),Name:zod.z.string().nullish(),Type:Xh.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:em.nullish(),Refund:tm.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Ga=zod.z.object({Enabled:zod.z.boolean().nullish(),Products:zod.z.record(zod.z.string(),im).nullish()}).passthrough(),Na=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(),ja=zod.z.object({Products:zod.z.record(zod.z.string(),Na).nullish(),LifetimeSpendUsdCents:zod.z.number().nullish()}).passthrough(),rm={Granted:"Granted",Restored:"Restored",AlreadyProcessed:"AlreadyProcessed"},sm=zod.z.enum(["Granted","Restored","AlreadyProcessed"]).catch("Granted"),Ys=zod.z.object({ServerTimeUtc:u,Store:ti.nullish(),ProductID:zod.z.string().nullish(),TransactionID:zod.z.string().nullish(),Status:sm.nullish(),Granted:zod.z.boolean().nullish(),Quantity:zod.z.number().nullish(),Resources:b.nullish(),ProductState:Na.nullish()}).passthrough(),Fa=Xe(Ys),Ut={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ValidatePurchase:"ValidatePurchase",ValidatePurchasesBatch:"ValidatePurchasesBatch"};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Purchase",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ut.GetDefinitions,e,Ga)}getUserState(e){return this.send(Ut.GetUserState,e,ja)}validatePurchase(e){return this.send(Ut.ValidatePurchase,e,Ys)}validatePurchasesBatch(e){return this.send(Ut.ValidatePurchasesBatch,e,Fa)}};var nm=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Va=zod.z.object({Reward:L.nullish(),Weight:zod.z.number().nullish(),AmountRange:nm.nullish()}).passthrough(),Bt=zod.z.object({SlotID:zod.z.string().nullish(),MinRolls:zod.z.number().nullish(),MaxRolls:zod.z.number().nullish(),Pool:zod.z.array(Va).nullish()}).passthrough(),Lt=zod.z.object({RuleID:zod.z.string().nullish(),Threshold:zod.z.number().nullish(),Pool:zod.z.array(Va).nullish()}).passthrough(),om=zod.z.object({RewardSlots:zod.z.array(Bt).nullish()}).passthrough(),am=zod.z.object({PityRules:zod.z.array(Lt).nullish()}).passthrough(),Rr=zod.z.object({SlotPresets:zod.z.record(zod.z.string(),om).nullish(),PityPresets:zod.z.record(zod.z.string(),am).nullish()}).passthrough();var lm=zod.z.object({RuleID:zod.z.string(),BoxIndex:zod.z.number().nullish()}),_a=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(lm).nullish()}),um=zod.z.object({RewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),cm=zod.z.object({CatalogID:zod.z.string().nullish(),ItemID:zod.z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),pm=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(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:um.nullish(),RewardMultiplier:ri.nullish(),SupplyLimits:zod.z.array(cm).nullish(),MaxOpenCount:zod.z.number().nullish()}).passthrough(),Xs=zod.z.object({Definitions:zod.z.record(zod.z.string(),pm).nullish(),RewardPools:Rr.nullish()}).passthrough(),Wa=zod.z.object({LootboxDefinitions:Xs.nullish()}),yr={GetDefinitions:"GetDefinitions",Open:"Open"};var Cr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(yr.GetDefinitions,e,Wa)}open(e){return this.send(yr.Open,e,_a)}};var dm=zod.z.object({}).passthrough().transform(o=>o),hm=zod.z.object({}).passthrough().transform(o=>o),mm=zod.z.object({}).passthrough().transform(o=>o),fm=zod.z.object({}).passthrough().transform(o=>o),gm=zod.z.object({}).passthrough().transform(o=>o),Qa=zod.z.object({ServerTimeUtc:u,CalendarID:zod.z.string(),DayNumber:zod.z.number().nullish(),DailyState:dm,Resources:b.nullish()}),Ka=zod.z.object({ServerTimeUtc:u,AccrualID:zod.z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:zod.z.number().nullish(),IdleState:hm,Resources:b.nullish()}),Ha=zod.z.object({ServerTimeUtc:u,ComebackID:zod.z.string(),ClaimedTierIndex:zod.z.number().nullish(),ComebackState:mm,Resources:b.nullish()}),$a=zod.z.object({ServerTimeUtc:u,ClaimID:zod.z.string(),ClaimState:fm,Resources:b.nullish()}),Za=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()}),Rm=zod.z.object({RewardMode:zod.z.string().nullish(),RewardStackLowerTiers:zod.z.boolean().nullish()}).passthrough(),ym=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(),Cm=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(ym).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(),Sm=zod.z.object({MinPremiumTier:zod.z.number().nullish(),RequiredPremiumID:zod.z.string().nullish(),Multiplier:zod.z.number().nullish()}).passthrough(),xm=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(Sm).nullish()}).passthrough(),Dm=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(),bm=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:xm.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:zod.z.number().nullish(),MinClaimSeconds:zod.z.number().nullish(),Requirements:Dm.nullish(),FirstClaimMode:zod.z.string().nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),vm=zod.z.object({MinAbsenceSeconds:zod.z.number().nullish(),Rewards:L.nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),zm=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(vm).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(),Tm=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(),Pm=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:ue.nullish(),PremiumLimitOverrides:zod.z.array(Tm).nullish(),Gate:W.nullish(),AvailableFromUtc:zod.z.string().nullish(),AvailableUntilUtc:zod.z.string().nullish()}).passthrough(),en=zod.z.object({TierRewards:Rm.nullish(),MilestoneRewardMultiplier:ri.nullish(),DailyCalendars:zod.z.record(zod.z.string(),Cm).nullish(),IdleAccruals:zod.z.record(zod.z.string(),bm).nullish(),Comebacks:zod.z.record(zod.z.string(),zm).nullish(),Claims:zod.z.record(zod.z.string(),Pm).nullish()}).passthrough(),Ja=zod.z.object({RewardDefinitions:en.nullish()}),Ya=zod.z.object({Rewards:gm.nullish()}),ot={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(ot.GetRewardDefinitions,e,Ja)}getUserRewardsState(e){return this.send(ot.GetUserRewardsState,e,Ya)}getMilestoneRewardMultiplier(e){return this.send(ot.GetMilestoneRewardMultiplier,e,Za)}claimDailyReward(e){return this.send(ot.ClaimDailyReward,e,Qa)}collectIdleAccrual(e){return this.send(ot.CollectIdleAccrual,e,Ka)}claimComebackReward(e){return this.send(ot.ClaimComebackReward,e,Ha)}claimReward(e){return this.send(ot.ClaimReward,e,$a)}};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Tutorial",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTutorialDefinitions(e){return this.send(qe.GetTutorialDefinitions,e,to)}getUserTutorialState(e){return this.send(qe.GetUserTutorialState,e,ro)}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,no)}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,so)}resetFlow(e){return this.send(qe.ResetFlow,e,ct)}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(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(lr.GetLocalizationManifest,e,Ia)}getLocalizationTable(e){return this.send(lr.GetLocalizationTable,e,ka)}};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Qe.GetQuestDefinitions,e,ni)}getUserQuestState(e){return this.send(Qe.GetUserQuestState,e,Vn)}refreshQuestCycles(e){return this.send(Qe.RefreshQuestCycles,e,De)}claimQuestReward(e){return this.send(Qe.ClaimQuestReward,e,gs)}claimQuestRewardsBatch(e){return this.send(Qe.ClaimQuestRewardsBatch,e,Qn)}claimMilestoneReward(e){return this.send(Qe.ClaimMilestoneReward,e,Rs)}claimMilestoneRewardsBatch(e){return this.send(Qe.ClaimMilestoneRewardsBatch,e,Kn)}claimGroupCompletionReward(e){return this.send(Qe.ClaimGroupCompletionReward,e,_n)}addQuestProgress(e){return this.send(Qe.AddQuestProgress,e,Wn)}};var Xa=zod.z.object({}).passthrough().transform(o=>o);var Im=zod.z.object({Order:zod.z.number().nullish(),Type:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),BonusMultiplier:zod.z.number().nullish()}).passthrough(),km=zod.z.object({Schedule:zod.z.array(Im).nullish(),RepeatCycle:zod.z.boolean().nullish(),MaxCycles:zod.z.number().nullish()}).passthrough(),Mm=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(),wm=zod.z.object({Milestones:Y.nullish()}).passthrough(),tn=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:gt.nullish(),TokenSources:zod.z.array(Le).nullish(),ClaimMode:zod.z.string().nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:wm.nullish(),BonusWindow:km.nullish()}).passthrough(),Am=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Content:tn.nullish(),ClaimGraceHours:zod.z.number().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Om=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:de.nullish(),Content:tn.nullish(),Events:zod.z.array(Am).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),Um=zod.z.object({MaxConcurrentEvents:zod.z.number().nullish()}).passthrough(),Bm=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),vr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Om).nullish(),Settings:Um.nullish(),Presets:Bm.nullish()}).passthrough(),Lm=zod.z.object({Type:Ft,TimedEventID:zod.z.string(),CurrentChainedEventID:zod.z.string().nullish(),Content:tn.nullish(),Progress:Xa.nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),CanEarn:zod.z.boolean().nullish(),CanClaim:zod.z.boolean().nullish(),NextMilestone:ve.nullish(),BonusWindow:Mm.nullish(),CurrentCycleIndex:zod.z.number().nullish(),CurrentEventOrder:zod.z.number().nullish(),TotalEventsInChain:zod.z.number().nullish()}).passthrough(),el=zod.z.object({ActiveEvents:zod.z.array(Lm).nullish()}).passthrough(),tl=zod.z.object({Tokens:zod.z.record(zod.z.string(),Xa).nullish()}),rn=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),sn=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Rewards:b.nullish()}),qm=zod.z.object({Type:Ft.nullish(),LteID:zod.z.string().nullish(),Resources:b.nullish()}),nn=zod.z.array(re(sn)),il=zod.z.array(re(rn)),rl=zod.z.array(re(qm)),Fe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Fe.GetActiveEvents,e,el)}getDefinitions(e){return this.send(Fe.GetDefinitions,e,vr)}getUserLteState(e){return this.send(Fe.GetUserLteState,e,tl)}grantTokens(e){return this.send(Fe.GrantTokens,e,b)}spendTokens(e){return this.send(Fe.SpendTokens,e,rn)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,sn)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,nn)}claimAllMilestones(e){return this.send(Fe.ClaimAllMilestones,e,nn)}spendTokensBatch(e){return this.send(Fe.SpendTokensBatch,e,il)}grantTokensBatch(e){return this.send(Fe.GrantTokensBatch,e,rl)}};var Em=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(),Kt=zod.z.object({LeaderboardID:zod.z.string(),CycleVersion:zod.z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:u.nullish(),TopUsers:zod.z.array(Em).nullish(),BracketID:zod.z.string().nullish()}),Gm=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(),Tr=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:ve.nullish(),HasUnclaimedMilestone:zod.z.boolean().nullish(),ClaimableGraceCycles:zod.z.array(Gm).nullish()}),Pr=zod.z.object({LeaderboardID:zod.z.string(),NewScore:M,CycleVersion:zod.z.number()}),Ir=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),Rank:zod.z.number().nullish(),Resources:b.nullish()}),kr=zod.z.object({ServerTimeUtc:u,LeaderboardID:zod.z.string(),MilestoneID:zod.z.string(),Resources:b.nullish()}),sl=zod.z.array(re(Kt)),nl=zod.z.array(re(Tr)),ol=zod.z.array(re(Ir)),al=zod.z.array(re(kr)),ll=zod.z.array(re(Pr)),Nm=zod.z.object({LeaderboardID:zod.z.string(),CycleReward:re(Ir).nullish(),Milestones:zod.z.array(re(kr)).nullish()}),ul=zod.z.array(Nm),jm=zod.z.object({LeaderboardID:zod.z.string(),Leaderboard:re(Kt).nullish(),Progress:re(Tr).nullish()}),cl=zod.z.array(jm),Fm=zod.z.string(),pl=zod.z.object({Rank:zod.z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:ms.nullish()}).passthrough(),Vm=zod.z.object({RankRewards:zod.z.array(pl).nullish()}).passthrough(),_m=zod.z.object({ChainedEventID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),ClaimGraceHours:zod.z.number().nullish()}).passthrough(),Wm=zod.z.object({Milestones:Y.nullish(),RankRewards:Y.nullish()}).passthrough(),Qm=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:Fm.nullish(),Schedule:de.nullish(),ChainEvents:zod.z.array(_m).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(pl).nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:Wm.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneClaimGraceHours:zod.z.number().nullish(),ScoreSources:zod.z.array(Le).nullish()}).passthrough(),Km=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish(),RankRewards:zod.z.record(zod.z.string(),Vm).nullish()}).passthrough(),Mr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Qm).nullish(),Presets:Km.nullish()}).passthrough(),be={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 wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(be.GetDefinitions,e,Mr)}getLeaderboard(e){return this.send(be.GetLeaderboard,e,Kt)}getMyProgress(e){return this.send(be.GetMyProgress,e,Tr)}submitScore(e){return this.send(be.SubmitScore,e,Pr)}submitScoreFromSource(e){return this.send(be.SubmitScoreFromSource,e,Pr)}claimCycleReward(e){return this.send(be.ClaimCycleReward,e,Ir)}claimMilestone(e){return this.send(be.ClaimMilestone,e,kr)}getFriendsLeaderboard(e){return this.send(be.GetFriendsLeaderboard,e,Kt)}getLeaderboardsBatch(e){return this.send(be.GetLeaderboardsBatch,e,sl)}getProgressBatch(e){return this.send(be.GetProgressBatch,e,nl)}claimCycleRewardsBatch(e){return this.send(be.ClaimCycleRewardsBatch,e,ol)}claimMilestonesBatch(e){return this.send(be.ClaimMilestonesBatch,e,al)}submitScoresBatch(e){return this.send(be.SubmitScoresBatch,e,ll)}claimAllRewardsBatch(e){return this.send(be.ClaimAllRewardsBatch,e,ul)}getOverviewBatch(e){return this.send(be.GetOverviewBatch,e,cl)}};var on=zod.z.object({}).passthrough().transform(o=>o),dl=zod.z.object({SeasonChainID:zod.z.string(),CycleIndex:zod.z.number().nullish(),Season:zod.z.lazy(()=>gl).nullish(),ComputedStartUtc:u.nullish(),ComputedEndUtc:u.nullish(),SecondsRemaining:M.nullish(),UserState:on.nullish(),NextTier:zod.z.lazy(()=>fl).nullish()}).passthrough(),hl=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()}),an=zod.z.object({SeasonChainID:zod.z.string(),CurrentSeasonID:zod.z.string().nullish(),TierNumber:zod.z.number(),Resources:b.nullish()}),ml=Xe(an);var fl=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(),gl=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(fl).nullish(),LinkedCollectionID:zod.z.string().nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough();var Hm=zod.z.object({SeasonChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Seasons:zod.z.array(gl).nullish(),GrantTokensAccessMode:zod.z.string().nullish(),Gate:W.nullish()}).passthrough(),Ar=zod.z.object({Chains:zod.z.record(zod.z.string(),Hm).nullish()}).passthrough(),ht={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward",ClaimTierRewardsBatch:"ClaimTierRewardsBatch"};var Or=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ht.GetDefinitions,e,Ar)}getActiveSeason(e){return this.send(ht.GetActiveSeason,e,dl)}getUserState(e){return this.send(ht.GetUserState,e,on)}grantStatusTokens(e){return this.send(ht.GrantStatusTokens,e,hl)}claimTierReward(e){return this.send(ht.ClaimTierReward,e,an)}claimTierRewardsBatch(e){return this.send(ht.ClaimTierRewardsBatch,e,ml)}};var $m={Apple:"Apple",Google:"Google"},Rl=zod.z.object({}).passthrough().transform(o=>o),Zm=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(),Jm=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(),ln=zod.z.object({Definitions:zod.z.record(zod.z.string(),Jm).nullish()}).passthrough(),yl=zod.z.object({Premium:ln.nullish()}),Cl=zod.z.object({ServerTimeUtc:u.nullish(),Premium:Rl.nullish()}),Ur=zod.z.object({ServerTimeUtc:u.nullish(),Premium:Rl.nullish(),Subscription:Zm.nullish(),Resources:b.nullish()}),yt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Br=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(yt.GetDefinitions,e,yl)}getUserState(e){return this.send(yt.GetUserState,e,Cl)}activateTrial(e){return this.send(yt.ActivateTrial,e,Ur)}purchaseItemOrCurrency(e){return this.send(yt.PurchaseWithResources,e,Ur)}purchaseRealMoney(e){return this.send(yt.PurchaseRealMoney,e,Ur)}};var Lr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Oe.GetCharacterDefinitions,e,Yi)}getUserCharacters(e){return this.send(Oe.GetUserCharacters,e,wo)}unlockCharacter(e){return this.send(Oe.UnlockCharacter,e,Us)}upgradeStatLevel(e){return this.send(Oe.UpgradeStatLevel,e,As)}upgradeCharacterLevel(e){return this.send(Oe.UpgradeCharacterLevel,e,Os)}equipItems(e){return this.send(Oe.EquipItems,e,Ao)}unequipItems(e){return this.send(Oe.UnequipItems,e,Oo)}unequipAllCharacters(e){return this.send(Oe.UnequipAllCharacters,e,Uo)}unlockCharactersBatch(e){return this.send(Oe.UnlockCharactersBatch,e,Bo)}upgradeCharacterLevelsBatch(e){return this.send(Oe.UpgradeCharacterLevelsBatch,e,Lo)}upgradeStatLevelsBatch(e){return this.send(Oe.UpgradeStatLevelsBatch,e,qo)}};var qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(tt.CreateMatch,e,aa)}updateMatch(e){return this.send(tt.UpdateMatch,e,la)}cancelMatch(e){return this.send(tt.CancelMatch,e,ua)}instantBattle(e){return this.send(tt.InstantBattle,e,ca)}saveStrategy(e){return this.send(tt.SaveStrategy,e,De)}getMyMatches(e){return this.send(tt.GetMyMatches,e,js)}getAvailableMatches(e){return this.send(tt.GetAvailableMatches,e,js)}getDefinitions(e){return this.send(tt.GetDefinitions,e,ma)}};var Ym={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Sl=zod.z.enum(["TradeUpRarity","TradeUpCollection"]).catch("TradeUpRarity"),Xm=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:hs.nullish()}),xl=zod.z.object({ServerTimeUtc:u,Type:Sl.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(Xm).nullish()}),ef=zod.z.object({CraftID:zod.z.string().nullish(),Type:Sl.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(),un=zod.z.object({Definitions:zod.z.record(zod.z.string(),ef).nullish()}).passthrough(),Dl=zod.z.object({ServerTimeUtc:u.nullish(),CraftDefinitions:un.nullish()}),Er={GetDefinitions:"GetDefinitions",Craft:"Craft"};var Gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Er.GetDefinitions,e,Dl)}craft(e){return this.send(Er.Craft,e,xl)}};var tf={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},rf=zod.z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]).catch("Pending"),bl=zod.z.object({}).passthrough().transform(o=>o),qt=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()}),vl=zod.z.object({GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).nullish(),CollectionCurrencyEarned:M.nullish()}),zl=zod.z.object({OpenedCount:zod.z.number().nullish(),Packs:zod.z.array(vl).nullish(),GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).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()}),Tl=zod.z.object({OpenedCount:zod.z.number().nullish(),Chests:zod.z.array(vl).nullish(),GrantedCollectibles:zod.z.array(qt).nullish(),DuplicateCollectibles:zod.z.array(qt).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:b.nullish(),TriggeredPity:zod.z.array(zod.z.unknown()).nullish()}),Pl=zod.z.object({GrantedCollectibleID:zod.z.string().nullish(),NewlyCompletedSetID:zod.z.string().nullish(),CollectionJustCompleted:zod.z.boolean().nullish(),Resources:b.nullish()}),cn=zod.z.object({SetID:zod.z.string(),Resources:b.nullish()}),Il=zod.z.array(re(cn)),kl=zod.z.object({Resources:b.nullish()}),sf=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:rf.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(),Ml=zod.z.object({OfferID:zod.z.string(),ExpiresAtUtc:u.nullish(),Resources:b.nullish()}),wl=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),Al=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()}),Ol=zod.z.object({OfferID:zod.z.string(),Resources:b.nullish()}),pn=zod.z.object({Offers:zod.z.array(sf).nullish()}),nf=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(),of=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(nf).nullish(),SetCompletionReward:L.nullish()}).passthrough(),af=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(of).nullish(),GrandPrize:L.nullish()}).passthrough(),Ul=zod.z.object({BonusRewardSlots:Y.nullish(),PityRules:Y.nullish()}).passthrough(),lf=zod.z.object({PackTypeID:zod.z.string().nullish(),PriceOptions:J.nullish(),BonusRewardSlots:zod.z.array(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:Ul.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(),uf=zod.z.object({Rarity:zod.z.number().nullish(),CollectionCurrencyGranted:zod.z.number().nullish()}).passthrough(),cf=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(Bt).nullish(),PityRules:zod.z.array(Lt).nullish(),Presets:Ul.nullish(),Tier:zod.z.number().nullish()}).passthrough(),pf=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(),Nr=zod.z.object({Collections:zod.z.record(zod.z.string(),af).nullish(),PackTypes:zod.z.record(zod.z.string(),lf).nullish(),CollectionChests:zod.z.array(cf).nullish(),DuplicateConversions:zod.z.array(uf).nullish(),DailyTradeLimit:zod.z.number().nullish(),CollectibleJokerCatalogID:zod.z.string().nullish(),CollectibleJokerItemID:zod.z.string().nullish(),SpecialTradeEvents:zod.z.array(pf).nullish(),RewardPools:Rr.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 jr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(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,Nr)}getUserState(e){return this.send(Te.GetUserState,e,bl)}openPack(e){return this.send(Te.OpenPack,e,zl)}openCollectionChest(e){return this.send(Te.OpenCollectionChest,e,Tl)}useCollectibleJoker(e){return this.send(Te.UseCollectibleJoker,e,Pl)}claimSetReward(e){return this.send(Te.ClaimSetReward,e,cn)}claimSetRewardsBatch(e){return this.send(Te.ClaimSetRewardsBatch,e,Il)}claimGrandPrize(e){return this.send(Te.ClaimGrandPrize,e,kl)}sendTradeOffer(e){return this.send(Te.SendTradeOffer,e,Ml)}cancelTradeOffer(e){return this.send(Te.CancelTradeOffer,e,wl)}acceptTradeOffer(e){return this.send(Te.AcceptTradeOffer,e,Al)}declineTradeOffer(e){return this.send(Te.DeclineTradeOffer,e,Ol)}getMyTradeOffers(e){return this.send(Te.GetMyTradeOffers,e,pn)}getIncomingTradeOffers(e){return this.send(Te.GetIncomingTradeOffers,e,pn)}};var df=zod.z.object({}).passthrough().transform(o=>o),hf={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},mf={Active:"Active",Left:"Left",Replaced:"Replaced"},ff=zod.z.object({ObjectIndex:zod.z.number().nullish(),ObjectCompletionRewardClaimed:zod.z.boolean().nullish()}).passthrough(),gf=zod.z.object({UserID:zod.z.string().nullish(),PublicData:ze.nullish(),BuildObjectsProgress:ff.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(),Rf=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(),yf=zod.z.object({Objects:zod.z.array(Rf).nullish()}).passthrough(),Bl=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(gf).nullish(),BuildObjectsState:yf.nullish(),Status:zod.z.string().nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Ll=zod.z.object({CoopChainID:zod.z.string()}).passthrough(),Cf=zod.z.string(),dn=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(),Sf=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(),xf=zod.z.object({Objects:zod.z.array(Sf).nullish(),PriceOptions:J.nullish(),SpinnerTable:zod.z.array(dn).nullish(),MaxSpinsPerCall:zod.z.number().nullish()}).passthrough(),Df=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:Cf.nullish(),PartnerCount:zod.z.number().nullish(),MatchmakingTimeoutMinutes:zod.z.number().nullish(),MemberGracePeriodMinutes:zod.z.number().nullish(),BuildObjects:xf.nullish(),GrandPrize:L.nullish()}).passthrough(),bf=zod.z.object({CoopChainID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Schedule:de.nullish(),Events:zod.z.array(Df).nullish(),Gate:W.nullish()}).passthrough(),ql=zod.z.object({ServerTimeUtc:u.nullish(),UserState:df.nullish(),ActiveGroup:Bl.nullish()}),hn=zod.z.object({ServerTimeUtc:u.nullish(),Group:Bl.nullish(),SecondsRemaining:M.nullish()}),El=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Resources:b.nullish(),ObjectIndex:zod.z.number().nullish(),Sector:dn.nullish(),RequestedSpins:zod.z.number().nullish(),SpinsUsed:zod.z.number().nullish(),Sectors:zod.z.array(dn).nullish(),ProgressDelta:zod.z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:zod.z.boolean().nullish(),AllObjectsCompleted:zod.z.boolean().nullish()}),mn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),Resources:b.nullish()}),Gl=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),Success:zod.z.boolean().nullish()}),Fr=zod.z.object({Chains:zod.z.record(zod.z.string(),bf).nullish()}).passthrough(),He={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var Vr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(He.GetDefinitions,e,Fr)}getActiveEvent(e){return this.send(He.GetActiveEvent,e,Ll)}getUserState(e){return this.send(He.GetUserState,e,ql)}getGroupState(e){return this.send(He.GetGroupState,e,hn)}joinOrCreateGroup(e){return this.send(He.JoinOrCreateGroup,e,hn)}spin(e){return this.send(He.Spin,e,El)}claimObjectReward(e){return this.send(He.ClaimObjectReward,e,mn)}claimGrandPrize(e){return this.send(He.ClaimGrandPrize,e,mn)}leaveGroup(e){return this.send(He.LeaveGroup,e,Gl)}};var vf={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},zf={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},Tf=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(),Pf=zod.z.object({TrackID:zod.z.string().nullish(),CurrentValue:zod.z.number().nullish(),LastUpdatedUtc:u.nullish()}).passthrough(),Nl=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(),Tf).nullish(),Tracks:zod.z.record(zod.z.string(),Pf).nullish(),SelectedChoiceNodeID:zod.z.string().nullish()}).passthrough(),If=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:Nl.nullish(),NextCycleStartsAtUtc:u.nullish(),LastUpdatedUtc:u.nullish(),DismissSkipAvailableAtUtc:u.nullish(),LastDismissedAtUtc:u.nullish()}).passthrough(),kf=zod.z.object({TotalExecutions:zod.z.number().nullish(),DailyExecutions:zod.z.number().nullish(),DailyResetUtc:u.nullish()}).passthrough(),Mf=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(),kf).nullish()}).passthrough(),wf=zod.z.object({Slots:zod.z.record(zod.z.string(),If).nullish(),OfferHistory:zod.z.record(zod.z.string(),Mf).nullish(),LastUpdatedUtc:u.nullish()}).passthrough();var Af=zod.z.object({Order:zod.z.number().nullish(),OfferID:zod.z.string().nullish(),DurationSec:zod.z.number().nullish(),DelayBeforeActivationSec:zod.z.number().nullish()}).passthrough(),Of=zod.z.object({SlotID:zod.z.string().nullish(),Enabled:zod.z.boolean().nullish(),SortOrder:zod.z.number().nullish(),Queue:zod.z.array(Af).nullish(),Schedule:de.nullish(),Gate:W.nullish(),AllowDismissSkip:zod.z.boolean().nullish(),DismissSkipDelaySec:zod.z.number().nullish()}).passthrough(),Uf=zod.z.object({StoreOfferID:zod.z.string().nullish(),BillingProductID:zod.z.string().nullish(),PriceOptions:J.nullish(),UseExternalRewards:zod.z.boolean().nullish()}).passthrough(),Bf=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:Uf.nullish(),RewardedVideo:Bf.nullish()}).passthrough(),qf=zod.z.object({TrackID:zod.z.string().nullish(),Operator:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Ef=zod.z.object({Milestones:Y.nullish()}).passthrough(),Gf=zod.z.object({TrackID:zod.z.string().nullish(),Amount:zod.z.number().nullish(),RespectBounds:zod.z.boolean().nullish()}).passthrough(),Nf=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(),jf=zod.z.object({RequiredCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredAnyCompletedNodeIDs:zod.z.array(zod.z.string()).nullish(),RequiredTracks:zod.z.array(qf).nullish(),VisibleWhileLocked:zod.z.boolean().nullish()}).passthrough(),Ff=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(Gf).nullish(),MilestonePoints:zod.z.number().nullish(),UnlockRules:jf.nullish(),NextNodeIDs:zod.z.array(zod.z.string()).nullish(),ChoiceGroupID:zod.z.string().nullish(),Limits:ue.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(),jl=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(Ff).nullish(),Tracks:zod.z.array(Nf).nullish(),Milestones:zod.z.record(zod.z.string(),ve).nullish(),Presets:Ef.nullish(),MilestoneClaimMode:zod.z.string().nullish(),MilestoneToken:gt.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(),Vf=zod.z.object({Milestones:zod.z.record(zod.z.string(),ut).nullish()}).passthrough(),fn=zod.z.object({Slots:zod.z.record(zod.z.string(),Of).nullish(),Offers:zod.z.record(zod.z.string(),jl).nullish(),Presets:Vf.nullish()}).passthrough(),Fl=zod.z.object({DealOfferDefinitions:fn.nullish()}),Vl=zod.z.object({DealOffers:wf.nullish()}),_f=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(),Wf=zod.z.object({SlotID:zod.z.string().nullish(),SortOrder:zod.z.number().nullish(),QueueIndex:zod.z.number().nullish(),CycleIndex:zod.z.number().nullish(),OfferDef:jl.nullish(),ActivationState:Nl.nullish(),IsNewActivation:zod.z.boolean().nullish(),ComputedExpiresAtUtc:u.nullish(),Cost:_t.nullish(),Milestone:_f.nullish()}).passthrough(),_l=zod.z.object({Slots:zod.z.array(Wf).nullish()}),Wl=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()}),Ql=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Kl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),Resources:b.nullish()}),Hl=zod.z.object({ServerTimeUtc:u.nullish(),SlotID:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),$l=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()}),it={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var _r=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(it.GetDefinition,e,Fl)}getUserState(e){return this.send(it.GetUserState,e,Vl)}getActiveDeals(e){return this.send(it.GetActiveDeals,e,_l)}dismissDeal(e){return this.send(it.DismissDeal,e,Ql)}executeNode(e){return this.send(it.ExecuteNode,e,Wl)}recordShow(e){return this.send(it.RecordShow,e,Kl)}claimMilestone(e){return this.send(it.ClaimMilestone,e,Hl)}claimMilestonesBatch(e){return this.send(it.ClaimMilestonesBatch,e,$l)}};var Qf=zod.z.object({}).passthrough().transform(o=>o),Kf=zod.z.object({FeatureKey:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Rate:zod.z.number().nullish(),Basis:zod.z.string().nullish(),SourceCurrencyID:zod.z.string().nullish(),TargetCurrencyID:zod.z.string().nullish(),MinSourceAmount:zod.z.number().nullish(),MaxRewardPerOperation:zod.z.number().nullish(),Limits:ue.nullish()}).passthrough(),gn=zod.z.object({IsEnabled:zod.z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:zod.z.record(zod.z.string(),ve).nullish(),SpendRewards:zod.z.array(Kf).nullish()}).passthrough(),Zl=zod.z.object({ReferralDefinitions:gn.nullish()}).passthrough(),Jl=zod.z.object({Referral:Qf.nullish(),InviteUrl:zod.z.string().nullish()}).passthrough(),Yl=zod.z.object({ReferralCode:zod.z.string().nullish(),ReferrerUserID:zod.z.string().nullish(),IsFirstActivation:zod.z.boolean().nullish(),Resources:b.nullish()}).passthrough(),Rn=zod.z.object({RewardID:zod.z.string().nullish(),Resources:b.nullish()}).passthrough(),Xl=Xe(Rn),Ct={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward",ClaimInviteRewardsBatch:"ClaimInviteRewardsBatch"};var Wr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ct.GetDefinitions,e,Zl)}getUserState(e){return this.send(Ct.GetUserState,e,Jl)}activateReferralCode(e){return this.send(Ct.ActivateReferralCode,e,Yl)}claimInviteReward(e){return this.send(Ct.ClaimInviteReward,e,Rn)}claimInviteRewardsBatch(e){return this.send(Ct.ClaimInviteRewardsBatch,e,Xl)}};var Hf={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},$f={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},eu=zod.z.object({UserID:zod.z.string(),PublicData:ze.nullish()}),Zf=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(),Ht=zod.z.object({Friends:zod.z.array(eu).nullish()}),Jf=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:eu.nullish(),Counters:Jf.nullish()}),tu=zod.z.object({Events:zod.z.array(Zf).nullish()}),$e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetOutgoingRequests:"GetOutgoingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var Qr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send($e.GetFriendsList,e,Ht)}getIncomingRequests(e){return this.send($e.GetIncomingRequests,e,Ht)}getOutgoingRequests(e){return this.send($e.GetOutgoingRequests,e,Ht)}getRecommendedFriends(e){return this.send($e.GetRecommendedFriends,e,Ht)}sendFriendRequest(e){return this.send($e.SendFriendRequest,e,$t)}acceptFriendRequest(e){return this.send($e.AcceptFriendRequest,e,$t)}declineFriendRequest(e){return this.send($e.DeclineFriendRequest,e,$t)}removeFriend(e){return this.send($e.RemoveFriend,e,$t)}getTimeline(e){return this.send($e.GetTimeline,e,tu)}};var Yf={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var Et=zod.z.object({Target:zod.z.string().nullish(),Operation:zod.z.string().nullish(),Value:zod.z.number().nullish()}).passthrough(),Xf=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:Et.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(),eg=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:de.nullish(),Effects:zod.z.array(Et).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),tg=zod.z.object({ChainedBoostID:zod.z.string().nullish(),Order:zod.z.number().nullish(),DurationSec:zod.z.number().nullish(),Effects:zod.z.array(Et).nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),ig=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:de.nullish(),Phases:zod.z.array(tg).nullish(),Gate:W.nullish(),CustomParams:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),rg=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(Et).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(),sg=zod.z.object({MaxAddPercent:zod.z.number().nullish(),MaxMultiply:zod.z.number().nullish(),MaxAddFlat:zod.z.number().nullish()}).passthrough(),ng=zod.z.object({StackingCaps:zod.z.record(zod.z.string(),sg).nullish()}).passthrough(),Kr=zod.z.object({Definitions:zod.z.record(zod.z.string(),Xf).nullish(),ScheduledBoosts:zod.z.record(zod.z.string(),eg).nullish(),BoostChains:zod.z.record(zod.z.string(),ig).nullish(),TriggeredBoosts:zod.z.record(zod.z.string(),rg).nullish(),Settings:ng.nullish()}).passthrough(),iu=zod.z.object({InstanceID:zod.z.string(),BoostID:zod.z.string(),ActivatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),RemainingCharges:zod.z.number().nullish(),EffectSnapshot:Et.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 ru=zod.z.object({ServerTimeUtc:u.nullish(),Active:zod.z.record(zod.z.string(),iu).nullish()}),su=zod.z.object({ServerTimeUtc:u.nullish(),BoostID:zod.z.string().nullish(),StackingPolicy:zod.z.string().nullish(),ActivatedBoost:iu.nullish(),Resources:b.nullish()}),og={Scheduled:"Scheduled",Chain:"Chain"},ag=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(Et).nullish(),DisplayName:zod.z.string().nullish(),AssetPaths:zod.z.record(zod.z.string(),zod.z.string()).nullish()}).passthrough(),nu=zod.z.object({ServerTimeUtc:u.nullish(),Windows:zod.z.array(ag).nullish()}),St={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var Hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(St.GetDefinitions,e,Kr)}getActive(e){return this.send(St.GetActive,e,ru)}getActiveWindows(e){return this.send(St.GetActiveWindows,e,nu)}activate(e){return this.send(St.Activate,e,su)}cleanupExpired(e){return this.send(St.CleanupExpired,e,De)}};var $r=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ke.GetUserCustomDataDefinitions,e,_i)}getMyUserCustomData(e){return this.send(Ke.GetMyUserCustomData,e,yo)}getPublicUserCustomDataOf(e){return this.send(Ke.GetPublicUserCustomDataOf,e,Ps)}setPrivateData(e){return this.send(Ke.SetPrivateData,e,Is)}setPublicData(e){return this.send(Ke.SetPublicData,e,Is)}deleteKey(e){return this.send(Ke.DeleteKey,e,De)}batchSet(e){return this.send(Ke.BatchSet,e,Co)}batchDelete(e){return this.send(Ke.BatchDelete,e,So)}batchGetPublicUserCustomDataOf(e){return this.send(Ke.BatchGetPublicUserCustomDataOf,e,xo)}};var lg={Static:"Static",Runtime:"Runtime"},ug={Public:"Public",Private:"Private"},cg=zod.z.enum(["Client","Server","System"]).catch("Client"),pg=zod.z.enum(["String","Int","Bool","Json"]).catch("String"),dg=zod.z.object({Value:zod.z.string().nullish(),UpdatedAt:u.nullish(),Version:zod.z.number().nullish(),LastWriter:cg.nullish(),ExpiresAt:u.nullish()}).passthrough(),ou=zod.z.record(zod.z.string(),dg),yn=zod.z.object({StaticVersion:zod.z.number().nullish(),RuntimeVersion:zod.z.number().nullish(),Static:ou.nullish(),Runtime:ou.nullish(),NotModified:zod.z.boolean().nullish()}),hg=zod.z.object({KeyID:zod.z.string(),Scope:zod.z.enum(["Static","Runtime"]).catch("Static").nullish(),Bucket:zod.z.enum(["Public","Private"]).catch("Public").nullish(),ValueType:pg.nullish(),MaxValueLengthBytes:zod.z.number().nullish(),TtlSeconds:zod.z.number().nullish(),DefaultValue:zod.z.string().nullish(),Description:zod.z.string().nullish()}).passthrough(),Zr=zod.z.object({Keys:zod.z.record(zod.z.string(),hg).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(),Zt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var Jr=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(Zt.GetTitleCustomDataDefinitions,e,Zr)}getPublicTitleData(e){return this.send(Zt.GetPublicTitleData,e,yn)}getPublicTitleDataKeys(e){return this.send(Zt.GetPublicTitleDataKeys,e,yn)}};var mg={Fast:"Fast",Sequential:"Sequential"},fg={Instant:"Instant",Timed:"Timed"};var gg={Hit:"Hit",Blocked:"Blocked"},Rg=zod.z.object({SlotIndex:zod.z.number(),Level:zod.z.number().nullish(),IsDamaged:zod.z.boolean().nullish(),MaxLevelRewardClaimed:zod.z.boolean().nullish()}).passthrough(),yg=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();var Cg=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:L.nullish()}).passthrough(),Sg=zod.z.object({Reward:L.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough();zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(Cg).nullish(),Rate:Sg.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 au=zod.z.object({}).passthrough().transform(o=>o),lu=zod.z.object({Min:zod.z.number().nullish(),Max:zod.z.number().nullish()}).passthrough(),Pe=zod.z.object({Operation:b.nullish(),ScaleWithRollMultiplier:zod.z.boolean().nullish()}).passthrough(),xg=zod.z.object({Count:zod.z.number().nullish(),Sides:zod.z.number().nullish()}).passthrough(),Dg=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(),bg=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:ge.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(),vg=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:ge.nullish()}).passthrough(),uu=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(),zg=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(),Tg=zod.z.object({Tiles:zod.z.record(zod.z.string(),zg).nullish()}).passthrough(),Pg=zod.z.object({Weight:zod.z.number().nullish(),Bonus:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Ig=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(Pg).nullish(),GuaranteedBonus:Pe.nullish(),IsJackpot:zod.z.boolean().nullish(),JackpotFinalMultiplier:zod.z.number().nullish(),JackpotSymbolDistribution:zod.z.record(zod.z.string(),zod.z.number()).nullish()}).passthrough(),kg=zod.z.object({Variants:zod.z.array(Ig).nullish()}).passthrough(),Mg=zod.z.object({Weight:zod.z.number().nullish(),OutcomeID:zod.z.string().nullish(),Reward:Pe.nullish(),ForceAction:zod.z.string().nullish(),SpecialModeID:zod.z.string().nullish()}).passthrough(),wg=zod.z.object({Outcomes:zod.z.array(Mg).nullish()}).passthrough(),cu=zod.z.object({PerAdMultiplierRange:lu.nullish(),MaxAdViews:zod.z.number().nullish(),AdCreditCost:zod.z.number().nullish(),FormulaKind:zod.z.string().nullish(),ApplyMultiplierOnEarlyClaim:zod.z.boolean().nullish()}).passthrough(),Ag=zod.z.object({ElapsedSeconds:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),Og=zod.z.object({Tiers:zod.z.array(Ag).nullish(),TierMode:zod.z.string().nullish(),BelowFirstTierReward:Pe.nullish()}).passthrough(),Ug=zod.z.object({RequiredValue:zod.z.number().nullish(),Reward:Pe.nullish()}).passthrough(),Bg=zod.z.object({Reward:Pe.nullish(),MetricPerReward:zod.z.number().nullish(),MaxRewardUnits:zod.z.number().nullish()}).passthrough(),Lg=zod.z.object({MetricID:zod.z.string().nullish(),MaxValuePerClaim:zod.z.number().nullish(),TierMode:zod.z.string().nullish(),ApplyClaimMultiplier:zod.z.boolean().nullish(),Tiers:zod.z.array(Ug).nullish(),Rate:Bg.nullish()}).passthrough(),pu=zod.z.object({MetricsByID:zod.z.record(zod.z.string(),Lg).nullish()}).passthrough(),qg=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:cu.nullish(),Gradation:Og.nullish(),RunStats:pu.nullish()}).passthrough(),Eg=zod.z.object({Choices:zod.z.array(qg).nullish(),OfferExpireSeconds:zod.z.number().nullish(),ClaimExpireSeconds:zod.z.number().nullish()}).passthrough(),Gg=zod.z.object({Chance:zod.z.number().nullish(),RequiredOutcome:zod.z.string().nullish(),Reward:Pe.nullish(),Tag:zod.z.string().nullish()}).passthrough(),Ng=zod.z.object({OnPassStart:Pe.nullish(),OnTileLanding:zod.z.record(zod.z.string(),Pe).nullish(),OnAttack:zod.z.record(zod.z.string(),Pe).nullish(),OnRaid:zod.z.record(zod.z.string(),Pe).nullish(),OnBuild:Pe.nullish(),OnStageComplete:Pe.nullish(),OnAttackBonusDrops:zod.z.array(Gg).nullish(),ChanceTablesByID:zod.z.record(zod.z.string(),wg).nullish(),SpecialModesByID:zod.z.record(zod.z.string(),Eg).nullish()}).passthrough(),du=zod.z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:zod.z.number().nullish(),MaxShields:zod.z.number().nullish(),Buildings:zod.z.array(uu).nullish(),HeistGridBonusConfig:kg.nullish(),StageOperations:Ng.nullish(),TileLandingMultiplier:lu.nullish(),EconomyOverride:vg.nullish()}).passthrough(),jg=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(uu).nullish(),StageTemplateID:zod.z.string().nullish(),CostMatrixTemplateID:zod.z.string().nullish(),UnitValue:zod.z.number().nullish(),Override:du.nullish()}).passthrough(),Yr=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(),Tg).nullish(),StageTemplatesByID:zod.z.record(zod.z.string(),du).nullish(),StagesByLevel:zod.z.record(zod.z.string(),jg).nullish(),SoftCurrencyID:zod.z.string().nullish(),ProceduralEconomy:bg.nullish(),Dice:xg.nullish(),Bots:Dg.nullish()}).passthrough(),Fg=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(),ve).nullish(),GrandPrize:L.nullish()}).passthrough(),Xr=zod.z.object({Board:Yr.nullish(),CommunityChest:Fg.nullish()}).passthrough(),Vg=zod.z.object({TargetUserID:zod.z.string().nullish(),IsBot:zod.z.boolean().nullish(),PublicData:ze.nullish(),TargetBuildingStates:zod.z.array(Rg).nullish(),TargetHasShield:zod.z.boolean().nullish()}).passthrough(),_g=zod.z.object({ChoiceID:zod.z.string().nullish(),Mode:zod.z.string().nullish(),Reward:Pe.nullish(),DurationSeconds:zod.z.number().nullish(),PriceOptions:J.nullish(),Multipliers:cu.nullish(),RunStats:pu.nullish()}).passthrough(),Wg=zod.z.object({ModeID:zod.z.string().nullish(),Choices:zod.z.array(_g).nullish()}).passthrough(),Qg=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(),hu=zod.z.object({UsedMultiplier:zod.z.number().nullish(),Steps:zod.z.number().nullish(),DiceValues:zod.z.array(zod.z.number()).nullish(),OldPosition:zod.z.number().nullish(),NewPosition:zod.z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:zod.z.string().nullish(),Operation:b.nullish(),ActionRequired:zod.z.string().nullish(),ActionData:Vg.nullish(),SpecialModeOffer:Wg.nullish(),CommunityChestContribution:Qg.nullish()}).passthrough(),mu=zod.z.object({Outcome:zod.z.string().nullish(),IsBotTarget:zod.z.boolean().nullish(),BuildingIndexHit:zod.z.number().nullish(),Operation:b.nullish(),DualResult:ft.nullish()}).passthrough(),Cn=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(yg).nullish(),HeistVariantTag:zod.z.string().nullish(),IsJackpot:zod.z.boolean().nullish(),Operation:b.nullish(),DualResult:ft.nullish()}).passthrough(),fu=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(),gu=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(),Ru=zod.z.object({AdViewsUsed:zod.z.number().nullish(),RolledMultiplier:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),RemainingAdViews:zod.z.number().nullish()}).passthrough(),Kg=zod.z.object({MetricID:zod.z.string().nullish(),ReachedTierIndex:zod.z.number().nullish(),RequiredValue:zod.z.number().nullish(),RewardUnits:zod.z.number().nullish()}).passthrough(),yu=zod.z.object({FinalMultiplier:zod.z.number().nullish(),AdViewsUsed:zod.z.number().nullish(),AccumulatedMultiplier:zod.z.number().nullish(),IsEarlyClaim:zod.z.boolean().nullish(),ReachedTierIndex:zod.z.number().nullish(),Operation:b.nullish(),AcceptedRunStats:zod.z.record(zod.z.string(),zod.z.number()).nullish(),RunStatAwards:zod.z.array(Kg).nullish(),RunStatsClamped:zod.z.boolean().nullish(),RunStatGrant:L.nullish()}).passthrough(),Hg={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Cu=zod.z.enum(["Forming","Active","Completed","Failed","Expired"]).catch("Forming"),$g={Active:"Active",Left:"Left",Replaced:"Replaced"},Zg=zod.z.enum(["Active","Left","Replaced"]).catch("Active"),Jg=zod.z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Yg=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(),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:Jg.nullish(),Status:Cu.nullish(),CreatedAtUtc:u.nullish(),ExpiresAtUtc:u.nullish(),Version:zod.z.number().nullish()}).passthrough(),Xg=zod.z.object({GroupID:zod.z.string().nullish(),RoundIndex:zod.z.number().nullish(),FinalStatus:Cu.nullish(),GrandPrizeReceived:zod.z.boolean().nullish(),FinishedAtUtc:u.nullish()}).passthrough(),eR=zod.z.object({ActiveGroupID:zod.z.string().nullish(),ActiveRoundIndex:zod.z.number().nullish(),History:zod.z.array(Xg).nullish()}).passthrough(),xu=zod.z.object({ServerTimeUtc:u.nullish(),UserState:eR.nullish(),ActiveGroup:Su.nullish(),SecondsRemaining:M.nullish()}),Du=zod.z.object({ServerTimeUtc:u.nullish(),Group:Su.nullish(),SecondsRemaining:M.nullish()}),Sn=zod.z.object({ServerTimeUtc:u.nullish(),GroupID:zod.z.string().nullish(),RewardType:zod.z.string().nullish(),MilestoneID:zod.z.string().nullish(),Resources:b.nullish()}),bu=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 tR=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(),iR=zod.z.object({ExperimentID:zod.z.string().nullish(),DisplayName:zod.z.string().nullish(),Description:zod.z.string().nullish(),IsEnabled:zod.z.boolean().nullish(),Schedule:de.nullish(),Gate:W.nullish(),Variants:zod.z.array(tR).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(),vu=zod.z.object({Experiments:zod.z.record(zod.z.string(),iR).nullish()}).passthrough();var rR={Mesh:"Mesh",Host:"Host"},xn=zod.z.enum(["Mesh","Host"]).catch("Mesh"),sR={ServerRelay:"ServerRelay",P2P:"P2P"},Dn=zod.z.enum(["ServerRelay","P2P"]).catch("ServerRelay"),nR={Public:"Public",Private:"Private"},oR=zod.z.enum(["Public","Private"]).catch("Public"),aR={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},lR=zod.z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]).catch("Signal"),zu=zod.z.object({Urls:zod.z.string().nullish(),Username:zod.z.string().nullish(),Credential:zod.z.string().nullish()}).passthrough(),uR=zod.z.object({Enabled:zod.z.boolean().nullish()}).passthrough(),Tu=zod.z.object({SystemState:uR.nullish(),DefaultTopology:xn.nullish(),AllowCreatorTopologyOverride:zod.z.boolean().nullish(),DefaultChatMode:Dn.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(zu).nullish()}).passthrough(),cR=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(),pR=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),Topology:xn.nullish(),ChatMode:Dn.nullish(),MaxPlayers:zod.z.number().nullish(),MemberCount:zod.z.number().nullish(),CreatedAt:zod.z.number().nullish()}).passthrough(),dR=zod.z.object({Seq:zod.z.number().nullish(),Type:lR.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(),es=zod.z.object({RoomID:zod.z.string().nullish(),Name:zod.z.string().nullish(),HostUserID:zod.z.string().nullish(),OwnerUserID:zod.z.string().nullish(),Topology:xn.nullish(),ChatMode:Dn.nullish(),Visibility:oR.nullish(),Status:zod.z.string().nullish(),MaxPlayers:zod.z.number().nullish(),Members:zod.z.array(cR).nullish(),IceServers:zod.z.array(zu).nullish(),Seq:zod.z.number().nullish()}).passthrough(),bn=zod.z.object({Closed:zod.z.boolean().nullish(),NewHostUserID:zod.z.string().nullish()}).passthrough(),Pu=zod.z.object({Rooms:zod.z.array(pR).nullish(),Page:zod.z.number().nullish(),PageSize:zod.z.number().nullish(),HasMore:zod.z.boolean().nullish()}).passthrough(),Iu=zod.z.object({Envelopes:zod.z.array(dR).nullish(),MaxSeq:zod.z.number().nullish()}).passthrough(),ts=zod.z.object({Seq:zod.z.number().nullish()}).passthrough(),Ve={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var vn=zod.z.object({TitleCustomData:Zr.nullish(),Character:Yi.nullish(),Item:dr.nullish(),Currency:Ji.nullish(),Store:mr.nullish(),Lootbox:Xs.nullish(),Quest:ni.nullish(),TimedEvent:vr.nullish(),Leaderboard:Mr.nullish(),Season:Ar.nullish(),Reward:en.nullish(),Collection:Nr.nullish(),Craft:un.nullish(),DealOffer:fn.nullish(),Premium:ln.nullish(),TimedBoost:Kr.nullish(),CoopEvent:Fr.nullish(),GameLoop:Xr.nullish(),Match:Vs.nullish(),Experiment:vu.nullish(),Blockchain:Ls.nullish(),Marketplace:Ks.nullish(),Multiplayer:Tu.nullish(),UserCustomData:_i.nullish(),Referral:gn.nullish(),Localization:Ta.nullish()}).passthrough();var xt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var is=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(xt.GetTitlePublicConfiguration,e,vn)}getTitlePublicConfigurationExcept(e){return this.send(xt.GetTitlePublicConfigurationExcept,e,vn)}getCurrencyDefinitions(e){return this.send(xt.GetCurrencyDefinitions,e,Ji)}getItemDefinitions(e){return this.send(xt.GetItemDefinitions,e,dr)}getServerTime(e){return this.send(xt.GetServerTime,e,De)}};var rs=class{constructor(e){this.ctx=e;}ctx;send(e,t,i,r=false){let s=A(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,Xr)}getBoardDefinition(e,t=false){return this.send(Se.GetBoardDefinition,e,Yr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(Se.GetBoardDefinitionForLevel,e,Yr,t)}getUserBoardState(e){return this.send(Se.GetUserBoardState,e,au)}boardLoopRoll(e){return this.send(Se.BoardLoopRoll,e,hu)}boardLoopAttack(e){return this.send(Se.BoardLoopAttack,e,mu)}boardLoopRaid(e){return this.send(Se.BoardLoopRaid,e,Cn)}boardLoopRaidFast(e){return this.send(Se.BoardLoopRaidFast,e,Cn)}boardLoopBuild(e){return this.send(Se.BoardLoopBuild,e,fu)}boardSpecialChoose(e){return this.send(Se.BoardSpecialChoose,e,gu)}boardSpecialApplyMultiplier(e){return this.send(Se.BoardSpecialApplyMultiplier,e,Ru)}boardSpecialClaim(e){return this.send(Se.BoardSpecialClaim,e,yu)}getCommunityChestState(e){return this.send(Se.GetCommunityChestState,e,xu)}joinOrCreateCommunityChest(e){return this.send(Se.JoinOrCreateCommunityChest,e,Du)}claimCommunityChestMilestone(e){return this.send(Se.ClaimCommunityChestMilestone,e,Sn)}claimCommunityChestGrandPrize(e){return this.send(Se.ClaimCommunityChestGrandPrize,e,Sn)}leaveCommunityChest(e){return this.send(Se.LeaveCommunityChest,e,bu)}};var Jt=zod.z.lazy(()=>zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null(),zod.z.array(Jt),zod.z.record(zod.z.string(),Jt)]));var mR={Live:"Live",Latest:"Latest",Specific:"Specific"},fR={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},gR=zod.z.enum(["Debug","Info","Warning","Error"]).catch("Debug"),RR={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"},yR=zod.z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]).catch("None"),CR=zod.z.object({Level:gR,Message:zod.z.string().nullish(),Data:Jt.nullish()}),SR=zod.z.object({Error:yR,Message:zod.z.string().nullish(),StackTrace:zod.z.string().nullish()}),ku=zod.z.object({FunctionName:zod.z.string().nullish(),Revision:zod.z.number().nullish(),FunctionResult:Jt.nullish(),FunctionResultTooLarge:zod.z.boolean().nullish(),Logs:zod.z.array(CR).nullish(),LogsTooLarge:zod.z.boolean().nullish(),ExecutionTimeSeconds:zod.z.number().nullish(),APIRequestsIssued:zod.z.number().nullish(),Error:SR.nullish()}),zn={Execute:"Execute"};var ss=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=A(this.ctx.settings.titleID,"CloudCode",zn.Execute,e.UserID??"");return this.ctx.transport.post(t,e,ku,{ticket:e.ClientSessionTicket})}};var ns=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ue.GetDefinitions,e,Ho)}getUserState(e){return this.send(Ue.GetUserState,e,$o)}depositToken(e){return this.send(Ue.DepositToken,e,Zo)}depositNFT(e){return this.send(Ue.DepositNFT,e,Jo)}requestTokenWithdrawal(e){return this.send(Ue.RequestTokenWithdrawal,e,Yo)}requestNFTWithdrawal(e){return this.send(Ue.RequestNFTWithdrawal,e,Xo)}getTransactionHistory(e){return this.send(Ue.GetTransactionHistory,e,ea)}retryWithdrawal(e){return this.send(Ue.RetryWithdrawal,e,ta)}confirmWithdrawal(e){return this.send(Ue.ConfirmWithdrawal,e,ia)}donateToDeveloper(e){return this.send(Ue.DonateToDeveloper,e,Gs)}donateToUsersPool(e){return this.send(Ue.DonateToUsersPool,e,Gs)}};var os=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(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,ga)}getGroupedOffers(e){return this.send(ae.GetGroupedOffers,e,Ra)}getOffersByItem(e){return this.send(ae.GetOffersByItem,e,Hs)}getOffer(e){return this.send(ae.GetOffer,e,ya)}getBuyOrders(e){return this.send(ae.GetBuyOrders,e,Hs)}getMyState(e){return this.send(ae.GetMyState,e,Sa)}getHistory(e){return this.send(ae.GetHistory,e,xa)}createListing(e){return this.send(ae.CreateListing,e,Qt)}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,Qt)}placeBid(e){return this.send(ae.PlaceBid,e,Ca)}claimAuction(e){return this.send(ae.ClaimAuction,e,Ge)}createBuyOrder(e){return this.send(ae.CreateBuyOrder,e,Qt)}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,Qt)}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 as=class{constructor(e){this.ctx=e;}ctx;send(e,t,i){let r=A(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,i,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ve.CreateRoom,e,es)}joinRoom(e){return this.send(Ve.JoinRoom,e,es)}leaveRoom(e){return this.send(Ve.LeaveRoom,e,bn)}listRooms(e){return this.send(Ve.ListRooms,e,Pu)}getRoom(e){return this.send(Ve.GetRoom,e,es)}closeRoom(e){return this.send(Ve.CloseRoom,e,bn)}poll(e){return this.send(Ve.Poll,e,Iu)}sendSignal(e){return this.send(Ve.SendSignal,e,ts)}sendChat(e){return this.send(Ve.SendChat,e,ts)}setMemberState(e){return this.send(Ve.SetMemberState,e,ts)}};var ls=class{settings;emitter;platform;acquisition;playtime;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=Mn(e),this.emitter=new Nt,this.platform=e.platform??new zt,this.clientPlatform=e.clientPlatform??Nn(),this.acquisition=new mt(this.platform),this.acquisition.capture(),this.playtime=new jt(this),this.emitter.on("auth:loggedIn",()=>{this.playtime.start(),this.acquisition.clear();}),this.emitter.on("auth:loggedOut",()=>{this.playtime.stop();}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.transport=new li({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e.fetch,debugLogging:this.settings.debugLogging,throttleMs:e.throttleMs,clientPlatform:this.clientPlatform}),this.data=new di(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 hi(this.platform.storage,this.settings.titleID),this.api={authentication:new ar(this),user:new ur(this),currency:new cr(this),item:new hr(this),store:new fr(this),purchase:new gr(this),lootbox:new Cr(this),reward:new Sr(this),quest:new br(this),tutorial:new xr(this),localization:new Dr(this),timedEvent:new zr(this),leaderboard:new wr(this),season:new Or(this),premium:new Br(this),character:new Lr(this),match:new qr(this),craft:new Gr(this),collection:new jr(this),coopEvent:new Vr(this),dealOffer:new _r(this),referral:new Wr(this),social:new Qr(this),timedBoost:new Hr(this),userCustomData:new $r(this),titleCustomData:new Jr(this),title:new is(this),gameLoop:new rs(this),cloudCode:new ss(this),blockchain:new ns(this),marketplace:new os(this),multiplayer:new as(this)},this.userService=new Ri(this),this.auth=new mi(this),this.currency=new Ci(this),this.item=new Si(this),this.store=new xi(this),this.purchase=new Di(this),this.checkout=new bi(this),this.lootbox=new vi(this),this.reward=new zi(this),this.quest=new ki(this),this.tutorial=new Ti(this),this.localization=new Ii(this),this.timedEvent=new Mi(this),this.leaderboard=new wi(this),this.season=new Ai(this),this.premium=new Oi(this),this.character=new Ui(this),this.match=new Bi(this),this.craft=new Li(this),this.collection=new qi(this),this.coopEvent=new Ei(this),this.dealOffer=new Gi(this),this.referral=new Ni(this),this.social=new ji(this),this.timedBoost=new Fi(this),this.userCustomData=new Wi(this),this.titleCustomData=new Qi(this),this.title=new Ki(this),this.gameLoop=new Hi(this),this.cloudCode=new $i(this),this.blockchain=new tr(this),this.marketplace=new nr(this),this.multiplayer=new or(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 us=class{ctx;constructor(e){this.ctx=new ls(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 xR(o){return new us(o)}var Mu="idos_sso",wu="state",Tn="idos:sso:state",DR="https://idosgames.com/sso/";function bR(){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(wu)??"",r=IR();return MR(e),kR(),r&&i!==r?null:{code:t,state:i}}function vR(o){if(typeof window>"u")return;let e=o.returnTo??zR(),t=TR();PR(t);let i=new URL(o.ssoUrl??DR);i.searchParams.set("title",o.titleID),i.searchParams.set("return_to",e),i.searchParams.set("state",t),window.location.assign(i.toString());}function zR(){let{origin:o,pathname:e,search:t}=window.location;return `${o}${e}${t}`}function TR(){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 PR(o){try{window.sessionStorage.setItem(Tn,o);}catch{}}function IR(){try{return window.sessionStorage.getItem(Tn)}catch{return null}}function kR(){try{window.sessionStorage.removeItem(Tn);}catch{}}function MR(o){o.delete(Mu),o.delete(wu);let e=o.toString(),{pathname:t,search:i}=window.location;window.history.replaceState(null,"",`${t}${i}${e?`#${e}`:""}`);}function wR(o,e){return !!o?.Claims?.[e]?.ClaimedAt}function AR(o){let e=o?.Claims;return e?Object.keys(e).filter(t=>!!e[t]?.ClaimedAt):[]}function OR(o,e){return o?.Claims?.[e]?.PremiumTiers??[]}function Ou(o,e,t,i=1){if(!o)return e;let r=o.Base??e,s=Math.max(0,t-i),a;switch(o.Shape??"Flat"){case "PerStep":a=r+(o.PerStep??0)*s;break;case "PerStepRate":a=r*(1+(o.PerStepRate??0)*s);break;case "Geometric":a=r*Math.pow(1+(o.GrowthRate??0),s);break;case "Table":a=r*Au(o,t,1);break;case "TableAbsolute":a=Au(o,t,r);break;default:a=r;break}return Number.isNaN(a)?r:(o.MinResult!=null&&a<o.MinResult&&(a=o.MinResult),o.MaxResult!=null&&a>o.MaxResult&&(a=o.MaxResult),a)}function UR(o,e,t=1){return Ou(o,1,e,t)}function BR(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 Uu(o.Points).length>0;default:return o.MinResult!=null||o.MaxResult!=null}}function LR(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 Uu(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 Au(o,e,t){let i=Uu(o.Points);if(i.length===0)return t;let r=null,s=null,a=null;for(let p of i)(a===null||p.AtStep>a.AtStep)&&(a=p),p.AtStep<=e&&(r===null||p.AtStep>=r.AtStep)&&(r=p),p.AtStep>e&&(s===null||p.AtStep<s.AtStep)&&(s=p);if(r===null)return t;if(s===null){let p=o.TailGrowthRate??0;return p===0?a.Value:a.Value*Math.pow(1+p,e-a.AtStep)}switch(o.Interpolation??"Step"){case "Linear":{let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+p*(s.Value-r.Value)}case "Geometric":{if(r.Value<=0||s.Value<=0){let x=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value+x*(s.Value-r.Value)}let p=(e-r.AtStep)/(s.AtStep-r.AtStep);return r.Value*Math.pow(s.Value/r.Value,p)}default:return r.Value}}var qR={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Pn=zod.z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]).catch("Banner"),ER={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},GR=zod.z.enum(["Top","Bottom","Left","Right"]).catch("Top"),NR=zod.z.object({PlacementID:zod.z.string().nullish(),Type:Pn.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(),jR=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(),FR=zod.z.object({CooldownSeconds:zod.z.number().nullish(),MinSessionTimeBeforeFirstSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),VR=zod.z.object({Enabled:zod.z.boolean().nullish(),Position:GR.nullish(),RefreshIntervalSeconds:zod.z.number().nullish()}).passthrough(),_R=zod.z.object({Enabled:zod.z.boolean().nullish(),CooldownSeconds:zod.z.number().nullish(),DailyImpressionCap:zod.z.number().nullish()}).passthrough(),WR=zod.z.object({MaxImpressionsPerHour:zod.z.number().nullish(),MaxImpressionsPerDay:zod.z.number().nullish(),MaxImpressionsPerSession:zod.z.number().nullish()}).passthrough(),QR=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(),KR=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(),HR=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(),$R=zod.z.object({AndroidUnitID:zod.z.string().nullish(),IosUnitID:zod.z.string().nullish(),WebUnitID:zod.z.string().nullish(),Type:Pn.nullish()}).passthrough(),ZR={AppLovinMax:"AppLovinMax",LevelPlay:"LevelPlay"},JR=zod.z.enum(["AppLovinMax","LevelPlay"]).catch("AppLovinMax"),YR=zod.z.object({ProviderID:zod.z.string().nullish(),Kind:JR.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(),$R).nullish()}).passthrough();zod.z.object({Enabled:zod.z.boolean().nullish(),Placements:zod.z.record(zod.z.string(),NR).nullish(),Providers:zod.z.record(zod.z.string(),YR).nullish(),RewardedVideo:jR.nullish(),Interstitial:FR.nullish(),Banner:VR.nullish(),AppOpen:_R.nullish(),FrequencyCapping:WR.nullish(),PremiumAdReductions:zod.z.array(QR).nullish(),Consent:KR.nullish(),Verification:HR.nullish()}).passthrough();var XR=zod.z.object({RewardedVideoCredit:zod.z.number().nullish(),TotalEarned:zod.z.number().nullish(),TotalSpent:zod.z.number().nullish()}).passthrough(),ey=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(),ty=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(),iy=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(),ry=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(),sy=zod.z.object({RequestID:zod.z.string().nullish(),PlacementID:zod.z.string().nullish(),ProviderID:zod.z.string().nullish(),Type:Pn.nullish(),IssuedAt:u.nullish(),ExpiresAt:u.nullish(),CreditsToAward:zod.z.number().nullish()}).passthrough(),ny=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:XR.nullish(),Placements:zod.z.record(zod.z.string(),ey).nullish(),Daily:ty.nullish(),Session:iy.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:ry.nullish(),PendingRequests:zod.z.record(zod.z.string(),sy).nullish(),FraudFlags:ny.nullish(),UpdatedAt:u.nullish()}).passthrough();var oy={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},ay=zod.z.enum(["Unread","Read","Deleted","Expired"]).catch("Unread"),ly={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},uy=zod.z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]).catch("Admin"),cy={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},py=zod.z.enum(["Active","Paused","Cancelled","Completed"]).catch("Active"),dy=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(),hy=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(),dy).nullish(),Segments:zod.z.array(hy).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:uy.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:ay.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:py.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 Bu="idos_device_id",cs=class{storage;constructor(e=new bt){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(Bu);return e||(e="noop-device",this.storage.setString(Bu,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};
2
+ exports.AcquisitionCapture=mt;exports.AdProviderKind=ZR;exports.AdType=qR;exports.AttackOutcome=gg;exports.AuthType=Re;exports.AuthenticationAction=we;exports.BannerPosition=ER;exports.BlockchainAction=Ue;exports.BlockchainNetworkType=dd;exports.BlockchainOperationCategory=Vo;exports.BlockchainTransactionStatus=xd;exports.BlockchainTransactionType=gd;exports.BodyPart=Wd;exports.BoostWindowKind=og;exports.BroadcastStatus=cy;exports.BrowserPlatformAdapter=zt;exports.BrowserStorage=Dt;exports.CharacterAction=Oe;exports.ClientPlatform=Ye;exports.CloudCodeAction=zn;exports.CloudCodeErrorCode=RR;exports.CloudCodeLogLevel=fR;exports.CloudCodeRevisionSelection=mR;exports.CollectionAction=Te;exports.CommissionSink=ph;exports.CommunityChestMemberStatus=$g;exports.CommunityChestStatus=Hg;exports.ConversionRateMode=Fp;exports.CoopEventAction=He;exports.CoopGroupStatus=hf;exports.CoopMemberStatus=mf;exports.CraftAction=Er;exports.CraftType=Ym;exports.CurrencyAction=Zi;exports.CurrencyStatus=jp;exports.CurrencyType=_e;exports.CurveInterpolation=ac;exports.CurveShape=nc;exports.CustomDataBucket=st;exports.CustomDataValueType=wp;exports.CustomDataWriter=Pp;exports.DEFAULT_BASE_URL=kn;exports.DealNodeRuntimeStatus=zf;exports.DealOfferAction=it;exports.DealOfferActivationStatus=vf;exports.EnvelopeType=aR;exports.EventTokenType=Qu;exports.FodderSelectionMode=Lh;exports.FodderValuationMode=Uh;exports.FriendActionStatus=Hf;exports.GameLoopAction=Se;exports.IDosGamesClient=us;exports.IapProductType=Yh;exports.IapPurchaseStatus=rm;exports.IapStoreValues=Wu;exports.ItemAction=pr;exports.KycStatus=Rd;exports.KycTier=Cd;exports.LeaderboardAction=be;exports.LocalizationAction=lr;exports.LocalizationMissingKeyMode=kh;exports.LootboxAction=yr;exports.MailboxMessageSource=ly;exports.MailboxMessageStatus=oy;exports.MarketGoodsType=sr;exports.MarketOfferStatus=ch;exports.MarketOfferType=uh;exports.MarketplaceAction=ae;exports.MatchAction=tt;exports.MatchStatus=Qd;exports.MemoryStorage=bt;exports.MultiplayerAction=Ve;exports.MultiplayerChatMode=sR;exports.MultiplayerTopology=rR;exports.NoopPlatformAdapter=cs;exports.PlaytimeTracker=jt;exports.PremiumAction=yt;exports.PurchaseAction=Ut;exports.QuestAction=Qe;exports.QuestObjectiveSource=Rc;exports.QuestPrerequisiteMode=Cc;exports.QuestStatus=mc;exports.RaidMode=mg;exports.ReferralAction=Ct;exports.ResourceEntryType=Yt;exports.RewardAction=ot;exports.RoomVisibility=nR;exports.ScheduleMode=Ku;exports.SeasonAction=ht;exports.SocialAction=$e;exports.SpecialChoiceMode=fg;exports.StoreAction=Ot;exports.StoreType=$m;exports.TimedBoostAction=St;exports.TimedBoostStackingPolicy=Yf;exports.TimedEventAction=Fe;exports.TimelineEventType=$f;exports.TitleAction=xt;exports.TitleCustomDataAction=Zt;exports.TitleDataBucket=ug;exports.TitleDataScope=lg;exports.TradeOfferStatus=tf;exports.TransactionDirection=Dd;exports.TutorialAction=qe;exports.TutorialBoardAction=Uc;exports.TutorialFlowStatus=wc;exports.TutorialGateMode=Xu;exports.TutorialRestartPolicy=kc;exports.TutorialScriptModule=Oc;exports.TutorialStepCompletionMode=Pc;exports.TypedEmitter=Nt;exports.UserAction=je;exports.UserCustomDataAction=Ke;exports.WalletLinkType=md;exports.beginSsoRedirect=vR;exports.claimedMilestoneIDs=AR;exports.createIDosGamesClient=xR;exports.curveMultiplier=UR;exports.evaluateCurve=Ou;exports.grantedPremiumTiers=OR;exports.isCurveConfigured=BR;exports.isFail=$u;exports.isMilestoneClaimed=wR;exports.isOk=Hu;exports.normalizeBlockchainCategory=Xi;exports.readSsoCodeFromUrl=bR;exports.roundAmount=LR;exports.zPaymentProof=Yp;exports.zPriceOption=ko;exports.zPriceOptions=J;