@idosgames/core 0.1.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +844 -560
- package/dist/index.d.ts +844 -560
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e,d}from'./chunk-QJVWT32O.js';export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,f as NoopPlatformAdapter}from'./chunk-QJVWT32O.js';import {z}from'zod';import Mt from'decimal.js';var gt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};var Ii="https://api.idosgames.com";function Mi(c){return {titleID:c.titleID,titleTemplateID:c.titleTemplateID??"default",buildKey:c.buildKey??"",baseUrl:(c.baseUrl??Ii).replace(/\/+$/,""),devBuild:c.devBuild??false,debugLogging:c.debugLogging??false}}function ki(c){return {ok:true,data:c}}function n(c,e){return {ok:false,reason:c,error:e}}function Qa(c){return c.ok}function Ha(c){return !c.ok}var vt=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(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var Tt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function Ai(c){return c===429||c>=500&&c<=599}function Tr(c,e=Math.random){let t=Math.min(500*Math.pow(2,c-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function Pr(c){return new Promise(e=>setTimeout(e,c))}var $a=12e3,Ka=z.object({Success:z.boolean(),Error:z.string().nullish(),Data:z.unknown().optional()}).passthrough(),It=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new Tt;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 vt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,u=JSON.stringify(t),m=r.ticket??null,z=r.silent??!1,B=r.timeoutMs??$a,G=r.autoRetry??!0,de=!1,fe=0;for(;;){let Pe;try{Pe=await this.doFetch(i,u,m,B);}catch{if(G&&fe<3){fe++,await Pr(Tr(fe));continue}return this.connectionFailure("Internet Connection Error",z)}let Ie=Pe.status;if(Ie>=200&&Ie<300)return await this.parseSuccess(Pe,s,z,e);if(Ie===401){if(!de&&this.sessionRefreshHandler){de=!0;let Ke=null;try{Ke=await this.sessionRefreshHandler();}catch{Ke=null;}if(Ke){m=Ke;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(Ai(Ie)){if(G&&fe<3){fe++,await Pr(Tr(fe));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Ie})`,z)}return await this.handleWebError(Pe,Ie,z)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,u=setTimeout(()=>{i.abort();},r);try{let m={"Content-Type":"application/json"};return s&&(m.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:m,signal:i.signal})}finally{clearTimeout(u);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let u;try{u=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let m=Ka.safeParse(u);if(!m.success)return this.globalError("Malformed response envelope",s);if(!m.data.Success){let B=m.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",B),n("server",B)}let z=t.safeParse(m.data.Data);if(!z.success){let B=`Validation error (${r}): ${z.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",B),s||this.emitter.emit("error:global",B),n("validation",B)}return ki(z.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let m=JSON.parse(i).Error;r=typeof m=="string"&&m.length>0?`HTTP ${t}: ${m}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||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 ot(c){return (typeof c=="string"?c:c.toISOString()).slice(0,10)}function yt(c){return `${ot(c)}T00:00:00.000Z`}function Ui(c){let e=new Date(c);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function Bi(c,e){return new Date(c.getTime()+e*6e4).toISOString()}function wi(c,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;c.InventoryV2??={};let i=c.InventoryV2,u=s.toISOString(),m=new Map,z=new Map,B=new Map,G=new Map,de=new Map,fe=new Map,Pe=new Map,Ie=new Map,Ke=e.Grant?.PremiumTiers??[],zt=Ke.length;for(let X=0;;X++){let ie,V;if(X===0)ie=e.Grant?.Standard?.Entries,V=false;else if(X-1<zt)ie=Ke[X-1]?.Resources?.Entries,V=false;else if(X===1+zt)ie=e.Consume?.Standard?.Entries,V=true;else break;if(ie)for(let N of ie){if(N.Type==null)continue;let _=Math.max(0,N.Amount??0);if(!(_<=0))switch(N.Type){case "VirtualCurrency":{if(!N.CurrencyID)continue;let W=V?z:m;W.set(N.CurrencyID,(W.get(N.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!N.CurrencyID)continue;let W=V?G:B;W.set(N.CurrencyID,(W.get(N.CurrencyID)??new Mt(0)).plus(_));break}case "Item":{if(!N.ItemID)continue;let W=Ja(t,N.CatalogID,N.ItemID),Y=(W?W.IsStackable??true:true)?V?fe:de:V?Ie:Pe;Y.set(N.ItemID,(Y.get(N.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=m.size>0||z.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let X of new Set([...m.keys(),...z.keys()])){let ie=m.get(X)??0,V=z.get(X)??0,N=ie-V,_=i.VirtualCurrencies[X];_?(_.Amount+=N,_.UpdatedAt=u,_.Daily&&ot(_.Daily.PeriodStartUtc)===ot(s)?(_.Daily.Earned+=ie,_.Daily.Spent+=V):_.Daily={PeriodStartUtc:yt(s),Earned:ie,Spent:V}):i.VirtualCurrencies[X]={Amount:N,CreatedAt:u,UpdatedAt:u,Daily:{PeriodStartUtc:yt(s),Earned:ie,Spent:V}};}}if(r.ccChanged=B.size>0||G.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let X of new Set([...B.keys(),...G.keys()])){let ie=B.get(X)??new Mt(0),V=G.get(X)??new Mt(0),N=ie.minus(V),_=i.CryptoCurrencies[X];_?(_.Amount=new Mt(_.Amount).plus(N).toString(),_.UpdatedAt=u):i.CryptoCurrencies[X]={Amount:N.toString(),Frozen:"0",CreatedAt:u,UpdatedAt:u};}}if(r.itemsChanged=de.size>0||fe.size>0||Pe.size>0||Ie.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let X=i.UnstackableItems,ie=new Set([...de.keys(),...fe.keys(),...Pe.keys(),...Ie.keys()]);for(let V of ie){let N=(de.get(V)??0)-(fe.get(V)??0),_=(Pe.get(V)??0)-(Ie.get(V)??0),W=N+_,Me=i.Items[V];Me?(N!==0&&(Me.StackableAmount+=N),_!==0&&(Me.UnstackableAmount+=_),W!==0&&(Me.TotalAmount+=W)):i.Items[V]={StackableAmount:Math.max(0,N),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[V,N]of Ie){if(N<=0)continue;let _=Object.values(X).filter(W=>W.ItemID===V&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(Za).slice(0,N).map(W=>W.ItemInstanceID);for(let W of _)delete X[W];}for(let[V,N]of Pe){let _=Ya(t,V);for(let W=0;W<N;W++){let Me=d();X[Me]={ItemInstanceID:Me,ItemID:V,CatalogID:_,RemainingUses:1,AcquiredAt:u};}}}c.EventToken??={};let Fa=c.EventToken;for(let X=0;;X++){let ie,V;if(X===0)ie=e.Grant?.Standard?.EventTokens,V=false;else if(X-1<zt)ie=Ke[X-1]?.Resources?.EventTokens,V=false;else if(X===1+zt)ie=e.Consume?.Standard?.EventTokens,V=true;else break;if(!(!ie||ie.length===0))for(let N of ie){let _=N.Address;if(!_||_.Type==null)continue;let W=N.Amount??0;if(W<=0)continue;let Me=Xa(Fa,_.Type);if(!Me)continue;let Y=Me[_.EntityID];Y||(Y={},Me[_.EntityID]=Y),Y.Balance??={Current:0,TotalEarned:0,TotalSpent:0},Y.Daily??={Date:yt(s),TotalEarned:0},Y.Meta??={};let Rt=N.Source&&N.Source.length>0?N.Source:"CustomAction";V?(Y.Balance.Current-=W,Y.Balance.TotalSpent+=W):(Y.Balance.Current+=W,Y.Balance.TotalEarned+=W,ot(Y.Daily.Date)!==ot(s)&&(Y.Daily={Date:yt(s),TotalEarned:0}),Y.Daily.TotalEarned+=W,Y.Daily.EarnedBySource??={},Y.Daily.EarnedBySource[Rt]=(Y.Daily.EarnedBySource[Rt]??0)+W,Y.Daily.TriggersBySource??={},Y.Daily.TriggersBySource[Rt]=(Y.Daily.TriggersBySource[Rt]??0)+1,Y.Daily.LastTriggerBySource??={},Y.Daily.LastTriggerBySource[Rt]=u,Y.Meta.JoinedAtUtc||(Y.Meta.JoinedAtUtc=u),Y.Meta.LastEarnedAtUtc=u),r.tokensChanged=true;}}return r}function Za(c,e){return c.AcquiredAt!==e.AcquiredAt?c.AcquiredAt<e.AcquiredAt?-1:1:c.ItemInstanceID===e.ItemInstanceID?0:c.ItemInstanceID<e.ItemInstanceID?-1:1}function Ja(c,e,t){let s=c?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function Ya(c,e){let t=c?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function Xa(c,e){switch(e){case "TimedEvent":return c.TimedEvent??={};case "Quest":return c.Quest??={};case "Leaderboard":return c.Leaderboard??={};case "CoopEvent":return c.CoopEvent??={};case "Season":return c.Season??={};default:return null}}function Ir(c,e){return c===e||c.startsWith(`${e}:`)}var kt=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);}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,s=new Date){if(!this.currentState)return;let r=wi(this.currentState,e,t,s);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,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof Mt?t:new Mt(t),u=s??new Date().toISOString(),m=r[e];m?(m.Amount=new Mt(m.Amount).plus(i).toString(),m.UpdatedAt=u):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:u,UpdatedAt:u},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,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=Ui(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let u of t)u.RuleID&&(r.Pity[`${e}:${u.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}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,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let u=i.Quests[e]??={QuestID:e,Status:s};u.Status=s,s==="Claimed"&&(u.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.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 s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",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 s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.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[s,r]of Object.entries(t))if(Ir(s,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,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!Ir(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.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 s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.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,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}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 s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.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,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}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 s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,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,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(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,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==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(s=>s!==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(s=>s!==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 s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[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,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let u=this.currentState.CustomData,m={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")u.Private??={},u.Private[t]=m;else if(e==="Public")u.Public??={},u.Public[t]=m;else return;u.Version=(u.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 s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.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 s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.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 s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.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 At=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 Ot=class{user;config;constructor(e){this.user=new kt(e),this.config=new At;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var we={Virtual:"Virtual",Crypto:"Crypto"},at=z.enum(["Virtual","Crypto"]),el={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Bt=z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),tl={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},wt=z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),sl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Ct=z.enum(["Cyclic","Scheduled","Chained"]),ae={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var qt=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 rl(e)?e:ae.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 rl(c){return c!==null&&Object.values(ae).includes(c)}var il=8,nl=100,ol=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,qi=["GameLoop"],Et=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ae.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(ae.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 s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ae.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ae.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(ae.Wallet)):i}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ae.iDosGames)):s}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,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,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,s){switch(e){case ae.Email:return this.loginWithEmail(t,s);case ae.Device:case ae.None:return this.loginWithDeviceID();case ae.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!==ae.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ae.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&&ol.test(e)}static isValidPasswordLength(e){return e.length>=il&&e.length<=nl}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ae.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(qi,qi);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 Lt=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:d()}:null}async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.user.getClientState(e);return t.ok&&this.applyClientState(t.data),t}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=await this.ctx.api.user.getClientStateExcept(s);return r.ok&&this.applyClientState(r.data,e,t),r}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,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}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 s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}applyClientState(e,t,s){let r=t?.includes("GameLoop")===true,i=s?.includes("GameLoop")===true,u=r?this.ctx.data.user.state?.GameLoop:void 0,m=i?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(e.Title),this.ctx.data.user.applyUserState(e.User??{});let z=this.ctx.data.user.state;r&&z&&z.GameLoop==null&&(z.GameLoop=u);let B=this.ctx.data.config.titlePublicConfiguration;i&&B&&B.GameLoop==null&&(B.GameLoop=m),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Nt=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,u){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Crypto||s===we.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 m={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:u&&u.length>0?u:`convert_${e}_${t}_to_${s}_${r}_${d()}`},z=await this.ctx.api.currency.convert(m);if(z.ok){let B=z.data,G={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.SourceID,Amount:B.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.TargetID,Amount:B.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(G,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",B);}return z}async cryptoConvert(e,t,s,r,i,u){let m=i instanceof Mt?i:new Mt(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(m.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===we.Virtual&&s===we.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===we.Virtual&&!m.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:m.toString(),TransactionID:u&&u.length>0?u:`crypto_convert_${e}_${t}_to_${s}_${r}_${d()}`},B=await this.ctx.api.currency.cryptoConvert(z);if(B.ok){let G=B.data,de=[],fe=[];if(G.SourceType===we.Virtual&&de.push({Type:"VirtualCurrency",CurrencyID:G.SourceID,Amount:Math.trunc(Number(G.SourceSpent))}),G.TargetType===we.Virtual&&fe.push({Type:"VirtualCurrency",CurrencyID:G.TargetID,Amount:Math.trunc(Number(G.TargetCredited))}),de.length>0||fe.length>0){let Pe={Consume:de.length>0?{Standard:{Entries:de}}:null,Grant:fe.length>0?{Standard:{Entries:fe}}:null};this.ctx.data.user.applyResourceOperation(Pe,this.ctx.data.config.itemDefinitions);}G.SourceType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(G.SourceID,new Mt(G.SourceSpent).negated(),G.ServerTimeUtc),G.TargetType===we.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(G.TargetID,new Mt(G.TargetCredited),G.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",G);}return B}};var jt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${d()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}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},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var al="Store",Ft=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${d()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let u=i.data;this.ctx.data.user.patchStorePurchase(e,t,u.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",u);}return i}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},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}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(al,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 ll="Lootbox",_t=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 s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(ll,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){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 r={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:s,RelatedEntityID:`lootbox_${e}_${s}_${d()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let u=i.data;u.TriggeredPity&&u.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,u.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(u.Inventory),this.ctx.emitter.emit("lootbox:opened",u);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ul="Reward";function kr(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var Wt=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 s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(ul,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}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 s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${d()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!kr(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}_${d()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.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 s}async claimComebackReward(e){if(!kr(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}_${d()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.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 s}async claimReward(e){if(!kr(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}_${d()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.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 s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var cl="Quest",Vt=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(cl,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 s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}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 s=e.trim();if(!s)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,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${d()}`},u=await this.ctx.api.quest.claimQuestReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchQuestStatus(m.QuestID,m.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",m);}return u}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},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${d()}`},u=await this.ctx.api.quest.claimMilestoneReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchMilestoneClaimed(m.CycleID,m.MilestoneID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",m);}return u}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},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${d()}`},u=await this.ctx.api.quest.claimGroupCompletionReward(i);if(u.ok){let m=u.data;this.ctx.data.user.patchGroupCompletionClaimed(m.CycleID,m.GroupCompletionID),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",m);}return u}async addQuestProgress(e,t){let s=e.trim();if(!s)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:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var pl="TimedEvent",Qt=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(pl,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,s,r,i,u,m=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:u,RollMultiplier:m},B=await this.ctx.api.timedEvent.grantTokens(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",B.data)),B}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=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:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)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:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let u=i.data;this.ctx.data.user.applyResourceOperation(u.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",u);}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},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}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},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}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},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.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 dl="Leaderboard",Ht=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(dl,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 s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}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 s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=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 u={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},m=await this.ctx.api.leaderboard.submitScoreFromSource(u);if(m.ok){let z=m.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),z.NewScore,z.NewScore,z.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",z);}return m}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},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.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 s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}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 s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}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 s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}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 s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.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",s.data);}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},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let u of r.Milestones??[])!u.Success||!u.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,u.Data.MilestoneID),u.Data.Resources&&this.ctx.data.user.applyResourceOperation(u.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}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 s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ml="Season",$t=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(ml,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 s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}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 s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${d()}`},r=await this.ctx.api.season.grantStatusTokens(s);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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${d()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hl="Premium",Kt=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(hl,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 s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);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,s="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 i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},u=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(u.ok){let m=u.data;m.Premium&&this.ctx.data.user.applyPremium(m.Premium),this.ctx.data.user.applyResourceOperation(m.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",m);}return u}async purchaseRealMoney(e,t,s,r,i,u,m,z){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let B={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:u,PackageName:m,AppStoreEnvironment:z,RelatedEntityID:`premium_iap_${e}_${t}`},G=await this.ctx.api.premium.purchaseRealMoney(B);if(G.ok){let de=G.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 G}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fl="Character",Zt=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(fl,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 s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}return t}async unlockCharacter(e){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`unlock_char_${e}_${d()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){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}_${d()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let u=i.data;this.ctx.data.user.patchCharacter(u.CharacterID,m=>{m.StatLevels??={},m.StatLevels[u.StatID]=u.StatLevel,u.Power!=null&&(m.Power=u.Power),m.UpdatedAt=u.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",u);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${d()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,u=>{u.Level=i.NewLevel,i.Power!=null&&(u.Power=i.Power),u.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(u.StatLevels??={},u.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.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},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}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},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}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},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Rl="Match",Jt=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let u=this.ctx.auth.context;if(!u)return n("unauthorized","Not logged in.");let m={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${u.userID}_${d()}`},z=await this.ctx.api.match.createMatch(m);return z.ok&&(this.ctx.data.user.applyResourceOperation(z.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",z.data)),z}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...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(s);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},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${d()}`},m=await this.ctx.api.match.instantBattle(u);if(m.ok){let z=m.data,B=this.ctx.data.config.itemDefinitions;if(z.Resources)this.ctx.data.user.applyResourceOperation(z.Resources,B);else if(z.ResourcesDual){let G=z.ResourcesDual;G.FromUserID===i.userID&&G.FromResult?this.ctx.data.user.applyResourceOperation(G.FromResult,B):G.ToUserID===i.userID&&G.ToResult&&this.ctx.data.user.applyResourceOperation(G.ToResult,B);}this.ctx.emitter.emit("match:instantBattleCompleted",z);}return m}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}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(Rl,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gl="Craft",Yt=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(gl,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${d()}`},m=await this.ctx.api.craft.craft(u);return m.ok&&(this.ctx.data.user.applyResourceOperation(m.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",m.data)),m}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yl="Collection",Xt=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(yl,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){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}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},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${d()}`},r=await this.ctx.api.collection.claimGrandPrize(s);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,s,r,i,u=false){let m=this.ctx.auth.context;if(!m)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:u,RelatedEntityID:`trade_send_${m.userID}_${r}_${d()}`},B=await this.ctx.api.collection.sendTradeOffer(z);return B.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",B.data),B}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}_${d()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}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}_${d()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}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}_${d()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cl="CoopEvent",es=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(Cl,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 s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}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 s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}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},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){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,RelatedEntityID:d()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}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},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}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},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Sl="DealOffer",ts=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(Sl,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}_${d()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${d()}`},u=await this.ctx.api.dealOffer.executeNode(i);return u.ok&&(u.data.Idempotent||this.ctx.data.user.applyResourceOperation(u.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",u.data)),u}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}_${d()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${d()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);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 s=[...new Set(t.map(u=>u.trim()).filter(u=>u.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${d()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xl="Referral",ss=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(xl,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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let u=i.data;u.ReferralCode&&this.ctx.data.user.patchReferralSubscription(u.ReferralCode),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",u);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let u=i.data;u.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(u.RewardID),this.ctx.data.user.applyResourceOperation(u.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",u);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var rs=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}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},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}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},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}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},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}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},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}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 Dl="TimedBoost";function bl(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var is=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(Dl,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){let t=e.trim();if(!bl(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${d()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let u=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,u);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}return r}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 M=z.union([z.number(),z.string()]).transform((c,e)=>{let t=typeof c=="string"?Number(c):c;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(c)}`}),z.NEVER)}),w=z.union([z.number(),z.string()]).transform((c,e)=>{let t=typeof c=="number"?String(c):c.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:z.ZodIssueCode.custom,message:`Invalid decimal: ${String(c)}`}),z.NEVER):t}),a=z.string();var We={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},zl={Client:"Client",Server:"Server",System:"System"},vl=z.enum(["Client","Server","System"]),Tl=z.object({Value:z.string().nullish(),UpdatedAt:a.nullish(),Version:z.number().nullish(),LastWriter:vl.nullish(),ExpiresAt:a.nullish()}).passthrough(),ns=z.record(z.string(),Tl),Ei=z.object({Version:z.number().nullish(),Private:ns.nullish(),Public:ns.nullish(),ReadOnly:ns.nullish()}),Ar=z.object({UserID:z.string().nullish(),Version:z.number().nullish(),Public:ns.nullish()}),Or=z.object({ServerTimeUtc:a.nullish(),Bucket:z.string().nullish(),KeyID:z.string(),Version:z.number().nullish(),ExpiresAt:a.nullish()}),Pl=z.object({Bucket:z.string().nullish(),KeyID:z.string(),Version:z.number().nullish(),ExpiresAt:a.nullish()}),Li=z.object({ServerTimeUtc:a.nullish(),Results:z.array(Pl).nullish()}),Gi=z.object({ServerTimeUtc:a.nullish(),DeletedCount:z.number().nullish()}),Ni=z.object({Results:z.array(Ar).nullish(),NotFoundUserIDs:z.array(z.string()).nullish()}),Il={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Ml=z.enum(["String","Int","Bool","Json"]),kl=z.object({KeyID:z.string(),Bucket:z.string().nullish(),ValueType:Ml.nullish(),MaxValueLengthBytes:z.number().nullish(),TtlSeconds:z.number().nullish(),DefaultValue:z.string().nullish(),Description:z.string().nullish()}).passthrough(),os=z.object({Keys:z.record(z.string(),kl).nullish(),DefaultMaxValueLengthBytes:z.number().nullish(),DefaultTtlSeconds:z.number().nullish(),MaxKeysPerBucket:z.number().nullish(),MaxTotalSizeBytes:z.number().nullish(),RejectUnregisteredKeys:z.boolean().nullish()}).passthrough(),Ee={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Al="UserCustomData";function ji(c){return c.length>0&&!c.includes(".")&&!c.includes("$")}var as=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(Al,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,We.Private)}async setPublicData(e,t){return this.setData(e,t,We.Public)}async setData(e,t,s){let r=e.trim();if(!ji(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 i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},m=await(s===We.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(m.ok){let z=m.data;this.ctx.data.user.patchUserCustomDataKey(s,z.KeyID,t,z.Version??0,z.ExpiresAt),this.ctx.emitter.emit(s===We.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",z);}return m}async deleteKey(e,t){let s=e.trim();if(!ji(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==We.Private&&t!==We.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:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}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},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??We.Private,u=e.find(m=>m.Bucket===i&&m.KeyID===r.KeyID);u&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,u.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}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},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}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 s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ol="TitleCustomData",ls=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 getPublicTitleCustomData(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.title.getPublicTitleCustomData(e);return t.ok&&(this.ctx.data.config.patchSection(Ol,t.data),this.ctx.emitter.emit("title:publicCustomDataReceived",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 Ul=15,Bl="GameLoop",wl="BoardDefinition",us=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(Bl,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 s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(wl,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,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 s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,u=Bi(new Date,Ul);this.ctx.data.user.patchBoardState(m=>{m.Position=i.NewPosition,m.CyclesCompleted=(m.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),m.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?m.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:u}:i.SpecialModeOffer&&(m.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:u,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${d()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let u=i.data;u.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(u.RaidLayout,u.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(u)),this.ctx.emitter.emit("gameLoop:boardRaided",u);}else await this.getUserBoardState();return i}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 s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}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 s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(u=>{u.StageLevel=(u.StageLevel??1)+1,u.Position=0,u.Pending=null,u.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,u=>{i.NewLevel!=null&&(u.Level=i.NewLevel),u.IsDamaged=false,i.MaxLevelRewardClaimed&&(u.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}return r}async boardSpecialChoose(e){if(!e)return n("client","choiceID must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(m=>{m.ChoiceID=e,m.ChosenMode=i.Mode??"Timed",m.StartedAtUtc=i.StartedAtUtc??null,m.DurationSeconds=i.DurationSeconds??null,m.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(u=>{u.AdViewsUsed=i.AdViewsUsed??0,u.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${d()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return s}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 s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.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 s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);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},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}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 cs=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let u={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},m=await this.ctx.api.cloudCode.execute(u);return m.ok&&this.ctx.emitter.emit("cloudCode:executed",m.data),m}};var Ur=z.object({Type:Bt.nullish(),CurrencyID:z.string().nullish(),Amount:M.nullish(),CatalogID:z.string().nullish(),ItemID:z.string().nullish()}),ql=z.object({Type:wt.nullish(),EntityID:z.string()}),El=z.object({Address:ql.nullish(),Amount:M.nullish(),Source:z.string().nullish()}),ne=z.object({Entries:z.array(Ur).nullish(),EventTokens:z.array(El).nullish()}),Fi=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),Resources:ne.nullish()}),L=z.object({Standard:ne.nullish(),PremiumBonuses:z.array(z.unknown()).nullish(),PremiumTiers:z.array(Fi).nullish()}),Q=z.object({Standard:ne.nullish(),PremiumDiscounts:z.array(z.unknown()).nullish(),PremiumTiers:z.array(Fi).nullish()}),S=z.object({Grant:L.nullish(),Consume:Q.nullish()}),Xe=z.object({FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),FromResult:S.nullish(),ToResult:S.nullish()});z.object({FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),Transferred:ne.nullish()});var _i=z.object({ServerTimeUtc:a,SourceType:at,SourceID:z.string(),TargetType:at,TargetID:z.string(),SourceSpent:M,FeeAmount:M,RateApplied:w,TargetCredited:M}),Wi=z.object({ServerTimeUtc:a,SourceType:at,SourceID:z.string(),TargetType:at,TargetID:z.string(),SourceSpent:w,FeeAmount:w,RateApplied:w,TargetCredited:w}),ps={Convert:"Convert",CryptoConvert:"CryptoConvert"},Ll={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},Vi=z.enum(["Active","Hidden","Deprecated","Maintenance"]),Gl={Automatic:"Automatic",Manual:"Manual"},Nl=z.enum(["Automatic","Manual"]),jl=z.object({ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),InitialDeposit:z.number().nullish(),MinBalance:z.number().nullish(),MaxBalance:z.number().nullish(),DailyEarnLimit:z.number().nullish(),DailySpendLimit:z.number().nullish()}).passthrough(),Fl=z.object({Rate:z.number().nullish(),Max:z.number().nullish(),Period:z.number().nullish()}).passthrough(),_l=z.object({IsTradable:z.boolean().nullish(),IsPurchasable:z.boolean().nullish(),IsRefundable:z.boolean().nullish()}).passthrough(),Wl=z.object({TargetCurrencyType:at.nullish(),TargetCurrencyID:z.string(),Rate:w.nullish(),MinAmount:z.number().nullish(),MaxAmount:z.number().nullish(),DailyLimit:z.number().nullish()}).passthrough(),Qi=z.object({Enabled:z.boolean().nullish(),RateMode:Nl.nullish(),FeePercent:w.nullish(),Targets:z.array(Wl).nullish()}).passthrough(),Hi=z.object({CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough(),Vl=z.object({CurrencyID:z.string(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Economy:jl.nullish(),Recharge:Fl.nullish(),Conversion:Qi.nullish(),Permissions:_l.nullish(),Audit:Hi.nullish(),Status:Vi.nullish()}).passthrough(),Ql=z.object({NetworkID:z.string(),ContractAddress:z.string().nullish(),Decimals:z.number().nullish(),MinDeposit:w.nullish(),MinWithdraw:w.nullish(),WithdrawFee:w.nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish()}).passthrough(),Hl=z.object({DailyWithdrawUsd:w.nullish(),MonthlyWithdrawUsd:w.nullish(),KycRequiredAboveUsd:w.nullish()}).passthrough(),$l=z.object({DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),SpendableInGame:z.boolean().nullish(),ConvertibleToVirtual:z.boolean().nullish()}).passthrough(),Br=z.object({CurrencyID:z.string(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),DisplayDecimals:z.number().nullish(),ValueInUSD:w.nullish(),ValueInUSDUpdatedAt:a.nullish(),DeveloperDepositSharePercent:w.nullish(),CommunityMarketingDepositSharePercent:w.nullish(),WithdrawalBurnPercent:w.nullish(),Networks:z.array(Ql).nullish(),Limits:Hl.nullish(),Permissions:$l.nullish(),Conversion:Qi.nullish(),Audit:Hi.nullish(),Status:Vi.nullish()}).passthrough(),ds=z.object({VirtualCurrencies:z.record(z.string(),Vl).nullish(),CryptoCurrencies:z.record(z.string(),Br).nullish()}).passthrough();var ee=c=>z.object({Id:z.string(),Success:z.boolean(),Error:z.string().nullish(),Data:c.nullish()}),ms=c=>z.object({ServerTimeUtc:a,Items:z.array(ee(c)),Resources:S.nullish()});var me=z.object({PresetID:z.string().nullish(),Remove:z.array(z.string()).nullish()}).passthrough();var $i=z.object({CatalogID:z.string().nullish(),ItemID:z.string().nullish(),ItemInstanceID:z.string().nullish(),EquippedAt:a.nullish()}),wr=z.object({CharacterID:z.string(),Level:z.number().nullish(),Experience:M.nullish(),Power:z.number().nullish(),StatLevels:z.record(z.string(),z.number()).nullish(),Equipment:z.record(z.string(),$i).nullish(),UpdatedAt:a.nullish()}).passthrough(),Kl=z.object({CharacterID:z.string().nullish(),SlotID:z.string().nullish()}).passthrough(),Zl=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:Kl.nullish(),CustomData:z.string().nullish()}).passthrough().transform(c=>c),Ze=z.object({ChangedInstances:z.record(z.string(),Zl).nullish(),RemovedInstanceIDs:z.array(z.string()).nullish()}),Ki=z.object({Characters:z.record(z.string(),wr).nullish()}),qr=z.object({ServerTimeUtc:a,CharacterID:z.string(),StatID:z.string(),StatLevel:z.number(),Power:z.number().nullish(),Resources:S.nullish()}),Er=z.object({ServerTimeUtc:a,CharacterID:z.string(),NewLevel:z.number(),Power:z.number().nullish(),Resources:S.nullish()}),Zi=z.object({ServerTimeUtc:a,CharacterID:z.string(),Equipment:z.record(z.string(),$i).nullish(),ReplacedInstanceIDs:z.array(z.string()).nullish(),Power:z.number().nullish(),Inventory:Ze.nullish()}),Ji=z.object({ServerTimeUtc:a,CharacterID:z.string(),ClearedSlotIDs:z.array(z.string()).nullish(),Power:z.number().nullish(),Inventory:Ze.nullish()}),Jl=z.object({ClearedSlotIDs:z.array(z.string()).nullish(),Power:z.number().nullish()}),Yi=z.object({ServerTimeUtc:a,Characters:z.record(z.string(),Jl).nullish(),Inventory:Ze.nullish()}),Lr=z.object({ServerTimeUtc:a,CharacterID:z.string(),Power:z.number().nullish(),Resources:S.nullish()}),Xi=ms(Lr),en=ms(Er),tn=ms(qr),sn=z.object({RequiredStatID:z.string(),RequiredLevel:z.number()}).passthrough(),rn=z.object({StatID:z.string(),TypeID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),MaxLevel:z.number().nullish(),Weight:z.number().nullish(),BaseCostResource:Q.nullish(),CostScalingFactor:z.number().nullish(),BaseStatValue:z.number().nullish(),StatScalingFactor:z.number().nullish(),CharacterLevelScalingFactor:z.number().nullish(),Requirements:z.array(sn).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),nn=z.object({Level:z.number().nullish(),UpgradeCost:Q.nullish(),GlobalStatMultiplier:z.number().nullish(),StatMaxLevelMultiplier:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),Yl=z.object({SlotID:z.string(),MinCharacterLevel:z.number().nullish(),StatRequirements:z.array(sn).nullish(),AllowedRarityIDs:z.array(z.string()).nullish(),AllowedItemTags:z.array(z.string()).nullish(),MinItemLevel:z.number().nullish(),MaxItemLevel:z.number().nullish()}).passthrough(),on=z.object({Slots:z.record(z.string(),Yl).nullish()}).passthrough(),Xl=z.object({DisplayName:z.string().nullish(),Description:z.string().nullish(),Lore:z.string().nullish(),SortOrder:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),eu=z.object({ClassID:z.string().nullish(),RarityID:z.string().nullish(),Tags:z.array(z.string()).nullish()}).passthrough(),tu=z.object({UnlockedByDefault:z.boolean().nullish(),Cost:Q.nullish()}).passthrough(),su=z.object({Stats:me.nullish(),Levels:me.nullish(),Equipment:me.nullish()}).passthrough(),ru=z.object({CharacterID:z.string(),Identity:Xl.nullish(),Classification:eu.nullish(),Unlock:tu.nullish(),Presets:su.nullish(),Equipment:on.nullish(),Stats:z.record(z.string(),rn).nullish(),Levels:z.record(z.string(),nn).nullish()}).passthrough(),iu=z.object({Stats:z.record(z.string(),rn).nullish()}).passthrough(),nu=z.object({Levels:z.record(z.string(),nn).nullish()}).passthrough(),ou=z.object({Equipment:on.nullish()}).passthrough(),au=z.object({Stats:z.record(z.string(),iu).nullish(),Levels:z.record(z.string(),nu).nullish(),Equipment:z.record(z.string(),ou).nullish()}).passthrough(),fs=z.object({Definitions:z.record(z.string(),ru).nullish(),Presets:au.nullish()}).passthrough(),ze={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var lu={EVM:"EVM",Solana:"Solana"},uu=z.enum(["EVM","Solana"]),cu={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},pu=z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),du={Token:"Token",Nft:"Nft"},an=z.enum(["Token","Nft"]),mu={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},hu=z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),fu={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},Ru=z.enum(["None","Tier1","Tier2","Tier3"]),gu={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Gr=z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),ln={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Rs(c){let e=c?.trim();return e||ln.GameTopUp}var yu={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},un=z.enum(["UsersCryptoWallet","Game"]),Cu=z.object({ContractAddress:z.string().nullish(),ItemCatalogID:z.string().nullish(),DisplayName:z.string().nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish()}).passthrough(),cn=z.object({Ios:z.boolean().nullish(),Android:z.boolean().nullish(),Web:z.boolean().nullish()}).passthrough(),Su=z.object({NetworkID:z.string().nullish(),DisplayName:z.string().nullish(),Type:uu.nullish(),ChainID:z.number().nullish(),ChainTicker:z.string().nullish(),RewardPoolAddress:z.string().nullish(),VaultDepositAddress:z.string().nullish(),ChainConfigVersion:z.number().nullish(),RequiredConfirmations:z.number().nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),NftDepositsEnabled:z.boolean().nullish(),NftWithdrawalsEnabled:z.boolean().nullish(),PlatformOverrides:cn.nullish(),NftCollections:z.array(Cu).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),xu=z.object({DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),NftDepositsEnabled:z.boolean().nullish(),NftWithdrawalsEnabled:z.boolean().nullish(),PlatformOverrides:cn.nullish()}).passthrough(),Du=z.object({MinAccountAgeDays:z.number().nullish(),MultiAccountCheckEnabled:z.boolean().nullish(),BanOnSharedWithdrawalAddress:z.boolean().nullish(),PendingWithdrawalTtlHours:z.number().nullish()}).passthrough();var bu=z.enum(["OnChain","Combined"]),zu=z.object({Enabled:z.boolean().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),MinBalance:w.nullish(),BalanceSource:bu.nullish(),DenyMessage:z.string().nullish()}).passthrough(),vu=z.object({Enabled:z.boolean().nullish(),TokenGates:z.array(zu).nullish(),WalletConnectProjectId:z.string().nullish()}).passthrough(),Nr=z.object({SystemState:xu.nullish(),Networks:z.record(z.string(),Su).nullish(),AccountSafety:Du.nullish(),WalletLogin:vu.nullish()}).passthrough(),Tu=z.object({NetworkID:z.string().nullish(),Address:z.string().nullish(),LinkedAt:a.nullish(),LastUsedAt:a.nullish(),LinkType:pu.nullish(),IsSignatureVerified:z.boolean().nullish()}).passthrough(),pn=z.object({TitleTransactionID:z.string().nullish(),Type:an.nullish(),NetworkID:z.string().nullish(),AssetID:z.string().nullish(),Amount:w.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),Pu=z.object({Status:hu.nullish(),Tier:Ru.nullish(),VerifiedAt:a.nullish(),ExpiresAt:a.nullish(),RejectedAt:a.nullish(),ProviderReference:z.string().nullish(),RejectionReason:z.string().nullish()}).passthrough(),Iu=z.object({CurrencyID:z.string().nullish(),Deposits:z.number().nullish(),DepositsVolumeNative:w.nullish(),DepositsVolumeUsd:w.nullish(),Withdrawals:z.number().nullish(),WithdrawalsVolumeNative:w.nullish(),WithdrawalsVolumeUsd:w.nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),Mu=z.object({TotalDeposits:z.number().nullish(),TotalWithdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),TotalDepositsVolumeUsd:w.nullish(),TotalWithdrawalsVolumeUsd:w.nullish(),PerCurrency:z.record(z.string(),Iu).nullish()}).passthrough(),ku=z.object({NetworkID:z.string().nullish(),ItemCatalogID:z.string().nullish(),Deposits:z.number().nullish(),Withdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),FirstDepositAt:a.nullish(),LastDepositAt:a.nullish(),FirstWithdrawalAt:a.nullish(),LastWithdrawalAt:a.nullish()}).passthrough(),Au=z.object({TotalDeposits:z.number().nullish(),TotalWithdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),PerCollection:z.record(z.string(),ku).nullish()}).passthrough(),Ou=z.object({Tokens:Mu.nullish(),Nfts:Au.nullish()}).passthrough(),Uu=z.object({CurrencyID:z.string().nullish(),Balance:w.nullish(),MinBalance:w.nullish()}).passthrough(),Bu=z.object({NetworkID:z.string().nullish(),Address:z.string().nullish(),CheckedAt:a.nullish(),LoggedInAt:a.nullish(),GatePassed:z.boolean().nullish(),GatedBalances:z.array(Uu).nullish()}).passthrough(),wu=z.object({Version:z.number().nullish(),Stats:Ou.nullish(),LinkedWallets:z.record(z.string(),Tu).nullish(),LastWalletLogin:Bu.nullish(),PendingWithdrawals:z.array(pn).nullish(),Kyc:Pu.nullish(),FirstActivityAt:a.nullish(),LastActivityAt:a.nullish(),IsFlagged:z.boolean().nullish(),FlagReason:z.string().nullish()}).passthrough(),qu=z.object({CurrencyID:z.string(),AmountDelta:w,FrozenDelta:w,UpdatedAt:a}).passthrough(),gs=z.object({CryptoBalances:z.record(z.string(),qu).nullish(),PendingAdded:pn.nullish(),PendingRemovedIDs:z.array(z.string()).nullish()}).passthrough(),Eu=z.object({Amount:w,Frozen:w,CreatedAt:a.nullish(),UpdatedAt:a.nullish()}).passthrough().transform(c=>c),Lu=z.object({ID:z.string().nullish(),TitleID:z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:z.string().nullish(),TransactionHash:z.string().nullish(),Nonce:z.string().nullish(),NetworkID:z.string().nullish(),ChainType:z.string().nullish(),ChainID:z.number().nullish(),Direction:un.nullish(),From:z.string().nullish(),To:z.string().nullish(),Amount:w.nullish(),Status:Gr.nullish(),SignatureData:z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:z.string().nullish(),Reason:z.string().nullish(),Category:z.string().nullish(),TokenID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountUsd:w.nullish(),NetPayoutAmount:w.nullish()}).passthrough(),Gu=z.object({ID:z.string().nullish(),TitleID:z.string().nullish(),CreatedAt:a.nullish(),UpdatedAt:a.nullish(),UserID:z.string().nullish(),TransactionHash:z.string().nullish(),Nonce:z.string().nullish(),NetworkID:z.string().nullish(),ChainType:z.string().nullish(),ChainID:z.number().nullish(),Direction:un.nullish(),From:z.string().nullish(),To:z.string().nullish(),Amount:w.nullish(),Status:Gr.nullish(),SignatureData:z.string().nullish(),CompletedAt:a.nullish(),ExpiresAt:a.nullish(),FailReason:z.string().nullish(),Reason:z.string().nullish(),Category:z.string().nullish(),NFTID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),SkinID:z.string().nullish()}).passthrough(),jr=z.object({TokenAddress:z.string().nullish(),WalletAddress:z.string().nullish(),Amount:z.string().nullish(),BurnAmount:z.string().nullish(),TokenId:z.string().nullish(),Nonce:z.string().nullish(),ContractAddress:z.string().nullish(),UserID:z.string().nullish(),TitleID:z.string().nullish(),Category:z.string().nullish(),Deadline:z.string().nullish(),Signature:z.string().nullish()}).passthrough(),Fr=z.object({Mint:z.string().nullish(),WalletAddress:z.string().nullish(),Amount:z.string().nullish(),Nonce:z.string().nullish(),ExpiresAt:z.string().nullish(),ProgramID:z.string().nullish(),SignatureHex:z.string().nullish(),SigIxIndex:z.number().nullish(),Ed25519PublicKey:z.string().nullish(),Ed25519Message:z.string().nullish(),UserID:z.string().nullish()}).passthrough(),dn=z.object({Blockchain:Nr.nullish(),CryptoCurrencies:z.record(z.string(),Br).nullish()}).passthrough(),mn=z.object({State:wu.nullish(),CryptoBalances:z.record(z.string(),Eu).nullish()}).passthrough(),hn=z.object({ServerTimeUtc:a.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),StateDelta:gs.nullish()}).passthrough(),fn=z.object({ServerTimeUtc:a.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),NftTokenID:z.string().nullish(),Amount:z.number().nullish(),Resources:S.nullish(),Inventory:Ze.nullish()}).passthrough(),Rn=z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:w.nullish(),NetAmountNative:w.nullish(),BurnAmountNative:w.nullish(),AmountUsd:w.nullish(),ExpiresAt:a.nullish(),EvmSignature:jr.nullish(),SolanaSignature:Fr.nullish(),StateDelta:gs.nullish()}).passthrough(),gn=z.object({ServerTimeUtc:a.nullish(),TitleTransactionID:z.string().nullish(),NetworkID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),NftTokenID:z.string().nullish(),Amount:z.number().nullish(),ExpiresAt:a.nullish(),Resources:S.nullish(),EvmSignature:jr.nullish(),SolanaSignature:Fr.nullish(),StateDelta:gs.nullish(),Inventory:Ze.nullish()}).passthrough(),yn=z.object({TokenTransactions:z.array(Lu).nullish(),NFTTransactions:z.array(Gu).nullish()}).passthrough(),_r=z.object({ServerTimeUtc:a.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:w.nullish(),AmountUsd:w.nullish(),Target:z.string().nullish()}).passthrough(),Cn=z.object({TitleTransactionID:z.string().nullish(),Kind:an.nullish(),EvmSignature:jr.nullish(),SolanaSignature:Fr.nullish()}).passthrough(),Sn=z.object({TitleTransactionID:z.string().nullish(),OnChainTxHash:z.string().nullish(),Status:Gr.nullish(),StateDelta:gs.nullish()}).passthrough(),ve={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Nu="Blockchain",ys=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(Nu,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Mt(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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);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,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.CurrencyID=e,u.NetworkID=t,u.WalletAddress=s,u.Amount=r,u.Category=Rs(i);let m=await this.ctx.api.blockchain.requestTokenWithdrawal(u);return m.ok&&m.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(m.data.CurrencyID,new Mt(m.data.AmountNative??0).negated(),m.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",m.data)),m}async requestNFTWithdrawal(e,t,s,r,i,u,m){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.NetworkID=t,z.WalletAddress=s,z.Amount=r,z.Category=Rs(i),u!==void 0&&(z.Level=u),m&&(z.ItemInstanceID=m);let B=await this.ctx.api.blockchain.requestNFTWithdrawal(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",B.data)),B}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}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 s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var ju=z.object({ExperimentID:z.string().nullish(),Variants:z.array(z.string()).nullish()}).passthrough(),H=z.object({Segments:z.array(z.string()).nullish(),MinPremiumTier:z.number().nullish(),RequiredPremiumIDs:z.array(z.string()).nullish(),MinLevel:z.number().nullish(),MaxLevel:z.number().nullish(),Countries:z.array(z.string()).nullish(),RegisteredWithinDays:z.number().nullish(),ActiveWithinDays:z.number().nullish(),Experiment:ju.nullish()}).passthrough();var ue=z.object({TotalCap:z.number().nullish(),DailyCap:z.number().nullish(),DailyWeightCap:z.number().nullish(),PerActivationCap:z.number().nullish(),CooldownSeconds:z.number().nullish(),MaxPerWindow:z.number().nullish(),WindowSeconds:z.number().nullish()}).passthrough();var Fu=z.object({OffsetSecondsFromParentStart:z.number().nullish(),DurationSeconds:z.number().nullish(),AllowEarningAfterEnd:z.boolean().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),_u=z.object({StartUtc:z.string().nullish(),EndUtc:z.string().nullish(),AllowEarningAfterEnd:z.boolean().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),Wu=z.object({AnchorUtc:z.string().nullish(),MaxCycles:z.number().nullish(),PauseBetweenPhasesSec:z.number().nullish(),PauseBetweenCyclesSec:z.number().nullish()}).passthrough();z.object({PhaseID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough();var Vu=z.object({Reset:z.string().nullish(),IntervalSeconds:z.number().nullish(),AnchorUtc:z.string().nullish(),PauseBetweenCyclesSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough();z.object({SourceType:z.string().nullish(),TileType:z.string().nullish(),TileIndex:z.number().nullish(),ChanceOutcomeID:z.string().nullish(),Outcome:z.string().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough();var et=z.object({SourceType:z.string().nullish(),BaseWeight:z.number().nullish(),ScaleWithRollMultiplier:z.boolean().nullish(),TileTypeFilter:z.array(z.string()).nullish(),TileIndexFilter:z.array(z.number()).nullish(),ChanceOutcomeFilter:z.array(z.string()).nullish(),OutcomeFilter:z.array(z.string()).nullish(),Params:z.record(z.string(),z.string()).nullish(),Limits:ue.nullish()}).passthrough(),le=z.object({Mode:z.string().nullish(),IsActive:z.boolean().nullish(),Scheduled:_u.nullish(),Chain:Wu.nullish(),Cyclic:Vu.nullish(),ActivationTriggers:z.array(et).nullish(),Relative:Fu.nullish()}).passthrough();var ge=z.object({Username:z.string().nullish(),Country:z.string().nullish(),AvatarUrl:z.string().nullish(),Premium:z.boolean().nullish(),Level:z.number().nullish(),Power:z.number().nullish(),BoardRank:z.number().nullish()}).passthrough();var Qu={Head:"Head",Torso:"Torso",Legs:"Legs"},Cs=z.enum(["Head","Torso","Legs"]),Hu={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},Wr=z.enum(["Open","InProgress","Cancelled","Completed"]),bn=z.object({AttackTarget:Cs,DefenseTarget:Cs});var $u=z.enum(["Hit","Critical","Block","Dodge"]),Ku=z.object({RoundIndex:z.number().nullish(),AttackerID:z.string().nullish(),DefenderID:z.string().nullish(),AttackZone:Cs.nullish(),DefenseZone:Cs.nullish(),HitType:$u.nullish(),DamageDealt:z.number().nullish(),DefenderHpRemaining:z.number().nullish()}).passthrough(),Zu=z.object({MaxHp:z.number().nullish(),CurrentHp:z.number().nullish(),Damage:z.number().nullish(),AttackSpeed:z.number().nullish(),CritChance:z.number().nullish(),CritMultiplier:z.number().nullish(),Armor:z.number().nullish(),DodgeChance:z.number().nullish()}).passthrough(),Ju=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),CustomData:z.string().nullish()}).passthrough().transform(c=>c),Dn=z.object({UserID:z.string().nullish(),SelectedCharacterID:z.string().nullish(),SelectedCharacter:wr.nullish(),BattleStrategy:z.array(bn).nullish(),UnstackableItems:z.record(z.string(),Ju).nullish(),Stats:Zu.nullish()}).passthrough(),Yu=z.object({WinnerUserID:z.string().nullish(),LoserUserID:z.string().nullish(),Entry:ne.nullish(),NetReward:ne.nullish(),BattleLog:z.array(Ku).nullish(),IsDraw:z.boolean().nullish(),P1BattleProfile:Dn.nullish(),P2BattleProfile:Dn.nullish()}).passthrough(),zn=z.object({MatchID:z.string(),TitleID:z.string().nullish(),RuleID:z.string().nullish(),CreatedAt:a.nullish(),CreatorID:z.string().nullish(),CreatorCharacterID:z.string().nullish(),CreatorStrategy:z.array(bn).nullish(),TargetUserID:z.string().nullish(),Entry:ne.nullish(),CreationCostPaid:ne.nullish(),RefundCreationCostOnCancel:z.boolean().nullish(),JoinedByUserID:z.string().nullish(),JoinedByCharacterID:z.string().nullish(),JoinedAt:a.nullish(),Status:Wr.nullish(),WinnerUserID:z.string().nullish(),CompletedAt:a.nullish(),IsRewardDistributed:z.boolean().nullish(),RewardDistributedAt:a.nullish()}).passthrough(),vn=z.object({Status:Wr,MatchID:z.string(),Entry:ne.nullish(),Resources:S.nullish()}),Tn=z.object({Match:zn.nullish()}),Pn=z.object({MatchID:z.string(),Status:Wr,Resources:S.nullish()}),In=z.object({Battle:Yu.nullish(),Resources:S.nullish(),ResourcesDual:Xe.nullish()}),Vr=z.object({Matches:z.array(zn).nullish(),Page:z.number().nullish(),PageSize:z.number().nullish(),HasMore:z.boolean().nullish()}),Ne={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Xu=z.enum(["VirtualCurrency","Item","EventToken"]);var ec=z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),tc=z.object({HealthStatID:z.string().nullish(),DamageStatID:z.string().nullish(),ArmorStatID:z.string().nullish(),AttackSpeedStatID:z.string().nullish(),CritChanceStatID:z.string().nullish(),CritDamageStatID:z.string().nullish(),DodgeStatID:z.string().nullish(),AllMightStatID:z.string().nullish()}).passthrough(),sc=z.object({MaxRounds:z.number().nullish(),BlockDamageMultiplier:z.number().nullish(),MinHitDamage:z.number().nullish(),DefaultCritMultiplier:z.number().nullish(),MaxCritChance:z.number().nullish(),MaxDodgeChance:z.number().nullish()}).passthrough(),rc=z.object({Source:ec.nullish(),StatID:z.string().nullish(),Value:z.number().nullish(),OnePlus:z.boolean().nullish()}).passthrough(),ic=z.object({Coefficient:z.number().nullish(),Factors:z.array(rc).nullish()}).passthrough(),tt=z.object({Terms:z.array(ic).nullish()}).passthrough(),nc=z.object({Health:tt.nullish(),Damage:tt.nullish(),Armor:tt.nullish(),AttackSpeed:tt.nullish(),CritChance:tt.nullish(),CritDamage:tt.nullish(),Dodge:tt.nullish()}).passthrough(),Mn=z.object({StatMapping:tc.nullish(),Combat:sc.nullish(),Formula:nc.nullish()}).passthrough(),oc=z.object({BurnRate:z.number().nullish()}).passthrough(),Qr=z.object({Kind:Xu.nullish(),CurrencyID:z.string().nullish(),CatalogID:z.string().nullish(),ItemID:z.string().nullish(),TokenType:wt.nullish(),EntityID:z.string().nullish(),MinAmount:z.number().nullish(),MaxAmount:z.number().nullish()}).passthrough(),kn=z.object({AllowVirtualCurrency:z.boolean().nullish(),AllowItems:z.boolean().nullish(),AllowEventTokens:z.boolean().nullish(),Allowed:z.array(Qr).nullish(),MaxPositions:z.number().nullish()}).passthrough(),An=z.object({Cost:Q.nullish(),RefundCostOnCancel:z.boolean().nullish(),MaxOpenMatches:z.number().nullish(),Limits:ue.nullish(),AllowPrivateMatches:z.boolean().nullish(),MaxMatchesPerOpponentPerDay:z.number().nullish()}).passthrough(),ac=z.object({RuleID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),Economy:oc.nullish(),Entry:kn.nullish(),Creation:An.nullish(),Settings:Mn.nullish()}).passthrough(),lc=z.object({Rules:z.record(z.string(),ac).nullish(),Defaults:Mn.nullish(),EntryDefaults:kn.nullish(),CreationDefaults:An.nullish()}).passthrough(),Hr=z.object({InstantBattle:lc.nullish()}).passthrough(),On=Hr;var uc={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},$r=z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),cc={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},Kr=z.enum(["Active","Completed","Cancelled","Declined","Expired"]),pc={Burn:"Burn",Ledger:"Ledger"},dc=z.enum(["Burn","Ledger"]),xs={Item:"Item",VirtualCurrency:"VirtualCurrency"},Zr=z.enum(["Item","VirtualCurrency"]),mc=z.object({Percent:z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),hc=z.object({AllowVirtualCurrency:z.boolean().nullish(),AllowItems:z.boolean().nullish(),AllowEventTokens:z.boolean().nullish(),Allowed:z.array(Qr).nullish(),MaxPositions:z.number().nullish()}).passthrough(),fc=z.object({Percent:z.number().nullish(),MinPerPosition:M.nullish(),Sink:dc.nullish(),LedgerAccountID:z.string().nullish(),PerCatalogOverrides:z.record(z.string(),mc).nullish(),ApplyToDirectTrades:z.boolean().nullish()}).passthrough(),Rc=z.object({AllowedCatalogIDs:z.array(z.string()).nullish(),DeniedCatalogIDs:z.array(z.string()).nullish(),DeniedItemIDs:z.array(z.string()).nullish(),AllowUnstackableWithState:z.boolean().nullish()}).passthrough(),gc=z.object({Enabled:z.boolean().nullish(),AllowedDurationsHours:z.array(z.number()).nullish(),MaxActiveListings:z.number().nullish(),CreateLimits:ue.nullish(),BuyLimits:ue.nullish(),ListingFee:Q.nullish(),RefundListingFeeOnCancel:z.boolean().nullish()}).passthrough(),yc=z.object({Enabled:z.boolean().nullish(),MinDurationHours:z.number().nullish(),MaxDurationHours:z.number().nullish(),AntiSnipeWindowSeconds:z.number().nullish(),AntiSnipeExtensionSeconds:z.number().nullish(),MaxAntiSnipeExtensions:z.number().nullish(),MinBidStepPercent:z.number().nullish(),MinBidStepAbsolute:M.nullish(),BidLimits:ue.nullish()}).passthrough(),Cc=z.object({Enabled:z.boolean().nullish(),MaxActiveOrders:z.number().nullish(),AllowedDurationsHours:z.array(z.number()).nullish(),CreateLimits:ue.nullish(),FillLimits:ue.nullish()}).passthrough(),Sc=z.object({Enabled:z.boolean().nullish(),OfferExpirationHours:z.number().nullish(),MaxPendingOutgoing:z.number().nullish(),AllowGifts:z.boolean().nullish(),CreateLimits:ue.nullish()}).passthrough(),xc=z.object({Enabled:z.boolean().nullish()}).passthrough(),Jr=z.object({Enabled:z.boolean().nullish(),Gate:H.nullish(),Schedule:le.nullish(),PricePolicy:hc.nullish(),Commission:fc.nullish(),Tradability:Rc.nullish(),Listings:gc.nullish(),Auctions:yc.nullish(),BuyOrders:Cc.nullish(),DirectTrades:Sc.nullish(),Matching:xc.nullish()}).passthrough(),Un=z.object({BidIndex:z.number().nullish(),UserID:z.string().nullish(),Amount:M.nullish(),Settled:z.boolean().nullish(),SettledAt:a.nullish()}).passthrough(),Dc=z.object({BidAxisType:Bt.nullish(),BidCurrencyID:z.string().nullish(),BidCatalogID:z.string().nullish(),BidItemID:z.string().nullish(),StartingBid:M.nullish(),CurrentBid:M.nullish(),CurrentBidderID:z.string().nullish(),BidCount:z.number().nullish(),ExtensionCount:z.number().nullish(),PendingRefunds:z.array(Un).nullish()}).passthrough(),Ss=z.object({LastAt:a.nullish(),DailyCount:z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),bc=z.object({Create:Ss.nullish(),Buy:Ss.nullish(),Sell:Ss.nullish(),Bid:Ss.nullish()}).passthrough(),zc=z.object({CharacterID:z.string().nullish(),SlotID:z.string().nullish()}).passthrough(),vc=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:a,ExpiresAt:a.nullish(),EquippedSlot:zc.nullish(),CustomData:z.string().nullish()}).passthrough().transform(c=>c),Ve=z.object({OfferID:z.string().nullish(),OfferType:$r.nullish(),Status:Kr.nullish(),CreatorUserID:z.string().nullish(),CreatorPublicData:ge.nullish(),TargetUserID:z.string().nullish(),GoodsType:Zr.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:z.array(vc).nullish(),Price:ne.nullish(),Auction:Dc.nullish(),CreatedAt:a.nullish(),ExpiresAt:a.nullish()}).passthrough(),Tc=z.object({GoodsType:Zr.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),CountsByType:z.record($r,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),Bn=z.object({Definitions:Jr.nullish(),IsOpenNow:z.boolean().nullish(),GatePassed:z.boolean().nullish()}).passthrough(),Yr=z.object({Offers:z.array(Ve).nullish(),ContinuationToken:z.string().nullish()}).passthrough(),wn=z.object({Groups:z.array(Tc).nullish()}).passthrough(),qn=z.object({Offer:Ve.nullish()}).passthrough(),ke=z.object({OfferID:z.string().nullish(),Status:Kr.nullish(),Settlement:Xe.nullish(),Resources:S.nullish(),CommissionTaken:ne.nullish()}).passthrough(),St=z.object({OfferID:z.string().nullish(),Offer:Ve.nullish(),Resources:S.nullish(),Matched:z.boolean().nullish(),Settlement:ke.nullish()}).passthrough(),En=z.object({OfferID:z.string().nullish(),CurrentBid:M.nullish(),BidCount:z.number().nullish(),ExpiresAt:a.nullish(),Resources:S.nullish()}).passthrough(),Ln=z.object({MyOffers:z.array(Ve).nullish(),MyLeadingBids:z.array(Ve).nullish(),MyBuyOrders:z.array(Ve).nullish(),IncomingTrades:z.array(Ve).nullish(),OutgoingTrades:z.array(Ve).nullish(),Claimables:z.array(Ve).nullish(),DrainedRefunds:z.array(Un).nullish(),Limits:bc.nullish()}).passthrough(),Pc=z.object({OfferID:z.string().nullish(),OfferType:$r.nullish(),FinalStatus:Kr.nullish(),SellerUserID:z.string().nullish(),BuyerUserID:z.string().nullish(),GoodsType:Zr.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:ne.nullish(),CommissionTaken:ne.nullish(),CompletedAt:a.nullish()}).passthrough(),Gn=z.object({Entries:z.array(Pc).nullish(),ContinuationToken:z.string().nullish()}).passthrough(),te={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 Ic="Marketplace",Ds=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(Ic,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,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let u=await this.ctx.api.marketplace.getOffersByItem(i);return u.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",u.data),u}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 s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,u){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 m=this.baseRequest();if(!m)return n("unauthorized","Not logged in.");m.ItemID=e,m.CatalogID=t,m.GoodsAmount=s,m.PriceBundle=r,m.DurationHours=i,m.ItemInstanceIDs=u;let z=await this.ctx.api.marketplace.createListing(m);return this.applyCreateOfferResult(z,"marketplace:listingCreated"),z}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 s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let u=await this.ctx.api.marketplace.marketBuy(r);return u.ok&&(this.applyDualPartySettlement(u.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",u.data)),u}async marketSell(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let u=await this.ctx.api.marketplace.marketSell(r);return u.ok&&(this.applyDualPartySettlement(u.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",u.data)),u}async createAuction(e,t,s,r,i,u,m={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.CatalogID=t,z.GoodsAmount=s,z.BidAxisType=r,z.BidCurrencyID=m.bidCurrencyID,z.BidCatalogID=m.bidCatalogID,z.BidItemID=m.bidItemID,z.StartingBid=i,z.DurationHours=u,z.ItemInstanceIDs=m.itemInstanceIDs;let B=await this.ctx.api.marketplace.createAuction(z);return this.applyCreateOfferResult(B,"marketplace:auctionCreated"),B}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);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 s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){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 u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.ItemID=e,u.CatalogID=t,u.GoodsAmount=s,u.PriceBundle=r,u.DurationHours=i;let m=await this.ctx.api.marketplace.createBuyOrder(u);return this.applyCreateOfferResult(m,"marketplace:buyOrderCreated"),m}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 s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let u=this.baseRequest();if(!u)return n("unauthorized","Not logged in.");u.TargetUserID=e,u.CatalogID=t,u.ItemID=s,u.ItemInstanceIDs=r,u.RequestedBundle=i;let m=await this.ctx.api.marketplace.createDirectTrade(u);return this.applyCreateOfferResult(m,"marketplace:directTradeCreated"),m}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);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 s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}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=xs.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=xs.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 s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bs=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);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 s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);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 s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}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 s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let u=await this.ctx.api.multiplayer.sendSignal(i);return u.ok&&this.ctx.emitter.emit("multiplayer:signalSent",u.data),u}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){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=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Nn=z.object({PlatformUserID:z.string().nullish(),PlatformAuthToken:z.string().nullish(),PlatformAuthTokenExpiration:a.nullish(),TitleUserID:z.string(),TitleClientSessionTicket:z.string(),TitleClientSessionTicketExpiration:a}),ye=z.object({IsCompleted:z.boolean().nullish(),ServerTime:a.nullish()}),jn=z.object({Message:z.string(),ExpiresAt:a}),Ae={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function O(c,e,t,s){let i=`api/v2/${c&&c.length>0?c:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var zs=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return O(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,Nn,{ticket:null})}loginWithDeviceID(e){return this.login(Ae.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ae.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ae.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ae.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ae.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Ae.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ae.RequestWalletChallenge),e,jn,{ticket:null})}loginWithWallet(e){return this.login(Ae.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ae.ForgotPassword),e,ye,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ae.ResetPassword),e,ye,{ticket:null})}};var Xr=z.object({Title:z.unknown().nullish(),User:z.unknown().nullish()}).passthrough().transform(c=>c),Fn=z.object({}).passthrough().transform(c=>c),_n=z.object({}).passthrough().transform(c=>c),Wn=z.object({Today:z.number(),Yesterday:z.number(),CurrentWeek:z.number(),CurrentMonth:z.number(),Total:z.number(),TotalSessions:z.number(),FirstActiveAt:a.nullish(),LastActiveAt:a.nullish(),LongestSessionEverSeconds:z.number().nullish(),CurrentWeekActiveHoursMask:z.number().nullish(),CurrentMonthActiveHoursMask:z.number().nullish(),ReactivationCount:z.number().nullish(),History:z.record(z.string(),z.unknown()).nullish()}).passthrough(),Vn=z.object({Username:z.string()}),je={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var vs=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return O(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(je.GetClientState,e.UserID),e,Xr,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(je.GetClientStateExcept,e.UserID),e,Xr,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(je.GetInventory,e.UserID),e,Fn,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(je.GetEventTokens,e.UserID),e,_n,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(je.GetUsageTime,e.UserID),e,Wn,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(je.AddUsageTime,e.UserID),e,ye,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(je.DeleteUserAccount,e.UserID),e,ye,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(je.ChangeUsername,e.UserID),e,Vn,{ticket:e.ClientSessionTicket})}};var Ts=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(ps.Convert,e,_i)}cryptoConvert(e){return this.send(ps.CryptoConvert,e,Wi)}};var Mc=z.object({ItemInstanceID:z.string(),Units:z.number(),Level:z.number()}),ei=z.object({ServerTimeUtc:a,ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Level:z.number(),Resources:S.nullish(),FodderConsumed:z.array(Mc).nullish()}),Qn=z.array(ee(ei)),Ps={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},kc={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Ac=z.enum(["FlatCount","Merge","InvestmentRefund"]),Oc={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},Uc=z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Bc=z.object({ContractAddress:z.string().nullish(),TokenID:z.string().nullish(),TokenStandard:z.string().nullish()}).passthrough(),wc=z.object({Networks:z.record(z.string(),Bc).nullish(),MetadataUrl:z.string().nullish()}).passthrough(),qc=z.object({FlatBonuses:z.record(z.string(),z.number()).nullish(),PercentBonuses:z.record(z.string(),z.number()).nullish(),Power:z.number().nullish()}).passthrough(),Ec=z.object({MinCharacterLevel:z.number().nullish(),UseRequirements:z.record(z.string(),z.number()).nullish(),AllowedCharacterIDs:z.array(z.string()).nullish(),AllowedSlotIDs:z.array(z.string()).nullish()}).passthrough(),Lc=z.object({ValuationMode:Ac.nullish(),MergeRatio:z.number().nullish(),Selection:Uc.nullish()}).passthrough(),Gc=z.object({MaxLevel:z.number().nullish(),BaseCostResource:Q.nullish(),CostScalingFactor:z.number().nullish(),FlatScalingFactor:z.number().nullish(),PercentScalingFactor:z.number().nullish(),PowerScalingFactor:z.number().nullish(),Fodder:Lc.nullish()}).passthrough(),Nc=z.object({RarityID:z.string().nullish(),CollectionID:z.string().nullish(),AuthorID:z.string().nullish()}).passthrough(),jc=z.object({ItemID:z.string(),CatalogID:z.string(),ItemClass:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),Tags:z.array(z.string()).nullish(),CustomData:z.string().nullish(),IsStackable:z.boolean().nullish(),IsTradable:z.boolean().nullish(),Weight:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),NFT:wc.nullish(),Stats:qc.nullish(),Equipment:Ec.nullish(),Upgrade:Gc.nullish(),Metadata:Nc.nullish(),ExpirationDurationSeconds:z.number().nullish()}).passthrough(),Fc=z.object({Items:z.record(z.string(),jc).nullish()}).passthrough(),Is=z.object({Catalogs:z.record(z.string(),Fc).nullish()}).passthrough();var Ms=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=O(this.ctx.settings.titleID,"Item",Ps.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,ei,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=O(this.ctx.settings.titleID,"Item",Ps.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,Qn,{ticket:e.ClientSessionTicket})}};var ti=z.object({ServerTimeUtc:a,OfferID:z.string(),Count:z.number(),Resources:S.nullish()}),Hn=z.array(ee(ti)),_c=z.object({OfferID:z.string(),TotalPurchases:z.number(),DailyPurchases:z.number(),DailyResetUtc:a,LastPurchasedAt:a}),$n=z.object({Purchases:z.record(z.string(),_c).nullish()}).passthrough().transform(c=>c),Wc=z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),RequiredFlags:z.array(z.string()).nullish()}).passthrough(),Vc=z.object({StoreID:z.string(),Type:z.string().nullish(),Name:z.string().nullish(),Description:z.string().nullish(),Rules:Wc.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),Qc=z.object({StartUtc:a.nullish(),EndUtc:a.nullish(),Gate:H.nullish(),Limits:ue.nullish()}).passthrough(),Hc=z.object({OfferID:z.string(),StoreIDs:z.array(z.string()).nullish(),Name:z.string().nullish(),Cost:Q.nullish(),Rewards:L.nullish(),Rules:Qc.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),ks=z.object({Stores:z.record(z.string(),Vc).nullish(),StoreOffers:z.record(z.string(),Hc).nullish()}).passthrough(),ut={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var As=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(ut.Purchase,e,ti)}purchaseBatch(e){return this.send(ut.PurchaseBatch,e,Hn)}getDefinitions(e){return this.send(ut.GetDefinitions,e,ks)}getUserState(e){return this.send(ut.GetUserState,e,$n)}};var $c=z.object({Min:z.number().nullish(),Max:z.number().nullish()}).passthrough(),Kn=z.object({Reward:L.nullish(),Weight:z.number().nullish(),AmountRange:$c.nullish()}).passthrough(),ct=z.object({SlotID:z.string().nullish(),MinRolls:z.number().nullish(),MaxRolls:z.number().nullish(),Pool:z.array(Kn).nullish()}).passthrough(),pt=z.object({RuleID:z.string().nullish(),Threshold:z.number().nullish(),Pool:z.array(Kn).nullish()}).passthrough(),Kc=z.object({RewardSlots:z.array(ct).nullish()}).passthrough(),Zc=z.object({PityRules:z.array(pt).nullish()}).passthrough(),Os=z.object({SlotPresets:z.record(z.string(),Kc).nullish(),PityPresets:z.record(z.string(),Zc).nullish()}).passthrough();var Jc=z.object({SeasonChainID:z.string().nullish(),MinSeasonTier:z.number().nullish(),Rewards:L.nullish()}).passthrough(),Yc=z.object({SeasonChainID:z.string().nullish(),MinSeasonTier:z.number().nullish(),Multiplier:z.number().nullish()}).passthrough(),si=z.object({Bundles:z.array(Jc).nullish(),Multipliers:z.array(Yc).nullish()}).passthrough();var Xc=z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var ep=z.enum(["Tiered","Linear"]);var tp=z.enum(["Step","Linear"]),sp=z.object({AtProgress:z.number().nullish(),Multiplier:z.number().nullish()}).passthrough(),Us=z.object({Source:Xc.nullish(),SourceKey:z.string().nullish(),CurveType:ep.nullish(),Tiers:z.array(sp).nullish(),TierMode:tp.nullish(),BaseMultiplier:z.number().nullish(),PerUnit:z.number().nullish(),Anchor:z.number().nullish(),MinMultiplier:z.number().nullish(),MaxMultiplier:z.number().nullish(),IncludeRewards:ne.nullish(),ExcludeRewards:ne.nullish()}).passthrough(),Se=z.object({MilestoneID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),RequiredProgress:z.number().nullish(),Rewards:L.nullish(),BonusRewards:L.nullish(),SeasonTierRewards:si.nullish(),SortOrder:z.number().nullish(),IsFeatured:z.boolean().nullish()}).passthrough(),dt=z.object({Milestones:z.record(z.string(),Se).nullish()}).passthrough();var rp=z.object({RuleID:z.string(),BoxIndex:z.number().nullish()}),Zn=z.object({ServerTimeUtc:a,LootboxID:z.string(),OpenedCount:z.number().nullish(),SelectedOptionID:z.number().nullish(),Resources:S.nullish(),Inventory:Ze.nullish(),Results:z.array(S).nullish(),TriggeredPity:z.array(rp).nullish()}),ip=z.object({PriceOptionID:z.number().nullish(),RequiredResources:Q.nullish()}).passthrough(),np=z.object({RewardSlots:me.nullish(),PityRules:me.nullish()}).passthrough(),op=z.object({CatalogID:z.string().nullish(),ItemID:z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),ap=z.object({LootboxID:z.string(),AssetPaths:z.record(z.string(),z.string()).nullish(),PriceOptions:z.record(z.string(),ip).nullish(),RewardSlots:z.array(ct).nullish(),PityRules:z.array(pt).nullish(),Presets:np.nullish(),RewardMultiplier:Us.nullish(),SupplyLimits:z.array(op).nullish()}).passthrough(),ri=z.object({Definitions:z.record(z.string(),ap).nullish(),RewardPools:Os.nullish()}).passthrough(),Jn=z.object({LootboxDefinitions:ri.nullish()}),Bs={GetDefinitions:"GetDefinitions",Open:"Open"};var ws=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Bs.GetDefinitions,e,Jn)}open(e){return this.send(Bs.Open,e,Zn)}};var lp=z.object({}).passthrough().transform(c=>c),up=z.object({}).passthrough().transform(c=>c),cp=z.object({}).passthrough().transform(c=>c),pp=z.object({}).passthrough().transform(c=>c),dp=z.object({}).passthrough().transform(c=>c),Yn=z.object({ServerTimeUtc:a,CalendarID:z.string(),DayNumber:z.number().nullish(),DailyState:lp,Resources:S.nullish()}),Xn=z.object({ServerTimeUtc:a,AccrualID:z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:z.number().nullish(),IdleState:up,Resources:S.nullish()}),eo=z.object({ServerTimeUtc:a,ComebackID:z.string(),ClaimedTierIndex:z.number().nullish(),ComebackState:cp,Resources:S.nullish()}),to=z.object({ServerTimeUtc:a,ClaimID:z.string(),ClaimState:pp,Resources:S.nullish()}),so=z.object({Enabled:z.boolean(),Multiplier:z.number().nullish(),Progress:M.nullish(),Source:z.string().nullish(),SourceKey:z.string().nullish()}),mp=z.object({RewardMode:z.string().nullish(),RewardStackLowerTiers:z.boolean().nullish()}).passthrough(),hp=z.object({DayNumber:z.number().nullish(),Rewards:L.nullish(),IsMilestone:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),fp=z.object({CalendarID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Days:z.array(hp).nullish(),IsLooping:z.boolean().nullish(),MissBehavior:z.string().nullish(),ResetByDays:z.number().nullish(),MissThresholdMultiplier:z.number().nullish(),ClaimMode:z.string().nullish(),ClaimCooldownSeconds:z.number().nullish(),Gate:H.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),Rp=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),Multiplier:z.number().nullish()}).passthrough(),gp=z.object({BaseRatePerSecond:z.number().nullish(),PowerCoefficient:z.number().nullish(),BoardRankCoefficient:z.number().nullish(),EquipmentBonusEnabled:z.boolean().nullish(),EquipmentCharacterID:z.string().nullish(),PremiumMultipliers:z.array(Rp).nullish()}).passthrough(),yp=z.object({MinCharacterLevel:z.number().nullish(),RequirementsCharacterID:z.string().nullish(),Gate:H.nullish(),RequiredItemIDs:z.array(z.string()).nullish(),RequiredEquippedItemIDs:z.array(z.string()).nullish()}).passthrough(),Cp=z.object({AccrualID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rate:gp.nullish(),Rewards:L.nullish(),MaxAccumulationSeconds:z.number().nullish(),MinClaimSeconds:z.number().nullish(),Requirements:yp.nullish(),FirstClaimMode:z.string().nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),Sp=z.object({MinAbsenceSeconds:z.number().nullish(),Rewards:L.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),xp=z.object({ComebackID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tiers:z.array(Sp).nullish(),ClaimCooldownSeconds:z.number().nullish(),ClaimWindowSeconds:z.number().nullish(),TrackPresenceOnRead:z.boolean().nullish(),Gate:H.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),Dp=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),CooldownSeconds:z.number().nullish(),MaxClaimsPerWindow:z.number().nullish(),WindowSeconds:z.number().nullish(),TotalClaimLimit:z.number().nullish()}).passthrough(),bp=z.object({ClaimID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Mode:z.string().nullish(),Rewards:L.nullish(),Limits:ue.nullish(),PremiumLimitOverrides:z.array(Dp).nullish(),Gate:H.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),ii=z.object({TierRewards:mp.nullish(),MilestoneRewardMultiplier:Us.nullish(),DailyCalendars:z.record(z.string(),fp).nullish(),IdleAccruals:z.record(z.string(),Cp).nullish(),Comebacks:z.record(z.string(),xp).nullish(),Claims:z.record(z.string(),bp).nullish()}).passthrough(),ro=z.object({RewardDefinitions:ii.nullish()}),io=z.object({Rewards:dp.nullish()}),He={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(He.GetRewardDefinitions,e,ro)}getUserRewardsState(e){return this.send(He.GetUserRewardsState,e,io)}getMilestoneRewardMultiplier(e){return this.send(He.GetMilestoneRewardMultiplier,e,so)}claimDailyReward(e){return this.send(He.ClaimDailyReward,e,Yn)}collectIdleAccrual(e){return this.send(He.CollectIdleAccrual,e,Xn)}claimComebackReward(e){return this.send(He.ClaimComebackReward,e,eo)}claimReward(e){return this.send(He.ClaimReward,e,to)}};var zp=z.object({TargetCurrencyID:z.string().nullish(),Rate:z.number().nullish(),MaxConvertAmount:z.number().nullish()}).passthrough(),mt=z.object({DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxBalance:z.number().nullish(),MaxPerGrant:z.number().nullish(),DailyEarnCap:z.number().nullish(),BurnOnEventEnd:z.boolean().nullish(),BurnConversion:zp.nullish()}).passthrough();var vp={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},no=z.enum(["Active","Completed","Claimed","Expired"]),Tp=z.object({}).passthrough().transform(c=>c),Pp=z.object({CycleID:z.string(),InstanceKey:z.string().nullish(),CycleStartUtc:a.nullish(),CycleEndUtc:a.nullish(),PointsTotalEarned:M.nullish(),PointsCurrent:M.nullish(),ClaimedPointMilestoneIDs:z.array(z.string()).nullish()}),Ip=z.object({QuestID:z.string(),CycleID:z.string().nullish(),ObjectiveID:z.string().nullish(),NewValue:M.nullish(),ObjectiveCompleted:z.boolean().nullish(),Status:no}),oo=z.object({State:Tp.nullish(),PointsTracks:z.record(z.string(),Pp).nullish()}),ni=z.object({ServerTimeUtc:a,QuestID:z.string(),CycleID:z.string().nullish(),NewStatus:no.nullish(),Resources:S.nullish()}),oi=z.object({ServerTimeUtc:a,CycleID:z.string(),MilestoneID:z.string(),PointsTotalEarned:M.nullish(),Resources:S.nullish()}),ao=z.object({ServerTimeUtc:a,CycleID:z.string(),GroupCompletionID:z.string(),GroupID:z.string().nullish(),CompletedGroupQuests:z.number().nullish(),RequiredGroupQuests:z.number().nullish(),Resources:S.nullish()}),lo=z.object({MetricID:z.string(),Updates:z.array(Ip).nullish()}),uo=z.array(ee(ni)),co=z.array(ee(oi)),Mp={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},kp=z.enum(["ClientApi","ServerApi","SystemEvent"]),Ap={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},Op=z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Up=z.object({ObjectiveID:z.string().nullish(),Source:kp.nullish(),MaxProgressPerCall:z.number().nullish(),MetricID:z.string().nullish(),TargetValue:z.number().nullish(),AggregationMethod:z.string().nullish(),Filters:z.record(z.string(),z.string()).nullish()}).passthrough(),Bp=z.object({QuestID:z.string().nullish(),CycleIDs:z.array(z.string()).nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),SortOrder:z.number().nullish(),RequiredQuestIDs:z.array(z.string()).nullish(),PrerequisiteMode:Op.nullish(),PointsReward:z.number().nullish(),Schedule:le.nullish(),AccrueProgressWhenLocked:z.boolean().nullish(),Gate:H.nullish(),Limits:ue.nullish(),GroupID:z.string().nullish(),Objectives:z.record(z.string(),Up).nullish(),Reward:L.nullish()}).passthrough(),wp=z.object({CompletionID:z.string().nullish(),GroupID:z.string().nullish(),RequiredCompletedQuests:z.number().nullish(),Gate:H.nullish(),Reward:L.nullish(),PointsReward:z.number().nullish()}).passthrough(),qp=z.object({CycleID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:le.nullish(),Milestones:z.record(z.string(),Se).nullish(),Gate:H.nullish(),PointsToken:mt.nullish(),GroupCompletions:z.record(z.string(),wp).nullish()}).passthrough(),Es=z.object({Cycles:z.record(z.string(),qp).nullish(),Quests:z.record(z.string(),Bp).nullish()}).passthrough(),Le={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var Ls=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Le.GetQuestDefinitions,e,Es)}getUserQuestState(e){return this.send(Le.GetUserQuestState,e,oo)}refreshQuestCycles(e){return this.send(Le.RefreshQuestCycles,e,ye)}claimQuestReward(e){return this.send(Le.ClaimQuestReward,e,ni)}claimQuestRewardsBatch(e){return this.send(Le.ClaimQuestRewardsBatch,e,uo)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,oi)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,co)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,ao)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,lo)}};var po=z.object({}).passthrough().transform(c=>c);var Ep=z.object({Order:z.number().nullish(),Type:z.string().nullish(),DurationSec:z.number().nullish(),BonusMultiplier:z.number().nullish()}).passthrough(),Lp=z.object({Schedule:z.array(Ep).nullish(),RepeatCycle:z.boolean().nullish(),MaxCycles:z.number().nullish()}).passthrough(),Gp=z.object({IsActive:z.boolean().nullish(),CurrentPhaseEndUtc:a.nullish(),NextBonusStartUtc:a.nullish(),CurrentCycleIndex:z.number().nullish(),CurrentPhaseIndex:z.number().nullish(),ActiveBonusMultiplier:z.number().nullish()}).passthrough(),Np=z.object({Milestones:me.nullish()}).passthrough(),ai=z.object({DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Category:z.string().nullish(),Token:mt.nullish(),TokenSources:z.array(et).nullish(),ClaimMode:z.string().nullish(),Milestones:z.record(z.string(),Se).nullish(),Presets:Np.nullish(),BonusWindow:Lp.nullish()}).passthrough(),jp=z.object({ChainedEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),Content:ai.nullish(),ClaimGraceHours:z.number().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Fp=z.object({TimedEventID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Schedule:le.nullish(),Content:ai.nullish(),Events:z.array(jp).nullish(),Gate:H.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),_p=z.object({MaxConcurrentEvents:z.number().nullish()}).passthrough(),Wp=z.object({Milestones:z.record(z.string(),dt).nullish()}).passthrough(),Gs=z.object({Definitions:z.record(z.string(),Fp).nullish(),Settings:_p.nullish(),Presets:Wp.nullish()}).passthrough(),Vp=z.object({Type:Ct,TimedEventID:z.string(),CurrentChainedEventID:z.string().nullish(),Content:ai.nullish(),Progress:po.nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),CanEarn:z.boolean().nullish(),CanClaim:z.boolean().nullish(),NextMilestone:Se.nullish(),BonusWindow:Gp.nullish(),CurrentCycleIndex:z.number().nullish(),CurrentEventOrder:z.number().nullish(),TotalEventsInChain:z.number().nullish()}).passthrough(),mo=z.object({ActiveEvents:z.array(Vp).nullish()}).passthrough(),ho=z.object({Tokens:z.record(z.string(),po).nullish()}),li=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),Resources:S.nullish()}),ui=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),MilestoneID:z.string().nullish(),Rewards:S.nullish()}),Qp=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),Resources:S.nullish()}),ci=z.array(ee(ui)),fo=z.array(ee(li)),Ro=z.array(ee(Qp)),Oe={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var Ns=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Oe.GetActiveEvents,e,mo)}getDefinitions(e){return this.send(Oe.GetDefinitions,e,Gs)}getUserLteState(e){return this.send(Oe.GetUserLteState,e,ho)}grantTokens(e){return this.send(Oe.GrantTokens,e,S)}spendTokens(e){return this.send(Oe.SpendTokens,e,li)}claimMilestone(e){return this.send(Oe.ClaimMilestone,e,ui)}claimMilestonesBatch(e){return this.send(Oe.ClaimMilestonesBatch,e,ci)}claimAllMilestones(e){return this.send(Oe.ClaimAllMilestones,e,ci)}spendTokensBatch(e){return this.send(Oe.SpendTokensBatch,e,fo)}grantTokensBatch(e){return this.send(Oe.GrantTokensBatch,e,Ro)}};var Hp=z.object({UserID:z.string(),Score:M.nullish(),Rank:z.number().nullish(),LastScoreUpdateUtc:a.nullish(),IpHash:z.string().nullish(),PublicProfile:ge.nullish(),SeasonTierAtCycleEnd:z.number().nullish()}).passthrough(),xt=z.object({LeaderboardID:z.string(),CycleVersion:z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:a.nullish(),TopUsers:z.array(Hp).nullish(),BracketID:z.string().nullish()}),$p=z.object({CycleKey:z.string().nullish(),CycleEndUtc:a.nullish(),ClaimDeadlineUtc:a.nullish(),MilestoneTokensEarned:M.nullish(),ClaimableMilestoneIDs:z.array(z.string()).nullish(),CycleIndex:z.number().nullish(),ChainedEventID:z.string().nullish()}).passthrough(),js=z.object({LeaderboardID:z.string(),CurrentScore:M.nullish(),LastKnownRank:z.number().nullish(),HasUnclaimedReward:z.boolean().nullish(),ScoreEarnedThisCycle:M.nullish(),MilestoneTokensEarned:M.nullish(),NextMilestone:Se.nullish(),HasUnclaimedMilestone:z.boolean().nullish(),ClaimableGraceCycles:z.array($p).nullish()}),Fs=z.object({LeaderboardID:z.string(),NewScore:M,CycleVersion:z.number()}),_s=z.object({ServerTimeUtc:a,LeaderboardID:z.string(),Rank:z.number().nullish(),Resources:S.nullish()}),Ws=z.object({ServerTimeUtc:a,LeaderboardID:z.string(),MilestoneID:z.string(),Resources:S.nullish()}),go=z.array(ee(xt)),yo=z.array(ee(js)),Co=z.array(ee(_s)),So=z.array(ee(Ws)),xo=z.array(ee(Fs)),Kp=z.object({LeaderboardID:z.string(),CycleReward:ee(_s).nullish(),Milestones:z.array(ee(Ws)).nullish()}),Do=z.array(Kp),Zp=z.object({LeaderboardID:z.string(),Leaderboard:ee(xt).nullish(),Progress:ee(js).nullish()}),bo=z.array(Zp),Jp=z.string(),zo=z.object({Rank:z.string().nullish(),Rewards:L.nullish(),SeasonTierRewards:si.nullish()}).passthrough(),Yp=z.object({RankRewards:z.array(zo).nullish()}).passthrough(),Xp=z.object({ChainedEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),ed=z.object({Milestones:me.nullish(),RankRewards:me.nullish()}).passthrough(),td=z.object({LeaderboardID:z.string(),DisplayName:z.string().nullish(),ScoreDisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),IsEnabled:z.boolean().nullish(),ScoreAggregation:Jp.nullish(),Schedule:le.nullish(),ChainEvents:z.array(Xp).nullish(),Gate:H.nullish(),TopUsersLimit:z.number().nullish(),MinScoreToEnterTop:z.number().nullish(),BracketSize:z.number().nullish(),LinkedSeasonChainID:z.string().nullish(),RankRewards:z.array(zo).nullish(),Milestones:z.record(z.string(),Se).nullish(),Presets:ed.nullish(),MilestoneClaimMode:z.string().nullish(),MilestoneClaimGraceHours:z.number().nullish(),ScoreSources:z.array(et).nullish()}).passthrough(),sd=z.object({Milestones:z.record(z.string(),dt).nullish(),RankRewards:z.record(z.string(),Yp).nullish()}).passthrough(),Vs=z.object({Definitions:z.record(z.string(),td).nullish(),Presets:sd.nullish()}).passthrough(),he={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 Qs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(he.GetDefinitions,e,Vs)}getLeaderboard(e){return this.send(he.GetLeaderboard,e,xt)}getMyProgress(e){return this.send(he.GetMyProgress,e,js)}submitScore(e){return this.send(he.SubmitScore,e,Fs)}submitScoreFromSource(e){return this.send(he.SubmitScoreFromSource,e,Fs)}claimCycleReward(e){return this.send(he.ClaimCycleReward,e,_s)}claimMilestone(e){return this.send(he.ClaimMilestone,e,Ws)}getFriendsLeaderboard(e){return this.send(he.GetFriendsLeaderboard,e,xt)}getLeaderboardsBatch(e){return this.send(he.GetLeaderboardsBatch,e,go)}getProgressBatch(e){return this.send(he.GetProgressBatch,e,yo)}claimCycleRewardsBatch(e){return this.send(he.ClaimCycleRewardsBatch,e,Co)}claimMilestonesBatch(e){return this.send(he.ClaimMilestonesBatch,e,So)}submitScoresBatch(e){return this.send(he.SubmitScoresBatch,e,xo)}claimAllRewardsBatch(e){return this.send(he.ClaimAllRewardsBatch,e,Do)}getOverviewBatch(e){return this.send(he.GetOverviewBatch,e,bo)}};var pi=z.object({}).passthrough().transform(c=>c),vo=z.object({SeasonChainID:z.string(),CycleIndex:z.number().nullish(),Season:z.lazy(()=>Mo).nullish(),ComputedStartUtc:a.nullish(),ComputedEndUtc:a.nullish(),SecondsRemaining:M.nullish(),UserState:pi.nullish(),NextTier:z.lazy(()=>Io).nullish()}).passthrough(),To=z.object({SeasonChainID:z.string(),CurrentSeasonID:z.string().nullish(),AmountGranted:M.nullish(),NewStatusTokens:M.nullish(),OldTier:z.number().nullish(),NewTier:z.number(),TierUp:z.boolean().nullish()}),Po=z.object({SeasonChainID:z.string(),CurrentSeasonID:z.string().nullish(),TierNumber:z.number(),Resources:S.nullish()});var Io=z.object({Tier:z.number().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),RequiredTokens:M.nullish(),TierReachedReward:L.nullish()}).passthrough(),Mo=z.object({SeasonID:z.string().nullish(),Order:z.number().nullish(),DurationSec:M.nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tiers:z.array(Io).nullish(),LinkedCollectionID:z.string().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough();var rd=z.object({SeasonChainID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:le.nullish(),Seasons:z.array(Mo).nullish(),GrantTokensAccessMode:z.string().nullish(),Gate:H.nullish()}).passthrough(),Hs=z.object({Chains:z.record(z.string(),rd).nullish()}).passthrough(),st={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var $s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(st.GetDefinitions,e,Hs)}getActiveSeason(e){return this.send(st.GetActiveSeason,e,vo)}getUserState(e){return this.send(st.GetUserState,e,pi)}grantStatusTokens(e){return this.send(st.GrantStatusTokens,e,To)}claimTierReward(e){return this.send(st.ClaimTierReward,e,Po)}};var id={Apple:"Apple",Google:"Google"},ko=z.object({}).passthrough().transform(c=>c),nd=z.object({PremiumID:z.string().nullish(),PurchaseDate:z.string().nullish(),ExpirationDate:z.string().nullish(),TransactionID:z.string().nullish(),IsAutoRenewEnabled:z.boolean().nullish()}).passthrough(),od=z.object({OptionID:z.string().nullish(),Name:z.string().nullish(),RequiredResources:Q.nullish()}).passthrough(),ad=z.object({PremiumID:z.string().nullish(),DisplayName:z.string().nullish(),Tier:z.number().nullish(),DurationDays:z.number().nullish(),TrialDurationDays:z.number().nullish(),PriceOptions:z.record(z.string(),od).nullish(),AppleProductID:z.string().nullish(),GoogleProductID:z.string().nullish(),Benefits:z.record(z.string(),z.string()).nullish()}).passthrough(),di=z.object({Definitions:z.record(z.string(),ad).nullish()}).passthrough(),Ao=z.object({Premium:di.nullish()}),Oo=z.object({ServerTimeUtc:a.nullish(),Premium:ko.nullish()}),Ks=z.object({ServerTimeUtc:a.nullish(),Premium:ko.nullish(),Subscription:nd.nullish(),Resources:S.nullish()}),rt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var Zs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(rt.GetDefinitions,e,Ao)}getUserState(e){return this.send(rt.GetUserState,e,Oo)}activateTrial(e){return this.send(rt.ActivateTrial,e,Ks)}purchaseItemOrCurrency(e){return this.send(rt.PurchaseWithResources,e,Ks)}purchaseRealMoney(e){return this.send(rt.PurchaseRealMoney,e,Ks)}};var Js=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(ze.GetCharacterDefinitions,e,fs)}getUserCharacters(e){return this.send(ze.GetUserCharacters,e,Ki)}unlockCharacter(e){return this.send(ze.UnlockCharacter,e,Lr)}upgradeStatLevel(e){return this.send(ze.UpgradeStatLevel,e,qr)}upgradeCharacterLevel(e){return this.send(ze.UpgradeCharacterLevel,e,Er)}equipItems(e){return this.send(ze.EquipItems,e,Zi)}unequipItems(e){return this.send(ze.UnequipItems,e,Ji)}unequipAllCharacters(e){return this.send(ze.UnequipAllCharacters,e,Yi)}unlockCharactersBatch(e){return this.send(ze.UnlockCharactersBatch,e,Xi)}upgradeCharacterLevelsBatch(e){return this.send(ze.UpgradeCharacterLevelsBatch,e,en)}upgradeStatLevelsBatch(e){return this.send(ze.UpgradeStatLevelsBatch,e,tn)}};var Ys=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(Ne.CreateMatch,e,vn)}updateMatch(e){return this.send(Ne.UpdateMatch,e,Tn)}cancelMatch(e){return this.send(Ne.CancelMatch,e,Pn)}instantBattle(e){return this.send(Ne.InstantBattle,e,In)}saveStrategy(e){return this.send(Ne.SaveStrategy,e,ye)}getMyMatches(e){return this.send(Ne.GetMyMatches,e,Vr)}getAvailableMatches(e){return this.send(Ne.GetAvailableMatches,e,Vr)}getDefinitions(e){return this.send(Ne.GetDefinitions,e,On)}};var ld={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},Uo=z.enum(["TradeUpRarity","TradeUpCollection"]),ud=z.object({Index:z.number().nullish(),BurnedItemIDs:z.array(z.string()).nullish(),RolledCollectionID:z.string().nullish(),UsedCollections:z.record(z.string(),z.number()).nullish(),Output:Ur.nullish()}),Bo=z.object({ServerTimeUtc:a,Type:Uo.nullish(),CraftID:z.string(),CraftedCount:z.number().nullish(),SelectedOptionID:z.string().nullish(),InputRarity:z.string().nullish(),OutputRarity:z.string().nullish(),Resources:S.nullish(),Results:z.array(ud).nullish()}),cd=z.object({OptionID:z.string().nullish(),RequiredResources:Q.nullish()}).passthrough(),pd=z.object({CraftID:z.string().nullish(),Type:Uo.nullish(),CatalogID:z.string().nullish(),CollectionID:z.string().nullish(),InputRarityID:z.string().nullish(),OutputRarityID:z.string().nullish(),RequiredItemCount:z.number().nullish(),PriceOptions:z.record(z.string(),cd).nullish()}).passthrough(),mi=z.object({Definitions:z.record(z.string(),pd).nullish()}).passthrough(),wo=z.object({ServerTimeUtc:a.nullish(),CraftDefinitions:mi.nullish()}),Xs={GetDefinitions:"GetDefinitions",Craft:"Craft"};var er=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Xs.GetDefinitions,e,wo)}craft(e){return this.send(Xs.Craft,e,Bo)}};var dd={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},md=z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),qo=z.object({}).passthrough().transform(c=>c),tr=z.object({CollectibleID:z.string(),Rarity:z.number().nullish(),IsSpecial:z.boolean().nullish(),IsDuplicate:z.boolean().nullish(),CollectionCurrencyConverted:z.number().nullish()}),Eo=z.object({GrantedCollectibles:z.array(tr).nullish(),DuplicateCollectibles:z.array(tr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),NewlyCompletedSetIDs:z.array(z.string()).nullish(),CollectionJustCompleted:z.boolean().nullish(),Resources:S.nullish(),TriggeredPity:z.array(z.unknown()).nullish()}),Lo=z.object({GrantedCollectibles:z.array(tr).nullish(),DuplicateCollectibles:z.array(tr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:S.nullish(),TriggeredPity:z.array(z.unknown()).nullish()}),Go=z.object({GrantedCollectibleID:z.string().nullish(),NewlyCompletedSetID:z.string().nullish(),CollectionJustCompleted:z.boolean().nullish(),Resources:S.nullish()}),hi=z.object({SetID:z.string(),Resources:S.nullish()}),No=z.array(ee(hi)),jo=z.object({Resources:S.nullish()}),hd=z.object({OfferID:z.string(),TitleID:z.string().nullish(),CollectionID:z.string().nullish(),SenderUserID:z.string().nullish(),SenderPublicData:ge.nullish(),OfferedCollectibleID:z.string().nullish(),OfferedCollectibleIsSpecial:z.boolean().nullish(),ReceiverUserID:z.string().nullish(),RequestedCollectibleID:z.string().nullish(),RequestedCollectibleIsSpecial:z.boolean().nullish(),Status:md.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RespondedAtUtc:a.nullish(),DeclineReason:z.string().nullish(),IsSpecialTradeEvent:z.boolean().nullish(),SpecialTradeEventID:z.string().nullish()}).passthrough(),Fo=z.object({OfferID:z.string(),ExpiresAtUtc:a.nullish(),Resources:S.nullish()}),_o=z.object({OfferID:z.string(),Resources:S.nullish()}),Wo=z.object({OfferID:z.string(),ReceivedCollectibleID:z.string().nullish(),ReceivedIsSpecial:z.boolean().nullish(),SentCollectibleID:z.string().nullish(),SentCollectibleIsSpecial:z.boolean().nullish(),Transfer:z.unknown().nullish()}),Vo=z.object({OfferID:z.string(),Resources:S.nullish()}),fi=z.object({Offers:z.array(hd).nullish()}),fd=z.object({CollectibleID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rarity:z.number().nullish(),HasSpecialVersion:z.boolean().nullish(),SortOrder:z.number().nullish()}).passthrough(),Rd=z.object({SetID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),SortOrder:z.number().nullish(),Collectibles:z.array(fd).nullish(),SetCompletionReward:L.nullish()}).passthrough(),gd=z.object({CollectionID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),SeasonChainID:z.string().nullish(),Sets:z.array(Rd).nullish(),GrandPrize:L.nullish()}).passthrough(),Qo=z.object({BonusRewardSlots:me.nullish(),PityRules:me.nullish()}).passthrough(),yd=z.object({PackTypeID:z.string().nullish(),Cost:Q.nullish(),BonusRewardSlots:z.array(ct).nullish(),PityRules:z.array(pt).nullish(),Presets:Qo.nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CollectibleCount:z.number().nullish(),GuaranteedMinRarity:z.number().nullish(),GuaranteeMaxRarity:z.boolean().nullish(),RarityWeights:z.record(z.string(),z.number()).nullish(),ColorTier:z.number().nullish()}).passthrough(),Cd=z.object({Rarity:z.number().nullish(),CollectionCurrencyGranted:z.number().nullish()}).passthrough(),Sd=z.object({CollectionChestID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CollectionCurrencyCost:z.number().nullish(),MinCollectibleCount:z.number().nullish(),MaxCollectibleCount:z.number().nullish(),GuaranteedMinRarity:z.number().nullish(),BonusRewardSlots:z.array(ct).nullish(),PityRules:z.array(pt).nullish(),Presets:Qo.nullish(),Tier:z.number().nullish()}).passthrough(),xd=z.object({SpecialTradeEventID:z.string().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),AllowedSpecialCollectibleIDs:z.array(z.string()).nullish(),SpecialTradeEventDailyTradeLimit:z.number().nullish()}).passthrough(),sr=z.object({Collections:z.record(z.string(),gd).nullish(),PackTypes:z.record(z.string(),yd).nullish(),CollectionChests:z.array(Sd).nullish(),DuplicateConversions:z.array(Cd).nullish(),DailyTradeLimit:z.number().nullish(),CollectibleJokerCatalogID:z.string().nullish(),CollectibleJokerItemID:z.string().nullish(),SpecialTradeEvents:z.array(xd).nullish(),RewardPools:Os.nullish()}).passthrough(),Ce={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 rr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ce.GetDefinitions,e,sr)}getUserState(e){return this.send(Ce.GetUserState,e,qo)}openPack(e){return this.send(Ce.OpenPack,e,Eo)}openCollectionChest(e){return this.send(Ce.OpenCollectionChest,e,Lo)}useCollectibleJoker(e){return this.send(Ce.UseCollectibleJoker,e,Go)}claimSetReward(e){return this.send(Ce.ClaimSetReward,e,hi)}claimSetRewardsBatch(e){return this.send(Ce.ClaimSetRewardsBatch,e,No)}claimGrandPrize(e){return this.send(Ce.ClaimGrandPrize,e,jo)}sendTradeOffer(e){return this.send(Ce.SendTradeOffer,e,Fo)}cancelTradeOffer(e){return this.send(Ce.CancelTradeOffer,e,_o)}acceptTradeOffer(e){return this.send(Ce.AcceptTradeOffer,e,Wo)}declineTradeOffer(e){return this.send(Ce.DeclineTradeOffer,e,Vo)}getMyTradeOffers(e){return this.send(Ce.GetMyTradeOffers,e,fi)}getIncomingTradeOffers(e){return this.send(Ce.GetIncomingTradeOffers,e,fi)}};var Dd=z.object({}).passthrough().transform(c=>c),bd={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},zd={Active:"Active",Left:"Left",Replaced:"Replaced"},vd=z.object({ObjectIndex:z.number().nullish(),ObjectCompletionRewardClaimed:z.boolean().nullish()}).passthrough(),Td=z.object({UserID:z.string().nullish(),PublicData:ge.nullish(),BuildObjectsProgress:vd.nullish(),IsBot:z.boolean().nullish(),SpinsCount:z.number().nullish(),TokensSpent:z.number().nullish(),MemberStatus:z.string().nullish(),GrandPrizeClaimed:z.boolean().nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),Pd=z.object({Index:z.number().nullish(),OwnerUserID:z.string().nullish(),CurrentProgress:z.number().nullish(),MaxProgress:z.number().nullish(),IsCompleted:z.boolean().nullish()}).passthrough(),Id=z.object({Objects:z.array(Pd).nullish()}).passthrough(),Ho=z.object({GroupID:z.string().nullish(),TitleID:z.string().nullish(),CoopChainID:z.string().nullish(),CoopEventID:z.string().nullish(),CycleIndex:z.number().nullish(),Members:z.array(Td).nullish(),BuildObjectsState:Id.nullish(),Status:z.string().nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:z.number().nullish()}).passthrough(),$o=z.object({CoopChainID:z.string()}).passthrough(),Md=z.string(),Ko=z.object({DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Weight:z.number().nullish(),MinProgress:z.number().nullish(),MaxProgress:z.number().nullish()}).passthrough(),kd=z.object({Index:z.number().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxProgress:z.number().nullish(),CompletionReward:L.nullish()}).passthrough(),Ad=z.object({Objects:z.array(kd).nullish(),SpinCost:Q.nullish(),SpinnerTable:z.array(Ko).nullish()}).passthrough(),Od=z.object({CoopEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),EventType:Md.nullish(),PartnerCount:z.number().nullish(),MatchmakingTimeoutMinutes:z.number().nullish(),MemberGracePeriodMinutes:z.number().nullish(),BuildObjects:Ad.nullish(),GrandPrize:L.nullish()}).passthrough(),Ud=z.object({CoopChainID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:le.nullish(),Events:z.array(Od).nullish(),Gate:H.nullish()}).passthrough(),Zo=z.object({ServerTimeUtc:a.nullish(),UserState:Dd.nullish(),ActiveGroup:Ho.nullish()}),Ri=z.object({ServerTimeUtc:a.nullish(),Group:Ho.nullish(),SecondsRemaining:M.nullish()}),Jo=z.object({ServerTimeUtc:a.nullish(),GroupID:z.string().nullish(),Resources:S.nullish(),ObjectIndex:z.number().nullish(),Sector:Ko.nullish(),ProgressDelta:z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:z.boolean().nullish(),AllObjectsCompleted:z.boolean().nullish()}),gi=z.object({ServerTimeUtc:a.nullish(),GroupID:z.string().nullish(),RewardType:z.string().nullish(),Resources:S.nullish()}),Yo=z.object({ServerTimeUtc:a.nullish(),GroupID:z.string().nullish(),Success:z.boolean().nullish()}),ir=z.object({Chains:z.record(z.string(),Ud).nullish()}).passthrough(),Ge={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var nr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ge.GetDefinitions,e,ir)}getActiveEvent(e){return this.send(Ge.GetActiveEvent,e,$o)}getUserState(e){return this.send(Ge.GetUserState,e,Zo)}getGroupState(e){return this.send(Ge.GetGroupState,e,Ri)}joinOrCreateGroup(e){return this.send(Ge.JoinOrCreateGroup,e,Ri)}spin(e){return this.send(Ge.Spin,e,Jo)}claimObjectReward(e){return this.send(Ge.ClaimObjectReward,e,gi)}claimGrandPrize(e){return this.send(Ge.ClaimGrandPrize,e,gi)}leaveGroup(e){return this.send(Ge.LeaveGroup,e,Yo)}};var Bd={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},wd={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},qd=z.object({NodeID:z.string().nullish(),Status:z.string().nullish(),ExecutionCount:z.number().nullish(),UnlockedAtUtc:a.nullish(),CompletedAtUtc:a.nullish(),LastExecutedAtUtc:a.nullish(),NextAvailableAtUtc:a.nullish(),LastExecutionRefID:z.string().nullish()}).passthrough(),Ed=z.object({TrackID:z.string().nullish(),CurrentValue:z.number().nullish(),LastUpdatedUtc:a.nullish()}).passthrough(),Xo=z.object({OfferID:z.string().nullish(),InstanceKey:z.string().nullish(),SourceOfferVersion:z.number().nullish(),Status:z.string().nullish(),ActivatedAtUtc:a.nullish(),ExhaustedAtUtc:a.nullish(),ExpiredAtUtc:a.nullish(),DismissedAtUtc:a.nullish(),ShowCount:z.number().nullish(),LastShownAtUtc:a.nullish(),Nodes:z.record(z.string(),qd).nullish(),Tracks:z.record(z.string(),Ed).nullish(),SelectedChoiceNodeID:z.string().nullish()}).passthrough(),Ld=z.object({SlotID:z.string().nullish(),QueueIndex:z.number().nullish(),CycleIndex:z.number().nullish(),ActiveOfferID:z.string().nullish(),ActiveOfferStartedAtUtc:a.nullish(),ActiveOfferExpiresAtUtc:a.nullish(),ActiveOffer:Xo.nullish(),NextCycleStartsAtUtc:a.nullish(),LastUpdatedUtc:a.nullish(),DismissSkipAvailableAtUtc:a.nullish(),LastDismissedAtUtc:a.nullish()}).passthrough(),Gd=z.object({TotalExecutions:z.number().nullish(),DailyExecutions:z.number().nullish(),DailyResetUtc:a.nullish()}).passthrough(),Nd=z.object({TotalActivations:z.number().nullish(),TotalExhausted:z.number().nullish(),TotalExpired:z.number().nullish(),TotalDismissed:z.number().nullish(),TotalShows:z.number().nullish(),LastShownAtUtc:a.nullish(),LastActivatedAtUtc:a.nullish(),LastExhaustedAtUtc:a.nullish(),NodeCounts:z.record(z.string(),Gd).nullish()}).passthrough(),jd=z.object({Slots:z.record(z.string(),Ld).nullish(),OfferHistory:z.record(z.string(),Nd).nullish(),LastUpdatedUtc:a.nullish()}).passthrough();var Fd=z.object({Order:z.number().nullish(),OfferID:z.string().nullish(),DurationSec:z.number().nullish(),DelayBeforeActivationSec:z.number().nullish()}).passthrough(),_d=z.object({SlotID:z.string().nullish(),Enabled:z.boolean().nullish(),SortOrder:z.number().nullish(),Queue:z.array(Fd).nullish(),Schedule:le.nullish(),Gate:H.nullish(),AllowDismissSkip:z.boolean().nullish(),DismissSkipDelaySec:z.number().nullish()}).passthrough(),Wd=z.object({StoreOfferID:z.string().nullish(),BillingProductID:z.string().nullish(),DirectCost:Q.nullish(),UseExternalRewards:z.boolean().nullish()}).passthrough(),Vd=z.object({AdPlacementID:z.string().nullish(),ViewsRequiredToComplete:z.number().nullish(),MaxViewsPerActivation:z.number().nullish(),CooldownSecondsBetweenViews:z.number().nullish(),RequireServerVerification:z.boolean().nullish(),GrantRewardsPerView:z.boolean().nullish()}).passthrough(),Qd=z.object({Purchase:Wd.nullish(),RewardedVideo:Vd.nullish()}).passthrough(),Hd=z.object({TrackID:z.string().nullish(),Operator:z.string().nullish(),Value:z.number().nullish()}).passthrough(),$d=z.object({Milestones:me.nullish()}).passthrough(),Kd=z.object({TrackID:z.string().nullish(),Amount:z.number().nullish(),RespectBounds:z.boolean().nullish()}).passthrough(),Zd=z.object({TrackID:z.string().nullish(),DisplayName:z.string().nullish(),StartValue:z.number().nullish(),MinValue:z.number().nullish(),MaxValue:z.number().nullish(),ClampToMin:z.boolean().nullish(),ClampToMax:z.boolean().nullish(),HiddenFromUI:z.boolean().nullish()}).passthrough(),Jd=z.object({RequiredCompletedNodeIDs:z.array(z.string()).nullish(),RequiredAnyCompletedNodeIDs:z.array(z.string()).nullish(),RequiredTracks:z.array(Hd).nullish(),VisibleWhileLocked:z.boolean().nullish()}).passthrough(),Yd=z.object({NodeID:z.string().nullish(),SortOrder:z.number().nullish(),Type:z.string().nullish(),Action:Qd.nullish(),Grants:L.nullish(),TrackChanges:z.array(Kd).nullish(),MilestonePoints:z.number().nullish(),UnlockRules:Jd.nullish(),NextNodeIDs:z.array(z.string()).nullish(),ChoiceGroupID:z.string().nullish(),Limits:ue.nullish(),HideWhenCompleted:z.boolean().nullish(),ExhaustOfferOnComplete:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Metadata:z.record(z.string(),z.string()).nullish()}).passthrough(),ea=z.object({OfferID:z.string().nullish(),Version:z.number().nullish(),Enabled:z.boolean().nullish(),GraphMode:z.string().nullish(),Name:z.string().nullish(),Description:z.string().nullish(),RootNodeIDs:z.array(z.string()).nullish(),Nodes:z.array(Yd).nullish(),Tracks:z.array(Zd).nullish(),Milestones:z.record(z.string(),Se).nullish(),Presets:$d.nullish(),MilestoneClaimMode:z.string().nullish(),MilestoneToken:mt.nullish(),ExhaustedWhenAllTerminalNodesCompleted:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Metadata:z.record(z.string(),z.string()).nullish()}).passthrough(),Xd=z.object({Milestones:z.record(z.string(),dt).nullish()}).passthrough(),yi=z.object({Slots:z.record(z.string(),_d).nullish(),Offers:z.record(z.string(),ea).nullish(),Presets:Xd.nullish()}).passthrough(),ta=z.object({DealOfferDefinitions:yi.nullish()}),sa=z.object({DealOffers:jd.nullish()}),em=z.object({EntityID:z.string().nullish(),TotalEarned:z.number().nullish(),ClaimedIDs:z.array(z.string()).nullish(),ReachedUnclaimedIDs:z.array(z.string()).nullish()}).passthrough(),tm=z.object({SlotID:z.string().nullish(),SortOrder:z.number().nullish(),QueueIndex:z.number().nullish(),CycleIndex:z.number().nullish(),OfferDef:ea.nullish(),ActivationState:Xo.nullish(),IsNewActivation:z.boolean().nullish(),ComputedExpiresAtUtc:a.nullish(),Cost:Q.nullish(),Milestone:em.nullish()}).passthrough(),ra=z.object({Slots:z.array(tm).nullish()}),ia=z.object({ServerTimeUtc:a.nullish(),SlotID:z.string().nullish(),NodeID:z.string().nullish(),NodeCompleted:z.boolean().nullish(),OfferExhausted:z.boolean().nullish(),Idempotent:z.boolean().nullish(),Resources:S.nullish()}),na=z.object({ServerTimeUtc:a.nullish(),SlotID:z.string().nullish(),Resources:S.nullish()}),oa=z.object({ServerTimeUtc:a.nullish(),SlotID:z.string().nullish(),Resources:S.nullish()}),aa=z.object({ServerTimeUtc:a.nullish(),SlotID:z.string().nullish(),MilestoneID:z.string().nullish(),Resources:S.nullish()}),la=z.object({ServerTimeUtc:a.nullish(),SlotID:z.string().nullish(),ClaimedIDs:z.array(z.string()).nullish(),Rejected:z.record(z.string(),z.string()).nullish(),Resources:S.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var or=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,ta)}getUserState(e){return this.send(Fe.GetUserState,e,sa)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,ra)}dismissDeal(e){return this.send(Fe.DismissDeal,e,na)}executeNode(e){return this.send(Fe.ExecuteNode,e,ia)}recordShow(e){return this.send(Fe.RecordShow,e,oa)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,aa)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,la)}};var sm=z.object({}).passthrough().transform(c=>c),rm=z.object({FeatureKey:z.string().nullish(),IsEnabled:z.boolean().nullish(),Percent:z.number().nullish(),SourceCurrencyID:z.string().nullish(),TargetCurrencyID:z.string().nullish()}).passthrough(),Ci=z.object({IsEnabled:z.boolean().nullish(),ActivationReward:L.nullish(),InviteRewards:z.record(z.string(),Se).nullish(),SpendRewards:z.array(rm).nullish()}).passthrough(),ua=z.object({ReferralDefinitions:Ci.nullish()}),ca=z.object({Referral:sm.nullish()}),pa=z.object({ReferralCode:z.string().nullish(),IsFirstActivation:z.boolean().nullish(),Resources:S.nullish()}),da=z.object({RewardID:z.string().nullish(),Resources:S.nullish()}),ht={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ht.GetDefinitions,e,ua)}getUserState(e){return this.send(ht.GetUserState,e,ca)}activateReferralCode(e){return this.send(ht.ActivateReferralCode,e,pa)}claimInviteReward(e){return this.send(ht.ClaimInviteReward,e,da)}};var im={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},nm={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},om=z.object({UserID:z.string(),PublicData:ge.nullish()}),am=z.object({OwnerUserID:z.string().nullish(),ActorUserID:z.string().nullish(),ActorProfile:ge.nullish(),Type:z.string().nullish(),CreatedAt:a.nullish(),OwnerImpact:S.nullish(),IsBlocked:z.boolean().nullish(),TargetObjectName:z.string().nullish()}).passthrough(),lr=z.object({Friends:z.array(om).nullish()}),Dt=z.object({TargetUserID:z.string().nullish(),Status:z.string().nullish()}),ma=z.object({Events:z.array(am).nullish()}),_e={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(_e.GetFriendsList,e,lr)}getIncomingRequests(e){return this.send(_e.GetIncomingRequests,e,lr)}getRecommendedFriends(e){return this.send(_e.GetRecommendedFriends,e,lr)}sendFriendRequest(e){return this.send(_e.SendFriendRequest,e,Dt)}acceptFriendRequest(e){return this.send(_e.AcceptFriendRequest,e,Dt)}declineFriendRequest(e){return this.send(_e.DeclineFriendRequest,e,Dt)}removeFriend(e){return this.send(_e.RemoveFriend,e,Dt)}getTimeline(e){return this.send(_e.GetTimeline,e,ma)}};var lm={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var ft=z.object({Target:z.string().nullish(),Operation:z.string().nullish(),Value:z.number().nullish()}).passthrough(),um=z.object({BoostID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),ActivationCost:Q.nullish(),Effect:ft.nullish(),DurationSeconds:z.number().nullish(),Charges:z.number().nullish(),StackingPolicy:z.string().nullish(),MaxActiveInstances:z.number().nullish(),Tags:z.array(z.string()).nullish()}).passthrough(),cm=z.object({ScheduledBoostID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tags:z.array(z.string()).nullish(),Schedule:le.nullish(),Effects:z.array(ft).nullish(),Gate:H.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),pm=z.object({ChainedBoostID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),Effects:z.array(ft).nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),dm=z.object({ChainID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Schedule:le.nullish(),Phases:z.array(pm).nullish(),Gate:H.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),mm=z.object({TriggeredBoostID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tags:z.array(z.string()).nullish(),Sources:z.array(et).nullish(),Effects:z.array(ft).nullish(),DurationSeconds:z.number().nullish(),Charges:z.number().nullish(),StackingPolicy:z.string().nullish(),MaxActiveInstances:z.number().nullish(),Gate:H.nullish()}).passthrough(),hm=z.object({MaxAddPercent:z.number().nullish(),MaxMultiply:z.number().nullish(),MaxAddFlat:z.number().nullish()}).passthrough(),fm=z.object({StackingCaps:z.record(z.string(),hm).nullish()}).passthrough(),cr=z.object({Definitions:z.record(z.string(),um).nullish(),ScheduledBoosts:z.record(z.string(),cm).nullish(),BoostChains:z.record(z.string(),dm).nullish(),TriggeredBoosts:z.record(z.string(),mm).nullish(),Settings:fm.nullish()}).passthrough(),ha=z.object({InstanceID:z.string(),BoostID:z.string(),ActivatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),RemainingCharges:z.number().nullish(),EffectSnapshot:ft.nullish(),SourceType:z.string().nullish(),SourceRef:z.string().nullish()}).passthrough();z.object({Date:a.nullish(),DailyCount:z.number().nullish(),LastFiredUtc:a.nullish()}).passthrough();var fa=z.object({ServerTimeUtc:a.nullish(),Active:z.record(z.string(),ha).nullish()}),Ra=z.object({ServerTimeUtc:a.nullish(),BoostID:z.string().nullish(),StackingPolicy:z.string().nullish(),ActivatedBoost:ha.nullish(),Resources:S.nullish()}),Rm={Scheduled:"Scheduled",Chain:"Chain"},gm=z.object({Kind:z.string().nullish(),SourceID:z.string().nullish(),PhaseID:z.string().nullish(),CycleIndex:z.number().nullish(),PhaseOrder:z.number().nullish(),StartUtc:a.nullish(),EndUtc:a.nullish(),Effects:z.array(ft).nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),ga=z.object({ServerTimeUtc:a.nullish(),Windows:z.array(gm).nullish()}),it={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(it.GetDefinitions,e,cr)}getActive(e){return this.send(it.GetActive,e,fa)}getActiveWindows(e){return this.send(it.GetActiveWindows,e,ga)}activate(e){return this.send(it.Activate,e,Ra)}cleanupExpired(e){return this.send(it.CleanupExpired,e,ye)}};var dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ee.GetUserCustomDataDefinitions,e,os)}getMyUserCustomData(e){return this.send(Ee.GetMyUserCustomData,e,Ei)}getPublicUserCustomDataOf(e){return this.send(Ee.GetPublicUserCustomDataOf,e,Ar)}setPrivateData(e){return this.send(Ee.SetPrivateData,e,Or)}setPublicData(e){return this.send(Ee.SetPublicData,e,Or)}deleteKey(e){return this.send(Ee.DeleteKey,e,ye)}batchSet(e){return this.send(Ee.BatchSet,e,Li)}batchDelete(e){return this.send(Ee.BatchDelete,e,Gi)}batchGetPublicUserCustomDataOf(e){return this.send(Ee.BatchGetPublicUserCustomDataOf,e,Ni)}};var ym={Fast:"Fast",Sequential:"Sequential"},Cm={Instant:"Instant",Timed:"Timed"},Sm={Hit:"Hit",Blocked:"Blocked"},xm=z.object({SlotIndex:z.number(),Level:z.number().nullish(),IsDamaged:z.boolean().nullish(),MaxLevelRewardClaimed:z.boolean().nullish()}).passthrough(),Dm=z.object({Symbol:z.union([z.string(),z.number()]).nullish(),OnOpenBonus:L.nullish(),BonusTag:z.string().nullish()}).passthrough();z.object({ElapsedSeconds:z.number().nullish(),Reward:L.nullish()}).passthrough();z.object({PlayedCount:z.number().nullish(),RewardsClaimedCount:z.number().nullish(),InstantClaimsCount:z.number().nullish(),EarlyClaimsCount:z.number().nullish(),LateClaimsCount:z.number().nullish(),AdViewsTotal:z.number().nullish()}).passthrough();var ya=z.object({}).passthrough().transform(c=>c),Ca=z.object({Min:z.number().nullish(),Max:z.number().nullish()}).passthrough(),be=z.object({Operation:S.nullish(),ScaleWithRollMultiplier:z.boolean().nullish()}).passthrough(),bm=z.object({Count:z.number().nullish(),Sides:z.number().nullish()}).passthrough(),zm=z.object({ShieldChance:z.number().nullish(),DamagedBuildingChance:z.number().nullish(),RankMultiplierMin:z.number().nullish(),RankMultiplierMax:z.number().nullish(),RankOffsetMin:z.number().nullish(),RankOffsetMax:z.number().nullish()}).passthrough(),vm=z.object({CostMatrixTemplatesByID:z.record(z.string(),z.array(z.array(z.number()))).nullish(),PerBoardGrowth:z.number().nullish(),VisualTemplateCycle:z.array(z.string()).nullish(),EconomyScaledResources:ne.nullish(),ScaleRaidStealWithEconomy:z.boolean().nullish(),ScaleAttackRewardWithEconomy:z.boolean().nullish(),AttackValueFromCostMatrix:z.boolean().nullish(),AttackBlockedRewardFactor:z.number().nullish(),ScaleVictimLossWithEconomy:z.boolean().nullish(),ScaleVictimLossWithTier:z.boolean().nullish(),SynthesizedBuildingSlots:z.number().nullish(),SynthesizedBuildingMaxLevel:z.number().nullish()}).passthrough(),Tm=z.object({CostMatrix:z.array(z.array(z.number())).nullish(),PerBoardGrowth:z.number().nullish(),EconomyScale:z.number().nullish(),ScaledResources:ne.nullish()}).passthrough(),Sa=z.object({SlotIndex:z.number().nullish(),Name:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxLevel:z.number().nullish(),MaxLevelReward:L.nullish()}).passthrough(),Pm=z.object({Index:z.number().nullish(),Type:z.string().nullish(),CustomTypeID:z.string().nullish(),RandomActionAttackWeight:z.number().nullish(),RandomActionRaidWeight:z.number().nullish(),ChanceTableID:z.string().nullish(),SpecialModeID:z.string().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough(),Im=z.object({Tiles:z.record(z.string(),Pm).nullish()}).passthrough(),Mm=z.object({Weight:z.number().nullish(),Bonus:be.nullish(),Tag:z.string().nullish()}).passthrough(),km=z.object({Weight:z.number().nullish(),Tag:z.string().nullish(),MinBonusCells:z.number().nullish(),MaxBonusCells:z.number().nullish(),BonusPool:z.array(Mm).nullish(),GuaranteedBonus:be.nullish(),IsJackpot:z.boolean().nullish(),JackpotFinalMultiplier:z.number().nullish(),JackpotSymbolDistribution:z.record(z.string(),z.number()).nullish()}).passthrough(),Am=z.object({Variants:z.array(km).nullish()}).passthrough(),Om=z.object({Weight:z.number().nullish(),OutcomeID:z.string().nullish(),Reward:be.nullish(),ForceAction:z.string().nullish(),SpecialModeID:z.string().nullish()}).passthrough(),Um=z.object({Outcomes:z.array(Om).nullish()}).passthrough(),xa=z.object({PerAdMultiplierRange:Ca.nullish(),MaxAdViews:z.number().nullish(),AdCreditCost:z.number().nullish(),FormulaKind:z.string().nullish(),ApplyMultiplierOnEarlyClaim:z.boolean().nullish()}).passthrough(),Bm=z.object({ElapsedSeconds:z.number().nullish(),Reward:be.nullish()}).passthrough(),wm=z.object({Tiers:z.array(Bm).nullish(),BelowFirstTierReward:be.nullish()}).passthrough(),qm=z.object({ChoiceID:z.string().nullish(),Mode:z.string().nullish(),Reward:be.nullish(),DurationSeconds:z.number().nullish(),EntryCost:Q.nullish(),Multipliers:xa.nullish(),Gradation:wm.nullish()}).passthrough(),Em=z.object({Choices:z.array(qm).nullish(),OfferExpireSeconds:z.number().nullish(),ClaimExpireSeconds:z.number().nullish()}).passthrough(),Lm=z.object({Chance:z.number().nullish(),RequiredOutcome:z.string().nullish(),Reward:be.nullish(),Tag:z.string().nullish()}).passthrough(),Gm=z.object({OnPassStart:be.nullish(),OnTileLanding:z.record(z.string(),be).nullish(),OnAttack:z.record(z.string(),be).nullish(),OnRaid:z.record(z.string(),be).nullish(),OnBuild:be.nullish(),OnStageComplete:be.nullish(),OnAttackBonusDrops:z.array(Lm).nullish(),ChanceTablesByID:z.record(z.string(),Um).nullish(),SpecialModesByID:z.record(z.string(),Em).nullish()}).passthrough(),Da=z.object({BaseAttackReward:L.nullish(),BaseRaidReward:L.nullish(),MaxRollMultiplier:z.number().nullish(),MaxShields:z.number().nullish(),Buildings:z.array(Sa).nullish(),HeistGridBonusConfig:Am.nullish(),StageOperations:Gm.nullish(),TileLandingMultiplier:Ca.nullish(),EconomyOverride:Tm.nullish()}).passthrough(),Nm=z.object({Name:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),BoardTemplateID:z.string().nullish(),Buildings:z.array(Sa).nullish(),StageTemplateID:z.string().nullish(),CostMatrixTemplateID:z.string().nullish(),UnitValue:z.number().nullish(),Override:Da.nullish()}).passthrough(),mr=z.object({RollCurrencyID:z.string().nullish(),ShieldCurrencyID:z.string().nullish(),RaidMode:z.string().nullish(),AllowedRollMultipliers:z.array(z.number()).nullish(),BoardTemplatesByID:z.record(z.string(),Im).nullish(),StageTemplatesByID:z.record(z.string(),Da).nullish(),StagesByLevel:z.record(z.string(),Nm).nullish(),SoftCurrencyID:z.string().nullish(),ProceduralEconomy:vm.nullish(),Dice:bm.nullish(),Bots:zm.nullish()}).passthrough(),jm=z.object({IsActive:z.boolean().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),AnchorUtc:a.nullish(),RoundDurationSec:z.number().nullish(),PauseBetweenRoundsSec:z.number().nullish(),MaxRounds:z.number().nullish(),PartnerCount:z.number().nullish(),MatchmakingTimeoutMinutes:z.number().nullish(),MemberGracePeriodMinutes:z.number().nullish(),ContributionMin:z.number().nullish(),ContributionMax:z.number().nullish(),ScaleContributionWithRollMultiplier:z.boolean().nullish(),MaxProgress:z.number().nullish(),Milestones:z.record(z.string(),Se).nullish(),GrandPrize:L.nullish()}).passthrough(),hr=z.object({Board:mr.nullish(),CommunityChest:jm.nullish()}).passthrough(),Fm=z.object({TargetUserID:z.string().nullish(),IsBot:z.boolean().nullish(),PublicData:ge.nullish(),TargetBuildingStates:z.array(xm).nullish(),TargetHasShield:z.boolean().nullish()}).passthrough(),_m=z.object({ChoiceID:z.string().nullish(),Mode:z.string().nullish(),Reward:be.nullish(),DurationSeconds:z.number().nullish(),EntryCost:Q.nullish(),Multipliers:xa.nullish()}).passthrough(),Wm=z.object({ModeID:z.string().nullish(),Choices:z.array(_m).nullish()}).passthrough(),Vm=z.object({GroupID:z.string().nullish(),Delta:M.nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),UnlockedMilestoneIDs:z.array(z.string()).nullish(),Completed:z.boolean().nullish()}).passthrough(),ba=z.object({UsedMultiplier:z.number().nullish(),Steps:z.number().nullish(),OldPosition:z.number().nullish(),NewPosition:z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:z.string().nullish(),Operation:S.nullish(),ActionRequired:z.string().nullish(),ActionData:Fm.nullish(),SpecialModeOffer:Wm.nullish(),CommunityChestContribution:Vm.nullish()}).passthrough(),za=z.object({Outcome:z.string().nullish(),IsBotTarget:z.boolean().nullish(),BuildingIndexHit:z.number().nullish(),Operation:S.nullish(),DualResult:Xe.nullish()}).passthrough(),Si=z.object({Status:z.string().nullish(),Outcome:z.string().nullish(),FoundSymbol:z.union([z.string(),z.number()]).nullish(),FoundBonus:L.nullish(),OpenedIndex:z.number().nullish(),AttemptsLeft:z.number().nullish(),RaidLayout:z.array(Dm).nullish(),HeistVariantTag:z.string().nullish(),IsJackpot:z.boolean().nullish(),Operation:S.nullish(),DualResult:Xe.nullish()}).passthrough(),va=z.object({BuiltIndex:z.number(),NewLevel:z.number().nullish(),StageComplete:z.boolean().nullish(),MaxLevelRewardClaimed:z.boolean().nullish(),Operation:S.nullish()}).passthrough(),Ta=z.object({Mode:z.union([z.string(),z.number()]).nullish(),Operation:S.nullish(),DurationSeconds:z.number().nullish(),StartedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish()}).passthrough(),Pa=z.object({AdViewsUsed:z.number().nullish(),RolledMultiplier:z.number().nullish(),AccumulatedMultiplier:z.number().nullish(),RemainingAdViews:z.number().nullish()}).passthrough(),Ia=z.object({FinalMultiplier:z.number().nullish(),AdViewsUsed:z.number().nullish(),AccumulatedMultiplier:z.number().nullish(),IsEarlyClaim:z.boolean().nullish(),Operation:S.nullish()}).passthrough(),Qm={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},Ma=z.enum(["Forming","Active","Completed","Failed","Expired"]),Hm={Active:"Active",Left:"Left",Replaced:"Replaced"},$m=z.enum(["Active","Left","Replaced"]),Km=z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Zm=z.object({UserID:z.string().nullish(),PublicData:ge.nullish(),IsBot:z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:z.array(z.string()).nullish(),GrandPrizeClaimed:z.boolean().nullish(),MemberStatus:$m.nullish(),JoinedAtUtc:a.nullish(),LeftAtUtc:a.nullish()}).passthrough(),ka=z.object({GroupID:z.string().nullish(),TitleID:z.string().nullish(),RoundIndex:z.number().nullish(),Members:z.array(Zm).nullish(),SharedProgress:Km.nullish(),Status:Ma.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),Version:z.number().nullish()}).passthrough(),Jm=z.object({GroupID:z.string().nullish(),RoundIndex:z.number().nullish(),FinalStatus:Ma.nullish(),GrandPrizeReceived:z.boolean().nullish(),FinishedAtUtc:a.nullish()}).passthrough(),Ym=z.object({ActiveGroupID:z.string().nullish(),ActiveRoundIndex:z.number().nullish(),History:z.array(Jm).nullish()}).passthrough(),Aa=z.object({ServerTimeUtc:a.nullish(),UserState:Ym.nullish(),ActiveGroup:ka.nullish(),SecondsRemaining:M.nullish()}),Oa=z.object({ServerTimeUtc:a.nullish(),Group:ka.nullish(),SecondsRemaining:M.nullish()}),xi=z.object({ServerTimeUtc:a.nullish(),GroupID:z.string().nullish(),RewardType:z.string().nullish(),MilestoneID:z.string().nullish(),Resources:S.nullish()}),Ua=z.object({ServerTimeUtc:a.nullish(),GroupID:z.string().nullish(),Success:z.boolean().nullish()}),pe={GetGameLoops:"GetGameLoops",GetBoardDefinition:"GetBoardDefinition",GetBoardDefinitionForLevel:"GetBoardDefinitionForLevel",GetUserBoardState:"GetUserBoardState",BoardLoopRoll:"BoardLoopRoll",BoardLoopAttack:"BoardLoopAttack",BoardLoopRaid:"BoardLoopRaid",BoardLoopRaidFast:"BoardLoopRaidFast",BoardLoopBuild:"BoardLoopBuild",BoardSpecialChoose:"BoardSpecialChoose",BoardSpecialApplyMultiplier:"BoardSpecialApplyMultiplier",BoardSpecialClaim:"BoardSpecialClaim",GetCommunityChestState:"GetCommunityChestState",JoinOrCreateCommunityChest:"JoinOrCreateCommunityChest",ClaimCommunityChestMilestone:"ClaimCommunityChestMilestone",ClaimCommunityChestGrandPrize:"ClaimCommunityChestGrandPrize",LeaveCommunityChest:"LeaveCommunityChest"};var Xm=z.object({VariantID:z.string().nullish(),DisplayName:z.string().nullish(),Weight:z.number().nullish(),IsControl:z.boolean().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough(),eh=z.object({ExperimentID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),IsEnabled:z.boolean().nullish(),Schedule:le.nullish(),Gate:H.nullish(),Variants:z.array(Xm).nullish(),Salt:z.string().nullish(),LayerID:z.string().nullish(),StickyAssignment:z.boolean().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Ba=z.object({Experiments:z.record(z.string(),eh).nullish()}).passthrough();var th={Mesh:"Mesh",Host:"Host"},Di=z.enum(["Mesh","Host"]),sh={ServerRelay:"ServerRelay",P2P:"P2P"},bi=z.enum(["ServerRelay","P2P"]),rh={Public:"Public",Private:"Private"},ih=z.enum(["Public","Private"]),nh={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},oh=z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),wa=z.object({Urls:z.string().nullish(),Username:z.string().nullish(),Credential:z.string().nullish()}).passthrough(),ah=z.object({Enabled:z.boolean().nullish()}).passthrough(),qa=z.object({SystemState:ah.nullish(),DefaultTopology:Di.nullish(),AllowCreatorTopologyOverride:z.boolean().nullish(),DefaultChatMode:bi.nullish(),AllowCreatorChatOverride:z.boolean().nullish(),MaxPlayersPerRoom:z.number().nullish(),RoomTtlSeconds:z.number().nullish(),HeartbeatIntervalMs:z.number().nullish(),MemberTimeoutMs:z.number().nullish(),MaxSignalPayloadBytes:z.number().nullish(),MaxChatTextLength:z.number().nullish(),RoomLogCap:z.number().nullish(),IceServers:z.array(wa).nullish()}).passthrough(),lh=z.object({UserID:z.string().nullish(),Username:z.string().nullish(),AvatarUrl:z.string().nullish(),Level:z.number().nullish(),Power:z.number().nullish(),Ready:z.boolean().nullish(),State:z.record(z.string(),z.string()).nullish(),JoinedAt:z.number().nullish(),IsHost:z.boolean().nullish(),LastSeenMs:z.number().nullish()}).passthrough(),uh=z.object({RoomID:z.string().nullish(),Name:z.string().nullish(),HostUserID:z.string().nullish(),Topology:Di.nullish(),ChatMode:bi.nullish(),MaxPlayers:z.number().nullish(),MemberCount:z.number().nullish(),CreatedAt:z.number().nullish()}).passthrough(),ch=z.object({Seq:z.number().nullish(),Type:oh.nullish(),FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),Kind:z.string().nullish(),Payload:z.string().nullish(),Ts:z.number().nullish()}).passthrough(),fr=z.object({RoomID:z.string().nullish(),Name:z.string().nullish(),HostUserID:z.string().nullish(),OwnerUserID:z.string().nullish(),Topology:Di.nullish(),ChatMode:bi.nullish(),Visibility:ih.nullish(),Status:z.string().nullish(),MaxPlayers:z.number().nullish(),Members:z.array(lh).nullish(),IceServers:z.array(wa).nullish(),Seq:z.number().nullish()}).passthrough(),zi=z.object({Closed:z.boolean().nullish(),NewHostUserID:z.string().nullish()}).passthrough(),Ea=z.object({Rooms:z.array(uh).nullish(),Page:z.number().nullish(),PageSize:z.number().nullish(),HasMore:z.boolean().nullish()}).passthrough(),La=z.object({Envelopes:z.array(ch).nullish(),MaxSeq:z.number().nullish()}).passthrough(),Rr=z.object({Seq:z.number().nullish()}).passthrough(),Ue={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var vi=z.object({Data:z.string().nullish(),SchemaVersion:z.number().nullish(),UpdatedAt:a.nullish()}),ph=z.object({PublicData:z.record(z.string(),vi).nullish(),PrivateData:z.record(z.string(),vi).nullish()}),Ga=z.object({TitleCustomData:ph.nullish(),Character:fs.nullish(),Item:Is.nullish(),Currency:ds.nullish(),Store:ks.nullish(),Lootbox:ri.nullish(),Quest:Es.nullish(),TimedEvent:Gs.nullish(),Leaderboard:Vs.nullish(),Season:Hs.nullish(),Reward:ii.nullish(),Collection:sr.nullish(),Craft:mi.nullish(),DealOffer:yi.nullish(),Premium:di.nullish(),TimedBoost:cr.nullish(),CoopEvent:ir.nullish(),GameLoop:hr.nullish(),Match:Hr.nullish(),Experiment:Ba.nullish(),Blockchain:Nr.nullish(),Marketplace:Jr.nullish(),Multiplayer:qa.nullish(),UserCustomData:os.nullish(),Referral:Ci.nullish()}).passthrough(),Na=z.object({PublicData:z.record(z.string(),vi).nullish()});var nt={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetPublicCustomTitleData:"GetPublicCustomTitleData",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(nt.GetTitlePublicConfiguration,e,Ga)}getPublicTitleCustomData(e){return this.send(nt.GetPublicCustomTitleData,e,Na)}getCurrencyDefinitions(e){return this.send(nt.GetCurrencyDefinitions,e,ds)}getItemDefinitions(e){return this.send(nt.GetItemDefinitions,e,Is)}getServerTime(e){return this.send(nt.GetServerTime,e,ye)}};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=O(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(pe.GetGameLoops,e,hr)}getBoardDefinition(e,t=false){return this.send(pe.GetBoardDefinition,e,mr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(pe.GetBoardDefinitionForLevel,e,mr,t)}getUserBoardState(e){return this.send(pe.GetUserBoardState,e,ya)}boardLoopRoll(e){return this.send(pe.BoardLoopRoll,e,ba)}boardLoopAttack(e){return this.send(pe.BoardLoopAttack,e,za)}boardLoopRaid(e){return this.send(pe.BoardLoopRaid,e,Si)}boardLoopRaidFast(e){return this.send(pe.BoardLoopRaidFast,e,Si)}boardLoopBuild(e){return this.send(pe.BoardLoopBuild,e,va)}boardSpecialChoose(e){return this.send(pe.BoardSpecialChoose,e,Ta)}boardSpecialApplyMultiplier(e){return this.send(pe.BoardSpecialApplyMultiplier,e,Pa)}boardSpecialClaim(e){return this.send(pe.BoardSpecialClaim,e,Ia)}getCommunityChestState(e){return this.send(pe.GetCommunityChestState,e,Aa)}joinOrCreateCommunityChest(e){return this.send(pe.JoinOrCreateCommunityChest,e,Oa)}claimCommunityChestMilestone(e){return this.send(pe.ClaimCommunityChestMilestone,e,xi)}claimCommunityChestGrandPrize(e){return this.send(pe.ClaimCommunityChestGrandPrize,e,xi)}leaveCommunityChest(e){return this.send(pe.LeaveCommunityChest,e,Ua)}};var bt=z.lazy(()=>z.union([z.string(),z.number(),z.boolean(),z.null(),z.array(bt),z.record(z.string(),bt)]));var dh={Live:"Live",Latest:"Latest",Specific:"Specific"},mh={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},hh=z.enum(["Debug","Info","Warning","Error"]),fh={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"},Rh=z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),gh=z.object({Level:hh,Message:z.string().nullish(),Data:bt.nullish()}),yh=z.object({Error:Rh,Message:z.string().nullish(),StackTrace:z.string().nullish()}),ja=z.object({FunctionName:z.string().nullish(),Revision:z.number().nullish(),FunctionResult:bt.nullish(),FunctionResultTooLarge:z.boolean().nullish(),Logs:z.array(gh).nullish(),LogsTooLarge:z.boolean().nullish(),ExecutionTimeSeconds:z.number().nullish(),APIRequestsIssued:z.number().nullish(),Error:yh.nullish()}),Ti={Execute:"Execute"};var Cr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=O(this.ctx.settings.titleID,"CloudCode",Ti.Execute,e.UserID??"");return this.ctx.transport.post(t,e,ja,{ticket:e.ClientSessionTicket})}};var Sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ve.GetDefinitions,e,dn)}getUserState(e){return this.send(ve.GetUserState,e,mn)}depositToken(e){return this.send(ve.DepositToken,e,hn)}depositNFT(e){return this.send(ve.DepositNFT,e,fn)}requestTokenWithdrawal(e){return this.send(ve.RequestTokenWithdrawal,e,Rn)}requestNFTWithdrawal(e){return this.send(ve.RequestNFTWithdrawal,e,gn)}getTransactionHistory(e){return this.send(ve.GetTransactionHistory,e,yn)}retryWithdrawal(e){return this.send(ve.RetryWithdrawal,e,Cn)}confirmWithdrawal(e){return this.send(ve.ConfirmWithdrawal,e,Sn)}donateToDeveloper(e){return this.send(ve.DonateToDeveloper,e,_r)}donateToUsersPool(e){return this.send(ve.DonateToUsersPool,e,_r)}};var xr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(te.GetDefinitions,e,Bn)}getGroupedOffers(e){return this.send(te.GetGroupedOffers,e,wn)}getOffersByItem(e){return this.send(te.GetOffersByItem,e,Yr)}getOffer(e){return this.send(te.GetOffer,e,qn)}getBuyOrders(e){return this.send(te.GetBuyOrders,e,Yr)}getMyState(e){return this.send(te.GetMyState,e,Ln)}getHistory(e){return this.send(te.GetHistory,e,Gn)}createListing(e){return this.send(te.CreateListing,e,St)}cancelListing(e){return this.send(te.CancelListing,e,ke)}buy(e){return this.send(te.Buy,e,ke)}marketBuy(e){return this.send(te.MarketBuy,e,ke)}marketSell(e){return this.send(te.MarketSell,e,ke)}createAuction(e){return this.send(te.CreateAuction,e,St)}placeBid(e){return this.send(te.PlaceBid,e,En)}claimAuction(e){return this.send(te.ClaimAuction,e,ke)}createBuyOrder(e){return this.send(te.CreateBuyOrder,e,St)}cancelBuyOrder(e){return this.send(te.CancelBuyOrder,e,ke)}fillBuyOrder(e){return this.send(te.FillBuyOrder,e,ke)}createDirectTrade(e){return this.send(te.CreateDirectTrade,e,St)}respondDirectTrade(e){return this.send(te.RespondDirectTrade,e,ke)}cancelDirectTrade(e){return this.send(te.CancelDirectTrade,e,ke)}claimBack(e){return this.send(te.ClaimBack,e,ke)}};var Dr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=O(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(Ue.CreateRoom,e,fr)}joinRoom(e){return this.send(Ue.JoinRoom,e,fr)}leaveRoom(e){return this.send(Ue.LeaveRoom,e,zi)}listRooms(e){return this.send(Ue.ListRooms,e,Ea)}getRoom(e){return this.send(Ue.GetRoom,e,fr)}closeRoom(e){return this.send(Ue.CloseRoom,e,zi)}poll(e){return this.send(Ue.Poll,e,La)}sendSignal(e){return this.send(Ue.SendSignal,e,Rr)}sendChat(e){return this.send(Ue.SendChat,e,Rr)}setMemberState(e){return this.send(Ue.SetMemberState,e,Rr)}};var br=class{settings;emitter;platform;transport;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e$1){this.settings=Mi(e$1),this.emitter=new gt,this.platform=e$1.platform??new e,this.transport=new It({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e$1.fetch,debugLogging:this.settings.debugLogging,throttleMs:e$1.throttleMs}),this.data=new Ot(this.emitter),this.authStore=new qt(this.platform.storage,this.settings.titleID),this.api={authentication:new zs(this),user:new vs(this),currency:new Ts(this),item:new Ms(this),store:new As(this),lootbox:new ws(this),reward:new qs(this),quest:new Ls(this),timedEvent:new Ns(this),leaderboard:new Qs(this),season:new $s(this),premium:new Zs(this),character:new Js(this),match:new Ys(this),craft:new er(this),collection:new rr(this),coopEvent:new nr(this),dealOffer:new or(this),referral:new ar(this),social:new ur(this),timedBoost:new pr(this),userCustomData:new dr(this),title:new gr(this),gameLoop:new yr(this),cloudCode:new Cr(this),blockchain:new Sr(this),marketplace:new xr(this),multiplayer:new Dr(this)},this.userService=new Lt(this),this.auth=new Et(this),this.currency=new Nt(this),this.item=new jt(this),this.store=new Ft(this),this.lootbox=new _t(this),this.reward=new Wt(this),this.quest=new Vt(this),this.timedEvent=new Qt(this),this.leaderboard=new Ht(this),this.season=new $t(this),this.premium=new Kt(this),this.character=new Zt(this),this.match=new Jt(this),this.craft=new Yt(this),this.collection=new Xt(this),this.coopEvent=new es(this),this.dealOffer=new ts(this),this.referral=new ss(this),this.social=new rs(this),this.timedBoost=new is(this),this.userCustomData=new as(this),this.title=new ls(this),this.gameLoop=new us(this),this.cloudCode=new cs(this),this.blockchain=new ys(this),this.marketplace=new Ds(this),this.multiplayer=new bs(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:d()}}};var zr=class{ctx;constructor(e){this.ctx=new br(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 lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}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 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 Ch(c){return new zr(c)}var Sh={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Pi=z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),xh={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},Dh=z.enum(["Top","Bottom","Left","Right"]),bh=z.object({PlacementID:z.string().nullish(),Type:Pi.nullish(),Enabled:z.boolean().nullish(),CooldownSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish(),CreditsRewarded:z.number().nullish(),AllowedProviderIDs:z.array(z.string()).nullish()}).passthrough(),zh=z.object({DefaultCreditsPerView:z.number().nullish(),MaxCreditsBalance:z.number().nullish(),DailyCreditEarnCap:z.number().nullish(),DailyViewCap:z.number().nullish(),MinSecondsBetweenViews:z.number().nullish()}).passthrough(),vh=z.object({CooldownSeconds:z.number().nullish(),MinSessionTimeBeforeFirstSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish(),MaxImpressionsPerSession:z.number().nullish()}).passthrough(),Th=z.object({Enabled:z.boolean().nullish(),Position:Dh.nullish(),RefreshIntervalSeconds:z.number().nullish()}).passthrough(),Ph=z.object({Enabled:z.boolean().nullish(),CooldownSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish()}).passthrough(),Ih=z.object({MaxImpressionsPerHour:z.number().nullish(),MaxImpressionsPerDay:z.number().nullish(),MaxImpressionsPerSession:z.number().nullish()}).passthrough(),Mh=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),DisableInterstitials:z.boolean().nullish(),DisableBanners:z.boolean().nullish(),DisableAppOpen:z.boolean().nullish()}).passthrough(),kh=z.object({RequirePersonalizedAdsConsent:z.boolean().nullish(),RequireTrackingConsent:z.boolean().nullish(),CurrentPolicyVersion:z.string().nullish(),RegulatedRegions:z.array(z.string()).nullish()}).passthrough(),Ah=z.object({RequireServerSideVerification:z.boolean().nullish(),PendingRequestTtlSeconds:z.number().nullish(),MaxPendingRequestsPerUser:z.number().nullish(),ProviderPublicKeys:z.record(z.string(),z.string()).nullish()}).passthrough(),Oh=z.object({AndroidUnitID:z.string().nullish(),IosUnitID:z.string().nullish(),WebUnitID:z.string().nullish(),Type:Pi.nullish()}).passthrough(),Uh=z.object({ProviderID:z.string().nullish(),Enabled:z.boolean().nullish(),Priority:z.number().nullish(),AndroidAppID:z.string().nullish(),IosAppID:z.string().nullish(),WebAppID:z.string().nullish(),Units:z.record(z.string(),Oh).nullish()}).passthrough();z.object({Enabled:z.boolean().nullish(),Placements:z.record(z.string(),bh).nullish(),Providers:z.record(z.string(),Uh).nullish(),RewardedVideo:zh.nullish(),Interstitial:vh.nullish(),Banner:Th.nullish(),AppOpen:Ph.nullish(),FrequencyCapping:Ih.nullish(),PremiumAdReductions:z.array(Mh).nullish(),Consent:kh.nullish(),Verification:Ah.nullish()}).passthrough();var Bh=z.object({RewardedVideoCredit:z.number().nullish(),TotalEarned:z.number().nullish(),TotalSpent:z.number().nullish()}).passthrough(),wh=z.object({PlacementID:z.string().nullish(),LastShownAt:a.nullish(),LastCompletedAt:a.nullish(),TotalImpressions:z.number().nullish(),TotalCompletions:z.number().nullish(),ConsecutiveFailures:z.number().nullish()}).passthrough(),qh=z.object({Date:a.nullish(),ImpressionsByPlacement:z.record(z.string(),z.number()).nullish(),CompletionsByPlacement:z.record(z.string(),z.number()).nullish(),TotalImpressions:z.number().nullish(),InterstitialImpressions:z.number().nullish(),RewardedCompletions:z.number().nullish(),AppOpenImpressions:z.number().nullish(),CreditsEarnedToday:z.number().nullish()}).passthrough(),Eh=z.object({SessionID:z.string().nullish(),SessionStartAt:a.nullish(),Impressions:z.number().nullish(),InterstitialImpressions:z.number().nullish(),RewardedCompletions:z.number().nullish()}).passthrough(),Lh=z.object({PersonalizedAdsConsent:z.boolean().nullish(),TrackingConsent:z.boolean().nullish(),PolicyVersion:z.string().nullish(),Region:z.string().nullish(),ConsentGivenAt:a.nullish(),ConsentRevokedAt:a.nullish()}).passthrough(),Gh=z.object({RequestID:z.string().nullish(),PlacementID:z.string().nullish(),ProviderID:z.string().nullish(),Type:Pi.nullish(),IssuedAt:a.nullish(),ExpiresAt:a.nullish(),CreditsToAward:z.number().nullish()}).passthrough(),Nh=z.object({InvalidSsvCount:z.number().nullish(),OrphanCompletions:z.number().nullish(),FastCompletions:z.number().nullish(),LastFlaggedAt:a.nullish()}).passthrough();z.object({Credits:Bh.nullish(),Placements:z.record(z.string(),wh).nullish(),Daily:qh.nullish(),Session:Eh.nullish(),LastImpressionAt:a.nullish(),LastInterstitialAt:a.nullish(),LastRewardedAt:a.nullish(),LastAppOpenAt:a.nullish(),TotalImpressions:z.number().nullish(),TotalRewardedCompletions:z.number().nullish(),AdsDisabledUntil:a.nullish(),Consent:Lh.nullish(),PendingRequests:z.record(z.string(),Gh).nullish(),FraudFlags:Nh.nullish(),UpdatedAt:a.nullish()}).passthrough();var jh={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Fh=z.enum(["Unread","Read","Deleted","Expired"]),_h={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},Wh=z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),Vh={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},Qh=z.enum(["Active","Paused","Cancelled","Completed"]),Hh=z.object({MessageTypeID:z.string().nullish(),DisplayName:z.string().nullish(),IconPath:z.string().nullish(),DisplayPriority:z.number().nullish(),ExpirationHours:z.number().nullish(),AutoClaim:z.boolean().nullish(),AllowP2P:z.boolean().nullish(),ShowBadge:z.boolean().nullish()}).passthrough(),$h=z.object({SegmentID:z.string().nullish(),DisplayName:z.string().nullish(),Gate:H.nullish()}).passthrough();z.object({MaxMessagesPerUser:z.number().nullish(),ReadNoRewardRetentionHours:z.number().nullish(),ClaimedRetentionHours:z.number().nullish(),DefaultPageSize:z.number().nullish(),EnableAutoClaim:z.boolean().nullish(),MessageTypes:z.record(z.string(),Hh).nullish(),Segments:z.array($h).nullish(),DailyP2PGiftLimit:z.number().nullish(),MaxRewardsPerP2PMessage:z.number().nullish()}).passthrough();z.object({MessageID:z.string().nullish(),TitleID:z.string().nullish(),RecipientUserID:z.string().nullish(),MessageTypeID:z.string().nullish(),Source:Wh.nullish(),RelatedEntityID:z.string().nullish(),SenderUserID:z.string().nullish(),SenderPublicData:ge.nullish(),Subject:z.string().nullish(),Body:z.string().nullish(),TemplateParams:z.record(z.string(),z.string()).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rewards:L.nullish(),Claimed:z.boolean().nullish(),ClaimedAtUtc:a.nullish(),Status:Fh.nullish(),CreatedAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),ReadAtUtc:a.nullish(),BroadcastID:z.string().nullish(),Version:z.number().nullish()}).passthrough();z.object({BroadcastID:z.string().nullish(),TitleID:z.string().nullish(),MessageTypeID:z.string().nullish(),Subject:z.string().nullish(),Body:z.string().nullish(),TemplateParams:z.record(z.string(),z.string()).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rewards:L.nullish(),TargetSegmentID:z.string().nullish(),TargetUserIDs:z.array(z.string()).nullish(),StartsAtUtc:a.nullish(),ExpiresAtUtc:a.nullish(),CreatedAtUtc:a.nullish(),CreatedByAdminID:z.string().nullish(),AdminComment:z.string().nullish(),Status:Qh.nullish(),DeliveredCount:z.number().nullish(),ClaimedCount:z.number().nullish()}).passthrough();z.object({UnreadCount:z.number().nullish(),UnclaimedRewardCount:z.number().nullish(),LastFetchCursor:a.nullish(),ReceivedBroadcastIDs:z.array(z.string()).nullish(),ClaimedBroadcastIDs:z.array(z.string()).nullish(),DailyP2PGiftsSent:z.number().nullish(),DailyGiftsResetDate:a.nullish(),LastOpenedAtUtc:a.nullish(),TotalMessagesReceived:z.number().nullish(),TotalRewardsClaimed:z.number().nullish()}).passthrough();
|
|
2
|
-
export{
|
|
1
|
+
import {e,d}from'./chunk-QJVWT32O.js';export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,f as NoopPlatformAdapter}from'./chunk-QJVWT32O.js';import {z}from'zod';import Lt from'decimal.js';var yt=class{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t);}}once(e,t){let s=this.on(e,r=>{s(),t(r);});return s}off(e,t){let s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e));}emit(e,t){let s=this.listeners.get(e);if(s)for(let r of [...s])r(t);}removeAllListeners(){this.listeners.clear();}};function Rl(){let a=new Map;return {get:e=>a.get(e)??null,set:(e,t)=>{a.set(e,t);},remove:e=>{a.delete(e);}}}function Ni(){return yl()??Rl()}function yl(){try{let a=globalThis.localStorage;if(!a)return null;let e="__idos_probe__";return a.setItem(e,"1"),a.removeItem(e),{get:t=>{try{return a.getItem(t)}catch{return null}},set:(t,s)=>{try{a.setItem(t,s);}catch{try{a.removeItem(t);}catch{}}},remove:t=>{try{a.removeItem(t);}catch{}}}}catch{return null}}var ji="https://api.idosgames.com";function Fi(a){return {titleID:a.titleID,titleTemplateID:a.titleTemplateID??"default",buildKey:a.buildKey??"",baseUrl:(a.baseUrl??ji).replace(/\/+$/,""),devBuild:a.devBuild??false,debugLogging:a.debugLogging??false,configStorage:a.configStorage??Ni()}}function Vi(a){return {ok:true,data:a}}function n(a,e){return {ok:false,reason:a,error:e}}function Cl(a){return a.ok}function Sl(a){return !a.ok}var qe={Virtual:"Virtual",Crypto:"Crypto"},lt=z.enum(["Virtual","Crypto"]),xl={Item:"Item",VirtualCurrency:"VirtualCurrency",CryptoCurrency:"CryptoCurrency",UsdCent:"UsdCent"},Mt=z.enum(["Item","VirtualCurrency","CryptoCurrency","UsdCent"]),Dl={TimedEvent:"TimedEvent",Quest:"Quest",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season"},kt=z.enum(["TimedEvent","Quest","Leaderboard","CoopEvent","Season"]),bl={Cyclic:"Cyclic",Scheduled:"Scheduled",Chained:"Chained"},Ct=z.enum(["Cyclic","Scheduled","Chained"]),ue={None:"None",Device:"Device",Email:"Email",iDosGames:"iDosGames",Facebook:"Facebook",Google:"Google",GooglePlay:"GooglePlay",Telegram:"Telegram",Wallet:"Wallet"};var M=z.union([z.number(),z.string()]).transform((a,e)=>{let t=typeof a=="string"?Number(a):a;return Number.isFinite(t)?Math.trunc(t):(e.addIssue({code:z.ZodIssueCode.custom,message:`Invalid integer amount: ${String(a)}`}),z.NEVER)}),q=z.union([z.number(),z.string()]).transform((a,e)=>{let t=typeof a=="number"?String(a):a.trim();return t===""||Number.isNaN(Number(t))?(e.addIssue({code:z.ZodIssueCode.custom,message:`Invalid decimal: ${String(a)}`}),z.NEVER):t}),l=z.string();var Ur=z.object({Type:Mt.nullish(),CurrencyID:z.string().nullish(),Amount:M.nullish(),CatalogID:z.string().nullish(),ItemID:z.string().nullish()}),zl=z.object({Type:kt.nullish(),EntityID:z.string()}),vl=z.object({Address:zl.nullish(),Amount:M.nullish(),Source:z.string().nullish()}),le=z.object({Entries:z.array(Ur).nullish(),EventTokens:z.array(vl).nullish()}),_i=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),Resources:le.nullish()}),G=z.object({Standard:le.nullish(),PremiumBonuses:z.array(z.unknown()).nullish(),PremiumTiers:z.array(_i).nullish()}),K=z.object({Standard:le.nullish(),PremiumDiscounts:z.array(z.unknown()).nullish(),PremiumTiers:z.array(_i).nullish()}),x=z.object({Grant:G.nullish(),Consume:K.nullish()}),tt=z.object({FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),FromResult:x.nullish(),ToResult:x.nullish()});z.object({FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),Transferred:le.nullish()});var Tl=z.object({ExperimentID:z.string().nullish(),Variants:z.array(z.string()).nullish()}).passthrough(),Q=z.object({Segments:z.array(z.string()).nullish(),MinPremiumTier:z.number().nullish(),RequiredPremiumIDs:z.array(z.string()).nullish(),MinLevel:z.number().nullish(),MaxLevel:z.number().nullish(),Countries:z.array(z.string()).nullish(),RegisteredWithinDays:z.number().nullish(),ActiveWithinDays:z.number().nullish(),Experiment:Tl.nullish()}).passthrough();var pe=z.object({TotalCap:z.number().nullish(),DailyCap:z.number().nullish(),DailyWeightCap:z.number().nullish(),PerActivationCap:z.number().nullish(),CooldownSeconds:z.number().nullish(),MaxPerWindow:z.number().nullish(),WindowSeconds:z.number().nullish()}).passthrough();var Pl=z.object({OffsetSecondsFromParentStart:z.number().nullish(),DurationSeconds:z.number().nullish(),AllowEarningAfterEnd:z.boolean().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),Il=z.object({StartUtc:z.string().nullish(),EndUtc:z.string().nullish(),AllowEarningAfterEnd:z.boolean().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),Ml=z.object({AnchorUtc:z.string().nullish(),MaxCycles:z.number().nullish(),PauseBetweenPhasesSec:z.number().nullish(),PauseBetweenCyclesSec:z.number().nullish()}).passthrough();z.object({PhaseID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough();var kl=z.object({Reset:z.string().nullish(),IntervalSeconds:z.number().nullish(),AnchorUtc:z.string().nullish(),PauseBetweenCyclesSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough();z.object({SourceType:z.string().nullish(),TileType:z.string().nullish(),TileIndex:z.number().nullish(),ChanceOutcomeID:z.string().nullish(),Outcome:z.string().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough();var _e=z.object({SourceType:z.string().nullish(),BaseWeight:z.number().nullish(),ScaleWithRollMultiplier:z.boolean().nullish(),TileTypeFilter:z.array(z.string()).nullish(),TileIndexFilter:z.array(z.number()).nullish(),ChanceOutcomeFilter:z.array(z.string()).nullish(),OutcomeFilter:z.array(z.string()).nullish(),Params:z.record(z.string(),z.string()).nullish(),Limits:pe.nullish()}).passthrough(),ce=z.object({Mode:z.string().nullish(),IsActive:z.boolean().nullish(),Scheduled:Il.nullish(),Chain:Ml.nullish(),Cyclic:kl.nullish(),ActivationTriggers:z.array(_e).nullish(),Relative:Pl.nullish()}).passthrough();var Al=z.object({SeasonChainID:z.string().nullish(),MinSeasonTier:z.number().nullish(),Rewards:G.nullish()}).passthrough(),Ul=z.object({SeasonChainID:z.string().nullish(),MinSeasonTier:z.number().nullish(),Multiplier:z.number().nullish()}).passthrough(),Or=z.object({Bundles:z.array(Al).nullish(),Multipliers:z.array(Ul).nullish()}).passthrough();var Ol=z.enum(["BoardStageLevel","BoardRank","BoardCyclesCompleted","CharacterLevel","SeasonTier","EventTokenTotalEarned","VirtualCurrencyBalance","PlayerLevel"]);var Bl=z.enum(["Tiered","Linear"]);var wl=z.enum(["Step","Linear"]),ql=z.object({AtProgress:z.number().nullish(),Multiplier:z.number().nullish()}).passthrough(),At=z.object({Source:Ol.nullish(),SourceKey:z.string().nullish(),CurveType:Bl.nullish(),Tiers:z.array(ql).nullish(),TierMode:wl.nullish(),BaseMultiplier:z.number().nullish(),PerUnit:z.number().nullish(),Anchor:z.number().nullish(),MinMultiplier:z.number().nullish(),MaxMultiplier:z.number().nullish(),IncludeRewards:le.nullish(),ExcludeRewards:le.nullish()}).passthrough(),ye=z.object({MilestoneID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),RequiredProgress:z.number().nullish(),Rewards:G.nullish(),BonusRewards:G.nullish(),SeasonTierRewards:Or.nullish(),SortOrder:z.number().nullish(),IsFeatured:z.boolean().nullish()}).passthrough(),Ye=z.object({Milestones:z.record(z.string(),ye).nullish()}).passthrough();var ie=z.object({PresetID:z.string().nullish(),Remove:z.array(z.string()).nullish()}).passthrough();var El=z.object({TargetCurrencyID:z.string().nullish(),Rate:z.number().nullish(),MaxConvertAmount:z.number().nullish()}).passthrough(),st=z.object({DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxBalance:z.number().nullish(),MaxPerGrant:z.number().nullish(),DailyEarnCap:z.number().nullish(),BurnOnEventEnd:z.boolean().nullish(),BurnConversion:El.nullish()}).passthrough();var se=a=>z.object({Id:z.string(),Success:z.boolean(),Error:z.string().nullish(),Data:a.nullish()}),Ot=a=>z.object({ServerTimeUtc:l,Items:z.array(se(a)),Resources:x.nullish()});var Ll={Active:"Active",Completed:"Completed",Claimed:"Claimed",Expired:"Expired"},Wi=z.enum(["Active","Completed","Claimed","Expired"]),Gl=z.object({}).passthrough().transform(a=>a),Nl=z.object({CycleID:z.string(),InstanceKey:z.string().nullish(),PhaseID:z.string().nullish(),CycleIndex:z.number().nullish(),CycleStartUtc:l.nullish(),CycleEndUtc:l.nullish(),PointsTotalEarned:M.nullish(),PointsCurrent:M.nullish(),ClaimedPointMilestoneIDs:z.array(z.string()).nullish()}),Br=z.object({QuestID:z.string(),CycleID:z.string().nullish(),ObjectiveID:z.string().nullish(),NewValue:M.nullish(),ObjectiveCompleted:z.boolean().nullish(),Status:Wi}),Qi=z.object({State:Gl.nullish(),PointsTracks:z.record(z.string(),Nl).nullish()}),wr=z.object({ServerTimeUtc:l,QuestID:z.string(),CycleID:z.string().nullish(),NewStatus:Wi.nullish(),Resources:x.nullish()}),qr=z.object({ServerTimeUtc:l,CycleID:z.string(),MilestoneID:z.string(),PointsTotalEarned:M.nullish(),Resources:x.nullish()}),Hi=z.object({ServerTimeUtc:l,CycleID:z.string(),GroupCompletionID:z.string(),GroupID:z.string().nullish(),CompletedGroupQuests:z.number().nullish(),RequiredGroupQuests:z.number().nullish(),Resources:x.nullish()}),Ki=z.object({MetricID:z.string(),Updates:z.array(Br).nullish()}),$i=z.array(se(wr)),Zi=z.array(se(qr)),jl={ClientApi:"ClientApi",ServerApi:"ServerApi",SystemEvent:"SystemEvent"},Fl=z.enum(["ClientApi","ServerApi","SystemEvent"]),Vl={BlockProgressAndClaim:"BlockProgressAndClaim",BlockClaimOnly:"BlockClaimOnly"},_l=z.enum(["BlockProgressAndClaim","BlockClaimOnly"]),Ji=z.object({ObjectiveID:z.string().nullish(),Source:Fl.nullish(),MaxProgressPerCall:z.number().nullish(),MetricID:z.string().nullish(),Triggers:z.array(_e).nullish(),TargetValue:z.number().nullish(),AggregationMethod:z.string().nullish()}).passthrough(),Er=z.object({Milestones:ie.nullish(),Linking:ie.nullish(),Availability:ie.nullish(),Reward:ie.nullish(),Objectives:ie.nullish()}).passthrough(),Wl=z.object({DisplayName:z.string().nullish(),Description:z.string().nullish(),SortOrder:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Yi=z.object({CycleIDs:z.array(z.string()).nullish(),GroupID:z.string().nullish(),PhaseIDs:z.array(z.string()).nullish(),RequiredQuestIDs:z.array(z.string()).nullish(),PrerequisiteMode:_l.nullish()}).passthrough(),Xi=z.object({Schedule:ce.nullish(),AccrueProgressWhenLocked:z.boolean().nullish(),Gate:Q.nullish(),Limits:pe.nullish()}).passthrough(),en=z.object({Grant:G.nullish(),PointsReward:z.number().nullish()}).passthrough(),Ql=z.object({QuestID:z.string().nullish(),Identity:Wl.nullish(),Linking:Yi.nullish(),Availability:Xi.nullish(),Objectives:z.record(z.string(),Ji).nullish(),Reward:en.nullish(),Presets:Er.nullish()}).passthrough(),Hl=z.object({CompletionID:z.string().nullish(),GroupID:z.string().nullish(),RequiredCompletedQuests:z.number().nullish(),Gate:Q.nullish(),Reward:G.nullish(),PointsReward:z.number().nullish()}).passthrough(),Kl=z.object({PhaseID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),ClaimGraceHours:z.number().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CustomParams:z.record(z.string(),z.string()).nullish(),Gate:Q.nullish(),Milestones:z.record(z.string(),ye).nullish(),Presets:Er.nullish(),PointsToken:st.nullish()}).passthrough(),$l=z.object({Milestones:z.record(z.string(),Ye).nullish(),Linking:z.record(z.string(),Yi).nullish(),Availability:z.record(z.string(),Xi).nullish(),Reward:z.record(z.string(),en).nullish(),Objectives:z.record(z.string(),z.record(z.string(),Ji)).nullish()}).passthrough(),Zl=z.object({CycleID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:ce.nullish(),Milestones:z.record(z.string(),ye).nullish(),Gate:Q.nullish(),PointsToken:st.nullish(),GroupCompletions:z.record(z.string(),Hl).nullish(),Phases:z.record(z.string(),Kl).nullish(),Presets:Er.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Bt=z.object({Cycles:z.record(z.string(),Zl).nullish(),Quests:z.record(z.string(),Ql).nullish(),Presets:$l.nullish()}).passthrough(),Le={GetQuestDefinitions:"GetQuestDefinitions",GetUserQuestState:"GetUserQuestState",RefreshQuestCycles:"RefreshQuestCycles",ClaimQuestReward:"ClaimQuestReward",ClaimMilestoneReward:"ClaimMilestoneReward",AddQuestProgress:"AddQuestProgress",ClaimQuestRewardsBatch:"ClaimQuestRewardsBatch",ClaimMilestoneRewardsBatch:"ClaimMilestoneRewardsBatch",ClaimGroupCompletionReward:"ClaimGroupCompletionReward"};var wt=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(),s=this.last.get(e);return s!==void 0&&t-s<this.windowMs?false:(this.last.set(e,t),true)}reset(){this.last.clear();}};var qt=class{set=new Set;add(e){return this.set.has(e)?false:(this.set.add(e),true)}remove(e){this.set.delete(e);}};function tn(a){return a===429||a>=500&&a<=599}function Lr(a,e=Math.random){let t=Math.min(500*Math.pow(2,a-1),4e3),s=t*.2*(e()*2-1);return Math.max(50,t+s)}function Gr(a){return new Promise(e=>setTimeout(e,a))}var Jl=12e3,Yl=z.object({Success:z.boolean(),Error:z.string().nullish(),Data:z.unknown().optional(),QuestProgress:z.array(Br).nullish()}).passthrough(),Et=class{baseUrl;emitter;fetchImpl;debugLogging;throttler;inflight=new qt;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 wt(e.throttleMs);}setSessionRefreshHandler(e){this.sessionRefreshHandler=e;}async post(e,t,s,r={}){if(!this.throttler.tryAcquire(e))return n("throttled","Throttled");if(!this.inflight.add(e))return n("throttled","Duplicate request skipped");this.raiseBusy();try{let i=`${this.baseUrl}/${e}`,c=JSON.stringify(t),d=r.ticket??null,z=r.silent??!1,B=r.timeoutMs??Jl,w=r.autoRetry??!0,me=!1,ge=0;for(;;){let Ie;try{Ie=await this.doFetch(i,c,d,B);}catch{if(w&&ge<3){ge++,await Gr(Lr(ge));continue}return this.connectionFailure("Internet Connection Error",z)}let Me=Ie.status;if(Me>=200&&Me<300)return await this.parseSuccess(Ie,s,z,e);if(Me===401){if(!me&&this.sessionRefreshHandler){me=!0;let Ze=null;try{Ze=await this.sessionRefreshHandler();}catch{Ze=null;}if(Ze){d=Ze;continue}}return this.emitter.emit("auth:unauthorized",void 0),n("unauthorized","Unauthorized")}if(tn(Me)){if(w&&ge<3){ge++,await Gr(Lr(ge));continue}return this.connectionFailure(`Server temporarily unavailable (HTTP ${Me})`,z)}return await this.handleWebError(Ie,Me,z)}}finally{this.inflight.remove(e),this.lowerBusy();}}async doFetch(e,t,s,r){let i=new AbortController,c=setTimeout(()=>{i.abort();},r);try{let d={"Content-Type":"application/json"};return s&&(d.Authorization=`Bearer ${s}`),await this.fetchImpl(e,{method:"POST",body:t,headers:d,signal:i.signal})}finally{clearTimeout(c);}}async parseSuccess(e,t,s,r){let i;try{i=await e.text();}catch{return this.globalError("Failed to read response body",s)}let c;try{c=JSON.parse(i);}catch{return this.globalError("JSON Parse Error",s)}let d=Yl.safeParse(c);if(!d.success)return this.globalError("Malformed response envelope",s);if(!d.data.Success){let w=d.data.Error??"Server returned Success=false";return s||this.emitter.emit("error:global",w),n("server",w)}let z=d.data.QuestProgress;z&&z.length>0&&this.emitter.emit("quest:systemProgress",z);let B=t.safeParse(d.data.Data);if(!B.success){let w=`Validation error (${r}): ${B.error.message}`;return this.debugLogging&&console.warn("[HttpTransport]",w),s||this.emitter.emit("error:global",w),n("validation",w)}return Vi(B.data)}async handleWebError(e,t,s){let r=`HTTP ${t}`;try{let i=await e.text();if(i)try{let d=JSON.parse(i).Error;r=typeof d=="string"&&d.length>0?`HTTP ${t}: ${d}`:`HTTP ${t}: ${i}`;}catch{r=`HTTP ${t}: ${i}`;}}catch{}return s||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 ct(a){return (typeof a=="string"?a:a.toISOString()).slice(0,10)}function xt(a){return `${ct(a)}T00:00:00.000Z`}function rn(a){let e=new Date(a);return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1)).toISOString()}function nn(a,e){return new Date(a.getTime()+e*6e4).toISOString()}function on(a,e,t,s){let r={vcChanged:false,ccChanged:false,itemsChanged:false,tokensChanged:false};if(!e)return r;a.InventoryV2??={};let i=a.InventoryV2,c=s.toISOString(),d$1=new Map,z=new Map,B=new Map,w=new Map,me=new Map,ge=new Map,Ie=new Map,Me=new Map,Ze=e.Grant?.PremiumTiers??[],Pt=Ze.length;for(let te=0;;te++){let ae,H;if(te===0)ae=e.Grant?.Standard?.Entries,H=false;else if(te-1<Pt)ae=Ze[te-1]?.Resources?.Entries,H=false;else if(te===1+Pt)ae=e.Consume?.Standard?.Entries,H=true;else break;if(ae)for(let j of ae){if(j.Type==null)continue;let _=Math.max(0,j.Amount??0);if(!(_<=0))switch(j.Type){case "VirtualCurrency":{if(!j.CurrencyID)continue;let W=H?z:d$1;W.set(j.CurrencyID,(W.get(j.CurrencyID)??0)+_);break}case "CryptoCurrency":{if(!j.CurrencyID)continue;let W=H?w:B;W.set(j.CurrencyID,(W.get(j.CurrencyID)??new Lt(0)).plus(_));break}case "Item":{if(!j.ItemID)continue;let W=eu(t,j.CatalogID,j.ItemID),X=(W?W.IsStackable??true:true)?H?ge:me:H?Me:Ie;X.set(j.ItemID,(X.get(j.ItemID)??0)+_);break}case "UsdCent":continue}}}if(r.vcChanged=d$1.size>0||z.size>0,r.vcChanged){i.VirtualCurrencies??={};for(let te of new Set([...d$1.keys(),...z.keys()])){let ae=d$1.get(te)??0,H=z.get(te)??0,j=ae-H,_=i.VirtualCurrencies[te];_?(_.Amount+=j,_.UpdatedAt=c,_.Daily&&ct(_.Daily.PeriodStartUtc)===ct(s)?(_.Daily.Earned+=ae,_.Daily.Spent+=H):_.Daily={PeriodStartUtc:xt(s),Earned:ae,Spent:H}):i.VirtualCurrencies[te]={Amount:j,CreatedAt:c,UpdatedAt:c,Daily:{PeriodStartUtc:xt(s),Earned:ae,Spent:H}};}}if(r.ccChanged=B.size>0||w.size>0,r.ccChanged){i.CryptoCurrencies??={};for(let te of new Set([...B.keys(),...w.keys()])){let ae=B.get(te)??new Lt(0),H=w.get(te)??new Lt(0),j=ae.minus(H),_=i.CryptoCurrencies[te];_?(_.Amount=new Lt(_.Amount).plus(j).toString(),_.UpdatedAt=c):i.CryptoCurrencies[te]={Amount:j.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c};}}if(r.itemsChanged=me.size>0||ge.size>0||Ie.size>0||Me.size>0,r.itemsChanged){i.Items??={},i.UnstackableItems??={};let te=i.UnstackableItems,ae=new Set([...me.keys(),...ge.keys(),...Ie.keys(),...Me.keys()]);for(let H of ae){let j=(me.get(H)??0)-(ge.get(H)??0),_=(Ie.get(H)??0)-(Me.get(H)??0),W=j+_,ke=i.Items[H];ke?(j!==0&&(ke.StackableAmount+=j),_!==0&&(ke.UnstackableAmount+=_),W!==0&&(ke.TotalAmount+=W)):i.Items[H]={StackableAmount:Math.max(0,j),UnstackableAmount:Math.max(0,_),TotalAmount:Math.max(0,W)};}for(let[H,j]of Me){if(j<=0)continue;let _=Object.values(te).filter(W=>W.ItemID===H&&W.EquippedSlot==null&&(W.ExpiresAt==null||new Date(W.ExpiresAt)>s)).sort(Xl).slice(0,j).map(W=>W.ItemInstanceID);for(let W of _)delete te[W];}for(let[H,j]of Ie){let _=tu(t,H);for(let W=0;W<j;W++){let ke=d();te[ke]={ItemInstanceID:ke,ItemID:H,CatalogID:_,RemainingUses:1,AcquiredAt:c};}}}a.EventToken??={};let hl=a.EventToken;for(let te=0;;te++){let ae,H;if(te===0)ae=e.Grant?.Standard?.EventTokens,H=false;else if(te-1<Pt)ae=Ze[te-1]?.Resources?.EventTokens,H=false;else if(te===1+Pt)ae=e.Consume?.Standard?.EventTokens,H=true;else break;if(!(!ae||ae.length===0))for(let j of ae){let _=j.Address;if(!_||_.Type==null)continue;let W=j.Amount??0;if(W<=0)continue;let ke=su(hl,_.Type);if(!ke)continue;let X=ke[_.EntityID];X||(X={},ke[_.EntityID]=X),X.Balance??={Current:0,TotalEarned:0,TotalSpent:0},X.Daily??={Date:xt(s),TotalEarned:0},X.Meta??={};let Rt=j.Source&&j.Source.length>0?j.Source:"CustomAction";H?(X.Balance.Current-=W,X.Balance.TotalSpent+=W):(X.Balance.Current+=W,X.Balance.TotalEarned+=W,ct(X.Daily.Date)!==ct(s)&&(X.Daily={Date:xt(s),TotalEarned:0}),X.Daily.TotalEarned+=W,X.Daily.EarnedBySource??={},X.Daily.EarnedBySource[Rt]=(X.Daily.EarnedBySource[Rt]??0)+W,X.Daily.TriggersBySource??={},X.Daily.TriggersBySource[Rt]=(X.Daily.TriggersBySource[Rt]??0)+1,X.Daily.LastTriggerBySource??={},X.Daily.LastTriggerBySource[Rt]=c,X.Meta.JoinedAtUtc||(X.Meta.JoinedAtUtc=c),X.Meta.LastEarnedAtUtc=c),r.tokensChanged=true;}}return r}function Xl(a,e){return a.AcquiredAt!==e.AcquiredAt?a.AcquiredAt<e.AcquiredAt?-1:1:a.ItemInstanceID===e.ItemInstanceID?0:a.ItemInstanceID<e.ItemInstanceID?-1:1}function eu(a,e,t){let s=a?.Catalogs;if(s){if(e){let r=s[e]?.Items?.[t];if(r)return r}for(let r of Object.values(s)){let i=r.Items?.[t];if(i)return i}}}function tu(a,e){let t=a?.Catalogs;if(t){for(let[s,r]of Object.entries(t))if(r.Items&&e in r.Items)return s}}function su(a,e){switch(e){case "TimedEvent":return a.TimedEvent??={};case "Quest":return a.Quest??={};case "Leaderboard":return a.Leaderboard??={};case "CoopEvent":return a.CoopEvent??={};case "Season":return a.Season??={};default:return null}}function Nr(a,e){return a===e||a.startsWith(`${e}:`)}var Gt=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 s of t)this.currentState[s]=e[s];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,s=new Date){if(!this.currentState)return;let r=on(this.currentState,e,t,s);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,s){if(!e||!this.currentState)return;this.currentState.InventoryV2??={},this.currentState.InventoryV2.CryptoCurrencies??={};let r=this.currentState.InventoryV2.CryptoCurrencies,i=t instanceof Lt?t:new Lt(t),c=s??new Date().toISOString(),d=r[e];d?(d.Amount=new Lt(d.Amount).plus(i).toString(),d.UpdatedAt=c):r[e]={Amount:i.toString(),Frozen:"0",CreatedAt:c,UpdatedAt:c},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,s){if(!e||t<1||!this.currentState)return;this.currentState.Store??={},this.currentState.Store.Purchases??={};let r=this.currentState.Store.Purchases,i=r[e];i||(i={OfferID:e,TotalPurchases:0,DailyPurchases:0,DailyResetUtc:"",LastPurchasedAt:""},r[e]=i),i.TotalPurchases+=t,i.LastPurchasedAt=s,s>=i.DailyResetUtc?(i.DailyPurchases=t,i.DailyResetUtc=rn(s)):i.DailyPurchases+=t,this.emitter.emit("user:storeUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyLootboxPityTriggers(e,t,s){if(!e||s<=0)return;this.currentState??={};let r=this.currentState.Lootbox??={};if(r.Pity??={},t){let i=new Date().toISOString();for(let c of t)c.RuleID&&(r.Pity[`${e}:${c.RuleID}`]={OpensSinceLastTrigger:0,LastTriggeredAtUtc:i});}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,s){if(!e)return;this.currentState??={},this.currentState.Quest??={};let r=this.currentState.Quest;if(t){r.Cycles??={};let i=r.Cycles[t];if(!i)return;i.Quests??={};let c=i.Quests[e]??={QuestID:e,Status:s};c.Status=s,s==="Claimed"&&(c.ClaimedAtUtc??=new Date().toISOString());}else {r.PermanentQuests??={};let i=r.PermanentQuests[e]??={QuestID:e,Status:s};i.Status=s,s==="Claimed"&&(i.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 s=this.getQuestPointsProgress(e);s&&(s.Milestone??={},s.Milestone.ClaimedIDs??=[],s.Milestone.ClaimedIDs.includes(t)||s.Milestone.ClaimedIDs.push(t),this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchQuestPointsTracks(e){if(!e)return;this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.Quest??={};let t=this.currentState.EventToken.Quest;for(let s of Object.values(e)){if(!s.CycleID)continue;let r=s.InstanceKey?`${s.CycleID}:${s.InstanceKey}`:s.CycleID,i=t[r]??={};i.Balance??={Current:0,TotalEarned:0,TotalSpent:0},i.Balance.Current=s.PointsCurrent??0,i.Balance.TotalEarned=s.PointsTotalEarned??0,i.Milestone??={},i.Milestone.ClaimedIDs=s.ClaimedPointMilestoneIDs??[];}this.emitter.emit("user:questUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchGroupCompletionClaimed(e,t){if(!e||!t)return;this.currentState??={},this.currentState.Quest??={},this.currentState.Quest.Cycles??={};let s=this.currentState.Quest.Cycles[e];s&&(s.ClaimedGroupCompletionIDs??=[],s.ClaimedGroupCompletionIDs.includes(t)||s.ClaimedGroupCompletionIDs.push(t),this.emitter.emit("user:questUpdated",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 s of e){if(!s.QuestID)continue;let r;if(!s.CycleID)t.PermanentQuests??={},r=t.PermanentQuests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};else {t.Cycles??={};let i=t.Cycles[s.CycleID];if(!i)continue;i.Quests??={},r=i.Quests[s.QuestID]??={QuestID:s.QuestID,Status:s.Status};}if(r.Status=s.Status,s.ObjectiveID){r.Objectives??={};let i=r.Objectives[s.ObjectiveID]??={ObjectiveID:s.ObjectiveID,CurrentValue:0,Completed:false};i.CurrentValue=s.NewValue??0,s.ObjectiveCompleted&&(i.Completed=true,i.CompletedAtUtc??=new Date().toISOString());}s.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[s,r]of Object.entries(t))if(Nr(s,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,s){if(!(!t||!s)){this.currentState??={},this.currentState.EventToken??={},this.currentState.EventToken.TimedEvent??={};for(let[r,i]of Object.entries(this.currentState.EventToken.TimedEvent))!Nr(r,t)||!i||this.markMilestoneClaimed(i.Milestone??(i.Milestone={}),s);this.patchActiveEventMilestoneClaimed(e,t,s),this.emitter.emit("user:timedEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}}patchActiveEventMilestoneClaimed(e,t,s){let r=this.activeEventsCache?.ActiveEvents;if(r)for(let i of r)i.Type!==e||i.TimedEventID!==t||(i.Progress??={},this.markMilestoneClaimed(i.Progress.Milestone??(i.Progress.Milestone={}),s));}markMilestoneClaimed(e,t){if(e.ClaimedIDs??=[],e.ClaimedIDs.includes(t)||e.ClaimedIDs.push(t),e.UnlockedIDs){let s=e.UnlockedIDs.indexOf(t);s>=0&&e.UnlockedIDs.splice(s,1);}}patchLeaderboardMyProgress(e,t){if(!e||!t)return;let s=this.ensureLeaderboardProgress(e);s.CurrentScore=t.CurrentScore??0,s.LastKnownRank=t.LastKnownRank??0,s.ScoreEarnedThisCycle=t.ScoreEarnedThisCycle??0,s.UnclaimedRewardCycleVersion=t.HasUnclaimedReward?Math.max(1,s.UnclaimedRewardCycleVersion??0):0,this.emitter.emit("user:leaderboardUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchLeaderboardScoreSubmitted(e,t,s,r){if(!e)return;let i=this.ensureLeaderboardProgress(e);(i.ScoreCycleVersion??0)<r&&(i.ScoreEarnedThisCycle=0,i.ClaimedMilestoneIDs=[],i.BracketID=null),i.CurrentScore=t,i.ScoreEarnedThisCycle=(i.ScoreEarnedThisCycle??0)+s,i.ScoreCycleVersion=r,i.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 s=this.ensureLeaderboardProgress(e);s.ClaimedMilestoneIDs??=[],s.ClaimedMilestoneIDs.includes(t)||s.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,s=t[e];return s||(s={CurrentScore:0,ScoreEarnedThisCycle:0,ScoreCycleVersion:0,UnclaimedRewardCycleVersion:0,LastKnownRank:0},t[e]=s),s}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 s=this.ensureSeasonState(e);s.CurrentTier=t,this.emitter.emit("user:seasonUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSeasonClaimedTier(e,t){if(!e)return;let s=this.ensureSeasonState(e);s.ClaimedTierRewards??=[],s.ClaimedTierRewards.includes(t)||s.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,s=t[e];return s||(s={SeasonChainID:e},t[e]=s),s}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 s=this.currentState.Character.Characters,r=s[e];r||(r={CharacterID:e},s[e]=r),t(r),this.emitter.emit("user:characterUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchCharacterEquipment(e,t,s){if(!e||!t)return;let r=this.currentState?.Character?.Characters?.[e];r&&(r.Equipment??={},s===null?delete r.Equipment[t]:r.Equipment[t]=s,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,s=false;for(let[r,i]of Object.entries(e.ChangedInstances??{}))t[r]=i,s=true;for(let r of e.RemovedInstanceIDs??[])r in t&&(delete t[r],s=true);s&&(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,s){this.currentState??={};let r=this.currentState.CoopEvent??={MyObjectIndex:-1};r.ActiveGroupID=e,r.ActiveCoopEventID=t,r.MyObjectIndex=s,this.emitter.emit("user:coopEventUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyDealOffer(e){this.currentState??={},this.currentState.DealOffer=e??{},this.emitter.emit("user:dealOfferUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applyReferral(e){this.currentState??={},this.currentState.Referral=e??{},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchReferralSubscription(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.SubscribedToUserID=e,this.currentState.Referral.UpdatedAt=new Date().toISOString(),this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}patchReferralInviteRewardClaimed(e){e&&(this.currentState??={},this.currentState.Referral??={},this.currentState.Referral.InviteRewardStates??={},this.currentState.Referral.InviteRewardStates[e]={RewardID:e,IsClaimed:true,ClaimedAt:new Date().toISOString()},this.emitter.emit("user:referralUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0));}applySocialFriendsList(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Accepted=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialIncomingRequests(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.IncomingRequests=(e??[]).map(t=>t.UserID),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}applySocialTimeline(e){this.currentState??={},this.currentState.Social??={},this.currentState.Social.Timeline=e??[],this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAddOutgoingRequest(e){if(!e)return;let t=this.ensureSocial();t.OutgoingRequests??=[],t.OutgoingRequests.includes(e)||t.OutgoingRequests.push(e),this.emitter.emit("user:socialUpdated",void 0),this.emitter.emit("user:anyUpdated",void 0);}patchSocialAcceptFriend(e){if(!e)return;let t=this.ensureSocial();t.IncomingRequests=(t.IncomingRequests??[]).filter(s=>s!==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(s=>s!==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(s=>s!==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 s=this.currentState.TimedBoost.Active;if(t==="Replace"||t==="KeepBest")for(let r of Object.keys(s)){let i=s[r];i&&i.BoostID===e.BoostID&&r!==e.InstanceID&&delete s[r];}s[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,s,r,i){if(!t)return;this.currentState??={},this.currentState.CustomData??={};let c=this.currentState.CustomData,d={Value:s,UpdatedAt:new Date().toISOString(),Version:r,LastWriter:"Client",ExpiresAt:i??null};if(e==="Private")c.Private??={},c.Private[t]=d;else if(e==="Public")c.Public??={},c.Public[t]=d;else return;c.Version=(c.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 s=this.currentState.CustomData;if(e==="Private")s.Private&&delete s.Private[t];else if(e==="Public")s.Public&&delete s.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 s=this.ensureBoard();s.BuildingStates??=[];let r=s.BuildingStates.find(i=>i.SlotIndex===e);r||(r={SlotIndex:e},s.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 s=this.ensureBoard().Pending;!s||s.Type.toUpperCase()!=="SPECIAL"||(s.Special??={},e(s.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 Nt=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 jt=class{user;config;constructor(e){this.user=new Gt(e),this.config=new Nt;}reset(){this.user.clear(),this.config.applyTitlePublicConfiguration(null);}};var Ft=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 ru(e)?e:ue.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 ru(a){return a!==null&&Object.values(ue).includes(a)}var iu=8,nu=100,ou=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i,an=["GameLoop"],Vt=class{constructor(e){this.ctx=e;}ctx;authContext=null;refreshing=false;rememberSession=true;sessionAuthType=ue.None;sessionEmail="";sessionPassword="";get context(){return this.authContext}get isLoggedIn(){return this.authContext!==null&&this.authContext.userID.length>0&&this.authContext.clientSessionTicket.length>0}get lastAuthType(){return this.ctx.authStore.lastAuthType}setRememberSession(e){this.rememberSession=e;}get remembersSession(){return this.rememberSession}baseRequest(){return {BuildKey:this.ctx.settings.buildKey,WebAppLink:this.ctx.platform.getFullURL()}}async loginWithDeviceID(){this.ctx.emitter.emit("auth:requestSent",void 0);let e=this.baseRequest();e.DeviceID=this.ctx.platform.getDeviceID(),e.Device=this.ctx.platform.getDeviceModel(),e.Platform=this.ctx.platform.getPlatform();let t=await this.ctx.api.authentication.loginWithDeviceID(e);return t.ok?(this.applyAuthContext(t.data),this.fetchAndApplyClientState(ue.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 s=await this.ctx.api.authentication.loginWithTelegram(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Telegram)):s}async loginWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t;let r=await this.ctx.api.authentication.loginWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async registerWithEmail(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();s.Email=e,s.Password=t,s.DeviceID=this.ctx.platform.getDeviceID(),s.Device=this.ctx.platform.getDeviceModel(),s.Platform=this.ctx.platform.getPlatform();let r=await this.ctx.api.authentication.registerWithEmail(s);if(!r.ok)return r;this.applyAuthContext(r.data);let i=await this.fetchAndApplyClientState(ue.Email);return i.ok&&this.keepEmailCredentials(e,t),i}async loginWithGoogle(e){this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.GoogleIDToken=e;let s=await this.ctx.api.authentication.loginWithGoogle(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.Google)):s}async requestWalletChallenge(e,t){this.ctx.emitter.emit("auth:requestSent",void 0);let s=this.baseRequest();return s.WalletAddress=e,s.NetworkID=t,this.ctx.api.authentication.requestWalletChallenge(s)}async loginWithWallet(e,t,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();r.WalletAddress=e,r.NetworkID=t,r.WalletSignature=s,r.Platform=this.ctx.platform.getPlatform(),r.Device=this.ctx.platform.getDeviceModel(),r.DeviceID=this.ctx.platform.getDeviceID();let i=await this.ctx.api.authentication.loginWithWallet(r);return i.ok?(this.applyAuthContext(i.data),this.fetchAndApplyClientState(ue.Wallet)):i}async loginWithPlatformToken(e){if(!e)return n("client","AuthToken is null or empty.");this.ctx.emitter.emit("auth:requestSent",void 0);let t=this.baseRequest();t.PlatformAuthToken=e,t.DeviceID=this.ctx.platform.getDeviceID(),t.Device=this.ctx.platform.getDeviceModel(),t.Platform=this.ctx.platform.getPlatform();let s=await this.ctx.api.authentication.loginWithPlatformToken(t);return s.ok?(this.applyAuthContext(s.data),this.fetchAndApplyClientState(ue.iDosGames)):s}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,s){this.ctx.emitter.emit("auth:requestSent",void 0);let r=this.baseRequest();return r.Email=e,r.ResetToken=t,r.Password=s,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,s){switch(e){case ue.Email:return this.loginWithEmail(t,s);case ue.Device:case ue.None:return this.loginWithDeviceID();case ue.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!==ue.None?this.sessionAuthType:this.ctx.authStore.lastAuthType;if(e===ue.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&&ou.test(e)}static isValidPasswordLength(e){return e.length>=iu&&e.length<=nu}keepEmailCredentials(e,t){this.sessionEmail=e,this.sessionPassword=t,this.rememberSession&&this.ctx.authStore.saveEmailAndPassword(e,t);}forgetSession(){this.sessionAuthType=ue.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(an,an);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 au="idos:cfg",pt=class{constructor(e,t){this.storage=e;this.titleId=t;}storage;titleId;static scopeOf(e,t){return t&&t.length>0?`x:${ln(t)}`:e&&e.length>0?`f:${ln(e)}`:t?"x:":"f:"}async read(e){try{let t=await this.storage.get(this.keyOf(e));if(!t)return null;let s=JSON.parse(t);return !s||typeof s!="object"||typeof s.v!="string"||!s.c?null:s}catch{return null}}async write(e,t,s){try{let r={v:t,c:s};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 `${au}:${this.titleId}:${e}`}};function ln(a){return [...a].map(e=>e.toLowerCase()).sort().join(",")}var lu="idos:state",_t=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 s=JSON.parse(t);return !s||typeof s!="object"||typeof s.e!="string"||!s.v||!s.s?null:s}catch{return null}}async write(e,t,s,r){if(!(!e||!t))try{let i={e:t,v:s,s:r};await this.storage.set(this.keyOf(e),JSON.stringify(i));}catch{}}keyOf(e){return `${lu}:${this.titleId}:${e}`}};function un(a,e){if(!a)return;let t=new Set((e??[]).map(r=>r.trim().toLowerCase()));if(t.size===0)return a;let s={};for(let[r,i]of Object.entries(a))t.has(r.toLowerCase())||(s[r]=i);return s}function Fr(a,e,t,s){let r={...a??{}};if(!e||!t||!s)return r;for(let[i,c]of Object.entries(t))s[i]===c&&i in e&&(r[i]=e[i]);return r}function cn(a){return {...a??{}}}function pn(a,e,t,s){let r={...a??{}},i={...e??{}};for(let[c,d]of Object.entries(s??{}))r[c]=t[c],i[c]=d;return {state:r,versions:i}}function Vr(a){return typeof a.StateEpoch=="string"&&a.StateEpoch.length>0?a.StateEpoch:null}var dn=n("server","Title configuration is unavailable (CDN and API both failed)."),Wt=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:d()}:null}get configCache(){return this.cache??=new pt(this.ctx.settings.configStorage,this.ctx.settings.titleID)}cache;get stateCache(){return this.userStateCache??=new _t(this.ctx.settings.configStorage,this.ctx.settings.titleID)}userStateCache;async getClientState(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=pt.scopeOf(e.TitleFields,null),s=await this.configCache.read(t);s&&(e.KnownTitleConfigVersion=s.v);let r=await this.prepareStateHandshake(e,null),i=await this.ctx.api.user.getClientState(e);if(!i.ok)return i;let c=await this.resolveTitleConfig(i.data,t,s,{Fields:e.TitleFields});return c==null?dn:(await this.finishStateHandshake(i.data,r),await this.applyClientState(i.data,c,void 0,void 0),i)}async prepareStateHandshake(e,t){let s=this.ctx.auth.context?.userID;if(!s)return {userId:null,cached:null,sent:void 0};let r=await this.stateCache.read(s);if(!r)return {userId:s,cached:null,sent:void 0};let i=un(r.v,t);return i&&Object.keys(i).length>0&&(e.KnownStateVersions=i,e.KnownStateEpoch=r.e),{userId:s,cached:r,sent:i}}async finishStateHandshake(e,t){let s=Fr(e.User,t.cached?.s,t.sent,e.StateVersions);e.User=s;let r=Vr(e);!r||!t.userId||await this.stateCache.write(t.userId,r,cn(e.StateVersions),s);}async resolveTitleConfig(e,t,s,r){let i=e.TitleConfigVersion;if(s&&i&&s.v===i)return s.c;if(e.TitleConfigUrl){let d=await this.fetchConfigFromCdn(e.TitleConfigUrl);if(d!=null)return i&&await this.configCache.write(t,i,d),d}let c=await this.fetchConfigFromApi(r);return c!=null?(i&&await this.configCache.write(t,i,c),c):s?.c??null}async fetchConfigFromCdn(e){try{let t=await this.ctx.fetchImpl(e);if(!t.ok)return null;let s=await t.json();return s&&typeof s=="object"?s:null}catch{return null}}async fetchConfigFromApi(e){let t=this.baseRequest();if(!t)return null;let s={...t,...e},r=e.ExcludeFields?await this.ctx.api.title.getTitlePublicConfigurationExcept(s):await this.ctx.api.title.getTitlePublicConfiguration(s);return r.ok?r.data:null}async getClientStateExcept(e,t){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ExcludeFields=e,s.ExcludeTitleFields=t;let r=pt.scopeOf(null,t??[]),i=await this.configCache.read(r);i&&(s.KnownTitleConfigVersion=i.v);let c=await this.prepareStateHandshake(s,e??null),d=await this.ctx.api.user.getClientStateExcept(s);if(!d.ok)return d;let z=await this.resolveTitleConfig(d.data,r,i,{ExcludeFields:t??[]});return z==null?dn:(await this.finishStateHandshake(d.data,c),await this.applyClientState(d.data,z,e,t),d)}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 s=await this.prepareStateHandshake(t,null),r=await this.ctx.api.user.getUserState(t);if(!r.ok)return r;let i=Fr(r.data.User,s.cached?.s,s.sent,r.data.StateVersions);r.data.User=i;let c=Object.keys(r.data.StateVersions??{});this.ctx.data.user.applyUserStateContainers(i,c);let d=Vr(r.data);if(d&&s.userId){let z=s.cached?.e===d?s.cached:null,B=pn(z?.s,z?.v,i,r.data.StateVersions);await this.stateCache.write(s.userId,d,B.versions,B.state);}return r}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,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.UsageTime=e,r.IsNewSession=t,r.SessionDurationSeconds=s;let i=await this.ctx.api.user.addUsageTime(r);return i.ok&&this.ctx.emitter.emit("user:usageTimeAdded",i.data),i}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 s=await this.ctx.api.user.changeUsername(t);return s.ok&&this.ctx.emitter.emit("user:usernameChanged",s.data),s}async applyClientState(e,t,s,r){let i=s?.includes("GameLoop")===true,c=r?.includes("GameLoop")===true,d=i?this.ctx.data.user.state?.GameLoop:void 0,z=c?this.ctx.data.config.titlePublicConfiguration?.GameLoop:void 0;this.ctx.data.config.applyTitlePublicConfiguration(t),this.ctx.data.user.applyUserState(e.User??{});let B=this.ctx.data.user.state;i&&B&&B.GameLoop==null&&(B.GameLoop=d);let w=this.ctx.data.config.titlePublicConfiguration;c&&w&&w.GameLoop==null&&(w.GameLoop=z),this.ctx.emitter.emit("user:clientStateReceived",e);}};var Ht=class{constructor(e){this.ctx=e;}ctx;async convert(e,t,s,r,i,c){if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(i<=0)return n("client","Amount must be positive.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Crypto||s===qe.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 d$1={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:String(Math.trunc(i)),TransactionID:c&&c.length>0?c:`convert_${e}_${t}_to_${s}_${r}_${d()}`},z=await this.ctx.api.currency.convert(d$1);if(z.ok){let B=z.data,w={Consume:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.SourceID,Amount:B.SourceSpent}]}},Grant:{Standard:{Entries:[{Type:"VirtualCurrency",CurrencyID:B.TargetID,Amount:B.TargetCredited}]}}};this.ctx.data.user.applyResourceOperation(w,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("currency:converted",B);}return z}async cryptoConvert(e,t,s,r,i,c){let d$1=i instanceof Lt?i:new Lt(i);if(!t)return n("client","SourceID is required.");if(!r)return n("client","TargetID is required.");if(d$1.lte(0))return n("client","SourceAmount must be a positive decimal.");if(e===s&&t===r)return n("client","Source and target must differ.");if(e===qe.Virtual&&s===qe.Virtual)return n("client","cryptoConvert requires at least one crypto side. Use convert for VC\u2194VC.");if(e===qe.Virtual&&!d$1.isInteger())return n("client","Virtual currency source amount must be integer.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),SourceType:e,SourceID:t,TargetType:s,TargetID:r,SourceAmount:d$1.toString(),TransactionID:c&&c.length>0?c:`crypto_convert_${e}_${t}_to_${s}_${r}_${d()}`},B=await this.ctx.api.currency.cryptoConvert(z);if(B.ok){let w=B.data,me=[],ge=[];if(w.SourceType===qe.Virtual&&me.push({Type:"VirtualCurrency",CurrencyID:w.SourceID,Amount:Math.trunc(Number(w.SourceSpent))}),w.TargetType===qe.Virtual&&ge.push({Type:"VirtualCurrency",CurrencyID:w.TargetID,Amount:Math.trunc(Number(w.TargetCredited))}),me.length>0||ge.length>0){let Ie={Consume:me.length>0?{Standard:{Entries:me}}:null,Grant:ge.length>0?{Standard:{Entries:ge}}:null};this.ctx.data.user.applyResourceOperation(Ie,this.ctx.data.config.itemDefinitions);}w.SourceType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(w.SourceID,new Lt(w.SourceSpent).negated(),w.ServerTimeUtc),w.TargetType===qe.Crypto&&this.ctx.data.user.patchCryptoCurrencyDelta(w.TargetID,new Lt(w.TargetCredited),w.ServerTimeUtc),this.ctx.emitter.emit("currency:cryptoConverted",w);}return B}};var Kt=class{constructor(e){this.ctx=e;}ctx;async upgradeLevel(e,t){let s=e.trim();if(!s)return n("client","ItemInstanceID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ItemInstanceID:s,RelatedEntityID:`upgrade_item_${s}_${d()}`};t&&t.length>0&&(r.FodderInstanceIDs=[...t]);let i=await this.ctx.api.item.upgradeLevel(r);return i.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelUpgraded",i.data)),i}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},s=await this.ctx.api.item.upgradeLevelsBatch(t);return s.ok&&(await this.ctx.userService.getUserInventory(),this.ctx.emitter.emit("item:levelsUpgradedBatch",s.data)),s}};var uu="Store",$t=class{constructor(e){this.ctx=e;}ctx;async purchase(e,t=1){if(!e)return n("client","OfferID is required.");if(t<1)return n("client","Count must be at least 1.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),OfferID:e,Count:t,RelatedEntityID:`store_buy_${e}_${s.userID}_${d()}`},i=await this.ctx.api.store.purchase(r);if(i.ok){let c=i.data;this.ctx.data.user.patchStorePurchase(e,t,c.ServerTimeUtc),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("store:offerPurchased",c);}return i}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},s=await this.ctx.api.store.purchaseBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||!i.Data.OfferID||(this.ctx.data.user.patchStorePurchase(i.Data.OfferID,i.Data.Count,i.Data.ServerTimeUtc),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("store:offersPurchasedBatch",s.data);}return s}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(uu,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 cu="Lootbox",Zt=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 s=t.data.LootboxDefinitions;s&&(this.ctx.data.config.patchSection(cu,s),this.ctx.emitter.emit("lootbox:definitionsLoaded",s));}return t}async open(e,t,s){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 r={...this.ctx.buildAuthedBaseRequest(),LootboxID:e,Count:t,SelectedOptionID:s,RelatedEntityID:`lootbox_${e}_${s}_${d()}`},i=await this.ctx.api.lootbox.open(r);if(i.ok){let c=i.data;c.TriggeredPity&&c.TriggeredPity.length>0&&this.ctx.data.user.applyLootboxPityTriggers(e,c.TriggeredPity,t),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.applyInventoryDelta(c.Inventory),this.ctx.emitter.emit("lootbox:opened",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var pu="Reward";function _r(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var Jt=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 s=t.data.RewardDefinitions;s&&(this.ctx.data.config.patchSection(pu,s),this.ctx.emitter.emit("reward:definitionsLoaded",s));}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 s=t.data;this.multiplierEnabled=s.Enabled,this.multiplier=s.Enabled?s.Multiplier??1:1,this.ctx.emitter.emit("reward:milestoneMultiplierLoaded",s);}return t}async claimDailyReward(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CalendarID:e,RelatedEntityID:`dailyreward_${t.userID}_${e??"default"}_${d()}`},r=await this.ctx.api.reward.claimDailyReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchDailyCalendarState(i.CalendarID,i.DailyState),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("reward:dailyClaimed",i);}return r}async collectIdleAccrual(e){if(!_r(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}_${d()}`},s=await this.ctx.api.reward.collectIdleAccrual(t);if(s.ok){let r=s.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 s}async claimComebackReward(e){if(!_r(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}_${d()}`},s=await this.ctx.api.reward.claimComebackReward(t);if(s.ok){let r=s.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 s}async claimReward(e){if(!_r(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}_${d()}`},s=await this.ctx.api.reward.claimReward(t);if(s.ok){let r=s.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 s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var du="Quest",Yt=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(du,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 s=await this.ctx.api.quest.getUserQuestState(t);if(s.ok){let r=s.data.State??{};this.ctx.data.user.applyQuest(r),this.ctx.data.user.patchQuestPointsTracks(s.data.PointsTracks),this.ctx.emitter.emit("quest:userStateLoaded",r);}return s}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 s=e.trim();if(!s)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,i={...this.ctx.buildAuthedBaseRequest(),QuestID:s,CycleID:r,RelatedEntityID:`quest_claim_${r??""}_${s}_${d()}`},c=await this.ctx.api.quest.claimQuestReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchQuestStatus(d.QuestID,d.CycleID,"Claimed"),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:rewardClaimed",d);}return c}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},s=await this.ctx.api.quest.claimQuestRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchQuestStatus(i.Data.QuestID,i.Data.CycleID,"Claimed"),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:rewardsClaimedBatch",s.data);}return s}async claimMilestoneReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and MilestoneID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,MilestoneID:r,RelatedEntityID:`milestone_claim_${s}_${r}_${d()}`},c=await this.ctx.api.quest.claimMilestoneReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchMilestoneClaimed(d.CycleID,d.MilestoneID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:milestoneClaimed",d);}return c}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},s=await this.ctx.api.quest.claimMilestoneRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!i.Success||!i.Data||(this.ctx.data.user.patchMilestoneClaimed(i.Data.CycleID,i.Data.MilestoneID),!r&&i.Data.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true));this.ctx.emitter.emit("quest:milestonesClaimedBatch",s.data);}return s}async claimGroupCompletionReward(e,t){let s=e.trim(),r=t.trim();if(!s||!r)return n("client","CycleID and GroupCompletionID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let i={...this.ctx.buildAuthedBaseRequest(),CycleID:s,GroupCompletionID:r,RelatedEntityID:`group_completion_${s}_${r}_${d()}`},c=await this.ctx.api.quest.claimGroupCompletionReward(i);if(c.ok){let d=c.data;this.ctx.data.user.patchGroupCompletionClaimed(d.CycleID,d.GroupCompletionID),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("quest:groupCompletionClaimed",d);}return c}async addQuestProgress(e,t){let s=e.trim();if(!s)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:s,ProgressValue:t},i=await this.ctx.api.quest.addQuestProgress(r);return i.ok&&(this.ctx.data.user.patchQuestProgressUpdates(i.data.Updates),this.ctx.emitter.emit("quest:progressAdded",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var hu="TimedEvent",Xt=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(hu,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,s,r,i,c,d=1){if(!t)return n("client","LteID is required.");if(!s)return n("client","SourceType is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),Type:e,LteID:t,SourceType:s,Outcome:r,AmountOverride:i,SourceParams:c,RollMultiplier:d},B=await this.ctx.api.timedEvent.grantTokens(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensGranted",B.data)),B}async spendTokens(e,t,s){if(!t)return n("client","LteID is required.");if(s<=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:s},i=await this.ctx.api.timedEvent.spendTokens(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedEvent:tokensSpent",i.data)),i}async claimMilestone(e,t,s){if(!t||!s)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:s},i=await this.ctx.api.timedEvent.claimMilestone(r);if(i.ok){let c=i.data;this.ctx.data.user.applyResourceOperation(c.Rewards,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchTimedEventMilestoneClaimed(e,t,s),this.ctx.emitter.emit("timedEvent:milestoneClaimed",c);}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},s=await this.ctx.api.timedEvent.claimMilestonesBatch(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:milestonesClaimedBatch",s.data)),s}async claimAllMilestones(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");e&&e.length>0&&(t.Events=e);let s=await this.ctx.api.timedEvent.claimAllMilestones(t);return s.ok&&(this.applyMilestoneClaimBatch(s.data),this.ctx.emitter.emit("timedEvent:allMilestonesClaimed",s.data)),s}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},s=await this.ctx.api.timedEvent.spendTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensSpentBatch",s.data);}return s}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},s=await this.ctx.api.timedEvent.grantTokensBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("timedEvent:tokensGrantedBatch",s.data);}return s}applyMilestoneClaimBatch(e){let t=false;for(let s of e){if(!s.Success||!s.Data)continue;let r=s.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 mu="Leaderboard",es=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(mu,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 s=await this.ctx.api.leaderboard.getLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loaded",s.data),s}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 s=await this.ctx.api.leaderboard.getMyProgress(t);return s.ok&&(this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(e),s.data),this.ctx.emitter.emit("leaderboard:myProgressLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,Score:t},r=await this.ctx.api.leaderboard.submitScore(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),i.NewScore,t,i.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",i);}return r}async submitScoreFromSource(e,t,s,r,i=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 c={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,SourceType:t,Outcome:s,Params:r,RollMultiplier:i},d=await this.ctx.api.leaderboard.submitScoreFromSource(c);if(d.ok){let z=d.data;this.ctx.data.user.patchLeaderboardScoreSubmitted(this.cycleDocID(e),z.NewScore,z.NewScore,z.CycleVersion),this.ctx.emitter.emit("leaderboard:scoreSubmitted",z);}return d}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},s=await this.ctx.api.leaderboard.claimCycleReward(t);if(s.ok){let r=s.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 s}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 s={...this.ctx.buildAuthedBaseRequest(),LeaderboardID:e,MilestoneID:t},r=await this.ctx.api.leaderboard.claimMilestone(s);if(r.ok){let i=r.data;this.ctx.data.user.patchLeaderboardMilestoneClaimed(this.cycleDocID(e),t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("leaderboard:milestoneClaimed",i);}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 s=await this.ctx.api.leaderboard.getFriendsLeaderboard(t);return s.ok&&this.ctx.emitter.emit("leaderboard:friendsLoaded",s.data),s}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 s=await this.ctx.api.leaderboard.getLeaderboardsBatch(t);return s.ok&&this.ctx.emitter.emit("leaderboard:loadedBatch",s.data),s}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 s=await this.ctx.api.leaderboard.getProgressBatch(t);if(s.ok){for(let r of s.data)!r.Success||!r.Data||this.ctx.data.user.patchLeaderboardMyProgress(this.cycleDocID(r.Data.LeaderboardID),r.Data);this.ctx.emitter.emit("leaderboard:myProgressLoadedBatch",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimCycleRewardsBatch(t);if(s.ok){for(let r of s.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",s.data);}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},s=await this.ctx.api.leaderboard.claimMilestonesBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.submitScoresBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}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},s=await this.ctx.api.leaderboard.claimAllRewardsBatch(t);if(s.ok){for(let r of s.data){let i=this.cycleDocID(r.LeaderboardID);r.CycleReward?.Success&&r.CycleReward.Data&&(this.ctx.data.user.patchLeaderboardCycleRewardClaimed(i),r.CycleReward.Data.Resources&&this.ctx.data.user.applyResourceOperation(r.CycleReward.Data.Resources,this.ctx.data.config.itemDefinitions));for(let c of r.Milestones??[])!c.Success||!c.Data||(this.ctx.data.user.patchLeaderboardMilestoneClaimed(i,c.Data.MilestoneID),c.Data.Resources&&this.ctx.data.user.applyResourceOperation(c.Data.Resources,this.ctx.data.config.itemDefinitions));}this.ctx.emitter.emit("leaderboard:allRewardsClaimedBatch",s.data);}return s}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 s=await this.ctx.api.leaderboard.getOverviewBatch(t);if(s.ok){for(let r of s.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",s.data);}return s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var fu="Season",ts=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(fu,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 s=await this.ctx.api.season.getActiveSeason(t);return s.ok&&(s.data.UserState&&this.ctx.data.user.patchSeasonState(e,s.data.UserState),this.ctx.emitter.emit("season:activeLoaded",s.data)),s}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 s=await this.ctx.api.season.getUserState(t);return s.ok&&(this.ctx.data.user.patchSeasonState(e,s.data),this.ctx.emitter.emit("season:userStateLoaded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,Amount:t,RelatedEntityID:`season_grant_${e}_${d()}`},r=await this.ctx.api.season.grantStatusTokens(s);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 s={...this.ctx.buildAuthedBaseRequest(),SeasonChainID:e,TierNumber:t,RelatedEntityID:`season_tier_${e}_t${t}_${d()}`},r=await this.ctx.api.season.claimTierReward(s);if(r.ok){let i=r.data;this.ctx.data.user.patchSeasonClaimedTier(e,t),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("season:tierRewardClaimed",i);}return r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var gu="Premium",ss=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(gu,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 s={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,RelatedEntityID:`premium_trial_${e}_${t}`},r=await this.ctx.api.premium.activateTrial(s);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,s="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 i={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,SelectedOptionID:s,Count:r,RelatedEntityID:`premium_purchase_${e}_${t}`},c=await this.ctx.api.premium.purchaseItemOrCurrency(i);if(c.ok){let d=c.data;d.Premium&&this.ctx.data.user.applyPremium(d.Premium),this.ctx.data.user.applyResourceOperation(d.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("premium:purchaseCompleted",d);}return c}async purchaseRealMoney(e,t,s,r,i,c,d,z){if(!e||!t)return n("client","PremiumID and TransactionID are required.");if(!r||!i)return n("client","ProductID and ReceiptData are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let B={...this.ctx.buildAuthedBaseRequest(),PremiumID:e,TransactionID:t,Store:s,ProductID:r,ReceiptData:i,PurchaseToken:c,PackageName:d,AppStoreEnvironment:z,RelatedEntityID:`premium_iap_${e}_${t}`},w=await this.ctx.api.premium.purchaseRealMoney(B);if(w.ok){let me=w.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 w}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ru="Character",rs=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(Ru,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 s=t.data.Characters??{};this.ctx.data.user.applyCharacter(s),this.ctx.emitter.emit("character:userCharactersLoaded",s);}return t}async unlockCharacter(e){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`unlock_char_${e}_${d()}`},s=await this.ctx.api.character.unlockCharacter(t);if(s.ok){let r=s.data;this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(r.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:unlocked",r);}return s}async upgradeStatLevel(e,t,s){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}_${d()}`,...s?.levels!=null?{Levels:s.levels}:{},...s?.targetLevel!=null?{TargetLevel:s.targetLevel}:{}},i=await this.ctx.api.character.upgradeStatLevel(r);if(i.ok){let c=i.data;this.ctx.data.user.patchCharacter(c.CharacterID,d=>{d.StatLevels??={},d.StatLevels[c.StatID]=c.StatLevel,c.Power!=null&&(d.Power=c.Power),d.UpdatedAt=c.ServerTimeUtc;}),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:statLevelUpgraded",c);}return i}async upgradeCharacterLevel(e,t){if(!e)return n("client","CharacterID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,RelatedEntityID:`upgrade_char_${e}_${d()}`,...t?.levels!=null?{Levels:t.levels}:{},...t?.targetLevel!=null?{TargetLevel:t.targetLevel}:{}},r=await this.ctx.api.character.upgradeCharacterLevel(s);if(r.ok){let i=r.data;this.ctx.data.user.patchCharacter(i.CharacterID,c=>{c.Level=i.NewLevel,i.Power!=null&&(c.Power=i.Power),c.UpdatedAt=i.ServerTimeUtc,i.NewLevel===1&&(c.StatLevels??={},c.Equipment??={});}),this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("character:levelUpgraded",i);}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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,ItemsToEquip:t},r=await this.ctx.api.character.equipItems(s);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 s={...this.ctx.buildAuthedBaseRequest(),CharacterID:e,UnequipSlotIDs:t},r=await this.ctx.api.character.unequipItems(s);if(r.ok){let i=r.data;this.applyUnequipChangesLocally(e,i),this.ctx.emitter.emit("character:itemsUnequipped",{characterID:e,slotIDs:i.ClearedSlotIDs??[],power:i.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},s=await this.ctx.api.character.unlockCharactersBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.Equipment??={},r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:charactersUnlocked",s.data)),s}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},s=await this.ctx.api.character.upgradeCharacterLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.Level=r.NewLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc,r.NewLevel===1&&(i.StatLevels??={},i.Equipment??={});});}),this.ctx.emitter.emit("character:levelsUpgraded",s.data)),s}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},s=await this.ctx.api.character.upgradeStatLevelsBatch(t);return s.ok&&(this.applyBatchResults(s.data,r=>{this.ctx.data.user.patchCharacter(r.CharacterID,i=>{i.StatLevels??={},i.StatLevels[r.StatID]=r.StatLevel,r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=r.ServerTimeUtc;});}),this.ctx.emitter.emit("character:statLevelsUpgraded",s.data)),s}applyBatchResults(e,t){e.Resources&&this.ctx.data.user.applyResourceOperation(e.Resources,this.ctx.data.config.itemDefinitions);for(let s of e.Items??[])!s.Success||!s.Data||t(s.Data);}applyInventoryDelta(e){this.ctx.data.user.applyInventoryDelta(e);}applyEquipChangesLocally(e,t){let s=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let[r,i]of Object.entries(t.Equipment??{}))s.patchCharacterEquipment(e,r,i);s.patchCharacter(e,r=>{t.Power!=null&&(r.Power=t.Power),r.UpdatedAt=t.ServerTimeUtc;});}applyUnequipChangesLocally(e,t){let s=t.ClearedSlotIDs??[];if(s.length===0&&t.Power==null)return;let r=this.ctx.data.user;this.applyInventoryDelta(t.Inventory);for(let i of s)r.patchCharacterEquipment(e,i,null);r.patchCharacter(e,i=>{t.Power!=null&&(i.Power=t.Power),i.UpdatedAt=t.ServerTimeUtc;});}applyUnequipAllLocally(e){let t=this.ctx.data.user;this.applyInventoryDelta(e.Inventory);for(let[s,r]of Object.entries(e.Characters??{})){for(let i of r.ClearedSlotIDs??[])t.patchCharacterEquipment(s,i,null);t.patchCharacter(s,i=>{r.Power!=null&&(i.Power=r.Power),i.UpdatedAt=e.ServerTimeUtc;});}}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var yu="Match",is=class{constructor(e){this.ctx=e;}ctx;async createMatch(e,t,s,r,i){let c=this.ctx.auth.context;if(!c)return n("unauthorized","Not logged in.");let d$1={...this.ctx.buildAuthedBaseRequest(),Entry:e,RuleID:t,CharacterID:s,BattleStrategy:r,TargetUserID:i,RelatedEntityID:`pvp_create_${c.userID}_${d()}`},z=await this.ctx.api.match.createMatch(d$1);return z.ok&&(this.ctx.data.user.applyResourceOperation(z.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:created",z.data)),z}async updateMatch(e,t={}){if(!e)return n("client","MatchID is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...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(s);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},s=await this.ctx.api.match.cancelMatch(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("match:cancelled",s.data)),s}async instantBattle(e,t,s,r){let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),MatchID:e,RuleID:t,CharacterID:s,BattleStrategy:r,RelatedEntityID:`pvp_battle_${e}_${d()}`},d$1=await this.ctx.api.match.instantBattle(c);if(d$1.ok){let z=d$1.data,B=this.ctx.data.config.itemDefinitions;if(z.Resources)this.ctx.data.user.applyResourceOperation(z.Resources,B);else if(z.ResourcesDual){let w=z.ResourcesDual;w.FromUserID===i.userID&&w.FromResult?this.ctx.data.user.applyResourceOperation(w.FromResult,B):w.ToUserID===i.userID&&w.ToResult&&this.ctx.data.user.applyResourceOperation(w.ToResult,B);}this.ctx.emitter.emit("match:instantBattleCompleted",z);}return d$1}async saveStrategy(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),BattleStrategy:e},s=await this.ctx.api.match.saveStrategy(t);return s.ok&&(this.ctx.data.user.patchMatchStrategy(e),this.ctx.emitter.emit("match:strategySaved",e)),s}async getMyMatches(e=0,t=20,s){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.Statuses=s;let i=await this.ctx.api.match.getMyMatches(r);return i.ok&&this.ctx.emitter.emit("match:myMatchesLoaded",i.data),i}async getAvailableMatches(e=0,t=20,s=false){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.Page=e,r.PageSize=t,r.OnlyPublic=s;let i=await this.ctx.api.match.getAvailableMatches(r);return i.ok&&this.ctx.emitter.emit("match:availableMatchesLoaded",i.data),i}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(yu,t.data),this.ctx.emitter.emit("match:definitionsLoaded",t.data)),t}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Cu="Craft",ns=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(Cu,t.data.CraftDefinitions),this.ctx.emitter.emit("craft:definitionsLoaded",t.data.CraftDefinitions)),t}async craft(e,t,s=1,r){if(!e)return n("client","CraftID is required.");let i=this.ctx.auth.context;if(!i)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),CraftID:e,InputItemIDs:t,Count:s,SelectedOptionID:r,RelatedEntityID:`craft_${e}_${i.userID}_${d()}`},d$1=await this.ctx.api.craft.craft(c);return d$1.ok&&(this.ctx.data.user.applyResourceOperation(d$1.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("craft:completed",d$1.data)),d$1}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Su="Collection",os=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(Su,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){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,PackTypeID:t,RelatedEntityID:`open_pack_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.openPack(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:packOpened",i.data)),i}async openCollectionChest(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectionChestID:t,RelatedEntityID:`open_chest_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.openCollectionChest(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:chestOpened",i.data)),i}async useCollectibleJoker(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:false,RelatedEntityID:`use_joker_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.useCollectibleJoker(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:jokerUsed",i.data)),i}async claimSetReward(e,t){let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,SetID:t,RelatedEntityID:`claim_set_${e}_${t}_${s.userID}_${d()}`},i=await this.ctx.api.collection.claimSetReward(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("collection:setRewardClaimed",i.data)),i}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},s=await this.ctx.api.collection.claimSetRewardsBatch(t);if(s.ok){let r=false;for(let i of s.data)!r&&i.Success&&i.Data?.Resources&&(this.ctx.data.user.applyResourceOperation(i.Data.Resources,this.ctx.data.config.itemDefinitions),r=true);this.ctx.emitter.emit("collection:setRewardsClaimedBatch",s.data);}return s}async claimGrandPrize(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,RelatedEntityID:`grand_prize_${e}_${t.userID}_${d()}`},r=await this.ctx.api.collection.claimGrandPrize(s);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,s,r,i,c=false){let d$1=this.ctx.auth.context;if(!d$1)return n("unauthorized","Not logged in.");let z={...this.ctx.buildAuthedBaseRequest(),CollectionID:e,CollectibleID:t,CollectibleIsSpecial:s,ReceiverUserID:r,RequestedCollectibleID:i,RequestedCollectibleIsSpecial:c,RelatedEntityID:`trade_send_${d$1.userID}_${r}_${d()}`},B=await this.ctx.api.collection.sendTradeOffer(z);return B.ok&&this.ctx.emitter.emit("collection:tradeOfferSent",B.data),B}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}_${d()}`},s=await this.ctx.api.collection.cancelTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferCancelled",s.data),s}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}_${d()}`},s=await this.ctx.api.collection.acceptTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferAccepted",s.data),s}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}_${d()}`},s=await this.ctx.api.collection.declineTradeOffer(t);return s.ok&&this.ctx.emitter.emit("collection:tradeOfferDeclined",s.data),s}async getMyTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getMyTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:myTradeOffersLoaded",s.data),s}async getIncomingTradeOffers(e){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.CollectionID=e;let s=await this.ctx.api.collection.getIncomingTradeOffers(t);return s.ok&&this.ctx.emitter.emit("collection:incomingTradeOffersLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var xu="CoopEvent",as=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(xu,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 s=await this.ctx.api.coopEvent.getActiveEvent(t);return s.ok&&this.ctx.emitter.emit("coopEvent:activeEventLoaded",s.data),s}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 s=await this.ctx.api.coopEvent.getGroupState(t);return s.ok&&this.ctx.emitter.emit("coopEvent:groupStateLoaded",s.data),s}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},s=await this.ctx.api.coopEvent.joinOrCreateGroup(t);if(s.ok){let r=s.data.Group;r&&this.ctx.data.user.patchCoopEventActiveGroup(r.GroupID??null,r.CoopEventID??null,-1),this.ctx.emitter.emit("coopEvent:groupJoined",s.data);}return s}async spin(e,t){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,RelatedEntityID:d()},r=await this.ctx.api.coopEvent.spin(s);return r.ok&&(this.ctx.data.user.applyResourceOperation(r.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:spinCompleted",r.data)),r}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},s=await this.ctx.api.coopEvent.claimObjectReward(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("coopEvent:objectRewardClaimed",s.data)),s}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},s=await this.ctx.api.coopEvent.claimGrandPrize(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:grandPrizeClaimed",s.data)),s}async leaveGroup(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.coopEvent.leaveGroup(t);return s.ok&&(this.ctx.data.user.patchCoopEventActiveGroup(null,null,-1),this.ctx.emitter.emit("coopEvent:groupLeft",s.data)),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Du="DealOffer",ls=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(Du,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}_${d()}`},s=await this.ctx.api.dealOffer.dismissDeal(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:dealDismissed",s.data)),s}async executeNode(e,t,s){if(!e||!t)return n("client","SlotID and NodeID are required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let r=s&&s.trim().length>0?s.trim():void 0,i={...this.ctx.buildAuthedBaseRequest(),SlotID:e,NodeID:t,RelatedEntityID:r??`deal_exec_${e}_${t}_${d()}`},c=await this.ctx.api.dealOffer.executeNode(i);return c.ok&&(c.data.Idempotent||this.ctx.data.user.applyResourceOperation(c.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:nodeExecuted",c.data)),c}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}_${d()}`},s=await this.ctx.api.dealOffer.recordShow(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:showRecorded",s.data)),s}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 s={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneID:t,RelatedEntityID:`deal_milestone_${e}_${t}_${d()}`},r=await this.ctx.api.dealOffer.claimMilestone(s);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 s=[...new Set(t.map(c=>c.trim()).filter(c=>c.length>0))],r={...this.ctx.buildAuthedBaseRequest(),SlotID:e,MilestoneIDs:s,RelatedEntityID:`deal_milestone_batch_${e}_${d()}`},i=await this.ctx.api.dealOffer.claimMilestonesBatch(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("dealOffer:milestonesBatchClaimed",i.data)),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var bu="Referral",us=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(bu,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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),ReferralCode:t,RelatedEntityID:`referral_activation_${s.userID}`},i=await this.ctx.api.referral.activateReferralCode(r);if(i.ok){let c=i.data;c.ReferralCode&&this.ctx.data.user.patchReferralSubscription(c.ReferralCode),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:codeActivated",c);}return i}async claimInviteReward(e){let t=e.trim();if(!t)return n("client","InviteRewardID is required.");let s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),InviteRewardID:t,RelatedEntityID:`referral_invite_${t}_${s.userID}`},i=await this.ctx.api.referral.claimInviteReward(r);if(i.ok){let c=i.data;c.RewardID&&this.ctx.data.user.patchReferralInviteRewardClaimed(c.RewardID),this.ctx.data.user.applyResourceOperation(c.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("referral:inviteRewardClaimed",c);}return i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var cs=class{constructor(e){this.ctx=e;}ctx;async getFriendsList(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getFriendsList(e);return t.ok&&(this.ctx.data.user.applySocialFriendsList(t.data.Friends),this.ctx.emitter.emit("social:friendsListLoaded",t.data)),t}async getIncomingRequests(){let e=this.baseRequest();if(!e)return n("unauthorized","Not logged in.");let t=await this.ctx.api.social.getIncomingRequests(e);return t.ok&&(this.ctx.data.user.applySocialIncomingRequests(t.data.Friends),this.ctx.emitter.emit("social:incomingRequestsLoaded",t.data)),t}async getRecommendedFriends(e=5){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Limit=e;let s=await this.ctx.api.social.getRecommendedFriends(t);return s.ok&&this.ctx.emitter.emit("social:recommendedFriendsLoaded",s.data),s}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},s=await this.ctx.api.social.sendFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAddOutgoingRequest(e),this.ctx.emitter.emit("social:friendRequestSent",s.data)),s}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},s=await this.ctx.api.social.acceptFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialAcceptFriend(e),this.ctx.emitter.emit("social:friendRequestAccepted",s.data)),s}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},s=await this.ctx.api.social.declineFriendRequest(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveIncomingRequest(e),this.ctx.emitter.emit("social:friendRequestDeclined",s.data)),s}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},s=await this.ctx.api.social.removeFriend(t);return s.ok&&(this.ctx.data.user.patchSocialRemoveFriend(e),this.ctx.emitter.emit("social:friendRemoved",s.data)),s}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 zu="TimedBoost";function vu(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var ps=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(zu,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){let t=e.trim();if(!vu(t))return n("client",'BoostID is required and must not contain "." or "$".');if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BoostID:t,RelatedEntityID:`timed_boost_activate_${t}_${d()}`},r=await this.ctx.api.timedBoost.activate(s);if(r.ok){let i=r.data;if(i.ActivatedBoost){let c=i.StackingPolicy??"Replace";this.ctx.data.user.patchActiveTimedBoost(i.ActivatedBoost,c);}this.ctx.data.user.applyResourceOperation(i.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("timedBoost:activated",i);}return r}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 We={Private:"Private",Public:"Public",ReadOnly:"ReadOnly",Internal:"Internal"},Tu={Client:"Client",Server:"Server",System:"System"},Pu=z.enum(["Client","Server","System"]),Iu=z.object({Value:z.string().nullish(),UpdatedAt:l.nullish(),Version:z.number().nullish(),LastWriter:Pu.nullish(),ExpiresAt:l.nullish()}).passthrough(),ds=z.record(z.string(),Iu),hn=z.object({Version:z.number().nullish(),Private:ds.nullish(),Public:ds.nullish(),ReadOnly:ds.nullish()}),Wr=z.object({UserID:z.string().nullish(),Version:z.number().nullish(),Public:ds.nullish()}),Qr=z.object({ServerTimeUtc:l.nullish(),Bucket:z.string().nullish(),KeyID:z.string(),Version:z.number().nullish(),ExpiresAt:l.nullish()}),Mu=z.object({Bucket:z.string().nullish(),KeyID:z.string(),Version:z.number().nullish(),ExpiresAt:l.nullish()}),mn=z.object({ServerTimeUtc:l.nullish(),Results:z.array(Mu).nullish()}),fn=z.object({ServerTimeUtc:l.nullish(),DeletedCount:z.number().nullish()}),gn=z.object({Results:z.array(Wr).nullish(),NotFoundUserIDs:z.array(z.string()).nullish()}),ku={String:"String",Int:"Int",Bool:"Bool",Json:"Json"},Au=z.enum(["String","Int","Bool","Json"]),Uu=z.object({KeyID:z.string(),Bucket:z.string().nullish(),ValueType:Au.nullish(),MaxValueLengthBytes:z.number().nullish(),TtlSeconds:z.number().nullish(),DefaultValue:z.string().nullish(),Description:z.string().nullish()}).passthrough(),hs=z.object({Keys:z.record(z.string(),Uu).nullish(),DefaultMaxValueLengthBytes:z.number().nullish(),DefaultTtlSeconds:z.number().nullish(),MaxKeysPerBucket:z.number().nullish(),MaxTotalSizeBytes:z.number().nullish(),RejectUnregisteredKeys:z.boolean().nullish()}).passthrough(),Ge={GetUserCustomDataDefinitions:"GetUserCustomDataDefinitions",GetMyUserCustomData:"GetMyUserCustomData",GetPublicUserCustomDataOf:"GetPublicUserCustomDataOf",SetPrivateData:"SetPrivateData",SetPublicData:"SetPublicData",DeleteKey:"DeleteKey",BatchSet:"BatchSet",BatchDelete:"BatchDelete",BatchGetPublicUserCustomDataOf:"BatchGetPublicUserCustomDataOf"};var Ou="UserCustomData";function Rn(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}var ms=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(Ou,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TargetUserID=t;let r=await this.ctx.api.userCustomData.getPublicUserCustomDataOf(s);return r.ok&&this.ctx.emitter.emit("userCustomData:publicDataLoaded",r.data),r}async setPrivateData(e,t){return this.setData(e,t,We.Private)}async setPublicData(e,t){return this.setData(e,t,We.Public)}async setData(e,t,s){let r=e.trim();if(!Rn(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 i={...this.ctx.buildAuthedBaseRequest(),KeyID:r,Value:t},d=await(s===We.Private?this.ctx.api.userCustomData.setPrivateData(i):this.ctx.api.userCustomData.setPublicData(i));if(d.ok){let z=d.data;this.ctx.data.user.patchUserCustomDataKey(s,z.KeyID,t,z.Version??0,z.ExpiresAt),this.ctx.emitter.emit(s===We.Private?"userCustomData:privateDataSet":"userCustomData:publicDataSet",z);}return d}async deleteKey(e,t){let s=e.trim();if(!Rn(s))return n("client",'KeyID is required and must not contain "." or "$".');if(t!==We.Private&&t!==We.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:s,Bucket:t},i=await this.ctx.api.userCustomData.deleteKey(r);return i.ok&&(this.ctx.data.user.removeUserCustomDataKey(t,s),this.ctx.emitter.emit("userCustomData:keyDeleted",void 0)),i}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},s=await this.ctx.api.userCustomData.batchSet(t);if(s.ok){for(let r of s.data.Results??[]){let i=r.Bucket??We.Private,c=e.find(d=>d.Bucket===i&&d.KeyID===r.KeyID);c&&this.ctx.data.user.patchUserCustomDataKey(i,r.KeyID,c.Value,r.Version??0,r.ExpiresAt);}this.ctx.emitter.emit("userCustomData:batchSet",s.data);}return s}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},s=await this.ctx.api.userCustomData.batchDelete(t);if(s.ok){for(let r of e)this.ctx.data.user.removeUserCustomDataKey(r.Bucket,r.KeyID.trim());this.ctx.emitter.emit("userCustomData:batchDeleted",s.data);}return s}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 s=await this.ctx.api.userCustomData.batchGetPublicUserCustomDataOf(t);return s.ok&&this.ctx.emitter.emit("userCustomData:batchPublicDataLoaded",s.data),s}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Bu="TitleCustomDataDefinitions",yn=50;function wu(a){return a.length>0&&!a.includes(".")&&!a.includes("$")}function Hr(a){if(a.ExpiresAt==null)return false;let e=Date.parse(a.ExpiresAt);return !Number.isNaN(e)&&e<=Date.now()}function qu(a){let e={};for(let[t,s]of Object.entries(a))Hr(s)||(e[t]=s);return e}var fs=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(Bu,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 s=await this.ctx.api.titleCustomData.getPublicTitleData(t);return s.ok&&this.absorb(s.data),s}async getPublicTitleDataKeys(e){let t=e.map(i=>i.trim()).filter(i=>i.length>0);if(!t.length)return n("client","At least one KeyID is required.");if(t.some(i=>!wu(i)))return n("client",'KeyID must not contain "." or "$".');if(t.length>yn)return n("client",`At most ${yn} keys per call \u2014 request them in chunks.`);let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.KeyIDs=t;let r=await this.ctx.api.titleCustomData.getPublicTitleDataKeys(s);return r.ok&&this.ctx.emitter.emit("titleCustomData:publicDataLoaded",r.data),r}getValue(e){let t=this.runtimeCache[e];if(t?.Value!=null&&!Hr(t))return t.Value;let s=this.staticCache[e];if(s?.Value!=null&&!Hr(s))return s.Value}get runtimeVersion(){return this.lastRuntimeVersion}staticCache={};absorb(e){e.Static&&(this.staticCache=e.Static),e.NotModified?(this.runtimeCache=qu(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 gs=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 Eu=15,Lu="GameLoop",Gu="BoardDefinition",Rs=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(Lu,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 s=await this.ctx.api.gameLoop.getBoardDefinition(t,e);return s.ok&&(this.ctx.data.config.patchSection(Gu,s.data),this.ctx.emitter.emit("gameLoop:boardDefinitionLoaded",s.data)),s}async getBoardDefinitionForLevel(e,t=false){if(e<=0)return n("client","stageLevel must be > 0.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.StageLevel=e;let r=await this.ctx.api.gameLoop.getBoardDefinitionForLevel(s,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 s={...this.ctx.buildAuthedBaseRequest(),RollMultiplier:e,RelatedEntityID:`roll_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopRoll(s);if(r.ok){let i=r.data,c=nn(new Date,Eu);this.ctx.data.user.patchBoardState(d=>{d.Position=i.NewPosition,d.CyclesCompleted=(d.CyclesCompleted??0)+(i.CyclesCompletedDelta??0),d.LastRollAtUtc=new Date().toISOString(),i.ActionRequired&&i.ActionData?d.Pending={Type:i.ActionRequired,TargetUserID:i.ActionData.TargetUserID,TargetPublicData:i.ActionData.PublicData,TargetBuildingStates:i.ActionData.TargetBuildingStates??void 0,TargetHasShield:i.ActionData.TargetHasShield??void 0,RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c}:i.SpecialModeOffer&&(d.Pending={Type:"SPECIAL",RollMultiplier:i.UsedMultiplier??1,ExpiresAtUtc:c,Special:{ModeID:i.SpecialModeOffer.ModeID??void 0,Choices:i.SpecialModeOffer.Choices??void 0}});}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),i.ActionRequired==="RAID"&&await this.getUserBoardState(),this.ctx.emitter.emit("gameLoop:boardRolled",i);}return r}async boardLoopAttack(e=-1){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`attack_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopAttack(s);if(r.ok){let i=r.data;this.ctx.data.user.clearBoardPending(),i.IsBotTarget&&i.Operation?this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs):!i.IsBotTarget&&i.DualResult?.FromResult&&this.ctx.data.user.applyResourceOperation(i.DualResult.FromResult,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardAttacked",i);}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 s=this.ctx.auth.context;if(!s)return n("unauthorized","Not logged in.");let r={...this.ctx.buildAuthedBaseRequest(),DigIndex:e,RelatedEntityID:t??`raid_${s.userID}_${d()}`},i=await this.ctx.api.gameLoop.boardLoopRaid(r);if(i.ok){let c=i.data;c.Status==="CONTINUE"?this.ctx.data.user.patchBoardPendingRaidLayout(c.RaidLayout,c.OpenedIndex??-1):(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(c)),this.ctx.emitter.emit("gameLoop:boardRaided",c);}else await this.getUserBoardState();return i}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 s={...this.ctx.buildAuthedBaseRequest(),DigIndices:e,RelatedEntityID:`raidfast_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopRaidFast(s);if(r.ok){let i=r.data;i.Status!=="CONTINUE"&&(this.ctx.data.user.clearBoardPending(),this.applyRaidResources(i)),this.ctx.emitter.emit("gameLoop:boardRaidedFast",i);}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 s={...this.ctx.buildAuthedBaseRequest(),BuildingIndex:e,RelatedEntityID:`build_${t.userID}_${e}_${d()}`},r=await this.ctx.api.gameLoop.boardLoopBuild(s);if(r.ok){let i=r.data;i.StageComplete?this.ctx.data.user.patchBoardState(c=>{c.StageLevel=(c.StageLevel??1)+1,c.Position=0,c.Pending=null,c.BuildingStates=null;}):this.ctx.data.user.patchBoardBuilding(i.BuiltIndex,c=>{i.NewLevel!=null&&(c.Level=i.NewLevel),c.IsDamaged=false,i.MaxLevelRewardClaimed&&(c.MaxLevelRewardClaimed=true);}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardBuilt",i);}return r}async boardSpecialChoose(e){if(!e)return n("client","choiceID must not be empty.");let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),ChoiceID:e,RelatedEntityID:`special_choose_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardSpecialChoose(s);if(r.ok){let i=r.data;i.Mode==="Instant"||i.Mode===0?this.ctx.data.user.clearBoardPending():this.ctx.data.user.patchBoardSpecialPending(d=>{d.ChoiceID=e,d.ChosenMode=i.Mode??"Timed",d.StartedAtUtc=i.StartedAtUtc??null,d.DurationSeconds=i.DurationSeconds??null,d.AdViewsUsed=0;}),i.Operation&&this.ctx.data.user.applyResourceOperation(i.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialChose",i);}return r}async boardSpecialApplyMultiplier(e){let t=this.ctx.auth.context;if(!t)return n("unauthorized","Not logged in.");let s={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:e??`special_ad_${t.userID}_${d()}`},r=await this.ctx.api.gameLoop.boardSpecialApplyMultiplier(s);if(r.ok){let i=r.data;this.ctx.data.user.patchBoardSpecialPending(c=>{c.AdViewsUsed=i.AdViewsUsed??0,c.AccumulatedMultiplier=i.AccumulatedMultiplier??0;}),this.ctx.emitter.emit("gameLoop:boardSpecialApplyMultiplier",i);}return r}async boardSpecialClaim(){let e=this.ctx.auth.context;if(!e)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),RelatedEntityID:`special_claim_${e.userID}_${d()}`},s=await this.ctx.api.gameLoop.boardSpecialClaim(t);if(s.ok){let r=s.data;this.ctx.data.user.clearBoardPending(),r.Operation&&this.ctx.data.user.applyResourceOperation(r.Operation,this.itemDefs),this.ctx.emitter.emit("gameLoop:boardSpecialClaimed",r);}return s}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 s=t.data.Group;s?.GroupID&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:s.GroupID,ActiveRoundIndex:s.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 s={...this.ctx.buildAuthedBaseRequest(),MilestoneID:e,GroupID:t},r=await this.ctx.api.gameLoop.claimCommunityChestMilestone(s);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},s=await this.ctx.api.gameLoop.claimCommunityChestGrandPrize(t);return s.ok&&(s.data.Resources&&this.ctx.data.user.applyResourceOperation(s.data.Resources,this.itemDefs),this.ctx.emitter.emit("gameLoop:communityChestGrandPrizeClaimed",s.data)),s}async leaveCommunityChest(e){if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let t={...this.ctx.buildAuthedBaseRequest(),GroupID:e},s=await this.ctx.api.gameLoop.leaveCommunityChest(t);return s.ok&&(s.data.Success&&this.ctx.data.user.applyCommunityChestUserState({ActiveGroupID:void 0,ActiveRoundIndex:-1}),this.ctx.emitter.emit("gameLoop:communityChestLeft",s.data)),s}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 ys=class{constructor(e){this.ctx=e;}ctx;async execute(e,t,s,r){let i=e.trim();if(!i)return n("client","FunctionName is required.");if(!this.ctx.auth.context)return n("unauthorized","Not logged in.");let c={...this.ctx.buildAuthedBaseRequest(),FunctionName:i,FunctionParameter:t,RevisionSelection:s,SpecificRevision:r},d=await this.ctx.api.cloudCode.execute(c);return d.ok&&this.ctx.emitter.emit("cloudCode:executed",d.data),d}};var Cn=z.object({ServerTimeUtc:l,SourceType:lt,SourceID:z.string(),TargetType:lt,TargetID:z.string(),SourceSpent:M,FeeAmount:M,RateApplied:q,TargetCredited:M}),Sn=z.object({ServerTimeUtc:l,SourceType:lt,SourceID:z.string(),TargetType:lt,TargetID:z.string(),SourceSpent:q,FeeAmount:q,RateApplied:q,TargetCredited:q}),Cs={Convert:"Convert",CryptoConvert:"CryptoConvert"},Nu={Active:"Active",Hidden:"Hidden",Deprecated:"Deprecated",Maintenance:"Maintenance"},xn=z.enum(["Active","Hidden","Deprecated","Maintenance"]),ju={Automatic:"Automatic",Manual:"Manual"},Fu=z.enum(["Automatic","Manual"]),Vu=z.object({ValueInUSD:q.nullish(),ValueInUSDUpdatedAt:l.nullish(),InitialDeposit:z.number().nullish(),MinBalance:z.number().nullish(),MaxBalance:z.number().nullish(),DailyEarnLimit:z.number().nullish(),DailySpendLimit:z.number().nullish()}).passthrough(),_u=z.object({Rate:z.number().nullish(),Max:z.number().nullish(),Period:z.number().nullish()}).passthrough(),Wu=z.object({IsTradable:z.boolean().nullish(),IsPurchasable:z.boolean().nullish(),IsRefundable:z.boolean().nullish()}).passthrough(),Qu=z.object({TargetCurrencyType:lt.nullish(),TargetCurrencyID:z.string(),Rate:q.nullish(),MinAmount:z.number().nullish(),MaxAmount:z.number().nullish(),DailyLimit:z.number().nullish()}).passthrough(),Dn=z.object({Enabled:z.boolean().nullish(),RateMode:Fu.nullish(),FeePercent:q.nullish(),Targets:z.array(Qu).nullish()}).passthrough(),bn=z.object({CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough(),Hu=z.object({CurrencyID:z.string(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Economy:Vu.nullish(),Recharge:_u.nullish(),Conversion:Dn.nullish(),Permissions:Wu.nullish(),Audit:bn.nullish(),Status:xn.nullish()}).passthrough(),Ku=z.object({NetworkID:z.string(),ContractAddress:z.string().nullish(),Decimals:z.number().nullish(),MinDeposit:q.nullish(),MinWithdraw:q.nullish(),WithdrawFee:q.nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish()}).passthrough(),$u=z.object({DailyWithdrawUsd:q.nullish(),MonthlyWithdrawUsd:q.nullish(),KycRequiredAboveUsd:q.nullish()}).passthrough(),Zu=z.object({DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),SpendableInGame:z.boolean().nullish(),ConvertibleToVirtual:z.boolean().nullish()}).passthrough(),Kr=z.object({CurrencyID:z.string(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),DisplayDecimals:z.number().nullish(),ValueInUSD:q.nullish(),ValueInUSDUpdatedAt:l.nullish(),DeveloperDepositSharePercent:q.nullish(),CommunityMarketingDepositSharePercent:q.nullish(),WithdrawalBurnPercent:q.nullish(),Networks:z.array(Ku).nullish(),Limits:$u.nullish(),Permissions:Zu.nullish(),Conversion:Dn.nullish(),Audit:bn.nullish(),Status:xn.nullish()}).passthrough(),Ss=z.object({VirtualCurrencies:z.record(z.string(),Hu).nullish(),CryptoCurrencies:z.record(z.string(),Kr).nullish()}).passthrough();var zn=z.object({CatalogID:z.string().nullish(),ItemID:z.string().nullish(),ItemInstanceID:z.string().nullish(),EquippedAt:l.nullish()}),$r=z.object({CharacterID:z.string(),Level:z.number().nullish(),Experience:M.nullish(),Power:z.number().nullish(),StatLevels:z.record(z.string(),z.number()).nullish(),Equipment:z.record(z.string(),zn).nullish(),UpdatedAt:l.nullish()}).passthrough(),Ju=z.object({CharacterID:z.string().nullish(),SlotID:z.string().nullish()}).passthrough(),Yu=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:l,ExpiresAt:l.nullish(),EquippedSlot:Ju.nullish(),CustomData:z.string().nullish()}).passthrough().transform(a=>a),Xe=z.object({ChangedInstances:z.record(z.string(),Yu).nullish(),RemovedInstanceIDs:z.array(z.string()).nullish()}),vn=z.object({Characters:z.record(z.string(),$r).nullish()}),Zr=z.object({ServerTimeUtc:l,CharacterID:z.string(),StatID:z.string(),StatLevel:z.number(),Power:z.number().nullish(),Resources:x.nullish()}),Jr=z.object({ServerTimeUtc:l,CharacterID:z.string(),NewLevel:z.number(),Power:z.number().nullish(),Resources:x.nullish()}),Tn=z.object({ServerTimeUtc:l,CharacterID:z.string(),Equipment:z.record(z.string(),zn).nullish(),ReplacedInstanceIDs:z.array(z.string()).nullish(),Power:z.number().nullish(),Inventory:Xe.nullish()}),Pn=z.object({ServerTimeUtc:l,CharacterID:z.string(),ClearedSlotIDs:z.array(z.string()).nullish(),Power:z.number().nullish(),Inventory:Xe.nullish()}),Xu=z.object({ClearedSlotIDs:z.array(z.string()).nullish(),Power:z.number().nullish()}),In=z.object({ServerTimeUtc:l,Characters:z.record(z.string(),Xu).nullish(),Inventory:Xe.nullish()}),Yr=z.object({ServerTimeUtc:l,CharacterID:z.string(),Power:z.number().nullish(),Resources:x.nullish()}),Mn=Ot(Yr),kn=Ot(Jr),An=Ot(Zr),Un=z.object({RequiredStatID:z.string(),RequiredLevel:z.number()}).passthrough(),On=z.object({StatID:z.string(),TypeID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),MaxLevel:z.number().nullish(),Weight:z.number().nullish(),BaseCostResource:K.nullish(),CostScalingFactor:z.number().nullish(),BaseStatValue:z.number().nullish(),StatScalingFactor:z.number().nullish(),CharacterLevelScalingFactor:z.number().nullish(),Requirements:z.array(Un).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),Bn=z.object({Level:z.number().nullish(),UpgradeCost:K.nullish(),GlobalStatMultiplier:z.number().nullish(),StatMaxLevelMultiplier:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),ec=z.object({SlotID:z.string(),MinCharacterLevel:z.number().nullish(),StatRequirements:z.array(Un).nullish(),AllowedRarityIDs:z.array(z.string()).nullish(),AllowedItemTags:z.array(z.string()).nullish(),MinItemLevel:z.number().nullish(),MaxItemLevel:z.number().nullish()}).passthrough(),wn=z.object({Slots:z.record(z.string(),ec).nullish()}).passthrough(),tc=z.object({DisplayName:z.string().nullish(),Description:z.string().nullish(),Lore:z.string().nullish(),SortOrder:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),sc=z.object({ClassID:z.string().nullish(),RarityID:z.string().nullish(),Tags:z.array(z.string()).nullish()}).passthrough(),rc=z.object({UnlockedByDefault:z.boolean().nullish(),Cost:K.nullish()}).passthrough(),ic=z.object({Stats:ie.nullish(),Levels:ie.nullish(),Equipment:ie.nullish()}).passthrough(),nc=z.object({CharacterID:z.string(),Identity:tc.nullish(),Classification:sc.nullish(),Unlock:rc.nullish(),Presets:ic.nullish(),Equipment:wn.nullish(),Stats:z.record(z.string(),On).nullish(),Levels:z.record(z.string(),Bn).nullish()}).passthrough(),oc=z.object({Stats:z.record(z.string(),On).nullish()}).passthrough(),ac=z.object({Levels:z.record(z.string(),Bn).nullish()}).passthrough(),lc=z.object({Equipment:wn.nullish()}).passthrough(),uc=z.object({Stats:z.record(z.string(),oc).nullish(),Levels:z.record(z.string(),ac).nullish(),Equipment:z.record(z.string(),lc).nullish()}).passthrough(),xs=z.object({Definitions:z.record(z.string(),nc).nullish(),Presets:uc.nullish()}).passthrough(),Te={GetCharacterDefinitions:"GetCharacterDefinitions",GetUserCharacters:"GetUserCharacters",UnlockCharacter:"UnlockCharacter",UpgradeStatLevel:"UpgradeStatLevel",UpgradeCharacterLevel:"UpgradeCharacterLevel",EquipItems:"EquipItems",UnequipItems:"UnequipItems",UnequipAllCharacters:"UnequipAllCharacters",UnlockCharactersBatch:"UnlockCharactersBatch",UpgradeCharacterLevelsBatch:"UpgradeCharacterLevelsBatch",UpgradeStatLevelsBatch:"UpgradeStatLevelsBatch"};var cc={EVM:"EVM",Solana:"Solana"},pc=z.enum(["EVM","Solana"]),dc={AutoLinkedFromTransaction:"AutoLinkedFromTransaction",SignatureVerified:"SignatureVerified",ManuallyLinked:"ManuallyLinked"},hc=z.enum(["AutoLinkedFromTransaction","SignatureVerified","ManuallyLinked"]),mc={Token:"Token",Nft:"Nft"},qn=z.enum(["Token","Nft"]),fc={NotRequested:"NotRequested",Pending:"Pending",Verified:"Verified",Rejected:"Rejected",Expired:"Expired"},gc=z.enum(["NotRequested","Pending","Verified","Rejected","Expired"]),Rc={None:"None",Tier1:"Tier1",Tier2:"Tier2",Tier3:"Tier3"},yc=z.enum(["None","Tier1","Tier2","Tier3"]),Cc={Pending:"Pending",Completed:"Completed",Failed:"Failed",Expired:"Expired",Abandoned:"Abandoned"},Xr=z.enum(["Pending","Completed","Failed","Expired","Abandoned"]),En={GameTopUp:"game_topup",CommunityReward:"community_reward"};function Ds(a){let e=a?.trim();return e||En.GameTopUp}var Sc={UsersCryptoWallet:"UsersCryptoWallet",Game:"Game"},Ln=z.enum(["UsersCryptoWallet","Game"]),xc=z.object({ContractAddress:z.string().nullish(),ItemCatalogID:z.string().nullish(),DisplayName:z.string().nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish()}).passthrough(),Gn=z.object({Ios:z.boolean().nullish(),Android:z.boolean().nullish(),Web:z.boolean().nullish()}).passthrough(),Dc=z.object({NetworkID:z.string().nullish(),DisplayName:z.string().nullish(),Type:pc.nullish(),ChainID:z.number().nullish(),ChainTicker:z.string().nullish(),RewardPoolAddress:z.string().nullish(),VaultDepositAddress:z.string().nullish(),ChainConfigVersion:z.number().nullish(),RequiredConfirmations:z.number().nullish(),DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),NftDepositsEnabled:z.boolean().nullish(),NftWithdrawalsEnabled:z.boolean().nullish(),PlatformOverrides:Gn.nullish(),NftCollections:z.array(xc).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),bc=z.object({DepositsEnabled:z.boolean().nullish(),WithdrawalsEnabled:z.boolean().nullish(),NftDepositsEnabled:z.boolean().nullish(),NftWithdrawalsEnabled:z.boolean().nullish(),PlatformOverrides:Gn.nullish()}).passthrough(),zc=z.object({MinAccountAgeDays:z.number().nullish(),MultiAccountCheckEnabled:z.boolean().nullish(),BanOnSharedWithdrawalAddress:z.boolean().nullish(),PendingWithdrawalTtlHours:z.number().nullish()}).passthrough();var vc=z.enum(["OnChain","Combined"]),Tc=z.object({Enabled:z.boolean().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),MinBalance:q.nullish(),BalanceSource:vc.nullish(),DenyMessage:z.string().nullish()}).passthrough(),Pc=z.object({Enabled:z.boolean().nullish(),TokenGates:z.array(Tc).nullish(),WalletConnectProjectId:z.string().nullish()}).passthrough(),ei=z.object({SystemState:bc.nullish(),Networks:z.record(z.string(),Dc).nullish(),AccountSafety:zc.nullish(),WalletLogin:Pc.nullish()}).passthrough(),Ic=z.object({NetworkID:z.string().nullish(),Address:z.string().nullish(),LinkedAt:l.nullish(),LastUsedAt:l.nullish(),LinkType:hc.nullish(),IsSignatureVerified:z.boolean().nullish()}).passthrough(),Nn=z.object({TitleTransactionID:z.string().nullish(),Type:qn.nullish(),NetworkID:z.string().nullish(),AssetID:z.string().nullish(),Amount:q.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),Mc=z.object({Status:gc.nullish(),Tier:yc.nullish(),VerifiedAt:l.nullish(),ExpiresAt:l.nullish(),RejectedAt:l.nullish(),ProviderReference:z.string().nullish(),RejectionReason:z.string().nullish()}).passthrough(),kc=z.object({CurrencyID:z.string().nullish(),Deposits:z.number().nullish(),DepositsVolumeNative:q.nullish(),DepositsVolumeUsd:q.nullish(),Withdrawals:z.number().nullish(),WithdrawalsVolumeNative:q.nullish(),WithdrawalsVolumeUsd:q.nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),FirstDepositAt:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Ac=z.object({TotalDeposits:z.number().nullish(),TotalWithdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),TotalDepositsVolumeUsd:q.nullish(),TotalWithdrawalsVolumeUsd:q.nullish(),PerCurrency:z.record(z.string(),kc).nullish()}).passthrough(),Uc=z.object({NetworkID:z.string().nullish(),ItemCatalogID:z.string().nullish(),Deposits:z.number().nullish(),Withdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),FirstDepositAt:l.nullish(),LastDepositAt:l.nullish(),FirstWithdrawalAt:l.nullish(),LastWithdrawalAt:l.nullish()}).passthrough(),Oc=z.object({TotalDeposits:z.number().nullish(),TotalWithdrawals:z.number().nullish(),FailedWithdrawals:z.number().nullish(),RejectedDeposits:z.number().nullish(),PerCollection:z.record(z.string(),Uc).nullish()}).passthrough(),Bc=z.object({Tokens:Ac.nullish(),Nfts:Oc.nullish()}).passthrough(),wc=z.object({CurrencyID:z.string().nullish(),Balance:q.nullish(),MinBalance:q.nullish()}).passthrough(),qc=z.object({NetworkID:z.string().nullish(),Address:z.string().nullish(),CheckedAt:l.nullish(),LoggedInAt:l.nullish(),GatePassed:z.boolean().nullish(),GatedBalances:z.array(wc).nullish()}).passthrough(),Ec=z.object({Version:z.number().nullish(),Stats:Bc.nullish(),LinkedWallets:z.record(z.string(),Ic).nullish(),LastWalletLogin:qc.nullish(),PendingWithdrawals:z.array(Nn).nullish(),Kyc:Mc.nullish(),FirstActivityAt:l.nullish(),LastActivityAt:l.nullish(),IsFlagged:z.boolean().nullish(),FlagReason:z.string().nullish()}).passthrough(),Lc=z.object({CurrencyID:z.string(),AmountDelta:q,FrozenDelta:q,UpdatedAt:l}).passthrough(),bs=z.object({CryptoBalances:z.record(z.string(),Lc).nullish(),PendingAdded:Nn.nullish(),PendingRemovedIDs:z.array(z.string()).nullish()}).passthrough(),Gc=z.object({Amount:q,Frozen:q,CreatedAt:l.nullish(),UpdatedAt:l.nullish()}).passthrough().transform(a=>a),Nc=z.object({ID:z.string().nullish(),TitleID:z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.nullish(),UserID:z.string().nullish(),TransactionHash:z.string().nullish(),Nonce:z.string().nullish(),NetworkID:z.string().nullish(),ChainType:z.string().nullish(),ChainID:z.number().nullish(),Direction:Ln.nullish(),From:z.string().nullish(),To:z.string().nullish(),Amount:q.nullish(),Status:Xr.nullish(),SignatureData:z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.nullish(),FailReason:z.string().nullish(),Reason:z.string().nullish(),Category:z.string().nullish(),TokenID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountUsd:q.nullish(),NetPayoutAmount:q.nullish()}).passthrough(),jc=z.object({ID:z.string().nullish(),TitleID:z.string().nullish(),CreatedAt:l.nullish(),UpdatedAt:l.nullish(),UserID:z.string().nullish(),TransactionHash:z.string().nullish(),Nonce:z.string().nullish(),NetworkID:z.string().nullish(),ChainType:z.string().nullish(),ChainID:z.number().nullish(),Direction:Ln.nullish(),From:z.string().nullish(),To:z.string().nullish(),Amount:q.nullish(),Status:Xr.nullish(),SignatureData:z.string().nullish(),CompletedAt:l.nullish(),ExpiresAt:l.nullish(),FailReason:z.string().nullish(),Reason:z.string().nullish(),Category:z.string().nullish(),NFTID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),SkinID:z.string().nullish()}).passthrough(),jn=z.object({To:z.string().nullish(),Amount:z.union([z.string(),z.number()]).nullish()}).passthrough(),ti=z.object({TokenAddress:z.string().nullish(),WalletAddress:z.string().nullish(),Amount:z.string().nullish(),BurnAmount:z.string().nullish(),TokenId:z.string().nullish(),Nonce:z.string().nullish(),ContractAddress:z.string().nullish(),UserID:z.string().nullish(),TitleID:z.string().nullish(),Category:z.string().nullish(),Deadline:z.string().nullish(),SignatureEpoch:z.string().nullish(),Splits:z.array(jn).nullish(),Signature:z.string().nullish()}).passthrough(),si=z.object({Mint:z.string().nullish(),WalletAddress:z.string().nullish(),Amount:z.string().nullish(),BurnAmount:z.string().nullish(),Nonce:z.string().nullish(),ExpiresAt:z.string().nullish(),ProgramID:z.string().nullish(),SignatureEpoch:z.string().nullish(),Domain:z.string().nullish(),Splits:z.array(jn).nullish(),SignatureHex:z.string().nullish(),SigIxIndex:z.number().nullish(),Ed25519PublicKey:z.string().nullish(),Ed25519Message:z.string().nullish(),UserID:z.string().nullish(),TitleID:z.string().nullish(),Category:z.string().nullish()}).passthrough(),Fn=z.object({Blockchain:ei.nullish(),CryptoCurrencies:z.record(z.string(),Kr).nullish()}).passthrough(),Vn=z.object({State:Ec.nullish(),CryptoBalances:z.record(z.string(),Gc).nullish()}).passthrough(),_n=z.object({ServerTimeUtc:l.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),StateDelta:bs.nullish()}).passthrough(),Wn=z.object({ServerTimeUtc:l.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),NftTokenID:z.string().nullish(),Amount:z.number().nullish(),Resources:x.nullish(),Inventory:Xe.nullish()}).passthrough(),Qn=z.object({ServerTimeUtc:l.nullish(),TitleTransactionID:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:q.nullish(),NetAmountNative:q.nullish(),BurnAmountNative:q.nullish(),AmountUsd:q.nullish(),ExpiresAt:l.nullish(),EvmSignature:ti.nullish(),SolanaSignature:si.nullish(),StateDelta:bs.nullish()}).passthrough(),Hn=z.object({ServerTimeUtc:l.nullish(),TitleTransactionID:z.string().nullish(),NetworkID:z.string().nullish(),ItemID:z.string().nullish(),CatalogID:z.string().nullish(),NftTokenID:z.string().nullish(),Amount:z.number().nullish(),ExpiresAt:l.nullish(),Resources:x.nullish(),EvmSignature:ti.nullish(),SolanaSignature:si.nullish(),StateDelta:bs.nullish(),Inventory:Xe.nullish()}).passthrough(),Kn=z.object({TokenTransactions:z.array(Nc).nullish(),NFTTransactions:z.array(jc).nullish()}).passthrough(),ri=z.object({ServerTimeUtc:l.nullish(),TransactionHash:z.string().nullish(),NetworkID:z.string().nullish(),CurrencyID:z.string().nullish(),AmountNative:q.nullish(),AmountUsd:q.nullish(),Target:z.string().nullish()}).passthrough(),$n=z.object({TitleTransactionID:z.string().nullish(),Kind:qn.nullish(),EvmSignature:ti.nullish(),SolanaSignature:si.nullish()}).passthrough(),Zn=z.object({TitleTransactionID:z.string().nullish(),OnChainTxHash:z.string().nullish(),Status:Xr.nullish(),StateDelta:bs.nullish()}).passthrough(),Pe={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",DepositToken:"DepositToken",DepositNFT:"DepositNFT",RequestTokenWithdrawal:"RequestTokenWithdrawal",RequestNFTWithdrawal:"RequestNFTWithdrawal",GetTransactionHistory:"GetTransactionHistory",RetryWithdrawal:"RetryWithdrawal",ConfirmWithdrawal:"ConfirmWithdrawal",DonateToDeveloper:"DonateToDeveloper",DonateToUsersPool:"DonateToUsersPool"};var Fc="Blockchain",zs=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(Fc,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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositToken(s);return r.ok&&r.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(r.data.CurrencyID,new Lt(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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.depositNFT(s);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,s,r,i){if(!e)return n("client","CurrencyID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.CurrencyID=e,c.NetworkID=t,c.WalletAddress=s,c.Amount=r,c.Category=Ds(i);let d=await this.ctx.api.blockchain.requestTokenWithdrawal(c);return d.ok&&d.data.CurrencyID&&(this.ctx.data.user.patchCryptoCurrencyDelta(d.data.CurrencyID,new Lt(d.data.AmountNative??0).negated(),d.data.ServerTimeUtc??void 0),this.ctx.emitter.emit("blockchain:tokenWithdrawalRequested",d.data)),d}async requestNFTWithdrawal(e,t,s,r,i,c,d){if(!e)return n("client","ItemID is required.");if(!t)return n("client","NetworkID is required.");if(!s)return n("client","WalletAddress is required.");if(!r)return n("client","Amount is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.NetworkID=t,z.WalletAddress=s,z.Amount=r,z.Category=Ds(i),c!==void 0&&(z.Level=c),d&&(z.ItemInstanceID=d);let B=await this.ctx.api.blockchain.requestNFTWithdrawal(z);return B.ok&&(this.ctx.data.user.applyResourceOperation(B.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("blockchain:nftWithdrawalRequested",B.data)),B}async getTransactionHistory(e=50){let t=this.baseRequest();if(!t)return n("unauthorized","Not logged in.");t.Amount=String(e);let s=await this.ctx.api.blockchain.getTransactionHistory(t);return s.ok&&this.ctx.emitter.emit("blockchain:transactionHistoryLoaded",s.data),s}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 s=await this.ctx.api.blockchain.retryWithdrawal(t);return s.ok&&this.ctx.emitter.emit("blockchain:withdrawalRetried",s.data),s}async confirmWithdrawal(e,t){if(!e)return n("client","TitleTransactionID is required.");if(!t)return n("client","On-chain TransactionHash is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.TitleTransactionID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.confirmWithdrawal(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToDeveloper(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.NetworkID=e,s.TransactionHash=t;let r=await this.ctx.api.blockchain.donateToUsersPool(s);return r.ok&&this.ctx.emitter.emit("blockchain:donatedToUsersPool",r.data),r}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ce=z.object({Username:z.string().nullish(),Country:z.string().nullish(),AvatarUrl:z.string().nullish(),Premium:z.boolean().nullish(),Level:z.number().nullish(),Power:z.number().nullish(),BoardRank:z.number().nullish()}).passthrough();var Vc={Head:"Head",Torso:"Torso",Legs:"Legs"},vs=z.enum(["Head","Torso","Legs"]),_c={Open:"Open",InProgress:"InProgress",Cancelled:"Cancelled",Completed:"Completed"},ii=z.enum(["Open","InProgress","Cancelled","Completed"]),Xn=z.object({AttackTarget:vs,DefenseTarget:vs});var Wc=z.enum(["Hit","Critical","Block","Dodge"]),Qc=z.object({RoundIndex:z.number().nullish(),AttackerID:z.string().nullish(),DefenderID:z.string().nullish(),AttackZone:vs.nullish(),DefenseZone:vs.nullish(),HitType:Wc.nullish(),DamageDealt:z.number().nullish(),DefenderHpRemaining:z.number().nullish()}).passthrough(),Hc=z.object({MaxHp:z.number().nullish(),CurrentHp:z.number().nullish(),Damage:z.number().nullish(),AttackSpeed:z.number().nullish(),CritChance:z.number().nullish(),CritMultiplier:z.number().nullish(),Armor:z.number().nullish(),DodgeChance:z.number().nullish()}).passthrough(),Kc=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:l,ExpiresAt:l.nullish(),CustomData:z.string().nullish()}).passthrough().transform(a=>a),Yn=z.object({UserID:z.string().nullish(),SelectedCharacterID:z.string().nullish(),SelectedCharacter:$r.nullish(),BattleStrategy:z.array(Xn).nullish(),UnstackableItems:z.record(z.string(),Kc).nullish(),Stats:Hc.nullish()}).passthrough(),$c=z.object({WinnerUserID:z.string().nullish(),LoserUserID:z.string().nullish(),Entry:le.nullish(),NetReward:le.nullish(),BattleLog:z.array(Qc).nullish(),IsDraw:z.boolean().nullish(),P1BattleProfile:Yn.nullish(),P2BattleProfile:Yn.nullish()}).passthrough(),eo=z.object({MatchID:z.string(),TitleID:z.string().nullish(),RuleID:z.string().nullish(),CreatedAt:l.nullish(),CreatorID:z.string().nullish(),CreatorCharacterID:z.string().nullish(),CreatorStrategy:z.array(Xn).nullish(),TargetUserID:z.string().nullish(),Entry:le.nullish(),CreationCostPaid:le.nullish(),RefundCreationCostOnCancel:z.boolean().nullish(),JoinedByUserID:z.string().nullish(),JoinedByCharacterID:z.string().nullish(),JoinedAt:l.nullish(),Status:ii.nullish(),WinnerUserID:z.string().nullish(),CompletedAt:l.nullish(),IsRewardDistributed:z.boolean().nullish(),RewardDistributedAt:l.nullish()}).passthrough(),to=z.object({Status:ii,MatchID:z.string(),Entry:le.nullish(),Resources:x.nullish()}),so=z.object({Match:eo.nullish()}),ro=z.object({MatchID:z.string(),Status:ii,Resources:x.nullish()}),io=z.object({Battle:$c.nullish(),Resources:x.nullish(),ResourcesDual:tt.nullish()}),ni=z.object({Matches:z.array(eo).nullish(),Page:z.number().nullish(),PageSize:z.number().nullish(),HasMore:z.boolean().nullish()}),je={CreateMatch:"CreateMatch",UpdateMatch:"UpdateMatch",CancelMatch:"CancelMatch",InstantBattle:"InstantBattle",SaveStrategy:"SaveStrategy",GetMyMatches:"GetMyMatches",GetAvailableMatches:"GetAvailableMatches",GetDefinitions:"GetDefinitions"};var Zc=z.enum(["VirtualCurrency","Item","EventToken"]);var Jc=z.enum(["Constant","Stat","RankMultiplier","AllMight","GearFlat","GearPercent"]),Yc=z.object({HealthStatID:z.string().nullish(),DamageStatID:z.string().nullish(),ArmorStatID:z.string().nullish(),AttackSpeedStatID:z.string().nullish(),CritChanceStatID:z.string().nullish(),CritDamageStatID:z.string().nullish(),DodgeStatID:z.string().nullish(),AllMightStatID:z.string().nullish()}).passthrough(),Xc=z.object({MaxRounds:z.number().nullish(),BlockDamageMultiplier:z.number().nullish(),MinHitDamage:z.number().nullish(),DefaultCritMultiplier:z.number().nullish(),MaxCritChance:z.number().nullish(),MaxDodgeChance:z.number().nullish()}).passthrough(),ep=z.object({Source:Jc.nullish(),StatID:z.string().nullish(),Value:z.number().nullish(),OnePlus:z.boolean().nullish()}).passthrough(),tp=z.object({Coefficient:z.number().nullish(),Factors:z.array(ep).nullish()}).passthrough(),rt=z.object({Terms:z.array(tp).nullish()}).passthrough(),sp=z.object({Health:rt.nullish(),Damage:rt.nullish(),Armor:rt.nullish(),AttackSpeed:rt.nullish(),CritChance:rt.nullish(),CritDamage:rt.nullish(),Dodge:rt.nullish()}).passthrough(),no=z.object({StatMapping:Yc.nullish(),Combat:Xc.nullish(),Formula:sp.nullish()}).passthrough(),rp=z.object({BurnRate:z.number().nullish()}).passthrough(),oi=z.object({Kind:Zc.nullish(),CurrencyID:z.string().nullish(),CatalogID:z.string().nullish(),ItemID:z.string().nullish(),TokenType:kt.nullish(),EntityID:z.string().nullish(),MinAmount:z.number().nullish(),MaxAmount:z.number().nullish()}).passthrough(),oo=z.object({AllowVirtualCurrency:z.boolean().nullish(),AllowItems:z.boolean().nullish(),AllowEventTokens:z.boolean().nullish(),Allowed:z.array(oi).nullish(),MaxPositions:z.number().nullish()}).passthrough(),ao=z.object({Cost:K.nullish(),RefundCostOnCancel:z.boolean().nullish(),MaxOpenMatches:z.number().nullish(),Limits:pe.nullish(),AllowPrivateMatches:z.boolean().nullish(),MaxMatchesPerOpponentPerDay:z.number().nullish()}).passthrough(),ip=z.object({RuleID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),Economy:rp.nullish(),Entry:oo.nullish(),Creation:ao.nullish(),Settings:no.nullish()}).passthrough(),np=z.object({Rules:z.record(z.string(),ip).nullish(),Defaults:no.nullish(),EntryDefaults:oo.nullish(),CreationDefaults:ao.nullish()}).passthrough(),ai=z.object({InstantBattle:np.nullish()}).passthrough(),lo=ai;var op={Listing:"Listing",Auction:"Auction",BuyOrder:"BuyOrder",DirectTrade:"DirectTrade"},li=z.enum(["Listing","Auction","BuyOrder","DirectTrade"]),ap={Active:"Active",Completed:"Completed",Cancelled:"Cancelled",Declined:"Declined",Expired:"Expired"},ui=z.enum(["Active","Completed","Cancelled","Declined","Expired"]),lp={Burn:"Burn",Ledger:"Ledger"},up=z.enum(["Burn","Ledger"]),Ps={Item:"Item",VirtualCurrency:"VirtualCurrency"},ci=z.enum(["Item","VirtualCurrency"]),cp=z.object({Percent:z.number().nullish(),MinPerPosition:M.nullish()}).passthrough(),pp=z.object({AllowVirtualCurrency:z.boolean().nullish(),AllowItems:z.boolean().nullish(),AllowEventTokens:z.boolean().nullish(),Allowed:z.array(oi).nullish(),MaxPositions:z.number().nullish()}).passthrough(),dp=z.object({Percent:z.number().nullish(),MinPerPosition:M.nullish(),Sink:up.nullish(),LedgerAccountID:z.string().nullish(),PerCatalogOverrides:z.record(z.string(),cp).nullish(),ApplyToDirectTrades:z.boolean().nullish()}).passthrough(),hp=z.object({AllowedCatalogIDs:z.array(z.string()).nullish(),DeniedCatalogIDs:z.array(z.string()).nullish(),DeniedItemIDs:z.array(z.string()).nullish(),AllowUnstackableWithState:z.boolean().nullish()}).passthrough(),mp=z.object({Enabled:z.boolean().nullish(),AllowedDurationsHours:z.array(z.number()).nullish(),MaxActiveListings:z.number().nullish(),CreateLimits:pe.nullish(),BuyLimits:pe.nullish(),ListingFee:K.nullish(),RefundListingFeeOnCancel:z.boolean().nullish()}).passthrough(),fp=z.object({Enabled:z.boolean().nullish(),MinDurationHours:z.number().nullish(),MaxDurationHours:z.number().nullish(),AntiSnipeWindowSeconds:z.number().nullish(),AntiSnipeExtensionSeconds:z.number().nullish(),MaxAntiSnipeExtensions:z.number().nullish(),MinBidStepPercent:z.number().nullish(),MinBidStepAbsolute:M.nullish(),BidLimits:pe.nullish()}).passthrough(),gp=z.object({Enabled:z.boolean().nullish(),MaxActiveOrders:z.number().nullish(),AllowedDurationsHours:z.array(z.number()).nullish(),CreateLimits:pe.nullish(),FillLimits:pe.nullish()}).passthrough(),Rp=z.object({Enabled:z.boolean().nullish(),OfferExpirationHours:z.number().nullish(),MaxPendingOutgoing:z.number().nullish(),AllowGifts:z.boolean().nullish(),CreateLimits:pe.nullish()}).passthrough(),yp=z.object({Enabled:z.boolean().nullish()}).passthrough(),pi=z.object({Enabled:z.boolean().nullish(),Gate:Q.nullish(),Schedule:ce.nullish(),PricePolicy:pp.nullish(),Commission:dp.nullish(),Tradability:hp.nullish(),Listings:mp.nullish(),Auctions:fp.nullish(),BuyOrders:gp.nullish(),DirectTrades:Rp.nullish(),Matching:yp.nullish()}).passthrough(),uo=z.object({BidIndex:z.number().nullish(),UserID:z.string().nullish(),Amount:M.nullish(),Settled:z.boolean().nullish(),SettledAt:l.nullish()}).passthrough(),Cp=z.object({BidAxisType:Mt.nullish(),BidCurrencyID:z.string().nullish(),BidCatalogID:z.string().nullish(),BidItemID:z.string().nullish(),StartingBid:M.nullish(),CurrentBid:M.nullish(),CurrentBidderID:z.string().nullish(),BidCount:z.number().nullish(),ExtensionCount:z.number().nullish(),PendingRefunds:z.array(uo).nullish()}).passthrough(),Ts=z.object({LastAt:l.nullish(),DailyCount:z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),Sp=z.object({Create:Ts.nullish(),Buy:Ts.nullish(),Sell:Ts.nullish(),Bid:Ts.nullish()}).passthrough(),xp=z.object({CharacterID:z.string().nullish(),SlotID:z.string().nullish()}).passthrough(),Dp=z.object({ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Quantity:z.number().nullish(),RemainingUses:z.number().nullish(),Level:z.number().nullish(),AcquiredAt:l,ExpiresAt:l.nullish(),EquippedSlot:xp.nullish(),CustomData:z.string().nullish()}).passthrough().transform(a=>a),Qe=z.object({OfferID:z.string().nullish(),OfferType:li.nullish(),Status:ui.nullish(),CreatorUserID:z.string().nullish(),CreatorPublicData:Ce.nullish(),TargetUserID:z.string().nullish(),GoodsType:ci.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),GoodsAmount:M.nullish(),GoodsInstances:z.array(Dp).nullish(),Price:le.nullish(),Auction:Cp.nullish(),CreatedAt:l.nullish(),ExpiresAt:l.nullish()}).passthrough(),bp=z.object({GoodsType:ci.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),CountsByType:z.record(li,M).nullish(),ListingCount:M.nullish(),AuctionCount:M.nullish(),BuyOrderCount:M.nullish()}).passthrough(),co=z.object({Definitions:pi.nullish(),IsOpenNow:z.boolean().nullish(),GatePassed:z.boolean().nullish()}).passthrough(),di=z.object({Offers:z.array(Qe).nullish(),ContinuationToken:z.string().nullish()}).passthrough(),po=z.object({Groups:z.array(bp).nullish()}).passthrough(),ho=z.object({Offer:Qe.nullish()}).passthrough(),Ae=z.object({OfferID:z.string().nullish(),Status:ui.nullish(),Settlement:tt.nullish(),Resources:x.nullish(),CommissionTaken:le.nullish()}).passthrough(),Dt=z.object({OfferID:z.string().nullish(),Offer:Qe.nullish(),Resources:x.nullish(),Matched:z.boolean().nullish(),Settlement:Ae.nullish()}).passthrough(),mo=z.object({OfferID:z.string().nullish(),CurrentBid:M.nullish(),BidCount:z.number().nullish(),ExpiresAt:l.nullish(),Resources:x.nullish()}).passthrough(),fo=z.object({MyOffers:z.array(Qe).nullish(),MyLeadingBids:z.array(Qe).nullish(),MyBuyOrders:z.array(Qe).nullish(),IncomingTrades:z.array(Qe).nullish(),OutgoingTrades:z.array(Qe).nullish(),Claimables:z.array(Qe).nullish(),DrainedRefunds:z.array(uo).nullish(),Limits:Sp.nullish()}).passthrough(),zp=z.object({OfferID:z.string().nullish(),OfferType:li.nullish(),FinalStatus:ui.nullish(),SellerUserID:z.string().nullish(),BuyerUserID:z.string().nullish(),GoodsType:ci.nullish(),GoodsCatalogID:z.string().nullish(),GoodsItemID:z.string().nullish(),GoodsCurrencyID:z.string().nullish(),GoodsAmount:M.nullish(),PricePaid:le.nullish(),CommissionTaken:le.nullish(),CompletedAt:l.nullish()}).passthrough(),go=z.object({Entries:z.array(zp).nullish(),ContinuationToken:z.string().nullish()}).passthrough(),re={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 vp="Marketplace",Is=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(vp,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,s,r=20){if(!e)return n("client","ItemID is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.ItemID=e,i.OfferTypeFilter=t,i.ContinuationToken=s,i.PageSize=r;let c=await this.ctx.api.marketplace.getOffersByItem(i);return c.ok&&this.ctx.emitter.emit("marketplace:offersByItemLoaded",c.data),c}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 s=await this.ctx.api.marketplace.getOffer(t);return s.ok&&this.ctx.emitter.emit("marketplace:offerLoaded",s.data),s}async getBuyOrders(e,t,s=20){let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.ItemID=e,r.ContinuationToken=t,r.PageSize=s;let i=await this.ctx.api.marketplace.getBuyOrders(r);return i.ok&&this.ctx.emitter.emit("marketplace:buyOrdersLoaded",i.data),i}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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.ContinuationToken=e,s.PageSize=t;let r=await this.ctx.api.marketplace.getHistory(s);return r.ok&&this.ctx.emitter.emit("marketplace:historyLoaded",r.data),r}async createListing(e,t,s,r,i,c){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");if(!r)return n("client","PriceBundle is required.");let d=this.baseRequest();if(!d)return n("unauthorized","Not logged in.");d.ItemID=e,d.CatalogID=t,d.GoodsAmount=s,d.PriceBundle=r,d.DurationHours=i,d.ItemInstanceIDs=c;let z=await this.ctx.api.marketplace.createListing(d);return this.applyCreateOfferResult(z,"marketplace:listingCreated"),z}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 s=await this.ctx.api.marketplace.buy(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:bought",s.data)),s}async marketBuy(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketBuy(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketBought",c.data)),c}async marketSell(e,t,s){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 i=this.applyGoodsSelector(r,s);if(i)return i;r.GoodsAmount=e,r.PriceBundle=t;let c=await this.ctx.api.marketplace.marketSell(r);return c.ok&&(this.applyDualPartySettlement(c.data.Settlement),this.ctx.emitter.emit("marketplace:marketSold",c.data)),c}async createAuction(e,t,s,r,i,c,d={}){if(!e)return n("client","ItemID is required.");if(!t)return n("client","CatalogID is required.");let z=this.baseRequest();if(!z)return n("unauthorized","Not logged in.");z.ItemID=e,z.CatalogID=t,z.GoodsAmount=s,z.BidAxisType=r,z.BidCurrencyID=d.bidCurrencyID,z.BidCatalogID=d.bidCatalogID,z.BidItemID=d.bidItemID,z.StartingBid=i,z.DurationHours=c,z.ItemInstanceIDs=d.itemInstanceIDs;let B=await this.ctx.api.marketplace.createAuction(z);return this.applyCreateOfferResult(B,"marketplace:auctionCreated"),B}async placeBid(e,t){if(!e)return n("client","OfferID is required.");if(!t||t<=0)return n("client","BidAmount must be positive.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.BidAmount=t;let r=await this.ctx.api.marketplace.placeBid(s);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 s=await this.ctx.api.marketplace.claimAuction(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:auctionClaimed",s.data)),s}async createBuyOrder(e,t,s,r,i){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 c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.ItemID=e,c.CatalogID=t,c.GoodsAmount=s,c.PriceBundle=r,c.DurationHours=i;let d=await this.ctx.api.marketplace.createBuyOrder(c);return this.applyCreateOfferResult(d,"marketplace:buyOrderCreated"),d}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 s=await this.ctx.api.marketplace.fillBuyOrder(t);return s.ok&&(this.applyDualPartySettlement(s.data.Settlement),this.ctx.emitter.emit("marketplace:buyOrderFilled",s.data)),s}async createDirectTrade(e,t,s,r,i){if(!e)return n("client","TargetUserID is required.");if(!t)return n("client","CatalogID is required.");if(!s)return n("client","ItemID is required.");let c=this.baseRequest();if(!c)return n("unauthorized","Not logged in.");c.TargetUserID=e,c.CatalogID=t,c.ItemID=s,c.ItemInstanceIDs=r,c.RequestedBundle=i;let d=await this.ctx.api.marketplace.createDirectTrade(c);return this.applyCreateOfferResult(d,"marketplace:directTradeCreated"),d}async respondDirectTrade(e,t){if(!e)return n("client","OfferID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.OfferID=e,s.Accept=t;let r=await this.ctx.api.marketplace.respondDirectTrade(s);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 s=await this.ctx.api.marketplace.claimBack(t);return s.ok&&(this.ctx.data.user.applyResourceOperation(s.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit("marketplace:claimedBack",s.data)),s}async cancelOffer(e,t,s){if(!e)return n("client","OfferID is required.");let r=this.baseRequest();if(!r)return n("unauthorized","Not logged in.");r.OfferID=e;let i=await t(r);return i.ok&&(this.ctx.data.user.applyResourceOperation(i.data.Resources,this.ctx.data.config.itemDefinitions),this.ctx.emitter.emit(s,i.data)),i}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=Ps.VirtualCurrency,e.GoodsCurrencyID=t.goodsCurrencyID,null):"itemID"in t&&t.itemID&&t.catalogID?(e.GoodsType=Ps.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 s=this.ctx.data.config.itemDefinitions;e.FromUserID===t&&e.FromResult?this.ctx.data.user.applyResourceOperation(e.FromResult,s):e.ToUserID===t&&e.ToResult&&this.ctx.data.user.applyResourceOperation(e.ToResult,s);}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ms=class{constructor(e){this.ctx=e;}ctx;async createRoom(e,t={}){if(!e)return n("client","RoomName is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomName=e,s.Topology=t.topology,s.ChatMode=t.chatMode,s.MaxPlayers=t.maxPlayers,s.Visibility=t.visibility,s.JoinCode=t.joinCode;let r=await this.ctx.api.multiplayer.createRoom(s);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 s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.JoinCode=t;let r=await this.ctx.api.multiplayer.joinRoom(s);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 s=await this.ctx.api.multiplayer.leaveRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLeft",s.data),s}async listRooms(e=0,t=20){let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.Page=e,s.PageSize=t;let r=await this.ctx.api.multiplayer.listRooms(s);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 s=await this.ctx.api.multiplayer.getRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomLoaded",s.data),s}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 s=await this.ctx.api.multiplayer.closeRoom(t);return s.ok&&this.ctx.emitter.emit("multiplayer:roomClosed",s.data),s}async poll(e,t){if(!e)return n("client","RoomID is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.LastSeq=t;let r=await this.ctx.api.multiplayer.poll(s);return r.ok&&this.ctx.emitter.emit("multiplayer:polled",r.data),r}async sendSignal(e,t,s,r){if(!e)return n("client","RoomID is required.");if(!t)return n("client","TargetUserID is required.");if(!s)return n("client","SignalKind is required.");let i=this.baseRequest();if(!i)return n("unauthorized","Not logged in.");i.RoomID=e,i.TargetUserID=t,i.SignalKind=s,i.Payload=r;let c=await this.ctx.api.multiplayer.sendSignal(i);return c.ok&&this.ctx.emitter.emit("multiplayer:signalSent",c.data),c}async sendChat(e,t){if(!e)return n("client","RoomID is required.");if(!t)return n("client","ChatText is required.");let s=this.baseRequest();if(!s)return n("unauthorized","Not logged in.");s.RoomID=e,s.ChatText=t;let r=await this.ctx.api.multiplayer.sendChat(s);return r.ok&&this.ctx.emitter.emit("multiplayer:chatSent",r.data),r}async setMemberState(e,t,s){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=s;let i=await this.ctx.api.multiplayer.setMemberState(r);return i.ok&&this.ctx.emitter.emit("multiplayer:memberStateSet",i.data),i}baseRequest(){return this.ctx.auth.context?this.ctx.buildAuthedBaseRequest():null}};var Ro=z.object({PlatformUserID:z.string().nullish(),PlatformAuthToken:z.string().nullish(),PlatformAuthTokenExpiration:l.nullish(),TitleUserID:z.string(),TitleClientSessionTicket:z.string(),TitleClientSessionTicketExpiration:l}),Se=z.object({IsCompleted:z.boolean().nullish(),ServerTime:l.nullish()}),yo=z.object({Message:z.string(),ExpiresAt:l}),Ue={LoginWithDeviceID:"LoginWithDeviceID",LoginWithTelegram:"LoginWithTelegram",LoginWithEmail:"LoginWithEmail",LoginWithGoogle:"LoginWithGoogle",LoginWithPlatformToken:"LoginWithPlatformToken",RegisterWithEmail:"RegisterWithEmail",RefreshPlatformToken:"RefreshPlatformToken",RequestWalletChallenge:"RequestWalletChallenge",LoginWithWallet:"LoginWithWallet",ForgotPassword:"ForgotPassword",ResetPassword:"ResetPassword"};function U(a,e,t,s){let i=`api/v2/${a&&a.length>0?a:"0"}/Client/${e}/${t}`;return s==null?i:`${i}/${s}`}var ks=class{constructor(e){this.ctx=e;}ctx;endpoint(e){return U(this.ctx.settings.titleID,"Authentication",e)}login(e,t){return this.ctx.transport.post(this.endpoint(e),t,Ro,{ticket:null})}loginWithDeviceID(e){return this.login(Ue.LoginWithDeviceID,e)}loginWithTelegram(e){return this.login(Ue.LoginWithTelegram,e)}loginWithEmail(e){return this.login(Ue.LoginWithEmail,e)}loginWithGoogle(e){return this.login(Ue.LoginWithGoogle,e)}loginWithPlatformToken(e){return this.login(Ue.LoginWithPlatformToken,e)}registerWithEmail(e){return this.login(Ue.RegisterWithEmail,e)}requestWalletChallenge(e){return this.ctx.transport.post(this.endpoint(Ue.RequestWalletChallenge),e,yo,{ticket:null})}loginWithWallet(e){return this.login(Ue.LoginWithWallet,e)}forgotPassword(e){return this.ctx.transport.post(this.endpoint(Ue.ForgotPassword),e,Se,{ticket:null})}resetPassword(e){return this.ctx.transport.post(this.endpoint(Ue.ResetPassword),e,Se,{ticket:null})}};var hi=z.object({TitleConfigVersion:z.string().nullish(),TitleConfigUrl:z.string().nullish(),User:z.unknown().nullish(),StateVersions:z.record(z.string(),z.number()).nullish(),StateEpoch:z.string().nullish()}).passthrough().transform(a=>a),Co=z.object({StateEpoch:z.string().nullish(),StateVersions:z.record(z.string(),z.number()).nullish()}).passthrough().transform(a=>a),So=z.object({StateEpoch:z.string().nullish(),StateVersions:z.record(z.string(),z.number()).nullish(),User:z.unknown().nullish()}).passthrough().transform(a=>a),xo=z.object({}).passthrough().transform(a=>a),Do=z.object({}).passthrough().transform(a=>a),bo=z.object({Today:z.number(),Yesterday:z.number(),CurrentWeek:z.number(),CurrentMonth:z.number(),Total:z.number(),TotalSessions:z.number(),FirstActiveAt:l.nullish(),LastActiveAt:l.nullish(),LongestSessionEverSeconds:z.number().nullish(),CurrentWeekActiveHoursMask:z.number().nullish(),CurrentMonthActiveHoursMask:z.number().nullish(),ReactivationCount:z.number().nullish(),History:z.record(z.string(),z.unknown()).nullish()}).passthrough(),zo=z.object({Username:z.string()}),Oe={GetClientState:"GetClientState",GetClientStateExcept:"GetClientStateExcept",GetStateVersions:"GetStateVersions",GetUserState:"GetUserState",GetInventory:"GetInventory",GetEventTokens:"GetEventTokens",GetUsageTime:"GetUsageTime",AddUsageTime:"AddUsageTime",DeleteUserAccount:"DeleteUserAccount",ChangeUsername:"ChangeUsername"};var As=class{constructor(e){this.ctx=e;}ctx;endpoint(e,t){return U(this.ctx.settings.titleID,"User",e,t??"")}getClientState(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientState,e.UserID),e,hi,{ticket:e.ClientSessionTicket})}getClientStateExcept(e){return this.ctx.transport.post(this.endpoint(Oe.GetClientStateExcept,e.UserID),e,hi,{ticket:e.ClientSessionTicket})}getStateVersions(e){return this.ctx.transport.post(this.endpoint(Oe.GetStateVersions,e.UserID),e,Co,{ticket:e.ClientSessionTicket})}getUserState(e){return this.ctx.transport.post(this.endpoint(Oe.GetUserState,e.UserID),e,So,{ticket:e.ClientSessionTicket})}getInventory(e){return this.ctx.transport.post(this.endpoint(Oe.GetInventory,e.UserID),e,xo,{ticket:e.ClientSessionTicket})}getEventTokens(e){return this.ctx.transport.post(this.endpoint(Oe.GetEventTokens,e.UserID),e,Do,{ticket:e.ClientSessionTicket})}getUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.GetUsageTime,e.UserID),e,bo,{ticket:e.ClientSessionTicket})}addUsageTime(e){return this.ctx.transport.post(this.endpoint(Oe.AddUsageTime,e.UserID),e,Se,{ticket:e.ClientSessionTicket,silent:true})}deleteUserAccount(e){return this.ctx.transport.post(this.endpoint(Oe.DeleteUserAccount,e.UserID),e,Se,{ticket:e.ClientSessionTicket})}changeUsername(e){return this.ctx.transport.post(this.endpoint(Oe.ChangeUsername,e.UserID),e,zo,{ticket:e.ClientSessionTicket})}};var Us=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Currency",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}convert(e){return this.send(Cs.Convert,e,Cn)}cryptoConvert(e){return this.send(Cs.CryptoConvert,e,Sn)}};var Tp=z.object({ItemInstanceID:z.string(),Units:z.number(),Level:z.number()}),mi=z.object({ServerTimeUtc:l,ItemInstanceID:z.string(),ItemID:z.string(),CatalogID:z.string().nullish(),Level:z.number(),Resources:x.nullish(),FodderConsumed:z.array(Tp).nullish()}),vo=z.array(se(mi)),Os={UpgradeLevel:"UpgradeLevel",UpgradeLevelsBatch:"UpgradeLevelsBatch"},Pp={FlatCount:"FlatCount",Merge:"Merge",InvestmentRefund:"InvestmentRefund"},Ip=z.enum(["FlatCount","Merge","InvestmentRefund"]),Mp={ProtectLeveled:"ProtectLeveled",CheapestFirst:"CheapestFirst",ClientSelected:"ClientSelected"},kp=z.enum(["ProtectLeveled","CheapestFirst","ClientSelected"]),Ap=z.object({ContractAddress:z.string().nullish(),TokenID:z.string().nullish(),TokenStandard:z.string().nullish()}).passthrough(),Up=z.object({Networks:z.record(z.string(),Ap).nullish(),MetadataUrl:z.string().nullish()}).passthrough(),Op=z.object({FlatBonuses:z.record(z.string(),z.number()).nullish(),PercentBonuses:z.record(z.string(),z.number()).nullish(),Power:z.number().nullish()}).passthrough(),Bp=z.object({MinCharacterLevel:z.number().nullish(),UseRequirements:z.record(z.string(),z.number()).nullish(),AllowedCharacterIDs:z.array(z.string()).nullish(),AllowedSlotIDs:z.array(z.string()).nullish()}).passthrough(),wp=z.object({ValuationMode:Ip.nullish(),MergeRatio:z.number().nullish(),Selection:kp.nullish()}).passthrough(),qp=z.object({MaxLevel:z.number().nullish(),BaseCostResource:K.nullish(),CostScalingFactor:z.number().nullish(),FlatScalingFactor:z.number().nullish(),PercentScalingFactor:z.number().nullish(),PowerScalingFactor:z.number().nullish(),Fodder:wp.nullish()}).passthrough(),Ep=z.object({RarityID:z.string().nullish(),CollectionID:z.string().nullish(),AuthorID:z.string().nullish()}).passthrough(),Lp=z.object({ItemID:z.string(),CatalogID:z.string(),ItemClass:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),Tags:z.array(z.string()).nullish(),CustomData:z.string().nullish(),IsStackable:z.boolean().nullish(),IsTradable:z.boolean().nullish(),Weight:z.number().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),NFT:Up.nullish(),Stats:Op.nullish(),Equipment:Bp.nullish(),Upgrade:qp.nullish(),Metadata:Ep.nullish(),ExpirationDurationSeconds:z.number().nullish()}).passthrough(),Gp=z.object({Items:z.record(z.string(),Lp).nullish()}).passthrough(),Bs=z.object({Catalogs:z.record(z.string(),Gp).nullish()}).passthrough();var ws=class{constructor(e){this.ctx=e;}ctx;upgradeLevel(e){let t=U(this.ctx.settings.titleID,"Item",Os.UpgradeLevel,e.UserID??"");return this.ctx.transport.post(t,e,mi,{ticket:e.ClientSessionTicket})}upgradeLevelsBatch(e){let t=U(this.ctx.settings.titleID,"Item",Os.UpgradeLevelsBatch,e.UserID??"");return this.ctx.transport.post(t,e,vo,{ticket:e.ClientSessionTicket})}};var fi=z.object({ServerTimeUtc:l,OfferID:z.string(),Count:z.number(),Resources:x.nullish()}),To=z.array(se(fi)),Np=z.object({OfferID:z.string(),TotalPurchases:z.number(),DailyPurchases:z.number(),DailyResetUtc:l,LastPurchasedAt:l}),Po=z.object({Purchases:z.record(z.string(),Np).nullish()}).passthrough().transform(a=>a),jp=z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),RequiredFlags:z.array(z.string()).nullish()}).passthrough(),Fp=z.object({StoreID:z.string(),Type:z.string().nullish(),Name:z.string().nullish(),Description:z.string().nullish(),Rules:jp.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),Vp=z.object({StartUtc:l.nullish(),EndUtc:l.nullish(),Gate:Q.nullish(),Limits:pe.nullish()}).passthrough(),_p=z.object({OfferID:z.string(),StoreIDs:z.array(z.string()).nullish(),Name:z.string().nullish(),Cost:K.nullish(),Rewards:G.nullish(),Rules:Vp.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),qs=z.object({Stores:z.record(z.string(),Fp).nullish(),StoreOffers:z.record(z.string(),_p).nullish()}).passthrough(),dt={Purchase:"Purchase",GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",PurchaseBatch:"PurchaseBatch"};var Es=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Store",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}purchase(e){return this.send(dt.Purchase,e,fi)}purchaseBatch(e){return this.send(dt.PurchaseBatch,e,To)}getDefinitions(e){return this.send(dt.GetDefinitions,e,qs)}getUserState(e){return this.send(dt.GetUserState,e,Po)}};var Wp=z.object({Min:z.number().nullish(),Max:z.number().nullish()}).passthrough(),Io=z.object({Reward:G.nullish(),Weight:z.number().nullish(),AmountRange:Wp.nullish()}).passthrough(),ht=z.object({SlotID:z.string().nullish(),MinRolls:z.number().nullish(),MaxRolls:z.number().nullish(),Pool:z.array(Io).nullish()}).passthrough(),mt=z.object({RuleID:z.string().nullish(),Threshold:z.number().nullish(),Pool:z.array(Io).nullish()}).passthrough(),Qp=z.object({RewardSlots:z.array(ht).nullish()}).passthrough(),Hp=z.object({PityRules:z.array(mt).nullish()}).passthrough(),Ls=z.object({SlotPresets:z.record(z.string(),Qp).nullish(),PityPresets:z.record(z.string(),Hp).nullish()}).passthrough();var Kp=z.object({RuleID:z.string(),BoxIndex:z.number().nullish()}),Mo=z.object({ServerTimeUtc:l,LootboxID:z.string(),OpenedCount:z.number().nullish(),SelectedOptionID:z.number().nullish(),Resources:x.nullish(),Inventory:Xe.nullish(),Results:z.array(x).nullish(),TriggeredPity:z.array(Kp).nullish()}),$p=z.object({PriceOptionID:z.number().nullish(),RequiredResources:K.nullish()}).passthrough(),Zp=z.object({RewardSlots:ie.nullish(),PityRules:ie.nullish()}).passthrough(),Jp=z.object({CatalogID:z.string().nullish(),ItemID:z.string().nullish(),MaxDrops:M.nullish()}).passthrough(),Yp=z.object({LootboxID:z.string(),AssetPaths:z.record(z.string(),z.string()).nullish(),PriceOptions:z.record(z.string(),$p).nullish(),RewardSlots:z.array(ht).nullish(),PityRules:z.array(mt).nullish(),Presets:Zp.nullish(),RewardMultiplier:At.nullish(),SupplyLimits:z.array(Jp).nullish()}).passthrough(),gi=z.object({Definitions:z.record(z.string(),Yp).nullish(),RewardPools:Ls.nullish()}).passthrough(),ko=z.object({LootboxDefinitions:gi.nullish()}),Gs={GetDefinitions:"GetDefinitions",Open:"Open"};var Ns=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Lootbox",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Gs.GetDefinitions,e,ko)}open(e){return this.send(Gs.Open,e,Mo)}};var Xp=z.object({}).passthrough().transform(a=>a),ed=z.object({}).passthrough().transform(a=>a),td=z.object({}).passthrough().transform(a=>a),sd=z.object({}).passthrough().transform(a=>a),rd=z.object({}).passthrough().transform(a=>a),Ao=z.object({ServerTimeUtc:l,CalendarID:z.string(),DayNumber:z.number().nullish(),DailyState:Xp,Resources:x.nullish()}),Uo=z.object({ServerTimeUtc:l,AccrualID:z.string(),AccruedSeconds:M.nullish(),AppliedRatePerSecond:z.number().nullish(),IdleState:ed,Resources:x.nullish()}),Oo=z.object({ServerTimeUtc:l,ComebackID:z.string(),ClaimedTierIndex:z.number().nullish(),ComebackState:td,Resources:x.nullish()}),Bo=z.object({ServerTimeUtc:l,ClaimID:z.string(),ClaimState:sd,Resources:x.nullish()}),wo=z.object({Enabled:z.boolean(),Multiplier:z.number().nullish(),Progress:M.nullish(),Source:z.string().nullish(),SourceKey:z.string().nullish()}),id=z.object({RewardMode:z.string().nullish(),RewardStackLowerTiers:z.boolean().nullish()}).passthrough(),nd=z.object({DayNumber:z.number().nullish(),Rewards:G.nullish(),IsMilestone:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),od=z.object({CalendarID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Days:z.array(nd).nullish(),IsLooping:z.boolean().nullish(),MissBehavior:z.string().nullish(),ResetByDays:z.number().nullish(),MissThresholdMultiplier:z.number().nullish(),ClaimMode:z.string().nullish(),ClaimCooldownSeconds:z.number().nullish(),Gate:Q.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),ad=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),Multiplier:z.number().nullish()}).passthrough(),ld=z.object({BaseRatePerSecond:z.number().nullish(),PowerCoefficient:z.number().nullish(),BoardRankCoefficient:z.number().nullish(),EquipmentBonusEnabled:z.boolean().nullish(),EquipmentCharacterID:z.string().nullish(),PremiumMultipliers:z.array(ad).nullish()}).passthrough(),ud=z.object({MinCharacterLevel:z.number().nullish(),RequirementsCharacterID:z.string().nullish(),Gate:Q.nullish(),RequiredItemIDs:z.array(z.string()).nullish(),RequiredEquippedItemIDs:z.array(z.string()).nullish()}).passthrough(),cd=z.object({AccrualID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rate:ld.nullish(),Rewards:G.nullish(),MaxAccumulationSeconds:z.number().nullish(),MinClaimSeconds:z.number().nullish(),Requirements:ud.nullish(),FirstClaimMode:z.string().nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),pd=z.object({MinAbsenceSeconds:z.number().nullish(),Rewards:G.nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),dd=z.object({ComebackID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tiers:z.array(pd).nullish(),ClaimCooldownSeconds:z.number().nullish(),ClaimWindowSeconds:z.number().nullish(),TrackPresenceOnRead:z.boolean().nullish(),Gate:Q.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),hd=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),CooldownSeconds:z.number().nullish(),MaxClaimsPerWindow:z.number().nullish(),WindowSeconds:z.number().nullish(),TotalClaimLimit:z.number().nullish()}).passthrough(),md=z.object({ClaimID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Mode:z.string().nullish(),Rewards:G.nullish(),Limits:pe.nullish(),PremiumLimitOverrides:z.array(hd).nullish(),Gate:Q.nullish(),AvailableFromUtc:z.string().nullish(),AvailableUntilUtc:z.string().nullish()}).passthrough(),Ri=z.object({TierRewards:id.nullish(),MilestoneRewardMultiplier:At.nullish(),DailyCalendars:z.record(z.string(),od).nullish(),IdleAccruals:z.record(z.string(),cd).nullish(),Comebacks:z.record(z.string(),dd).nullish(),Claims:z.record(z.string(),md).nullish()}).passthrough(),qo=z.object({RewardDefinitions:Ri.nullish()}),Eo=z.object({Rewards:rd.nullish()}),Ke={GetRewardDefinitions:"GetRewardDefinitions",GetUserRewardsState:"GetUserRewardsState",ClaimDailyReward:"ClaimDailyReward",CollectIdleAccrual:"CollectIdleAccrual",ClaimComebackReward:"ClaimComebackReward",ClaimReward:"ClaimReward",ClaimRewardsBatch:"ClaimRewardsBatch",GetMilestoneRewardMultiplier:"GetMilestoneRewardMultiplier"};var js=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Reward",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getRewardDefinitions(e){return this.send(Ke.GetRewardDefinitions,e,qo)}getUserRewardsState(e){return this.send(Ke.GetUserRewardsState,e,Eo)}getMilestoneRewardMultiplier(e){return this.send(Ke.GetMilestoneRewardMultiplier,e,wo)}claimDailyReward(e){return this.send(Ke.ClaimDailyReward,e,Ao)}collectIdleAccrual(e){return this.send(Ke.CollectIdleAccrual,e,Uo)}claimComebackReward(e){return this.send(Ke.ClaimComebackReward,e,Oo)}claimReward(e){return this.send(Ke.ClaimReward,e,Bo)}};var Fs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Quest",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getQuestDefinitions(e){return this.send(Le.GetQuestDefinitions,e,Bt)}getUserQuestState(e){return this.send(Le.GetUserQuestState,e,Qi)}refreshQuestCycles(e){return this.send(Le.RefreshQuestCycles,e,Se)}claimQuestReward(e){return this.send(Le.ClaimQuestReward,e,wr)}claimQuestRewardsBatch(e){return this.send(Le.ClaimQuestRewardsBatch,e,$i)}claimMilestoneReward(e){return this.send(Le.ClaimMilestoneReward,e,qr)}claimMilestoneRewardsBatch(e){return this.send(Le.ClaimMilestoneRewardsBatch,e,Zi)}claimGroupCompletionReward(e){return this.send(Le.ClaimGroupCompletionReward,e,Hi)}addQuestProgress(e){return this.send(Le.AddQuestProgress,e,Ki)}};var Lo=z.object({}).passthrough().transform(a=>a);var fd=z.object({Order:z.number().nullish(),Type:z.string().nullish(),DurationSec:z.number().nullish(),BonusMultiplier:z.number().nullish()}).passthrough(),gd=z.object({Schedule:z.array(fd).nullish(),RepeatCycle:z.boolean().nullish(),MaxCycles:z.number().nullish()}).passthrough(),Rd=z.object({IsActive:z.boolean().nullish(),CurrentPhaseEndUtc:l.nullish(),NextBonusStartUtc:l.nullish(),CurrentCycleIndex:z.number().nullish(),CurrentPhaseIndex:z.number().nullish(),ActiveBonusMultiplier:z.number().nullish()}).passthrough(),yd=z.object({Milestones:ie.nullish()}).passthrough(),yi=z.object({DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Category:z.string().nullish(),Token:st.nullish(),TokenSources:z.array(_e).nullish(),ClaimMode:z.string().nullish(),Milestones:z.record(z.string(),ye).nullish(),Presets:yd.nullish(),BonusWindow:gd.nullish()}).passthrough(),Cd=z.object({ChainedEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),Content:yi.nullish(),ClaimGraceHours:z.number().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Sd=z.object({TimedEventID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Schedule:ce.nullish(),Content:yi.nullish(),Events:z.array(Cd).nullish(),Gate:Q.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),xd=z.object({MaxConcurrentEvents:z.number().nullish()}).passthrough(),Dd=z.object({Milestones:z.record(z.string(),Ye).nullish()}).passthrough(),Vs=z.object({Definitions:z.record(z.string(),Sd).nullish(),Settings:xd.nullish(),Presets:Dd.nullish()}).passthrough(),bd=z.object({Type:Ct,TimedEventID:z.string(),CurrentChainedEventID:z.string().nullish(),Content:yi.nullish(),Progress:Lo.nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),CanEarn:z.boolean().nullish(),CanClaim:z.boolean().nullish(),NextMilestone:ye.nullish(),BonusWindow:Rd.nullish(),CurrentCycleIndex:z.number().nullish(),CurrentEventOrder:z.number().nullish(),TotalEventsInChain:z.number().nullish()}).passthrough(),Go=z.object({ActiveEvents:z.array(bd).nullish()}).passthrough(),No=z.object({Tokens:z.record(z.string(),Lo).nullish()}),Ci=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),Resources:x.nullish()}),Si=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),MilestoneID:z.string().nullish(),Rewards:x.nullish()}),zd=z.object({Type:Ct.nullish(),LteID:z.string().nullish(),Resources:x.nullish()}),xi=z.array(se(Si)),jo=z.array(se(Ci)),Fo=z.array(se(zd)),Be={GetActiveEvents:"GetActiveEvents",GrantTokens:"GrantTokens",SpendTokens:"SpendTokens",ClaimMilestone:"ClaimMilestone",GetDefinitions:"GetDefinitions",GetUserLteState:"GetUserLteState",ClaimMilestonesBatch:"ClaimMilestonesBatch",ClaimAllMilestones:"ClaimAllMilestones",SpendTokensBatch:"SpendTokensBatch",GrantTokensBatch:"GrantTokensBatch"};var _s=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getActiveEvents(e){return this.send(Be.GetActiveEvents,e,Go)}getDefinitions(e){return this.send(Be.GetDefinitions,e,Vs)}getUserLteState(e){return this.send(Be.GetUserLteState,e,No)}grantTokens(e){return this.send(Be.GrantTokens,e,x)}spendTokens(e){return this.send(Be.SpendTokens,e,Ci)}claimMilestone(e){return this.send(Be.ClaimMilestone,e,Si)}claimMilestonesBatch(e){return this.send(Be.ClaimMilestonesBatch,e,xi)}claimAllMilestones(e){return this.send(Be.ClaimAllMilestones,e,xi)}spendTokensBatch(e){return this.send(Be.SpendTokensBatch,e,jo)}grantTokensBatch(e){return this.send(Be.GrantTokensBatch,e,Fo)}};var vd=z.object({UserID:z.string(),Score:M.nullish(),Rank:z.number().nullish(),LastScoreUpdateUtc:l.nullish(),IpHash:z.string().nullish(),PublicProfile:Ce.nullish(),SeasonTierAtCycleEnd:z.number().nullish()}).passthrough(),bt=z.object({LeaderboardID:z.string(),CycleVersion:z.number().nullish(),TotalParticipants:M.nullish(),CycleEndUtc:l.nullish(),TopUsers:z.array(vd).nullish(),BracketID:z.string().nullish()}),Td=z.object({CycleKey:z.string().nullish(),CycleEndUtc:l.nullish(),ClaimDeadlineUtc:l.nullish(),MilestoneTokensEarned:M.nullish(),ClaimableMilestoneIDs:z.array(z.string()).nullish(),CycleIndex:z.number().nullish(),ChainedEventID:z.string().nullish()}).passthrough(),Ws=z.object({LeaderboardID:z.string(),CurrentScore:M.nullish(),LastKnownRank:z.number().nullish(),HasUnclaimedReward:z.boolean().nullish(),ScoreEarnedThisCycle:M.nullish(),MilestoneTokensEarned:M.nullish(),NextMilestone:ye.nullish(),HasUnclaimedMilestone:z.boolean().nullish(),ClaimableGraceCycles:z.array(Td).nullish()}),Qs=z.object({LeaderboardID:z.string(),NewScore:M,CycleVersion:z.number()}),Hs=z.object({ServerTimeUtc:l,LeaderboardID:z.string(),Rank:z.number().nullish(),Resources:x.nullish()}),Ks=z.object({ServerTimeUtc:l,LeaderboardID:z.string(),MilestoneID:z.string(),Resources:x.nullish()}),Vo=z.array(se(bt)),_o=z.array(se(Ws)),Wo=z.array(se(Hs)),Qo=z.array(se(Ks)),Ho=z.array(se(Qs)),Pd=z.object({LeaderboardID:z.string(),CycleReward:se(Hs).nullish(),Milestones:z.array(se(Ks)).nullish()}),Ko=z.array(Pd),Id=z.object({LeaderboardID:z.string(),Leaderboard:se(bt).nullish(),Progress:se(Ws).nullish()}),$o=z.array(Id),Md=z.string(),Zo=z.object({Rank:z.string().nullish(),Rewards:G.nullish(),SeasonTierRewards:Or.nullish()}).passthrough(),kd=z.object({RankRewards:z.array(Zo).nullish()}).passthrough(),Ad=z.object({ChainedEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),ClaimGraceHours:z.number().nullish()}).passthrough(),Ud=z.object({Milestones:ie.nullish(),RankRewards:ie.nullish()}).passthrough(),Od=z.object({LeaderboardID:z.string(),DisplayName:z.string().nullish(),ScoreDisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),IsEnabled:z.boolean().nullish(),ScoreAggregation:Md.nullish(),Schedule:ce.nullish(),ChainEvents:z.array(Ad).nullish(),Gate:Q.nullish(),TopUsersLimit:z.number().nullish(),MinScoreToEnterTop:z.number().nullish(),BracketSize:z.number().nullish(),LinkedSeasonChainID:z.string().nullish(),RankRewards:z.array(Zo).nullish(),Milestones:z.record(z.string(),ye).nullish(),Presets:Ud.nullish(),MilestoneClaimMode:z.string().nullish(),MilestoneClaimGraceHours:z.number().nullish(),ScoreSources:z.array(_e).nullish()}).passthrough(),Bd=z.object({Milestones:z.record(z.string(),Ye).nullish(),RankRewards:z.record(z.string(),kd).nullish()}).passthrough(),$s=z.object({Definitions:z.record(z.string(),Od).nullish(),Presets:Bd.nullish()}).passthrough(),fe={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 Zs=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Leaderboard",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(fe.GetDefinitions,e,$s)}getLeaderboard(e){return this.send(fe.GetLeaderboard,e,bt)}getMyProgress(e){return this.send(fe.GetMyProgress,e,Ws)}submitScore(e){return this.send(fe.SubmitScore,e,Qs)}submitScoreFromSource(e){return this.send(fe.SubmitScoreFromSource,e,Qs)}claimCycleReward(e){return this.send(fe.ClaimCycleReward,e,Hs)}claimMilestone(e){return this.send(fe.ClaimMilestone,e,Ks)}getFriendsLeaderboard(e){return this.send(fe.GetFriendsLeaderboard,e,bt)}getLeaderboardsBatch(e){return this.send(fe.GetLeaderboardsBatch,e,Vo)}getProgressBatch(e){return this.send(fe.GetProgressBatch,e,_o)}claimCycleRewardsBatch(e){return this.send(fe.ClaimCycleRewardsBatch,e,Wo)}claimMilestonesBatch(e){return this.send(fe.ClaimMilestonesBatch,e,Qo)}submitScoresBatch(e){return this.send(fe.SubmitScoresBatch,e,Ho)}claimAllRewardsBatch(e){return this.send(fe.ClaimAllRewardsBatch,e,Ko)}getOverviewBatch(e){return this.send(fe.GetOverviewBatch,e,$o)}};var Di=z.object({}).passthrough().transform(a=>a),Jo=z.object({SeasonChainID:z.string(),CycleIndex:z.number().nullish(),Season:z.lazy(()=>ta).nullish(),ComputedStartUtc:l.nullish(),ComputedEndUtc:l.nullish(),SecondsRemaining:M.nullish(),UserState:Di.nullish(),NextTier:z.lazy(()=>ea).nullish()}).passthrough(),Yo=z.object({SeasonChainID:z.string(),CurrentSeasonID:z.string().nullish(),AmountGranted:M.nullish(),NewStatusTokens:M.nullish(),OldTier:z.number().nullish(),NewTier:z.number(),TierUp:z.boolean().nullish()}),Xo=z.object({SeasonChainID:z.string(),CurrentSeasonID:z.string().nullish(),TierNumber:z.number(),Resources:x.nullish()});var ea=z.object({Tier:z.number().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),RequiredTokens:M.nullish(),TierReachedReward:G.nullish()}).passthrough(),ta=z.object({SeasonID:z.string().nullish(),Order:z.number().nullish(),DurationSec:M.nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tiers:z.array(ea).nullish(),LinkedCollectionID:z.string().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough();var wd=z.object({SeasonChainID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:ce.nullish(),Seasons:z.array(ta).nullish(),GrantTokensAccessMode:z.string().nullish(),Gate:Q.nullish()}).passthrough(),Js=z.object({Chains:z.record(z.string(),wd).nullish()}).passthrough(),it={GetDefinitions:"GetDefinitions",GetActiveSeason:"GetActiveSeason",GetUserState:"GetUserState",GrantStatusTokens:"GrantStatusTokens",ClaimTierReward:"ClaimTierReward"};var Ys=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Season",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(it.GetDefinitions,e,Js)}getActiveSeason(e){return this.send(it.GetActiveSeason,e,Jo)}getUserState(e){return this.send(it.GetUserState,e,Di)}grantStatusTokens(e){return this.send(it.GrantStatusTokens,e,Yo)}claimTierReward(e){return this.send(it.ClaimTierReward,e,Xo)}};var qd={Apple:"Apple",Google:"Google"},sa=z.object({}).passthrough().transform(a=>a),Ed=z.object({PremiumID:z.string().nullish(),PurchaseDate:z.string().nullish(),ExpirationDate:z.string().nullish(),TransactionID:z.string().nullish(),IsAutoRenewEnabled:z.boolean().nullish()}).passthrough(),Ld=z.object({OptionID:z.string().nullish(),Name:z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Gd=z.object({PremiumID:z.string().nullish(),DisplayName:z.string().nullish(),Tier:z.number().nullish(),DurationDays:z.number().nullish(),TrialDurationDays:z.number().nullish(),PriceOptions:z.record(z.string(),Ld).nullish(),AppleProductID:z.string().nullish(),GoogleProductID:z.string().nullish(),Benefits:z.record(z.string(),z.string()).nullish()}).passthrough(),bi=z.object({Definitions:z.record(z.string(),Gd).nullish()}).passthrough(),ra=z.object({Premium:bi.nullish()}),ia=z.object({ServerTimeUtc:l.nullish(),Premium:sa.nullish()}),Xs=z.object({ServerTimeUtc:l.nullish(),Premium:sa.nullish(),Subscription:Ed.nullish(),Resources:x.nullish()}),nt={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateTrial:"ActivateTrial",PurchaseWithResources:"PurchaseWithResources",PurchaseRealMoney:"PurchaseRealMoney"};var er=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Premium",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(nt.GetDefinitions,e,ra)}getUserState(e){return this.send(nt.GetUserState,e,ia)}activateTrial(e){return this.send(nt.ActivateTrial,e,Xs)}purchaseItemOrCurrency(e){return this.send(nt.PurchaseWithResources,e,Xs)}purchaseRealMoney(e){return this.send(nt.PurchaseRealMoney,e,Xs)}};var tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Character",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getCharacterDefinitions(e){return this.send(Te.GetCharacterDefinitions,e,xs)}getUserCharacters(e){return this.send(Te.GetUserCharacters,e,vn)}unlockCharacter(e){return this.send(Te.UnlockCharacter,e,Yr)}upgradeStatLevel(e){return this.send(Te.UpgradeStatLevel,e,Zr)}upgradeCharacterLevel(e){return this.send(Te.UpgradeCharacterLevel,e,Jr)}equipItems(e){return this.send(Te.EquipItems,e,Tn)}unequipItems(e){return this.send(Te.UnequipItems,e,Pn)}unequipAllCharacters(e){return this.send(Te.UnequipAllCharacters,e,In)}unlockCharactersBatch(e){return this.send(Te.UnlockCharactersBatch,e,Mn)}upgradeCharacterLevelsBatch(e){return this.send(Te.UpgradeCharacterLevelsBatch,e,kn)}upgradeStatLevelsBatch(e){return this.send(Te.UpgradeStatLevelsBatch,e,An)}};var sr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Match",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createMatch(e){return this.send(je.CreateMatch,e,to)}updateMatch(e){return this.send(je.UpdateMatch,e,so)}cancelMatch(e){return this.send(je.CancelMatch,e,ro)}instantBattle(e){return this.send(je.InstantBattle,e,io)}saveStrategy(e){return this.send(je.SaveStrategy,e,Se)}getMyMatches(e){return this.send(je.GetMyMatches,e,ni)}getAvailableMatches(e){return this.send(je.GetAvailableMatches,e,ni)}getDefinitions(e){return this.send(je.GetDefinitions,e,lo)}};var Nd={TradeUpRarity:"TradeUpRarity",TradeUpCollection:"TradeUpCollection"},na=z.enum(["TradeUpRarity","TradeUpCollection"]),jd=z.object({Index:z.number().nullish(),BurnedItemIDs:z.array(z.string()).nullish(),RolledCollectionID:z.string().nullish(),UsedCollections:z.record(z.string(),z.number()).nullish(),Output:Ur.nullish()}),oa=z.object({ServerTimeUtc:l,Type:na.nullish(),CraftID:z.string(),CraftedCount:z.number().nullish(),SelectedOptionID:z.string().nullish(),InputRarity:z.string().nullish(),OutputRarity:z.string().nullish(),Resources:x.nullish(),Results:z.array(jd).nullish()}),Fd=z.object({OptionID:z.string().nullish(),RequiredResources:K.nullish()}).passthrough(),Vd=z.object({CraftID:z.string().nullish(),Type:na.nullish(),CatalogID:z.string().nullish(),CollectionID:z.string().nullish(),InputRarityID:z.string().nullish(),OutputRarityID:z.string().nullish(),RequiredItemCount:z.number().nullish(),PriceOptions:z.record(z.string(),Fd).nullish()}).passthrough(),zi=z.object({Definitions:z.record(z.string(),Vd).nullish()}).passthrough(),aa=z.object({ServerTimeUtc:l.nullish(),CraftDefinitions:zi.nullish()}),rr={GetDefinitions:"GetDefinitions",Craft:"Craft"};var ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Craft",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(rr.GetDefinitions,e,aa)}craft(e){return this.send(rr.Craft,e,oa)}};var _d={Pending:"Pending",Accepted:"Accepted",Declined:"Declined",Cancelled:"Cancelled",Expired:"Expired"},Wd=z.enum(["Pending","Accepted","Declined","Cancelled","Expired"]),la=z.object({}).passthrough().transform(a=>a),nr=z.object({CollectibleID:z.string(),Rarity:z.number().nullish(),IsSpecial:z.boolean().nullish(),IsDuplicate:z.boolean().nullish(),CollectionCurrencyConverted:z.number().nullish()}),ua=z.object({GrantedCollectibles:z.array(nr).nullish(),DuplicateCollectibles:z.array(nr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),NewlyCompletedSetIDs:z.array(z.string()).nullish(),CollectionJustCompleted:z.boolean().nullish(),Resources:x.nullish(),TriggeredPity:z.array(z.unknown()).nullish()}),ca=z.object({GrantedCollectibles:z.array(nr).nullish(),DuplicateCollectibles:z.array(nr).nullish(),CollectionCurrencyEarned:M.nullish(),NewCollectionCurrencyBalance:M.nullish(),Resources:x.nullish(),TriggeredPity:z.array(z.unknown()).nullish()}),pa=z.object({GrantedCollectibleID:z.string().nullish(),NewlyCompletedSetID:z.string().nullish(),CollectionJustCompleted:z.boolean().nullish(),Resources:x.nullish()}),vi=z.object({SetID:z.string(),Resources:x.nullish()}),da=z.array(se(vi)),ha=z.object({Resources:x.nullish()}),Qd=z.object({OfferID:z.string(),TitleID:z.string().nullish(),CollectionID:z.string().nullish(),SenderUserID:z.string().nullish(),SenderPublicData:Ce.nullish(),OfferedCollectibleID:z.string().nullish(),OfferedCollectibleIsSpecial:z.boolean().nullish(),ReceiverUserID:z.string().nullish(),RequestedCollectibleID:z.string().nullish(),RequestedCollectibleIsSpecial:z.boolean().nullish(),Status:Wd.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RespondedAtUtc:l.nullish(),DeclineReason:z.string().nullish(),IsSpecialTradeEvent:z.boolean().nullish(),SpecialTradeEventID:z.string().nullish()}).passthrough(),ma=z.object({OfferID:z.string(),ExpiresAtUtc:l.nullish(),Resources:x.nullish()}),fa=z.object({OfferID:z.string(),Resources:x.nullish()}),ga=z.object({OfferID:z.string(),ReceivedCollectibleID:z.string().nullish(),ReceivedIsSpecial:z.boolean().nullish(),SentCollectibleID:z.string().nullish(),SentCollectibleIsSpecial:z.boolean().nullish(),Transfer:z.unknown().nullish()}),Ra=z.object({OfferID:z.string(),Resources:x.nullish()}),Ti=z.object({Offers:z.array(Qd).nullish()}),Hd=z.object({CollectibleID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rarity:z.number().nullish(),HasSpecialVersion:z.boolean().nullish(),SortOrder:z.number().nullish()}).passthrough(),Kd=z.object({SetID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),SortOrder:z.number().nullish(),Collectibles:z.array(Hd).nullish(),SetCompletionReward:G.nullish()}).passthrough(),$d=z.object({CollectionID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),SeasonChainID:z.string().nullish(),Sets:z.array(Kd).nullish(),GrandPrize:G.nullish()}).passthrough(),ya=z.object({BonusRewardSlots:ie.nullish(),PityRules:ie.nullish()}).passthrough(),Zd=z.object({PackTypeID:z.string().nullish(),Cost:K.nullish(),BonusRewardSlots:z.array(ht).nullish(),PityRules:z.array(mt).nullish(),Presets:ya.nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CollectibleCount:z.number().nullish(),GuaranteedMinRarity:z.number().nullish(),GuaranteeMaxRarity:z.boolean().nullish(),RarityWeights:z.record(z.string(),z.number()).nullish(),ColorTier:z.number().nullish()}).passthrough(),Jd=z.object({Rarity:z.number().nullish(),CollectionCurrencyGranted:z.number().nullish()}).passthrough(),Yd=z.object({CollectionChestID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),CollectionCurrencyCost:z.number().nullish(),MinCollectibleCount:z.number().nullish(),MaxCollectibleCount:z.number().nullish(),GuaranteedMinRarity:z.number().nullish(),BonusRewardSlots:z.array(ht).nullish(),PityRules:z.array(mt).nullish(),Presets:ya.nullish(),Tier:z.number().nullish()}).passthrough(),Xd=z.object({SpecialTradeEventID:z.string().nullish(),StartUtc:l.nullish(),EndUtc:l.nullish(),AllowedSpecialCollectibleIDs:z.array(z.string()).nullish(),SpecialTradeEventDailyTradeLimit:z.number().nullish()}).passthrough(),or=z.object({Collections:z.record(z.string(),$d).nullish(),PackTypes:z.record(z.string(),Zd).nullish(),CollectionChests:z.array(Yd).nullish(),DuplicateConversions:z.array(Jd).nullish(),DailyTradeLimit:z.number().nullish(),CollectibleJokerCatalogID:z.string().nullish(),CollectibleJokerItemID:z.string().nullish(),SpecialTradeEvents:z.array(Xd).nullish(),RewardPools:Ls.nullish()}).passthrough(),xe={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 ar=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Collection",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(xe.GetDefinitions,e,or)}getUserState(e){return this.send(xe.GetUserState,e,la)}openPack(e){return this.send(xe.OpenPack,e,ua)}openCollectionChest(e){return this.send(xe.OpenCollectionChest,e,ca)}useCollectibleJoker(e){return this.send(xe.UseCollectibleJoker,e,pa)}claimSetReward(e){return this.send(xe.ClaimSetReward,e,vi)}claimSetRewardsBatch(e){return this.send(xe.ClaimSetRewardsBatch,e,da)}claimGrandPrize(e){return this.send(xe.ClaimGrandPrize,e,ha)}sendTradeOffer(e){return this.send(xe.SendTradeOffer,e,ma)}cancelTradeOffer(e){return this.send(xe.CancelTradeOffer,e,fa)}acceptTradeOffer(e){return this.send(xe.AcceptTradeOffer,e,ga)}declineTradeOffer(e){return this.send(xe.DeclineTradeOffer,e,Ra)}getMyTradeOffers(e){return this.send(xe.GetMyTradeOffers,e,Ti)}getIncomingTradeOffers(e){return this.send(xe.GetIncomingTradeOffers,e,Ti)}};var eh=z.object({}).passthrough().transform(a=>a),th={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},sh={Active:"Active",Left:"Left",Replaced:"Replaced"},rh=z.object({ObjectIndex:z.number().nullish(),ObjectCompletionRewardClaimed:z.boolean().nullish()}).passthrough(),ih=z.object({UserID:z.string().nullish(),PublicData:Ce.nullish(),BuildObjectsProgress:rh.nullish(),IsBot:z.boolean().nullish(),SpinsCount:z.number().nullish(),TokensSpent:z.number().nullish(),MemberStatus:z.string().nullish(),GrandPrizeClaimed:z.boolean().nullish(),JoinedAtUtc:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),nh=z.object({Index:z.number().nullish(),OwnerUserID:z.string().nullish(),CurrentProgress:z.number().nullish(),MaxProgress:z.number().nullish(),IsCompleted:z.boolean().nullish()}).passthrough(),oh=z.object({Objects:z.array(nh).nullish()}).passthrough(),Ca=z.object({GroupID:z.string().nullish(),TitleID:z.string().nullish(),CoopChainID:z.string().nullish(),CoopEventID:z.string().nullish(),CycleIndex:z.number().nullish(),Members:z.array(ih).nullish(),BuildObjectsState:oh.nullish(),Status:z.string().nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:z.number().nullish()}).passthrough(),Sa=z.object({CoopChainID:z.string()}).passthrough(),ah=z.string(),xa=z.object({DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Weight:z.number().nullish(),MinProgress:z.number().nullish(),MaxProgress:z.number().nullish()}).passthrough(),lh=z.object({Index:z.number().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxProgress:z.number().nullish(),CompletionReward:G.nullish()}).passthrough(),uh=z.object({Objects:z.array(lh).nullish(),SpinCost:K.nullish(),SpinnerTable:z.array(xa).nullish()}).passthrough(),ch=z.object({CoopEventID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),EventType:ah.nullish(),PartnerCount:z.number().nullish(),MatchmakingTimeoutMinutes:z.number().nullish(),MemberGracePeriodMinutes:z.number().nullish(),BuildObjects:uh.nullish(),GrandPrize:G.nullish()}).passthrough(),ph=z.object({CoopChainID:z.string().nullish(),DisplayName:z.string().nullish(),Schedule:ce.nullish(),Events:z.array(ch).nullish(),Gate:Q.nullish()}).passthrough(),Da=z.object({ServerTimeUtc:l.nullish(),UserState:eh.nullish(),ActiveGroup:Ca.nullish()}),Pi=z.object({ServerTimeUtc:l.nullish(),Group:Ca.nullish(),SecondsRemaining:M.nullish()}),ba=z.object({ServerTimeUtc:l.nullish(),GroupID:z.string().nullish(),Resources:x.nullish(),ObjectIndex:z.number().nullish(),Sector:xa.nullish(),ProgressDelta:z.number().nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),ObjectCompleted:z.boolean().nullish(),AllObjectsCompleted:z.boolean().nullish()}),Ii=z.object({ServerTimeUtc:l.nullish(),GroupID:z.string().nullish(),RewardType:z.string().nullish(),Resources:x.nullish()}),za=z.object({ServerTimeUtc:l.nullish(),GroupID:z.string().nullish(),Success:z.boolean().nullish()}),lr=z.object({Chains:z.record(z.string(),ph).nullish()}).passthrough(),Ne={GetDefinitions:"GetDefinitions",GetActiveEvent:"GetActiveEvent",GetUserState:"GetUserState",GetGroupState:"GetGroupState",JoinOrCreateGroup:"JoinOrCreateGroup",Spin:"Spin",ClaimObjectReward:"ClaimObjectReward",ClaimGrandPrize:"ClaimGrandPrize",LeaveGroup:"LeaveGroup"};var ur=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"CoopEvent",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Ne.GetDefinitions,e,lr)}getActiveEvent(e){return this.send(Ne.GetActiveEvent,e,Sa)}getUserState(e){return this.send(Ne.GetUserState,e,Da)}getGroupState(e){return this.send(Ne.GetGroupState,e,Pi)}joinOrCreateGroup(e){return this.send(Ne.JoinOrCreateGroup,e,Pi)}spin(e){return this.send(Ne.Spin,e,ba)}claimObjectReward(e){return this.send(Ne.ClaimObjectReward,e,Ii)}claimGrandPrize(e){return this.send(Ne.ClaimGrandPrize,e,Ii)}leaveGroup(e){return this.send(Ne.LeaveGroup,e,za)}};var dh={Active:"Active",Exhausted:"Exhausted",Expired:"Expired",Dismissed:"Dismissed"},hh={Locked:"Locked",Available:"Available",InProgress:"InProgress",Completed:"Completed",Hidden:"Hidden"},mh=z.object({NodeID:z.string().nullish(),Status:z.string().nullish(),ExecutionCount:z.number().nullish(),UnlockedAtUtc:l.nullish(),CompletedAtUtc:l.nullish(),LastExecutedAtUtc:l.nullish(),NextAvailableAtUtc:l.nullish(),LastExecutionRefID:z.string().nullish()}).passthrough(),fh=z.object({TrackID:z.string().nullish(),CurrentValue:z.number().nullish(),LastUpdatedUtc:l.nullish()}).passthrough(),va=z.object({OfferID:z.string().nullish(),InstanceKey:z.string().nullish(),SourceOfferVersion:z.number().nullish(),Status:z.string().nullish(),ActivatedAtUtc:l.nullish(),ExhaustedAtUtc:l.nullish(),ExpiredAtUtc:l.nullish(),DismissedAtUtc:l.nullish(),ShowCount:z.number().nullish(),LastShownAtUtc:l.nullish(),Nodes:z.record(z.string(),mh).nullish(),Tracks:z.record(z.string(),fh).nullish(),SelectedChoiceNodeID:z.string().nullish()}).passthrough(),gh=z.object({SlotID:z.string().nullish(),QueueIndex:z.number().nullish(),CycleIndex:z.number().nullish(),ActiveOfferID:z.string().nullish(),ActiveOfferStartedAtUtc:l.nullish(),ActiveOfferExpiresAtUtc:l.nullish(),ActiveOffer:va.nullish(),NextCycleStartsAtUtc:l.nullish(),LastUpdatedUtc:l.nullish(),DismissSkipAvailableAtUtc:l.nullish(),LastDismissedAtUtc:l.nullish()}).passthrough(),Rh=z.object({TotalExecutions:z.number().nullish(),DailyExecutions:z.number().nullish(),DailyResetUtc:l.nullish()}).passthrough(),yh=z.object({TotalActivations:z.number().nullish(),TotalExhausted:z.number().nullish(),TotalExpired:z.number().nullish(),TotalDismissed:z.number().nullish(),TotalShows:z.number().nullish(),LastShownAtUtc:l.nullish(),LastActivatedAtUtc:l.nullish(),LastExhaustedAtUtc:l.nullish(),NodeCounts:z.record(z.string(),Rh).nullish()}).passthrough(),Ch=z.object({Slots:z.record(z.string(),gh).nullish(),OfferHistory:z.record(z.string(),yh).nullish(),LastUpdatedUtc:l.nullish()}).passthrough();var Sh=z.object({Order:z.number().nullish(),OfferID:z.string().nullish(),DurationSec:z.number().nullish(),DelayBeforeActivationSec:z.number().nullish()}).passthrough(),xh=z.object({SlotID:z.string().nullish(),Enabled:z.boolean().nullish(),SortOrder:z.number().nullish(),Queue:z.array(Sh).nullish(),Schedule:ce.nullish(),Gate:Q.nullish(),AllowDismissSkip:z.boolean().nullish(),DismissSkipDelaySec:z.number().nullish()}).passthrough(),Dh=z.object({StoreOfferID:z.string().nullish(),BillingProductID:z.string().nullish(),DirectCost:K.nullish(),UseExternalRewards:z.boolean().nullish()}).passthrough(),bh=z.object({AdPlacementID:z.string().nullish(),ViewsRequiredToComplete:z.number().nullish(),MaxViewsPerActivation:z.number().nullish(),CooldownSecondsBetweenViews:z.number().nullish(),RequireServerVerification:z.boolean().nullish(),GrantRewardsPerView:z.boolean().nullish()}).passthrough(),zh=z.object({Purchase:Dh.nullish(),RewardedVideo:bh.nullish()}).passthrough(),vh=z.object({TrackID:z.string().nullish(),Operator:z.string().nullish(),Value:z.number().nullish()}).passthrough(),Th=z.object({Milestones:ie.nullish()}).passthrough(),Ph=z.object({TrackID:z.string().nullish(),Amount:z.number().nullish(),RespectBounds:z.boolean().nullish()}).passthrough(),Ih=z.object({TrackID:z.string().nullish(),DisplayName:z.string().nullish(),StartValue:z.number().nullish(),MinValue:z.number().nullish(),MaxValue:z.number().nullish(),ClampToMin:z.boolean().nullish(),ClampToMax:z.boolean().nullish(),HiddenFromUI:z.boolean().nullish()}).passthrough(),Mh=z.object({RequiredCompletedNodeIDs:z.array(z.string()).nullish(),RequiredAnyCompletedNodeIDs:z.array(z.string()).nullish(),RequiredTracks:z.array(vh).nullish(),VisibleWhileLocked:z.boolean().nullish()}).passthrough(),kh=z.object({NodeID:z.string().nullish(),SortOrder:z.number().nullish(),Type:z.string().nullish(),Action:zh.nullish(),Grants:G.nullish(),TrackChanges:z.array(Ph).nullish(),MilestonePoints:z.number().nullish(),UnlockRules:Mh.nullish(),NextNodeIDs:z.array(z.string()).nullish(),ChoiceGroupID:z.string().nullish(),Limits:pe.nullish(),HideWhenCompleted:z.boolean().nullish(),ExhaustOfferOnComplete:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Metadata:z.record(z.string(),z.string()).nullish()}).passthrough(),Ta=z.object({OfferID:z.string().nullish(),Version:z.number().nullish(),Enabled:z.boolean().nullish(),GraphMode:z.string().nullish(),Name:z.string().nullish(),Description:z.string().nullish(),RootNodeIDs:z.array(z.string()).nullish(),Nodes:z.array(kh).nullish(),Tracks:z.array(Ih).nullish(),Milestones:z.record(z.string(),ye).nullish(),Presets:Th.nullish(),MilestoneClaimMode:z.string().nullish(),MilestoneToken:st.nullish(),ExhaustedWhenAllTerminalNodesCompleted:z.boolean().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Metadata:z.record(z.string(),z.string()).nullish()}).passthrough(),Ah=z.object({Milestones:z.record(z.string(),Ye).nullish()}).passthrough(),Mi=z.object({Slots:z.record(z.string(),xh).nullish(),Offers:z.record(z.string(),Ta).nullish(),Presets:Ah.nullish()}).passthrough(),Pa=z.object({DealOfferDefinitions:Mi.nullish()}),Ia=z.object({DealOffers:Ch.nullish()}),Uh=z.object({EntityID:z.string().nullish(),TotalEarned:z.number().nullish(),ClaimedIDs:z.array(z.string()).nullish(),ReachedUnclaimedIDs:z.array(z.string()).nullish()}).passthrough(),Oh=z.object({SlotID:z.string().nullish(),SortOrder:z.number().nullish(),QueueIndex:z.number().nullish(),CycleIndex:z.number().nullish(),OfferDef:Ta.nullish(),ActivationState:va.nullish(),IsNewActivation:z.boolean().nullish(),ComputedExpiresAtUtc:l.nullish(),Cost:K.nullish(),Milestone:Uh.nullish()}).passthrough(),Ma=z.object({Slots:z.array(Oh).nullish()}),ka=z.object({ServerTimeUtc:l.nullish(),SlotID:z.string().nullish(),NodeID:z.string().nullish(),NodeCompleted:z.boolean().nullish(),OfferExhausted:z.boolean().nullish(),Idempotent:z.boolean().nullish(),Resources:x.nullish()}),Aa=z.object({ServerTimeUtc:l.nullish(),SlotID:z.string().nullish(),Resources:x.nullish()}),Ua=z.object({ServerTimeUtc:l.nullish(),SlotID:z.string().nullish(),Resources:x.nullish()}),Oa=z.object({ServerTimeUtc:l.nullish(),SlotID:z.string().nullish(),MilestoneID:z.string().nullish(),Resources:x.nullish()}),Ba=z.object({ServerTimeUtc:l.nullish(),SlotID:z.string().nullish(),ClaimedIDs:z.array(z.string()).nullish(),Rejected:z.record(z.string(),z.string()).nullish(),Resources:x.nullish()}),Fe={GetDefinition:"GetDefinition",GetUserState:"GetUserState",GetActiveDeals:"GetActiveDeals",DismissDeal:"DismissDeal",ExecuteNode:"ExecuteNode",RecordShow:"RecordShow",ClaimMilestone:"ClaimMilestone",ClaimMilestonesBatch:"ClaimMilestonesBatch"};var cr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"DealOffer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinition(e){return this.send(Fe.GetDefinition,e,Pa)}getUserState(e){return this.send(Fe.GetUserState,e,Ia)}getActiveDeals(e){return this.send(Fe.GetActiveDeals,e,Ma)}dismissDeal(e){return this.send(Fe.DismissDeal,e,Aa)}executeNode(e){return this.send(Fe.ExecuteNode,e,ka)}recordShow(e){return this.send(Fe.RecordShow,e,Ua)}claimMilestone(e){return this.send(Fe.ClaimMilestone,e,Oa)}claimMilestonesBatch(e){return this.send(Fe.ClaimMilestonesBatch,e,Ba)}};var Bh=z.object({}).passthrough().transform(a=>a),wh=z.object({FeatureKey:z.string().nullish(),IsEnabled:z.boolean().nullish(),Percent:z.number().nullish(),SourceCurrencyID:z.string().nullish(),TargetCurrencyID:z.string().nullish()}).passthrough(),ki=z.object({IsEnabled:z.boolean().nullish(),ActivationReward:G.nullish(),InviteRewards:z.record(z.string(),ye).nullish(),SpendRewards:z.array(wh).nullish()}).passthrough(),wa=z.object({ReferralDefinitions:ki.nullish()}),qa=z.object({Referral:Bh.nullish()}),Ea=z.object({ReferralCode:z.string().nullish(),IsFirstActivation:z.boolean().nullish(),Resources:x.nullish()}),La=z.object({RewardID:z.string().nullish(),Resources:x.nullish()}),ft={GetDefinitions:"GetDefinitions",GetUserState:"GetUserState",ActivateReferralCode:"ActivateReferralCode",ClaimInviteReward:"ClaimInviteReward"};var pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Referral",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ft.GetDefinitions,e,wa)}getUserState(e){return this.send(ft.GetUserState,e,qa)}activateReferralCode(e){return this.send(ft.ActivateReferralCode,e,Ea)}claimInviteReward(e){return this.send(ft.ClaimInviteReward,e,La)}};var qh={RequestSent:"RequestSent",Accepted:"Accepted",Declined:"Declined",Removed:"Removed"},Eh={Attack:"Attack",Raid:"Raid",FriendAdd:"FriendAdd"},Lh=z.object({UserID:z.string(),PublicData:Ce.nullish()}),Gh=z.object({OwnerUserID:z.string().nullish(),ActorUserID:z.string().nullish(),ActorProfile:Ce.nullish(),Type:z.string().nullish(),CreatedAt:l.nullish(),OwnerImpact:x.nullish(),IsBlocked:z.boolean().nullish(),TargetObjectName:z.string().nullish()}).passthrough(),dr=z.object({Friends:z.array(Lh).nullish()}),zt=z.object({TargetUserID:z.string().nullish(),Status:z.string().nullish()}),Ga=z.object({Events:z.array(Gh).nullish()}),Ve={GetFriendsList:"GetFriendsList",GetIncomingRequests:"GetIncomingRequests",GetRecommendedFriends:"GetRecommendedFriends",SendFriendRequest:"SendFriendRequest",AcceptFriendRequest:"AcceptFriendRequest",DeclineFriendRequest:"DeclineFriendRequest",RemoveFriend:"RemoveFriend",GetTimeline:"GetTimeline"};var hr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Social",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getFriendsList(e){return this.send(Ve.GetFriendsList,e,dr)}getIncomingRequests(e){return this.send(Ve.GetIncomingRequests,e,dr)}getRecommendedFriends(e){return this.send(Ve.GetRecommendedFriends,e,dr)}sendFriendRequest(e){return this.send(Ve.SendFriendRequest,e,zt)}acceptFriendRequest(e){return this.send(Ve.AcceptFriendRequest,e,zt)}declineFriendRequest(e){return this.send(Ve.DeclineFriendRequest,e,zt)}removeFriend(e){return this.send(Ve.RemoveFriend,e,zt)}getTimeline(e){return this.send(Ve.GetTimeline,e,Ga)}};var Nh={Replace:"Replace",Refresh:"Refresh",KeepBest:"KeepBest",Stack:"Stack"};var gt=z.object({Target:z.string().nullish(),Operation:z.string().nullish(),Value:z.number().nullish()}).passthrough(),jh=z.object({BoostID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),ActivationCost:K.nullish(),Effect:gt.nullish(),DurationSeconds:z.number().nullish(),Charges:z.number().nullish(),StackingPolicy:z.string().nullish(),MaxActiveInstances:z.number().nullish(),Tags:z.array(z.string()).nullish()}).passthrough(),Fh=z.object({ScheduledBoostID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tags:z.array(z.string()).nullish(),Schedule:ce.nullish(),Effects:z.array(gt).nullish(),Gate:Q.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Vh=z.object({ChainedBoostID:z.string().nullish(),Order:z.number().nullish(),DurationSec:z.number().nullish(),Effects:z.array(gt).nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),_h=z.object({ChainID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Schedule:ce.nullish(),Phases:z.array(Vh).nullish(),Gate:Q.nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),Wh=z.object({TriggeredBoostID:z.string().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Tags:z.array(z.string()).nullish(),Sources:z.array(_e).nullish(),Effects:z.array(gt).nullish(),DurationSeconds:z.number().nullish(),Charges:z.number().nullish(),StackingPolicy:z.string().nullish(),MaxActiveInstances:z.number().nullish(),Gate:Q.nullish()}).passthrough(),Qh=z.object({MaxAddPercent:z.number().nullish(),MaxMultiply:z.number().nullish(),MaxAddFlat:z.number().nullish()}).passthrough(),Hh=z.object({StackingCaps:z.record(z.string(),Qh).nullish()}).passthrough(),mr=z.object({Definitions:z.record(z.string(),jh).nullish(),ScheduledBoosts:z.record(z.string(),Fh).nullish(),BoostChains:z.record(z.string(),_h).nullish(),TriggeredBoosts:z.record(z.string(),Wh).nullish(),Settings:Hh.nullish()}).passthrough(),Na=z.object({InstanceID:z.string(),BoostID:z.string(),ActivatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),RemainingCharges:z.number().nullish(),EffectSnapshot:gt.nullish(),SourceType:z.string().nullish(),SourceRef:z.string().nullish()}).passthrough();z.object({Date:l.nullish(),DailyCount:z.number().nullish(),LastFiredUtc:l.nullish()}).passthrough();var ja=z.object({ServerTimeUtc:l.nullish(),Active:z.record(z.string(),Na).nullish()}),Fa=z.object({ServerTimeUtc:l.nullish(),BoostID:z.string().nullish(),StackingPolicy:z.string().nullish(),ActivatedBoost:Na.nullish(),Resources:x.nullish()}),Kh={Scheduled:"Scheduled",Chain:"Chain"},$h=z.object({Kind:z.string().nullish(),SourceID:z.string().nullish(),PhaseID:z.string().nullish(),CycleIndex:z.number().nullish(),PhaseOrder:z.number().nullish(),StartUtc:l.nullish(),EndUtc:l.nullish(),Effects:z.array(gt).nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish()}).passthrough(),Va=z.object({ServerTimeUtc:l.nullish(),Windows:z.array($h).nullish()}),ot={GetDefinitions:"GetDefinitions",GetActive:"GetActive",GetActiveWindows:"GetActiveWindows",Activate:"Activate",CleanupExpired:"CleanupExpired"};var fr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TimedBoost",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(ot.GetDefinitions,e,mr)}getActive(e){return this.send(ot.GetActive,e,ja)}getActiveWindows(e){return this.send(ot.GetActiveWindows,e,Va)}activate(e){return this.send(ot.Activate,e,Fa)}cleanupExpired(e){return this.send(ot.CleanupExpired,e,Se)}};var gr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"UserCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getUserCustomDataDefinitions(e){return this.send(Ge.GetUserCustomDataDefinitions,e,hs)}getMyUserCustomData(e){return this.send(Ge.GetMyUserCustomData,e,hn)}getPublicUserCustomDataOf(e){return this.send(Ge.GetPublicUserCustomDataOf,e,Wr)}setPrivateData(e){return this.send(Ge.SetPrivateData,e,Qr)}setPublicData(e){return this.send(Ge.SetPublicData,e,Qr)}deleteKey(e){return this.send(Ge.DeleteKey,e,Se)}batchSet(e){return this.send(Ge.BatchSet,e,mn)}batchDelete(e){return this.send(Ge.BatchDelete,e,fn)}batchGetPublicUserCustomDataOf(e){return this.send(Ge.BatchGetPublicUserCustomDataOf,e,gn)}};var Zh={Static:"Static",Runtime:"Runtime"},Jh={Public:"Public",Private:"Private"},Yh=z.enum(["Client","Server","System"]),Xh=z.enum(["String","Int","Bool","Json"]),em=z.object({Value:z.string().nullish(),UpdatedAt:l.nullish(),Version:z.number().nullish(),LastWriter:Yh.nullish(),ExpiresAt:l.nullish()}).passthrough(),_a=z.record(z.string(),em),Ai=z.object({StaticVersion:z.number().nullish(),RuntimeVersion:z.number().nullish(),Static:_a.nullish(),Runtime:_a.nullish(),NotModified:z.boolean().nullish()}),tm=z.object({KeyID:z.string(),Scope:z.enum(["Static","Runtime"]).nullish(),Bucket:z.enum(["Public","Private"]).nullish(),ValueType:Xh.nullish(),MaxValueLengthBytes:z.number().nullish(),TtlSeconds:z.number().nullish(),DefaultValue:z.string().nullish(),Description:z.string().nullish()}).passthrough(),Rr=z.object({Keys:z.record(z.string(),tm).nullish(),DefaultMaxValueLengthBytes:z.number().nullish(),DefaultTtlSeconds:z.number().nullish(),MaxKeysPerBucket:z.number().nullish(),MaxTotalSizeBytes:z.number().nullish(),RejectUnregisteredKeys:z.boolean().nullish()}).passthrough(),vt={GetTitleCustomDataDefinitions:"GetTitleCustomDataDefinitions",GetPublicTitleData:"GetPublicTitleData",GetPublicTitleDataKeys:"GetPublicTitleDataKeys"};var yr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"TitleCustomData",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitleCustomDataDefinitions(e){return this.send(vt.GetTitleCustomDataDefinitions,e,Rr)}getPublicTitleData(e){return this.send(vt.GetPublicTitleData,e,Ai)}getPublicTitleDataKeys(e){return this.send(vt.GetPublicTitleDataKeys,e,Ai)}};var sm={Fast:"Fast",Sequential:"Sequential"},rm={Instant:"Instant",Timed:"Timed"},im={Hit:"Hit",Blocked:"Blocked"},nm=z.object({SlotIndex:z.number(),Level:z.number().nullish(),IsDamaged:z.boolean().nullish(),MaxLevelRewardClaimed:z.boolean().nullish()}).passthrough(),om=z.object({Symbol:z.union([z.string(),z.number()]).nullish(),OnOpenBonus:G.nullish(),BonusTag:z.string().nullish()}).passthrough();z.object({ElapsedSeconds:z.number().nullish(),Reward:G.nullish()}).passthrough();z.object({PlayedCount:z.number().nullish(),RewardsClaimedCount:z.number().nullish(),InstantClaimsCount:z.number().nullish(),EarlyClaimsCount:z.number().nullish(),LateClaimsCount:z.number().nullish(),AdViewsTotal:z.number().nullish()}).passthrough();var Wa=z.object({}).passthrough().transform(a=>a),Qa=z.object({Min:z.number().nullish(),Max:z.number().nullish()}).passthrough(),ze=z.object({Operation:x.nullish(),ScaleWithRollMultiplier:z.boolean().nullish()}).passthrough(),am=z.object({Count:z.number().nullish(),Sides:z.number().nullish()}).passthrough(),lm=z.object({ShieldChance:z.number().nullish(),DamagedBuildingChance:z.number().nullish(),RankMultiplierMin:z.number().nullish(),RankMultiplierMax:z.number().nullish(),RankOffsetMin:z.number().nullish(),RankOffsetMax:z.number().nullish()}).passthrough(),um=z.object({CostMatrixTemplatesByID:z.record(z.string(),z.array(z.array(z.number()))).nullish(),PerBoardGrowth:z.number().nullish(),VisualTemplateCycle:z.array(z.string()).nullish(),EconomyScaledResources:le.nullish(),ScaleRaidStealWithEconomy:z.boolean().nullish(),ScaleAttackRewardWithEconomy:z.boolean().nullish(),AttackValueFromCostMatrix:z.boolean().nullish(),AttackBlockedRewardFactor:z.number().nullish(),ScaleVictimLossWithEconomy:z.boolean().nullish(),ScaleVictimLossWithTier:z.boolean().nullish(),SynthesizedBuildingSlots:z.number().nullish(),SynthesizedBuildingMaxLevel:z.number().nullish()}).passthrough(),cm=z.object({CostMatrix:z.array(z.array(z.number())).nullish(),PerBoardGrowth:z.number().nullish(),EconomyScale:z.number().nullish(),ScaledResources:le.nullish()}).passthrough(),Ha=z.object({SlotIndex:z.number().nullish(),Name:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),MaxLevel:z.number().nullish(),MaxLevelReward:G.nullish()}).passthrough(),pm=z.object({Index:z.number().nullish(),Type:z.string().nullish(),CustomTypeID:z.string().nullish(),RandomActionAttackWeight:z.number().nullish(),RandomActionRaidWeight:z.number().nullish(),ChanceTableID:z.string().nullish(),SpecialModeID:z.string().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough(),dm=z.object({Tiles:z.record(z.string(),pm).nullish()}).passthrough(),hm=z.object({Weight:z.number().nullish(),Bonus:ze.nullish(),Tag:z.string().nullish()}).passthrough(),mm=z.object({Weight:z.number().nullish(),Tag:z.string().nullish(),MinBonusCells:z.number().nullish(),MaxBonusCells:z.number().nullish(),BonusPool:z.array(hm).nullish(),GuaranteedBonus:ze.nullish(),IsJackpot:z.boolean().nullish(),JackpotFinalMultiplier:z.number().nullish(),JackpotSymbolDistribution:z.record(z.string(),z.number()).nullish()}).passthrough(),fm=z.object({Variants:z.array(mm).nullish()}).passthrough(),gm=z.object({Weight:z.number().nullish(),OutcomeID:z.string().nullish(),Reward:ze.nullish(),ForceAction:z.string().nullish(),SpecialModeID:z.string().nullish()}).passthrough(),Rm=z.object({Outcomes:z.array(gm).nullish()}).passthrough(),Ka=z.object({PerAdMultiplierRange:Qa.nullish(),MaxAdViews:z.number().nullish(),AdCreditCost:z.number().nullish(),FormulaKind:z.string().nullish(),ApplyMultiplierOnEarlyClaim:z.boolean().nullish()}).passthrough(),ym=z.object({ElapsedSeconds:z.number().nullish(),Reward:ze.nullish()}).passthrough(),Cm=z.object({Tiers:z.array(ym).nullish(),BelowFirstTierReward:ze.nullish()}).passthrough(),Sm=z.object({ChoiceID:z.string().nullish(),Mode:z.string().nullish(),Reward:ze.nullish(),DurationSeconds:z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ka.nullish(),Gradation:Cm.nullish()}).passthrough(),xm=z.object({Choices:z.array(Sm).nullish(),OfferExpireSeconds:z.number().nullish(),ClaimExpireSeconds:z.number().nullish()}).passthrough(),Dm=z.object({Chance:z.number().nullish(),RequiredOutcome:z.string().nullish(),Reward:ze.nullish(),Tag:z.string().nullish()}).passthrough(),bm=z.object({OnPassStart:ze.nullish(),OnTileLanding:z.record(z.string(),ze).nullish(),OnAttack:z.record(z.string(),ze).nullish(),OnRaid:z.record(z.string(),ze).nullish(),OnBuild:ze.nullish(),OnStageComplete:ze.nullish(),OnAttackBonusDrops:z.array(Dm).nullish(),ChanceTablesByID:z.record(z.string(),Rm).nullish(),SpecialModesByID:z.record(z.string(),xm).nullish()}).passthrough(),$a=z.object({BaseAttackReward:G.nullish(),BaseRaidReward:G.nullish(),MaxRollMultiplier:z.number().nullish(),MaxShields:z.number().nullish(),Buildings:z.array(Ha).nullish(),HeistGridBonusConfig:fm.nullish(),StageOperations:bm.nullish(),TileLandingMultiplier:Qa.nullish(),EconomyOverride:cm.nullish()}).passthrough(),zm=z.object({Name:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),BoardTemplateID:z.string().nullish(),Buildings:z.array(Ha).nullish(),StageTemplateID:z.string().nullish(),CostMatrixTemplateID:z.string().nullish(),UnitValue:z.number().nullish(),Override:$a.nullish()}).passthrough(),Cr=z.object({RollCurrencyID:z.string().nullish(),ShieldCurrencyID:z.string().nullish(),RaidMode:z.string().nullish(),AllowedRollMultipliers:z.array(z.number()).nullish(),BoardTemplatesByID:z.record(z.string(),dm).nullish(),StageTemplatesByID:z.record(z.string(),$a).nullish(),StagesByLevel:z.record(z.string(),zm).nullish(),SoftCurrencyID:z.string().nullish(),ProceduralEconomy:um.nullish(),Dice:am.nullish(),Bots:lm.nullish()}).passthrough(),vm=z.object({IsActive:z.boolean().nullish(),DisplayName:z.string().nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),AnchorUtc:l.nullish(),RoundDurationSec:z.number().nullish(),PauseBetweenRoundsSec:z.number().nullish(),MaxRounds:z.number().nullish(),PartnerCount:z.number().nullish(),MatchmakingTimeoutMinutes:z.number().nullish(),MemberGracePeriodMinutes:z.number().nullish(),ContributionMin:z.number().nullish(),ContributionMax:z.number().nullish(),ScaleContributionWithRollMultiplier:z.boolean().nullish(),MaxProgress:z.number().nullish(),Milestones:z.record(z.string(),ye).nullish(),GrandPrize:G.nullish()}).passthrough(),Sr=z.object({Board:Cr.nullish(),CommunityChest:vm.nullish()}).passthrough(),Tm=z.object({TargetUserID:z.string().nullish(),IsBot:z.boolean().nullish(),PublicData:Ce.nullish(),TargetBuildingStates:z.array(nm).nullish(),TargetHasShield:z.boolean().nullish()}).passthrough(),Pm=z.object({ChoiceID:z.string().nullish(),Mode:z.string().nullish(),Reward:ze.nullish(),DurationSeconds:z.number().nullish(),EntryCost:K.nullish(),Multipliers:Ka.nullish()}).passthrough(),Im=z.object({ModeID:z.string().nullish(),Choices:z.array(Pm).nullish()}).passthrough(),Mm=z.object({GroupID:z.string().nullish(),Delta:M.nullish(),NewProgress:M.nullish(),MaxProgress:M.nullish(),UnlockedMilestoneIDs:z.array(z.string()).nullish(),Completed:z.boolean().nullish()}).passthrough(),Za=z.object({UsedMultiplier:z.number().nullish(),Steps:z.number().nullish(),OldPosition:z.number().nullish(),NewPosition:z.number(),CyclesCompletedDelta:M.nullish(),LandedTileType:z.string().nullish(),Operation:x.nullish(),ActionRequired:z.string().nullish(),ActionData:Tm.nullish(),SpecialModeOffer:Im.nullish(),CommunityChestContribution:Mm.nullish()}).passthrough(),Ja=z.object({Outcome:z.string().nullish(),IsBotTarget:z.boolean().nullish(),BuildingIndexHit:z.number().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ui=z.object({Status:z.string().nullish(),Outcome:z.string().nullish(),FoundSymbol:z.union([z.string(),z.number()]).nullish(),FoundBonus:G.nullish(),OpenedIndex:z.number().nullish(),AttemptsLeft:z.number().nullish(),RaidLayout:z.array(om).nullish(),HeistVariantTag:z.string().nullish(),IsJackpot:z.boolean().nullish(),Operation:x.nullish(),DualResult:tt.nullish()}).passthrough(),Ya=z.object({BuiltIndex:z.number(),NewLevel:z.number().nullish(),StageComplete:z.boolean().nullish(),MaxLevelRewardClaimed:z.boolean().nullish(),Operation:x.nullish()}).passthrough(),Xa=z.object({Mode:z.union([z.string(),z.number()]).nullish(),Operation:x.nullish(),DurationSeconds:z.number().nullish(),StartedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish()}).passthrough(),el=z.object({AdViewsUsed:z.number().nullish(),RolledMultiplier:z.number().nullish(),AccumulatedMultiplier:z.number().nullish(),RemainingAdViews:z.number().nullish()}).passthrough(),tl=z.object({FinalMultiplier:z.number().nullish(),AdViewsUsed:z.number().nullish(),AccumulatedMultiplier:z.number().nullish(),IsEarlyClaim:z.boolean().nullish(),Operation:x.nullish()}).passthrough(),km={Forming:"Forming",Active:"Active",Completed:"Completed",Failed:"Failed",Expired:"Expired"},sl=z.enum(["Forming","Active","Completed","Failed","Expired"]),Am={Active:"Active",Left:"Left",Replaced:"Replaced"},Um=z.enum(["Active","Left","Replaced"]),Om=z.object({CurrentProgress:M.nullish(),MaxProgress:M.nullish()}).passthrough(),Bm=z.object({UserID:z.string().nullish(),PublicData:Ce.nullish(),IsBot:z.boolean().nullish(),ContributionPoints:M.nullish(),ClaimedMilestoneIDs:z.array(z.string()).nullish(),GrandPrizeClaimed:z.boolean().nullish(),MemberStatus:Um.nullish(),JoinedAtUtc:l.nullish(),LeftAtUtc:l.nullish()}).passthrough(),rl=z.object({GroupID:z.string().nullish(),TitleID:z.string().nullish(),RoundIndex:z.number().nullish(),Members:z.array(Bm).nullish(),SharedProgress:Om.nullish(),Status:sl.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),Version:z.number().nullish()}).passthrough(),wm=z.object({GroupID:z.string().nullish(),RoundIndex:z.number().nullish(),FinalStatus:sl.nullish(),GrandPrizeReceived:z.boolean().nullish(),FinishedAtUtc:l.nullish()}).passthrough(),qm=z.object({ActiveGroupID:z.string().nullish(),ActiveRoundIndex:z.number().nullish(),History:z.array(wm).nullish()}).passthrough(),il=z.object({ServerTimeUtc:l.nullish(),UserState:qm.nullish(),ActiveGroup:rl.nullish(),SecondsRemaining:M.nullish()}),nl=z.object({ServerTimeUtc:l.nullish(),Group:rl.nullish(),SecondsRemaining:M.nullish()}),Oi=z.object({ServerTimeUtc:l.nullish(),GroupID:z.string().nullish(),RewardType:z.string().nullish(),MilestoneID:z.string().nullish(),Resources:x.nullish()}),ol=z.object({ServerTimeUtc:l.nullish(),GroupID:z.string().nullish(),Success:z.boolean().nullish()}),he={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 Em=z.object({VariantID:z.string().nullish(),DisplayName:z.string().nullish(),Weight:z.number().nullish(),IsControl:z.boolean().nullish(),Params:z.record(z.string(),z.string()).nullish()}).passthrough(),Lm=z.object({ExperimentID:z.string().nullish(),DisplayName:z.string().nullish(),Description:z.string().nullish(),IsEnabled:z.boolean().nullish(),Schedule:ce.nullish(),Gate:Q.nullish(),Variants:z.array(Em).nullish(),Salt:z.string().nullish(),LayerID:z.string().nullish(),StickyAssignment:z.boolean().nullish(),CustomParams:z.record(z.string(),z.string()).nullish()}).passthrough(),al=z.object({Experiments:z.record(z.string(),Lm).nullish()}).passthrough();var Gm={Mesh:"Mesh",Host:"Host"},Bi=z.enum(["Mesh","Host"]),Nm={ServerRelay:"ServerRelay",P2P:"P2P"},wi=z.enum(["ServerRelay","P2P"]),jm={Public:"Public",Private:"Private"},Fm=z.enum(["Public","Private"]),Vm={Signal:"Signal",Chat:"Chat",PlayerJoined:"PlayerJoined",PlayerLeft:"PlayerLeft",HostChanged:"HostChanged",RoomClosed:"RoomClosed",MemberState:"MemberState"},_m=z.enum(["Signal","Chat","PlayerJoined","PlayerLeft","HostChanged","RoomClosed","MemberState"]),ll=z.object({Urls:z.string().nullish(),Username:z.string().nullish(),Credential:z.string().nullish()}).passthrough(),Wm=z.object({Enabled:z.boolean().nullish()}).passthrough(),ul=z.object({SystemState:Wm.nullish(),DefaultTopology:Bi.nullish(),AllowCreatorTopologyOverride:z.boolean().nullish(),DefaultChatMode:wi.nullish(),AllowCreatorChatOverride:z.boolean().nullish(),MaxPlayersPerRoom:z.number().nullish(),RoomTtlSeconds:z.number().nullish(),HeartbeatIntervalMs:z.number().nullish(),MemberTimeoutMs:z.number().nullish(),MaxSignalPayloadBytes:z.number().nullish(),MaxChatTextLength:z.number().nullish(),RoomLogCap:z.number().nullish(),IceServers:z.array(ll).nullish()}).passthrough(),Qm=z.object({UserID:z.string().nullish(),Username:z.string().nullish(),AvatarUrl:z.string().nullish(),Level:z.number().nullish(),Power:z.number().nullish(),Ready:z.boolean().nullish(),State:z.record(z.string(),z.string()).nullish(),JoinedAt:z.number().nullish(),IsHost:z.boolean().nullish(),LastSeenMs:z.number().nullish()}).passthrough(),Hm=z.object({RoomID:z.string().nullish(),Name:z.string().nullish(),HostUserID:z.string().nullish(),Topology:Bi.nullish(),ChatMode:wi.nullish(),MaxPlayers:z.number().nullish(),MemberCount:z.number().nullish(),CreatedAt:z.number().nullish()}).passthrough(),Km=z.object({Seq:z.number().nullish(),Type:_m.nullish(),FromUserID:z.string().nullish(),ToUserID:z.string().nullish(),Kind:z.string().nullish(),Payload:z.string().nullish(),Ts:z.number().nullish()}).passthrough(),xr=z.object({RoomID:z.string().nullish(),Name:z.string().nullish(),HostUserID:z.string().nullish(),OwnerUserID:z.string().nullish(),Topology:Bi.nullish(),ChatMode:wi.nullish(),Visibility:Fm.nullish(),Status:z.string().nullish(),MaxPlayers:z.number().nullish(),Members:z.array(Qm).nullish(),IceServers:z.array(ll).nullish(),Seq:z.number().nullish()}).passthrough(),qi=z.object({Closed:z.boolean().nullish(),NewHostUserID:z.string().nullish()}).passthrough(),cl=z.object({Rooms:z.array(Hm).nullish(),Page:z.number().nullish(),PageSize:z.number().nullish(),HasMore:z.boolean().nullish()}).passthrough(),pl=z.object({Envelopes:z.array(Km).nullish(),MaxSeq:z.number().nullish()}).passthrough(),Dr=z.object({Seq:z.number().nullish()}).passthrough(),we={CreateRoom:"CreateRoom",JoinRoom:"JoinRoom",LeaveRoom:"LeaveRoom",ListRooms:"ListRooms",GetRoom:"GetRoom",CloseRoom:"CloseRoom",Poll:"Poll",SendSignal:"SendSignal",SendChat:"SendChat",SetMemberState:"SetMemberState"};var Ei=z.object({TitleCustomData:Rr.nullish(),Character:xs.nullish(),Item:Bs.nullish(),Currency:Ss.nullish(),Store:qs.nullish(),Lootbox:gi.nullish(),Quest:Bt.nullish(),TimedEvent:Vs.nullish(),Leaderboard:$s.nullish(),Season:Js.nullish(),Reward:Ri.nullish(),Collection:or.nullish(),Craft:zi.nullish(),DealOffer:Mi.nullish(),Premium:bi.nullish(),TimedBoost:mr.nullish(),CoopEvent:lr.nullish(),GameLoop:Sr.nullish(),Match:ai.nullish(),Experiment:al.nullish(),Blockchain:ei.nullish(),Marketplace:pi.nullish(),Multiplayer:ul.nullish(),UserCustomData:hs.nullish(),Referral:ki.nullish()}).passthrough();var at={GetTitlePublicConfiguration:"GetTitlePublicConfiguration",GetTitlePublicConfigurationExcept:"GetTitlePublicConfigurationExcept",GetCurrencyDefinitions:"GetCurrencyDefinitions",GetItemDefinitions:"GetItemDefinitions",GetServerTime:"GetServerTime"};var br=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Title",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getTitlePublicConfiguration(e){return this.send(at.GetTitlePublicConfiguration,e,Ei)}getTitlePublicConfigurationExcept(e){return this.send(at.GetTitlePublicConfigurationExcept,e,Ei)}getCurrencyDefinitions(e){return this.send(at.GetCurrencyDefinitions,e,Ss)}getItemDefinitions(e){return this.send(at.GetItemDefinitions,e,Bs)}getServerTime(e){return this.send(at.GetServerTime,e,Se)}};var zr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s,r=false){let i=U(this.ctx.settings.titleID,"GameLoop",e,t.UserID??"");return this.ctx.transport.post(i,t,s,{ticket:t.ClientSessionTicket,silent:r})}getGameLoops(e){return this.send(he.GetGameLoops,e,Sr)}getBoardDefinition(e,t=false){return this.send(he.GetBoardDefinition,e,Cr,t)}getBoardDefinitionForLevel(e,t=false){return this.send(he.GetBoardDefinitionForLevel,e,Cr,t)}getUserBoardState(e){return this.send(he.GetUserBoardState,e,Wa)}boardLoopRoll(e){return this.send(he.BoardLoopRoll,e,Za)}boardLoopAttack(e){return this.send(he.BoardLoopAttack,e,Ja)}boardLoopRaid(e){return this.send(he.BoardLoopRaid,e,Ui)}boardLoopRaidFast(e){return this.send(he.BoardLoopRaidFast,e,Ui)}boardLoopBuild(e){return this.send(he.BoardLoopBuild,e,Ya)}boardSpecialChoose(e){return this.send(he.BoardSpecialChoose,e,Xa)}boardSpecialApplyMultiplier(e){return this.send(he.BoardSpecialApplyMultiplier,e,el)}boardSpecialClaim(e){return this.send(he.BoardSpecialClaim,e,tl)}getCommunityChestState(e){return this.send(he.GetCommunityChestState,e,il)}joinOrCreateCommunityChest(e){return this.send(he.JoinOrCreateCommunityChest,e,nl)}claimCommunityChestMilestone(e){return this.send(he.ClaimCommunityChestMilestone,e,Oi)}claimCommunityChestGrandPrize(e){return this.send(he.ClaimCommunityChestGrandPrize,e,Oi)}leaveCommunityChest(e){return this.send(he.LeaveCommunityChest,e,ol)}};var Tt=z.lazy(()=>z.union([z.string(),z.number(),z.boolean(),z.null(),z.array(Tt),z.record(z.string(),Tt)]));var Zm={Live:"Live",Latest:"Latest",Specific:"Specific"},Jm={Debug:"Debug",Info:"Info",Warning:"Warning",Error:"Error"},Ym=z.enum(["Debug","Info","Warning","Error"]),Xm={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"},ef=z.enum(["None","Disabled","NoActiveRevision","RevisionNotFound","InvalidFieldName","RateLimited","HandlerNotFound","HandlerDisabled","Timeout","StatementCountExceeded","StackOverflow","ApiCallLimitExceeded","JavaScriptException","ExecutionError"]),tf=z.object({Level:Ym,Message:z.string().nullish(),Data:Tt.nullish()}),sf=z.object({Error:ef,Message:z.string().nullish(),StackTrace:z.string().nullish()}),dl=z.object({FunctionName:z.string().nullish(),Revision:z.number().nullish(),FunctionResult:Tt.nullish(),FunctionResultTooLarge:z.boolean().nullish(),Logs:z.array(tf).nullish(),LogsTooLarge:z.boolean().nullish(),ExecutionTimeSeconds:z.number().nullish(),APIRequestsIssued:z.number().nullish(),Error:sf.nullish()}),Li={Execute:"Execute"};var vr=class{constructor(e){this.ctx=e;}ctx;execute(e){let t=U(this.ctx.settings.titleID,"CloudCode",Li.Execute,e.UserID??"");return this.ctx.transport.post(t,e,dl,{ticket:e.ClientSessionTicket})}};var Tr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Blockchain",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(Pe.GetDefinitions,e,Fn)}getUserState(e){return this.send(Pe.GetUserState,e,Vn)}depositToken(e){return this.send(Pe.DepositToken,e,_n)}depositNFT(e){return this.send(Pe.DepositNFT,e,Wn)}requestTokenWithdrawal(e){return this.send(Pe.RequestTokenWithdrawal,e,Qn)}requestNFTWithdrawal(e){return this.send(Pe.RequestNFTWithdrawal,e,Hn)}getTransactionHistory(e){return this.send(Pe.GetTransactionHistory,e,Kn)}retryWithdrawal(e){return this.send(Pe.RetryWithdrawal,e,$n)}confirmWithdrawal(e){return this.send(Pe.ConfirmWithdrawal,e,Zn)}donateToDeveloper(e){return this.send(Pe.DonateToDeveloper,e,ri)}donateToUsersPool(e){return this.send(Pe.DonateToUsersPool,e,ri)}};var Pr=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Marketplace",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}getDefinitions(e){return this.send(re.GetDefinitions,e,co)}getGroupedOffers(e){return this.send(re.GetGroupedOffers,e,po)}getOffersByItem(e){return this.send(re.GetOffersByItem,e,di)}getOffer(e){return this.send(re.GetOffer,e,ho)}getBuyOrders(e){return this.send(re.GetBuyOrders,e,di)}getMyState(e){return this.send(re.GetMyState,e,fo)}getHistory(e){return this.send(re.GetHistory,e,go)}createListing(e){return this.send(re.CreateListing,e,Dt)}cancelListing(e){return this.send(re.CancelListing,e,Ae)}buy(e){return this.send(re.Buy,e,Ae)}marketBuy(e){return this.send(re.MarketBuy,e,Ae)}marketSell(e){return this.send(re.MarketSell,e,Ae)}createAuction(e){return this.send(re.CreateAuction,e,Dt)}placeBid(e){return this.send(re.PlaceBid,e,mo)}claimAuction(e){return this.send(re.ClaimAuction,e,Ae)}createBuyOrder(e){return this.send(re.CreateBuyOrder,e,Dt)}cancelBuyOrder(e){return this.send(re.CancelBuyOrder,e,Ae)}fillBuyOrder(e){return this.send(re.FillBuyOrder,e,Ae)}createDirectTrade(e){return this.send(re.CreateDirectTrade,e,Dt)}respondDirectTrade(e){return this.send(re.RespondDirectTrade,e,Ae)}cancelDirectTrade(e){return this.send(re.CancelDirectTrade,e,Ae)}claimBack(e){return this.send(re.ClaimBack,e,Ae)}};var Ir=class{constructor(e){this.ctx=e;}ctx;send(e,t,s){let r=U(this.ctx.settings.titleID,"Multiplayer",e,t.UserID??"");return this.ctx.transport.post(r,t,s,{ticket:t.ClientSessionTicket})}createRoom(e){return this.send(we.CreateRoom,e,xr)}joinRoom(e){return this.send(we.JoinRoom,e,xr)}leaveRoom(e){return this.send(we.LeaveRoom,e,qi)}listRooms(e){return this.send(we.ListRooms,e,cl)}getRoom(e){return this.send(we.GetRoom,e,xr)}closeRoom(e){return this.send(we.CloseRoom,e,qi)}poll(e){return this.send(we.Poll,e,pl)}sendSignal(e){return this.send(we.SendSignal,e,Dr)}sendChat(e){return this.send(we.SendChat,e,Dr)}setMemberState(e){return this.send(we.SetMemberState,e,Dr)}};var Mr=class{settings;emitter;platform;transport;fetchImpl;data;authStore;api;auth;userService;currency;item;store;lootbox;reward;quest;timedEvent;leaderboard;season;premium;character;match;craft;collection;coopEvent;dealOffer;referral;social;timedBoost;userCustomData;titleCustomData;title;gameLoop;cloudCode;blockchain;marketplace;multiplayer;constructor(e$1){this.settings=Fi(e$1),this.emitter=new yt,this.platform=e$1.platform??new e,this.fetchImpl=e$1.fetch??globalThis.fetch.bind(globalThis),this.transport=new Et({baseUrl:this.settings.baseUrl,emitter:this.emitter,fetchImpl:e$1.fetch,debugLogging:this.settings.debugLogging,throttleMs:e$1.throttleMs}),this.data=new jt(this.emitter),this.emitter.on("quest:systemProgress",t=>{this.data.user.patchQuestProgressUpdates(t);}),this.authStore=new Ft(this.platform.storage,this.settings.titleID),this.api={authentication:new ks(this),user:new As(this),currency:new Us(this),item:new ws(this),store:new Es(this),lootbox:new Ns(this),reward:new js(this),quest:new Fs(this),timedEvent:new _s(this),leaderboard:new Zs(this),season:new Ys(this),premium:new er(this),character:new tr(this),match:new sr(this),craft:new ir(this),collection:new ar(this),coopEvent:new ur(this),dealOffer:new cr(this),referral:new pr(this),social:new hr(this),timedBoost:new fr(this),userCustomData:new gr(this),titleCustomData:new yr(this),title:new br(this),gameLoop:new zr(this),cloudCode:new vr(this),blockchain:new Tr(this),marketplace:new Pr(this),multiplayer:new Ir(this)},this.userService=new Wt(this),this.auth=new Vt(this),this.currency=new Ht(this),this.item=new Kt(this),this.store=new $t(this),this.lootbox=new Zt(this),this.reward=new Jt(this),this.quest=new Yt(this),this.timedEvent=new Xt(this),this.leaderboard=new es(this),this.season=new ts(this),this.premium=new ss(this),this.character=new rs(this),this.match=new is(this),this.craft=new ns(this),this.collection=new os(this),this.coopEvent=new as(this),this.dealOffer=new ls(this),this.referral=new us(this),this.social=new cs(this),this.timedBoost=new ps(this),this.userCustomData=new ms(this),this.titleCustomData=new fs(this),this.title=new gs(this),this.gameLoop=new Rs(this),this.cloudCode=new ys(this),this.blockchain=new zs(this),this.marketplace=new Is(this),this.multiplayer=new Ms(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:d()}}};var kr=class{ctx;constructor(e){this.ctx=new Mr(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 lootbox(){return this.ctx.lootbox}get reward(){return this.ctx.reward}get quest(){return this.ctx.quest}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 rf(a){return new kr(a)}var nf={Banner:"Banner",Interstitial:"Interstitial",RewardedVideo:"RewardedVideo",RewardedInterstitial:"RewardedInterstitial",AppOpen:"AppOpen",Native:"Native"},Gi=z.enum(["Banner","Interstitial","RewardedVideo","RewardedInterstitial","AppOpen","Native"]),of={Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"},af=z.enum(["Top","Bottom","Left","Right"]),lf=z.object({PlacementID:z.string().nullish(),Type:Gi.nullish(),Enabled:z.boolean().nullish(),CooldownSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish(),CreditsRewarded:z.number().nullish(),AllowedProviderIDs:z.array(z.string()).nullish()}).passthrough(),uf=z.object({DefaultCreditsPerView:z.number().nullish(),MaxCreditsBalance:z.number().nullish(),DailyCreditEarnCap:z.number().nullish(),DailyViewCap:z.number().nullish(),MinSecondsBetweenViews:z.number().nullish()}).passthrough(),cf=z.object({CooldownSeconds:z.number().nullish(),MinSessionTimeBeforeFirstSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish(),MaxImpressionsPerSession:z.number().nullish()}).passthrough(),pf=z.object({Enabled:z.boolean().nullish(),Position:af.nullish(),RefreshIntervalSeconds:z.number().nullish()}).passthrough(),df=z.object({Enabled:z.boolean().nullish(),CooldownSeconds:z.number().nullish(),DailyImpressionCap:z.number().nullish()}).passthrough(),hf=z.object({MaxImpressionsPerHour:z.number().nullish(),MaxImpressionsPerDay:z.number().nullish(),MaxImpressionsPerSession:z.number().nullish()}).passthrough(),mf=z.object({MinPremiumTier:z.number().nullish(),RequiredPremiumID:z.string().nullish(),DisableInterstitials:z.boolean().nullish(),DisableBanners:z.boolean().nullish(),DisableAppOpen:z.boolean().nullish()}).passthrough(),ff=z.object({RequirePersonalizedAdsConsent:z.boolean().nullish(),RequireTrackingConsent:z.boolean().nullish(),CurrentPolicyVersion:z.string().nullish(),RegulatedRegions:z.array(z.string()).nullish()}).passthrough(),gf=z.object({RequireServerSideVerification:z.boolean().nullish(),PendingRequestTtlSeconds:z.number().nullish(),MaxPendingRequestsPerUser:z.number().nullish(),ProviderPublicKeys:z.record(z.string(),z.string()).nullish()}).passthrough(),Rf=z.object({AndroidUnitID:z.string().nullish(),IosUnitID:z.string().nullish(),WebUnitID:z.string().nullish(),Type:Gi.nullish()}).passthrough(),yf=z.object({ProviderID:z.string().nullish(),Enabled:z.boolean().nullish(),Priority:z.number().nullish(),AndroidAppID:z.string().nullish(),IosAppID:z.string().nullish(),WebAppID:z.string().nullish(),Units:z.record(z.string(),Rf).nullish()}).passthrough();z.object({Enabled:z.boolean().nullish(),Placements:z.record(z.string(),lf).nullish(),Providers:z.record(z.string(),yf).nullish(),RewardedVideo:uf.nullish(),Interstitial:cf.nullish(),Banner:pf.nullish(),AppOpen:df.nullish(),FrequencyCapping:hf.nullish(),PremiumAdReductions:z.array(mf).nullish(),Consent:ff.nullish(),Verification:gf.nullish()}).passthrough();var Cf=z.object({RewardedVideoCredit:z.number().nullish(),TotalEarned:z.number().nullish(),TotalSpent:z.number().nullish()}).passthrough(),Sf=z.object({PlacementID:z.string().nullish(),LastShownAt:l.nullish(),LastCompletedAt:l.nullish(),TotalImpressions:z.number().nullish(),TotalCompletions:z.number().nullish(),ConsecutiveFailures:z.number().nullish()}).passthrough(),xf=z.object({Date:l.nullish(),ImpressionsByPlacement:z.record(z.string(),z.number()).nullish(),CompletionsByPlacement:z.record(z.string(),z.number()).nullish(),TotalImpressions:z.number().nullish(),InterstitialImpressions:z.number().nullish(),RewardedCompletions:z.number().nullish(),AppOpenImpressions:z.number().nullish(),CreditsEarnedToday:z.number().nullish()}).passthrough(),Df=z.object({SessionID:z.string().nullish(),SessionStartAt:l.nullish(),Impressions:z.number().nullish(),InterstitialImpressions:z.number().nullish(),RewardedCompletions:z.number().nullish()}).passthrough(),bf=z.object({PersonalizedAdsConsent:z.boolean().nullish(),TrackingConsent:z.boolean().nullish(),PolicyVersion:z.string().nullish(),Region:z.string().nullish(),ConsentGivenAt:l.nullish(),ConsentRevokedAt:l.nullish()}).passthrough(),zf=z.object({RequestID:z.string().nullish(),PlacementID:z.string().nullish(),ProviderID:z.string().nullish(),Type:Gi.nullish(),IssuedAt:l.nullish(),ExpiresAt:l.nullish(),CreditsToAward:z.number().nullish()}).passthrough(),vf=z.object({InvalidSsvCount:z.number().nullish(),OrphanCompletions:z.number().nullish(),FastCompletions:z.number().nullish(),LastFlaggedAt:l.nullish()}).passthrough();z.object({Credits:Cf.nullish(),Placements:z.record(z.string(),Sf).nullish(),Daily:xf.nullish(),Session:Df.nullish(),LastImpressionAt:l.nullish(),LastInterstitialAt:l.nullish(),LastRewardedAt:l.nullish(),LastAppOpenAt:l.nullish(),TotalImpressions:z.number().nullish(),TotalRewardedCompletions:z.number().nullish(),AdsDisabledUntil:l.nullish(),Consent:bf.nullish(),PendingRequests:z.record(z.string(),zf).nullish(),FraudFlags:vf.nullish(),UpdatedAt:l.nullish()}).passthrough();var Tf={Unread:"Unread",Read:"Read",Deleted:"Deleted",Expired:"Expired"},Pf=z.enum(["Unread","Read","Deleted","Expired"]),If={Admin:"Admin",Leaderboard:"Leaderboard",CoopEvent:"CoopEvent",Season:"Season",Collection:"Collection",MilestoneEvent:"MilestoneEvent",PlayerGift:"PlayerGift",Social:"Social",Compensation:"Compensation",Referral:"Referral",Quest:"Quest"},Mf=z.enum(["Admin","Leaderboard","CoopEvent","Season","Collection","MilestoneEvent","PlayerGift","Social","Compensation","Referral","Quest"]),kf={Active:"Active",Paused:"Paused",Cancelled:"Cancelled",Completed:"Completed"},Af=z.enum(["Active","Paused","Cancelled","Completed"]),Uf=z.object({MessageTypeID:z.string().nullish(),DisplayName:z.string().nullish(),IconPath:z.string().nullish(),DisplayPriority:z.number().nullish(),ExpirationHours:z.number().nullish(),AutoClaim:z.boolean().nullish(),AllowP2P:z.boolean().nullish(),ShowBadge:z.boolean().nullish()}).passthrough(),Of=z.object({SegmentID:z.string().nullish(),DisplayName:z.string().nullish(),Gate:Q.nullish()}).passthrough();z.object({MaxMessagesPerUser:z.number().nullish(),ReadNoRewardRetentionHours:z.number().nullish(),ClaimedRetentionHours:z.number().nullish(),DefaultPageSize:z.number().nullish(),EnableAutoClaim:z.boolean().nullish(),MessageTypes:z.record(z.string(),Uf).nullish(),Segments:z.array(Of).nullish(),DailyP2PGiftLimit:z.number().nullish(),MaxRewardsPerP2PMessage:z.number().nullish()}).passthrough();z.object({MessageID:z.string().nullish(),TitleID:z.string().nullish(),RecipientUserID:z.string().nullish(),MessageTypeID:z.string().nullish(),Source:Mf.nullish(),RelatedEntityID:z.string().nullish(),SenderUserID:z.string().nullish(),SenderPublicData:Ce.nullish(),Subject:z.string().nullish(),Body:z.string().nullish(),TemplateParams:z.record(z.string(),z.string()).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rewards:G.nullish(),Claimed:z.boolean().nullish(),ClaimedAtUtc:l.nullish(),Status:Pf.nullish(),CreatedAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),ReadAtUtc:l.nullish(),BroadcastID:z.string().nullish(),Version:z.number().nullish()}).passthrough();z.object({BroadcastID:z.string().nullish(),TitleID:z.string().nullish(),MessageTypeID:z.string().nullish(),Subject:z.string().nullish(),Body:z.string().nullish(),TemplateParams:z.record(z.string(),z.string()).nullish(),AssetPaths:z.record(z.string(),z.string()).nullish(),Rewards:G.nullish(),TargetSegmentID:z.string().nullish(),TargetUserIDs:z.array(z.string()).nullish(),StartsAtUtc:l.nullish(),ExpiresAtUtc:l.nullish(),CreatedAtUtc:l.nullish(),CreatedByAdminID:z.string().nullish(),AdminComment:z.string().nullish(),Status:Af.nullish(),DeliveredCount:z.number().nullish(),ClaimedCount:z.number().nullish()}).passthrough();z.object({UnreadCount:z.number().nullish(),UnclaimedRewardCount:z.number().nullish(),LastFetchCursor:l.nullish(),ReceivedBroadcastIDs:z.array(z.string()).nullish(),ClaimedBroadcastIDs:z.array(z.string()).nullish(),DailyP2PGiftsSent:z.number().nullish(),DailyGiftsResetDate:l.nullish(),LastOpenedAtUtc:l.nullish(),TotalMessagesReceived:z.number().nullish(),TotalRewardsClaimed:z.number().nullish()}).passthrough();
|
|
2
|
+
export{nf as AdType,im as AttackOutcome,ue as AuthType,Ue as AuthenticationAction,of as BannerPosition,Pe as BlockchainAction,cc as BlockchainNetworkType,En as BlockchainOperationCategory,Cc as BlockchainTransactionStatus,mc as BlockchainTransactionType,Vc as BodyPart,Kh as BoostWindowKind,kf as BroadcastStatus,Te as CharacterAction,Li as CloudCodeAction,Xm as CloudCodeErrorCode,Jm as CloudCodeLogLevel,Zm as CloudCodeRevisionSelection,xe as CollectionAction,lp as CommissionSink,Am as CommunityChestMemberStatus,km as CommunityChestStatus,ju as ConversionRateMode,Ne as CoopEventAction,th as CoopGroupStatus,sh as CoopMemberStatus,rr as CraftAction,Nd as CraftType,Cs as CurrencyAction,Nu as CurrencyStatus,qe as CurrencyType,We as CustomDataBucket,ku as CustomDataValueType,Tu as CustomDataWriter,ji as DEFAULT_BASE_URL,hh as DealNodeRuntimeStatus,Fe as DealOfferAction,dh as DealOfferActivationStatus,Vm as EnvelopeType,Dl as EventTokenType,Mp as FodderSelectionMode,Pp as FodderValuationMode,qh as FriendActionStatus,he as GameLoopAction,kr as IDosGamesClient,Os as ItemAction,fc as KycStatus,Rc as KycTier,fe as LeaderboardAction,Gs as LootboxAction,If as MailboxMessageSource,Tf as MailboxMessageStatus,Ps as MarketGoodsType,ap as MarketOfferStatus,op as MarketOfferType,re as MarketplaceAction,je as MatchAction,_c as MatchStatus,we as MultiplayerAction,Nm as MultiplayerChatMode,Gm as MultiplayerTopology,nt as PremiumAction,Le as QuestAction,jl as QuestObjectiveSource,Vl as QuestPrerequisiteMode,Ll as QuestStatus,sm as RaidMode,ft as ReferralAction,xl as ResourceEntryType,Ke as RewardAction,jm as RoomVisibility,bl as ScheduleMode,it as SeasonAction,Ve as SocialAction,rm as SpecialChoiceMode,dt as StoreAction,qd as StoreType,ot as TimedBoostAction,Nh as TimedBoostStackingPolicy,Be as TimedEventAction,Eh as TimelineEventType,at as TitleAction,vt as TitleCustomDataAction,Jh as TitleDataBucket,Zh as TitleDataScope,_d as TradeOfferStatus,Sc as TransactionDirection,yt as TypedEmitter,Oe as UserAction,Ge as UserCustomDataAction,dc as WalletLinkType,rf as createIDosGamesClient,Sl as isFail,Cl as isOk,Ds as normalizeBlockchainCategory};
|